@lexical/history
Interfaces
HistoryConfig
Defined in: packages/lexical-history/src/index.ts:601
Properties
createInitialHistoryState
createInitialHistoryState: (
editor) =>HistoryState
Defined in: packages/lexical-history/src/index.ts:610
The initial history state, the default is createEmptyHistoryState.
Parameters
editor
Returns
delay
delay:
number
Defined in: packages/lexical-history/src/index.ts:606
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:614
Whether history is disabled or not
maxDepth
maxDepth:
number|null
Defined in: packages/lexical-history/src/index.ts:630
The maximum number of entries the undo stack may hold. When the cap is
exceeded the oldest entries are dropped (FIFO) so the stack stays at this
length. Defaults to null, which keeps the stack unbounded — the
historical behavior. Setting a finite cap is recommended for editors that
may receive a very large number of distinct history events (long writing
sessions, automated input, etc.) since each entry retains a full
EditorState snapshot.
For reference, ProseMirror's history() plugin defaults to depth: 100.
now
now: () =>
number
Defined in: packages/lexical-history/src/index.ts:618
The now() function, defaults to Date.now.
Returns
number
HistoryExtensionOutput
Defined in: packages/lexical-history/src/index.ts:648
The output signals exposed by HistoryExtension.
Config-derived signals (delay, disabled, historyState, now) are
writable so that peer extensions such as SharedHistoryExtension can
redirect them at runtime. The canUndo / canRedo signals are
readonly for consumers — they are derived from the current
HistoryState and kept in sync automatically.
Properties
canRedo
canRedo:
ReadonlySignal<boolean>
Defined in: packages/lexical-history/src/index.ts:653
true when there is at least one entry in the redo stack, i.e. the
editor can perform a redo.
canUndo
canUndo:
ReadonlySignal<boolean>
Defined in: packages/lexical-history/src/index.ts:658
true when there is at least one entry in the undo stack, i.e. the
editor can perform an undo.
delay
delay:
Signal<number>
Defined in: packages/lexical-history/src/index.ts:660
The merge-delay in milliseconds forwarded to registerHistory.
disabled
disabled:
Signal<boolean>
Defined in: packages/lexical-history/src/index.ts:662
When true the history listener is not registered.
historyState
historyState:
Signal<HistoryState>
Defined in: packages/lexical-history/src/index.ts:664
The active HistoryState instance.
maxDepth
maxDepth:
Signal<number|null>
Defined in: packages/lexical-history/src/index.ts:670
Maximum number of entries the undo stack may hold. null disables the
cap. Changes apply to the next history event — the current undo stack is
not retroactively trimmed when the value is lowered.
now
now:
Signal<() =>number>
Defined in: packages/lexical-history/src/index.ts:672
The clock function forwarded to registerHistory.
SharedHistoryConfig
Defined in: packages/lexical-history/src/index.ts:753
Properties
disabled
disabled:
boolean
Defined in: packages/lexical-history/src/index.ts:757
Whether shared history is disabled or not
parentEditor
parentEditor:
LexicalEditor|null
Defined in: packages/lexical-history/src/index.ts:763
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:58
Properties
current
current:
null|HistoryStateEntry
Defined in: packages/lexical-history/src/index.ts:59
redoStack
redoStack:
HistoryStateEntry[]
Defined in: packages/lexical-history/src/index.ts:60
undoStack
undoStack:
HistoryStateEntry[]
Defined in: packages/lexical-history/src/index.ts:61
HistoryStateEntry
HistoryStateEntry =
object
Defined in: packages/lexical-history/src/index.ts:54
Properties
editor
editor:
LexicalEditor
Defined in: packages/lexical-history/src/index.ts:55
editorState
editorState:
EditorState
Defined in: packages/lexical-history/src/index.ts:56
Variables
HistoryExtension
constHistoryExtension:LexicalExtension<HistoryConfig,"@lexical/history/History",HistoryExtensionOutput,HistoryExtensionInit>
Defined in: packages/lexical-history/src/index.ts:679
Registers necessary listeners to manage undo/redo history stack and related editor commands, via the @lexical/history module.
SharedHistoryExtension
constSharedHistoryExtension:LexicalExtension<SharedHistoryConfig,"@lexical/history/SharedHistory",NamedSignalsOutput<{disabled:boolean;parentEditor:LexicalEditor|null; }>,unknown>
Defined in: packages/lexical-history/src/index.ts:771
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:593
Creates an empty history state.
Returns
- The empty history state, as an object.
registerHistory()
registerHistory(
editor,historyState,delay,dateNow?,onHistoryStateChange?,maxDepth?): () =>void
Defined in: packages/lexical-history/src/index.ts:463
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
The lexical editor.
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
The clock function used for delay-based merging.
onHistoryStateChange?
(state) => void
Optional callback invoked once on registration
and again any time historyState is mutated (push, pop, clear, etc.). It is
NOT invoked when a candidate update is discarded without changing the
stacks. Useful for keeping derived values (e.g. signals) in sync with the
current HistoryState.
maxDepth?
number | ReadonlySignal<number | null> | null
The maximum number of entries the undo stack may hold.
When the cap is exceeded a new history event has been pushed the oldest
entries are dropped from the front of the stack until the stack length is
maxDepth. Pass null (the default) to keep the stack unbounded — the
historical behavior. May be a plain number or a ReadonlySignal<number | null>
for reactive reconfiguration.
Returns
The listeners cleanup callback function.
() => void