Skip to main content

Class: RootNode

lexical.RootNode

Hierarchy

Constructors

constructor

new RootNode(): RootNode

Returns

RootNode

Overrides

ElementNode.constructor

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:37

Methods

append

append(...nodesToAppend): this

Parameters

NameType
...nodesToAppendLexicalNode[]

Returns

this

Overrides

ElementNode.append

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:86


collapseAtStart

collapseAtStart(): true

Returns

true

Overrides

ElementNode.collapseAtStart

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:108


getTextContent

getTextContent(): string

Returns the text content of the node. Override this for custom nodes that should have a representation in plain text format (for copy + paste, for example)

Returns

string

Overrides

ElementNode.getTextContent

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:49


getTopLevelElementOrThrow

getTopLevelElementOrThrow(): never

Returns the highest (in the EditorState tree) non-root ancestor of this node, or throws if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".

Returns

never

Overrides

ElementNode.getTopLevelElementOrThrow

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:42


insertAfter

insertAfter(nodeToInsert): LexicalNode

Inserts a node after this LexicalNode (as the next sibling).

Parameters

NameTypeDescription
nodeToInsertLexicalNodeThe node to insert after this one.

Returns

LexicalNode

Overrides

ElementNode.insertAfter

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:74


insertBefore

insertBefore(nodeToInsert): LexicalNode

Inserts a node before this LexicalNode (as the previous sibling).

Parameters

NameTypeDescription
nodeToInsertLexicalNodeThe node to insert before this one.

Returns

LexicalNode

Overrides

ElementNode.insertBefore

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:70


remove

remove(): never

Removes this LexicalNode from the EditorState. If the node isn't re-inserted somewhere, the Lexical garbage collector will eventually clean it up.

Returns

never

Overrides

ElementNode.remove

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:62


replace

replace<N>(node): never

Replaces this LexicalNode with the provided node, optionally transferring the children of the replaced node to the replacing node.

Type parameters

NameType
NLexicalNode

Parameters

NameTypeDescription
nodeNThe node to replace this one with.

Returns

never

Overrides

ElementNode.replace

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:66


updateDOM

updateDOM(prevNode, dom): false

Called when a node changes and should update the DOM in whatever way is necessary to make it align with any changes that might have happened during the update.

Returning "true" here will cause lexical to unmount and recreate the DOM node (by calling createDOM). You would need to do this if the element tag changes, for instance.

Parameters

NameType
prevNodethis
domHTMLElement

Returns

false

Overrides

ElementNode.updateDOM

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:80


clone

clone(): RootNode

Clones this node, creating a new node with a different key and adding it to the EditorState (but not attaching it anywhere!). All nodes must implement this method.

Returns

RootNode

Overrides

ElementNode.clone

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:33


getType

getType(): string

Returns the string type of this node. Every node must implement this and it MUST BE UNIQUE amongst nodes registered on the editor.

Returns

string

Overrides

ElementNode.getType

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:29


importJSON

importJSON(serializedNode): RootNode

Controls how the this node is deserialized from JSON. This is usually boilerplate, but provides an abstraction between the node implementation and serialized interface that can be important if you ever make breaking changes to a node schema (by adding or removing properties). See Serialization & Deserialization.

Parameters

NameType
serializedNodeSerializedRootNode<SerializedLexicalNode>

Returns

RootNode

Overrides

ElementNode.importJSON

Defined in

packages/lexical/src/nodes/LexicalRootNode.ts:99