Nodes are the building blocks of Plate documents. It can either be the Editor root node (highest), an Element node, or a Text node (lowest). This API provides utilities for interacting with nodes, including traversing, querying, and extracting data.
type TNode = Editor | TElement | TText;
type Descendant = Element | Text
type Ancestor = Editor | Element
NodeAPI
ancestor
Get the node at a specific path, asserting that it's an ancestor node.
ancestors
Return a generator of all the ancestor nodes above a specific path.
child
Get the child of a node at a specific index.
children
Iterate over the children of a node at a specific path.
common
Get an entry for the common ancestor node of two paths.
descendant
Get the node at a specific path, asserting that it's a descendant node.
descendants
Return a generator of all the descendant node entries inside a root node.
elements
Return a generator of all the element nodes inside a root node.
first
Get the first node entry in a root node from a path.
firstChild
Get the first child node entry of a node.
firstText
Get the first text node entry of a node.
fragment
Get the sliced fragment represented by a range inside a root node.
get
Get the descendant node referred to by a specific path.
last
Get the last node entry in a root node from a path.
lastChild
Get the last child node entry of a node.
leaf
Get the node at a specific path, ensuring it's a leaf text node.
levels
Return a generator of the in a branch of the tree, from a specific path.
nodes
Return a generator of all the node entries of a root node.
parent
Get the parent of a node at a specific path.
texts
Return a generator of all leaf text nodes in a root node.
extractProps
Get the props of a node.
has
Check if a descendant node exists at a specific path.
hasSingleChild
Check if a node has a single child.
isAncestor
Check if a value implements the Ancestor
interface.
isDescendant
Check if a value implements the Descendant
interface.
isLastChild
Check if a node is the last child of its parent.
isNode
Check if a value implements the TNode
interface.
isNodeList
Check if a value is a list of Descendant
objects.
matches
Check if a node matches a set of props.
string
Get the concatenated text string of a node's content.
Types
TNode
Node
is a type alias for TNode
.
type TNode = Editor | TElement | TText;
NodeEntry
NodeEntry
objects are returned when iterating over the nodes in a Plate document tree. They consist of an array with two elements: the TNode
and its Path
relative to the root node in the document.
Descendant
The Descendant
union type represents nodes that are descendants in the tree.
type Descendant = TElement | TText;
Ancestor
The Ancestor
union type represents nodes that are ancestors in the tree.
type Ancestor = Editor | TElement;
NodeOf<N>
NodeIn<V>
TNodeMatch<N>
DescendantOf<N>
DescendantIn<V>
ChildOf<N>
AncestorOf<N>
AncestorIn<V>
AncestorEntry
Ancestor entries represent an ancestor node (Editor or Element) and its path.
DescendantEntry
Descendant entries represent a descendant node (Element or Text) and its path.
NodeChildEntry
Node child entries represent a child node and its path relative to its parent.
On This Page
NodeAPI
ancestor
ancestors
child
children
common
descendant
descendants
elements
first
firstChild
firstText
fragment
get
last
lastChild
leaf
levels
nodes
parent
texts
extractProps
has
hasSingleChild
isAncestor
isDescendant
isLastChild
isNode
isNodeList
matches
string
TypesTNode
NodeEntry
Descendant
Ancestor
NodeOf<N>
NodeIn<V>
TNodeMatch<N>
DescendantOf<N>
DescendantIn<V>
ChildOf<N>
AncestorOf<N>
AncestorIn<V>
AncestorEntry
DescendantEntry
NodeChildEntry