Returns the current limit of the UndoManager
Sets the limit of the UndoManager.
This limits the size of the undoStack. If the size of the undoStack exceeds the limit, the oldest Undoables on the stack are removed.
If the new limit is lower than the old limit, the oldest items on the undoStack will be discarded, without applying them.
The new limit. Must be strictly positive.
Returns a copy of the redo stack. The upcoming undoable is the last element in the array.
You can use this stack to show one or more upcoming undoables, for example in a drop-down box of a redo button.
Returns a copy of the undo stack. The upcoming undoable is the last element in the array.
You can use this stack to show one or more upcoming undoables, for example in a drop-down box of an undo button.
Pushes a new item on the undoStack. This discards all Undoables on the redoStack.
If there are more Undoable on the undoStack than limit, the oldest Undoable on the stack is removed.
Note that an asynchronous Undoable is already on the redoStack while it is being undone. Pushing during that window discards it, so it can no longer be redone, even though undoing it still completes. Use a lock to stop the events that an asynchronous Undoable triggers from pushing new Undoables, as shown in the undo/redo guide.
Redoes the last Undoable on the redoStack. This Undoable then moves to the undoStack, immediately, before it is applied.
Undoable.redo can be asynchronous. If it is, this method returns a promise that resolves once that Undoable is redone, and this UndoManager waits for it before it applies the next Undoable. Calls to undo and redo that arrive in the meantime are queued, and applied in the order in which you called them.
If every Undoable in this UndoManager is synchronous, the returned promise never rejects, and you can ignore it. As soon as one of them can be asynchronous, await it inside a try/catch block, so that you find out whether the Undoable was applied and can report a failed model update to your user.
If Undoable.redo fails, the Undoable still moves to the undoStack, and the operations queued behind it are still applied. A synchronous Undoable on an idle UndoManager throws its error synchronously, as it did before 2026.1, so existing error handling around this method keeps working. An asynchronous Undoable, or a synchronous one that is queued behind an asynchronous operation, rejects the returned promise instead.
a promise that resolves once the Undoable is redone, or rejects if redoing it
asynchronously failed. Note that this method returned void before 2026.1.
Resets the UndoManager. This empties the Undoables;
This does not cancel Undoables that are being undone or redone, or that are queued behind them. They are still applied, and can still change your models after this call. Await the promises that undo and redo return if you need all of them to be applied before you reset.
Undoes the last Undoable on the undoStack. This Undoable then moves to the redoStack, immediately, before it is applied.
Undoable.undo can be asynchronous. If it is, this method returns a promise that resolves once that Undoable is undone, and this UndoManager waits for it before it applies the next Undoable. Calls to undo and redo that arrive in the meantime are queued, and applied in the order in which you called them.
If every Undoable in this UndoManager is synchronous, the returned promise never rejects, and you can ignore it. As soon as one of them can be asynchronous, await it inside a try/catch block, so that you find out whether the Undoable was applied and can report a failed model update to your user.
If Undoable.undo fails, the Undoable still moves to the redoStack, and the operations queued behind it are still applied. A synchronous Undoable on an idle UndoManager throws its error synchronously, as it did before 2026.1, so existing error handling around this method keeps working. An asynchronous Undoable, or a synchronous one that is queued behind an asynchronous operation, rejects the returned promise instead.
a promise that resolves once the Undoable is undone, or rejects if undoing it
asynchronously failed. Note that this method returned void before 2026.1.
A manager of Undoables.
You can undoables that you can undo or redo.
You can wire a keyboard shortcut, like CTRL+Z to undo, as follows:
You usually create undoables in response to an event from the API, and then add them to an UndoManager. You can find a list of common events in Undoable.
This example shows how to create Undoables in LuciadRIA:
You can find the full source, and more examples, in
toolbox/ria/core/util/SampleUndoSupport.ts.See the Adding undo/redo support to your application guide for more information on how to work with undo/redo in LuciadRIA.
See
Undoable
Since
2022.1