Skip to main content

@lexical/extension

Classes​

DecoratorTextNode​

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:44

Extends​

Constructors​

Constructor​

new DecoratorTextNode(key?): DecoratorTextNode

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

Parameters​
key?​

string

Returns​

DecoratorTextNode

Inherited from​

DecoratorNode.constructor

Properties​

importDOM?​

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

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

Returns​

DOMConversionMap<any> | null

Inherited from​

DecoratorNode.importDOM

Methods​

$config()​

$config(): StaticNodeConfigRecord<"decorator-text", { extends: typeof DecoratorNode; stateConfigs: object[]; }>

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:45

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​

StaticNodeConfigRecord<"decorator-text", { extends: typeof DecoratorNode; stateConfigs: object[]; }>

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

DecoratorNode.$config

afterCloneFrom()​

afterCloneFrom(prevNode): void

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

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​

DecoratorNode.afterCloneFrom

config()​

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

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

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

Type Parameters​
Type​

Type extends string

Config​

Config extends StaticNodeConfigValue<DecoratorTextNode, Type>

Parameters​
type​

Type

config​

Config

Returns​

StaticNodeConfigRecord<Type, Config>

Inherited from​

DecoratorNode.config

createDOM()​

createDOM(): HTMLElement

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:79

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.

Returns​

HTMLElement

Overrides​

DecoratorNode.createDOM

createParentElementNode()​

createParentElementNode(): ElementNode

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

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

Returns​

ElementNode

Inherited from​

DecoratorNode.createParentElementNode

decorate()​

decorate(editor, config): unknown

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:30

The returned value is added to the LexicalEditor._decorators

Parameters​
editor​

LexicalEditor

config​

EditorConfig

Returns​

unknown

Inherited from​

DecoratorNode.decorate

exportDOM()​

exportDOM(editor): DOMExportOutput

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

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​

DecoratorNode.exportDOM

exportJSON()​

exportJSON(): SerializedLexicalNode

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

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.

Returns​

SerializedLexicalNode

Inherited from​

DecoratorNode.exportJSON

getCommonAncestor()​

getCommonAncestor<T>(node): T | null

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

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​

DecoratorNode.getCommonAncestor

getDOMSlot()​

getDOMSlot(element): DOMSlot<HTMLElement>

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

Experimental

Returns a DOMSlot pointing at the content-bearing element of this node's DOM. The default returns a slot wrapping the keyed DOM as-is.

Override this when createDOM returns a wrapper around the content-bearing element (e.g. <span><br/></span> for a styled line break), so selection / reconciliation logic can target the inner element.

ElementNode overrides this to return an ElementDOMSlot with children-management semantics (used by the reconciler to place managed children).

Parameters​
element​

HTMLElement

Returns​

DOMSlot<HTMLElement>

Inherited from​

DecoratorNode.getDOMSlot

getFormat()​

getFormat(): number

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:52

Returns​

number

getFormatFlags()​

getFormatFlags(type, alignWithFormat): number

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:56

Parameters​
type​

TextFormatType

alignWithFormat​

number | null

Returns​

number

getIndexWithinParent()​

getIndexWithinParent(): number

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

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

Returns​

number

Inherited from​

DecoratorNode.getIndexWithinParent

getKey()​

getKey(): string

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

Returns this nodes key.

Returns​

string

Inherited from​

DecoratorNode.getKey

getLatest()​

getLatest(): this

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

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​

DecoratorNode.getLatest

getNextSibling()​

getNextSibling<T>(): T | null

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

Returns the "next" siblings - that is, the node that comes after this one in the same parent

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Inherited from​

DecoratorNode.getNextSibling

getNextSiblings()​

getNextSiblings<T>(): T[]

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

Returns all "next" siblings - that is, the nodes that come between this one and the last child of it's parent, inclusive.

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Inherited from​

DecoratorNode.getNextSiblings

getNodesBetween()​

getNodesBetween(targetNode): LexicalNode[]

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

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​

DecoratorNode.getNodesBetween

getParent()​

getParent<T>(): T | null

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

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

Type Parameters​
T​

T extends ElementNode

Returns​

T | null

Inherited from​

DecoratorNode.getParent

getParentKeys()​

getParentKeys(): string[]

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

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

Returns​

string[]

Inherited from​

DecoratorNode.getParentKeys

getParentOrThrow()​

getParentOrThrow<T>(): T

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

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

Type Parameters​
T​

T extends ElementNode

Returns​

T

Inherited from​

DecoratorNode.getParentOrThrow

getParents()​

getParents(): ElementNode[]

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

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

Returns​

ElementNode[]

Inherited from​

DecoratorNode.getParents

getPreviousSibling()​

getPreviousSibling<T>(): T | null

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

Returns the "previous" siblings - that is, the node that comes before this one in the same parent.

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Inherited from​

DecoratorNode.getPreviousSibling

getPreviousSiblings()​

getPreviousSiblings<T>(): T[]

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

Returns the "previous" siblings - that is, the nodes that come between this one and the first child of it's parent, inclusive.

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Inherited from​

DecoratorNode.getPreviousSiblings

getTextContent()​

getTextContent(): string

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

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​

DecoratorNode.getTextContent

getTextContentSize()​

getTextContentSize(): number

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

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

Returns​

number

Inherited from​

DecoratorNode.getTextContentSize

getTopLevelElement()​

getTopLevelElement(): ElementNode | DecoratorTextNode | null

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:17

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 | DecoratorTextNode | null

Inherited from​

DecoratorNode.getTopLevelElement

getTopLevelElementOrThrow()​

getTopLevelElementOrThrow(): ElementNode | DecoratorTextNode

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:18

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

Inherited from​

DecoratorNode.getTopLevelElementOrThrow

getType()​

getType(): string

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

Returns the string type of this node.

Returns​

string

Inherited from​

DecoratorNode.getType

getWritable()​

getWritable(): this

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

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​

DecoratorNode.getWritable

hasFormat()​

hasFormat(type): boolean

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:60

Parameters​
type​

TextFormatType

Returns​

boolean

insertAfter()​

insertAfter(nodeToInsert, restoreSelection?): LexicalNode

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

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​

DecoratorNode.insertAfter

insertBefore()​

insertBefore(nodeToInsert, restoreSelection?): LexicalNode

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

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​

DecoratorNode.insertBefore

is()​

is(object): boolean

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

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​

DecoratorNode.is

isAttached()​

isAttached(): boolean

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

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​

DecoratorNode.isAttached

isBefore()​

isBefore(targetNode): boolean

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

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​

DecoratorNode.isBefore

isDirty()​

isDirty(): boolean

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

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

Returns​

boolean

Inherited from​

DecoratorNode.isDirty

isInline()​

isInline(): true

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:75

Returns​

true

Overrides​

DecoratorNode.isInline

isIsolated()​

isIsolated(): boolean

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:34

Returns​

boolean

Inherited from​

DecoratorNode.isIsolated

isKeyboardSelectable()​

isKeyboardSelectable(): boolean

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:42

Returns​

boolean

Inherited from​

DecoratorNode.isKeyboardSelectable

isParentOf()​

isParentOf(targetNode): boolean

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

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​

DecoratorNode.isParentOf

isParentRequired()​

isParentRequired(): boolean

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

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​

DecoratorNode.isParentRequired

isSelected()​

isSelected(selection?): boolean

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

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​

DecoratorNode.isSelected

markDirty()​

markDirty(): void

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

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

Returns​

void

Inherited from​

DecoratorNode.markDirty

remove()​

remove(preserveEmptyParent?): void

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

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​

DecoratorNode.remove

replace()​

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

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

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

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​

DecoratorNode.replace

resetOnCopyNodeFrom()​

resetOnCopyNodeFrom(originalNode): void

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

Reset state in this copy of originalNode, if necessary

Parameters​
originalNode​

this

Returns​

void

Inherited from​

DecoratorNode.resetOnCopyNodeFrom

selectEnd()​

selectEnd(): RangeSelection

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

Returns​

RangeSelection

Inherited from​

DecoratorNode.selectEnd

selectNext()​

selectNext(anchorOffset?, focusOffset?): RangeSelection

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

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​

DecoratorNode.selectNext

selectPrevious()​

selectPrevious(anchorOffset?, focusOffset?): RangeSelection

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

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​

DecoratorNode.selectPrevious

selectStart()​

selectStart(): RangeSelection

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

Returns​

RangeSelection

Inherited from​

DecoratorNode.selectStart

setFormat()​

setFormat(type): this

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:65

Parameters​
type​

StateValueOrUpdater<StateConfig<"format", number>>

Returns​

this

toggleFormat()​

toggleFormat(type): this

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:69

Parameters​
type​

TextFormatType

Returns​

this

updateDOM()​

updateDOM(): false

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:83

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.

Returns​

false

Overrides​

DecoratorNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

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

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​

LexicalUpdateJSON<SerializedLexicalNode>

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);
}
}
Inherited from​

DecoratorNode.updateFromJSON

clone()​

static clone(_data): LexicalNode

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

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​

DecoratorNode.clone

getType()​

static getType(): string

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

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​

DecoratorNode.getType

importJSON()​

static importJSON(_serializedNode): LexicalNode

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

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​

SerializedLexicalNode

Returns​

LexicalNode

Inherited from​

DecoratorNode.importJSON

transform()​

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

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

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​

DecoratorNode.transform


HorizontalRuleNode​

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:51

Extends​

Extended by​

Constructors​

Constructor​

new HorizontalRuleNode(key?): HorizontalRuleNode

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

Parameters​
key?​

string

Returns​

HorizontalRuleNode

Inherited from​

DecoratorNode.constructor

Methods​

$config()​

$config(): BaseStaticNodeConfig

Defined in: packages/lexical/src/LexicalNode.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

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

DecoratorNode.$config

afterCloneFrom()​

afterCloneFrom(prevNode): void

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

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​

DecoratorNode.afterCloneFrom

config()​

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

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

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

Type Parameters​
Type​

Type extends string

Config​

Config extends StaticNodeConfigValue<HorizontalRuleNode, Type>

Parameters​
type​

Type

config​

Config

Returns​

StaticNodeConfigRecord<Type, Config>

Inherited from​

DecoratorNode.config

createDOM()​

createDOM(config): HTMLElement

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:79

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

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

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

Parameters​
config​

EditorConfig

Returns​

HTMLElement

Overrides​

DecoratorNode.createDOM

createParentElementNode()​

createParentElementNode(): ElementNode

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

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

Returns​

ElementNode

Inherited from​

DecoratorNode.createParentElementNode

decorate()​

decorate(editor, config): unknown

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:30

The returned value is added to the LexicalEditor._decorators

Parameters​
editor​

LexicalEditor

config​

EditorConfig

Returns​

unknown

Inherited from​

DecoratorNode.decorate

exportDOM()​

exportDOM(): DOMExportOutput

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:75

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.

Returns​

DOMExportOutput

Overrides​

DecoratorNode.exportDOM

exportJSON()​

exportJSON(): SerializedLexicalNode

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

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.

Returns​

SerializedLexicalNode

Inherited from​

DecoratorNode.exportJSON

getCommonAncestor()​

getCommonAncestor<T>(node): T | null

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

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​

DecoratorNode.getCommonAncestor

getDOMSlot()​

getDOMSlot(element): DOMSlot<HTMLElement>

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

Experimental

Returns a DOMSlot pointing at the content-bearing element of this node's DOM. The default returns a slot wrapping the keyed DOM as-is.

Override this when createDOM returns a wrapper around the content-bearing element (e.g. <span><br/></span> for a styled line break), so selection / reconciliation logic can target the inner element.

ElementNode overrides this to return an ElementDOMSlot with children-management semantics (used by the reconciler to place managed children).

Parameters​
element​

HTMLElement

Returns​

DOMSlot<HTMLElement>

Inherited from​

DecoratorNode.getDOMSlot

getIndexWithinParent()​

getIndexWithinParent(): number

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

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

Returns​

number

Inherited from​

DecoratorNode.getIndexWithinParent

getKey()​

getKey(): string

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

Returns this nodes key.

Returns​

string

Inherited from​

DecoratorNode.getKey

getLatest()​

getLatest(): this

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

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​

DecoratorNode.getLatest

getNextSibling()​

getNextSibling<T>(): T | null

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

Returns the "next" siblings - that is, the node that comes after this one in the same parent

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Inherited from​

DecoratorNode.getNextSibling

getNextSiblings()​

getNextSiblings<T>(): T[]

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

Returns all "next" siblings - that is, the nodes that come between this one and the last child of it's parent, inclusive.

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Inherited from​

DecoratorNode.getNextSiblings

getNodesBetween()​

getNodesBetween(targetNode): LexicalNode[]

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

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​

DecoratorNode.getNodesBetween

getParent()​

getParent<T>(): T | null

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

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

Type Parameters​
T​

T extends ElementNode

Returns​

T | null

Inherited from​

DecoratorNode.getParent

getParentKeys()​

getParentKeys(): string[]

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

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

Returns​

string[]

Inherited from​

DecoratorNode.getParentKeys

getParentOrThrow()​

getParentOrThrow<T>(): T

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

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

Type Parameters​
T​

T extends ElementNode

Returns​

T

Inherited from​

DecoratorNode.getParentOrThrow

getParents()​

getParents(): ElementNode[]

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

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

Returns​

ElementNode[]

Inherited from​

DecoratorNode.getParents

getPreviousSibling()​

getPreviousSibling<T>(): T | null

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

Returns the "previous" siblings - that is, the node that comes before this one in the same parent.

Type Parameters​
T​

T extends LexicalNode

Returns​

T | null

Inherited from​

DecoratorNode.getPreviousSibling

getPreviousSiblings()​

getPreviousSiblings<T>(): T[]

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

Returns the "previous" siblings - that is, the nodes that come between this one and the first child of it's parent, inclusive.

Type Parameters​
T​

T extends LexicalNode

Returns​

T[]

Inherited from​

DecoratorNode.getPreviousSiblings

getTextContent()​

getTextContent(): string

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:85

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

Returns​

string

Overrides​

DecoratorNode.getTextContent

getTextContentSize()​

getTextContentSize(): number

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

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

Returns​

number

Inherited from​

DecoratorNode.getTextContentSize

getTopLevelElement()​

getTopLevelElement(): ElementNode | HorizontalRuleNode | null

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:17

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 | HorizontalRuleNode | null

Inherited from​

DecoratorNode.getTopLevelElement

getTopLevelElementOrThrow()​

getTopLevelElementOrThrow(): ElementNode | HorizontalRuleNode

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:18

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

Inherited from​

DecoratorNode.getTopLevelElementOrThrow

getType()​

getType(): string

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

Returns the string type of this node.

Returns​

string

Inherited from​

DecoratorNode.getType

getWritable()​

getWritable(): this

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

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​

DecoratorNode.getWritable

insertAfter()​

insertAfter(nodeToInsert, restoreSelection?): LexicalNode

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

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​

DecoratorNode.insertAfter

insertBefore()​

insertBefore(nodeToInsert, restoreSelection?): LexicalNode

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

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​

DecoratorNode.insertBefore

is()​

is(object): boolean

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

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​

DecoratorNode.is

isAttached()​

isAttached(): boolean

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

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​

DecoratorNode.isAttached

isBefore()​

isBefore(targetNode): boolean

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

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​

DecoratorNode.isBefore

isDirty()​

isDirty(): boolean

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

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

Returns​

boolean

Inherited from​

DecoratorNode.isDirty

isInline()​

isInline(): false

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:89

Returns​

false

Overrides​

DecoratorNode.isInline

isIsolated()​

isIsolated(): boolean

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:34

Returns​

boolean

Inherited from​

DecoratorNode.isIsolated

isKeyboardSelectable()​

isKeyboardSelectable(): boolean

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:42

Returns​

boolean

Inherited from​

DecoratorNode.isKeyboardSelectable

isParentOf()​

isParentOf(targetNode): boolean

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

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​

DecoratorNode.isParentOf

isParentRequired()​

isParentRequired(): boolean

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

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​

DecoratorNode.isParentRequired

isSelected()​

isSelected(selection?): boolean

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

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​

DecoratorNode.isSelected

markDirty()​

markDirty(): void

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

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

Returns​

void

Inherited from​

DecoratorNode.markDirty

remove()​

remove(preserveEmptyParent?): void

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

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​

DecoratorNode.remove

replace()​

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

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

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

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​

DecoratorNode.replace

resetOnCopyNodeFrom()​

resetOnCopyNodeFrom(originalNode): void

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

Reset state in this copy of originalNode, if necessary

Parameters​
originalNode​

this

Returns​

void

Inherited from​

DecoratorNode.resetOnCopyNodeFrom

selectEnd()​

selectEnd(): RangeSelection

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

Returns​

RangeSelection

Inherited from​

DecoratorNode.selectEnd

selectNext()​

selectNext(anchorOffset?, focusOffset?): RangeSelection

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

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​

DecoratorNode.selectNext

selectPrevious()​

selectPrevious(anchorOffset?, focusOffset?): RangeSelection

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

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​

DecoratorNode.selectPrevious

selectStart()​

selectStart(): RangeSelection

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

Returns​

RangeSelection

Inherited from​

DecoratorNode.selectStart

updateDOM()​

updateDOM(): boolean

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:93

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.

Returns​

boolean

Overrides​

DecoratorNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

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

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​

LexicalUpdateJSON<SerializedLexicalNode>

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);
}
}
Inherited from​

DecoratorNode.updateFromJSON

clone()​

static clone(node): HorizontalRuleNode

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:56

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

HorizontalRuleNode

Returns​

HorizontalRuleNode

Overrides​

DecoratorNode.clone

getType()​

static getType(): string

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:52

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

Returns​

string

Overrides​

DecoratorNode.getType

importDOM()​

static importDOM(): DOMConversionMap | null

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:66

Returns​

DOMConversionMap | null

Overrides​

DecoratorNode.importDOM

importJSON()​

static importJSON(serializedNode): HorizontalRuleNode

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:60

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​

SerializedLexicalNode

Returns​

HorizontalRuleNode

Overrides​

DecoratorNode.importJSON

transform()​

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

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

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​

DecoratorNode.transform

Interfaces​

AutoFocusConfig​

Defined in: packages/lexical-extension/src/AutoFocusExtension.ts:15

Properties​

defaultSelection​

defaultSelection: DefaultSelection

Defined in: packages/lexical-extension/src/AutoFocusExtension.ts:20

Where to move the selection when the editor is focused and there is no existing selection. Can be "rootStart" or "rootEnd" (the default).

disabled​

disabled: boolean

Defined in: packages/lexical-extension/src/AutoFocusExtension.ts:24

The initial state of disabled


ClearEditorConfig​

Defined in: packages/lexical-extension/src/ClearEditorExtension.ts:39

Properties​

$onClear​

$onClear: () => void

Defined in: packages/lexical-extension/src/ClearEditorExtension.ts:40

Returns​

void


ClickAfterLastBlockConfig​

Defined in: packages/lexical-extension/src/ClickAfterLastBlockExtension.ts:50

Properties​

$shouldInsertAfter​

$shouldInsertAfter: (node) => boolean

Defined in: packages/lexical-extension/src/ClickAfterLastBlockExtension.ts:60

Called inside the editor update with the last child of the root when the user clicks the empty area below it. Return true to insert a new paragraph after that node and select it; return false to leave the click alone. Default is $defaultShouldInsertAfter — see its docs for composition patterns.

Parameters​
node​

LexicalNode

Returns​

boolean

disabled​

disabled: boolean

Defined in: packages/lexical-extension/src/ClickAfterLastBlockExtension.ts:52

Set to true to disable this extension.


ClickAfterLastBlockOutput​

Defined in: packages/lexical-extension/src/ClickAfterLastBlockExtension.ts:63

Properties​

$shouldInsertAfter​

$shouldInsertAfter: Signal<(node) => boolean>

Defined in: packages/lexical-extension/src/ClickAfterLastBlockExtension.ts:67

Predicate signal — see ClickAfterLastBlockConfig.$shouldInsertAfter.

disabled​

disabled: Signal<boolean>

Defined in: packages/lexical-extension/src/ClickAfterLastBlockExtension.ts:65

Set to true to disable this extension.


InitialStateConfig​

Defined in: packages/lexical-extension/src/InitialStateExtension.ts:37

Properties​

setOptions​

setOptions: EditorSetOptions

Defined in: packages/lexical-extension/src/InitialStateExtension.ts:39

updateOptions​

updateOptions: EditorUpdateOptions

Defined in: packages/lexical-extension/src/InitialStateExtension.ts:38


KnownTypesAndNodes​

Defined in: packages/lexical-extension/src/config.ts:16

Properties​

nodes​

nodes: Set<KlassConstructor<typeof LexicalNode>>

Defined in: packages/lexical-extension/src/config.ts:18

types​

types: Set<string>

Defined in: packages/lexical-extension/src/config.ts:17


NormalizeInlineElementsConfig​

Defined in: packages/lexical-extension/src/NormalizeInlineElementsExtension.ts:22

Properties​

disabled​

disabled: boolean

Defined in: packages/lexical-extension/src/NormalizeInlineElementsExtension.ts:23


NormalizeTripleClickSelectionConfig​

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:41

Properties​

$fixFocusOverselection​

$fixFocusOverselection: () => void

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:49

The update function to call when triple click is detected

Returns​

void

dateNow​

dateNow: () => number

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:47

The clock function used for delay-based merging, default Date.now

Returns​

number

disabled​

disabled: boolean

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:43

true to disable this extension

thresholdMsec​

thresholdMsec: number

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:45

The maximum number of msec from the triple click to expect a selection change, default 100


NormalizeTripleClickSelectionOutput​

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:52

Properties​

$fixFocusOverselection​

$fixFocusOverselection: Signal<() => void>

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:60

The update function to call when triple click is detected

dateNow​

dateNow: Signal<() => number>

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:58

The clock function used for delay-based merging, default Date.now

disabled​

disabled: Signal<boolean>

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:54

true to disable this extension

thresholdMsec​

thresholdMsec: Signal<number>

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:56

The maximum number of msec from the triple click to expect a selection change, default 100


ReadonlySignal​

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:76

An interface for read-only signals.

Type Parameters​

T​

T = any

Properties​

brand​

brand: typeof BRAND_SYMBOL

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:83

value​

readonly value: T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:77

Methods​

peek()​

peek(): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:78

Returns​

T

subscribe()​

subscribe(fn): () => void

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:79

Parameters​
fn​

(value) => void

Returns​

() => void

toJSON()​

toJSON(): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:82

Returns​

T

toString()​

toString(): string

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:81

Returns​

string

valueOf()​

valueOf(): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:80

Returns​

T


Signal​

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:36

The base class for plain and computed signals.

Type Parameters​

T​

T = any

Properties​

brand​

brand: typeof BRAND_SYMBOL

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:44

name?​

optional name?: string

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:39

Accessors​

value​
Get Signature​

get value(): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:45

Returns​

T

Set Signature​

set value(value): void

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:46

Parameters​
value​

T

Returns​

void

Methods​

peek()​

peek(): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:43

Returns​

T

subscribe()​

subscribe(fn): () => void

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:38

Parameters​
fn​

(value) => void

Returns​

() => void

toJSON()​

toJSON(): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:42

Returns​

T

toString()​

toString(): string

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:41

Returns​

string

valueOf()​

valueOf(): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:40

Returns​

T


SignalOptions​

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:48

Type Parameters​

T​

T = any

Properties​

name?​

optional name?: string

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:51

unwatched?​

optional unwatched?: (this) => void

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:50

Parameters​
this​

Signal<T>

Returns​

void

watched?​

optional watched?: (this) => void

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:49

Parameters​
this​

Signal<T>

Returns​

void


TabIndentationConfig​

Defined in: packages/lexical-extension/src/TabIndentationExtension.ts:134

Properties​

$canIndent​

$canIndent: CanIndentPredicate

Defined in: packages/lexical-extension/src/TabIndentationExtension.ts:141

By default, indents are set on all elements for which the ElementNode.canIndent returns true. This option allows you to set indents for specific nodes without overriding the method for others.

disabled​

disabled: boolean

Defined in: packages/lexical-extension/src/TabIndentationExtension.ts:135

maxIndent​

maxIndent: number | null

Defined in: packages/lexical-extension/src/TabIndentationExtension.ts:136

Type Aliases​

CanIndentPredicate​

CanIndentPredicate = (node) => boolean

Defined in: packages/lexical-extension/src/TabIndentationExtension.ts:70

Parameters​

node​

ElementNode

Returns​

boolean


NamedSignalsOptions​

NamedSignalsOptions<Defaults> = { [K in keyof Defaults]?: Defaults[K] }

Defined in: packages/lexical-extension/src/namedSignals.ts:10

Type Parameters​

Defaults​

Defaults


NamedSignalsOutput​

NamedSignalsOutput<Defaults> = { [K in keyof Defaults]: Signal<Defaults[K]> }

Defined in: packages/lexical-extension/src/namedSignals.ts:13

Type Parameters​

Defaults​

Defaults


SerializedDecoratorTextNode​

SerializedDecoratorTextNode = Spread<{ format: number; }, SerializedLexicalNode>

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:33


SerializedHorizontalRuleNode​

SerializedHorizontalRuleNode = SerializedLexicalNode

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:46

Variables​

AutoFocusExtension​

const AutoFocusExtension: LexicalExtension<AutoFocusConfig, "@lexical/extension/AutoFocus", NamedSignalsOutput<AutoFocusConfig>, unknown>

Defined in: packages/lexical-extension/src/AutoFocusExtension.ts:31

An Extension to focus the LexicalEditor when the root element is set (typically only when the editor is first created).


ClearEditorExtension​

const ClearEditorExtension: LexicalExtension<ClearEditorConfig, "@lexical/extension/ClearEditor", NamedSignalsOutput<ClearEditorConfig>, unknown>

Defined in: packages/lexical-extension/src/ClearEditorExtension.ts:60

An extension to provide an implementation of CLEAR_EDITOR_COMMAND


ClickAfterLastBlockExtension​

const ClickAfterLastBlockExtension: LexicalExtension<ClickAfterLastBlockConfig, "@lexical/ClickAfterLastBlock", ClickAfterLastBlockOutput, unknown>

Defined in: packages/lexical-extension/src/ClickAfterLastBlockExtension.ts:133

Click handling for the empty area below the last block of the document.

Without this extension, clicking the area below the last block when that block is a DecoratorNode, a shadow-root ElementNode (e.g. TableNode), or any other block that doesn't accept the click naturally leaves the selection in an awkward place — null for a bare decorator, or at the end of a table cell. Users typically expect a new paragraph to appear below the block with the caret in it, matching the behavior of editors like Notion.

This extension intercepts clicks under those conditions, inserts a new empty paragraph after the last block, and selects it.

Closes #8544.


DecoratorTextExtension​

const DecoratorTextExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/DecoratorText", unknown, unknown>

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:195

An extension for DecoratorTextNode that sets the format for the node and CSS classes for the DOM container. The base class is always set, and the focus class is set when the node is selected.


EditorStateExtension​

const EditorStateExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/EditorState", Signal<EditorState>, unknown>

Defined in: packages/lexical-extension/src/EditorStateExtension.ts:15

An extension to provide the current EditorState as a signal


HorizontalRuleExtension​

const HorizontalRuleExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/HorizontalRule", unknown, unknown>

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:137

An extension for HorizontalRuleNode that provides an implementation that works without any React dependency.


InitialStateExtension​

const InitialStateExtension: LexicalExtension<InitialStateConfig, "@lexical/extension/InitialState", unknown, { $initialEditorState: InitialEditorStateType; initialized: boolean; }>

Defined in: packages/lexical-extension/src/InitialStateExtension.ts:51

An extension to set the initial state of the editor from a function or serialized JSON EditorState. This is implicitly included with all editors built with Lexical Extension. This happens in the afterRegistration phase so your initial state may depend on registered commands, but you should not call editor.setRootElement earlier than this phase to avoid rendering an empty editor first.


INSERT_HORIZONTAL_RULE_COMMAND​

const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:48


NestedEditorExtension​

const NestedEditorExtension: LexicalExtension<NestedEditorConfig, "@lexical/extension/NestedEditor", NamedSignalsOutput<{ inheritEditableFromParent: boolean; }>, void>

Defined in: packages/lexical-extension/src/NestedEditorExtension.ts:26


NodeSelectionExtension​

const NodeSelectionExtension: LexicalExtension<ExtensionConfigBase, "@lexical/extension/NodeSelection", { watchNodeKey: (key) => ReadonlySignal<boolean>; }, unknown>

Defined in: packages/lexical-extension/src/NodeSelectionExtension.ts:30

An extension that provides a watchNodeKey output that returns a signal for the selection state of a node.

Typically used for tracking whether a DecoratorNode is currently selected or not. A framework independent alternative to useLexicalNodeSelection.


NormalizeInlineElementsExtension​

const NormalizeInlineElementsExtension: LexicalExtension<NormalizeInlineElementsConfig, "@lexical/NormalizeInlineElements", NamedSignalsOutput<NormalizeInlineElementsConfig>, unknown>

Defined in: packages/lexical-extension/src/NormalizeInlineElementsExtension.ts:43

This extension removes empty inline nodes from the EditorState. This extension is designed to facilitate a smooth migration from the plugin API with the option to disable it, but it may be removed in the future and integrated into the core


NormalizeTripleClickSelectionExtension​

const NormalizeTripleClickSelectionExtension: LexicalExtension<NormalizeTripleClickSelectionConfig, "@lexical/NormalizeTripleClickSelection", NormalizeTripleClickSelectionOutput, unknown>

Defined in: packages/lexical-extension/src/NormalizeTripleClickSelectionExtension.ts:153

This extension handles triple-click events and will move the focus towards the anchor in certain conditions to meet expectations. Simply speaking, the focus should prefer to land at the end of a node rather than the beginning of its next sibling, and it should not skip over a LineBreakNode.

In order to fix the result visually and avoid a flash of over-selection it will also eagerly manipulate the DOM selection directly.

It is conservative in that it only fires this $fixFocusOverselection callback when it has detected a triple click, but it provides the function as an output signal so that it can both be called from other places and it can be replaced or wrapped with different functionality.


SelectionAlwaysOnDisplayExtension​

const SelectionAlwaysOnDisplayExtension: LexicalExtension<SelectionAlwaysOnDisplayConfig, "@lexical/utils/SelectionAlwaysOnDisplay", NamedSignalsOutput<SelectionAlwaysOnDisplayConfig>, unknown>

Defined in: packages/lexical-extension/src/SelectionAlwaysOnDisplayExtension.ts:24

An extension that highlights selected content in the Lexical editor even when the editor is not currently focused.


TabIndentationExtension​

const TabIndentationExtension: LexicalExtension<TabIndentationConfig, "@lexical/extension/TabIndentation", NamedSignalsOutput<TabIndentationConfig>, unknown>

Defined in: packages/lexical-extension/src/TabIndentationExtension.ts:149

This extension adds the ability to indent content using the tab key. Generally, we don't recommend using this plugin as it could negatively affect accessibility for keyboard users, causing focus to become trapped within the editor.

Functions​

$createHorizontalRuleNode()​

$createHorizontalRuleNode(): HorizontalRuleNode

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:102

Returns​

HorizontalRuleNode


$defaultShouldInsertAfter()​

$defaultShouldInsertAfter(node): boolean

Defined in: packages/lexical-extension/src/ClickAfterLastBlockExtension.ts:40

Experimental

Default predicate matches DecoratorNode and shadow-root ElementNodes (e.g. TableNode). Apps that want to also trigger on other node types — CodeNode, custom non-editable blocks — should compose this default in their own predicate rather than re-deriving the check:

configExtension(ClickAfterLastBlockExtension, {
$shouldInsertAfter: (node) =>
$defaultShouldInsertAfter(node) || $isCodeNode(node),
});

Parameters​

node​

LexicalNode

Returns​

boolean


$getExtensionDependency()​

$getExtensionDependency<E>(extension): LexicalExtensionDependency<E>

Defined in: packages/lexical-extension/src/getExtensionDependency.ts:44

Get the finalized config and output for extension from the editor currently in scope. A $-flavored shorthand for getExtensionDependencyFromEditor($getEditor(), extension).

Throws if the editor was not built with extension as a dependency.

Type Parameters​

E​

E extends AnyLexicalExtension

Parameters​

extension​

E

Returns​

LexicalExtensionDependency<E>

Example​

import {$getExtensionDependency} from '@lexical/extension';
import {KeywordsExtension} from './KeywordsExtension';

class KeywordNode extends TextNode {
createDOM(config: EditorConfig): HTMLElement {
const dom = super.createDOM(config);
dom.className =
$getExtensionDependency(KeywordsExtension).config.className;
return dom;
}
}

See​

getExtensionDependencyFromEditor when you have an explicit editor reference (e.g. outside a read/update).


$getExtensionOutput()​

$getExtensionOutput<E>(extension): LexicalExtensionOutput<E>

Defined in: packages/lexical-extension/src/getExtensionDependency.ts:69

Shorthand for $getExtensionDependency(extension).output — the most common reason to look up an extension dependency. Throws if the editor was not built with extension as a dependency.

Type Parameters​

E​

E extends AnyLexicalExtension

Parameters​

extension​

E

Returns​

LexicalExtensionOutput<E>

Example​

import {$getExtensionOutput} from '@lexical/extension';
import {DOMImportExtension} from '@lexical/html';

const nodes = $getExtensionOutput(DOMImportExtension).$generateNodesFromDOM(
dom,
);

See​

$getExtensionDependency when you need both .config and .output (or want to mirror the shape of getExtensionDependencyFromEditor).


$getPeerDependency()​

$getPeerDependency<E>(extensionName): LexicalExtensionDependency<E> | undefined

Defined in: packages/lexical-extension/src/getExtensionDependency.ts:100

Get the finalized config and output for an optional peer extension by name, from the editor currently in scope. A $-flavored shorthand for getPeerDependencyFromEditor($getEditor(), extensionName).

Returns undefined if the editor was not built with the named extension. Both the explicit Extension type and the name are required so the returned config / output types are correct.

Type Parameters​

E​

E extends AnyLexicalExtension = never

Parameters​

extensionName​

E["name"]

Returns​

LexicalExtensionDependency<E> | undefined

Example​

import {$getPeerDependency} from '@lexical/extension';
import type {HistoryExtension} from '@lexical/history';

const dep = $getPeerDependency<typeof HistoryExtension>(
'@lexical/history/History',
);
if (dep) {
// …read dep.config / dep.output…
}

See​

getPeerDependencyFromEditor when you have an explicit editor reference.


$isDecoratorTextNode()​

$isDecoratorTextNode(node): node is DecoratorTextNode

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:88

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is DecoratorTextNode


$isHorizontalRuleNode()​

$isHorizontalRuleNode(node): node is HorizontalRuleNode

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:106

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is HorizontalRuleNode


applyFormatFromStyle()​

applyFormatFromStyle(lexicalNode, style, shouldApply?): DecoratorTextNode

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:105

Applies formatting to the node based on the properties in the passed style object. By default, properties are checked according to the values set when importing content from Google Docs. This algorithm is identical to the TextNode import.

Parameters​

lexicalNode​

DecoratorTextNode

The node to which the format will apply

style​

CSSStyleDeclaration

CSS style object

shouldApply?​

TextFormatType

format to apply if it is not in style

Returns​

DecoratorTextNode

lexicalNode


applyFormatToDom()​

applyFormatToDom(lexicalNode, domNode, tagNameToFormat?): HTMLElement | Text

Defined in: packages/lexical-extension/src/DecoratorTextExtension.ts:156

The function wraps the passed DOM node in semantic tags depending on the node format.

Parameters​

lexicalNode​

DecoratorTextNode

The node where the format is checked

domNode​

HTMLElement | Text

DOM that will be wrapped in tags

tagNameToFormat?​

Tag name and format mapping

Returns​

HTMLElement | Text

domNode


batch()​

batch<T>(fn): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:24

Combine multiple value updates into one "commit" at the end of the provided callback.

Batches can be nested and changes are only flushed once the outermost batch callback completes.

Accessing a signal that has been modified within a batch will reflect its updated value.

Type Parameters​

T​

T

Parameters​

fn​

() => T

The callback function.

Returns​

T

The value returned by the callback.


buildEditorFromExtensions()​

buildEditorFromExtensions(...extensions): LexicalEditorWithDispose

Defined in: packages/lexical-extension/src/LexicalBuilder.ts:81

Build a LexicalEditor by combining together one or more extensions, optionally overriding some of their configuration.

Parameters​

extensions​

...AnyLexicalExtensionArgument[]

Extension arguments (extensions or extensions with config overrides)

Returns​

LexicalEditorWithDispose

An editor handle

Examples​

A single root extension with multiple dependencies

const editor = buildEditorFromExtensions(
defineExtension({
name: "[root]",
dependencies: [
RichTextExtension,
configExtension(EmojiExtension, { emojiBaseUrl: "/assets/emoji" }),
],
register: (editor: LexicalEditor) => {
console.log("Editor Created");
return () => console.log("Editor Disposed");
},
}),
);

A very similar minimal configuration without the register hook

const editor = buildEditorFromExtensions(
RichTextExtension,
configExtension(EmojiExtension, { emojiBaseUrl: "/assets/emoji" }),
);

computed()​

computed<T>(fn, options?): ReadonlySignal<T>

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:94

Create a new signal that is computed based on the values of other signals.

The returned computed signal is read-only, and its value is automatically updated when any signals accessed from within the callback function change.

Type Parameters​

T​

T

Parameters​

fn​

() => T

The effect callback.

options?​

SignalOptions<T>

Returns​

ReadonlySignal<T>

A new read-only signal.


effect()​

effect(fn, options?): DisposeFn

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:139

Create an effect to run arbitrary code in response to signal changes.

An effect tracks which signals are accessed within the given callback function fn, and re-runs the callback when those signals change.

The callback may return a cleanup function. The cleanup function gets run once, either when the callback is next called or when the effect gets disposed, whichever happens first.

Parameters​

fn​

EffectFn

The effect callback.

options?​

EffectOptions

Returns​

DisposeFn

A function for disposing the effect.


getExtensionDependencyFromEditor()​

getExtensionDependencyFromEditor<Extension>(editor, extension): LexicalExtensionDependency<Extension>

Defined in: packages/lexical-extension/src/getExtensionDependencyFromEditor.ts:35

Get the finalized config and output of an Extension that was used to build the editor.

This is useful in the implementation of a LexicalNode or in other situations where you have an editor reference but it's not easy to pass the config or ExtensionRegisterState around.

It will throw if the Editor was not built using this Extension.

Inside an editor read/update, prefer $getExtensionDependency or $getExtensionOutput — they resolve the editor via $getEditor() so you don't have to thread it through.

Type Parameters​

Extension​

Extension extends AnyLexicalExtension

Parameters​

editor​

LexicalEditor

The editor that was built using extension

extension​

Extension

The concrete reference to an Extension used to build this editor

Returns​

LexicalExtensionDependency<Extension>

The config and output for that Extension


getKnownTypesAndNodes()​

getKnownTypesAndNodes(config): KnownTypesAndNodes

Defined in: packages/lexical-extension/src/config.ts:28

Get the sets of nodes and types registered in the InitialEditorConfig. This is to be used when an extension needs to register optional behavior if some node or type is present.

Parameters​

config​

Pick<InitialEditorConfig, "nodes">

The InitialEditorConfig (accessible from an extension's init)

Returns​

KnownTypesAndNodes

The known types and nodes as Sets


getPeerDependencyFromEditor()​

getPeerDependencyFromEditor<Extension>(editor, extensionName): LexicalExtensionDependency<Extension> | undefined

Defined in: packages/lexical-extension/src/getPeerDependencyFromEditor.ts:44

Get the finalized config and output of an Extension that was used to build the editor by name.

This can be used from the implementation of a LexicalNode or in other situation where you have an editor reference but it's not easy to pass the config around. Use this version if you do not have a concrete reference to the Extension for some reason (e.g. it is an optional peer dependency, or you are avoiding a circular import).

Both the explicit Extension type and the name are required.

Inside an editor read/update, prefer $getPeerDependency — it resolves the editor via $getEditor() so you don't have to thread it through.

Type Parameters​

Extension​

Extension extends AnyLexicalExtension = never

Parameters​

editor​

LexicalEditor

The editor that may have been built using extension

extensionName​

Extension["name"]

The name of the Extension

Returns​

LexicalExtensionDependency<Extension> | undefined

The config and output of the Extension or undefined

Example​

import type { HistoryExtension } from "@lexical/history";
getPeerDependencyFromEditor<typeof HistoryExtension>(editor, "@lexical/history/History");

getPeerDependencyFromEditorOrThrow()​

getPeerDependencyFromEditorOrThrow<Extension>(editor, extensionName): LexicalExtensionDependency<Extension>

Defined in: packages/lexical-extension/src/getPeerDependencyFromEditor.ts:100

Get the finalized config and output of an Extension that was used to build the editor by name.

This can be used from the implementation of a LexicalNode or in other situation where you have an editor reference but it's not easy to pass the config around. Use this version if you do not have a concrete reference to the Extension for some reason (e.g. it is an optional peer dependency, or you are avoiding a circular import).

Both the explicit Extension type and the name are required.

Inside an editor read/update, prefer $getPeerDependency (which resolves the editor via $getEditor()) and add your own invariant if the peer is required.

Type Parameters​

Extension​

Extension extends AnyLexicalExtension = never

Parameters​

editor​

LexicalEditor

The editor that may have been built using extension

extensionName​

Extension["name"]

The name of the Extension

Returns​

LexicalExtensionDependency<Extension>

The config and output of the Extension

Example​

import type { EmojiExtension } from "./EmojiExtension";
export class EmojiNode extends TextNode {
// other implementation details not included
createDOM(
config: EditorConfig,
editor?: LexicalEditor | undefined
): HTMLElement {
const dom = super.createDOM(config, editor);
addClassNamesToElement(
dom,
getPeerDependencyFromEditorOrThrow<typeof EmojiExtension>(
editor || $getEditor(),
"@lexical/playground/emoji",
).config.emojiClass,
);
return dom;
}
}

namedSignals()​

namedSignals<Defaults>(defaults, opts?): NamedSignalsOutput<Defaults>

Defined in: packages/lexical-extension/src/namedSignals.ts:29

Return an object with the same shape as defaults with a Signal for each value. If specified, the second opts argument is a partial of overrides to the defaults and will be used as the initial value.

Typically used to make a reactive version of some subset of the configuration of an extension, so it can be reconfigured at runtime.

Type Parameters​

Defaults​

Defaults

Parameters​

defaults​

Defaults

The object with default values

opts?​

NamedSignalsOptions<Defaults> = {}

Overrides to those default values

Returns​

NamedSignalsOutput<Defaults>

An object with signals initialized with the default values


registerClearEditor()​

registerClearEditor(editor, $onClear?): () => void

Defined in: packages/lexical-extension/src/ClearEditorExtension.ts:43

Parameters​

editor​

LexicalEditor

$onClear?​

() => void

Returns​

() => void


registerTabIndentation()​

registerTabIndentation(editor, maxIndent?, $canIndent?): () => void

Defined in: packages/lexical-extension/src/TabIndentationExtension.ts:76

Parameters​

editor​

LexicalEditor

maxIndent?​

number | ReadonlySignal<number | null>

$canIndent?​

CanIndentPredicate | ReadonlySignal<CanIndentPredicate>

Returns​

() => void


signal()​

Call Signature​

signal<T>(value, options?): Signal<T>

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:59

Create a new plain signal.

Type Parameters​
T​

T

Parameters​
value​

T

The initial value for the signal.

options?​

SignalOptions<T>

Returns​

Signal<T>

A new signal.

Call Signature​

signal<T>(): Signal<T | undefined>

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:60

Create a new plain signal.

Type Parameters​
T​

T = undefined

Returns​

Signal<T | undefined>

A new signal.


untracked()​

untracked<T>(fn): T

Defined in: node_modules/.pnpm/@preact+signals-core@1.14.1/node_modules/@preact/signals-core/dist/signals-core.d.ts:32

Run a callback function that can access signal values without subscribing to the signal updates.

Type Parameters​

T​

T

Parameters​

fn​

() => T

The callback function.

Returns​

T

The value returned by the callback.


watchedSignal()​

watchedSignal<T>(getSnapshot, register): Signal<T>

Defined in: packages/lexical-extension/src/watchedSignal.ts:18

Create a Signal that will subscribe to a value from an external store when watched, similar to React's useSyncExternalStore.

Type Parameters​

T​

T

Parameters​

getSnapshot​

() => T

Used to get the initial value of the signal when created and when first watched.

register​

(self) => () => void

A callback that will subscribe to some external store and update the signal, must return a dispose function.

Returns​

Signal<T>

The signal

References​

AnyLexicalExtension​

Re-exports AnyLexicalExtension


AnyLexicalExtensionArgument​

Re-exports AnyLexicalExtensionArgument


configExtension​

Re-exports configExtension


declarePeerDependency​

Re-exports declarePeerDependency


defineExtension​

Re-exports defineExtension


ExtensionConfigBase​

Re-exports ExtensionConfigBase


ExtensionRegisterState​

Re-exports ExtensionRegisterState


InitialEditorStateType​

Re-exports InitialEditorStateType


LexicalEditorWithDispose​

Re-exports LexicalEditorWithDispose


LexicalExtension​

Re-exports LexicalExtension


LexicalExtensionArgument​

Re-exports LexicalExtensionArgument


LexicalExtensionConfig​

Re-exports LexicalExtensionConfig


LexicalExtensionDependency​

Re-exports LexicalExtensionDependency


LexicalExtensionInit​

Re-exports LexicalExtensionInit


LexicalExtensionName​

Re-exports LexicalExtensionName


LexicalExtensionOutput​

Re-exports LexicalExtensionOutput


NormalizedLexicalExtensionArgument​

Re-exports NormalizedLexicalExtensionArgument


NormalizedPeerDependency​

Re-exports NormalizedPeerDependency


OutputComponentExtension​

Re-exports OutputComponentExtension


safeCast​

Re-exports safeCast


shallowMergeConfig​

Re-exports shallowMergeConfig