@atlaskit/editor-plugin-width
Version:
Width plugin for @atlaskit/editor-core
25 lines • 695 B
JavaScript
import { createPlugin } from './pm-plugins/main';
import { pluginKey } from './pm-plugins/plugin-key';
import { useResizeWidthObserver } from './ui/hooks/useResizeWidthObserver';
/**
* Width plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
* from `@atlaskit/editor-core`.
*/
export const widthPlugin = () => {
return {
name: 'width',
pmPlugins: () => [{
name: 'width',
plugin: ({
dispatch
}) => createPlugin(dispatch)
}],
getSharedState: editorState => {
if (!editorState) {
return undefined;
}
return pluginKey.getState(editorState);
},
usePluginHook: useResizeWidthObserver
};
};