UNPKG

@atlaskit/editor-plugin-unsupported-content

Version:

Unsupported Content plugin for @atlaskit/editor-core

87 lines (85 loc) 3.87 kB
"use strict"; var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.unsupportedContentPlugin = void 0; var _adfSchema = require("@atlaskit/adf-schema"); var _reactNodeView = _interopRequireWildcard(require("@atlaskit/editor-common/react-node-view")); var _safePlugin = require("@atlaskit/editor-common/safe-plugin"); var _ui = require("@atlaskit/editor-common/ui"); var _state = require("@atlaskit/editor-prosemirror/state"); var _unsupportedInlineNodeView = require("./nodeviews/unsupported-inline-node-view"); 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); } var pluginKey = new _state.PluginKey('unsupportedContentPlugin'); var createPlugin = function createPlugin(pmPluginFactoryParams) { var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI, eventDispatcher = pmPluginFactoryParams.eventDispatcher, dispatchAnalyticsEvent = pmPluginFactoryParams.dispatchAnalyticsEvent; return new _safePlugin.SafePlugin({ key: pluginKey, props: { nodeViews: { confluenceUnsupportedBlock: _reactNodeView.default.fromComponent(_ui.UnsupportedBlock, portalProviderAPI, eventDispatcher, { dispatchAnalyticsEvent: dispatchAnalyticsEvent }, undefined), confluenceUnsupportedInline: (0, _reactNodeView.getInlineNodeViewProducer)({ pmPluginFactoryParams: pmPluginFactoryParams, Component: _unsupportedInlineNodeView.UnsupportedInlineNodeView, extraComponentProps: { dispatchAnalyticsEvent: dispatchAnalyticsEvent } }), unsupportedBlock: _reactNodeView.default.fromComponent(_ui.UnsupportedBlock, portalProviderAPI, eventDispatcher, { dispatchAnalyticsEvent: dispatchAnalyticsEvent }, undefined), unsupportedInline: (0, _reactNodeView.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: _adfSchema.unsupportedMark }, { name: 'unsupportedNodeAttribute', mark: _adfSchema.unsupportedNodeAttribute }]; }, nodes: function nodes() { return [{ name: 'confluenceUnsupportedBlock', node: _adfSchema.confluenceUnsupportedBlock }, { name: 'confluenceUnsupportedInline', node: _adfSchema.confluenceUnsupportedInline }, { name: 'unsupportedBlock', node: _adfSchema.unsupportedBlock }, { name: 'unsupportedInline', node: _adfSchema.unsupportedInline }]; }, pmPlugins: function pmPlugins() { return [{ name: 'unsupportedContent', plugin: createPlugin }]; } }; };