UNPKG

@atlaskit/editor-plugin-panel

Version:

Panel plugin for @atlaskit/editor-core.

28 lines 1.12 kB
import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel'; import { SafePlugin } from '@atlaskit/editor-common/safe-plugin'; import { createSelectionClickHandler } from '@atlaskit/editor-common/selection'; import { getPanelNodeView } from '../nodeviews/panel'; import { pluginKey } from '../panelPluginType'; import { handleCut } from './utils/utils'; export const createPlugin = (dispatch, providerFactory, pluginOptions, api, nodeViewPortalProviderAPI) => { const { useLongPressSelection = false } = pluginOptions; return new SafePlugin({ key: pluginKey, appendTransaction: (transactions, oldState, newState) => { const tr = transactions.find(tr => tr.getMeta('uiEvent') === 'cut'); if (tr) { return handleCut(newState, oldState); } }, props: { nodeViews: { panel: getPanelNodeView(pluginOptions, api, nodeViewPortalProviderAPI, providerFactory) }, handleClickOn: createSelectionClickHandler(['panel'], target => !!target.closest(`.${PanelSharedCssClassName.prefix}`), { useLongPressSelection }) } }); };