Bug
A. Redos are lost when trying to undo past the history stack using keyboard shortcut
B. Redos are lost when focus is changed
This is problem in the history example: https://www.slatejs.org/#/history
To replicate (A):
|Redos are lost when trying to undo past the history stack using keyboard shortcut |
| -- |
|
|
NOTE: This works if you undo/redo using the buttons in the toolbar
To replicate (B):
|Redos are lost when focus is changed |
| -- |
|
|
Chrome Version 74.0.3729.169
Safari Version 12.0.1 (14606.2.104.1.1)
MacOs 110.14.1 (18B75)
Undo/Redo history should be retained.
Similar problem occurs if -in the rich text editor example- you select a piece of text, mark it as bold, then hit Ctrl+Z twice, Ctrl+Y doesn't work anymore.
It is because setting the selection is seen as an "undoable action" (an operation). We might want to consider separating setting the selection from the operation mechanism and instead infer it from the operations that occur. This could also clear the way to handling multiple selections (such as with OT) in the future?
If anybody wants an (undocumented) starting point, I'm pretty sure my PR resolves that, but it's outdated and incomplete: https://github.com/ianstormtaylor/slate/pull/2347
thanks @bryanph and @Slapbox for giving some feedbacks and hint to dig the issue.
One thing I still don't get, is why would we wipe the redos ? It doesn't seems the common behaviour on any other editing tools/input/text area
I've been testing to prevent cleaning it (by setting manually editor.tmp.merge to null using the event onFocus and it seems to work fine.. At least I can't find yet any wrong behaviour about it.. Am I missing something ?
@julienR2 the clearing of redos is just an overlooked scenario for the history management logic, not necessarily intentional. If I recall, it happens because the editor inserts an event into the undo/redo stack when the editor is blurred.
I'm not sure if what you're doing will have side effects, but running the Slate built in tests with the same configuration you're using should give you an idea of what it breaks.
The PR #2347 is pretty much entirely undocumented and out of date, but at the time it fixed that issue with only one test failure.
Unfortunately I won't have time to revisit the issue until some time in 2020, but if anyone wants to work on fixing it, I can provide guidance based on what I recall/what I can decipher of my own work.
https://github.com/ianstormtaylor/slate/pull/2948 seems to have fixed A but B is still not fixed. Redos are lost when there is a selection change. Does anyone know if somebody is working on fixing this?
I believe that this may be fixed by https://github.com/ianstormtaylor/slate/pull/3093, which has changed a lot of the logic in Slate and slate-react especially. I'm going to close this out, but as always, feel free to open a new issue if it persists for you. Thanks for understanding.
I believe that this may be fixed by #3093, which has changed a _lot_ of the logic in Slate and
slate-reactespecially. I'm going to close this out, but as always, feel free to open a new issue if it persists for you. Thanks for understanding.
This has not been fixed so I created a new issue: https://github.com/ianstormtaylor/slate/issues/3140
Most helpful comment
If anybody wants an (undocumented) starting point, I'm pretty sure my PR resolves that, but it's outdated and incomplete: https://github.com/ianstormtaylor/slate/pull/2347