UNPKG

@atlaskit/editor-plugin-paste

Version:

Paste plugin for @atlaskit/editor-core

48 lines (47 loc) 2.19 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.updateContentMoved = exports.resetContentMovedTransform = exports.resetContentMoved = void 0; var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); var _actions = require("./actions"); var _pluginFactory = require("./plugin-factory"); var _pluginKey = require("./plugin-key"); var updateContentMoved = exports.updateContentMoved = function updateContentMoved(nextState, nextAction) { return (0, _pluginFactory.createCommand)(function (state) { var _getPluginState = (0, _pluginFactory.getPluginState)(state), contentMoved = _getPluginState.contentMoved; var data = { currentActions: [].concat((0, _toConsumableArray2.default)(contentMoved.currentActions), [nextAction]), size: (nextState === null || nextState === void 0 ? void 0 : nextState.size) || contentMoved.size, nodeName: nextState === null || nextState === void 0 ? void 0 : nextState.nodeName, nodeDepth: nextState === null || nextState === void 0 ? void 0 : nextState.nodeDepth, nodeTypes: nextState === null || nextState === void 0 ? void 0 : nextState.nodeTypes, hasSelectedMultipleNodes: nextState === null || nextState === void 0 ? void 0 : nextState.hasSelectedMultipleNodes }; return { type: _actions.MoveAnalyticPluginTypes.UpdateMovedAction, data: data }; }, function (tr) { return tr.setMeta('addToHistory', false); }); }; var resetContentMoved = exports.resetContentMoved = function resetContentMoved() { return (0, _pluginFactory.createCommand)(function () { return { type: _actions.MoveAnalyticPluginTypes.RemoveMovedAction }; }, function (tr) { return tr.setMeta('addToHistory', false); }); }; var resetContentMovedTransform = exports.resetContentMovedTransform = function resetContentMovedTransform() { return function (tr) { var payload = { type: _actions.MoveAnalyticPluginTypes.RemoveMovedAction }; return tr.setMeta(_pluginKey.pluginKey, payload); }; };