Type Editor / @type-editor/tables / copypaste/clip-cells / clipCells
Function: clipCells()
ts
function clipCells(area, newWidth, newHeight): Area;Defined in: tables/src/copypaste/clip-cells.ts:30
Clips or extends (repeats) a set of cells to cover the given dimensions.
This function adjusts the cell area to match the target width and height:
- If the area is smaller, cells are repeated to fill the space
- If the area is larger, cells are clipped
- Cells with rowspan/colspan that extend beyond boundaries are trimmed
Parameters
| Parameter | Type | Description |
|---|---|---|
area | Area | The original area containing width, height, and rows. |
newWidth | number | The target width (number of columns). |
newHeight | number | The target height (number of rows). |
Returns
A new Area with the adjusted dimensions.
Example
typescript
// Clip a 3x3 area to 2x2
const clipped = clipCells(originalArea, 2, 2);
// Extend a 2x2 area to 4x4 by repeating
const extended = clipCells(originalArea, 4, 4);