Skip to main content

Class: LexicalEditor

lexical.LexicalEditor

Constructors

constructor

new LexicalEditor(editorState, parentEditor, nodes, config, onError, htmlConversions, editable)

Parameters

NameType
editorStateEditorState
parentEditornull | LexicalEditor
nodesRegisteredNodes
configEditorConfig
onErrorErrorHandler
htmlConversionsDOMConversionCache
editableboolean

Defined in

lexical/src/LexicalEditor.ts:476

Properties

_cloneNotNeeded

_cloneNotNeeded: Set<string>

Defined in

lexical/src/LexicalEditor.ts:464


_commands

_commands: Commands

Defined in

lexical/src/LexicalEditor.ts:458


_compositionKey

_compositionKey: null | string

Defined in

lexical/src/LexicalEditor.ts:452


_config

_config: EditorConfig

Defined in

lexical/src/LexicalEditor.ts:462


_decorators

_decorators: Record<string, unknown>

Defined in

lexical/src/LexicalEditor.ts:460


_deferred

_deferred: () => void[]

Defined in

lexical/src/LexicalEditor.ts:453


_dirtyElements

_dirtyElements: Map<string, boolean>

Defined in

lexical/src/LexicalEditor.ts:466


_dirtyLeaves

_dirtyLeaves: Set<string>

Defined in

lexical/src/LexicalEditor.ts:465


_dirtyType

_dirtyType: 0 | 1 | 2

Defined in

lexical/src/LexicalEditor.ts:463


_editable

_editable: boolean

Defined in

lexical/src/LexicalEditor.ts:474


_editorState

_editorState: EditorState

Defined in

lexical/src/LexicalEditor.ts:450


_headless

_headless: boolean

Defined in

lexical/src/LexicalEditor.ts:447


_htmlConversions

_htmlConversions: DOMConversionCache

Defined in

lexical/src/LexicalEditor.ts:472


_key

_key: string

Defined in

lexical/src/LexicalEditor.ts:470


_keyToDOMMap

_keyToDOMMap: Map<string, HTMLElement>

Defined in

lexical/src/LexicalEditor.ts:454


_listeners

_listeners: Listeners

Defined in

lexical/src/LexicalEditor.ts:457


_nodes

_nodes: RegisteredNodes

Defined in

lexical/src/LexicalEditor.ts:459


_normalizedNodes

_normalizedNodes: Set<string>

Defined in

lexical/src/LexicalEditor.ts:467


_observer

_observer: null | MutationObserver

Defined in

lexical/src/LexicalEditor.ts:469


_onError

_onError: ErrorHandler

Defined in

lexical/src/LexicalEditor.ts:471


_parentEditor

_parentEditor: null | LexicalEditor

Defined in

lexical/src/LexicalEditor.ts:448


_pendingDecorators

_pendingDecorators: null | Record<string, unknown>

Defined in

lexical/src/LexicalEditor.ts:461


_pendingEditorState

_pendingEditorState: null | EditorState

Defined in

lexical/src/LexicalEditor.ts:451


_rootElement

_rootElement: null | HTMLElement

Defined in

lexical/src/LexicalEditor.ts:449


_updateTags

_updateTags: Set<string>

Defined in

lexical/src/LexicalEditor.ts:468


_updates

_updates: [() => void, undefined | EditorUpdateOptions][]

Defined in

lexical/src/LexicalEditor.ts:455


_updating

_updating: boolean

Defined in

lexical/src/LexicalEditor.ts:456


_window

_window: null | Window

Defined in

lexical/src/LexicalEditor.ts:473

Methods

blur

blur(): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:852


dispatchCommand

dispatchCommand<TCommand>(type, payload): boolean

Type parameters

NameType
TCommandextends LexicalCommand<unknown>

Parameters

NameType
typeTCommand
payloadCommandPayloadType<TCommand>

Returns

boolean

Defined in

lexical/src/LexicalEditor.ts:688


focus

focus(callbackFn?, options?): void

Parameters

NameType
callbackFn?() => void
optionsEditorFocusOptions

Returns

void

Defined in

lexical/src/LexicalEditor.ts:812


getDecorators

getDecorators<T>(): Record<string, T>

Type parameters

Name
T

Returns

Record<string, T>

Defined in

lexical/src/LexicalEditor.ts:695


getEditorState

getEditorState(): EditorState

Returns

EditorState

Defined in

lexical/src/LexicalEditor.ts:760


getElementByKey

getElementByKey(key): null | HTMLElement

Parameters

NameType
keystring

Returns

null | HTMLElement

Defined in

lexical/src/LexicalEditor.ts:756


getKey

getKey(): string

Returns

string

Defined in

lexical/src/LexicalEditor.ts:703


getRootElement

getRootElement(): null | HTMLElement

Returns

null | HTMLElement

Defined in

lexical/src/LexicalEditor.ts:699


hasNodes

hasNodes<T>(nodes): boolean

Type parameters

NameType
Textends Klass<LexicalNode>

Parameters

NameType
nodesT[]

Returns

boolean

Defined in

lexical/src/LexicalEditor.ts:675


isComposing

isComposing(): boolean

Returns

boolean

Defined in

lexical/src/LexicalEditor.ts:538


isEditable

isEditable(): boolean

Returns

boolean

Defined in

lexical/src/LexicalEditor.ts:866


parseEditorState

parseEditorState(maybeStringifiedEditorState, updateFn?): EditorState

Parameters

NameType
maybeStringifiedEditorStatestring | SerializedEditorState
updateFn?() => void

Returns

EditorState

Defined in

lexical/src/LexicalEditor.ts:797


registerCommand

registerCommand<P>(command, listener, priority): () => void

Type parameters

Name
P

Parameters

NameType
commandLexicalCommand<P>
listenerCommandListener<P>
priorityCommandListenerPriority

Returns

fn

▸ (): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:584


registerDecoratorListener

registerDecoratorListener<T>(listener): () => void

Type parameters

Name
T

Parameters

NameType
listenerDecoratorListener<T>

Returns

fn

▸ (): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:558


registerEditableListener

registerEditableListener(listener): () => void

Parameters

NameType
listenerEditableListener

Returns

fn

▸ (): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:550


registerMutationListener

registerMutationListener(klass, listener): () => void

Parameters

NameType
klassKlass<LexicalNode>
listenerMutationListener

Returns

fn

▸ (): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:630


registerNodeTransform

registerNodeTransform<T>(klass, listener): () => void

Type parameters

NameType
Textends LexicalNode<T>

Parameters

NameType
klassKlass<T>
listenerTransform<T>

Returns

fn

▸ (): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:651


registerRootListener

registerRootListener(listener): () => void

Parameters

NameType
listenerRootListener

Returns

fn

▸ (): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:574


registerTextContentListener

registerTextContentListener(listener): () => void

Parameters

NameType
listenerTextContentListener

Returns

fn

▸ (): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:566


registerUpdateListener

registerUpdateListener(listener): () => void

Parameters

NameType
listenerUpdateListener

Returns

fn

▸ (): void

Returns

void

Defined in

lexical/src/LexicalEditor.ts:542


setEditable

setEditable(editable): void

Parameters

NameType
editableboolean

Returns

void

Defined in

lexical/src/LexicalEditor.ts:870


setEditorState

setEditorState(editorState, options?): void

Parameters

NameType
editorStateEditorState
options?EditorSetOptions

Returns

void

Defined in

lexical/src/LexicalEditor.ts:764


setRootElement

setRootElement(nextRootElement): void

Parameters

NameType
nextRootElementnull | HTMLElement

Returns

void

Defined in

lexical/src/LexicalEditor.ts:707


toJSON

toJSON(): SerializedEditor

Returns

SerializedEditor

Defined in

lexical/src/LexicalEditor.ts:877


update

update(updateFn, options?): void

Parameters

NameType
updateFn() => void
options?EditorUpdateOptions

Returns

void

Defined in

lexical/src/LexicalEditor.ts:808