Make the undo history extendable #24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
So that custom code can introduce custom history events, that are applied as part of or between the history events created by editing
An officially-supported way to add data to a history event would be extremely helpful, too. I’d love to be able to store some extra state when CM commits a change, and then get that state on undo/redo.
Also, having a method to simply undo/redo something would be great, like having something like
EditorView.undo().That already exists—just call the
undocommand exported from the history package.This has landed with state effects and the
invertedEffectsfacet.Are state affects what one might use to attach data to a history event?
Yes, you model your actions as effects (which are attached to transactions), and register a handler that, given a transaction, produces the effects the inverse of that transaction should have. The history will store those inversed effects and replay them when the transaction is undone.
Fantastic. This is a critical feature of making code mirror usably accessible, instead of merely accessible.
for future reference, there is an example of this feature on codemirror.net.