Undo and Redo issue with text #172254
Replies: 4 comments 1 reply
-
|
GrapesJS's default RTE can cause issues with undo/redo due to its handling of text edits, especially with complex content or custom RTEs. To ensure proper undo/redo, explicitly track text changes using the Undo Manager API or customize the RTE with Thx. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @abhi1722 👋 You’re correct that GrapesJS handles text editing differently compared to other components, which can cause undo/redo to behave unexpectedly. By default, GrapesJS uses a built-in Rich Text Editor (RTE) that manages text content internally, and this can interfere with the UndoManager’s ability to track changes properly. To resolve this, you should:
This explicit handling ensures GrapesJS’s UndoManager receives all the necessary events to maintain a proper undo/redo stack for text edits. Let me know if you need a sample implementation or further details. |
Beta Was this translation helpful? Give feedback.
-
|
@IU1004 @KaloudasDev If no text is selected, the undo/redo works as expected. However, when text is selected and I change some of its properties, the undo only reverts the most recent change. If the text isn’t selected, the undo works correctly. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
I’m using GrapesJS with the following undo/redo methods:
editor.UndoManager.undo();
editor.UndoManager.redo();
The problem occurs specifically with text edits.
When I edit text inside a component and click undo, it only undoes the change once.
After that, redo doesn’t work or even show up.
For other components (shapes, images, etc.), undo/redo works correctly.
I tried adding this listener:
editorInstance.on('component:update:content', (component: any) => {
editorInstance.UndoManager.add(component);
});
But it still doesn’t fix the issue when text is selected and edited directly.
My question is:
Does GrapesJS handle text editing differently, which prevents redo from working?
Or do I need to explicitly handle text edits to make undo/redo work properly?
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions