getNode
getNode(
snapshot,path): {node:Node;path:Path; } |undefined
Defined in: get-node.ts:36
Get the node at a given path.
The path can be either keyed (KeyedSegment + field name strings) or
indexed (numbers). Keyed segments are resolved by matching _key,
field name strings name a structural descent into the previous
node’s children, and numbers are resolved by index.
The returned path always identifies the returned node: segments
are keyed wherever the node has a usable _key (numeric indices are
converted to KeyedSegments), and stay numeric for nodes
normalization has not keyed yet (a {_key: undefined} segment would
not distinguish keyless siblings). Any trailing segments in the
input that point outside the value tree — e.g. an object node’s
primitive field, or an annotation reached via 'markDefs' on a text
block — are stripped so that
getNode(snapshot, entry.path).node === entry.node.
The walk stops when a string segment names a field that isn’t the
current node’s structural child array. Annotations live in
markDefs on a text block, alongside children rather than inside
it, so getNode resolves an annotation path to the enclosing text
block. Use getAnnotation to resolve the annotation itself.
Parameters
Section titled “Parameters”snapshot
Section titled “snapshot”TraversalSnapshot
Path
Returns
Section titled “Returns”{ node: Node; path: Path; } | undefined