Skip to content

Type Editor


Type Editor / @type-editor/tables / utils/cell-near / cellNear

Function: cellNear()

ts
function cellNear($pos): ResolvedPos;

Defined in: tables/src/utils/cell-near.ts:24

Finds a cell near the given position by traversing adjacent nodes.

This function first looks forward through nodeAfter and its first children, then looks backward through nodeBefore and its last children. This is useful when the position is at a table boundary rather than inside a cell.

Parameters

ParameterTypeDescription
$posResolvedPosThe resolved position to search from.

Returns

ResolvedPos

The resolved position of the nearby cell, or undefined if none found.

Example

typescript
const $cell = cellNear($pos);
if ($cell) {
  console.log("Found cell near position");
}