Skip to main content

@lexical/history

Interfaces​

HistoryConfig​

Defined in: packages/lexical-history/src/index.ts:540

Properties​

createInitialHistoryState​

createInitialHistoryState: (editor) => HistoryState

Defined in: packages/lexical-history/src/index.ts:549

The initial history state, the default is createEmptyHistoryState.

Parameters​
editor​

LexicalEditor

Returns​

HistoryState

delay​

delay: number

Defined in: packages/lexical-history/src/index.ts:545

The time (in milliseconds) the editor should delay generating a new history stack, instead of merging the current changes with the current stack. The default is 300ms.

disabled​

disabled: boolean

Defined in: packages/lexical-history/src/index.ts:553

Whether history is disabled or not

now​

now: () => number

Defined in: packages/lexical-history/src/index.ts:557

The now() function, defaults to Date.now.

Returns​

number


SharedHistoryConfig​

Defined in: packages/lexical-history/src/index.ts:601

Properties​

disabled​

disabled: boolean

Defined in: packages/lexical-history/src/index.ts:605

Whether shared history is disabled or not

parentEditor​

parentEditor: LexicalEditor | null

Defined in: packages/lexical-history/src/index.ts:611

The parentEditor to use, by default it is derived from config.parentEditor which can be provided by NestedEditorExtension

Type Aliases​

HistoryState​

HistoryState = object

Defined in: packages/lexical-history/src/index.ts:56

Properties​

current​

current: null | HistoryStateEntry

Defined in: packages/lexical-history/src/index.ts:57

redoStack​

redoStack: HistoryStateEntry[]

Defined in: packages/lexical-history/src/index.ts:58

undoStack​

undoStack: HistoryStateEntry[]

Defined in: packages/lexical-history/src/index.ts:59


HistoryStateEntry​

HistoryStateEntry = object

Defined in: packages/lexical-history/src/index.ts:52

Properties​

editor​

editor: LexicalEditor

Defined in: packages/lexical-history/src/index.ts:53

editorState​

editorState: EditorState

Defined in: packages/lexical-history/src/index.ts:54

Variables​

HistoryExtension​

const HistoryExtension: LexicalExtension<HistoryConfig, "@lexical/history/History", NamedSignalsOutput<{ delay: number; disabled: boolean; historyState: HistoryState; now: () => number; }>, unknown>

Defined in: packages/lexical-history/src/index.ts:565

Registers necessary listeners to manage undo/redo history stack and related editor commands, via the @lexical/history module.


SharedHistoryExtension​

const SharedHistoryExtension: LexicalExtension<SharedHistoryConfig, "@lexical/history/SharedHistory", NamedSignalsOutput<{ disabled: boolean; parentEditor: LexicalEditor | null; }>, unknown>

Defined in: packages/lexical-history/src/index.ts:619

Registers necessary listeners to manage undo/redo history stack and related editor commands, via the @lexical/history module, only if the parent editor has a history plugin implementation.

Functions​

createEmptyHistoryState()​

createEmptyHistoryState(): HistoryState

Defined in: packages/lexical-history/src/index.ts:532

Creates an empty history state.

Returns​

HistoryState

  • The empty history state, as an object.

registerHistory()​

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

Defined in: packages/lexical-history/src/index.ts:427

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​

editor​

LexicalEditor

The lexical editor.

historyState​

HistoryState

The history state, containing the current state and the undo/redo stack.

delay​

number | ReadonlySignal<number>

The time (in milliseconds) the editor should delay generating a new history stack, instead of merging the current changes with the current stack.

dateNow?​

() => number

Returns​

The listeners cleanup callback function.

() => void