UNPKG

@atlaskit/editor-plugin-insert-block

Version:

Insert block plugin for @atlaskit/editor-core

22 lines 629 B
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin'; import { PluginKey } from '@atlaskit/editor-prosemirror/state'; export const toggleInsertBlockPmKey = new PluginKey('toggleInsertBlockPmKey'); export const toggleInsertBlockPmPlugin = () => new SafePlugin({ key: toggleInsertBlockPmKey, state: { init() { return { showElementBrowser: false }; }, apply(tr, pluginState) { const meta = tr.getMeta(toggleInsertBlockPmKey); if (!meta) { return pluginState; } return { showElementBrowser: !pluginState.showElementBrowser }; } } });