UNPKG

@atlaskit/editor-plugin-media

Version:

Media plugin for @atlaskit/editor-core

31 lines 1.15 kB
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin'; import { pluginFactory, pmHistoryPluginKey } from '@atlaskit/editor-common/utils'; // eslint-disable-next-line @typescript-eslint/consistent-type-imports import { PluginKey } from '@atlaskit/editor-prosemirror/state'; import reducer from './reducer'; var pluginKey = new PluginKey('mediaAltTextPlugin'); var dest = pluginFactory(pluginKey, reducer, { onSelectionChanged: function onSelectionChanged(tr, newState) { // dont close alt text for undo/redo transactions (if it comes from prosemirror-history) if (tr.getMeta(pmHistoryPluginKey)) { return newState; } return { isAltTextEditorOpen: false }; } }); var createPluginState = dest.createPluginState; var createCommand = dest.createCommand; var getPluginState = dest.getPluginState; export var createPlugin = function createPlugin(_ref) { var dispatch = _ref.dispatch, providerFactory = _ref.providerFactory; return new SafePlugin({ state: createPluginState(dispatch, { isAltTextEditorOpen: false }), key: pluginKey }); }; export { createCommand, getPluginState };