getEnclosingBlock
Call Signature
Section titled “Call Signature”getEnclosingBlock<
TMatch>(snapshot,path,options): {node:TMatch;path:Path; } |undefined
Defined in: get-enclosing-block.ts:25
Walk up from a path to find the nearest enclosing block.
Returns the node at the path if it is a block, otherwise the first ancestor that is a block. Works at any depth — inside a container this returns the container-internal block, not the outer container.
With match, returns the first enclosing block that also satisfies the
predicate. When match is a type predicate, the returned node narrows
to that type.
mode: 'lowest' (default) returns the innermost enclosing block; the node
at the path itself counts. mode: 'highest' returns the outermost
ancestor that matches, falling back to the node at the path only if no
ancestor does.
Type Parameters
Section titled “Type Parameters”TMatch
Section titled “TMatch”TMatch extends PortableTextBlock
Parameters
Section titled “Parameters”snapshot
Section titled “snapshot”TraversalSnapshot
Path
options
Section titled “options”(node, path) => node is TMatch
"lowest" | "highest"
Returns
Section titled “Returns”{ node: TMatch; path: Path; } | undefined
Call Signature
Section titled “Call Signature”getEnclosingBlock(
snapshot,path,options?): {node:PortableTextBlock;path:Path; } |undefined
Defined in: get-enclosing-block.ts:36
Parameters
Section titled “Parameters”snapshot
Section titled “snapshot”TraversalSnapshot
Path
options?
Section titled “options?”match?
Section titled “match?”(node, path) => boolean
"lowest" | "highest"
Returns
Section titled “Returns”{ node: PortableTextBlock; path: Path; } | undefined