Skip to content

Type Editor


Type Editor / @type-editor/tables / copypaste/pasted-cells / pastedCells

Function: pastedCells()

ts
function pastedCells(slice): Area;

Defined in: tables/src/copypaste/pasted-cells.ts:38

Extracts a rectangular area of cells from a slice.

This function analyzes the content of a slice and, if it contains table cells or rows, extracts them into a normalized rectangular Area structure. The function handles partial selections by fitting them into complete rows.

Parameters

ParameterTypeDescription
sliceSliceThe slice to extract cells from, typically from a clipboard operation.

Returns

Area

A rectangular Area containing the cells, or null if the slice doesn't contain table cells or rows.

Example

typescript
const slice = view.state.doc.slice(from, to);
const cells = pastedCells(slice);
if (cells) {
  console.log(`Pasted ${cells.width}x${cells.height} cells`);
}