This page is available as Markdown at /api/traversal/functions/getancestors.md. For the full documentation index, see /llms.txt, or the complete corpus at /llms-full.txt.
getAncestors
getAncestors(
snapshot,path):object[]
Defined in: get-ancestors.ts:26
Get all ancestors of the node at a given path, from nearest to furthest.
For a path like [{_key:‘t1’}, ‘rows’, {_key:‘r1’}, ‘cells’, {_key:‘c1’}], the ancestors are (nearest first): [{_key:‘t1’}, ‘rows’, {_key:‘r1’}] [{_key:‘t1’}]
Walks from root to the target in a single pass collecting each ancestor as it goes.
Every ancestor is a PortableTextBlock: only text blocks and object
nodes can contain children.
Parameters
Section titled “Parameters”snapshot
Section titled “snapshot”TraversalSnapshot
Path
Returns
Section titled “Returns”object[]