-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting data doesn't clear undo stack #4060
Comments
@scofalik wrote in another ticket:
|
In ckeditor/ckeditor5-paragraph#27 we noticed that we stopped autoparagraphing on |
The above is not true anymore because now post-fixers don't check the type of batch. |
I'm raising the priority of this ticket. It'd be good to first gather some feedback. What options do developers need? What API will be most useful? In https://github.com/ckeditor/ckeditor5-autosave/issues/6 we've seen people doing subsequent |
In https://github.com/ckeditor/ckeditor5-autosave/issues/6#issuecomment-404776461 I commented on the proposal to have I'd rather see something like: editor.setData( data ); // does "init data"
editor.setData( data, { mode: 'change' } ); // does "set data as nothing happened, keep undo, etc." |
Working on the comments integration we were also missing the option to re-init editors data. With @oskarwrobel it took us a while to find a way to load comments and content in the way which does not look like a total hack, and we are still not very happy with what we get. Loading data should be simple and there should be no hacks needed. It is not only about cleaning the undo stack, but also about resetting some plugins (remove pending actions, stop uploads, remove comments, etc.). Also, note that collaborative editing feature will integrate differently with it (basically will not allow you to re-init data if the collaborative editing plugin is enabled). Since we already have When it comes to the
But I am not sure if it won't be missleading :/ |
I think we all agree that the main usecase for |
Since we already have It should either use normal batch and let undoing (makes sense) or it should re-init the whole editor, i.e. use transparent batch, clear history and fire an event on which plugins can listen and clear themselves. Now we have the worst option, TBH, which is prone to generate errors. |
👍 |
Reported on Gitter: https://gitter.im/ckeditor/ckeditor5?at=5cb89dfb375bac7470c6613a |
It'd be good to know if there's some quick workaround - a method or something you can do after calling |
Citing myself from Gitter: Well, Out of the top of my head, there's one small issue with that - removed nodes, which are stored in The go-to solution would be, in my opinion:
For now I am afraid that there's no nice solution. |
Any changes in that issue? Still can't clear undo stack by public API. And |
@baturian not yet, but we've just added this ticket to the sprint so most likely it will land at the end of July. The decision was to have We want to implement a solution described by #4060 (comment). It's not yet clear whether |
Fix (undo): Undo/redo stacks should be cleared on `DataController#set()`. Closes #4060. Feature (engine): The method `DataController#set()` is now decorated so plugins can listen to `editor.setData()` calls. MAJOR BREAKING CHANGE: The method `editor.setData()` clears the undo and redo stacks.
editor.setData( '<p>foo</p>' );
We have two things here:
It should be possible to manage whether setting data resets the history (whether it's undoable or not) or not. Or, like in CKE4, there should be a way to tell whether
setData()
should create undo step and a way to clear the stack. This is more granular but boils down to the same story.If
setData()
was meant to create an undo step then undoing shouldn't throw an error.I also thought that features like typing may need to reset their stored batch on such actions. I think that
ChangeBuffer
should be doing this reliably now but it may be good to write a test for it (if there's none).The text was updated successfully, but these errors were encountered: