@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
32 lines • 1.87 kB
JavaScript
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 { DragAndDropActionType } from './actions';
import { DropTargetType } from './consts';
export default (function (pluginState, action) {
switch (action.type) {
case DragAndDropActionType.SET_DROP_TARGET:
return _objectSpread(_objectSpread({}, pluginState), {}, {
decorationSet: action.data.decorationSet,
dropTargetType: action.data.type,
dropTargetIndex: action.data.index,
isDragging: true
});
case DragAndDropActionType.CLEAR_DROP_TARGET:
return _objectSpread(_objectSpread({}, pluginState), {}, {
decorationSet: action.data.decorationSet,
dropTargetType: DropTargetType.NONE,
dropTargetIndex: 0,
isDragging: false
});
case DragAndDropActionType.TOGGLE_DRAG_MENU:
return _objectSpread(_objectSpread({}, pluginState), {}, {
isDragMenuOpen: action.data.isDragMenuOpen,
dragMenuDirection: action.data.direction,
dragMenuIndex: action.data.index,
isKeyboardModeActive: action.data.isKeyboardModeActive
});
default:
return pluginState;
}
});