UNPKG

@atlaskit/editor-plugin-width

Version:

Width plugin for @atlaskit/editor-core

31 lines • 1.02 kB
import { createPlugin } from './pm-plugins/main'; import { pluginKey } from './pm-plugins/plugin-key'; import { useWidthObserver } from './ui/hooks/useWidthObserver'; /** * Width plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor` * from `@atlaskit/editor-core`. */ export var widthPlugin = function widthPlugin() { return { name: 'width', pmPlugins: function pmPlugins() { return [{ name: 'width', plugin: function plugin(_ref) { var dispatch = _ref.dispatch; return createPlugin(dispatch); } }]; }, getSharedState: function getSharedState(editorState) { if (!editorState) { return undefined; } return pluginKey.getState(editorState); }, // Dispatches between the legacy hook and its replacement while // `platform_editor_reduce_forced_layout` runs. On cleanup, point this at the surviving // hook and delete `useWidthObserver`. usePluginHook: useWidthObserver }; };