Skip to main content

@lexical/extension

Classes

HorizontalRuleNode

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

Extends

Extended by

Constructors

Constructor

new HorizontalRuleNode(key?): HorizontalRuleNode

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

Parameters
key?

string

Returns

HorizontalRuleNode

Inherited from

DecoratorNode.constructor

Methods

$config()

$config(): BaseStaticNodeConfig

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

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:520

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:460

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:78

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:1374

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:74

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:1096

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): null | T

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

Type Parameters
T

T extends ElementNode = ElementNode

Parameters
node

LexicalNode

the other node to find the common ancestor of.

Returns

null | T

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

getIndexWithinParent()

getIndexWithinParent(): number

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

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:645

Returns this nodes key.

Returns

string

Inherited from

DecoratorNode.getKey

getLatest()

getLatest(): this

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

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>(): null | T

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

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

Type Parameters
T

T extends LexicalNode

Returns

null | T

Inherited from

DecoratorNode.getNextSibling

getNextSiblings()

getNextSiblings<T>(): T[]

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

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:897

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>(): null | T

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

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

Type Parameters
T

T extends ElementNode

Returns

null | T

Inherited from

DecoratorNode.getParent

getParentKeys()

getParentKeys(): string[]

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

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:684

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:735

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>(): null | T

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

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

Type Parameters
T

T extends LexicalNode

Returns

null | T

Inherited from

DecoratorNode.getPreviousSibling

getPreviousSiblings()

getPreviousSiblings<T>(): T[]

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

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:84

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:1036

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

Returns

number

Inherited from

DecoratorNode.getTextContentSize

getTopLevelElement()

getTopLevelElement(): null | ElementNode | HorizontalRuleNode

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

null | ElementNode | HorizontalRuleNode

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:559

Returns the string type of this node.

Returns

string

Inherited from

DecoratorNode.getType

getWritable()

getWritable(): this

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

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:1259

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:1326

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:844

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

the node to perform the equality comparison on.

undefined | null | LexicalNode

Returns

boolean

Inherited from

DecoratorNode.is

isAttached()

isAttached(): boolean

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

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:862

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:967

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:88

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:885

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:1366

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:600

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?

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

null | BaseSelection

Returns

boolean

Inherited from

DecoratorNode.isSelected

markDirty()

markDirty(): void

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

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:1178

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:1189

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

selectEnd()

selectEnd(): RangeSelection

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

Returns

RangeSelection

Inherited from

DecoratorNode.selectEnd

selectNext()

selectNext(anchorOffset?, focusOffset?): RangeSelection

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

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:1392

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:1378

Returns

RangeSelection

Inherited from

DecoratorNode.selectStart

updateDOM()

updateDOM(): boolean

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

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:1149

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:55

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:51

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(): null | DOMConversionMap

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

Returns

null | DOMConversionMap

Overrides

DecoratorNode.importDOM

importJSON()

static importJSON(serializedNode): HorizontalRuleNode

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

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(): null | (node) => void

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

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

null | (node) => void

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


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:10

Properties

nodes

nodes: Set<KlassConstructor<typeof LexicalNode>>

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

types

types: Set<string>

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


ReadonlySignal<T>

Defined in: 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/@preact/signals-core/dist/signals-core.d.ts:83

value

readonly value: T

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

Methods

peek()

peek(): T

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

Returns

T

subscribe()

subscribe(fn): () => void

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

Parameters
fn

(value) => void

Returns

(): void

Returns

void

toJSON()

toJSON(): T

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

Returns

T

toString()

toString(): string

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

Returns

string

valueOf()

valueOf(): T

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

Returns

T


Signal<T>

Defined in: 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/@preact/signals-core/dist/signals-core.d.ts:44

name?

optional name: string

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

Accessors

value
Get Signature

get value(): T

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

Returns

T

Set Signature

set value(value): void

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

Parameters
value

T

Returns

void

Methods

peek()

peek(): T

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

Returns

T

subscribe()

subscribe(fn): () => void

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

Parameters
fn

(value) => void

Returns

(): void

Returns

void

toJSON()

toJSON(): T

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

Returns

T

toString()

toString(): string

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

Returns

string

valueOf()

valueOf(): T

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

Returns

T


SignalOptions<T>

Defined in: 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/@preact/signals-core/dist/signals-core.d.ts:51

unwatched()?

optional unwatched: (this) => void

Defined in: 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/@preact/signals-core/dist/signals-core.d.ts:49

Parameters
this

Signal<T>

Returns

void


TabIndentationConfig

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

Properties

disabled

disabled: boolean

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

maxIndent

maxIndent: null | number

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

Type Aliases

NamedSignalsOptions<Defaults>

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

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

Type Parameters

Defaults

Defaults


NamedSignalsOutput<Defaults>

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

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

Type Parameters

Defaults

Defaults


SerializedHorizontalRuleNode

SerializedHorizontalRuleNode = SerializedLexicalNode

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

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


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:136

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:47


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.


TabIndentationExtension

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

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

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:101

Returns

HorizontalRuleNode


$isHorizontalRuleNode()

$isHorizontalRuleNode(node): node is HorizontalRuleNode

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

Parameters

node

undefined | null | LexicalNode

Returns

node is HorizontalRuleNode


batch()

batch<T>(fn): T

Defined in: 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:76

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/@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?): () => void

Defined in: node_modules/@preact/signals-core/dist/signals-core.d.ts:131

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

A function for disposing the effect.

(): void

Returns

void


getExtensionDependencyFromEditor()

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

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

Experimental

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.

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): object

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

Experimental

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

InitialEditorConfig

The InitialEditorConfig (accessible from an extension's init)

Returns

object

The known types and nodes as Sets

nodes

nodes: Set<KlassConstructor<typeof LexicalNode>>

types

types: Set<string>


getPeerDependencyFromEditor()

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

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

Experimental

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.

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

undefined | LexicalExtensionDependency<Extension>

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:92

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.

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:30

Experimental

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

Returns

void


registerTabIndentation()

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

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

Parameters

editor

LexicalEditor

maxIndent?

number | ReadonlySignal<null | number>

Returns

(): void

Returns

void


signal()

Call Signature

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

Defined in: 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<undefined | T>

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

Create a new plain signal.

Type Parameters
T

T = undefined

Returns

Signal<undefined | T>

A new signal.


untracked()

untracked<T>(fn): T

Defined in: 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:19

Experimental

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