UndoManager API
Less than 1 minute
UndoManager API
UndoManager maintains undo/redo stacks and records entity add/delete/update operations.
Import
const { UndoManager } = vjmapext;Usually via mapcadLayer.undoManager, or mapcadLayer.undo() / mapcadLayer.redo().
Methods
undo()
Undo the last operation. No-op if nothing to undo.
mapcadLayer.undo();
// or
mapcadLayer.undoManager.undo();redo()
Redo the last undone operation.
mapcadLayer.redo();canUndo()
| Returns | Type | Description |
|---|---|---|
| — | boolean | Whether undo is available |
canRedo()
| Returns | Type | Description |
|---|---|---|
| — | boolean | Whether redo is available |
clear()
Clear undo and redo stacks.
recordReorder(previousOrder)
Record a draw-order change so it can be undone.
| Parameter | Type | Description |
|---|---|---|
| previousOrder | string[] | Entity ids before the change |
Automatic recording
Most changes (add/delete/property edits) are pushed by EntityStore automatically. Use recordReorder only when you need draw order on the undo stack.
How it works
Notes
Warning
After a new action, the redo stack after the undone point is cleared. If you undo three steps then perform a new edit, those three steps cannot be redone.