Skip to content

Type Editor


Type Editor / @type-editor/tables / utils/add-col-span / addColSpan

Function: addColSpan()

ts
function addColSpan(attrs, pos, n?): Attrs;

Defined in: tables/src/utils/add-col-span.ts:25

Creates new cell attributes with increased colspan.

Adds the specified number of columns to the cell's span, inserting zeros at the specified position in the colwidth array if it exists.

Parameters

ParameterTypeDefault valueDescription
attrsCellAttrsundefinedThe current cell attributes.
posnumberundefinedThe position within the colwidth array to insert at.
nnumber1The number of columns to add. Defaults to 1.

Returns

Attrs

A new attributes object with the updated colspan and colwidth.

Example

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