@samatawy/diagrams
    Preparing search index...

    Class HistoryStack

    A class that manages the history of changes to a diagram, allowing for undo and redo functionality. It tracks the state of the diagram at various points in time and provides methods to restore previous states.

    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    • get canUndo(): boolean

      Indicates whether there are any states in the undo stack that can be undone. Returns true if there is at least one state in the undo stack, false otherwise.

      Returns boolean

      true if undo is possible, false otherwise.

    • get canRedo(): boolean

      Indicates whether there are any states in the redo stack that can be redone. Returns true if there is at least one state in the redo stack, false otherwise.

      Returns boolean

      true if redo is possible, false otherwise.

    Methods

    • Clears the history stacks for both undo and redo, effectively resetting the history of changes.

      Returns void

    • Adds the current state of the diagram to the undo stack. This should be called whenever a change is made to the diagram that should be undoable.

      Returns void

    • Undoes the last change made to the diagram by restoring the previous state from the undo stack. The current state is pushed onto the redo stack to allow for redo operations.

      Returns Promise<boolean>

      A promise that resolves to true if the undo operation was successful, false otherwise.

    • Redoes the last undone change by restoring the state from the redo stack. The current state is pushed onto the undo stack to allow for undo operations.

      Returns Promise<boolean>

      A promise that resolves to true if the redo operation was successful, false otherwise.