Class UndoManager

Manager class returned by undoMiddleware that allows you to perform undo/redo actions.

Constructors

Properties

store: UndoStore

The store currently being used to store undo/redo action events.

Accessors

  • get canRedo(): boolean
  • If redo can be performed (if there is at least one redo action available)

    Returns boolean

  • get canUndo(): boolean
  • If undo can be performed (if there is at least one undo action available).

    Returns boolean

  • get isUndoRecordingDisabled(): boolean
  • Returns if undo recording is currently disabled or not for this particular UndoManager.

    Returns boolean

  • get redoLevels(): number
  • The number of redo actions available.

    Returns number

  • get redoQueue(): readonly UndoEvent[]
  • The redo stack, where the first operation to redo will be the last of the array. Do not manipulate this array directly.

    Returns readonly UndoEvent[]

  • get undoLevels(): number
  • The number of undo actions available.

    Returns number

  • get undoQueue(): readonly UndoEvent[]
  • The undo stack, where the first operation to undo will be the last of the array. Do not manipulate this array directly.

    Returns readonly UndoEvent[]

Methods

  • Clears the redo queue.

    Returns void

  • Clears the undo queue.

    Returns void

  • Creates a custom group that can be continued multiple times and then ended.

    Parameters

    • Optional groupName: string

      Optional group name.

    Returns {
        continue<T>(fn): T;
        end(): void;
    }

    An API to continue/end the group.

    • continue:function
      • Type Parameters

        • T

        Parameters

        • fn: (() => T)
            • (): T
            • Returns T

        Returns T

    • end:function
      • Returns void

  • Disposes the undo middleware.

    Returns void

  • Redoes the previous action. Will throw if there is no action to redo.

    Returns void

  • Undoes the last action. Will throw if there is no action to undo.

    Returns void

  • Runs a synchronous code block as an undo group. Note that nested groups are allowed.

    Type Parameters

    • T

    Parameters

    • groupName: string

      Group name.

    • fn: (() => T)

      Code block.

        • (): T
        • Returns T

    Returns T

    Code block return value.

  • Runs a synchronous code block as an undo group. Note that nested groups are allowed.

    Type Parameters

    • T

    Parameters

    • fn: (() => T)

      Code block.

        • (): T
        • Returns T

    Returns T

    Code block return value.

  • Runs an asynchronous code block as an undo group. Note that nested groups are allowed.

    Type Parameters

    • R

    Parameters

    • groupName: string

      Group name.

    • fn: (() => Generator<any, R, any>)

      Flow function.

        • (): Generator<any, R, any>
        • Returns Generator<any, R, any>

    Returns Promise<R>

    Flow function return value.

  • Runs an asynchronous code block as an undo group. Note that nested groups are allowed.

    Type Parameters

    • R

    Parameters

    • fn: (() => Generator<any, R, any>)

      Flow function.

        • (): Generator<any, R, any>
        • Returns Generator<any, R, any>

    Returns Promise<R>

    Flow function return value.

  • Skips the undo recording mechanism for the code block that gets run synchronously inside.

    Type Parameters

    • T

    Parameters

    • fn: (() => T)

      Code block to run.

        • (): T
        • Returns T

    Returns T

    The value returned by the code block.

    Typeparam

    T Code block return type.