Open s-panferov opened 3 years ago
Good question!
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:
Delete(ids)
to undo stackInsert(cursor, deleted_content)
to undo stackIdeally 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.
Its probably time to adding undo / redo support now. The API surface area internally is ready for it, and I want it for the wiki.
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?