[Feature]: Improve UndoManager API
Question
One thing i think would add great functionality is a more detailed history stack. U can get the undo stack and build a sort of history report from it of all the edits one has made but it is a little unclear as to what each edit was (at least to me so if I am missing something please let me know). Maybe like a formulaic description that is like component [component name] added/deleted/edited at [location on page or component added to], or component [component] text edited, . . . (please excuse the general description as even i have no clue how i would phrase it) just some quick description that can give a brief overview of what that particular undo/redo history was for each item on the stack. I am aware of only the id of each history item atm, so if this is currently possible I am just unaware of how i should go about extracting this information to create a history sidebar outside of just the id so please give me a clue as what to look for
Is there an alternative at the latest version?
- Yes (describe the alternative)
- [ x] No
Is this related to an issue?
- Yes (Give a link to the issue)
- [ x] No
Answers (3)
Hi @anatoli-dp the ability to view the undo history would be actually super cool and I was already thinking about how to extend the UndoManager module in order to allow this kind of functionality via a plugin (eg. you can render the UI with your framework of choice). The UndoManager stack is updated, with a new UndoAction object (containing infos about the action), on any change of listened models/collections (components, css rules, etc.). One thing worth noting is that one change can generate multiple UndoActions:
// This will generate one UndoAction for a new component
// and another one for a new CSS Rule
editor.addComponents(`
<div class="test">Hi</div>
<style>.test{color: red}</style>
`);
Here is an example of how you could retrieve an array of grouped UndoActions (the private method I made during the last refactoring).
One thing to understand is how to identify each group of UndoActions with the proper description/label (as you have described).
yeah im aware of how to access the stack i just dont know how to intepret it to give a more meaningful description to the end user
i just dont know how to intepret it to give a more meaningful description to the end user
Each UndoAction (each instance of the stack) tells you the action type (eg. add, remove, reset, change) and details about the updated model (eg. Component, CssRule, etc.). You can try to read those data but I was thinking more about how to make each operation easily recognizable.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3399
Convert JSON to HTML server-side
So first of all, thank you @artf for this amazing project. I have a question: Is it possible to easily convert the components-JSON to HTML...
Issue #1806
[Feature]: Add category on traits
Hi and thank's for your job ! It's possible to make traits under cateogories like blocks ? If it's possible, maybe use the Category object...
Issue #3317
FEAT: Add support for promises to custom RTE API
What are you trying to add to GrapesJS? Support for richtext editors with promise based APIs. Describe your feature request detailed CKEdit...
Issue #2364
[Question] How to add toolbar functionality to the layers panel.
I am trying to add the toolbar to the layers panel and I am not sure how to go about this. Is there any way to accomplish this? toolbar Whe...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.