UNPKG

@atlaskit/editor-plugin-decorations

Version:

Decorations plugin for @atlaskit/editor-core

53 lines (52 loc) 2.32 kB
"use strict"; var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.decorationsPlugin = void 0; var _experiments = require("@atlaskit/tmp-editor-statsig/experiments"); var _commands = require("./pm-plugins/commands"); var _main = _interopRequireWildcard(require("./pm-plugins/main")); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); } /** * Decorations plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor` * from `@atlaskit/editor-core`. */ var decorationsPlugin = exports.decorationsPlugin = function decorationsPlugin() { return { name: 'decorations', pmPlugins: function pmPlugins() { return [{ name: 'decorationPlugin', plugin: function plugin() { return (0, _main.default)(); } }]; }, actions: { hoverDecoration: _main.hoverDecoration, removeDecoration: _main.removeDecoration }, getSharedState: function getSharedState(editorState) { if (!editorState) { return { decoration: undefined }; } return _main.decorationStateKey.getState(editorState); }, commands: { hoverDecoration: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? function (_ref) { var add = _ref.add, className = _ref.className; return (0, _commands.hoverDecorationCommand)({ add: add, className: className }); } : undefined, removeDecoration: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? function () { return (0, _commands.removeDecorationCommand)(); } : undefined } }; };