@atlaskit/editor-plugin-panel
Version:
Panel plugin for @atlaskit/editor-core.
31 lines • 1.35 kB
JavaScript
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 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: {
panel: getPanelNodeView(pluginOptions, api, nodeViewPortalProviderAPI, providerFactory)
},
handleClickOn: createSelectionClickHandler(['panel'], function (target) {
return !!target.closest(".".concat(PanelSharedCssClassName.prefix));
}, {
useLongPressSelection: useLongPressSelection
})
}
});
};