@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
25 lines • 1.28 kB
JavaScript
import { pluginKey } from '../plugin-key';
import { deleteColumns } from '../transforms/delete-columns';
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
export var deleteColumnsCommand = function deleteColumnsCommand(rect, api) {
var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var isTableFixedColumnWidthsOptionEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var shouldUseIncreasedScalingPercent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var isCommentEditor = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
return function (state, dispatch, view) {
var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), api, view, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(state.tr);
// If we delete a column we should also clean up the hover selection
tr.setMeta(pluginKey, {
type: 'CLEAR_HOVER_SELECTION',
data: {
isInDanger: false,
isWholeTableInDanger: false
}
});
if (dispatch) {
dispatch(tr);
return true;
}
return false;
};
};