You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for the amazing library. I have a quick question: can undo/redo be implemented on top of this library and what is a general strategy of doing so?
The text was updated successfully, but these errors were encountered:
Its still a bit early for me to add direct undo/redo support. Probably the simplest way to implement it is to have an undo stack, and simply make a change which does the inverse of the user's action.
There's an API internally (which I should expose) for getting a unique ID based on a document position, or an ID (or sequence of IDs) for some inserts.
So for undo, it would be something like:
When inserting new content:
Insert actual items
Get IDs for inserted elements
Push Delete(ids) to undo stack
When deleting:
Delete items
Get ID for cursor position where items were deleted
Push Insert(cursor, deleted_content) to undo stack
Ideally we'll have some utility code for this inside diamond types, but I'm working on file loading & saving and some other features added first.
josephg
changed the title
Question: Undo/Redo
Undo/Redo support
Mar 28, 2022
Hi, thanks for the amazing library. I have a quick question: can undo/redo be implemented on top of this library and what is a general strategy of doing so?
The text was updated successfully, but these errors were encountered: