Undo and Redo in JavaScript Block Editor
Undo/redo lets users revert and reapply changes made to the editor content, providing a safety net for edits.
The Block Editor tracks the following types of actions in the undo/redo stack:
- Text content changes (typing, deletion)
- Block additions, deletions, and duplication
- Block movements and reordering (via drag-and-drop or shortcuts)
- Inline formatting changes (bold, italic, underline, color)
- Block transformations (paragraph to heading, etc.)
Keyboard shortcuts
| Action | Windows | Mac | Description |
|---|---|---|---|
| Undo | Ctrl + Z | ⌘ + Z | Reverts the last action. |
| Redo | Ctrl + Y | ⌘ + Y | Reapplies the last undone action. |
Configuring Undo/Redo stack
By default, the editor saves up to 30 actions in its undo/redo history. You can customize this limit using the undoRedoStack property.
The example below sets the undo/redo history limit to 20 actions.