(editor: Editable)
| 11 | const EDITOR_TO_TOOLBAR_STORE = new WeakMap<Editable, UseBoundStore<StoreApi<ToolbarState>>>() |
| 12 | |
| 13 | const getStore = (editor: Editable) => { |
| 14 | let store = EDITOR_TO_TOOLBAR_STORE.get(editor) |
| 15 | if (!store) { |
| 16 | store = create<ToolbarState>(() => ({ |
| 17 | items: [], |
| 18 | })) |
| 19 | EDITOR_TO_TOOLBAR_STORE.set(editor, store) |
| 20 | } |
| 21 | return store |
| 22 | } |
| 23 | |
| 24 | export const useToolbarStore = (editor: Editable) => { |
| 25 | return React.useMemo(() => getStore(editor), [editor]) |
no test coverage detected
searching dependent graphs…