Module: lexical
Classes
- ArtificialNode__DO_NOT_USE
 - DecoratorNode
 - EditorState
 - ElementDOMSlot
 - ElementNode
 - LexicalEditor
 - LexicalNode
 - LineBreakNode
 - NodeSelection
 - ParagraphNode
 - Point
 - RangeSelection
 - RootNode
 - TabNode
 - TextNode
 
Interfaces
- BaseNodeCaret
 - BaseSelection
 - BreadthNodeCaret
 - DepthNodeCaret
 - EditorStateReadOptions
 - NodeCaretRange
 - SerializedEditorState
 - StepwiseIteratorConfig
 - TextPointCaret
 - TextPointCaretSlice
 
Type Aliases
CaretDirection
Ƭ CaretDirection: "next" | "previous"
The direction of a caret, 'next' points towards the end of the document and 'previous' points towards the beginning
Defined in
packages/lexical/src/caret/LexicalCaret.ts:21
CaretType
Ƭ CaretType: "breadth" | "depth"
A breadth caret type points from a LexicalNode origin to its next or previous sibling, and a depth caret type points from an ElementNode origin to its first or last child.
Defined in
packages/lexical/src/caret/LexicalCaret.ts:30
CommandListener
Ƭ CommandListener<P>: (payload: P, editor: LexicalEditor) => boolean
Type parameters
| Name | 
|---|
P | 
Type declaration
▸ (payload, editor): boolean
Parameters
| Name | Type | 
|---|---|
payload | P | 
editor | LexicalEditor | 
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
| Name | Type | 
|---|---|
TCommand | extends LexicalCommand<unknown> | 
Defined in
packages/lexical/src/LexicalEditor.ts:299
CreateEditorArgs
Ƭ CreateEditorArgs: Object
Type declaration
| Name | Type | 
|---|---|
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
| Name | Type | 
|---|---|
lexicalNode | LexicalNode | 
parentLexicalNode | LexicalNode | null | undefined | 
Returns
LexicalNode | null | undefined
Defined in
packages/lexical/src/LexicalNode.ts:156
DOMConversion
Ƭ DOMConversion<T>: Object
Type parameters
| Name | Type | 
|---|---|
T | extends HTMLElement = HTMLElement | 
Type declaration
| Name | Type | 
|---|---|
conversion | DOMConversionFn<T> | 
priority? | 0 | 1 | 2 | 3 | 4 | 
Defined in
packages/lexical/src/LexicalNode.ts:147
DOMConversionFn
Ƭ DOMConversionFn<T>: (element: T) => DOMConversionOutput | null
Type parameters
| Name | Type | 
|---|---|
T | extends HTMLElement = HTMLElement | 
Type declaration
▸ (element): DOMConversionOutput | null
Parameters
| Name | Type | 
|---|---|
element | T | 
Returns
DOMConversionOutput | null
Defined in
packages/lexical/src/LexicalNode.ts:152
DOMConversionMap
Ƭ DOMConversionMap<T>: Record<NodeName, (node: T) => DOMConversion<T> | null>
Type parameters
| Name | Type | 
|---|---|
T | extends HTMLElement = HTMLElement | 
Defined in
packages/lexical/src/LexicalNode.ts:161
DOMConversionOutput
Ƭ DOMConversionOutput: Object
Type declaration
| Name | Type | 
|---|---|
after? | (childLexicalNodes: LexicalNode[]) => LexicalNode[] | 
forChild? | DOMChildConversion | 
node | null | LexicalNode | LexicalNode[] | 
Defined in
packages/lexical/src/LexicalNode.ts:167
DOMExportOutput
Ƭ DOMExportOutput: Object
Type declaration
| Name | Type | 
|---|---|
after? | (generatedElement: HTMLElement | DocumentFragment | Text | null | undefined) => HTMLElement | Text | null | undefined | 
element | HTMLElement | 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
| Name | Type | 
|---|---|
editable | boolean | 
Returns
void
Defined in
packages/lexical/src/LexicalEditor.ts:264
EditorConfig
Ƭ EditorConfig: Object
Type declaration
| Name | Type | 
|---|---|
disableEvents? | boolean | 
namespace | string | 
theme | EditorThemeClasses | 
Defined in
packages/lexical/src/LexicalEditor.ts:166
EditorSetOptions
Ƭ EditorSetOptions: Object
Type declaration
| Name | Type | 
|---|---|
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
Defined in
packages/lexical/src/LexicalEditor.ts:103
EditorUpdateOptions
Ƭ EditorUpdateOptions: Object
Type declaration
| Name | Type | 
|---|---|
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
| Name | Type | 
|---|---|
_selection | BaseSelection | 
getNode | () => ElementNode | 
is | (point: PointType) => boolean | 
isBefore | (point: PointType) => boolean | 
key | NodeKey | 
offset | number | 
set | (key: NodeKey, offset: number, type: "text" | "element", onlyIfChanged?: boolean) => void | 
type | "element" | 
Defined in
packages/lexical/src/LexicalSelection.ts:89
EventHandler
Ƭ EventHandler: (event: Event, editor: LexicalEditor) => void
Type declaration
▸ (event, editor): void
Parameters
| Name | Type | 
|---|---|
event | Event | 
editor | LexicalEditor | 
Returns
void
Defined in
packages/lexical/src/LexicalEvents.ts:1232
FlipDirection
Ƭ FlipDirection<D>: typeof FLIP_DIRECTION[D]
A type utility to flip next and previous
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Defined in
packages/lexical/src/caret/LexicalCaret.ts:25
HTMLConfig
Ƭ HTMLConfig: Object
Type declaration
| Name | Type | 
|---|---|
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
| Name | Type | 
|---|---|
T | extends LexicalNode | 
Defined in
packages/lexical/src/LexicalEditor.ts:61
KlassConstructor
Ƭ KlassConstructor<Cls>: GenericConstructor<InstanceType<Cls>> & { [k in keyof Cls]: Cls[k] }
Type parameters
| Name | Type | 
|---|---|
Cls | extends GenericConstructor<any> | 
Defined in
packages/lexical/src/LexicalEditor.ts:56
LexicalCommand
Ƭ LexicalCommand<TPayload>: Object
Type parameters
| Name | 
|---|
TPayload | 
Type declaration
| Name | Type | 
|---|---|
type? | string | 
Defined in
packages/lexical/src/LexicalEditor.ts:275
LexicalNodeReplacement
Ƭ LexicalNodeReplacement: Object
Type declaration
| Name | Type | 
|---|---|
replace | Klass<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
| Name | Type | 
|---|---|
T | extends 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
| Name | Type | 
|---|---|
nodes | Map<NodeKey, NodeMutation> | 
payload | Object | 
payload.dirtyLeaves | Set<string> | 
payload.prevEditorState | EditorState | 
payload.updateTags | Set<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
| Name | Type | 
|---|---|
D | extends CaretDirection = CaretDirection | 
Defined in
packages/lexical/src/caret/LexicalCaret.ts:169
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
PointNodeCaret
Ƭ PointNodeCaret<D>: TextPointCaret<TextNode, D> | BreadthNodeCaret<LexicalNode, D> | DepthNodeCaret<ElementNode, D>
A PointNodeCaret is a NodeCaret that also includes a specialized TextPointCaret type which refers to a specific offset of a TextNode. This type is separate because it is not relevant to general node traversal so it doesn't make sense to have it show up except when defining a NodeCaretRange and in those cases there will be at most two of them only at the boundaries.
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection = CaretDirection | 
Defined in
packages/lexical/src/caret/LexicalCaret.ts:181
PointType
Ƭ PointType: TextPoint | ElementPoint
Defined in
packages/lexical/src/LexicalSelection.ts:105
RootMode
Ƭ RootMode: "root" | "shadowRoot"
The RootMode is specified in all caret traversals where the traversal can go up towards the root. 'root' means that it will stop at the document root, and 'shadowRoot' will stop at the document root or any shadow root (per $isRootOrShadowRoot).
Defined in
packages/lexical/src/caret/LexicalCaret.ts:37
SerializedEditor
Ƭ SerializedEditor: Object
Type declaration
| Name | Type | 
|---|---|
editorState | SerializedEditorState | 
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
| Name | Type | 
|---|---|
T | extends SerializedLexicalNode = SerializedLexicalNode | 
Defined in
packages/lexical/src/nodes/LexicalElementNode.ts:54
SerializedLexicalNode
Ƭ SerializedLexicalNode: Object
The base type for all serialized nodes
Type declaration
| Name | Type | Description | 
|---|---|---|
type | string | The type string used by the Node class | 
version | number | A 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
| Name | Type | 
|---|---|
T | extends 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:76
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:89
TextModeType
Ƭ TextModeType: "normal" | "token" | "segmented"
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:102
TextPoint
Ƭ TextPoint: Object
Type declaration
| Name | Type | 
|---|---|
_selection | BaseSelection | 
getNode | () => TextNode | 
is | (point: PointType) => boolean | 
isBefore | (point: PointType) => boolean | 
key | NodeKey | 
offset | number | 
set | (key: NodeKey, offset: number, type: "text" | "element", onlyIfChanged?: boolean) => void | 
type | "text" | 
Defined in
packages/lexical/src/LexicalSelection.ts:73
TextPointCaretSliceTuple
Ƭ TextPointCaretSliceTuple<D>: readonly TextPointCaretSlice<TextNode, D>[] & { length: 0 | 1 | 2  }
A utility type to specify that a NodeCaretRange may have zero, one, or two associated TextPointCaretSlice.
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Defined in
packages/lexical/src/caret/LexicalCaret.ts:275
Transform
Ƭ Transform<T>: (node: T) => void
Type parameters
| Name | Type | 
|---|---|
T | extends LexicalNode | 
Type declaration
▸ (node): void
Parameters
| Name | Type | 
|---|---|
node | T | 
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
| Name | Type | 
|---|---|
arg0 | Object | 
arg0.dirtyElements | Map<NodeKey, IntentionallyMarkedAsDirtyElement> | 
arg0.dirtyLeaves | Set<NodeKey> | 
arg0.editorState | EditorState | 
arg0.normalizedNodes | Set<NodeKey> | 
arg0.prevEditorState | EditorState | 
arg0.tags | Set<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
| Name | Type | 
|---|---|
tag | string | 
Returns
void
Defined in
packages/lexical/src/LexicalUtils.ts:1392
$applyNodeReplacement
▸ $applyNodeReplacement<N>(node): N
Type parameters
| Name | Type | 
|---|---|
N | extends LexicalNode | 
Parameters
| Name | Type | 
|---|---|
node | N | 
Returns
N
Defined in
packages/lexical/src/LexicalUtils.ts:1502
$caretFromPoint
▸ $caretFromPoint<D>(point, direction): PointNodeCaret<D>
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | 
|---|---|
point | PointType | 
direction | D | 
Returns
a PointNodeCaret for the point
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:59
$caretRangeFromSelection
▸ $caretRangeFromSelection(selection): NodeCaretRange
Get a pair of carets for a RangeSelection.
If the focus is before the anchor, then the direction will be 'previous', otherwise the direction will be 'next'.
Parameters
| Name | Type | 
|---|---|
selection | RangeSelection | 
Returns
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:158
$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
| Name | Type | 
|---|---|
T | extends LexicalNode | 
Parameters
| Name | Type | 
|---|---|
latestNode | T | 
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
| Name | Type | 
|---|---|
T | extends LexicalNode | 
Parameters
| Name | Type | Description | 
|---|---|---|
node | T | The node to be copied. | 
Returns
T
The copy of the node.
Defined in
packages/lexical/src/LexicalUtils.ts:1496
$createLineBreakNode
▸ $createLineBreakNode(): LineBreakNode
Returns
Defined in
packages/lexical/src/nodes/LexicalLineBreakNode.ts:78
$createNodeSelection
▸ $createNodeSelection(): NodeSelection
Returns
Defined in
packages/lexical/src/LexicalSelection.ts:2390
$createParagraphNode
▸ $createParagraphNode(): ParagraphNode
Returns
Defined in
packages/lexical/src/nodes/LexicalParagraphNode.ts:170
$createPoint
▸ $createPoint(key, offset, type): PointType
Parameters
| Name | Type | 
|---|---|
key | string | 
offset | number | 
type | "text" | "element" | 
Returns
Defined in
packages/lexical/src/LexicalSelection.ts:196
$createRangeSelection
▸ $createRangeSelection(): RangeSelection
Returns
Defined in
packages/lexical/src/LexicalSelection.ts:2384
$createRangeSelectionFromDom
▸ $createRangeSelectionFromDom(domSelection, editor): null | RangeSelection
Parameters
| Name | Type | 
|---|---|
domSelection | null | Selection | 
editor | LexicalEditor | 
Returns
null | RangeSelection
Defined in
packages/lexical/src/LexicalSelection.ts:2413
$createTabNode
▸ $createTabNode(): TabNode
Returns
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:87
$createTextNode
▸ $createTextNode(text?): TextNode
Parameters
| Name | Type | Default value | 
|---|---|---|
text | string | '' | 
Returns
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:1347
$getAdjacentDepthCaret
▸ $getAdjacentDepthCaret<D>(caret): 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
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
caret | null | NodeCaret<D> | The caret to start at | 
Returns
null | NodeCaret<D>
Defined in
packages/lexical/src/caret/LexicalCaret.ts:771
$getAdjacentNode
▸ $getAdjacentNode(focus, isBackward): null | LexicalNode
Parameters
| Name | Type | 
|---|---|
focus | PointType | 
isBackward | boolean | 
Returns
null | LexicalNode
Defined in
packages/lexical/src/LexicalUtils.ts:1246
$getAdjacentSiblingOrParentSiblingCaret
▸ $getAdjacentSiblingOrParentSiblingCaret<D>(startCaret, rootMode?): null | [NodeCaret<D>, number]
Returns the Node sibling when this exists, otherwise the closest parent sibling. For example R -> P -> T1, T2 -> P2 returns T2 for node T1, P2 for node T2, and null for node P2.
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | Default value | 
|---|---|---|
startCaret | NodeCaret<D> | undefined | 
rootMode | RootMode | 'root' | 
Returns
null | [NodeCaret<D>, number]
An array (tuple) containing the found Lexical node and the depth difference, or null, if this node doesn't exist.
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:528
$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
| Name | Type | 
|---|---|
T | extends LexicalNode | 
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
origin | T | The origin node | 
direction | D | '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/caret/LexicalCaret.ts:635
▸ $getBreadthCaret<T, D>(origin, direction): null | BreadthNodeCaret<T, D>
Type parameters
| Name | Type | 
|---|---|
T | extends LexicalNode | 
D | extends CaretDirection | 
Parameters
| Name | Type | 
|---|---|
origin | null | T | 
direction | D | 
Returns
null | BreadthNodeCaret<T, D>
Defined in
packages/lexical/src/caret/LexicalCaret.ts:639
$getCaretInDirection
▸ $getCaretInDirection<D>(caret, direction): PointNodeCaret<D>
Return the caret if it's in the given direction, otherwise return caret.getFlipped().
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
caret | PointNodeCaret<CaretDirection> | Any PointNodeCaret | 
direction | D | The desired direction | 
Returns
A PointNodeCaret in direction
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:420
$getCaretRange
▸ $getCaretRange<D>(anchor, focus): NodeCaretRange<D>
Construct a NodeCaretRange from anchor and focus carets pointing in the same direction. In order to get the expected behavior, the anchor must point towards the focus or be the same point.
In the 'next' direction the anchor should be at or before the focus in the document. In the 'previous' direction the anchor should be at or after the focus in the document (similar to a backwards RangeSelection).
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | 
|---|---|
anchor | PointNodeCaret<D> | 
focus | PointNodeCaret<D> | 
Returns
a NodeCaretRange
Defined in
packages/lexical/src/caret/LexicalCaret.ts:883
$getCaretRangeInDirection
▸ $getCaretRangeInDirection<D>(range, direction): NodeCaretRange<D>
Return the range if it's in the given direction, otherwise construct a new range using a flipped focus as the anchor and a flipped anchor as the focus. This transformation preserves the section of the document that it's working with, but reverses the order of iteration.
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
range | NodeCaretRange<CaretDirection> | Any NodeCaretRange | 
direction | D | The desired direction | 
Returns
A NodeCaretRange in direction
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:440
$getCharacterOffsets
▸ $getCharacterOffsets(selection): [number, number]
Parameters
| Name | Type | 
|---|---|
selection | BaseSelection | 
Returns
[number, number]
Defined in
packages/lexical/src/LexicalSelection.ts:1927
$getChildCaretAtIndex
▸ $getChildCaretAtIndex<D>(parent, index, direction): NodeCaret<D>
Get a 'next' caret for the child at the given index, or the last caret in that node if out of bounds
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
parent | ElementNode | An ElementNode | 
index | number | The index of the origin for the caret | 
direction | D | - | 
Returns
NodeCaret<D>
A next caret with the arrow at that index
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:503
$getChildCaretOrSelf
▸ $getChildCaretOrSelf<Caret>(caret): PointNodeCaret<NonNullable<Caret>["direction"]> | Caret & null
Gets the DepthNodeCaret if one is possible at this caret origin, otherwise return the caret
Type parameters
| Name | Type | 
|---|---|
Caret | extends null | PointNodeCaret<CaretDirection> | 
Parameters
| Name | Type | 
|---|---|
caret | Caret | 
Returns
PointNodeCaret<NonNullable<Caret>["direction"]> | Caret & null
Defined in
packages/lexical/src/caret/LexicalCaret.ts:758
$getDepthCaret
▸ $getDepthCaret<T, D>(origin, 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
| Name | Type | 
|---|---|
T | extends ElementNode | 
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
origin | T | The origin ElementNode | 
direction | D | '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/caret/LexicalCaret.ts:744
$getEditor
▸ $getEditor(): LexicalEditor
Utility function for accessing current active editor instance.
Returns
Current active editor
Defined in
packages/lexical/src/LexicalUtils.ts:1877
$getNearestNodeFromDOMNode
▸ $getNearestNodeFromDOMNode(startingDOM, editorState?): LexicalNode | null
Parameters
| Name | Type | 
|---|---|
startingDOM | Node | 
editorState? | EditorState | 
Returns
LexicalNode | null
Defined in
packages/lexical/src/LexicalUtils.ts:496
$getNearestRootOrShadowRoot
▸ $getNearestRootOrShadowRoot(node): RootNode | ElementNode
Parameters
| Name | Type | 
|---|---|
node | LexicalNode | 
Returns
Defined in
packages/lexical/src/LexicalUtils.ts:1464
$getNodeByKey
▸ $getNodeByKey<T>(key, _editorState?): T | null
Type parameters
| Name | Type | 
|---|---|
T | extends LexicalNode | 
Parameters
| Name | Type | 
|---|---|
key | string | 
_editorState? | EditorState | 
Returns
T | null
Defined in
packages/lexical/src/LexicalUtils.ts:455
$getNodeByKeyOrThrow
▸ $getNodeByKeyOrThrow<N>(key): N
Type parameters
| Name | Type | 
|---|---|
N | extends LexicalNode | 
Parameters
| Name | Type | 
|---|---|
key | string | 
Returns
N
Defined in
packages/lexical/src/LexicalUtils.ts:1568
$getPreviousSelection
▸ $getPreviousSelection(): null | BaseSelection
Returns
null | BaseSelection
Defined in
packages/lexical/src/LexicalSelection.ts:2550
$getRoot
▸ $getRoot(): RootNode
Returns
Defined in
packages/lexical/src/LexicalUtils.ts:564
$getSelection
▸ $getSelection(): null | BaseSelection
Returns
null | BaseSelection
Defined in
packages/lexical/src/LexicalSelection.ts:2545
$getTextContent
▸ $getTextContent(): string
Returns
string
Defined in
packages/lexical/src/LexicalSelection.ts:2929
$getTextPointCaret
▸ $getTextPointCaret<T, D>(origin, direction, offset): TextPointCaret<T, D>
Construct a TextPointCaret
Type parameters
| Name | Type | 
|---|---|
T | extends TextNode | 
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
origin | T | The TextNode | 
direction | D | The direction (next points to the end of the text, previous points to the beginning) | 
offset | number | CaretDirection | The offset into the text in absolute positive string coordinates (0 is the start) | 
Returns
TextPointCaret<T, D>
a TextPointCaret
Defined in
packages/lexical/src/caret/LexicalCaret.ts:678
$getTextPointCaretSlice
▸ $getTextPointCaretSlice<T, D>(caret, distance): TextPointCaretSlice<T, D>
Construct a TextPointCaretSlice given a TextPointCaret and a signed distance. The distance should be negative to slice text before the caret's offset, and positive to slice text after the offset. The direction of the caret itself is not relevant to the string coordinates when working with a TextPointCaretSlice but mutation operations will preserve the direction.
Type parameters
| Name | Type | 
|---|---|
T | extends TextNode | 
D | extends CaretDirection | 
Parameters
| Name | Type | 
|---|---|
caret | TextPointCaret<T, D> | 
distance | number | 
Returns
TextPointCaretSlice<T, D>
TextPointCaretSlice
Defined in
packages/lexical/src/caret/LexicalCaret.ts:729
$getTextSliceContent
▸ $getTextSliceContent(slice): string
Read the text from a TextNodeSlice
Parameters
| Name | Type | Description | 
|---|---|---|
slice | TextPointCaretSlice<TextNode, CaretDirection> | The slice to read | 
Returns
string
The text represented by the slice
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:487
$hasAncestor
▸ $hasAncestor(child, targetNode): boolean
Parameters
| Name | Type | 
|---|---|
child | LexicalNode | 
targetNode | LexicalNode | 
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:1430
$hasUpdateTag
▸ $hasUpdateTag(tag): boolean
Parameters
| Name | Type | 
|---|---|
tag | string | 
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:1387
$insertNodes
▸ $insertNodes(nodes): void
Parameters
| Name | Type | 
|---|---|
nodes | LexicalNode[] | 
Returns
void
Defined in
packages/lexical/src/LexicalSelection.ts:2920
$isBlockElementNode
▸ $isBlockElementNode(node): node is ElementNode
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | 
Returns
node is ElementNode
Defined in
packages/lexical/src/LexicalSelection.ts:2354
$isBreadthNodeCaret
▸ $isBreadthNodeCaret<D>(caret): caret is BreadthNodeCaret<LexicalNode, D>
Guard to check if the given argument is specifically a BreadthNodeCaret (or TextPointCaret)
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | 
|---|---|
caret | undefined | null | PointNodeCaret<D> | 
Returns
caret is BreadthNodeCaret<LexicalNode, D>
true if caret is a BreadthNodeCaret
Defined in
packages/lexical/src/caret/LexicalCaret.ts:574
$isDecoratorNode
▸ $isDecoratorNode<T>(node): node is DecoratorNode<T>
Type parameters
| Name | 
|---|
T | 
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | 
Returns
node is DecoratorNode<T>
Defined in
packages/lexical/src/nodes/LexicalDecoratorNode.ts:48
$isDepthNodeCaret
▸ $isDepthNodeCaret<D>(caret): caret is DepthNodeCaret<ElementNode, D>
Guard to check if the given argument is specifically a DepthNodeCaret
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | 
|---|---|
caret | undefined | null | PointNodeCaret<D> | 
Returns
caret is DepthNodeCaret<ElementNode, D>
true if caret is a DepthNodeCaret
Defined in
packages/lexical/src/caret/LexicalCaret.ts:586
$isElementNode
▸ $isElementNode(node): node is ElementNode
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | 
Returns
node is ElementNode
Defined in
packages/lexical/src/nodes/LexicalElementNode.ts:976
$isInlineElementOrDecoratorNode
▸ $isInlineElementOrDecoratorNode(node): boolean
Parameters
| Name | Type | 
|---|---|
node | LexicalNode | 
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:1457
$isLeafNode
▸ $isLeafNode(node): node is DecoratorNode<unknown> | TextNode | LineBreakNode
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | 
Returns
node is DecoratorNode<unknown> | TextNode | LineBreakNode
Defined in
packages/lexical/src/LexicalUtils.ts:256
$isLineBreakNode
▸ $isLineBreakNode(node): node is LineBreakNode
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | 
Returns
node is LineBreakNode
Defined in
packages/lexical/src/nodes/LexicalLineBreakNode.ts:82
$isNodeSelection
▸ $isNodeSelection(x): x is NodeSelection
Parameters
| Name | Type | 
|---|---|
x | unknown | 
Returns
x is NodeSelection
Defined in
packages/lexical/src/LexicalSelection.ts:1911
$isParagraphNode
▸ $isParagraphNode(node): node is ParagraphNode
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | 
Returns
node is ParagraphNode
Defined in
packages/lexical/src/nodes/LexicalParagraphNode.ts:174
$isRangeSelection
▸ $isRangeSelection(x): x is RangeSelection
Parameters
| Name | Type | 
|---|---|
x | unknown | 
Returns
x is RangeSelection
Defined in
packages/lexical/src/LexicalSelection.ts:419
$isRootNode
▸ $isRootNode(node): node is RootNode
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | RootNode | 
Returns
node is RootNode
Defined in
packages/lexical/src/nodes/LexicalRootNode.ts:113
$isRootOrShadowRoot
▸ $isRootOrShadowRoot(node): node is RootNode | ShadowRootNode
Parameters
| Name | Type | 
|---|---|
node | null | LexicalNode | 
Returns
node is RootNode | ShadowRootNode
Defined in
packages/lexical/src/LexicalUtils.ts:1484
$isSameTextPointCaret
▸ $isSameTextPointCaret<T>(a, b): b is T
Guard to check the equivalence of TextPointCaret
Type parameters
| Name | Type | 
|---|---|
T | extends TextPointCaret<TextNode, CaretDirection> | 
Parameters
| Name | Type | Description | 
|---|---|---|
a | T | The caret known to be a TextPointCaret | 
b | undefined | null | PointNodeCaret<CaretDirection> | Any caret | 
Returns
b is T
true if b is a TextPointCaret with the same origin, direction and offset as a
Defined in
packages/lexical/src/caret/LexicalCaret.ts:550
$isTabNode
▸ $isTabNode(node): node is TabNode
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | 
Returns
node is TabNode
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:91
$isTextNode
▸ $isTextNode(node): node is TextNode
Parameters
| Name | Type | 
|---|---|
node | undefined | null | LexicalNode | 
Returns
node is TextNode
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:1351
$isTextPointCaret
▸ $isTextPointCaret<D>(caret): caret is TextPointCaret<TextNode, D>
Guard to check if the given caret is specifically a TextPointCaret
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
caret | undefined | null | PointNodeCaret<D> | Any caret | 
Returns
caret is TextPointCaret<TextNode, D>
true if it is a TextPointCaret
Defined in
packages/lexical/src/caret/LexicalCaret.ts:533
$isTokenOrSegmented
▸ $isTokenOrSegmented(node): boolean
Parameters
| Name | Type | 
|---|---|
node | TextNode | 
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:195
$nodesOfType
▸ $nodesOfType<T>(klass): T[]
Type parameters
| Name | Type | 
|---|---|
T | extends LexicalNode | 
Parameters
| Name | Type | 
|---|---|
klass | Klass<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
| Name | Type | 
|---|---|
selection | RangeSelection | 
Returns
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
| Name | Type | Description | 
|---|---|---|
updateFn | () => void | The function to run after the current update. | 
Returns
void
Defined in
packages/lexical/src/LexicalUtils.ts:1405
$parseSerializedNode
▸ $parseSerializedNode(serializedNode): LexicalNode
Parameters
| Name | Type | 
|---|---|
serializedNode | SerializedLexicalNode | 
Returns
Defined in
packages/lexical/src/LexicalUpdates.ts:344
$removeTextFromCaretRange
▸ $removeTextFromCaretRange<D>(initialRange): NodeCaretRange<D>
Remove all text and nodes in the given range. If the range spans multiple blocks then the remaining contents of the later block will be merged with the earlier block.
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | 
|---|---|
initialRange | NodeCaretRange<D> | 
Returns
The new collapsed range (biased towards the earlier node)
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:223
$removeTextSlice
▸ $removeTextSlice<T, D>(slice): TextPointCaret<T, D>
Remove the slice of text from the contained caret, returning a new TextPointCaret without the wrapper (since the size would be zero).
Note that this is a lower-level utility that does not have any specific behavior for 'segmented' or 'token' modes and it will not remove an empty TextNode.
Type parameters
| Name | Type | 
|---|---|
T | extends TextNode | 
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
slice | TextPointCaretSlice<T, D> | The slice to mutate | 
Returns
TextPointCaret<T, D>
The inner TextPointCaret with the same offset and direction and the latest TextNode origin after mutation
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:466
$rewindBreadthCaret
▸ $rewindBreadthCaret<T, D>(caret): NodeCaret<D>
Given a BreadthNodeCaret we can always compute a caret that points to the origin of that caret in the same direction. The adjacent caret of the returned caret will be equivalent to the given caret.
Type parameters
| Name | Type | 
|---|---|
T | extends LexicalNode | 
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
caret | BreadthNodeCaret<T, D> | The caret to "rewind" | 
Returns
NodeCaret<D>
A new caret (DepthNodeCaret or BreadthNodeCaret) with the same direction
Example
breadthCaret.is($rewindBreadthCaret(breadthCaret).getAdjacentCaret())
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:182
$selectAll
▸ $selectAll(selection?): RangeSelection
Parameters
| Name | Type | 
|---|---|
selection? | null | RangeSelection | 
Returns
Defined in
packages/lexical/src/LexicalUtils.ts:1121
$setCompositionKey
▸ $setCompositionKey(compositionKey): void
Parameters
| Name | Type | 
|---|---|
compositionKey | null | string | 
Returns
void
Defined in
packages/lexical/src/LexicalUtils.ts:426
$setPointFromCaret
▸ $setPointFromCaret<D>(point, caret): void
Update the given point in-place from the PointNodeCaret
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
point | PointType | the point to set | 
caret | PointNodeCaret<D> | the caret to set the point from | 
Returns
void
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:89
$setSelection
▸ $setSelection(selection): void
Parameters
| Name | Type | 
|---|---|
selection | null | BaseSelection | 
Returns
void
Defined in
packages/lexical/src/LexicalUtils.ts:572
$setSelectionFromCaretRange
▸ $setSelectionFromCaretRange(caretRange): RangeSelection
Set a RangeSelection on the editor from the given NodeCaretRange
Parameters
| Name | Type | 
|---|---|
caretRange | NodeCaretRange<CaretDirection> | 
Returns
The new RangeSelection
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:129
$splitNode
▸ $splitNode(node, offset): [ElementNode | null, ElementNode]
Parameters
| Name | Type | 
|---|---|
node | ElementNode | 
offset | number | 
Returns
[ElementNode | null, ElementNode]
Defined in
packages/lexical/src/LexicalUtils.ts:1701
$updateRangeSelectionFromCaretRange
▸ $updateRangeSelectionFromCaretRange(selection, caretRange): void
Update the points of a RangeSelection based on the given PointNodeCaret.
Parameters
| Name | Type | 
|---|---|
selection | RangeSelection | 
caretRange | NodeCaretRange<CaretDirection> | 
Returns
void
Defined in
packages/lexical/src/caret/LexicalCaretUtils.ts:144
createCommand
▸ createCommand<T>(type?): LexicalCommand<T>
Type parameters
| Name | 
|---|
T | 
Parameters
| Name | Type | 
|---|---|
type? | string | 
Returns
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
| Name | Type | Description | 
|---|---|---|
editorConfig? | CreateEditorArgs | the editor configuration. | 
Returns
a LexicalEditor instance
Defined in
packages/lexical/src/LexicalEditor.ts:427
flipDirection
▸ flipDirection<D>(direction): FlipDirection<D>
Flip a direction ('next' -> 'previous'; 'previous' -> 'next').
Note that TypeScript can't prove that FlipDirection is its own inverse (but if you have a concrete 'next' or 'previous' it will simplify accordingly).
Type parameters
| Name | Type | 
|---|---|
D | extends CaretDirection | 
Parameters
| Name | Type | Description | 
|---|---|---|
direction | D | A direction | 
Returns
The opposite direction
Defined in
packages/lexical/src/caret/LexicalCaret.ts:475
getDOMOwnerDocument
▸ getDOMOwnerDocument(target): Document | null
Parameters
| Name | Type | 
|---|---|
target | null | 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
| Name | Type | Description | 
|---|---|---|
targetWindow | null | Window | The 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
| Name | Type | Description | 
|---|---|---|
eventTarget | null | EventTarget | The 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
| Name | Type | 
|---|---|
element | null | Node | 
Returns
Text | null
Defined in
packages/lexical/src/LexicalUtils.ts:215
getNearestEditorFromDOMNode
▸ getNearestEditorFromDOMNode(node): LexicalEditor | null
Parameters
| Name | Type | 
|---|---|
node | null | Node | 
Returns
LexicalEditor | null
Defined in
packages/lexical/src/LexicalUtils.ts:165
isBlockDomNode
▸ isBlockDomNode(node): boolean
Parameters
| Name | Type | Description | 
|---|---|---|
node | Node | the 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
| Name | Type | Description | 
|---|---|---|
node | unknown | The 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
| Name | Type | Description | 
|---|---|---|
x | unknown | The 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
| Name | Type | Description | 
|---|---|---|
node | unknown | The 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
| Name | Type | Description | 
|---|---|---|
x | unknown | The 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
| Name | Type | Description | 
|---|---|---|
x | unknown | The 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
| Name | Type | Description | 
|---|---|---|
x | unknown | The 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
| Name | Type | Description | 
|---|---|---|
node | Node | the 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
| Name | Type | 
|---|---|
editor | unknown | 
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
| Name | Type | 
|---|---|
anchorDOM | Node | 
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:119
isSelectionWithinEditor
▸ isSelectionWithinEditor(editor, anchorDOM, focusDOM): boolean
Parameters
| Name | Type | 
|---|---|
editor | LexicalEditor | 
anchorDOM | null | Node | 
focusDOM | null | Node | 
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:136
makeStepwiseIterator
▸ makeStepwiseIterator<State, Stop, Value>(config): IterableIterator<Value>
A generalized utility for creating a stepwise iterator based on:
- an initial state
 - a stop guard that returns true if the iteration is over, this is typically used to detect a sentinel value such as null or undefined from the state but may return true for other conditions as well
 - a step function that advances the state (this will be called after map each time next() is called to prepare the next state)
 - a map function that will be called that may transform the state before returning it. It will only be called once for each next() call when stop(state) === false
 
Type parameters
| Name | 
|---|
State | 
Stop | 
Value | 
Parameters
| Name | Type | 
|---|---|
config | StepwiseIteratorConfig<State, Stop, Value> | 
Returns
IterableIterator<Value>
An IterableIterator
Defined in
packages/lexical/src/caret/LexicalCaret.ts:912
resetRandomKey
▸ resetRandomKey(): void
Returns
void
Defined in
packages/lexical/src/LexicalUtils.ts:86
setNodeIndentFromDOM
▸ setNodeIndentFromDOM(elementDom, elementNode): void
Parameters
| Name | Type | 
|---|---|
elementDom | HTMLElement | 
elementNode | ElementNode | 
Returns
void