@atlaskit/editor-plugin-floating-toolbar
Version:
Floating toolbar plugin for @atlaskit/editor-core
9 lines (8 loc) • 658 B
JavaScript
import { useSyncExternalStore } from 'react';
const emptySnapshot = () => 0;
const emptySubscription = () => () => {};
/** Refresh toolbar content when its optional external store changes. */
export const useToolbarExternalStore = store => {
var _store$subscribe, _store$getSnapshot;
useSyncExternalStore((_store$subscribe = store === null || store === void 0 ? void 0 : store.subscribe) !== null && _store$subscribe !== void 0 ? _store$subscribe : emptySubscription, (_store$getSnapshot = store === null || store === void 0 ? void 0 : store.getSnapshot) !== null && _store$getSnapshot !== void 0 ? _store$getSnapshot : emptySnapshot, emptySnapshot);
};