@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
15 lines (14 loc) • 903 B
JavaScript
// Resize a given column by an amount from the current state
import { growColumn, shrinkColumn } from './resize-logic';
import { updateColgroup } from './resize-state';
export var resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
var scalePercent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1;
var resizeAmount = amount;
if (isTableScalingEnabled) {
resizeAmount = amount / scalePercent;
}
var newState = resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled, scalePercent);
return newState;
};