Skip to main content

Module: lexical

Classes

Interfaces

Type Aliases

CaretDirection

Ƭ CaretDirection: "next" | "previous"

Defined in

packages/lexical/src/LexicalCaret.ts:18


CaretType

Ƭ CaretType: "breadth" | "depth"

Defined in

packages/lexical/src/LexicalCaret.ts:20


CommandListener

Ƭ CommandListener<P>: (payload: P, editor: LexicalEditor) => boolean

Type parameters

Name
P

Type declaration

▸ (payload, editor): boolean

Parameters
NameType
payloadP
editorLexicalEditor
Returns

boolean

Defined in

packages/lexical/src/LexicalEditor.ts:262


CommandListenerPriority

Ƭ CommandListenerPriority: 0 | 1 | 2 | 3 | 4

Defined in

packages/lexical/src/LexicalEditor.ts:266


CommandPayloadType

Ƭ CommandPayloadType<TCommand>: TCommand extends LexicalCommand<infer TPayload> ? TPayload : never

Type helper for extracting the payload type from a command.

Example

const MY_COMMAND = createCommand<SomeType>();

// ...

editor.registerCommand(MY_COMMAND, payload => {
// Type of `payload` is inferred here. But lets say we want to extract a function to delegate to
$handleMyCommand(editor, payload);
return true;
});

function $handleMyCommand(editor: LexicalEditor, payload: CommandPayloadType<typeof MY_COMMAND>) {
// `payload` is of type `SomeType`, extracted from the command.
}

Type parameters

NameType
TCommandextends LexicalCommand<unknown>

Defined in

packages/lexical/src/LexicalEditor.ts:299


CreateEditorArgs

Ƭ CreateEditorArgs: Object

Type declaration

NameType
disableEvents?boolean
editable?boolean
editorState?EditorState
html?HTMLConfig
namespace?string
nodes?ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>
onError?ErrorHandler
parentEditor?LexicalEditor
theme?EditorThemeClasses

Defined in

packages/lexical/src/LexicalEditor.ts:186


DOMChildConversion

Ƭ DOMChildConversion: (lexicalNode: LexicalNode, parentLexicalNode: LexicalNode | null | undefined) => LexicalNode | null | undefined

Type declaration

▸ (lexicalNode, parentLexicalNode): LexicalNode | null | undefined

Parameters
NameType
lexicalNodeLexicalNode
parentLexicalNodeLexicalNode | null | undefined
Returns

LexicalNode | null | undefined

Defined in

packages/lexical/src/LexicalNode.ts:156


DOMConversion

Ƭ DOMConversion<T>: Object

Type parameters

NameType
Textends HTMLElement = HTMLElement

Type declaration

NameType
conversionDOMConversionFn<T>
priority?0 | 1 | 2 | 3 | 4

Defined in

packages/lexical/src/LexicalNode.ts:147


DOMConversionFn

Ƭ DOMConversionFn<T>: (element: T) => DOMConversionOutput | null

Type parameters

NameType
Textends HTMLElement = HTMLElement

Type declaration

▸ (element): DOMConversionOutput | null

Parameters
NameType
elementT
Returns

DOMConversionOutput | null

Defined in

packages/lexical/src/LexicalNode.ts:152


DOMConversionMap

Ƭ DOMConversionMap<T>: Record<NodeName, (node: T) => DOMConversion<T> | null>

Type parameters

NameType
Textends HTMLElement = HTMLElement

Defined in

packages/lexical/src/LexicalNode.ts:161


DOMConversionOutput

Ƭ DOMConversionOutput: Object

Type declaration

NameType
after?(childLexicalNodes: LexicalNode[]) => LexicalNode[]
forChild?DOMChildConversion
nodenull | LexicalNode | LexicalNode[]

Defined in

packages/lexical/src/LexicalNode.ts:167


DOMExportOutput

Ƭ DOMExportOutput: Object

Type declaration

NameType
after?(generatedElement: HTMLElement | DocumentFragment | Text | null | undefined) => HTMLElement | Text | null | undefined
elementHTMLElement | DocumentFragment | Text | null

Defined in

packages/lexical/src/LexicalNode.ts:178


DOMExportOutputMap

Ƭ DOMExportOutputMap: Map<Klass<LexicalNode>, (editor: LexicalEditor, target: LexicalNode) => DOMExportOutput>

Defined in

packages/lexical/src/LexicalNode.ts:173


EditableListener

Ƭ EditableListener: (editable: boolean) => void

Type declaration

▸ (editable): void

Parameters
NameType
editableboolean
Returns

void

Defined in

packages/lexical/src/LexicalEditor.ts:264


EditorConfig

Ƭ EditorConfig: Object

Type declaration

NameType
disableEvents?boolean
namespacestring
themeEditorThemeClasses

Defined in

packages/lexical/src/LexicalEditor.ts:166


EditorSetOptions

Ƭ EditorSetOptions: Object

Type declaration

NameType
tag?string

Defined in

packages/lexical/src/LexicalEditor.ts:95


EditorThemeClassName

Ƭ EditorThemeClassName: string

Defined in

packages/lexical/src/LexicalEditor.ts:67


EditorThemeClasses

Ƭ EditorThemeClasses: Object

Index signature

▪ [key: string]: any

Type declaration

NameType
blockCursor?EditorThemeClassName
characterLimit?EditorThemeClassName
code?EditorThemeClassName
codeHighlight?Record<string, EditorThemeClassName>
embedBlock?{ base?: EditorThemeClassName ; focus?: EditorThemeClassName }
embedBlock.base?EditorThemeClassName
embedBlock.focus?EditorThemeClassName
hashtag?EditorThemeClassName
heading?{ h1?: EditorThemeClassName ; h2?: EditorThemeClassName ; h3?: EditorThemeClassName ; h4?: EditorThemeClassName ; h5?: EditorThemeClassName ; h6?: EditorThemeClassName }
heading.h1?EditorThemeClassName
heading.h2?EditorThemeClassName
heading.h3?EditorThemeClassName
heading.h4?EditorThemeClassName
heading.h5?EditorThemeClassName
heading.h6?EditorThemeClassName
hr?EditorThemeClassName
image?EditorThemeClassName
indent?EditorThemeClassName
link?EditorThemeClassName
list?{ checklist?: EditorThemeClassName ; listitem?: EditorThemeClassName ; listitemChecked?: EditorThemeClassName ; listitemUnchecked?: EditorThemeClassName ; nested?: { list?: EditorThemeClassName ; listitem?: EditorThemeClassName } ; ol?: EditorThemeClassName ; olDepth?: EditorThemeClassName[] ; ul?: EditorThemeClassName ; ulDepth?: EditorThemeClassName[] }
list.checklist?EditorThemeClassName
list.listitem?EditorThemeClassName
list.listitemChecked?EditorThemeClassName
list.listitemUnchecked?EditorThemeClassName
list.nested?{ list?: EditorThemeClassName ; listitem?: EditorThemeClassName }
list.nested.list?EditorThemeClassName
list.nested.listitem?EditorThemeClassName
list.ol?EditorThemeClassName
list.olDepth?EditorThemeClassName[]
list.ul?EditorThemeClassName
list.ulDepth?EditorThemeClassName[]
ltr?EditorThemeClassName
mark?EditorThemeClassName
markOverlap?EditorThemeClassName
paragraph?EditorThemeClassName
quote?EditorThemeClassName
root?EditorThemeClassName
rtl?EditorThemeClassName
specialText?EditorThemeClassName
tab?EditorThemeClassName
table?EditorThemeClassName
tableAddColumns?EditorThemeClassName
tableAddRows?EditorThemeClassName
tableCell?EditorThemeClassName
tableCellActionButton?EditorThemeClassName
tableCellActionButtonContainer?EditorThemeClassName
tableCellHeader?EditorThemeClassName
tableCellResizer?EditorThemeClassName
tableCellSelected?EditorThemeClassName
tableRow?EditorThemeClassName
tableScrollableWrapper?EditorThemeClassName
tableSelected?EditorThemeClassName
tableSelection?EditorThemeClassName
text?TextNodeThemeClasses

Defined in

packages/lexical/src/LexicalEditor.ts:103


EditorUpdateOptions

Ƭ EditorUpdateOptions: Object

Type declaration

NameType
discrete?true
onUpdate?() => void
skipTransforms?true
tag?string | string[]

Defined in

packages/lexical/src/LexicalEditor.ts:86


ElementFormatType

Ƭ ElementFormatType: "left" | "start" | "center" | "right" | "end" | "justify" | ""

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:68


ElementPoint

Ƭ ElementPoint: Object

Type declaration

NameType
_selectionBaseSelection
getNode() => ElementNode
is(point: PointType) => boolean
isBefore(point: PointType) => boolean
keyNodeKey
offsetnumber
set(key: NodeKey, offset: number, type: "text" | "element", onlyIfChanged?: boolean) => void
type"element"

Defined in

packages/lexical/src/LexicalSelection.ts:86


EventHandler

Ƭ EventHandler: (event: Event, editor: LexicalEditor) => void

Type declaration

▸ (event, editor): void

Parameters
NameType
eventEvent
editorLexicalEditor
Returns

void

Defined in

packages/lexical/src/LexicalEvents.ts:1212


FlipDirection

Ƭ FlipDirection<D>: typeof FLIP_DIRECTION[D]

Type parameters

NameType
Dextends CaretDirection

Defined in

packages/lexical/src/LexicalCaret.ts:19


HTMLConfig

Ƭ HTMLConfig: Object

Type declaration

NameType
export?DOMExportOutputMap
import?DOMConversionMap

Defined in

packages/lexical/src/LexicalEditor.ts:181


Klass

Ƭ Klass<T>: InstanceType<T["constructor"]> extends T ? T["constructor"] : GenericConstructor<T> & T["constructor"]

Type parameters

NameType
Textends LexicalNode

Defined in

packages/lexical/src/LexicalEditor.ts:61


KlassConstructor

Ƭ KlassConstructor<Cls>: GenericConstructor<InstanceType<Cls>> & { [k in keyof Cls]: Cls[k] }

Type parameters

NameType
Clsextends GenericConstructor<any>

Defined in

packages/lexical/src/LexicalEditor.ts:56


LexicalCommand

Ƭ LexicalCommand<TPayload>: Object

Type parameters

Name
TPayload

Type declaration

NameType
type?string

Defined in

packages/lexical/src/LexicalEditor.ts:275


LexicalNodeReplacement

Ƭ LexicalNodeReplacement: Object

Type declaration

NameType
replaceKlass<LexicalNode>
with<T>(node: InstanceType<T>) => LexicalNode
withKlass?Klass<LexicalNode>

Defined in

packages/lexical/src/LexicalEditor.ts:172


LexicalUpdateJSON

Ƭ LexicalUpdateJSON<T>: Omit<T, "children" | "type" | "version">

Omit the children, type, and version properties from the given SerializedLexicalNode definition.

Type parameters

NameType
Textends SerializedLexicalNode

Defined in

packages/lexical/src/LexicalNode.ts:67


MutationListener

Ƭ MutationListener: (nodes: Map<NodeKey, NodeMutation>, payload: { dirtyLeaves: Set<string> ; prevEditorState: EditorState ; updateTags: Set<string> }) => void

Type declaration

▸ (nodes, payload): void

Parameters
NameType
nodesMap<NodeKey, NodeMutation>
payloadObject
payload.dirtyLeavesSet<string>
payload.prevEditorStateEditorState
payload.updateTagsSet<string>
Returns

void

Defined in

packages/lexical/src/LexicalEditor.ts:253


NodeCaret

Ƭ NodeCaret<D>: BreadthNodeCaret<LexicalNode, D> | DepthNodeCaret<ElementNode, D>

A NodeCaret is the combination of an origin node and a direction that points towards where a connected node will be fetched, inserted, or replaced. A BreadthNodeCaret points from a node to its next or previous sibling, and a DepthNodeCaret points to its first or last child (using next or previous as direction, for symmetry with BreadthNodeCaret).

The differences between NodeCaret and PointType are:

  • NodeCaret can only be used to refer to an entire node. A PointType of text type can be used to refer to a specific location inside of a TextNode.
  • NodeCaret stores an origin node, type (breadth or depth), and direction (next or previous). A PointType stores a type (text or element), the key of a node, and an offset within that node.
  • NodeCaret is directional and always refers to a very specific node, eliminating all ambiguity. PointType can refer to the location before or after a node depending on context.
  • NodeCaret is more robust to nearby mutations, as it relies only on a node's direct connections. An element Any change to the count of previous siblings in an element PointType will invalidate it.
  • NodeCaret is designed to work more directly with the internal representation of the document tree, making it suitable for use in traversals without performing any redundant work.

The caret does not update in response to any mutations, you should not persist it across editor updates, and using a caret after its origin node has been removed or replaced may result in runtime errors.

Type parameters

NameType
Dextends CaretDirection = CaretDirection

Defined in

packages/lexical/src/LexicalCaret.ts:100


NodeKey

Ƭ NodeKey: string

Defined in

packages/lexical/src/LexicalNode.ts:185


NodeMap

Ƭ NodeMap: Map<NodeKey, LexicalNode>

Defined in

packages/lexical/src/LexicalNode.ts:52


NodeMutation

Ƭ NodeMutation: "created" | "updated" | "destroyed"

Defined in

packages/lexical/src/LexicalEditor.ts:219


PasteCommandType

Ƭ PasteCommandType: ClipboardEvent | InputEvent | KeyboardEvent

Defined in

packages/lexical/src/LexicalCommands.ts:17


PointType

Ƭ PointType: TextPoint | ElementPoint

Defined in

packages/lexical/src/LexicalSelection.ts:102


RootMode

Ƭ RootMode: "root" | "shadowRoot"

Defined in

packages/lexical/src/LexicalCaret.ts:21


SerializedEditor

Ƭ SerializedEditor: Object

Type declaration

NameType
editorStateSerializedEditorState

Defined in

packages/lexical/src/LexicalEditor.ts:340


SerializedElementNode

Ƭ SerializedElementNode<T>: Spread<{ children: T[] ; direction: "ltr" | "rtl" | null ; format: ElementFormatType ; indent: number ; textFormat?: number ; textStyle?: string }, SerializedLexicalNode>

Type parameters

NameType
Textends SerializedLexicalNode = SerializedLexicalNode

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:54


SerializedLexicalNode

Ƭ SerializedLexicalNode: Object

The base type for all serialized nodes

Type declaration

NameTypeDescription
typestringThe type string used by the Node class
versionnumberA numeric version for this schema, defaulting to 1, but not generally recommended for use

Defined in

packages/lexical/src/LexicalNode.ts:57


SerializedLineBreakNode

Ƭ SerializedLineBreakNode: SerializedLexicalNode

Defined in

packages/lexical/src/nodes/LexicalLineBreakNode.ts:24


SerializedParagraphNode

Ƭ SerializedParagraphNode: Spread<{ textFormat: number ; textStyle: string }, SerializedElementNode>

Defined in

packages/lexical/src/nodes/LexicalParagraphNode.ts:36


SerializedRootNode

Ƭ SerializedRootNode<T>: SerializedElementNode<T>

Type parameters

NameType
Textends SerializedLexicalNode = SerializedLexicalNode

Defined in

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


SerializedTabNode

Ƭ SerializedTabNode: SerializedTextNode

Defined in

packages/lexical/src/nodes/LexicalTabNode.ts:24


SerializedTextNode

Ƭ SerializedTextNode: Spread<{ detail: number ; format: number ; mode: TextModeType ; style: string ; text: string }, SerializedLexicalNode>

Defined in

packages/lexical/src/nodes/LexicalTextNode.ts:72


Spread

Ƭ Spread<T1, T2>: Omit<T2, keyof T1> & T1

Type parameters

Name
T1
T2

Defined in

packages/lexical/src/LexicalEditor.ts:52


TextFormatType

Ƭ TextFormatType: "bold" | "underline" | "strikethrough" | "italic" | "highlight" | "code" | "subscript" | "superscript" | "lowercase" | "uppercase" | "capitalize"

Defined in

packages/lexical/src/nodes/LexicalTextNode.ts:85


TextModeType

Ƭ TextModeType: "normal" | "token" | "segmented"

Defined in

packages/lexical/src/nodes/LexicalTextNode.ts:98


TextPoint

Ƭ TextPoint: Object

Type declaration

NameType
_selectionBaseSelection
getNode() => TextNode
is(point: PointType) => boolean
isBefore(point: PointType) => boolean
keyNodeKey
offsetnumber
set(key: NodeKey, offset: number, type: "text" | "element", onlyIfChanged?: boolean) => void
type"text"

Defined in

packages/lexical/src/LexicalSelection.ts:70


Transform

Ƭ Transform<T>: (node: T) => void

Type parameters

NameType
Textends LexicalNode

Type declaration

▸ (node): void

Parameters
NameType
nodeT
Returns

void

Defined in

packages/lexical/src/LexicalEditor.ts:211


UpdateListener

Ƭ UpdateListener: (arg0: { dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement> ; dirtyLeaves: Set<NodeKey> ; editorState: EditorState ; normalizedNodes: Set<NodeKey> ; prevEditorState: EditorState ; tags: Set<string> }) => void

Type declaration

▸ (arg0): void

Parameters
NameType
arg0Object
arg0.dirtyElementsMap<NodeKey, IntentionallyMarkedAsDirtyElement>
arg0.dirtyLeavesSet<NodeKey>
arg0.editorStateEditorState
arg0.normalizedNodesSet<NodeKey>
arg0.prevEditorStateEditorState
arg0.tagsSet<string>
Returns

void

Defined in

packages/lexical/src/LexicalEditor.ts:233

Variables

BLUR_COMMAND

Const BLUR_COMMAND: LexicalCommand<FocusEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:122


CAN_REDO_COMMAND

Const CAN_REDO_COMMAND: LexicalCommand<boolean>

Defined in

packages/lexical/src/LexicalCommands.ts:116


CAN_UNDO_COMMAND

Const CAN_UNDO_COMMAND: LexicalCommand<boolean>

Defined in

packages/lexical/src/LexicalCommands.ts:118


CLEAR_EDITOR_COMMAND

Const CLEAR_EDITOR_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:110


CLEAR_HISTORY_COMMAND

Const CLEAR_HISTORY_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:113


CLICK_COMMAND

Const CLICK_COMMAND: LexicalCommand<MouseEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:30


COMMAND_PRIORITY_CRITICAL

Const COMMAND_PRIORITY_CRITICAL: 4

Defined in

packages/lexical/src/LexicalEditor.ts:272


COMMAND_PRIORITY_EDITOR

Const COMMAND_PRIORITY_EDITOR: 0

Defined in

packages/lexical/src/LexicalEditor.ts:268


COMMAND_PRIORITY_HIGH

Const COMMAND_PRIORITY_HIGH: 3

Defined in

packages/lexical/src/LexicalEditor.ts:271


COMMAND_PRIORITY_LOW

Const COMMAND_PRIORITY_LOW: 1

Defined in

packages/lexical/src/LexicalEditor.ts:269


COMMAND_PRIORITY_NORMAL

Const COMMAND_PRIORITY_NORMAL: 2

Defined in

packages/lexical/src/LexicalEditor.ts:270


CONTROLLED_TEXT_INSERTION_COMMAND

Const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<InputEvent | string>

Defined in

packages/lexical/src/LexicalCommands.ts:41


COPY_COMMAND

Const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent | null>

Defined in

packages/lexical/src/LexicalCommands.ts:102


CUT_COMMAND

Const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent | null>

Defined in

packages/lexical/src/LexicalCommands.ts:105


DELETE_CHARACTER_COMMAND

Const DELETE_CHARACTER_COMMAND: LexicalCommand<boolean>

Defined in

packages/lexical/src/LexicalCommands.ts:32


DELETE_LINE_COMMAND

Const DELETE_LINE_COMMAND: LexicalCommand<boolean>

Defined in

packages/lexical/src/LexicalCommands.ts:51


DELETE_WORD_COMMAND

Const DELETE_WORD_COMMAND: LexicalCommand<boolean>

Defined in

packages/lexical/src/LexicalCommands.ts:48


DRAGEND_COMMAND

Const DRAGEND_COMMAND: LexicalCommand<DragEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:100


DRAGOVER_COMMAND

Const DRAGOVER_COMMAND: LexicalCommand<DragEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:98


DRAGSTART_COMMAND

Const DRAGSTART_COMMAND: LexicalCommand<DragEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:96


DROP_COMMAND

Const DROP_COMMAND: LexicalCommand<DragEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:92


FOCUS_COMMAND

Const FOCUS_COMMAND: LexicalCommand<FocusEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:120


FORMAT_ELEMENT_COMMAND

Const FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>

Defined in

packages/lexical/src/LexicalCommands.ts:94


FORMAT_TEXT_COMMAND

Const FORMAT_TEXT_COMMAND: LexicalCommand<TextFormatType>

Defined in

packages/lexical/src/LexicalCommands.ts:54


INDENT_CONTENT_COMMAND

Const INDENT_CONTENT_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:86


INSERT_LINE_BREAK_COMMAND

Const INSERT_LINE_BREAK_COMMAND: LexicalCommand<boolean>

Defined in

packages/lexical/src/LexicalCommands.ts:35


INSERT_PARAGRAPH_COMMAND

Const INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:38


INSERT_TAB_COMMAND

Const INSERT_TAB_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:84


IS_ALL_FORMATTING

Const IS_ALL_FORMATTING: number

Defined in

packages/lexical/src/LexicalConstants.ts:53


IS_BOLD

Const IS_BOLD: 1

Defined in

packages/lexical/src/LexicalConstants.ts:41


IS_CODE

Const IS_CODE: number

Defined in

packages/lexical/src/LexicalConstants.ts:45


IS_HIGHLIGHT

Const IS_HIGHLIGHT: number

Defined in

packages/lexical/src/LexicalConstants.ts:48


IS_ITALIC

Const IS_ITALIC: number

Defined in

packages/lexical/src/LexicalConstants.ts:42


IS_STRIKETHROUGH

Const IS_STRIKETHROUGH: number

Defined in

packages/lexical/src/LexicalConstants.ts:43


IS_SUBSCRIPT

Const IS_SUBSCRIPT: number

Defined in

packages/lexical/src/LexicalConstants.ts:46


IS_SUPERSCRIPT

Const IS_SUPERSCRIPT: number

Defined in

packages/lexical/src/LexicalConstants.ts:47


IS_UNDERLINE

Const IS_UNDERLINE: number

Defined in

packages/lexical/src/LexicalConstants.ts:44


KEY_ARROW_DOWN_COMMAND

Const KEY_ARROW_DOWN_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:70


KEY_ARROW_LEFT_COMMAND

Const KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:64


KEY_ARROW_RIGHT_COMMAND

Const KEY_ARROW_RIGHT_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:60


KEY_ARROW_UP_COMMAND

Const KEY_ARROW_UP_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:68


KEY_BACKSPACE_COMMAND

Const KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:76


KEY_DELETE_COMMAND

Const KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:80


KEY_DOWN_COMMAND

Const KEY_DOWN_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:58


KEY_ENTER_COMMAND

Const KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>

Defined in

packages/lexical/src/LexicalCommands.ts:72


KEY_ESCAPE_COMMAND

Const KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:78


KEY_MODIFIER_COMMAND

Const KEY_MODIFIER_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:124


KEY_SPACE_COMMAND

Const KEY_SPACE_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:74


KEY_TAB_COMMAND

Const KEY_TAB_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:82


MOVE_TO_END

Const MOVE_TO_END: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:62


MOVE_TO_START

Const MOVE_TO_START: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:66


OUTDENT_CONTENT_COMMAND

Const OUTDENT_CONTENT_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:89


PASTE_COMMAND

Const PASTE_COMMAND: LexicalCommand<PasteCommandType>

Defined in

packages/lexical/src/LexicalCommands.ts:44


REDO_COMMAND

Const REDO_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:57


REMOVE_TEXT_COMMAND

Const REMOVE_TEXT_COMMAND: LexicalCommand<InputEvent | null>

Defined in

packages/lexical/src/LexicalCommands.ts:46


SELECTION_CHANGE_COMMAND

Const SELECTION_CHANGE_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:23


SELECTION_INSERT_CLIPBOARD_NODES_COMMAND

Const SELECTION_INSERT_CLIPBOARD_NODES_COMMAND: LexicalCommand<{ nodes: LexicalNode[] ; selection: BaseSelection }>

Defined in

packages/lexical/src/LexicalCommands.ts:26


SELECT_ALL_COMMAND

Const SELECT_ALL_COMMAND: LexicalCommand<KeyboardEvent>

Defined in

packages/lexical/src/LexicalCommands.ts:108


TEXT_TYPE_TO_FORMAT

Const TEXT_TYPE_TO_FORMAT: Record<TextFormatType | string, number>

Defined in

packages/lexical/src/LexicalConstants.ts:106


UNDO_COMMAND

Const UNDO_COMMAND: LexicalCommand<void>

Defined in

packages/lexical/src/LexicalCommands.ts:56

Functions

$addUpdateTag

$addUpdateTag(tag): void

Parameters

NameType
tagstring

Returns

void

Defined in

packages/lexical/src/LexicalUtils.ts:1392


$applyNodeReplacement

$applyNodeReplacement<N>(node): N

Type parameters

NameType
Nextends LexicalNode

Parameters

NameType
nodeN

Returns

N

Defined in

packages/lexical/src/LexicalUtils.ts:1502


$caretFromPoint

$caretFromPoint(point): NodeCaret<"next">

Since a NodeCaret can only represent a whole node, when a text PointType is encountered the caret will lie before the text node if it is non-empty and offset === 0, otherwise it will lie after the node.

Parameters

NameType
pointPointType

Returns

NodeCaret<"next">

a NodeCaret for the point

Defined in

packages/lexical/src/LexicalCaret.ts:551


$caretRangeFromSelection

$caretRangeFromSelection(selection): NodeCaretRange

Get a pair of carets for a RangeSelection. Since a NodeCaret can only represent a whole node, when a text PointType is encountered the caret will be moved to before or after the node depending on where the other point lies.

If the focus is before the anchor, then the direction will be 'previous', otherwise the direction will be 'next'.

Parameters

NameType
selectionRangeSelection

Returns

NodeCaretRange

Defined in

packages/lexical/src/LexicalCaret.ts:583


$cloneWithProperties

$cloneWithProperties<T>(latestNode): T

Returns a clone of a node using node.constructor.clone() followed by clone.afterCloneFrom(node). The resulting clone must have the same key, parent/next/prev pointers, and other properties that are not set by node.constructor.clone (format, style, etc.). This is primarily used by LexicalNode.getWritable to create a writable version of an existing node. The clone is the same logical node as the original node, do not try and use this function to duplicate or copy an existing node.

Does not mutate the EditorState.

Type parameters

NameType
Textends LexicalNode

Parameters

NameType
latestNodeT

Returns

T

The clone of the node.

Defined in

packages/lexical/src/LexicalUtils.ts:1940


$copyNode

$copyNode<T>(node): T

Returns a shallow clone of node with a new key

Type parameters

NameType
Textends LexicalNode

Parameters

NameTypeDescription
nodeTThe node to be copied.

Returns

T

The copy of the node.

Defined in

packages/lexical/src/LexicalUtils.ts:1496


$createLineBreakNode

$createLineBreakNode(): LineBreakNode

Returns

LineBreakNode

Defined in

packages/lexical/src/nodes/LexicalLineBreakNode.ts:78


$createNodeSelection

$createNodeSelection(): NodeSelection

Returns

NodeSelection

Defined in

packages/lexical/src/LexicalSelection.ts:2416


$createParagraphNode

$createParagraphNode(): ParagraphNode

Returns

ParagraphNode

Defined in

packages/lexical/src/nodes/LexicalParagraphNode.ts:170


$createPoint

$createPoint(key, offset, type): PointType

Parameters

NameType
keystring
offsetnumber
type"text" | "element"

Returns

PointType

Defined in

packages/lexical/src/LexicalSelection.ts:193


$createRangeSelection

$createRangeSelection(): RangeSelection

Returns

RangeSelection

Defined in

packages/lexical/src/LexicalSelection.ts:2410


$createRangeSelectionFromDom

$createRangeSelectionFromDom(domSelection, editor): null | RangeSelection

Parameters

NameType
domSelectionnull | Selection
editorLexicalEditor

Returns

null | RangeSelection

Defined in

packages/lexical/src/LexicalSelection.ts:2439


$createTabNode

$createTabNode(): TabNode

Returns

TabNode

Defined in

packages/lexical/src/nodes/LexicalTabNode.ts:87


$createTextNode

$createTextNode(text?): TextNode

Parameters

NameTypeDefault value
textstring''

Returns

TextNode

Defined in

packages/lexical/src/nodes/LexicalTextNode.ts:1310


$getAdjacentDepthCaret

$getAdjacentDepthCaret<D>(origin): null | NodeCaret<D>

Gets the adjacent caret, if not-null and if the origin of the adjacent caret is an ElementNode, then return the DepthNodeCaret. This can be used along with the getParentAdjacentCaret method to perform a full DFS style traversal of the tree.

Type parameters

NameType
Dextends CaretDirection

Parameters

NameType
originnull | NodeCaret<D>

Returns

null | NodeCaret<D>

Defined in

packages/lexical/src/LexicalCaret.ts:446


$getAdjacentNode

$getAdjacentNode(focus, isBackward): null | LexicalNode

Parameters

NameType
focusPointType
isBackwardboolean

Returns

null | LexicalNode

Defined in

packages/lexical/src/LexicalUtils.ts:1246


$getBreadthCaret

$getBreadthCaret<T, D>(origin, direction): BreadthNodeCaret<T, D>

Get a caret that points at the next or previous sibling of the given origin node.

Type parameters

NameType
Textends LexicalNode
Dextends CaretDirection

Parameters

NameTypeDescription
originTThe origin node
directionD'next' or 'previous'

Returns

BreadthNodeCaret<T, D>

null if origin is null, otherwise a BreadthNodeCaret for this origin and direction

Defined in

packages/lexical/src/LexicalCaret.ts:395

$getBreadthCaret<T, D>(origin, direction): null | BreadthNodeCaret<T, D>

Type parameters

NameType
Textends LexicalNode
Dextends CaretDirection

Parameters

NameType
originnull | T
directionD

Returns

null | BreadthNodeCaret<T, D>

Defined in

packages/lexical/src/LexicalCaret.ts:399


$getCharacterOffsets

$getCharacterOffsets(selection): [number, number]

Parameters

NameType
selectionBaseSelection

Returns

[number, number]

Defined in

packages/lexical/src/LexicalSelection.ts:1953


$getChildCaretAtIndex

$getChildCaretAtIndex(parent, index): NodeCaret<"next">

Get a 'next' caret for the child at the given index, or the last caret in that node if out of bounds

Parameters

NameTypeDescription
parentElementNodeAn ElementNode
indexnumberThe index of the origin for the caret

Returns

NodeCaret<"next">

A next caret with the arrow at that index

Defined in

packages/lexical/src/LexicalCaret.ts:460


$getChildCaretOrSelf

$getChildCaretOrSelf<D, Null>(caret): NodeCaret<D> | Null

Gets the DepthNodeCaret if one is possible at this caret origin, otherwise return the caret

Type parameters

NameType
Dextends CaretDirection
Nullextends null = never

Parameters

NameType
caretNull | NodeCaret<D>

Returns

NodeCaret<D> | Null

Defined in

packages/lexical/src/LexicalCaret.ts:432


$getDepthCaret

$getDepthCaret<T, D>(node, direction): DepthNodeCaret<T, D>

Get a caret that points at the first or last child of the given origin node, which must be an ElementNode.

Type parameters

NameType
Textends ElementNode
Dextends CaretDirection

Parameters

NameTypeDescription
nodeT-
directionD'next' for first child or 'previous' for last child

Returns

DepthNodeCaret<T, D>

null if origin is null or not an ElementNode, otherwise a DepthNodeCaret for this origin and direction

Defined in

packages/lexical/src/LexicalCaret.ts:418


$getEditor

$getEditor(): LexicalEditor

Utility function for accessing current active editor instance.

Returns

LexicalEditor

Current active editor

Defined in

packages/lexical/src/LexicalUtils.ts:1877


$getNearestNodeFromDOMNode

$getNearestNodeFromDOMNode(startingDOM, editorState?): LexicalNode | null

Parameters

NameType
startingDOMNode
editorState?EditorState

Returns

LexicalNode | null

Defined in

packages/lexical/src/LexicalUtils.ts:496


$getNearestRootOrShadowRoot

$getNearestRootOrShadowRoot(node): RootNode | ElementNode

Parameters

NameType
nodeLexicalNode

Returns

RootNode | ElementNode

Defined in

packages/lexical/src/LexicalUtils.ts:1464


$getNodeByKey

$getNodeByKey<T>(key, _editorState?): T | null

Type parameters

NameType
Textends LexicalNode

Parameters

NameType
keystring
_editorState?EditorState

Returns

T | null

Defined in

packages/lexical/src/LexicalUtils.ts:455


$getNodeByKeyOrThrow

$getNodeByKeyOrThrow<N>(key): N

Type parameters

NameType
Nextends LexicalNode

Parameters

NameType
keystring

Returns

N

Defined in

packages/lexical/src/LexicalUtils.ts:1568


$getPreviousSelection

$getPreviousSelection(): null | BaseSelection

Returns

null | BaseSelection

Defined in

packages/lexical/src/LexicalSelection.ts:2576


$getRoot

$getRoot(): RootNode

Returns

RootNode

Defined in

packages/lexical/src/LexicalUtils.ts:564


$getSelection

$getSelection(): null | BaseSelection

Returns

null | BaseSelection

Defined in

packages/lexical/src/LexicalSelection.ts:2571


$getTextContent

$getTextContent(): string

Returns

string

Defined in

packages/lexical/src/LexicalSelection.ts:2955


$hasAncestor

$hasAncestor(child, targetNode): boolean

Parameters

NameType
childLexicalNode
targetNodeLexicalNode

Returns

boolean

Defined in

packages/lexical/src/LexicalUtils.ts:1430


$hasUpdateTag

$hasUpdateTag(tag): boolean

Parameters

NameType
tagstring

Returns

boolean

Defined in

packages/lexical/src/LexicalUtils.ts:1387


$insertNodes

$insertNodes(nodes): void

Parameters

NameType
nodesLexicalNode[]

Returns

void

Defined in

packages/lexical/src/LexicalSelection.ts:2946


$isBlockElementNode

$isBlockElementNode(node): node is ElementNode

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is ElementNode

Defined in

packages/lexical/src/LexicalSelection.ts:2380


$isDecoratorNode

$isDecoratorNode<T>(node): node is DecoratorNode<T>

Type parameters

Name
T

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is DecoratorNode<T>

Defined in

packages/lexical/src/nodes/LexicalDecoratorNode.ts:48


$isElementNode

$isElementNode(node): node is ElementNode

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is ElementNode

Defined in

packages/lexical/src/nodes/LexicalElementNode.ts:976


$isInlineElementOrDecoratorNode

$isInlineElementOrDecoratorNode(node): boolean

Parameters

NameType
nodeLexicalNode

Returns

boolean

Defined in

packages/lexical/src/LexicalUtils.ts:1457


$isLeafNode

$isLeafNode(node): node is DecoratorNode<unknown> | TextNode | LineBreakNode

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is DecoratorNode<unknown> | TextNode | LineBreakNode

Defined in

packages/lexical/src/LexicalUtils.ts:256


$isLineBreakNode

$isLineBreakNode(node): node is LineBreakNode

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is LineBreakNode

Defined in

packages/lexical/src/nodes/LexicalLineBreakNode.ts:82


$isNodeSelection

$isNodeSelection(x): x is NodeSelection

Parameters

NameType
xunknown

Returns

x is NodeSelection

Defined in

packages/lexical/src/LexicalSelection.ts:1937


$isParagraphNode

$isParagraphNode(node): node is ParagraphNode

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is ParagraphNode

Defined in

packages/lexical/src/nodes/LexicalParagraphNode.ts:174


$isRangeSelection

$isRangeSelection(x): x is RangeSelection

Parameters

NameType
xunknown

Returns

x is RangeSelection

Defined in

packages/lexical/src/LexicalSelection.ts:416


$isRootNode

$isRootNode(node): node is RootNode

Parameters

NameType
nodeundefined | null | LexicalNode | RootNode

Returns

node is RootNode

Defined in

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


$isRootOrShadowRoot

$isRootOrShadowRoot(node): node is RootNode | ShadowRootNode

Parameters

NameType
nodenull | LexicalNode

Returns

node is RootNode | ShadowRootNode

Defined in

packages/lexical/src/LexicalUtils.ts:1484


$isTabNode

$isTabNode(node): node is TabNode

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is TabNode

Defined in

packages/lexical/src/nodes/LexicalTabNode.ts:91


$isTextNode

$isTextNode(node): node is TextNode

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is TextNode

Defined in

packages/lexical/src/nodes/LexicalTextNode.ts:1314


$isTokenOrSegmented

$isTokenOrSegmented(node): boolean

Parameters

NameType
nodeTextNode

Returns

boolean

Defined in

packages/lexical/src/LexicalUtils.ts:195


$nodesOfType

$nodesOfType<T>(klass): T[]

Type parameters

NameType
Textends LexicalNode

Parameters

NameType
klassKlass<T>

Returns

T[]

Deprecated

Use LexicalEditor.registerMutationListener with skipInitialization: false instead.

Defined in

packages/lexical/src/LexicalUtils.ts:1203


$normalizeSelection__EXPERIMENTAL

$normalizeSelection__EXPERIMENTAL(selection): RangeSelection

Parameters

NameType
selectionRangeSelection

Returns

RangeSelection

Defined in

packages/lexical/src/LexicalNormalization.ts:89


$onUpdate

$onUpdate(updateFn): void

Add a function to run after the current update. This will run after any onUpdate function already supplied to editor.update(), as well as any functions added with previous calls to $onUpdate.

Parameters

NameTypeDescription
updateFn() => voidThe function to run after the current update.

Returns

void

Defined in

packages/lexical/src/LexicalUtils.ts:1405


$parseSerializedNode

$parseSerializedNode(serializedNode): LexicalNode

Parameters

NameType
serializedNodeSerializedLexicalNode

Returns

LexicalNode

Defined in

packages/lexical/src/LexicalUpdates.ts:344


$selectAll

$selectAll(selection?): RangeSelection

Parameters

NameType
selection?null | RangeSelection

Returns

RangeSelection

Defined in

packages/lexical/src/LexicalUtils.ts:1121


$setCompositionKey

$setCompositionKey(compositionKey): void

Parameters

NameType
compositionKeynull | string

Returns

void

Defined in

packages/lexical/src/LexicalUtils.ts:426


$setSelection

$setSelection(selection): void

Parameters

NameType
selectionnull | BaseSelection

Returns

void

Defined in

packages/lexical/src/LexicalUtils.ts:572


$splitNode

$splitNode(node, offset): [ElementNode | null, ElementNode]

Parameters

NameType
nodeElementNode
offsetnumber

Returns

[ElementNode | null, ElementNode]

Defined in

packages/lexical/src/LexicalUtils.ts:1701


createCommand

createCommand<T>(type?): LexicalCommand<T>

Type parameters

Name
T

Parameters

NameType
type?string

Returns

LexicalCommand<T>

Defined in

packages/lexical/src/LexicalCommands.ts:19


createEditor

createEditor(editorConfig?): LexicalEditor

Creates a new LexicalEditor attached to a single contentEditable (provided in the config). This is the lowest-level initialization API for a LexicalEditor. If you're using React or another framework, consider using the appropriate abstractions, such as LexicalComposer

Parameters

NameTypeDescription
editorConfig?CreateEditorArgsthe editor configuration.

Returns

LexicalEditor

a LexicalEditor instance

Defined in

packages/lexical/src/LexicalEditor.ts:427


getDOMOwnerDocument

getDOMOwnerDocument(target): Document | null

Parameters

NameType
targetnull | EventTarget

Returns

Document | null

Defined in

packages/lexical/src/LexicalUtils.ts:1324


getDOMSelection

getDOMSelection(targetWindow): null | Selection

Returns the selection for the given window, or the global window if null. Will return null if CAN_USE_DOM is false.

Parameters

NameTypeDescription
targetWindownull | WindowThe window to get the selection from

Returns

null | Selection

a Selection or null

Defined in

packages/lexical/src/LexicalUtils.ts:1684


getDOMSelectionFromTarget

getDOMSelectionFromTarget(eventTarget): null | Selection

Returns the selection for the defaultView of the ownerDocument of given EventTarget.

Parameters

NameTypeDescription
eventTargetnull | EventTargetThe node to get the selection from

Returns

null | Selection

a Selection or null

Defined in

packages/lexical/src/LexicalUtils.ts:1694


getDOMTextNode

getDOMTextNode(element): Text | null

Parameters

NameType
elementnull | Node

Returns

Text | null

Defined in

packages/lexical/src/LexicalUtils.ts:215


getNearestEditorFromDOMNode

getNearestEditorFromDOMNode(node): LexicalEditor | null

Parameters

NameType
nodenull | Node

Returns

LexicalEditor | null

Defined in

packages/lexical/src/LexicalUtils.ts:165


isBlockDomNode

isBlockDomNode(node): boolean

Parameters

NameTypeDescription
nodeNodethe Dom Node to check

Returns

boolean

if the Dom Node is a block node

Defined in

packages/lexical/src/LexicalUtils.ts:1821


isCurrentlyReadOnlyMode

isCurrentlyReadOnlyMode(): boolean

Returns

boolean

Defined in

packages/lexical/src/LexicalUpdates.ts:73


isDOMDocumentNode

isDOMDocumentNode(node): node is Document

Parameters

NameTypeDescription
nodeunknownThe element being tested

Returns

node is Document

Returns true if node is an DOM Document node, false otherwise.

Defined in

packages/lexical/src/LexicalUtils.ts:211


isDOMNode

isDOMNode(x): x is Node

Parameters

NameTypeDescription
xunknownThe element being tested

Returns

x is Node

Returns true if x is a DOM Node, false otherwise.

Defined in

packages/lexical/src/LexicalUtils.ts:1786


isDOMTextNode

isDOMTextNode(node): node is Text

Parameters

NameTypeDescription
nodeunknownThe element being tested

Returns

node is Text

Returns true if node is an DOM Text node, false otherwise.

Defined in

packages/lexical/src/LexicalUtils.ts:203


isDocumentFragment

isDocumentFragment(x): x is DocumentFragment

Parameters

NameTypeDescription
xunknownThe element being testing

Returns

x is DocumentFragment

Returns true if x is a document fragment, false otherwise.

Defined in

packages/lexical/src/LexicalUtils.ts:1799


isHTMLAnchorElement

isHTMLAnchorElement(x): x is HTMLAnchorElement

Parameters

NameTypeDescription
xunknownThe element being tested

Returns

x is HTMLAnchorElement

Returns true if x is an HTML anchor tag, false otherwise

Defined in

packages/lexical/src/LexicalUtils.ts:1770


isHTMLElement

isHTMLElement(x): x is HTMLElement

Parameters

NameTypeDescription
xunknownThe element being tested

Returns

x is HTMLElement

Returns true if x is an HTML element, false otherwise.

Defined in

packages/lexical/src/LexicalUtils.ts:1778


isInlineDomNode

isInlineDomNode(node): boolean

Parameters

NameTypeDescription
nodeNodethe Dom Node to check

Returns

boolean

if the Dom Node is an inline node

Defined in

packages/lexical/src/LexicalUtils.ts:1808


isLexicalEditor

isLexicalEditor(editor): editor is LexicalEditor

Parameters

NameType
editorunknown

Returns

editor is LexicalEditor

true if the given argument is a LexicalEditor instance from this build of Lexical

Defined in

packages/lexical/src/LexicalUtils.ts:160


isSelectionCapturedInDecoratorInput

isSelectionCapturedInDecoratorInput(anchorDOM): boolean

Parameters

NameType
anchorDOMNode

Returns

boolean

Defined in

packages/lexical/src/LexicalUtils.ts:119


isSelectionWithinEditor

isSelectionWithinEditor(editor, anchorDOM, focusDOM): boolean

Parameters

NameType
editorLexicalEditor
anchorDOMnull | Node
focusDOMnull | Node

Returns

boolean

Defined in

packages/lexical/src/LexicalUtils.ts:136


makeStepwiseIterator

makeStepwiseIterator<State, Stop, Value>(«destructured»): IterableIterator<Value>

Type parameters

Name
State
Stop
Value

Parameters

NameType
«destructured»StepwiseIteratorConfig<State, Stop, Value>

Returns

IterableIterator<Value>

Defined in

packages/lexical/src/LexicalCaret.ts:617


resetRandomKey

resetRandomKey(): void

Returns

void

Defined in

packages/lexical/src/LexicalUtils.ts:86


setNodeIndentFromDOM

setNodeIndentFromDOM(elementDom, elementNode): void

Parameters

NameType
elementDomHTMLElement
elementNodeElementNode

Returns

void

Defined in

packages/lexical/src/LexicalUtils.ts:1963