-
Notifications
You must be signed in to change notification settings - Fork 132
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
Problem with the input history. #9
Comments
Diffing/patching the document JSON might a good approach. I haven't looked into it but I remember seeing this discussion where it was mentioned that Immer makes this straightforward. |
I've had a play around with Immer and it looks promising. The Vue docs recommend its use, including specifically when looking to implement undo/redo functionality. I took the playground that the Vue docs link to and expanded it to something more practical. No Lotion🧴 involved at the minute but it think the demo is useful at showing what's possible. View demoIn this demo you can update text and toggle items as 'done' and these changes will be tracked by Immer, with undo and redo operations possible through both undo/redo buttons and keyboard shortcuts. Note this demo isn't working at all on Safari but neither is the Playground linked to above... Safari doesn't seem to like the way one of the modules is being imported by the Vue Playground. This is quite rough at the minute (sometimes it suggests there are things to undo when there aren't). But it does show Immer working! Note that App.vue is just fairly routine Vue stuff, all the Immer related stuff happens in immer.js. The patches pages in the Immer docs is most relevant. There are obviously considerations around this, perhaps most importantly whether there might be performance issues with a large undo history. But there are potential solutions, e.g. a) allowing enabling/disabling history entirely during initialisation, b) limiting the undo history to a maximum number of steps, or c) compressing the undo history (the Immer docs link to a Medium Article on this... the solution in this article isn't quite right but points in the right direction. There might be a way to 'squash' only older undos periodically as the undo history grows. |
ctrl+z
andctrl+y
has not a normal or notion-like behavior.Maybe don't use the browser behavior for
ctrl+z
andctrl+y
and add a history for the data tree?Thanks for your awesome job, and please, keep it simple :)
The text was updated successfully, but these errors were encountered: