@mocanvas/editor · class

HistoryManager

declare class HistoryManager<R extends UnknownRecord>

Undo/redo over store diffs. Every user-sourced document change is recorded; marks delimit undo steps. Undo applies the reverse of every diff back to the previous mark.


Methods · 13

bail(): this

Undo to the previous mark and drop the undone entries (no redo).

bailToMark(id: string): this

Undo back to a specific mark and drop the entries.

clear(): void
constructor(store: Store<R>, onBatchComplete?: (() => void) | undefined)
destroy(): void
getNumRedos(): number
getNumUndos(): number
getVersion(): number

Reactive counter for UI.

ignore<T>(fn: () => T): T

Run fn without recording its changes.

mark(id?: string): string

Place a stopping point. Returns the mark id.

redo(): this
squashToMark(id: string): this

Merge every diff since id into one step (the mark stays).

undo(): this

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.