Skip to main content

@lexical/link

Classes

AutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:510

Extends

Constructors

Constructor

new AutoLinkNode(url?, attributes?, key?): AutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:526

Parameters
url?

string = ''

attributes?

AutoLinkAttributes = {}

key?

string

Returns

AutoLinkNode

Inherited from

LinkNode.constructor

Properties

__isUnlinked

__isUnlinked: boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:524

Indicates whether the autolink was ever unlinked. *

importDOM?

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

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

Returns

DOMConversionMap<any> | null

Inherited from

LinkNode.importDOM

Methods

$config()

$config(): BaseStaticNodeConfig & StaticNodeConfigAccessor<{ $transform: { }; extends: typeof LexicalNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<ElementNode, { direction?: "ltr" | "rtl" | null; format?: "" | "left" | "start" | "center" | "right" | "end" | "justify"; indent?: string | number; textFormat?: string | number; textStyle?: string; }>; }> & object & StaticNodeTypeAccessor<"link"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; generated: GeneratedJSONFactory; importDOM: { a: () => object; }; json: NodeSerializationSchema<LinkNode, { rel?: string | null; target?: string | null; title?: string | null; url?: string; }>; }> & object & StaticNodeTypeAccessor<"autolink"> & StaticNodeConfigAccessor<{ extends: typeof LinkNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<AutoLinkNode, { isUnlinked?: boolean; }>; }>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:538

Override this to implement the new static node configuration protocol, this method is called directly on the prototype and must not depend on anything initialized in the constructor. Generally it should be a trivial implementation.

Returns

BaseStaticNodeConfig & StaticNodeConfigAccessor<{ $transform: { }; extends: typeof LexicalNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<ElementNode, { direction?: "ltr" | "rtl" | null; format?: "" | "left" | "start" | "center" | "right" | "end" | "justify"; indent?: string | number; textFormat?: string | number; textStyle?: string; }>; }> & object & StaticNodeTypeAccessor<"link"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; generated: GeneratedJSONFactory; importDOM: { a: () => object; }; json: NodeSerializationSchema<LinkNode, { rel?: string | null; target?: string | null; title?: string | null; url?: string; }>; }> & object & StaticNodeTypeAccessor<"autolink"> & StaticNodeConfigAccessor<{ extends: typeof LinkNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<AutoLinkNode, { isUnlinked?: boolean; }>; }>

Example
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Inherited from

LinkNode.$config

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

LinkNode.afterCloneFrom

append()

append(...nodesToAppend): this

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

Parameters
nodesToAppend

...LexicalNode[]

Returns

this

Inherited from

LinkNode.append

canBeEmpty()

canBeEmpty(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:292

Returns

boolean

Inherited from

LinkNode.canBeEmpty

canIndent()

canIndent(): boolean

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

Returns

boolean

Inherited from

LinkNode.canIndent

canInsertTextAfter()

canInsertTextAfter(): false

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:288

Returns

false

Inherited from

LinkNode.canInsertTextAfter

canInsertTextBefore()

canInsertTextBefore(): false

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:284

Returns

false

Inherited from

LinkNode.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

LinkNode.canMergeWhenEmpty

clear()

clear(): this

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

Returns

this

Inherited from

LinkNode.clear

collapseAtStart()

collapseAtStart(selection): boolean

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

Parameters
selection

RangeSelection

Returns

boolean

Inherited from

LinkNode.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<AutoLinkNode, string>

Parameters
type

symbol

config

Config

Returns

AbstractStaticNodeConfigRecord<Config>

Inherited from

LinkNode.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<AutoLinkNode, Type>

Parameters
type

Type

config

Config

Returns

StaticNodeConfigRecord<Type, Config>

Inherited from

LinkNode.config

createDOM()

createDOM(config): LinkHTMLElementType

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:560

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

LinkHTMLElementType

Inherited from

LinkNode.createDOM

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

LinkNode.createParentElementNode

excludeFromCopy()

excludeFromCopy(destination?): boolean

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

Parameters
destination?

"clone" | "html"

Returns

boolean

Inherited from

LinkNode.excludeFromCopy

exportDOM()

exportDOM(editor): DOMExportOutput

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

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

LinkNode.exportDOM

exportJSON()
Call Signature

exportJSON(compact?): SerializedAutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:511

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

SerializedAutoLinkNode

Inherited from

LinkNode.exportJSON

Call Signature

exportJSON(compact): SerializedPartial<SerializedAutoLinkNode>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:512

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<SerializedAutoLinkNode>

See

SerializedPartial

Inherited from

LinkNode.exportJSON

extractWithChild()

extractWithChild(child, selection, destination): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:300

Parameters
child

LexicalNode

selection

BaseSelection

destination

"clone" | "html"

Returns

boolean

Inherited from

LinkNode.extractWithChild

getAllTextNodes()

getAllTextNodes(): TextNode[]

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

Returns

TextNode[]

Inherited from

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.getChildren

getChildrenKeys()

getChildrenKeys(): string[]

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

Returns

string[]

Inherited from

LinkNode.getChildrenKeys

getChildrenSize()

getChildrenSize(): number

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

Returns

number

Inherited from

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.getDescendantByIndex

getDirection()

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

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

Returns

"ltr" | "rtl" | null

Inherited from

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.getFirstDescendant

getFormat()

getFormat(): number

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

Returns

number

Inherited from

LinkNode.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

LinkNode.getFormatFlags

getFormatType()

getFormatType(): ElementFormatType

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

Returns

ElementFormatType

Inherited from

LinkNode.getFormatType

getIndent()

getIndent(): number

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

Returns

number

Inherited from

LinkNode.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

LinkNode.getIndexWithinParent

getIsUnlinked()

getIsUnlinked(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:550

Returns

boolean

getKey()

getKey(): string

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

Returns this nodes key.

Returns

string

Inherited from

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.getPreviousSiblings

getRel()

getRel(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:255

Returns

string | null

Inherited from

LinkNode.getRel

getStyle()

getStyle(): string

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

Returns

string

Inherited from

LinkNode.getStyle

getTarget()

getTarget(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:245

Returns

string | null

Inherited from

LinkNode.getTarget

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

LinkNode.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

LinkNode.getTextContentSize

getTextFormat()

getTextFormat(): number

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

Returns

number

Inherited from

LinkNode.getTextFormat

getTextStyle()

getTextStyle(): string

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

Returns

string

Inherited from

LinkNode.getTextStyle

getTitle()

getTitle(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:265

Returns

string | null

Inherited from

LinkNode.getTitle

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

LinkNode.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

LinkNode.getTopLevelElementOrThrow

getType()

getType(): string

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

Returns the string type of this node.

Returns

string

Inherited from

LinkNode.getType

getURL()

getURL(): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:235

Returns

string

Inherited from

LinkNode.getURL

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

LinkNode.getWritable

hasFormat()

hasFormat(type): boolean

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

Parameters
type

ElementFormatType

Returns

boolean

Inherited from

LinkNode.hasFormat

hasTextFormat()

hasTextFormat(type): boolean

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

Parameters
type

TextFormatType

Returns

boolean

Inherited from

LinkNode.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

LinkNode.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

LinkNode.insertBefore

insertNewAfter()

insertNewAfter(_, restoreSelection?): ElementNode | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:275

Parameters
_

RangeSelection

restoreSelection?

boolean = true

Returns

ElementNode | null

Inherited from

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.isDirty

isEmailURI()

isEmailURI(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:319

Returns

boolean

Inherited from

LinkNode.isEmailURI

isEmpty()

isEmpty(): boolean

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

Returns

boolean

Inherited from

LinkNode.isEmpty

isInline()

isInline(): true

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:296

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

Returns

true

Inherited from

LinkNode.isInline

isLastChild()

isLastChild(): boolean

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

Returns

boolean

Inherited from

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.isSelected

isShadowRoot()

isShadowRoot(): boolean

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

Returns

boolean

Inherited from

LinkNode.isShadowRoot

isWebSiteURI()

isWebSiteURI(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:323

Returns

boolean

Inherited from

LinkNode.isWebSiteURI

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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.resetOnCopyNodeFrom

sanitizeUrl()

sanitizeUrl(url): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:190

Parameters
url

string

Returns

string

Inherited from

LinkNode.sanitizeUrl

select()

select(_anchorOffset?, _focusOffset?): RangeSelection

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

Parameters
_anchorOffset?

number

_focusOffset?

number

Returns

RangeSelection

Inherited from

LinkNode.select

selectEnd()

selectEnd(): RangeSelection

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

Returns

RangeSelection

Inherited from

LinkNode.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

LinkNode.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

LinkNode.selectPrevious

selectStart()

selectStart(): RangeSelection

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

Returns

RangeSelection

Inherited from

LinkNode.selectStart

setDirection()

setDirection(direction): this

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

Parameters
direction

"ltr" | "rtl" | null

Returns

this

Inherited from

LinkNode.setDirection

setFormat()

setFormat(type): this

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

Parameters
type

ElementFormatType

Returns

this

Inherited from

LinkNode.setFormat

setIndent()

setIndent(indentLevel): this

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

Parameters
indentLevel

number

Returns

this

Inherited from

LinkNode.setIndent

setIsUnlinked()

setIsUnlinked(value): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:554

Parameters
value

boolean

Returns

this

setRel()

setRel(rel): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:259

Parameters
rel

string | null

Returns

this

Inherited from

LinkNode.setRel

setStyle()

setStyle(style): this

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

Parameters
style

string

Returns

this

Inherited from

LinkNode.setStyle

setTarget()

setTarget(target): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:249

Parameters
target

string | null

Returns

this

Inherited from

LinkNode.setTarget

setTextFormat()

setTextFormat(type): this

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

Parameters
type

number

Returns

this

Inherited from

LinkNode.setTextFormat

setTextStyle()

setTextStyle(style): this

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

Parameters
style

string

Returns

this

Inherited from

LinkNode.setTextStyle

setTitle()

setTitle(title): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:269

Parameters
title

string | null

Returns

this

Inherited from

LinkNode.setTitle

setURL()

setURL(url): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:239

Parameters
url

string

Returns

this

Inherited from

LinkNode.setURL

shouldMergeAdjacentLink(_otherLink): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:546

Parameters

LinkNode

Returns

boolean

Inherited from

LinkNode.shouldMergeAdjacentLink

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

LinkNode.splice

updateDOM()

updateDOM(prevNode, anchor, config): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:568

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

anchor

LinkHTMLElementType

config

EditorConfig

Returns

boolean

Inherited from

LinkNode.updateDOM

updateFromJSON()

updateFromJSON(serializedNode): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:513

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<SerializedAutoLinkNode>

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

LinkNode.updateFromJSON

updateLinkDOM()

updateLinkDOM(prevNode, anchor, config): void

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:158

Parameters
prevNode

AutoLinkNode | null

anchor

LinkHTMLElementType

config

EditorConfig

Returns

void

Inherited from

LinkNode.updateLinkDOM

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

LinkNode.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

LinkNode.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

LinkNode.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

LinkNode.transform


LinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:106

Extends

Extended by

Constructors

Constructor

new LinkNode(url?, attributes?, key?): LinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:138

Parameters
url?

string = ''

attributes?

LinkAttributes = {}

key?

string

Returns

LinkNode

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

$config()

$config(): BaseStaticNodeConfig & StaticNodeConfigAccessor<{ $transform: { }; extends: typeof LexicalNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<ElementNode, { direction?: "ltr" | "rtl" | null; format?: "" | "left" | "start" | "center" | "right" | "end" | "justify"; indent?: string | number; textFormat?: string | number; textStyle?: string; }>; }> & object & StaticNodeTypeAccessor<"link"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; generated: GeneratedJSONFactory; importDOM: { a: () => object; }; json: NodeSerializationSchema<LinkNode, { rel?: string | null; target?: string | null; title?: string | null; url?: string; }>; }>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:124

Override this to implement the new static node configuration protocol, this method is called directly on the prototype and must not depend on anything initialized in the constructor. Generally it should be a trivial implementation.

Returns

BaseStaticNodeConfig & StaticNodeConfigAccessor<{ $transform: { }; extends: typeof LexicalNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<ElementNode, { direction?: "ltr" | "rtl" | null; format?: "" | "left" | "start" | "center" | "right" | "end" | "justify"; indent?: string | number; textFormat?: string | number; textStyle?: string; }>; }> & object & StaticNodeTypeAccessor<"link"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; generated: GeneratedJSONFactory; importDOM: { a: () => object; }; json: NodeSerializationSchema<LinkNode, { rel?: string | null; target?: string | null; title?: string | null; url?: string; }>; }>

Example
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Inherited from

ElementNode.$config

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(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:292

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(): false

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:288

Returns

false

Inherited from

ElementNode.canInsertTextAfter

canInsertTextBefore()

canInsertTextBefore(): false

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:284

Returns

false

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<LinkNode, 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<LinkNode, Type>

Parameters
type

Type

config

Config

Returns

StaticNodeConfigRecord<Type, Config>

Inherited from

ElementNode.config

createDOM()

createDOM(config): LinkHTMLElementType

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:151

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

LinkHTMLElementType

Inherited from

ElementNode.createDOM

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/src/nodes/LexicalElementNode.ts:967

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?): SerializedLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:107

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

SerializedLinkNode

Inherited from

ElementNode.exportJSON

Call Signature

exportJSON(compact): SerializedPartial<SerializedLinkNode>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:108

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<SerializedLinkNode>

See

SerializedPartial

Inherited from

ElementNode.exportJSON

extractWithChild()

extractWithChild(child, selection, destination): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:300

Parameters
child

LexicalNode

selection

BaseSelection

destination

"clone" | "html"

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

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

getRel()

getRel(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:255

Returns

string | null

getStyle()

getStyle(): string

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

Returns

string

Inherited from

ElementNode.getStyle

getTarget()

getTarget(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:245

Returns

string | null

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

getTitle()

getTitle(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:265

Returns

string | null

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

getURL()

getURL(): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:235

Returns

string

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(_, restoreSelection?): ElementNode | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:275

Parameters
_

RangeSelection

restoreSelection?

boolean = true

Returns

ElementNode | 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

isEmailURI()

isEmailURI(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:319

Returns

boolean

isEmpty()

isEmpty(): boolean

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

Returns

boolean

Inherited from

ElementNode.isEmpty

isInline()

isInline(): true

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:296

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

Returns

true

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

isWebSiteURI()

isWebSiteURI(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:323

Returns

boolean

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

sanitizeUrl()

sanitizeUrl(url): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:190

Parameters
url

string

Returns

string

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

setRel()

setRel(rel): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:259

Parameters
rel

string | null

Returns

this

setStyle()

setStyle(style): this

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

Parameters
style

string

Returns

this

Inherited from

ElementNode.setStyle

setTarget()

setTarget(target): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:249

Parameters
target

string | null

Returns

this

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

setTitle()

setTitle(title): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:269

Parameters
title

string | null

Returns

this

setURL()

setURL(url): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:239

Parameters
url

string

Returns

this

shouldMergeAdjacentLink(otherLink): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:328

Parameters

LinkNode

Returns

boolean

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

updateDOM()

updateDOM(prevNode, anchor, config): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:181

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

anchor

LinkHTMLElementType

config

EditorConfig

Returns

boolean

Inherited from

ElementNode.updateDOM

updateFromJSON()

updateFromJSON(serializedNode): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:109

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<SerializedLinkNode>

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

updateLinkDOM()

updateLinkDOM(prevNode, anchor, config): void

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:158

Parameters
prevNode

LinkNode | null

anchor

LinkHTMLElementType

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

Interfaces

AutoLinkAnnounceExtensionConfig

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:15

Properties

created

created: string

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:17

Announced when typing turns text into a link.

createdMany

createdMany: string

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:22

Announced when several links appear at once, as pasting a block of text can. %s is replaced with how many.

destroyed

destroyed: string

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:24

Announced when an automatic link stops being a link.

destroyedMany

destroyedMany: string

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:29

Announced when several links go at once, as deleting a selection that spans them does. %s is replaced with how many.

disabled

disabled: boolean

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:34

When true, automatic links are not announced. Toggle at runtime via the output signal. Default false.


AutoLinkConfig

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:601

Properties

changeHandlers

changeHandlers: ChangeHandler[]

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:602

excludeParents

excludeParents: (parent) => boolean[]

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:603

Parameters
parent

ElementNode

Returns

boolean

matchers

matchers: LinkMatcher[]

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:604

separatorRegex

separatorRegex: RegExp

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:610

The regular expression used to determine whether surrounding characters count as separators when validating auto-link boundaries. Defaults to /[.,;\s]/.


ClickableLinkConfig

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:42

Properties

disabled

disabled: boolean

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:46

Disable this extension when true (default false)

newTab

newTab: boolean

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:44

Open clicked links in a new tab when true (default false)

Type Aliases

AutoLinkAttributes

AutoLinkAttributes = Partial<Spread<LinkAttributes, { isUnlinked?: boolean; }>>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:61


ChangeHandler

ChangeHandler = (url, prevUrl) => void

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:43

A callback invoked when the auto-link plugin creates, updates, or removes an automatic link. It receives the new url and the prevUrl; either may be null when a link is added or removed.

Parameters

url

string | null

prevUrl

string | null

Returns

void


LinkAttributes

LinkAttributes = object

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:55

Properties

rel?

optional rel?: null | string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:56

target?

optional target?: null | string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:57

title?

optional title?: null | string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:58


LinkMatcher

LinkMatcher = (text) => LinkMatcherResult | null

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:61

A function that inspects a piece of text and returns a LinkMatcherResult for the first URL it recognizes, or null if none is found. Used by the auto-link plugin to detect links as the user types.

Parameters

text

string

Returns

LinkMatcherResult | null


SerializedAutoLinkNode

SerializedAutoLinkNode = Spread<{ isUnlinked: boolean; }, SerializedLinkNode>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:492


SerializedLinkNode

SerializedLinkNode = Spread<{ url: string; }, Spread<LinkAttributes, SerializedElementNode>>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:65

Variables

AutoLinkAnnounceExtension

const AutoLinkAnnounceExtension: LexicalExtension<AutoLinkAnnounceExtensionConfig, "@lexical/link/AutoLinkAnnounce", NamedSignalsOutput<AutoLinkAnnounceExtensionConfig>, unknown>

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:50

Announces automatic links through the AriaLiveRegionExtension sink.

Typing a web address turns it into a link on its own, partway through typing it, with no keystroke to confirm and nothing inserted. A screen reader says nothing, so the user has no way to know a link now exists.

A creation paired with a destruction in the same update is not announced. Every keystroke that extends an address rebuilds the link — the old node destroyed and a new one created at once — so announcing every creation would say "Link" at www.example.c, again at o, and again at m. Only a creation on its own is a link that was not there a moment ago.


autoLinkEmailMatcher

const autoLinkEmailMatcher: LinkMatcher

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:132

A ready-to-use LinkMatcher for email addresses. Bounded quantifiers keep matching linear-time; the limits comfortably exceed RFC 5321 maximums.


AutoLinkExtension

const AutoLinkExtension: LexicalExtension<AutoLinkConfig, "@lexical/link/AutoLink", unknown, unknown>

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:698

An extension to automatically create AutoLinkNode from text that matches the configured matchers. For ready-to-use matchers see autoLinkUrlMatcher (Unicode URL detection with parenthesis balancing) and autoLinkEmailMatcher (email addresses). To build a custom matcher from a RegExp, see createLinkMatcherWithRegExp.

The given matchers and changeHandlers will be merged by concatenating the configured arrays.


autoLinkUrlMatcher

const autoLinkUrlMatcher: LinkMatcher

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:102

A ready-to-use LinkMatcher for URLs with full Unicode support (\\p{L}, \\p{N}). Handles parenthesis balancing so that Wikipedia-style URLs like https://en.wikipedia.org/wiki/Fish_(disambiguation) are matched correctly even when wrapped in prose parentheses.


ClickableLinkExtension

const ClickableLinkExtension: LexicalExtension<ClickableLinkConfig, "@lexical/link/ClickableLink", NamedSignalsOutput<ClickableLinkConfig>, unknown>

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:145

Normally in a Lexical editor the CLICK_COMMAND on a LinkNode will cause the selection to change instead of opening a link. This extension can be used to restore the default behavior, e.g. when the editor is not editable.


LinkExtension

const LinkExtension: LexicalExtension<LinkConfig, "@lexical/link/Link", NamedSignalsOutput<LinkConfig>, unknown>

Defined in: packages/lexical-link/src/LexicalLinkExtension.ts:157

Provides LinkNode, an implementation of TOGGLE_LINK_COMMAND, and a PASTE_COMMAND listener to wrap selected nodes in a link when a URL is pasted and validateUrl is defined.


LinkImportExtension

const LinkImportExtension: LexicalExtension<ExtensionConfigBase, "@lexical/link/Import", unknown, unknown>

Defined in: packages/lexical-link/src/LexicalLinkExtension.ts:197

Experimental

Bundles LinkImportRules together with the runtime LinkExtension.

Deprecated

LinkExtension now registers LinkImportRules (and CoreImportExtension) itself — depend on it directly instead.


LinkImportRules

const LinkImportRules: DOMImportRule<ElementSelectorBuilder<HTMLAnchorElement, Record<string, never>>>[]

Defined in: packages/lexical-link/src/LinkImportExtension.ts:48

Experimental

Import rules for LinkNode.

Registered by LinkExtension itself (together with CoreImportExtension), so any editor that uses the link extension can import <a> through the DOMImportExtension pipeline without further configuration.


const TOGGLE_LINK_COMMAND: LexicalCommand<string | object & LinkAttributes | null>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:612

Functions

$createAutoLinkNode()

$createAutoLinkNode(url?, attributes?): AutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:594

Takes a URL and creates an AutoLinkNode. AutoLinkNodes are generally automatically generated during typing, which is especially useful when a button to generate a LinkNode is not practical.

Parameters

url?

string = ''

The URL the LinkNode should direct to.

attributes?

Partial<Spread<LinkAttributes, { isUnlinked?: boolean; }>>

Optional HTML a tag attributes. { target, rel, title }

Returns

AutoLinkNode

The LinkNode.


$createLinkNode()

$createLinkNode(url?, attributes?): LinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:474

Takes a URL and creates a LinkNode.

Parameters

url?

string = ''

The URL the LinkNode should direct to.

attributes?

LinkAttributes

Optional HTML a tag attributes { target, rel, title }

Returns

LinkNode

The LinkNode.


$isAutoLinkNode()

$isAutoLinkNode(node): node is AutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:606

Determines if node is an AutoLinkNode.

Parameters

node

LexicalNode | null | undefined

The node to be checked.

Returns

node is AutoLinkNode

true if node is an AutoLinkNode, false otherwise.


$isLinkNode()

$isLinkNode(node): node is LinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:486

Determines if node is a LinkNode.

Parameters

node

LexicalNode | null | undefined

The node to be checked.

Returns

node is LinkNode

true if node is a LinkNode, false otherwise.


$toggleLink(urlOrAttributes, attributes?): void

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:741

Generates or updates a LinkNode. It can also delete a LinkNode if the URL is null, but saves any children and brings them up to the parent node.

Parameters

urlOrAttributes

string | LinkAttributes & object | null

The URL the link directs to, or an attributes object with an url property

attributes?

LinkAttributes = {}

Optional HTML a tag attributes. { target, rel, title }

Returns

void


createLinkMatcherWithRegExp()

createLinkMatcherWithRegExp(regExp, urlTransformer?): (text) => { index: number; length: number; text: string; url: string; } | null

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:72

Builds a LinkMatcher from a regular expression. The matched text is used as the link URL, optionally rewritten by urlTransformer (for example to prepend a protocol). Pass the result to the auto-link plugin's matchers.

Parameters

regExp

RegExp

urlTransformer?

(text) => string

Returns

A matcher that reports the first match of regExp in the text.

@NO_SIDE_EFFECTS

(text) => { index: number; length: number; text: string; url: string; } | null


formatUrl()

formatUrl(url): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:944

Formats a URL string by adding appropriate protocol if missing

Parameters

url

string

URL to format

Returns

string

Formatted URL with appropriate protocol


registerAutoLink(editor, config?): () => void

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:620

Parameters

editor

LexicalEditor

config?

Partial<AutoLinkConfig> & Omit<AutoLinkConfig, "separatorRegex"> = defaultConfig

Returns

() => void


registerClickableLink(editor, stores, eventOptions?): () => void

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:49

Parameters

editor

LexicalEditor

stores

NamedSignalsOutput<ClickableLinkConfig>

eventOptions?

Pick<AddEventListenerOptions, "signal"> = {}

Returns

() => void