Skip to main content

$getNearestNodeOfType

function

Takes a node and traverses up its ancestors (toward the root node) in order to find a specific type of node.

function $getNearestNodeOfType<T extends ElementNode>(node: LexicalNode, klass: Klass<T>): T | null

Import

import { $getNearestNodeOfType } from '@modular/sdk/editor';

Notes

returns
the node of type klass that was passed, or null if none exist.