ReadonlyattrsAn object mapping attribute names to values. The kind of attributes allowed and required are determined by the node type.
ReadonlycontentA container holding the node's children.
ReadonlymarksThe marks (things like whether it is emphasized or part of a link) applied to this node.
ReadonlytextFor text nodes, this contains the node's text content.
ReadonlytypeThe type of node that this is.
The number of children that the node has.
The array of this node's child nodes.
Returns this node's first child, or null if there are no
children.
True when this node allows inline content.
True when this is an atom, i.e. when it does not have directly
editable content. This is usually the same as isLeaf, but can
be configured with the atom property
on a node's spec (typically used when the node is displayed as
an uneditable node view).
True when this is a block (non-inline node)
True when this is an inline node (a text node or a node that can appear among text).
True when this is a leaf node.
True when this is a text node.
True when this is a textblock node, a block node with inline content.
Returns this node's last child, or null if there are no
children.
The size of this node, as defined by the integer-based indexing scheme. For text nodes, this is the amount of characters. For other leaf nodes, it is one. For non-leaf nodes, it is the size of the content plus two (the start and end token).
Concatenates all the text nodes found in this fragment and its children.
Test whether the given node's content could be appended to this node. If that node is empty, this will only return true if there is at least one node type that can appear in both nodes (to avoid merging completely incompatible nodes).
Test whether replacing the range between from and to (by
child index) with the given replacement fragment (which defaults
to the empty fragment) would leave the node's content valid. You
can optionally pass start and end indices into the
replacement fragment.
Optionalreplacement: FragmentOptionalstart: numberOptionalend: numberTest whether replacing the range from to to (by index) with
a node of the given type would leave the node's content valid.
Optionalmarks: readonly Mark[]Check whether this node and its descendants conform to the schema, and raise an exception when they do not.
Get the child node at the given index. Raises an error when the index is out of range.
Find the (direct) child node after the given offset, if any, and return it along with its index and offset relative to this node.
Find the (direct) child node before the given offset, if any, and return it along with its index and offset relative to this node.
Get the content match in this node at the given index.
Create a new node with the same markup as this node, containing the given content (or empty, if no content is given).
Optionalcontent: null | FragmentCreate a copy of this node with only the content between the
given positions. If to is not given, it defaults to the end of
the node.
Optionalto: numberCall the given callback for every descendant node. Doesn't
descend into a node when the callback returns false.
Test whether two nodes represent the same piece of document.
Call f for every child node, passing the node, its offset
into this parent node, and its index.
Check whether this node's markup correspond to the given type, attributes, and marks.
Optionalattrs: null | AttrsOptionalmarks: readonly Mark[]Create a copy of this node, with the given set of marks instead of the node's own marks.
Get the child node at the given index, if it exists.
Find the node directly after the given position.
Invoke a callback for all descendant nodes recursively between the given two positions that are relative to start of this node's content. The callback is invoked with the node, its position relative to the original node (method receiver), its parent node, and its child index. When the callback returns false for a given node, that node's children will not be recursed over. The last parameter can be used to specify a starting position to count from.
OptionalstartPos: numberTest whether a given mark or mark type occurs in this document between the two given positions.
Replace the part of the document between the given positions with
the given slice. The slice must 'fit', meaning its open sides
must be able to connect to the surrounding content, and its
content nodes must be valid children for the node they are placed
into. If any of this is violated, an error of type
ReplaceError is thrown.
Resolve the given position in the document, returning an object with information about its context.
Compare the markup (type, attributes, and marks) of this node to
those of another. Returns true if both have the same markup.
Cut out the part of the document between the given positions, and
return it as a Slice object.
Optionalto: numberOptionalincludeParents: booleanGet all text between positions from and to. When
blockSeparator is given, it will be inserted to separate text
from different block nodes. If leafText is given, it'll be
inserted for every non-text leaf node encountered, otherwise
leafText will be used.
OptionalblockSeparator: null | stringOptionalleafText: null | string | ((leafNode: ProseMirrorNode) => string)Return a JSON-serializeable representation of this node.
Return a string representation of this node for debugging purposes.
This class represents a node in the tree that makes up a ProseMirror document. So a document is an instance of
Node, with children that are also instances ofNode.Nodes are persistent data structures. Instead of changing them, you create new ones with the content you want. Old ones keep pointing at the old document shape. This is made cheaper by sharing structure between the old and new data as much as possible, which a tree shape like this (without back pointers) makes easy.
Do not directly mutate the properties of a
Nodeobject. See the guide for more information.