UNPKG

@atlaskit/editor-plugin-panel

Version:

Panel plugin for @atlaskit/editor-core.

32 lines 1.5 kB
import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel'; import { SafePlugin } from '@atlaskit/editor-common/safe-plugin'; import { createSelectionClickHandler } from '@atlaskit/editor-common/selection'; import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals'; 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), ...(expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? { panel_c1: getPanelNodeView(pluginOptions, api, nodeViewPortalProviderAPI, providerFactory) } : {}) }, handleClickOn: createSelectionClickHandler(expValEquals('platform_editor_nest_table_in_panel', 'isEnabled', true) ? ['panel', 'panel_c1'] : ['panel'], target => !!target.closest(`.${PanelSharedCssClassName.prefix}`), { useLongPressSelection }) } }); };