UNPKG

@atlaskit/editor-plugin-local-id

Version:

LocalId plugin for @atlaskit/editor-core

43 lines (42 loc) 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.localIdPlugin = void 0; var _platformFeatureFlags = require("@atlaskit/platform-feature-flags"); var _editorActions = require("./editor-actions"); var _main = require("./pm-plugins/main"); var _watchmen = require("./pm-plugins/watchmen"); var localIdPlugin = exports.localIdPlugin = function localIdPlugin(_ref) { var api = _ref.api; return { name: 'localId', actions: { replaceNode: (0, _editorActions.replaceNode)(api), getNode: (0, _editorActions.getNode)(api) }, pmPlugins: function pmPlugins() { return [{ name: 'localIdPlugin', plugin: function plugin() { return (0, _main.createPlugin)(api); } }, { name: 'localId-watchmen', plugin: function plugin() { return (0, _platformFeatureFlags.fg)('platform_editor_ai_aifc_localid_error_reporting') ? (0, _watchmen.createWatchmenPlugin)(api) : undefined; } }]; }, getSharedState: function getSharedState(editorState) { if (!editorState) { return undefined; } var watchmentPluginState = _watchmen.localIdWatchmenPluginKey.getState(editorState); return { localIdWatchmenEnabled: !!(watchmentPluginState !== null && watchmentPluginState !== void 0 && watchmentPluginState.enabled), localIdStatus: new Map(watchmentPluginState === null || watchmentPluginState === void 0 ? void 0 : watchmentPluginState.localIdStatus) }; } }; };