Skip to content

Type Editor


Type Editor / @type-editor/tables / utils/remove-col-span / removeColSpan

Function: removeColSpan()

ts
function removeColSpan(attrs, pos, n?): CellAttrs;

Defined in: tables/src/utils/remove-col-span.ts:23

Creates new cell attributes with reduced colspan.

Removes the specified number of columns from the cell's span, updating the colwidth array accordingly. If all remaining column widths are zero, the colwidth is set to null.

Parameters

ParameterTypeDefault valueDescription
attrsCellAttrsundefinedThe current cell attributes.
posnumberundefinedThe position within the colwidth array to start removing from.
nnumber1The number of columns to remove. Defaults to 1.

Returns

CellAttrs

A new CellAttrs object with the updated colspan and colwidth.

Example

typescript
const attrs = { colspan: 3, rowspan: 1, colwidth: [100, 200, 300] };
const newAttrs = removeColSpan(attrs, 1, 1);
// newAttrs = { colspan: 2, rowspan: 1, colwidth: [100, 300] }