import { Transaction, GardState } from 'wordgard/state'; import { ChangeSet } from 'wordgard/doc'; import { Command, Menu } from 'wordgard/command'; interface HistoryConfig { /** The minimum depth (amount of events) to store. Defaults to 100. */ minDepth?: number; /** The maximum time (in milliseconds) that adjacent events can be apart and still be grouped together. Defaults to 500. */ newGroupDelay?: number; /** By default, when close enough together in time, changes are joined into an existing undo event if they touch any of the changed ranges from that event. You can pass a custom predicate here to influence that logic. */ joinToEvent?: (tr: Transaction, isAdjacent: boolean) => boolean; } /** Create a history extension with the given configuration. Will include the state field that tracks history, handlers for the {@link undo} and {@link redo} commands that make use of it, and the {@link undoButton undo}/{@link redoButton redo} menu buttons. */ declare function history(config?: HistoryConfig): GardState.Extension; declare namespace history { /** The state field used to store the history data. Should probably only be used when you want to {@link GardState.toJSON serialize} or {@link GardState.fromJSON deserialize} state objects in a way that preserves history. */ const field: GardState.Field; /** Transaction annotation that will prevent that transaction from being combined with other transactions in the undo history. Given `"before"`, it'll prevent merging with previous transactions. With `"after"`, subsequent transactions won't be combined with this one. With `true`, the transaction is isolated on both sides. */ const isolate: Transaction.Annotation.Type; /** This facet provides a way to register functions that, given a transaction, provide a set of effects that the history should store when inverting the transaction. This can be used to integrate specific effects in the history, so that they can be undone (and redone again). */ const invertedEffects: GardState.Facet<(tr: Transaction) => readonly Transaction.Effect[], readonly ((tr: Transaction) => readonly Transaction.Effect[])[]>; type EventJSON = { changes: ChangeSet.JSON; selection: unknown; }; type JSON = { done: readonly EventJSON[]; undone: readonly EventJSON[]; }; } /** Undo a single group of history events. Returns false if no group is available. */ declare const undo: Command.Pure; /** Redo a single group of undone history events. Returns false if no group is available. */ declare const redo: Command.Pure; /** The amount of undoable change events available in a given state. */ declare const undoDepth: (state: GardState) => number; /** The amount of redoable change events available in a given state. */ declare const redoDepth: (state: GardState) => number; /** A menu button that undoes a change. */ declare const undoButton: Menu.Button; /** A menu button that redoes an undone change. */ declare const redoButton: Menu.Button; export { history, redo, redoButton, redoDepth, undo, undoButton, undoDepth };