import { CursorState, FinalizedChangeset } from "../../data"; import type { EditorState } from "../../model/editorState"; /** * A stack item is used to store * a lot of operations committed by the user. * * The data stored in the object is used * to restore when the user trigger undo. * * A stack item has a property named `sealed`. * When a StackItem is sealed, it can't be * changed anymore. */ export declare class HistoryItem { prevSibling: HistoryItem | null; nextSibling: HistoryItem | null; cursorState?: CursorState | null; sealed: boolean; startVersion: number; length: number; seal(): void; } export declare class FixedSizeStack { #private; private maxSize; constructor(maxSize: number); push(item: HistoryItem): void; peek(): HistoryItem | null; pop(): HistoryItem | void; clear(): void; get length(): number; } export declare class UndoManager { #private; readonly state: EditorState; /** * When the composition started, the current cursorState * is saved here. * When a text edit is committed, the value will be * consumed by the [UndoManager]. * * This is not a good solution because the text committed * maybe not be the text which is pointed by the cursor. */ cursorBeforeComposition: CursorState | null; readonly undoStack: FixedSizeStack; readonly redoStack: FixedSizeStack; constructor(state: EditorState, stackSize?: number); getAUndoItem(): HistoryItem; pushRedoItem(changeset: FinalizedChangeset): void; clearRedoStack(): void; seal(): void; undo(): HistoryItem | void; redo(): void; }