UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

29 lines 1.8 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import { pluginFactory } from '@atlaskit/editor-common/utils'; import { pluginKey as tablePluginKey } from '../plugin-key'; import { pluginKey } from './plugin-key'; import reducer from './reducer'; var _pluginFactory = pluginFactory(pluginKey, reducer, { mapping: function mapping(tr, pluginState) { if (tr.docChanged) { var decorationSet = pluginState.decorationSet; var meta = tr.getMeta(tablePluginKey); if (meta && meta.data && meta.data.decorationSet) { decorationSet = meta.data.decorationSet; } if (decorationSet) { decorationSet = decorationSet.map(tr.mapping, tr.doc); } return _objectSpread(_objectSpread({}, pluginState), { decorationSet: decorationSet }); } return pluginState; } }), createPluginState = _pluginFactory.createPluginState, createCommand = _pluginFactory.createCommand, getPluginState = _pluginFactory.getPluginState; export { createPluginState, createCommand, getPluginState };