UNPKG

@atlaskit/editor-plugin-table

Version:

Table plugin for the @atlaskit/editor

36 lines (34 loc) 1.27 kB
import { AnalyticPluginTypes } from './actions'; import { createCommand, getPluginState } from './plugin-factory'; import { pluginKey } from './plugin-key'; // eslint-disable-next-line import/order import { getMovedPayload } from './utils/moved-event'; // eslint-disable-next-line import/order export const updateRowOrColumnMoved = (nextState, nextAction) => createCommand(state => { const { rowOrColumnMoved } = getPluginState(state); const data = getMovedPayload(nextState, nextAction, rowOrColumnMoved); return { type: AnalyticPluginTypes.UpdateRowOrColumnMovedAction, data }; }, tr => tr.setMeta('addToHistory', false)); // --- transforms, prefer these over commands to avoid an extra 'dispatch' export const resetRowOrColumnMovedTransform = () => tr => { const payload = { type: AnalyticPluginTypes.RemoveRowOrColumnMovedAction }; return tr.setMeta(pluginKey, payload); }; export const updateRowOrColumnMovedTransform = (nextState, nextAction) => (state, tr) => { const { rowOrColumnMoved } = getPluginState(state); const data = getMovedPayload(nextState, nextAction, rowOrColumnMoved); const payload = { type: AnalyticPluginTypes.UpdateRowOrColumnMovedAction, data }; return tr.setMeta(pluginKey, payload); };