Type Editor / @type-editor/tables / utils/query / findCellPos
Function: findCellPos()
ts
function findCellPos(doc, pos): ResolvedPos;Defined in: tables/src/utils/query.ts:187
Finds the resolved position of a table cell at or near the given document position.
This function first attempts to find a cell that directly contains the position using cellAround. If no containing cell is found, it searches for a nearby cell using cellNear.
Parameters
| Parameter | Type | Description |
|---|---|---|
doc | Node_2 | The document node to search within. |
pos | number | The document position to search from. |
Returns
ResolvedPos
The resolved position pointing to the cell, or undefined if no cell is found at or near the position.
Example
typescript
const $cell = findCellPos(state.doc, clickPosition);
if ($cell) {
console.log("Found cell at position:", $cell.pos);
console.log("Cell node:", $cell.nodeAfter);
}