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
| Parameter | Type | Description |
|---|---|---|
rowIndex | number | The zero-based index of the row to retrieve cells from. Must be within the valid range [0, tableHeight - 1]. |
selection | PmSelection | The current editor selection, used to locate the table context. |
Returns
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));
}