UNPKG

@atlaskit/editor-plugin-primary-toolbar

Version:

Primary toolbar plugin for @atlaskit/editor-core

43 lines (41 loc) 1.66 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.primaryToolbarPlugin = void 0; var _actions = require("./editor-actions/actions"); var _pmPlugin = require("./pm-plugins/pm-plugin"); var _separator = _interopRequireDefault(require("./ui/separator")); var primaryToolbarPlugin = exports.primaryToolbarPlugin = function primaryToolbarPlugin(_ref) { var config = _ref.config; // We use a plugin variable to store the component registry to avoid having to use // effects in each plugin, and to enable rendering the toolbar in SSR // TODO: ED-26962 - Replace this with something in plugin state once we have a way to initialise across plugins on plugin initialisation var componentRegistry = new Map(); // Pre-fill registry with the separator component componentRegistry.set('separator', _separator.default); return { name: 'primaryToolbar', actions: { registerComponent: (0, _actions.registerComponent)(componentRegistry) }, pmPlugins: function pmPlugins() { return [{ name: 'primaryToolbar', plugin: function plugin() { return (0, _pmPlugin.createPlugin)({ componentRegistry: componentRegistry, contextualFormattingEnabled: config === null || config === void 0 ? void 0 : config.contextualFormattingEnabled }); } }]; }, getSharedState: function getSharedState(editorState) { if (!editorState) { return; } return _pmPlugin.primaryToolbarPluginKey.getState(editorState); } }; };