packages/docs/docs/editor-starter/undo-and-redo.mdx
The Editor Starter implements a basic Undo and Redo feature.
It works by keeping an array of snapshots of the undoable state of the editor in memory.
An undo stack is an array of previous states that is being kept in memory.
By default, the undo stack holds 50 states.
Whenever updating a state, you should set the commitToUndoStack property appropriately to indicate whether the state update should be committed to the undo stack.
Actions that you may not want to add to the undo stack are high-frequency state update like:
In these cases, it is appropriate to only commit to the undo stack once the mouse cursor is released.
The undo stack only adds a new entry when the state object reference actually changes.
If a state update results in oldState === newState evaluating to true, no entry is added to the undo stack.
See Preventing state updates when nothing has changed for more information.
You can undo and redo actions:
This behavior is controlled by the following flags: