Skip to content

Type Editor


Type Editor / @type-editor/tables / utils/next-cell / nextCell

Function: nextCell()

ts
function nextCell($pos, axis, dir): ResolvedPos;

Defined in: tables/src/utils/next-cell.ts:23

Finds the next cell in a given direction along an axis.

Navigates from the current cell position to find an adjacent cell, properly handling cells that span multiple rows or columns.

Parameters

ParameterTypeDescription
$posResolvedPosA resolved position pointing at or within a cell.
axis"horiz" | "vert"The axis to move along: 'horiz' for left/right, 'vert' for up/down.
dirnumberThe direction to move: positive for right/down, negative for left/up.

Returns

ResolvedPos

The resolved position of the next cell, or null if at the table boundary.

Example

typescript
const nextRight = nextCell($cellPos, "horiz", 1);
const nextUp = nextCell($cellPos, "vert", -1);