Replies: 33 comments 2 replies
-
I'd like to see this too, currently if you delete something, it's gone for good. |
Beta Was this translation helpful? Give feedback.
-
On the undo-redo note - I've been using immer for a project recently and adding in my own undo / redo functionality was trivial. It is a great library because it offers the ability to use "patches" (https://github.com/mweststrate/immer#patches) which are records of the individual pieces of your JSON tree that you have changed on your object. The easy of use it brings to editing big JSON objects directly might be useful as a whole to this project, and the patches would be a great addition to allow complete control over undo / redo. Behind the scenes they look something like this (you get both regular and inverse patches so you can go both ways):
I actually think its the perfect data tool for something like a block editor. I understand not wanting to add dependencies, but this one could be worth looking at and its only 4.2kB gzipped. |
Beta Was this translation helpful? Give feedback.
-
Hi @lostpebble ! I was working on these features using "patches" too, thanks for pointing out the immer! This also would be really good for the future collaborative mode |
Beta Was this translation helpful? Give feedback.
-
Yep exactly! That's part of the magic - only sending exactly the changes that are being made instead of the entire tree. This could definitely kill two birds with one stone, undo / redo and collaborative modes. I would definitely take more of a look at immer as whole too, it really has made my life 10x easier when working on my state library (https://github.com/lostpebble/pullstate) - in fact I made it a core mechanic - as it allows you to mutate your state objects directly and it can figure out when nothing has changed very easily (good for performance checks). Overall a brilliant library! |
Beta Was this translation helpful? Give feedback.
-
The problem I faced is we need to work with DOM state directly if we don't want to plugin developers care about that. It is a little inconsistent with the idea of working with the data as JS objects. Anyway will look at the immer, thanks! |
Beta Was this translation helpful? Give feedback.
-
Ah, okay. That is a little disappointing requirement, I was thinking that this was more of a "virtual" DOM as a whole - based completely off of the JSON object. |
Beta Was this translation helpful? Give feedback.
-
We will think of options how to implement this. I hope we will include it to the next major release |
Beta Was this translation helpful? Give feedback.
-
Great library guys! Without undo operations, it is hard to envision anyone using this for production apps. If the DOM could somehow be reactive to the underlying JSON model, then one could fairly easily implement undo/redo and collaborative editing using a CRDT library such as AutoMerge. Using CDRT, in my opinion, would give this library a huge leg up on the competition, which primarily use Operational Transformation (which from my understanding requires a server to ensure that operations are transformed in the correct order, as opposed to CDRT, which does not care about order of transactions). |
Beta Was this translation helpful? Give feedback.
-
Hi! Any info about this bug? Can't work without undo-redo =( |
Beta Was this translation helpful? Give feedback.
-
what is the current progress on the undo/redo feature?
|
Beta Was this translation helpful? Give feedback.
-
Hey Guys, any news about this feature? |
Beta Was this translation helpful? Give feedback.
-
@lostpebble Could you provide an example of your implementation? |
Beta Was this translation helpful? Give feedback.
-
another possible approach is let editor.js-core maintains an undo/redo stack, once what you guys think? @gohabereg @eduardomart @lostpebble @bbbford @just99 |
Beta Was this translation helpful? Give feedback.
-
@gohabereg @neSpecc Is there any progress regarding this issue? |
Beta Was this translation helpful? Give feedback.
-
Everyone waiting for this feature ^^ |
Beta Was this translation helpful? Give feedback.
-
👋👋👋 We have developed a plugin that can address this feature. We hope this may help :). https://github.com/kommitters/editorjs-undo The code is already open and published to NPM ... everyone is welcome to contribute 🎩. |
Beta Was this translation helpful? Give feedback.
-
I forgot to mention ... Redo is also supported ;) |
Beta Was this translation helpful? Give feedback.
-
that's awesome! but i wonder if the history-stack should only store the diff part between each save data ? otherwise the history-stack will be huge if the article is large. plus the undo and redo seems lost the caret state ? |
Beta Was this translation helpful? Give feedback.
-
@mydearxym The main issue with that approach is that the render method the API provides receives the whole object. We cannot render a specific piece of the blocks. About the last part, what do you mean with 'caret state'? It would be awesome if you create an issue explaining us the problem. Thanks! |
Beta Was this translation helpful? Give feedback.
-
@nicolasgaviria Firstly, thanks for contributing your plugin! It's really cool and I think our organisation will start using it! However, like @mydearxym suggested, I too think that the history stack should only store the diffs, probably using a command pattern!
That's a fair point, but couldn't the plugin compute the whole set of blocks that need to be passed to the editor by replaying the commands according to the user's actions? I might (please don't hold me accountable 🙃 ) start a fork of either your undo plugin or the editor itself to try implementing it with a command pattern. I'd argue that it'd be better to have this feature natively in the editor core because, especially to end users but to developers as well, the editor looks like one big I think that the way @nicolasgaviria 's plugin implements it using a DOM Anyway, those are my two cents, I'll report back if I do end up forking, or creating something else! |
Beta Was this translation helpful? Give feedback.
-
Hi, without Undo/Redo operation, it is really very hard to use editor. |
Beta Was this translation helpful? Give feedback.
-
This is awesome @juanhurtado10!! But, if you have empty blocks in between the data, they are lost while pressing notebook_new_line.mov |
Beta Was this translation helpful? Give feedback.
-
Hey, @komaldembla thanks for reporting. Just added a new issue in the plugin repo Could you please drop the following information there?
Best, |
Beta Was this translation helpful? Give feedback.
-
Thanks @juanhurtado10! I've updated the details on this issue itself |
Beta Was this translation helpful? Give feedback.
-
So is that supported now ? |
Beta Was this translation helpful? Give feedback.
-
Have you guys tried the following config? I think this allows the undo plugin to recover the empty blocks. paragraph: {
class: Paragraph,
inlineToolbar: true,
config: {
preserveBlank: true,
},
},
... let me know if worked for you! Best, Screen.Recording.2021-09-08.at.5.07.51.PM.mov |
Beta Was this translation helpful? Give feedback.
-
Thank you so much @juanhurtado10. It works like a charm!! |
Beta Was this translation helpful? Give feedback.
-
Hey everyone!! We just released the
All the info is in the Readme. Hope it helps 🍻 ... feedback is really appreciated :). Best |
Beta Was this translation helpful? Give feedback.
-
The performance for editorjs-undo is unbearable. I've had to fork the undo plugin to support slices of what's changed. However, I have had no luck in getting what has changed from editorjs (what index or grouping of indices - pages of a document in my case). Further support of the onChange event in plugins would allow one to extend and get the changes correctly. Indices before and after - store them. |
Beta Was this translation helpful? Give feedback.
-
Does this feature replace this plugin? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions