Type Editor / @type-editor/util / find-parent
find-parent
Functions
| Function | Description |
|---|---|
Finds the deepest common ancestor node that contains both ends of the selection. For a collapsed selection or when both ends share the same parent, returns that immediate parent. For selections spanning multiple nodes, traverses upward to find the first ancestor that contains both endpoints. Example typescript | |
Finds the nearest ancestor node in the document tree that satisfies the given predicate. The search starts from the common parent of the selection and traverses upward through the document hierarchy until a matching node is found or the root is reached. Example typescript | |
Finds the nearest ancestor node of a specific type. This is a convenience wrapper around findParent that matches nodes by their type. Example typescript |