Skip to main content

@lexical/list

Classes​

ListItemNode​

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:125

Extends​

Constructors​

Constructor​

new ListItemNode(value?, checked?, key?): ListItemNode

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:197

Parameters​
value?​

number = 1

checked?​

boolean | undefined

key?​

string

Returns​

ListItemNode

Inherited from​

ElementNode.constructor

Properties​

importDOM?​

static optional importDOM?: () => DOMConversionMap<any> | null

Defined in: packages/lexical/src/LexicalNode.ts:1161

Returns​

DOMConversionMap<any> | null

Inherited from​

ElementNode.importDOM

Methods​

afterCloneFrom()​

afterCloneFrom(prevNode): void

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:329

Perform any state updates on the clone of prevNode that are not already handled by the constructor call in the static clone method. If you have state to update in your clone that is not handled directly by the constructor, it is advisable to override this method but it is required to include a call to super.afterCloneFrom(prevNode) in your implementation. This is only intended to be called by $cloneWithProperties function or via a super call.

Parameters​
prevNode​

this

Returns​

void

Example​
class ClassesTextNode extends TextNode {
// Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
__classes = new Set<string>();
static clone(node: ClassesTextNode): ClassesTextNode {
// The inherited TextNode constructor is used here, so
// classes is not set by this method.
return new ClassesTextNode(node.__text, node.__key);
}
afterCloneFrom(node: this): void {
// This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
// for necessary state updates
super.afterCloneFrom(node);
this.__addClasses(node.__classes);
}
// This method is a private implementation detail, it is not
// suitable for the public API because it does not call getWritable
__addClasses(classNames: Iterable<string>): this {
for (const className of classNames) {
this.__classes.add(className);
}
return this;
}
addClass(...classNames: string[]): this {
return this.getWritable().__addClasses(classNames);
}
removeClass(...classNames: string[]): this {
const node = this.getWritable();
for (const className of classNames) {
this.__classes.delete(className);
}
return this;
}
getClasses(): Set<string> {
return this.getLatest().__classes;
}
}
Inherited from​

ElementNode.afterCloneFrom

append()​

append(...nodes): this

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:279

Parameters​
nodes​

...LexicalNode[]

Returns​

this

Inherited from​

ElementNode.append

canBeEmpty()​

canBeEmpty(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1072

Returns​

boolean

Inherited from​

ElementNode.canBeEmpty

canIndent()​

canIndent(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1044

Returns​

boolean

Inherited from​

ElementNode.canIndent

canInsertTextAfter()​

canInsertTextAfter(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1078

Returns​

boolean

Inherited from​

ElementNode.canInsertTextAfter

canInsertTextBefore()​

canInsertTextBefore(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1075

Returns​

boolean

Inherited from​

ElementNode.canInsertTextBefore

canMergeWhenEmpty()​

canMergeWhenEmpty(): true

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:587

Determines whether this node, when empty, can merge with a first block of nodes being inserted.

This method is specifically called in RangeSelection.insertNodes to determine merging behavior during nodes insertion.

Returns​

true

Example​
// In a ListItemNode or QuoteNode implementation:
canMergeWhenEmpty(): true {
return true;
}
Inherited from​

ElementNode.canMergeWhenEmpty

clear()​

clear(): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:768

Returns​

this

Inherited from​

ElementNode.clear

collapseAtStart()​

collapseAtStart(selection): boolean

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:442

Parameters​
selection​

RangeSelection

Returns​

boolean

Inherited from​

ElementNode.collapseAtStart

config()​
Call Signature​

config<Config>(type, config): AbstractStaticNodeConfigRecord<Config>

Defined in: packages/lexical/src/LexicalNode.ts:1065

This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.

An abstract base class that has no concrete node type may pass a well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of a string type to declare configuration shared with its subclasses.

Type Parameters​
Config​

Config extends StaticNodeConfigValue<ListItemNode, string>

Parameters​
type​

symbol

config​

Config

Returns​

AbstractStaticNodeConfigRecord<Config>

Inherited from​

ElementNode.config

Call Signature​

config<Type, Config>(type, config): StaticNodeConfigRecord<Type, Config>

Defined in: packages/lexical/src/LexicalNode.ts:1069

This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.

An abstract base class that has no concrete node type may pass a well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of a string type to declare configuration shared with its subclasses.

Type Parameters​
Type​

Type extends string

Config​

Config extends StaticNodeConfigValue<ListItemNode, Type>

Parameters​
type​

Type

config​

Config

Returns​

StaticNodeConfigRecord<Type, Config>

Inherited from​

ElementNode.config

createDOM()​

createDOM(config): HTMLElement

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:207

Called during the reconciliation process to determine which nodes to insert into the DOM for this Lexical Node.

This method must return exactly one HTMLElement. Nested elements are not supported.

Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.

Parameters​
config​

EditorConfig

Returns​

HTMLElement

Inherited from​

ElementNode.createDOM

createParentElementNode()​

createParentElementNode(): ListNode

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:583

The creation logic for any required parent. Should be implemented if isParentRequired returns true.

Returns​

ListNode

Inherited from​

ElementNode.createParentElementNode

excludeFromCopy()​

excludeFromCopy(destination?): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1061

Parameters​
destination?​

"clone" | "html"

Returns​

boolean

Inherited from​

ElementNode.excludeFromCopy

exportDOM()​

exportDOM(editor): DOMExportOutput

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:243

Controls how the this node is serialized to HTML. This is important for copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces, in which case the primary transfer format is HTML. It's also important if you're serializing to HTML for any other reason via $generateHtmlFromNodes. You could also use this method to build your own HTML renderer.

Parameters​
editor​

LexicalEditor

Returns​

DOMExportOutput

Inherited from​

ElementNode.exportDOM

exportJSON()​
Call Signature​

exportJSON(compact?): SerializedListItemNode

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:126

Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See Serialization & Deserialization.

The base implementation writes every property the node's schema declares (its own and those it inherits), reading each through its getter — get<Prop> by default, or the name recorded with withAccessors. A getter that returns undefined omits its property. Override this only for output a schema can not describe, and call super.exportJSON(compact) when you do.

This may serialize the instance as-is, without resolving the latest version. A property declared with withField is read straight off the node, which is the optimization the serialization walk is built on — every node the walk reaches comes from the EditorState's node map and is already current, so it resolves nothing per node.

So on a reference that a getWritable() (any set<Prop>) has since superseded, this writes pre-mutation values. Which properties do is not something to rely on: a property whose accessor a subclass overrode still goes through that accessor and resolves the latest, so one node can write a current text beside a stale style. Call node.getLatest().exportJSON() whenever you hold such a reference rather than reasoning about which properties resolve.

This is a breaking change. Every property previously went through an accessor, and every accessor resolves getLatest(), so a stale reference exported current values.

Parameters​
compact?​

false

Write the compact form: omit a property the parser derives rather than reads, one whose value is the schema default parsing would restore, and the deprecated version. The two forms describe the same document. A node that overrides this and ignores the flag simply keeps writing the full form, which still parses.

Returns​

SerializedListItemNode

Inherited from​

ElementNode.exportJSON

Call Signature​

exportJSON(compact): SerializedPartial<SerializedListItemNode>

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:127

The compact form omits properties, so what it returns is the partial serialized type — every node-specific property optional — rather than the full one. Passing a boolean whose value is not statically known selects this overload too, which is right: neither form can be promised then.

Parameters​
compact​

boolean

Returns​

SerializedPartial<SerializedListItemNode>

See​

SerializedPartial

Inherited from​

ElementNode.exportJSON

extractWithChild()​

extractWithChild(child, selection): boolean

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:564

Parameters​
child​

LexicalNode

selection​

BaseSelection

Returns​

boolean

Inherited from​

ElementNode.extractWithChild

getAllTextNodes()​

getAllTextNodes(): TextNode[]

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:420

Returns​

TextNode[]

Inherited from​

ElementNode.getAllTextNodes

getChecked()​

getChecked(): boolean | undefined

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:485

Returns​

boolean | undefined

getChildAtIndex()​
Call Signature​

getChildAtIndex(index): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:605

Returns the child of this node at the given index, or null if the index is out of range.

Parameters​
index​

number

Returns​

LexicalNode | null

Inherited from​

ElementNode.getChildAtIndex

Call Signature​

getChildAtIndex<T>(index): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:612

Type Parameters​
T​

T extends LexicalNode

Parameters​
index​

number

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getChildAtIndex(index) as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getChildAtIndex

getChildren()​
Call Signature​

getChildren(): LexicalNode[]

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:374

Returns the children of this node, in document order.

Returns​

LexicalNode[]

Inherited from​

ElementNode.getChildren

Call Signature​

getChildren<T>(): T[]

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:381

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getChildren() as T[], and will be removed in a future release. Call this method without a type argument and narrow the results with a type guard instead.

Inherited from​

ElementNode.getChildren

getChildrenKeys()​

getChildrenKeys(): string[]

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:391

Returns​

string[]

Inherited from​

ElementNode.getChildrenKeys

getChildrenSize()​

getChildrenSize(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:400

Returns​

number

Inherited from​

ElementNode.getChildrenSize

getCommonAncestor()​

getCommonAncestor<T>(node): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1506

Type Parameters​
T​

T extends ElementNode = ElementNode

Parameters​
node​

LexicalNode

the other node to find the common ancestor of.

Returns​

T | null

Deprecated​

use $getCommonAncestor

Returns the closest common ancestor of this node and the provided one or null if one cannot be found.

Inherited from​

ElementNode.getCommonAncestor

getDescendantByIndex()​
Call Signature​

getDescendantByIndex(index): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:505

Returns the deepest descendant corresponding to the child at the given index, or null if this node has no children.

Parameters​
index​

number

Returns​

LexicalNode | null

Inherited from​

ElementNode.getDescendantByIndex

Call Signature​

getDescendantByIndex<T>(index): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:512

Type Parameters​
T​

T extends LexicalNode

Parameters​
index​

number

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getDescendantByIndex(index) as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getDescendantByIndex

getDirection()​

getDirection(): "ltr" | "rtl" | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:678

Returns​

"ltr" | "rtl" | null

Inherited from​

ElementNode.getDirection

getDOMSlot()​

getDOMSlot(element): ElementDOMSlot<HTMLElement>

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:964

Experimental

An ElementNode subclass can override this to control where its children are inserted into the DOM, e.g. to add a wrapping node or accessory nodes before or after the children. The root of the node returned by createDOM must still be exactly one HTMLElement.

Parameters​
element​

HTMLElement

Returns​

ElementDOMSlot<HTMLElement>

Inherited from​

ElementNode.getDOMSlot

getFirstChild()​
Call Signature​

getFirstChild(): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:536

Returns the first child of this node, or null if it has no children.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getFirstChild

Call Signature​

getFirstChild<T>(): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:543

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getFirstChild() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getFirstChild

getFirstChildOrThrow()​
Call Signature​

getFirstChildOrThrow(): LexicalNode

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:552

Returns the first child of this node, or throws if it has no children.

Returns​

LexicalNode

Inherited from​

ElementNode.getFirstChildOrThrow

Call Signature​

getFirstChildOrThrow<T>(): T

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:559

Type Parameters​
T​

T extends LexicalNode

Returns​

T

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getFirstChildOrThrow() as T, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getFirstChildOrThrow

getFirstDescendant()​
Call Signature​

getFirstDescendant(): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:459

Returns the deepest first descendant of this node, or null if it has no children.

Descendant navigation is children-only by design: it feeds selectStart / selectEnd and selection, which must not see slots (slots are isolated).

Returns​

LexicalNode | null

Inherited from​

ElementNode.getFirstDescendant

Call Signature​

getFirstDescendant<T>(): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:466

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getFirstDescendant() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getFirstDescendant

getFormat()​

getFormat(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:355

Returns​

number

Inherited from​

ElementNode.getFormat

getFormatFlags()​

getFormatFlags(type, alignWithFormat): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:702

Returns the format flags applied to the node as a 32-bit integer.

Parameters​
type​

TextFormatType

alignWithFormat​

number | null

Returns​

number

a number representing the TextFormatTypes applied to the node.

Inherited from​

ElementNode.getFormatFlags

getFormatType()​

getFormatType(): ElementFormatType

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:359

Returns​

ElementFormatType

Inherited from​

ElementNode.getFormatType

getIndent()​

getIndent(): number

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:509

Returns​

number

Inherited from​

ElementNode.getIndent

getIndexWithinParent()​

getIndexWithinParent(): number

Defined in: packages/lexical/src/LexicalNode.ts:1283

Returns the zero-based index of this node within the parent.

Returns​

number

Inherited from​

ElementNode.getIndexWithinParent

getKey()​

getKey(): string

Defined in: packages/lexical/src/LexicalNode.ts:1275

Returns this nodes key.

Returns​

string

Inherited from​

ElementNode.getKey

getLastChild()​
Call Signature​

getLastChild(): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:570

Returns the last child of this node, or null if it has no children.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getLastChild

Call Signature​

getLastChild<T>(): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:577

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getLastChild() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getLastChild

getLastChildOrThrow()​
Call Signature​

getLastChildOrThrow(): LexicalNode

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:586

Returns the last child of this node, or throws if it has no children.

Returns​

LexicalNode

Inherited from​

ElementNode.getLastChildOrThrow

Call Signature​

getLastChildOrThrow<T>(): T

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:593

Type Parameters​
T​

T extends LexicalNode

Returns​

T

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getLastChildOrThrow() as T, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getLastChildOrThrow

getLastDescendant()​
Call Signature​

getLastDescendant(): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:482

Returns the deepest last descendant of this node, or null if it has no children.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getLastDescendant

Call Signature​

getLastDescendant<T>(): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:489

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getLastDescendant() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getLastDescendant

getLatest()​

getLatest(): this

Defined in: packages/lexical/src/LexicalNode.ts:1656

Returns the latest version of the node from the active EditorState. This is used to avoid getting values from stale node references.

Returns​

this

Inherited from​

ElementNode.getLatest

getNextSibling()​
Call Signature​

getNextSibling(): LexicalNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1462

Returns the node after this one in the same parent, or null if there is no such node.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getNextSibling

Call Signature​

getNextSibling<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1469

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getNextSibling() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getNextSibling

getNextSiblings()​
Call Signature​

getNextSiblings(): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1480

Returns all nodes after this one in the same parent, in document order.

Returns​

LexicalNode[]

Inherited from​

ElementNode.getNextSiblings

Call Signature​

getNextSiblings<T>(): T[]

Defined in: packages/lexical/src/LexicalNode.ts:1487

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getNextSiblings() as T[], and will be removed in a future release. Call this method without a type argument and narrow the results with a type guard instead.

Inherited from​

ElementNode.getNextSiblings

getNodesBetween()​

getNodesBetween(targetNode): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1575

Returns a list of nodes that are between this node and the target node in the EditorState.

Parameters​
targetNode​

LexicalNode

the node that marks the other end of the range of nodes to be returned.

Returns​

LexicalNode[]

Inherited from​

ElementNode.getNodesBetween

getParent()​
Call Signature​

getParent(): ElementNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1303

Returns the parent of this node, or null if none is found.

Returns​

ElementNode | null

Inherited from​

ElementNode.getParent

Call Signature​

getParent<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1310

Type Parameters​
T​

T extends ElementNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getParent() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getParent

getParentKeys()​

getParentKeys(): string[]

Defined in: packages/lexical/src/LexicalNode.ts:1401

Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.

Returns​

string[]

Inherited from​

ElementNode.getParentKeys

getParentOrThrow()​
Call Signature​

getParentOrThrow(): ElementNode

Defined in: packages/lexical/src/LexicalNode.ts:1323

Returns the parent of this node, or throws if none is found.

Returns​

ElementNode

Inherited from​

ElementNode.getParentOrThrow

Call Signature​

getParentOrThrow<T>(): T

Defined in: packages/lexical/src/LexicalNode.ts:1330

Type Parameters​
T​

T extends ElementNode

Returns​

T

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getParentOrThrow() as T, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getParentOrThrow

getParents()​

getParents(): ElementNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1386

Returns a list of the every ancestor of this node, all the way up to the RootNode.

Returns​

ElementNode[]

Inherited from​

ElementNode.getParents

getPreviousSibling()​
Call Signature​

getPreviousSibling(): LexicalNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1415

Returns the node before this one in the same parent, or null if there is no such node.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getPreviousSibling

Call Signature​

getPreviousSibling<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1422

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getPreviousSibling() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getPreviousSibling

getPreviousSiblings()​
Call Signature​

getPreviousSiblings(): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1433

Returns all nodes before this one in the same parent, in document order.

Returns​

LexicalNode[]

Inherited from​

ElementNode.getPreviousSiblings

Call Signature​

getPreviousSiblings<T>(): T[]

Defined in: packages/lexical/src/LexicalNode.ts:1440

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getPreviousSiblings() as T[], and will be removed in a future release. Call this method without a type argument and narrow the results with a type guard instead.

Inherited from​

ElementNode.getPreviousSiblings

getStyle()​

getStyle(): string

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:363

Returns​

string

Inherited from​

ElementNode.getStyle

getTextContent()​

getTextContent(): string

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:640

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

Inherited from​

ElementNode.getTextContent

getTextContentSize()​

getTextContentSize(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:659

Returns the length of the string produced by calling getTextContent on this node.

Returns​

number

Inherited from​

ElementNode.getTextContentSize

getTextFormat()​

getTextFormat(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:682

Returns​

number

Inherited from​

ElementNode.getTextFormat

getTextStyle()​

getTextStyle(): string

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:708

Returns​

string

Inherited from​

ElementNode.getTextStyle

getTopLevelElement()​

getTopLevelElement(): ElementNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:241

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

Returns​

ElementNode | null

Inherited from​

ElementNode.getTopLevelElement

getTopLevelElementOrThrow()​

getTopLevelElementOrThrow(): ElementNode

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:242

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​

ElementNode

Inherited from​

ElementNode.getTopLevelElementOrThrow

getType()​

getType(): string

Defined in: packages/lexical/src/LexicalNode.ts:1186

Returns the string type of this node.

Returns​

string

Inherited from​

ElementNode.getType

getValue()​

getValue(): number

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:473

Returns​

number

getWritable()​

getWritable(): this

Defined in: packages/lexical/src/LexicalNode.ts:1677

Returns a mutable version of the node using $cloneWithProperties if necessary. Will throw an error if called outside of a Lexical Editor LexicalEditor.update callback.

Returns​

this

Inherited from​

ElementNode.getWritable

hasFormat()​

hasFormat(type): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:686

Parameters​
type​

ElementFormatType

Returns​

boolean

Inherited from​

ElementNode.hasFormat

hasTextFormat()​

hasTextFormat(type): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:693

Parameters​
type​

TextFormatType

Returns​

boolean

Inherited from​

ElementNode.hasTextFormat

insertAfter()​

insertAfter(node, restoreSelection?): LexicalNode

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:363

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

Parameters​
node​

LexicalNode

restoreSelection?​

boolean = true

Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.

Returns​

LexicalNode

Inherited from​

ElementNode.insertAfter

insertBefore()​

insertBefore(nodeToInsert, restoreSelection?): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:2223

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

Parameters​
nodeToInsert​

LexicalNode

The node to insert before this one.

restoreSelection?​

boolean = true

Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.

Returns​

LexicalNode

Inherited from​

ElementNode.insertBefore

insertNewAfter()​

insertNewAfter(_, restoreSelection?): ParagraphNode | ListItemNode

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:431

Parameters​
_​

RangeSelection

restoreSelection?​

boolean = true

Returns​

ParagraphNode | ListItemNode

Inherited from​

ElementNode.insertNewAfter

is()​

is(object): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1523

Returns true if the provided node is the exact same one as this node, from Lexical's perspective. Always use this instead of referential equality.

Parameters​
object​

LexicalNode | null | undefined

the node to perform the equality comparison on.

Returns​

boolean

Inherited from​

ElementNode.is

isAttached()​

isAttached(): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1203

Returns true if there is a path between this node and the RootNode, false otherwise. This is a way of determining if the node is "attached" EditorState. Unattached nodes won't be reconciled and will ultimately be cleaned up by the Lexical GC.

Returns​

boolean

Inherited from​

ElementNode.isAttached

isBefore()​

isBefore(targetNode): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1541

Returns true if this node logically precedes the target node in the editor state, false otherwise (including if there is no common ancestor).

Note that this notion of isBefore is based on post-order; a descendant node is always before its ancestors. See also $getCommonAncestor and $comparePointCaretNext for more flexible ways to determine the relative positions of nodes.

Parameters​
targetNode​

LexicalNode

the node we're testing to see if it's after this one.

Returns​

boolean

Inherited from​

ElementNode.isBefore

isDirty()​

isDirty(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:410

Returns true if this node has been marked dirty during this update cycle.

Returns​

boolean

Inherited from​

ElementNode.isDirty

isEmpty()​

isEmpty(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:404

Returns​

boolean

Inherited from​

ElementNode.isEmpty

isInline()​

isInline(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1086

If the method is overridden and returns true, ensure that canBeEmpty() returns false for the inline node to work correctly

Returns​

boolean

Inherited from​

ElementNode.isInline

isLastChild()​

isLastChild(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:415

Returns​

boolean

Inherited from​

ElementNode.isLastChild

isParentOf()​

isParentOf(targetNode): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1564

Returns true if this node is an ancestor of and distinct from the target node, false otherwise.

Parameters​
targetNode​

LexicalNode

the would-be child node.

Returns​

boolean

Inherited from​

ElementNode.isParentOf

isParentRequired()​

isParentRequired(): true

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:579

Whether or not this node has a required parent. Used during copy + paste operations to normalize nodes that would otherwise be orphaned. For example, ListItemNodes without a ListNode parent or TextNodes with a ParagraphNode parent.

Returns​

true

Inherited from​

ElementNode.isParentRequired

isSelected()​

isSelected(selection?): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1230

Returns true if this node is contained within the provided Selection., false otherwise. Relies on the algorithms implemented in BaseSelection.getNodes to determine what's included.

Parameters​
selection?​

BaseSelection | null

The selection that we want to determine if the node is in.

Returns​

boolean

Inherited from​

ElementNode.isSelected

isShadowRoot()​

isShadowRoot(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1093

Returns​

boolean

Inherited from​

ElementNode.isShadowRoot

markDirty()​

markDirty(): void

Defined in: packages/lexical/src/LexicalNode.ts:2387

Marks a node dirty, triggering transforms and forcing it to be reconciled during the update cycle.

Returns​

void

Inherited from​

ElementNode.markDirty

remove()​

remove(preserveEmptyParent?): void

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:404

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

Parameters​
preserveEmptyParent?​

boolean

If falsy, the node's parent will be removed if it's empty after the removal operation. This is the default behavior, subject to other node heuristics such as ElementNode#canBeEmpty

Returns​

void

Inherited from​

ElementNode.remove

replace()​

replace<N>(replaceWithNode, includeChildren?): N

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:295

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

Named slots are bound to their host node and are never transferred: this node keeps its slot map, so if it is reattached elsewhere (as $wrapNodeInElement does) its slots come with it, and if it stays detached the slot subtrees are garbage-collected along with it. To move a slot value onto another host, use $setSlot explicitly.

Type Parameters​
N​

N extends LexicalNode

Parameters​
replaceWithNode​

N

includeChildren?​

boolean

Whether or not to transfer the children of this node to the replacing node.

Returns​

N

Inherited from​

ElementNode.replace

resetOnCopyNodeFrom()​

resetOnCopyNodeFrom(original): void

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:424

Reset state in this copy of originalNode, if necessary

Parameters​
original​

this

Returns​

void

Inherited from​

ElementNode.resetOnCopyNodeFrom

select()​

select(_anchorOffset?, _focusOffset?): RangeSelection

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:715

Parameters​
_anchorOffset?​

number

_focusOffset?​

number

Returns​

RangeSelection

Inherited from​

ElementNode.select

selectEnd()​

selectEnd(): RangeSelection

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:764

Returns​

RangeSelection

Inherited from​

ElementNode.selectEnd

selectNext()​

selectNext(anchorOffset?, focusOffset?): RangeSelection

Defined in: packages/lexical/src/LexicalNode.ts:2359

Moves selection to the next sibling of this node, at the specified offsets.

Parameters​
anchorOffset?​

number

The anchor offset for selection.

focusOffset?​

number

The focus offset for selection

Returns​

RangeSelection

Inherited from​

ElementNode.selectNext

selectPrevious()​

selectPrevious(anchorOffset?, focusOffset?): RangeSelection

Defined in: packages/lexical/src/LexicalNode.ts:2330

Moves selection to the previous sibling of this node, at the specified offsets.

Parameters​
anchorOffset?​

number

The anchor offset for selection.

focusOffset?​

number

The focus offset for selection

Returns​

RangeSelection

Inherited from​

ElementNode.selectPrevious

selectStart()​

selectStart(): RangeSelection

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:760

Returns​

RangeSelection

Inherited from​

ElementNode.selectStart

setChecked()​

setChecked(checked?): this

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:498

Parameters​
checked?​

boolean

Returns​

this

setDirection()​

setDirection(direction): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:777

Parameters​
direction​

"ltr" | "rtl" | null

Returns​

this

Inherited from​

ElementNode.setDirection

setFormat()​

setFormat(type): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:782

Parameters​
type​

ElementFormatType

Returns​

this

Inherited from​

ElementNode.setFormat

setIndent()​

setIndent(indent): this

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:526

Parameters​
indent​

number

Returns​

this

Inherited from​

ElementNode.setIndent

setStyle()​

setStyle(style): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:787

Parameters​
style​

string

Returns​

this

Inherited from​

ElementNode.setStyle

setTextFormat()​

setTextFormat(type): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:792

Parameters​
type​

number

Returns​

this

Inherited from​

ElementNode.setTextFormat

setTextStyle()​

setTextStyle(style): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:797

Parameters​
style​

string

Returns​

this

Inherited from​

ElementNode.setTextStyle

setValue()​

setValue(value): this

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:479

Parameters​
value​

number

Returns​

this

splice()​

splice(start, deleteCount, nodesToInsert): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:807

Parameters​
start​

number

deleteCount​

number

nodesToInsert​

LexicalNode[]

Returns​

this

Inherited from​

ElementNode.splice

toggleChecked()​

toggleChecked(): this

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:504

Returns​

this

updateDOM()​

updateDOM(prevNode, dom, config): boolean

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:232

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​
prevNode​

ListItemNode

dom​

HTMLElement

config​

EditorConfig

Returns​

boolean

Inherited from​

ElementNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:128

Update this LexicalNode instance from serialized JSON. It's recommended to implement as much logic as possible in this method instead of the static importJSON method, so that the functionality can be inherited in subclasses.

The LexicalUpdateJSON utility type should be used to ignore any type, version, or children properties in the JSON so that the extended JSON from subclasses are acceptable parameters for the super call.

If overridden, this method must call super.

Parameters​
serializedNode​

LexicalParseJSON<SerializedListItemNode>

Returns​

this

Example​
class MyTextNode extends TextNode {
// ...
static importJSON(serializedNode: SerializedMyTextNode): MyTextNode {
return $createMyTextNode()
.updateFromJSON(serializedNode);
}
updateFromJSON(
serializedNode: LexicalUpdateJSON<SerializedMyTextNode>,
): this {
return super.updateFromJSON(serializedNode)
.setMyProperty(serializedNode.myProperty);
}
}

The whole schema is applied, so a property the JSON omits is set to its schema default rather than left as it is — that is what lets the compact form omit a default-valued property and have parsing restore it. (A flat NodeState is the exception: it is applied only when present.) Pass the node's complete serialized form unless you mean to reset what you leave out.

Inherited from​

ElementNode.updateFromJSON

updateListItemDOM()​

updateListItemDOM(prevNode, dom, config): void

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:214

Parameters​
prevNode​

ListItemNode | null

dom​

HTMLLIElement

config​

EditorConfig

Returns​

void

clone()​

static clone(_data): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:1029

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.

Parameters​
_data​

unknown

Returns​

LexicalNode

Inherited from​

ElementNode.clone

getType()​

static getType(): string

Defined in: packages/lexical/src/LexicalNode.ts:1013

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

Inherited from​

ElementNode.getType

importJSON()​

static importJSON(_serializedNode): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:1870

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​
_serializedNode​

Omit<SerializedLexicalNode & Partial<SerializedLexicalNode>, "$slots" | "children" | "version"> & object & Record<string, unknown>

Returns​

LexicalNode

Inherited from​

ElementNode.importJSON

transform()​

static transform(): ((node) => void) | null

Defined in: packages/lexical/src/LexicalNode.ts:1934

Experimental

Registers the returned function as a transform on the node during Editor initialization. Most such use cases should be addressed via the LexicalEditor.registerNodeTransform API.

Experimental - use at your own risk.

Returns​

((node) => void) | null

Inherited from​

ElementNode.transform


ListNode​

Defined in: packages/lexical-list/src/LexicalListNode.ts:91

Extends​

Constructors​

Constructor​

new ListNode(listType?, start?, key?): ListNode

Defined in: packages/lexical-list/src/LexicalListNode.ts:130

Parameters​
listType?​

ListType = 'number'

start?​

number = 1

key?​

string

Returns​

ListNode

Inherited from​

ElementNode.constructor

Properties​

importDOM?​

static optional importDOM?: () => DOMConversionMap<any> | null

Defined in: packages/lexical/src/LexicalNode.ts:1161

Returns​

DOMConversionMap<any> | null

Inherited from​

ElementNode.importDOM

Methods​

afterCloneFrom()​

afterCloneFrom(prevNode): void

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:329

Perform any state updates on the clone of prevNode that are not already handled by the constructor call in the static clone method. If you have state to update in your clone that is not handled directly by the constructor, it is advisable to override this method but it is required to include a call to super.afterCloneFrom(prevNode) in your implementation. This is only intended to be called by $cloneWithProperties function or via a super call.

Parameters​
prevNode​

this

Returns​

void

Example​
class ClassesTextNode extends TextNode {
// Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
__classes = new Set<string>();
static clone(node: ClassesTextNode): ClassesTextNode {
// The inherited TextNode constructor is used here, so
// classes is not set by this method.
return new ClassesTextNode(node.__text, node.__key);
}
afterCloneFrom(node: this): void {
// This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
// for necessary state updates
super.afterCloneFrom(node);
this.__addClasses(node.__classes);
}
// This method is a private implementation detail, it is not
// suitable for the public API because it does not call getWritable
__addClasses(classNames: Iterable<string>): this {
for (const className of classNames) {
this.__classes.add(className);
}
return this;
}
addClass(...classNames: string[]): this {
return this.getWritable().__addClasses(classNames);
}
removeClass(...classNames: string[]): this {
const node = this.getWritable();
for (const className of classNames) {
this.__classes.delete(className);
}
return this;
}
getClasses(): Set<string> {
return this.getLatest().__classes;
}
}
Inherited from​

ElementNode.afterCloneFrom

append()​

append(...nodesToAppend): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:774

Parameters​
nodesToAppend​

...LexicalNode[]

Returns​

this

Inherited from​

ElementNode.append

canBeEmpty()​

canBeEmpty(): false

Defined in: packages/lexical-list/src/LexicalListNode.ts:222

Returns​

false

Inherited from​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

Defined in: packages/lexical-list/src/LexicalListNode.ts:226

Returns​

false

Inherited from​

ElementNode.canIndent

canInsertTextAfter()​

canInsertTextAfter(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1078

Returns​

boolean

Inherited from​

ElementNode.canInsertTextAfter

canInsertTextBefore()​

canInsertTextBefore(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1075

Returns​

boolean

Inherited from​

ElementNode.canInsertTextBefore

canMergeWhenEmpty()​

canMergeWhenEmpty(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1121

Determines whether this node, when empty, can merge with a first block of nodes being inserted.

This method is specifically called in RangeSelection.insertNodes to determine merging behavior during nodes insertion.

Returns​

boolean

Example​
// In a ListItemNode or QuoteNode implementation:
canMergeWhenEmpty(): true {
return true;
}
Inherited from​

ElementNode.canMergeWhenEmpty

clear()​

clear(): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:768

Returns​

this

Inherited from​

ElementNode.clear

collapseAtStart()​

collapseAtStart(selection): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1058

Parameters​
selection​

RangeSelection

Returns​

boolean

Inherited from​

ElementNode.collapseAtStart

config()​
Call Signature​

config<Config>(type, config): AbstractStaticNodeConfigRecord<Config>

Defined in: packages/lexical/src/LexicalNode.ts:1065

This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.

An abstract base class that has no concrete node type may pass a well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of a string type to declare configuration shared with its subclasses.

Type Parameters​
Config​

Config extends StaticNodeConfigValue<ListNode, string>

Parameters​
type​

symbol

config​

Config

Returns​

AbstractStaticNodeConfigRecord<Config>

Inherited from​

ElementNode.config

Call Signature​

config<Type, Config>(type, config): StaticNodeConfigRecord<Type, Config>

Defined in: packages/lexical/src/LexicalNode.ts:1069

This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.

An abstract base class that has no concrete node type may pass a well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of a string type to declare configuration shared with its subclasses.

Type Parameters​
Type​

Type extends string

Config​

Config extends StaticNodeConfigValue<ListNode, Type>

Parameters​
type​

Type

config​

Config

Returns​

StaticNodeConfigRecord<Type, Config>

Inherited from​

ElementNode.config

createDOM()​

createDOM(config, _editor?): HTMLElement

Defined in: packages/lexical-list/src/LexicalListNode.ts:169

Called during the reconciliation process to determine which nodes to insert into the DOM for this Lexical Node.

This method must return exactly one HTMLElement. Nested elements are not supported.

Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.

Parameters​
config​

EditorConfig

_editor?​

LexicalEditor

allows access to the editor for context during reconciliation.

Returns​

HTMLElement

Inherited from​

ElementNode.createDOM

createListItemNode()​

createListItemNode(): ListItemNode

Defined in: packages/lexical-list/src/LexicalListNode.ts:269

Create an appropriate ListItemNode to be a child of this ListNode, $createListItemNode is the default implementation.

Returns​

ListItemNode

A new ListItemNode.

createParentElementNode()​

createParentElementNode(): ElementNode

Defined in: packages/lexical/src/LexicalNode.ts:2312

The creation logic for any required parent. Should be implemented if isParentRequired returns true.

Returns​

ElementNode

Inherited from​

ElementNode.createParentElementNode

excludeFromCopy()​

excludeFromCopy(destination?): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1061

Parameters​
destination?​

"clone" | "html"

Returns​

boolean

Inherited from​

ElementNode.excludeFromCopy

exportDOM()​

exportDOM(editor): DOMExportOutput

Defined in: packages/lexical-list/src/LexicalListNode.ts:200

Controls how the this node is serialized to HTML. This is important for copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces, in which case the primary transfer format is HTML. It's also important if you're serializing to HTML for any other reason via $generateHtmlFromNodes. You could also use this method to build your own HTML renderer.

Parameters​
editor​

LexicalEditor

Returns​

DOMExportOutput

Inherited from​

ElementNode.exportDOM

exportJSON()​
Call Signature​

exportJSON(compact?): SerializedListNode

Defined in: packages/lexical-list/src/LexicalListNode.ts:92

Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See Serialization & Deserialization.

The base implementation writes every property the node's schema declares (its own and those it inherits), reading each through its getter — get<Prop> by default, or the name recorded with withAccessors. A getter that returns undefined omits its property. Override this only for output a schema can not describe, and call super.exportJSON(compact) when you do.

This may serialize the instance as-is, without resolving the latest version. A property declared with withField is read straight off the node, which is the optimization the serialization walk is built on — every node the walk reaches comes from the EditorState's node map and is already current, so it resolves nothing per node.

So on a reference that a getWritable() (any set<Prop>) has since superseded, this writes pre-mutation values. Which properties do is not something to rely on: a property whose accessor a subclass overrode still goes through that accessor and resolves the latest, so one node can write a current text beside a stale style. Call node.getLatest().exportJSON() whenever you hold such a reference rather than reasoning about which properties resolve.

This is a breaking change. Every property previously went through an accessor, and every accessor resolves getLatest(), so a stale reference exported current values.

Parameters​
compact?​

false

Write the compact form: omit a property the parser derives rather than reads, one whose value is the schema default parsing would restore, and the deprecated version. The two forms describe the same document. A node that overrides this and ignores the flag simply keeps writing the full form, which still parses.

Returns​

SerializedListNode

Inherited from​

ElementNode.exportJSON

Call Signature​

exportJSON(compact): SerializedPartial<SerializedListNode>

Defined in: packages/lexical-list/src/LexicalListNode.ts:93

The compact form omits properties, so what it returns is the partial serialized type — every node-specific property optional — rather than the full one. Passing a boolean whose value is not statically known selects this overload too, which is right: neither form can be promised then.

Parameters​
compact​

boolean

Returns​

SerializedPartial<SerializedListNode>

See​

SerializedPartial

Inherited from​

ElementNode.exportJSON

extractWithChild()​

extractWithChild(child): boolean

Defined in: packages/lexical-list/src/LexicalListNode.ts:259

Parameters​
child​

LexicalNode

Returns​

boolean

Inherited from​

ElementNode.extractWithChild

getAllTextNodes()​

getAllTextNodes(): TextNode[]

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:420

Returns​

TextNode[]

Inherited from​

ElementNode.getAllTextNodes

getChildAtIndex()​
Call Signature​

getChildAtIndex(index): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:605

Returns the child of this node at the given index, or null if the index is out of range.

Parameters​
index​

number

Returns​

LexicalNode | null

Inherited from​

ElementNode.getChildAtIndex

Call Signature​

getChildAtIndex<T>(index): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:612

Type Parameters​
T​

T extends LexicalNode

Parameters​
index​

number

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getChildAtIndex(index) as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getChildAtIndex

getChildren()​
Call Signature​

getChildren(): LexicalNode[]

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:374

Returns the children of this node, in document order.

Returns​

LexicalNode[]

Inherited from​

ElementNode.getChildren

Call Signature​

getChildren<T>(): T[]

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:381

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getChildren() as T[], and will be removed in a future release. Call this method without a type argument and narrow the results with a type guard instead.

Inherited from​

ElementNode.getChildren

getChildrenKeys()​

getChildrenKeys(): string[]

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:391

Returns​

string[]

Inherited from​

ElementNode.getChildrenKeys

getChildrenSize()​

getChildrenSize(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:400

Returns​

number

Inherited from​

ElementNode.getChildrenSize

getCommonAncestor()​

getCommonAncestor<T>(node): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1506

Type Parameters​
T​

T extends ElementNode = ElementNode

Parameters​
node​

LexicalNode

the other node to find the common ancestor of.

Returns​

T | null

Deprecated​

use $getCommonAncestor

Returns the closest common ancestor of this node and the provided one or null if one cannot be found.

Inherited from​

ElementNode.getCommonAncestor

getDescendantByIndex()​
Call Signature​

getDescendantByIndex(index): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:505

Returns the deepest descendant corresponding to the child at the given index, or null if this node has no children.

Parameters​
index​

number

Returns​

LexicalNode | null

Inherited from​

ElementNode.getDescendantByIndex

Call Signature​

getDescendantByIndex<T>(index): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:512

Type Parameters​
T​

T extends LexicalNode

Parameters​
index​

number

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getDescendantByIndex(index) as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getDescendantByIndex

getDirection()​

getDirection(): "ltr" | "rtl" | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:678

Returns​

"ltr" | "rtl" | null

Inherited from​

ElementNode.getDirection

getDOMSlot()​

getDOMSlot(element): ElementDOMSlot<HTMLElement>

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:964

Experimental

An ElementNode subclass can override this to control where its children are inserted into the DOM, e.g. to add a wrapping node or accessory nodes before or after the children. The root of the node returned by createDOM must still be exactly one HTMLElement.

Parameters​
element​

HTMLElement

Returns​

ElementDOMSlot<HTMLElement>

Inherited from​

ElementNode.getDOMSlot

getFirstChild()​
Call Signature​

getFirstChild(): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:536

Returns the first child of this node, or null if it has no children.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getFirstChild

Call Signature​

getFirstChild<T>(): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:543

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getFirstChild() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getFirstChild

getFirstChildOrThrow()​
Call Signature​

getFirstChildOrThrow(): LexicalNode

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:552

Returns the first child of this node, or throws if it has no children.

Returns​

LexicalNode

Inherited from​

ElementNode.getFirstChildOrThrow

Call Signature​

getFirstChildOrThrow<T>(): T

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:559

Type Parameters​
T​

T extends LexicalNode

Returns​

T

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getFirstChildOrThrow() as T, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getFirstChildOrThrow

getFirstDescendant()​
Call Signature​

getFirstDescendant(): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:459

Returns the deepest first descendant of this node, or null if it has no children.

Descendant navigation is children-only by design: it feeds selectStart / selectEnd and selection, which must not see slots (slots are isolated).

Returns​

LexicalNode | null

Inherited from​

ElementNode.getFirstDescendant

Call Signature​

getFirstDescendant<T>(): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:466

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getFirstDescendant() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getFirstDescendant

getFormat()​

getFormat(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:355

Returns​

number

Inherited from​

ElementNode.getFormat

getFormatFlags()​

getFormatFlags(type, alignWithFormat): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:702

Returns the format flags applied to the node as a 32-bit integer.

Parameters​
type​

TextFormatType

alignWithFormat​

number | null

Returns​

number

a number representing the TextFormatTypes applied to the node.

Inherited from​

ElementNode.getFormatFlags

getFormatType()​

getFormatType(): ElementFormatType

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:359

Returns​

ElementFormatType

Inherited from​

ElementNode.getFormatType

getIndent()​

getIndent(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:367

Returns​

number

Inherited from​

ElementNode.getIndent

getIndexWithinParent()​

getIndexWithinParent(): number

Defined in: packages/lexical/src/LexicalNode.ts:1283

Returns the zero-based index of this node within the parent.

Returns​

number

Inherited from​

ElementNode.getIndexWithinParent

getKey()​

getKey(): string

Defined in: packages/lexical/src/LexicalNode.ts:1275

Returns this nodes key.

Returns​

string

Inherited from​

ElementNode.getKey

getLastChild()​
Call Signature​

getLastChild(): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:570

Returns the last child of this node, or null if it has no children.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getLastChild

Call Signature​

getLastChild<T>(): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:577

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getLastChild() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getLastChild

getLastChildOrThrow()​
Call Signature​

getLastChildOrThrow(): LexicalNode

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:586

Returns the last child of this node, or throws if it has no children.

Returns​

LexicalNode

Inherited from​

ElementNode.getLastChildOrThrow

Call Signature​

getLastChildOrThrow<T>(): T

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:593

Type Parameters​
T​

T extends LexicalNode

Returns​

T

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getLastChildOrThrow() as T, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getLastChildOrThrow

getLastDescendant()​
Call Signature​

getLastDescendant(): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:482

Returns the deepest last descendant of this node, or null if it has no children.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getLastDescendant

Call Signature​

getLastDescendant<T>(): T | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:489

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to element.getLastDescendant() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getLastDescendant

getLatest()​

getLatest(): this

Defined in: packages/lexical/src/LexicalNode.ts:1656

Returns the latest version of the node from the active EditorState. This is used to avoid getting values from stale node references.

Returns​

this

Inherited from​

ElementNode.getLatest

getListType()​

getListType(): ListType

Defined in: packages/lexical-list/src/LexicalListNode.ts:153

Returns​

ListType

getNextSibling()​
Call Signature​

getNextSibling(): LexicalNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1462

Returns the node after this one in the same parent, or null if there is no such node.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getNextSibling

Call Signature​

getNextSibling<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1469

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getNextSibling() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getNextSibling

getNextSiblings()​
Call Signature​

getNextSiblings(): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1480

Returns all nodes after this one in the same parent, in document order.

Returns​

LexicalNode[]

Inherited from​

ElementNode.getNextSiblings

Call Signature​

getNextSiblings<T>(): T[]

Defined in: packages/lexical/src/LexicalNode.ts:1487

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getNextSiblings() as T[], and will be removed in a future release. Call this method without a type argument and narrow the results with a type guard instead.

Inherited from​

ElementNode.getNextSiblings

getNodesBetween()​

getNodesBetween(targetNode): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1575

Returns a list of nodes that are between this node and the target node in the EditorState.

Parameters​
targetNode​

LexicalNode

the node that marks the other end of the range of nodes to be returned.

Returns​

LexicalNode[]

Inherited from​

ElementNode.getNodesBetween

getParent()​
Call Signature​

getParent(): ElementNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1303

Returns the parent of this node, or null if none is found.

Returns​

ElementNode | null

Inherited from​

ElementNode.getParent

Call Signature​

getParent<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1310

Type Parameters​
T​

T extends ElementNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getParent() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getParent

getParentKeys()​

getParentKeys(): string[]

Defined in: packages/lexical/src/LexicalNode.ts:1401

Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.

Returns​

string[]

Inherited from​

ElementNode.getParentKeys

getParentOrThrow()​
Call Signature​

getParentOrThrow(): ElementNode

Defined in: packages/lexical/src/LexicalNode.ts:1323

Returns the parent of this node, or throws if none is found.

Returns​

ElementNode

Inherited from​

ElementNode.getParentOrThrow

Call Signature​

getParentOrThrow<T>(): T

Defined in: packages/lexical/src/LexicalNode.ts:1330

Type Parameters​
T​

T extends ElementNode

Returns​

T

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getParentOrThrow() as T, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getParentOrThrow

getParents()​

getParents(): ElementNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1386

Returns a list of the every ancestor of this node, all the way up to the RootNode.

Returns​

ElementNode[]

Inherited from​

ElementNode.getParents

getPreviousSibling()​
Call Signature​

getPreviousSibling(): LexicalNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1415

Returns the node before this one in the same parent, or null if there is no such node.

Returns​

LexicalNode | null

Inherited from​

ElementNode.getPreviousSibling

Call Signature​

getPreviousSibling<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1422

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getPreviousSibling() as T | null, and will be removed in a future release. Call this method without a type argument and narrow the result with a type guard instead.

Inherited from​

ElementNode.getPreviousSibling

getPreviousSiblings()​
Call Signature​

getPreviousSiblings(): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1433

Returns all nodes before this one in the same parent, in document order.

Returns​

LexicalNode[]

Inherited from​

ElementNode.getPreviousSiblings

Call Signature​

getPreviousSiblings<T>(): T[]

Defined in: packages/lexical/src/LexicalNode.ts:1440

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Deprecated​

The type parameter is an unchecked and unsafe cast, equivalent to node.getPreviousSiblings() as T[], and will be removed in a future release. Call this method without a type argument and narrow the results with a type guard instead.

Inherited from​

ElementNode.getPreviousSiblings

getStart()​

getStart(): number

Defined in: packages/lexical-list/src/LexicalListNode.ts:157

Returns​

number

getStyle()​

getStyle(): string

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:363

Returns​

string

Inherited from​

ElementNode.getStyle

getTag()​

getTag(): ListNodeTagType

Defined in: packages/lexical-list/src/LexicalListNode.ts:142

Returns​

ListNodeTagType

getTextContent()​

getTextContent(): string

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:640

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

Inherited from​

ElementNode.getTextContent

getTextContentSize()​

getTextContentSize(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:659

Returns the length of the string produced by calling getTextContent on this node.

Returns​

number

Inherited from​

ElementNode.getTextContentSize

getTextFormat()​

getTextFormat(): number

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:682

Returns​

number

Inherited from​

ElementNode.getTextFormat

getTextStyle()​

getTextStyle(): string

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:708

Returns​

string

Inherited from​

ElementNode.getTextStyle

getTopLevelElement()​

getTopLevelElement(): ElementNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:241

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

Returns​

ElementNode | null

Inherited from​

ElementNode.getTopLevelElement

getTopLevelElementOrThrow()​

getTopLevelElementOrThrow(): ElementNode

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:242

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​

ElementNode

Inherited from​

ElementNode.getTopLevelElementOrThrow

getType()​

getType(): string

Defined in: packages/lexical/src/LexicalNode.ts:1186

Returns the string type of this node.

Returns​

string

Inherited from​

ElementNode.getType

getWritable()​

getWritable(): this

Defined in: packages/lexical/src/LexicalNode.ts:1677

Returns a mutable version of the node using $cloneWithProperties if necessary. Will throw an error if called outside of a Lexical Editor LexicalEditor.update callback.

Returns​

this

Inherited from​

ElementNode.getWritable

hasFormat()​

hasFormat(type): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:686

Parameters​
type​

ElementFormatType

Returns​

boolean

Inherited from​

ElementNode.hasFormat

hasTextFormat()​

hasTextFormat(type): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:693

Parameters​
type​

TextFormatType

Returns​

boolean

Inherited from​

ElementNode.hasTextFormat

insertAfter()​

insertAfter(nodeToInsert, restoreSelection?): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:2116

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

Parameters​
nodeToInsert​

LexicalNode

The node to insert after this one.

restoreSelection?​

boolean = true

Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.

Returns​

LexicalNode

Inherited from​

ElementNode.insertAfter

insertBefore()​

insertBefore(nodeToInsert, restoreSelection?): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:2223

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

Parameters​
nodeToInsert​

LexicalNode

The node to insert before this one.

restoreSelection?​

boolean = true

Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.

Returns​

LexicalNode

Inherited from​

ElementNode.insertBefore

insertNewAfter()​

insertNewAfter(selection, restoreSelection?): LexicalNode | null

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1038

Parameters​
selection​

RangeSelection

restoreSelection?​

boolean

Returns​

LexicalNode | null

Inherited from​

ElementNode.insertNewAfter

is()​

is(object): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1523

Returns true if the provided node is the exact same one as this node, from Lexical's perspective. Always use this instead of referential equality.

Parameters​
object​

LexicalNode | null | undefined

the node to perform the equality comparison on.

Returns​

boolean

Inherited from​

ElementNode.is

isAttached()​

isAttached(): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1203

Returns true if there is a path between this node and the RootNode, false otherwise. This is a way of determining if the node is "attached" EditorState. Unattached nodes won't be reconciled and will ultimately be cleaned up by the Lexical GC.

Returns​

boolean

Inherited from​

ElementNode.isAttached

isBefore()​

isBefore(targetNode): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1541

Returns true if this node logically precedes the target node in the editor state, false otherwise (including if there is no common ancestor).

Note that this notion of isBefore is based on post-order; a descendant node is always before its ancestors. See also $getCommonAncestor and $comparePointCaretNext for more flexible ways to determine the relative positions of nodes.

Parameters​
targetNode​

LexicalNode

the node we're testing to see if it's after this one.

Returns​

boolean

Inherited from​

ElementNode.isBefore

isDirty()​

isDirty(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:410

Returns true if this node has been marked dirty during this update cycle.

Returns​

boolean

Inherited from​

ElementNode.isDirty

isEmpty()​

isEmpty(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:404

Returns​

boolean

Inherited from​

ElementNode.isEmpty

isInline()​

isInline(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1086

If the method is overridden and returns true, ensure that canBeEmpty() returns false for the inline node to work correctly

Returns​

boolean

Inherited from​

ElementNode.isInline

isLastChild()​

isLastChild(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:415

Returns​

boolean

Inherited from​

ElementNode.isLastChild

isParentOf()​

isParentOf(targetNode): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1564

Returns true if this node is an ancestor of and distinct from the target node, false otherwise.

Parameters​
targetNode​

LexicalNode

the would-be child node.

Returns​

boolean

Inherited from​

ElementNode.isParentOf

isParentRequired()​

isParentRequired(): boolean

Defined in: packages/lexical/src/LexicalNode.ts:2304

Whether or not this node has a required parent. Used during copy + paste operations to normalize nodes that would otherwise be orphaned. For example, ListItemNodes without a ListNode parent or TextNodes with a ParagraphNode parent.

Returns​

boolean

Inherited from​

ElementNode.isParentRequired

isSelected()​

isSelected(selection?): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1230

Returns true if this node is contained within the provided Selection., false otherwise. Relies on the algorithms implemented in BaseSelection.getNodes to determine what's included.

Parameters​
selection?​

BaseSelection | null

The selection that we want to determine if the node is in.

Returns​

boolean

Inherited from​

ElementNode.isSelected

isShadowRoot()​

isShadowRoot(): boolean

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1093

Returns​

boolean

Inherited from​

ElementNode.isShadowRoot

markDirty()​

markDirty(): void

Defined in: packages/lexical/src/LexicalNode.ts:2387

Marks a node dirty, triggering transforms and forcing it to be reconciled during the update cycle.

Returns​

void

Inherited from​

ElementNode.markDirty

remove()​

remove(preserveEmptyParent?): void

Defined in: packages/lexical/src/LexicalNode.ts:1948

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

Parameters​
preserveEmptyParent?​

boolean

If falsy, the node's parent will be removed if it's empty after the removal operation. This is the default behavior, subject to other node heuristics such as ElementNode#canBeEmpty

Returns​

void

Inherited from​

ElementNode.remove

replace()​

replace<N>(replaceWith, includeChildren?): N

Defined in: packages/lexical/src/LexicalNode.ts:1965

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

Named slots are bound to their host node and are never transferred: this node keeps its slot map, so if it is reattached elsewhere (as $wrapNodeInElement does) its slots come with it, and if it stays detached the slot subtrees are garbage-collected along with it. To move a slot value onto another host, use $setSlot explicitly.

Type Parameters​
N​

N extends LexicalNode

Parameters​
replaceWith​

N

The node to replace this one with.

includeChildren?​

boolean

Whether or not to transfer the children of this node to the replacing node.

Returns​

N

Inherited from​

ElementNode.replace

resetOnCopyNodeFrom()​

resetOnCopyNodeFrom(originalNode): void

Defined in: packages/lexical/src/LexicalNode.ts:1154

Reset state in this copy of originalNode, if necessary

Parameters​
originalNode​

this

Returns​

void

Inherited from​

ElementNode.resetOnCopyNodeFrom

select()​

select(_anchorOffset?, _focusOffset?): RangeSelection

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:715

Parameters​
_anchorOffset?​

number

_focusOffset?​

number

Returns​

RangeSelection

Inherited from​

ElementNode.select

selectEnd()​

selectEnd(): RangeSelection

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:764

Returns​

RangeSelection

Inherited from​

ElementNode.selectEnd

selectNext()​

selectNext(anchorOffset?, focusOffset?): RangeSelection

Defined in: packages/lexical/src/LexicalNode.ts:2359

Moves selection to the next sibling of this node, at the specified offsets.

Parameters​
anchorOffset?​

number

The anchor offset for selection.

focusOffset?​

number

The focus offset for selection

Returns​

RangeSelection

Inherited from​

ElementNode.selectNext

selectPrevious()​

selectPrevious(anchorOffset?, focusOffset?): RangeSelection

Defined in: packages/lexical/src/LexicalNode.ts:2330

Moves selection to the previous sibling of this node, at the specified offsets.

Parameters​
anchorOffset?​

number

The anchor offset for selection.

focusOffset?​

number

The focus offset for selection

Returns​

RangeSelection

Inherited from​

ElementNode.selectPrevious

selectStart()​

selectStart(): RangeSelection

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:760

Returns​

RangeSelection

Inherited from​

ElementNode.selectStart

setDirection()​

setDirection(direction): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:777

Parameters​
direction​

"ltr" | "rtl" | null

Returns​

this

Inherited from​

ElementNode.setDirection

setFormat()​

setFormat(type): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:782

Parameters​
type​

ElementFormatType

Returns​

this

Inherited from​

ElementNode.setFormat

setIndent()​

setIndent(indentLevel): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:802

Parameters​
indentLevel​

number

Returns​

this

Inherited from​

ElementNode.setIndent

setListType()​

setListType(type): this

Defined in: packages/lexical-list/src/LexicalListNode.ts:146

Parameters​
type​

ListType

Returns​

this

setStart()​

setStart(start): this

Defined in: packages/lexical-list/src/LexicalListNode.ts:161

Parameters​
start​

number

Returns​

this

setStyle()​

setStyle(style): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:787

Parameters​
style​

string

Returns​

this

Inherited from​

ElementNode.setStyle

setTextFormat()​

setTextFormat(type): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:792

Parameters​
type​

number

Returns​

this

Inherited from​

ElementNode.setTextFormat

setTextStyle()​

setTextStyle(style): this

Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:797

Parameters​
style​

string

Returns​

this

Inherited from​

ElementNode.setTextStyle

splice()​

splice(start, deleteCount, nodesToInsert): this

Defined in: packages/lexical-list/src/LexicalListNode.ts:230

Parameters​
start​

number

deleteCount​

number

nodesToInsert​

LexicalNode[]

Returns​

this

Inherited from​

ElementNode.splice

updateDOM()​

updateDOM(prevNode, dom, config): boolean

Defined in: packages/lexical-list/src/LexicalListNode.ts:183

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​
prevNode​

this

dom​

HTMLElement

config​

EditorConfig

Returns​

boolean

Inherited from​

ElementNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

Defined in: packages/lexical-list/src/LexicalListNode.ts:94

Update this LexicalNode instance from serialized JSON. It's recommended to implement as much logic as possible in this method instead of the static importJSON method, so that the functionality can be inherited in subclasses.

The LexicalUpdateJSON utility type should be used to ignore any type, version, or children properties in the JSON so that the extended JSON from subclasses are acceptable parameters for the super call.

If overridden, this method must call super.

Parameters​
serializedNode​

LexicalParseJSON<SerializedListNode>

Returns​

this

Example​
class MyTextNode extends TextNode {
// ...
static importJSON(serializedNode: SerializedMyTextNode): MyTextNode {
return $createMyTextNode()
.updateFromJSON(serializedNode);
}
updateFromJSON(
serializedNode: LexicalUpdateJSON<SerializedMyTextNode>,
): this {
return super.updateFromJSON(serializedNode)
.setMyProperty(serializedNode.myProperty);
}
}

The whole schema is applied, so a property the JSON omits is set to its schema default rather than left as it is — that is what lets the compact form omit a default-valued property and have parsing restore it. (A flat NodeState is the exception: it is applied only when present.) Pass the node's complete serialized form unless you mean to reset what you leave out.

Inherited from​

ElementNode.updateFromJSON

clone()​

static clone(_data): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:1029

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.

Parameters​
_data​

unknown

Returns​

LexicalNode

Inherited from​

ElementNode.clone

getType()​

static getType(): string

Defined in: packages/lexical/src/LexicalNode.ts:1013

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

Inherited from​

ElementNode.getType

importJSON()​

static importJSON(_serializedNode): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:1870

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​
_serializedNode​

Omit<SerializedLexicalNode & Partial<SerializedLexicalNode>, "$slots" | "children" | "version"> & object & Record<string, unknown>

Returns​

LexicalNode

Inherited from​

ElementNode.importJSON

transform()​

static transform(): ((node) => void) | null

Defined in: packages/lexical/src/LexicalNode.ts:1934

Experimental

Registers the returned function as a transform on the node during Editor initialization. Most such use cases should be addressed via the LexicalEditor.registerNodeTransform API.

Experimental - use at your own risk.

Returns​

((node) => void) | null

Inherited from​

ElementNode.transform

Interfaces​

CheckListConfig​

Defined in: packages/lexical-list/src/LexicalListExtension.ts:73

Properties​

disableTakeFocusOnClick​

disableTakeFocusOnClick: boolean

Defined in: packages/lexical-list/src/LexicalListExtension.ts:74


ListConfig​

Defined in: packages/lexical-list/src/LexicalListExtension.ts:24

Properties​

hasStrictIndent​

hasStrictIndent: boolean

Defined in: packages/lexical-list/src/LexicalListExtension.ts:29

When true, enforces strict indentation rules for list items, ensuring consistent structure. When false (default), indentation is more flexible.

shouldPreserveNumbering​

shouldPreserveNumbering: boolean

Defined in: packages/lexical-list/src/LexicalListExtension.ts:30


RegisterListOptions​

Defined in: packages/lexical-list/src/registerList.ts:51

Properties​

restoreNumbering?​

optional restoreNumbering?: boolean

Defined in: packages/lexical-list/src/registerList.ts:52

Type Aliases​

ListNodeTagType​

ListNodeTagType = "ul" | "ol"

Defined in: packages/lexical-list/src/LexicalListNode.ts:58


ListType​

ListType = "number" | "bullet" | "check"

Defined in: packages/lexical-list/src/LexicalListNode.ts:56


SerializedListItemNode​

SerializedListItemNode = Spread<{ checked: boolean | undefined; value: number; }, SerializedElementNode>

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:60


SerializedListNode​

SerializedListNode = Spread<{ listType: ListType; start: number; tag: ListNodeTagType; }, SerializedElementNode>

Defined in: packages/lexical-list/src/LexicalListNode.ts:47

Variables​

CheckListExtension​

const CheckListExtension: LexicalExtension<CheckListConfig, "@lexical/list/CheckList", NamedSignalsOutput<CheckListConfig>, unknown>

Defined in: packages/lexical-list/src/LexicalListExtension.ts:82

Registers checklist functionality for ListNode and ListItemNode with a INSERT_CHECK_LIST_COMMAND listener and the expected keyboard and mouse interactions for checkboxes.


INSERT_CHECK_LIST_COMMAND​

const INSERT_CHECK_LIST_COMMAND: LexicalCommand<void>

Defined in: packages/lexical-list/src/checkList.ts:65


INSERT_ORDERED_LIST_COMMAND​

const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<void>

Defined in: packages/lexical-list/src/registerList.ts:44


INSERT_UNORDERED_LIST_COMMAND​

const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<void>

Defined in: packages/lexical-list/src/registerList.ts:42


ListExtension​

const ListExtension: LexicalExtension<ListConfig, "@lexical/list/List", NamedSignalsOutput<ListConfig>, unknown>

Defined in: packages/lexical-list/src/LexicalListExtension.ts:37

Configures ListNode, ListItemNode and registers the strict indent transform if hasStrictIndent is true (default false).


ListImportExtension​

const ListImportExtension: LexicalExtension<ExtensionConfigBase, "@lexical/list/Import", unknown, unknown>

Defined in: packages/lexical-list/src/LexicalListExtension.ts:102

Experimental

Bundles ListImportRules together with the runtime ListExtension.

Deprecated​

ListExtension now registers ListImportRules (and CoreImportExtension) itself — depend on it directly instead.


ListImportRules​

const ListImportRules: (DOMImportRule<ElementSelectorBuilder<HTMLLIElement, Record<string, never>>> | DOMImportRule<ElementSelectorBuilder<HTMLOListElement | HTMLUListElement, Record<string, never>>>)[]

Defined in: packages/lexical-list/src/ListImportExtension.ts:302

Experimental

Import rules for ListNode and ListItemNode, including GitHub task-list and Joplin checkbox heuristics.

Registered by ListExtension itself (together with CoreImportExtension), so any editor that uses the list extension can import these tags through the DOMImportExtension pipeline without further configuration.


ListSchema​

const ListSchema: ChildSchema

Defined in: packages/lexical-list/src/ListImportExtension.ts:280

Experimental

A ChildSchema that enforces ListNode invariants: only ListItemNode and (immediately-nested) ListNode children are accepted; runs of other children get wrapped in a fresh ListItemNode.


REMOVE_LIST_COMMAND​

const REMOVE_LIST_COMMAND: LexicalCommand<void>

Defined in: packages/lexical-list/src/registerList.ts:47


UPDATE_LIST_START_COMMAND​

const UPDATE_LIST_START_COMMAND: LexicalCommand<{ listNodeKey: NodeKey; newStart: number; }>

Defined in: packages/lexical-list/src/registerList.ts:38


WordListImportExtension​

const WordListImportExtension: LexicalExtension<ExtensionConfigBase, "@lexical/list/WordListImport", unknown, unknown>

Defined in: packages/lexical-list/src/WordListImportExtension.ts:243

Experimental

Word list paste support for ListNode: opt in by adding this to an editor's dependencies. ListExtension does not depend on it, so an editor that never pastes from Word does not bundle any of it.

defineExtension({
dependencies: [WordListImportExtension],
name: 'my-editor',
});

Functions​

$createListItemNode()​

$createListItemNode(checked?): ListItemNode

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:746

Creates a new List Item node, passing true/false will convert it to a checkbox input.

Parameters​

checked?​

boolean

Is the List Item a checkbox and, if so, is it checked? undefined/null: not a checkbox, true/false is a checkbox and checked/unchecked, respectively.

Returns​

ListItemNode

The new List Item.


$createListNode()​

$createListNode(listType?, start?): ListNode

Defined in: packages/lexical-list/src/LexicalListNode.ts:413

Creates a ListNode of listType.

Parameters​

listType?​

ListType = 'number'

The type of list to be created. Can be 'number', 'bullet', or 'check'.

start?​

number = 1

Where an ordered list starts its count, start = 1 if left undefined.

Returns​

ListNode

The new ListNode


$getListDepth()​

$getListDepth(listNode): number

Defined in: packages/lexical-list/src/utils.ts:29

Checks the depth of listNode from the root node.

Parameters​

listNode​

ListNode

The ListNode to be checked.

Returns​

number

The depth of the ListNode.


$handleListInsertParagraph()​

$handleListInsertParagraph(restoreNumbering?): boolean

Defined in: packages/lexical-list/src/formatList.ts:557

Attempts to insert a ParagraphNode at selection and selects the new node. The selection must contain a ListItemNode or a node that does not already contain text. If its grandparent is the root/shadow root, it will get the ListNode (which should be the parent node) and insert the ParagraphNode as a sibling to the ListNode. If the ListNode is nested in a ListItemNode instead, it will add the ParagraphNode after the grandparent ListItemNode. Throws an invariant if the selection is not a child of a ListNode.

Parameters​

restoreNumbering?​

boolean = false

Returns​

boolean

true if a ParagraphNode was inserted successfully, false if there is no selection or the selection does not contain a ListItemNode or the node already holds text.


$insertList()​

$insertList(listType): void

Defined in: packages/lexical-list/src/formatList.ts:85

Inserts a new ListNode. If the selection's anchor node is an empty ListItemNode and is a child of the root/shadow root, it will replace the ListItemNode with a ListNode and the old ListItemNode. Otherwise it will replace its parent with a new ListNode and re-insert the ListItemNode and any previous children. If the selection's anchor node is not an empty ListItemNode, it will add a new ListNode or merge an existing ListNode, unless the node is a leaf node, in which case it will attempt to find a ListNode up the branch and replace it with a new ListNode, or create a new ListNode at the nearest root/shadow root.

Parameters​

listType​

ListType

The type of list, "number" | "bullet" | "check".

Returns​

void


$isListItemNode()​

$isListItemNode(node): node is ListItemNode

Defined in: packages/lexical-list/src/LexicalListItemNode.ts:755

Checks to see if the node is a ListItemNode.

Parameters​

node​

LexicalNode | null | undefined

The node to be checked.

Returns​

node is ListItemNode

true if the node is a ListItemNode, false otherwise.


$isListNode()​

$isListNode(node): node is ListNode

Defined in: packages/lexical-list/src/LexicalListNode.ts:425

Checks to see if the node is a ListNode.

Parameters​

node​

LexicalNode | null | undefined

The node to be checked.

Returns​

node is ListNode

true if the node is a ListNode, false otherwise.


$removeList()​

$removeList(): void

Defined in: packages/lexical-list/src/formatList.ts:286

Searches for the nearest ancestral ListNode and removes it. If selection is an empty ListItemNode it will remove the whole list, including the ListItemNode. For each ListItemNode in the ListNode, removeList will also generate new ParagraphNodes in the removed ListNode's place. Any child node inside a ListItemNode will be appended to the new ParagraphNodes.

Returns​

void


registerCheckList()​

registerCheckList(editor, options?): () => void

Defined in: packages/lexical-list/src/checkList.ts:75

Registers the checklist plugin with the editor.

Parameters​

editor​

LexicalEditor

The LexicalEditor instance.

options?​

Optional configuration.

  • disableTakeFocusOnClick: If true, clicking a checklist item will not focus the editor (useful for mobile).
disableTakeFocusOnClick?​

boolean | Signal<boolean>

Returns​

() => void


registerList()​

registerList(editor, options?): () => void

Defined in: packages/lexical-list/src/registerList.ts:55

Parameters​

editor​

LexicalEditor

options?​

RegisterListOptions

Returns​

() => void


registerListStrictIndentTransform()​

registerListStrictIndentTransform(editor): () => void

Defined in: packages/lexical-list/src/registerList.ts:185

Parameters​

editor​

LexicalEditor

Returns​

() => void