UNPKG

@atlaskit/editor-plugin-panel

Version:

Panel plugin for @atlaskit/editor-core.

37 lines 2.49 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } 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 var createPlugin = function createPlugin(dispatch, providerFactory, pluginOptions, api, nodeViewPortalProviderAPI) { var _pluginOptions$useLon = pluginOptions.useLongPressSelection, useLongPressSelection = _pluginOptions$useLon === void 0 ? false : _pluginOptions$useLon; return new SafePlugin({ key: pluginKey, appendTransaction: function appendTransaction(transactions, oldState, newState) { var tr = transactions.find(function (tr) { return tr.getMeta('uiEvent') === 'cut'; }); if (tr) { return handleCut(newState, oldState); } }, props: { nodeViews: _objectSpread({ 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'], function (target) { return !!target.closest(".".concat(PanelSharedCssClassName.prefix)); }, { useLongPressSelection: useLongPressSelection }) } }); };