@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
13 lines (12 loc) • 741 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 const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode, selectedColumns, isTableScalingEnabled = false, scalePercent = 1) => {
let resizeAmount = amount;
if (isTableScalingEnabled) {
resizeAmount = amount / scalePercent;
}
const newState = resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled, scalePercent);
return newState;
};