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

feature request: add arbitrary events to the undo history #800

alidcastano opened this issue May 20, 2018 · 3 comments


None yet
3 participants
Copy link

commented May 20, 2018

Following discussion in forum about being able to undo decoration deletions:

One idea for the API, is that, similar to how you can add an onRemove option to mapped decorations, you can add an onUndo option to the meta transaction. E.g. tr.setMeta(key, value, { onUndo: Function(tr) }) and let the user handle the logic for restoring a specific decoration based on the previous transaction.

I feel like that's a pretty simple way of handling this. But I'm not sure if there's any nuances I'm not taking into account, so opening this issue to start a discussion and see if we can land this feature. :)


This comment has been minimized.

Copy link

commented May 20, 2018

I'll add a quick example of how'd it look using above API

const commentToDelete = {..}
  tr.setMeta(commentPlugin, { type: 'deleteComment' comment: CommentToDelete }, { 
    // option1 append steps to undo transaction
    appendUndo (tr) {
        return tr.setMeta(commentPlugin, { type: 'createComment', comment: commentToDelete }
    // option 2 dispatch new transaction based on new state after undo
    // onUndo (state, dispatch) { ... }

This comment has been minimized.

Copy link

commented May 23, 2019

@alidcastano, is there any updates or suggested workarounds on this issue?


This comment has been minimized.

Copy link

commented May 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.