Cancel deletion?

In my current use case I’m working with Y.Snapshot, my user is working on a snapshot, doing some updates validating and send the snapshot update to others (like a suggestion).
I’m also computing deltas and rendering them has an overlay on the editor.

My current challenge is related to deletion, my user want to revert a deletion like it never happen.

So I’m using Y.UndoManager that looks perfect for that use case. It do record the user actions (like the deletion) but then when we call Undo it is basically inserting what has been deleted and this resulting to a delta remove & insert the same text.
I’m wondering is there a way to simply cancel a deletion? I mean deletion are stored to a deleteSet next to store, could we remove that deletion?

After some deeper look, it looks like my Y.Array elements are duplicated and the duplicate has redone attribute that is strictly equal to ID of the left node (original node).
So the right node with redone is the deletion “canceled” by UndoManager, so I just made the assumption to skip that node when computing my deltas.
Now the issue is the left node has for ID the current client with a clock that is unknown from the previous snapshot making it “as new”.

@dmonad Do you think you could give me some hint there?

  • How do work UndoManager?
  • What is the use of redone attribute on the items?

Your help would be very appreciated :slight_smile:

This is an issue with all real time colab tech. There is no such thing as undo/redo (just trying to keep the intent). Though it should probably be possible to add another tombstone like flag to an item that would represent it coming back to life (and extrapolating it out you could have a whole list or if something is deleted or brought back) that would be a big change to how everything works and not really worth it in most cases.

You could make your own data structure that held the information, which would be a major pain but possible. Usually you want to know that something was taken out and put back in though, as others might have seen the change and made decisions based on it…

1 Like