UNPKG

@atlaskit/editor-plugin-unsupported-content

Version:

Unsupported Content plugin for @atlaskit/editor-core

79 lines (78 loc) 2.96 kB
import { confluenceUnsupportedBlock, confluenceUnsupportedInline, unsupportedBlock, unsupportedInline, unsupportedMark, unsupportedNodeAttribute } from '@atlaskit/adf-schema'; import ReactNodeView, { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view'; import { SafePlugin } from '@atlaskit/editor-common/safe-plugin'; import { UnsupportedBlock } from '@atlaskit/editor-common/ui'; import { PluginKey } from '@atlaskit/editor-prosemirror/state'; import { UnsupportedInlineNodeView } from './nodeviews/unsupported-inline-node-view'; var pluginKey = new PluginKey('unsupportedContentPlugin'); var createPlugin = function createPlugin(pmPluginFactoryParams) { var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI, eventDispatcher = pmPluginFactoryParams.eventDispatcher, dispatchAnalyticsEvent = pmPluginFactoryParams.dispatchAnalyticsEvent; return new SafePlugin({ key: pluginKey, props: { nodeViews: { confluenceUnsupportedBlock: ReactNodeView.fromComponent(UnsupportedBlock, portalProviderAPI, eventDispatcher, { dispatchAnalyticsEvent: dispatchAnalyticsEvent }, undefined), confluenceUnsupportedInline: getInlineNodeViewProducer({ pmPluginFactoryParams: pmPluginFactoryParams, Component: UnsupportedInlineNodeView, extraComponentProps: { dispatchAnalyticsEvent: dispatchAnalyticsEvent } }), unsupportedBlock: ReactNodeView.fromComponent(UnsupportedBlock, portalProviderAPI, eventDispatcher, { dispatchAnalyticsEvent: dispatchAnalyticsEvent }, undefined), unsupportedInline: getInlineNodeViewProducer({ pmPluginFactoryParams: pmPluginFactoryParams, Component: UnsupportedInlineNodeView, extraComponentProps: { dispatchAnalyticsEvent: dispatchAnalyticsEvent } }) } } }); }; /** * Unsupported content plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor` * from `@atlaskit/editor-core`. */ export var unsupportedContentPlugin = function unsupportedContentPlugin() { return { name: 'unsupportedContent', marks: function marks() { return [{ name: 'unsupportedMark', mark: unsupportedMark }, { name: 'unsupportedNodeAttribute', mark: unsupportedNodeAttribute }]; }, nodes: function nodes() { return [{ name: 'confluenceUnsupportedBlock', node: confluenceUnsupportedBlock }, { name: 'confluenceUnsupportedInline', node: confluenceUnsupportedInline }, { name: 'unsupportedBlock', node: unsupportedBlock }, { name: 'unsupportedInline', node: unsupportedInline }]; }, pmPlugins: function pmPlugins() { return [{ name: 'unsupportedContent', plugin: createPlugin }]; } }; };