Skip to main content

Module: @lexical/history

Type Aliases

HistoryState

Ƭ HistoryState: Object

Type declaration

NameType
currentnull | HistoryStateEntry
redoStackHistoryStateEntry[]
undoStackHistoryStateEntry[]

Defined in

packages/lexical-history/src/index.ts:42


HistoryStateEntry

Ƭ HistoryStateEntry: Object

Type declaration

NameType
editorLexicalEditor
editorStateEditorState

Defined in

packages/lexical-history/src/index.ts:38

Functions

createEmptyHistoryState

createEmptyHistoryState(): HistoryState

Creates an empty history state.

Returns

HistoryState

  • The empty history state, as an object.

Defined in

packages/lexical-history/src/index.ts:500


registerHistory

registerHistory(editor, historyState, delay): () => void

Registers necessary listeners to manage undo/redo history stack and related editor commands. It returns unregister callback that cleans up all listeners and should be called on editor unmount.

Parameters

NameTypeDescription
editorLexicalEditorThe lexical editor.
historyStateHistoryStateThe history state, containing the current state and the undo/redo stack.
delaynumberThe time (in milliseconds) the editor should delay generating a new history stack, instead of merging the current changes with the current stack.

Returns

fn

The listeners cleanup callback function.

▸ (): void

Returns

void

Defined in

packages/lexical-history/src/index.ts:389