Skip to content
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

Local undo/redo/history in client #210

Open
brainkim opened this issue May 23, 2018 · 3 comments
Open

Local undo/redo/history in client #210

brainkim opened this issue May 23, 2018 · 3 comments

Comments

@brainkim
Copy link

brainkim commented May 23, 2018

I got the sharedb client working with a codemirror instance, but I don’t see any tools or methods on the sharedb client to store and revert/reapply local changes. Current behavior in my app makes it so that pressing ctrl-z will undo ops sent from the server. Checking to see if anyone has implemented local undo or if I have to roll it myself? :)

@gkubisa
Copy link
Contributor

gkubisa commented May 24, 2018

I have implemented it outside ShareDB based on the op and before op events only, however, I could probably port the solution to ShareDB core. I might look into doing it in a few weeks but I don't promise anything.

In case you want to roll out your own local undo/redo, here are some pointers:

  • if your ot type supports invert, you can use it to generate undo operations. Otherwise you could use diff - diff the snapshots from before op and op (this is what I do).
  • transform the undo/redo stacks top-down by the remote operations.
  • consider composing successive operations on the undo stack.
  • consider storing (and transforming) text selections on the undo/redo stack. (I'm planning to do that later but for now I set the caret at the furthest editing position on undo/redo.)

@gkubisa
Copy link
Contributor

gkubisa commented Jun 25, 2018

Here's a PR adding local undo/redo to ShareDB: #216.

@curran
Copy link
Contributor

curran commented Dec 3, 2021

What is the current status of the undo/redo feature? It's a cool idea and would be great to have in ShareDB!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants