UNPKG

@atlaskit/editor-plugin-decorations

Version:

Decorations plugin for @atlaskit/editor-core

45 lines (44 loc) 1.31 kB
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: function hoverDecoration(_ref) { var add = _ref.add, className = _ref.className; return hoverDecorationCommand({ add: add, className: className }); }, removeDecoration: function removeDecoration() { return removeDecorationCommand(); } } }; };