UNPKG

@atlaskit/editor-plugin-unsupported-content

Version:

Unsupported Content plugin for @atlaskit/editor-core

105 lines (103 loc) • 5.28 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.unsupportedContentPlugin = void 0; var _confluenceUnsupportedBlock = require("@atlaskit/adf-schema/confluence-unsupported-block"); var _confluenceUnsupportedInline = require("@atlaskit/adf-schema/confluence-unsupported-inline"); var _unsupportedBlock = require("@atlaskit/adf-schema/unsupported-block"); var _unsupportedInline = require("@atlaskit/adf-schema/unsupported-inline"); var _unsupportedMark = require("@atlaskit/adf-schema/unsupported-mark"); var _unsupportedNodeAttributes = require("@atlaskit/adf-schema/unsupported-node-attributes"); var _getInlineNodeViewProducer = require("@atlaskit/editor-common/getInlineNodeViewProducer"); var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view")); var _safePlugin = require("@atlaskit/editor-common/safe-plugin"); var _UnsupportedBlock = _interopRequireDefault(require("@atlaskit/editor-common/UnsupportedBlock")); var _state = require("@atlaskit/editor-prosemirror/state"); var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled"); var _unsupportedBlockNodeView = require("./nodeviews/unsupported-block-node-view"); var _unsupportedInlineNodeView = require("./nodeviews/unsupported-inline-node-view"); var _unsupportedInlineNodeViewVanilla = require("./nodeviews/unsupported-inline-node-view-vanilla"); var pluginKey = new _state.PluginKey('unsupportedContentPlugin'); var createPlugin = function createPlugin(pmPluginFactoryParams) { var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI, eventDispatcher = pmPluginFactoryParams.eventDispatcher, dispatchAnalyticsEvent = pmPluginFactoryParams.dispatchAnalyticsEvent, getIntl = pmPluginFactoryParams.getIntl; var intl = getIntl(); return new _safePlugin.SafePlugin({ key: pluginKey, props: { nodeViews: { confluenceUnsupportedBlock: (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_vanilla_node_views_phase1') ? function (node) { return new _unsupportedBlockNodeView.UnsupportedBlockNodeView(node, intl, dispatchAnalyticsEvent); } : _reactNodeView.default.fromComponent(_UnsupportedBlock.default, portalProviderAPI, eventDispatcher, { dispatchAnalyticsEvent: dispatchAnalyticsEvent }, undefined), confluenceUnsupportedInline: (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_vanilla_node_views_phase1') ? function (node) { return new _unsupportedInlineNodeViewVanilla.UnsupportedInlineNodeViewVanilla(node, intl, dispatchAnalyticsEvent); } : (0, _getInlineNodeViewProducer.getInlineNodeViewProducer)({ pmPluginFactoryParams: pmPluginFactoryParams, Component: _unsupportedInlineNodeView.UnsupportedInlineNodeView, extraComponentProps: { dispatchAnalyticsEvent: dispatchAnalyticsEvent } }), unsupportedBlock: (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_vanilla_node_views_phase1') ? function (node) { return new _unsupportedBlockNodeView.UnsupportedBlockNodeView(node, intl, dispatchAnalyticsEvent); } : _reactNodeView.default.fromComponent(_UnsupportedBlock.default, portalProviderAPI, eventDispatcher, { dispatchAnalyticsEvent: dispatchAnalyticsEvent }, undefined), unsupportedInline: (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_vanilla_node_views_phase1') ? function (node) { return new _unsupportedInlineNodeViewVanilla.UnsupportedInlineNodeViewVanilla(node, intl, dispatchAnalyticsEvent); } : (0, _getInlineNodeViewProducer.getInlineNodeViewProducer)({ pmPluginFactoryParams: pmPluginFactoryParams, Component: _unsupportedInlineNodeView.UnsupportedInlineNodeView, extraComponentProps: { dispatchAnalyticsEvent: dispatchAnalyticsEvent } }) } } }); }; /** * Unsupported content plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor` * from `@atlaskit/editor-core`. */ var unsupportedContentPlugin = exports.unsupportedContentPlugin = function unsupportedContentPlugin() { return { name: 'unsupportedContent', marks: function marks() { return [{ name: 'unsupportedMark', mark: _unsupportedMark.unsupportedMark }, { name: 'unsupportedNodeAttribute', mark: _unsupportedNodeAttributes.unsupportedNodeAttribute }]; }, nodes: function nodes() { return [{ name: 'confluenceUnsupportedBlock', node: _confluenceUnsupportedBlock.confluenceUnsupportedBlock }, { name: 'confluenceUnsupportedInline', node: _confluenceUnsupportedInline.confluenceUnsupportedInline }, { name: 'unsupportedBlock', node: _unsupportedBlock.unsupportedBlock }, { name: 'unsupportedInline', node: _unsupportedInline.unsupportedInline }]; }, pmPlugins: function pmPlugins() { return [{ name: 'unsupportedContent', plugin: createPlugin }]; } }; };