UNPKG

@atlaskit/editor-plugin-decorations

Version:

Decorations plugin for @atlaskit/editor-core

46 lines (45 loc) 1.49 kB
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments'; import { hoverDecorationCommand, removeDecorationCommand } from './pm-plugins/commands'; import decorationPlugin, { decorationStateKey, hoverDecoration, removeDecoration } from './pm-plugins/main'; /** * Decorations plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor` * from `@atlaskit/editor-core`. */ export var decorationsPlugin = function decorationsPlugin() { return { name: 'decorations', pmPlugins: function pmPlugins() { return [{ name: 'decorationPlugin', plugin: function plugin() { return decorationPlugin(); } }]; }, actions: { hoverDecoration: hoverDecoration, removeDecoration: removeDecoration }, getSharedState: function getSharedState(editorState) { if (!editorState) { return { decoration: undefined }; } return decorationStateKey.getState(editorState); }, commands: { hoverDecoration: editorExperiment('platform_editor_block_menu', true) ? function (_ref) { var add = _ref.add, className = _ref.className; return hoverDecorationCommand({ add: add, className: className }); } : undefined, removeDecoration: editorExperiment('platform_editor_block_menu', true) ? function () { return removeDecorationCommand(); } : undefined } }; };