Module: lexical
Classes
- ArtificialNode__DO_NOT_USE
- DecoratorNode
- EditorState
- ElementNode
- LexicalEditor
- LexicalNode
- LineBreakNode
- NodeSelection
- ParagraphNode
- Point
- RangeSelection
- RootNode
- TabNode
- TextNode
Interfaces
Type Aliases
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:254
CommandListenerPriority
Ƭ CommandListenerPriority: 0
| 1
| 2
| 3
| 4
Defined in
packages/lexical/src/LexicalEditor.ts:258
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:291
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:178
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:134
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:125
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:130
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:139
DOMConversionOutput
Ƭ DOMConversionOutput: Object
Type declaration
Name | Type |
---|---|
after? | (childLexicalNodes : LexicalNode []) => LexicalNode [] |
forChild? | DOMChildConversion |
node | null | LexicalNode | LexicalNode [] |
Defined in
packages/lexical/src/LexicalNode.ts:145
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:156
EditableListener
Ƭ EditableListener: (editable
: boolean
) => void
Type declaration
▸ (editable
): void
Parameters
Name | Type |
---|---|
editable | boolean |
Returns
void
Defined in
packages/lexical/src/LexicalEditor.ts:256
EditorConfig
Ƭ EditorConfig: Object
Type declaration
Name | Type |
---|---|
disableEvents? | boolean |
namespace | string |
theme | EditorThemeClasses |
Defined in
packages/lexical/src/LexicalEditor.ts:158
EditorSetOptions
Ƭ EditorSetOptions: Object
Type declaration
Name | Type |
---|---|
tag? | string |
Defined in
packages/lexical/src/LexicalEditor.ts:87
EditorThemeClassName
Ƭ EditorThemeClassName: string
Defined in
packages/lexical/src/LexicalEditor.ts:64
EditorThemeClasses
Ƭ EditorThemeClasses: Object
Index signature
▪ [key: string
]: any
Type declaration
Defined in
packages/lexical/src/LexicalEditor.ts:95
EditorUpdateOptions
Ƭ EditorUpdateOptions: Object
Type declaration
Name | Type |
---|---|
discrete? | true |
onUpdate? | () => void |
skipTransforms? | true |
tag? | string | string [] |
Defined in
packages/lexical/src/LexicalEditor.ts:80
ElementFormatType
Ƭ ElementFormatType: "left"
| "start"
| "center"
| "right"
| "end"
| "justify"
| ""
Defined in
packages/lexical/src/nodes/LexicalElementNode.ts:51
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" ) => void |
type | "element" |
Defined in
packages/lexical/src/LexicalSelection.ts:79
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:1207
HTMLConfig
Ƭ HTMLConfig: Object
Type declaration
Name | Type |
---|---|
export? | DOMExportOutputMap |
import? | DOMConversionMap |
Defined in
packages/lexical/src/LexicalEditor.ts:173
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:58
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:53
LexicalCommand
Ƭ LexicalCommand<TPayload
>: Object
Type parameters
Name |
---|
TPayload |
Type declaration
Name | Type |
---|---|
type? | string |
Defined in
packages/lexical/src/LexicalEditor.ts:267
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:164
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:245
NodeKey
Ƭ NodeKey: string
Defined in
packages/lexical/src/LexicalNode.ts:163
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:211
PasteCommandType
Ƭ PasteCommandType: ClipboardEvent
| InputEvent
| KeyboardEvent
Defined in
packages/lexical/src/LexicalCommands.ts:17
PointType
Ƭ PointType: TextPoint
| ElementPoint
Defined in
packages/lexical/src/LexicalSelection.ts:90
SerializedEditor
Ƭ SerializedEditor: Object
Type declaration
Name | Type |
---|---|
editorState | SerializedEditorState |
Defined in
packages/lexical/src/LexicalEditor.ts:332
SerializedElementNode
Ƭ SerializedElementNode<T
>: Spread
<{ children
: T
[] ; direction
: "ltr"
| "rtl"
| null
; format
: ElementFormatType
; indent
: number
}, SerializedLexicalNode
>
Type parameters
Name | Type |
---|---|
T | extends SerializedLexicalNode = SerializedLexicalNode |
Defined in
packages/lexical/src/nodes/LexicalElementNode.ts:39
SerializedLexicalNode
Ƭ SerializedLexicalNode: Object
Type declaration
Name | Type |
---|---|
type | string |
version | number |
Defined in
packages/lexical/src/LexicalNode.ts:54
SerializedLineBreakNode
Ƭ SerializedLineBreakNode: SerializedLexicalNode
Defined in
packages/lexical/src/nodes/LexicalLineBreakNode.ts:21
SerializedParagraphNode
Ƭ SerializedParagraphNode: Spread
<{ textFormat
: number
; textStyle
: string
}, SerializedElementNode
>
Defined in
packages/lexical/src/nodes/LexicalParagraphNode.ts:38
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:23
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:49
TextFormatType
Ƭ TextFormatType: "bold"
| "underline"
| "strikethrough"
| "italic"
| "highlight"
| "code"
| "subscript"
| "superscript"
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:85
TextModeType
Ƭ TextModeType: "normal"
| "token"
| "segmented"
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:95
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" ) => void |
type | "text" |
Defined in
packages/lexical/src/LexicalSelection.ts:68
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:203
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:264
COMMAND_PRIORITY_EDITOR
• Const
COMMAND_PRIORITY_EDITOR: 0
Defined in
packages/lexical/src/LexicalEditor.ts:260
COMMAND_PRIORITY_HIGH
• Const
COMMAND_PRIORITY_HIGH: 3
Defined in
packages/lexical/src/LexicalEditor.ts:263
COMMAND_PRIORITY_LOW
• Const
COMMAND_PRIORITY_LOW: 1
Defined in
packages/lexical/src/LexicalEditor.ts:261
COMMAND_PRIORITY_NORMAL
• Const
COMMAND_PRIORITY_NORMAL: 2
Defined in
packages/lexical/src/LexicalEditor.ts:262
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:48
IS_BOLD
• Const
IS_BOLD: 1
Defined in
packages/lexical/src/LexicalConstants.ts:39
IS_CODE
• Const
IS_CODE: number
Defined in
packages/lexical/src/LexicalConstants.ts:43
IS_HIGHLIGHT
• Const
IS_HIGHLIGHT: number
Defined in
packages/lexical/src/LexicalConstants.ts:46
IS_ITALIC
• Const
IS_ITALIC: number
Defined in
packages/lexical/src/LexicalConstants.ts:40
IS_STRIKETHROUGH
• Const
IS_STRIKETHROUGH: number
Defined in
packages/lexical/src/LexicalConstants.ts:41
IS_SUBSCRIPT
• Const
IS_SUBSCRIPT: number
Defined in
packages/lexical/src/LexicalConstants.ts:44
IS_SUPERSCRIPT
• Const
IS_SUPERSCRIPT: number
Defined in
packages/lexical/src/LexicalConstants.ts:45
IS_UNDERLINE
• Const
IS_UNDERLINE: number
Defined in
packages/lexical/src/LexicalConstants.ts:42
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:98
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:1311
$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:1408
$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:1801
$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:1402
$createLineBreakNode
▸ $createLineBreakNode(): LineBreakNode
Returns
Defined in
packages/lexical/src/nodes/LexicalLineBreakNode.ts:82
$createNodeSelection
▸ $createNodeSelection(): NodeSelection
Returns
Defined in
packages/lexical/src/LexicalSelection.ts:2344
$createParagraphNode
▸ $createParagraphNode(): ParagraphNode
Returns
Defined in
packages/lexical/src/nodes/LexicalParagraphNode.ts:240
$createPoint
▸ $createPoint(key
, offset
, type
): PointType
Parameters
Name | Type |
---|---|
key | string |
offset | number |
type | "text" | "element" |
Returns
Defined in
packages/lexical/src/LexicalSelection.ts:160
$createRangeSelection
▸ $createRangeSelection(): RangeSelection
Returns
Defined in
packages/lexical/src/LexicalSelection.ts:2338
$createRangeSelectionFromDom
▸ $createRangeSelectionFromDom(domSelection
, editor
): null
| RangeSelection
Parameters
Name | Type |
---|---|
domSelection | null | Selection |
editor | LexicalEditor |
Returns
null
| RangeSelection
Defined in
packages/lexical/src/LexicalSelection.ts:2366
$createTabNode
▸ $createTabNode(): TabNode
Returns
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:86
$createTextNode
▸ $createTextNode(text?
): TextNode
Parameters
Name | Type | Default value |
---|---|---|
text | string | '' |
Returns
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:1305
$getAdjacentNode
▸ $getAdjacentNode(focus
, isBackward
): null
| LexicalNode
Parameters
Name | Type |
---|---|
focus | PointType |
isBackward | boolean |
Returns
null
| LexicalNode
Defined in
packages/lexical/src/LexicalUtils.ts:1175
$getCharacterOffsets
▸ $getCharacterOffsets(selection
): [number
, number
]
Parameters
Name | Type |
---|---|
selection | BaseSelection |
Returns
[number
, number
]
Defined in
packages/lexical/src/LexicalSelection.ts:1899
$getEditor
▸ $getEditor(): LexicalEditor
Utility function for accessing current active editor instance.
Returns
Current active editor
Defined in
packages/lexical/src/LexicalUtils.ts:1747
$getNearestNodeFromDOMNode
▸ $getNearestNodeFromDOMNode(startingDOM
, editorState?
): LexicalNode
| null
Parameters
Name | Type |
---|---|
startingDOM | Node |
editorState? | EditorState |
Returns
LexicalNode
| null
Defined in
packages/lexical/src/LexicalUtils.ts:452
$getNearestRootOrShadowRoot
▸ $getNearestRootOrShadowRoot(node
): RootNode
| ElementNode
Parameters
Name | Type |
---|---|
node | LexicalNode |
Returns
Defined in
packages/lexical/src/LexicalUtils.ts:1370
$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:427
$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:1474
$getPreviousSelection
▸ $getPreviousSelection(): null
| BaseSelection
Returns
null
| BaseSelection
Defined in
packages/lexical/src/LexicalSelection.ts:2458
$getRoot
▸ $getRoot(): RootNode
Returns
Defined in
packages/lexical/src/LexicalUtils.ts:506
$getSelection
▸ $getSelection(): null
| BaseSelection
Returns
null
| BaseSelection
Defined in
packages/lexical/src/LexicalSelection.ts:2453
$getTextContent
▸ $getTextContent(): string
Returns
string
Defined in
packages/lexical/src/LexicalSelection.ts:2840
$hasAncestor
▸ $hasAncestor(child
, targetNode
): boolean
Parameters
Name | Type |
---|---|
child | LexicalNode |
targetNode | LexicalNode |
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:1336
$hasUpdateTag
▸ $hasUpdateTag(tag
): boolean
Parameters
Name | Type |
---|---|
tag | string |
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:1306
$insertNodes
▸ $insertNodes(nodes
): void
Parameters
Name | Type |
---|---|
nodes | LexicalNode [] |
Returns
void
Defined in
packages/lexical/src/LexicalSelection.ts:2831
$isBlockElementNode
▸ $isBlockElementNode(node
): node is ElementNode
Parameters
Name | Type |
---|---|
node | undefined | null | LexicalNode |
Returns
node is ElementNode
Defined in
packages/lexical/src/LexicalSelection.ts:2308
$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:52
$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:615
$isInlineElementOrDecoratorNode
▸ $isInlineElementOrDecoratorNode(node
): boolean
Parameters
Name | Type |
---|---|
node | LexicalNode |
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:1363
$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:228
$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:86
$isNodeSelection
▸ $isNodeSelection(x
): x is NodeSelection
Parameters
Name | Type |
---|---|
x | unknown |
Returns
x is NodeSelection
Defined in
packages/lexical/src/LexicalSelection.ts:1883
$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:244
$isRangeSelection
▸ $isRangeSelection(x
): x is RangeSelection
Parameters
Name | Type |
---|---|
x | unknown |
Returns
x is RangeSelection
Defined in
packages/lexical/src/LexicalSelection.ts:394
$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:128
$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:1390
$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:90
$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:1309
$isTokenOrSegmented
▸ $isTokenOrSegmented(node
): boolean
Parameters
Name | Type |
---|---|
node | TextNode |
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:188
$nodesOfType
▸ $nodesOfType<T
>(klass
): T
[]
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Parameters
Name | Type |
---|---|
klass | Klass <T > |
Returns
T
[]
Defined in
packages/lexical/src/LexicalUtils.ts:1132
$normalizeSelection__EXPERIMENTAL
▸ $normalizeSelection__EXPERIMENTAL(selection
): RangeSelection
Parameters
Name | Type |
---|---|
selection | RangeSelection |
Returns
Defined in
packages/lexical/src/LexicalNormalization.ts:89
$parseSerializedNode
▸ $parseSerializedNode(serializedNode
): LexicalNode
Parameters
Name | Type |
---|---|
serializedNode | SerializedLexicalNode |
Returns
Defined in
packages/lexical/src/LexicalUpdates.ts:343
$selectAll
▸ $selectAll(): void
Returns
void
Defined in
packages/lexical/src/LexicalUtils.ts:1067
$setCompositionKey
▸ $setCompositionKey(compositionKey
): void
Parameters
Name | Type |
---|---|
compositionKey | null | string |
Returns
void
Defined in
packages/lexical/src/LexicalUtils.ts:398
$setSelection
▸ $setSelection(selection
): void
Parameters
Name | Type |
---|---|
selection | null | BaseSelection |
Returns
void
Defined in
packages/lexical/src/LexicalUtils.ts:514
$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:1589
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:419
getNearestEditorFromDOMNode
▸ getNearestEditorFromDOMNode(node
): LexicalEditor
| null
Parameters
Name | Type |
---|---|
node | null | Node |
Returns
LexicalEditor
| null
Defined in
packages/lexical/src/LexicalUtils.ts:158
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:1700
isCurrentlyReadOnlyMode
▸ isCurrentlyReadOnlyMode(): boolean
Returns
boolean
Defined in
packages/lexical/src/LexicalUpdates.ts:72
isDocumentFragment
▸ isDocumentFragment(x
): x is DocumentFragment
Parameters
Name | Type | Description |
---|---|---|
x | EventTarget | Node | 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:1675
isHTMLAnchorElement
▸ isHTMLAnchorElement(x
): x is HTMLAnchorElement
Parameters
Name | Type | Description |
---|---|---|
x | Node | 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:1658
isHTMLElement
▸ isHTMLElement(x
): x is HTMLElement
Parameters
Name | Type | Description |
---|---|---|
x | EventTarget | Node | The element being testing |
Returns
x is HTMLElement
Returns true if x is an HTML element, false otherwise.
Defined in
packages/lexical/src/LexicalUtils.ts:1666
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:1687
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:153
isSelectionCapturedInDecoratorInput
▸ isSelectionCapturedInDecoratorInput(anchorDOM
): boolean
Parameters
Name | Type |
---|---|
anchorDOM | Node |
Returns
boolean
Defined in
packages/lexical/src/LexicalUtils.ts:112
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:129
resetRandomKey
▸ resetRandomKey(): void
Returns
void