UNPKG

@atlaskit/editor-plugin-media-insert

Version:

Media Insert plugin for @atlaskit/editor-core

38 lines (37 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createPlugin = void 0; var _safePlugin = require("@atlaskit/editor-common/safe-plugin"); var _actions = require("./actions"); var _pluginKey = require("./plugin-key"); var createPlugin = exports.createPlugin = function createPlugin() { return new _safePlugin.SafePlugin({ state: { init: function init() { return { isOpen: false, mountInfo: undefined }; }, apply: function apply(tr, mediaInsertPluginState) { var meta = tr.getMeta(_pluginKey.pluginKey); switch (meta === null || meta === void 0 ? void 0 : meta.type) { case _actions.ACTION_OPEN_POPUP: return { isOpen: true, mountInfo: meta.mountInfo }; case _actions.ACTION_CLOSE_POPUP: return { isOpen: false }; default: return mediaInsertPluginState; } } }, key: _pluginKey.pluginKey }); };