Class: LexicalEditor
lexical.LexicalEditor
Properties
constructor
• constructor: KlassConstructor
<typeof LexicalEditor
>
Defined in
packages/lexical/src/LexicalEditor.ts:550
Methods
blur
▸ blur(): void
Removes focus from the editor.
Returns
void
Defined in
packages/lexical/src/LexicalEditor.ts:1197
dispatchCommand
▸ dispatchCommand<TCommand
>(type
, payload
): boolean
Dispatches a command of the specified type with the specified payload. This triggers all command listeners (set by LexicalEditor.registerCommand) for this type, passing them the provided payload.
Type parameters
Name | Type |
---|---|
TCommand | extends LexicalCommand <unknown > |
Parameters
Name | Type | Description |
---|---|---|
type | TCommand | the type of command listeners to trigger. |
payload | CommandPayloadType <TCommand > | the data to pass as an argument to the command listeners. |
Returns
boolean
Defined in
packages/lexical/src/LexicalEditor.ts:951
focus
▸ focus(callbackFn?
, options?
): void
Focuses the editor
Parameters
Name | Type | Description |
---|---|---|
callbackFn? | () => void | A function to run after the editor is focused. |
options | EditorFocusOptions | A bag of options |
Returns
void
Defined in
packages/lexical/src/LexicalEditor.ts:1153
getDecorators
▸ getDecorators<T
>(): Record
<string
, T
>
Gets a map of all decorators in the editor.
Type parameters
Name |
---|
T |
Returns
Record
<string
, T
>
A mapping of call decorator keys to their decorated content
Defined in
packages/lexical/src/LexicalEditor.ts:962
getEditorState
▸ getEditorState(): EditorState
Gets the active editor state.
Returns
The editor state
Defined in
packages/lexical/src/LexicalEditor.ts:1054
getElementByKey
▸ getElementByKey(key
): null
| HTMLElement
Gets the underlying HTMLElement associated with the LexicalNode for the given key.
Parameters
Name | Type | Description |
---|---|---|
key | string | the key of the LexicalNode. |
Returns
null
| HTMLElement
the HTMLElement rendered by the LexicalNode associated with the key.
Defined in
packages/lexical/src/LexicalEditor.ts:1046
getKey
▸ getKey(): string
Gets the key of the editor
Returns
string
The editor key
Defined in
packages/lexical/src/LexicalEditor.ts:980
getRootElement
▸ getRootElement(): null
| HTMLElement
Returns
null
| HTMLElement
the current root element of the editor. If you want to register an event listener, do it via LexicalEditor.registerRootListener, since this reference may not be stable.
Defined in
packages/lexical/src/LexicalEditor.ts:972
hasNode
▸ hasNode<T
>(node
): boolean
Used to assert that a certain node is registered, usually by plugins to ensure nodes that they depend on have been registered.
Type parameters
Name | Type |
---|---|
T | extends KlassConstructor <typeof LexicalNode > |
Parameters
Name | Type |
---|---|
node | T |
Returns
boolean
True if the editor has registered the provided node type, false otherwise.
Defined in
packages/lexical/src/LexicalEditor.ts:931
hasNodes
▸ hasNodes<T
>(nodes
): boolean
Used to assert that certain nodes are registered, usually by plugins to ensure nodes that they depend on have been registered.
Type parameters
Name | Type |
---|---|
T | extends KlassConstructor <typeof LexicalNode > |
Parameters
Name | Type |
---|---|
nodes | T [] |
Returns
boolean
True if the editor has registered all of the provided node types, false otherwise.
Defined in
packages/lexical/src/LexicalEditor.ts:940
isComposing
▸ isComposing(): boolean
Returns
boolean
true if the editor is currently in "composition" mode due to receiving input through an IME, or 3P extension, for example. Returns false otherwise.
Defined in
packages/lexical/src/LexicalEditor.ts:678