Skip to content

Type Editor


Type Editor / @type-editor/tables / utils/get-cells / getCellsInRow

Function: getCellsInRow()

ts
function getCellsInRow(rowIndex, selection): FindNodeResult[];

Defined in: tables/src/utils/get-cells.ts:102

Returns an array of cells in a row at the specified row index.

This function locates the table containing the current selection and retrieves all cells that belong to the specified row. The returned cells include their positions and node references for further manipulation.

Parameters

ParameterTypeDescription
rowIndexnumberThe zero-based index of the row to retrieve cells from. Must be within the valid range [0, tableHeight - 1].
selectionPmSelectionThe current editor selection, used to locate the table context.

Returns

FindNodeResult[]

An array of cell information objects if the row exists, or undefined if no table is found or the row index is out of bounds.

Example

typescript
const cells = getCellsInRow(0, editorState.selection);
if (cells) {
  cells.forEach((cell) => console.log(cell.node.textContent));
}