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

Open
alidcastano opened this issue May 20, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@alidcastano
Copy link

commented May 20, 2018

Following discussion in forum about being able to undo decoration deletions: https://discuss.prosemirror.net/t/add-inverse-of-decoration-step-to-history/1342/3

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. :)

@alidcastano

This comment has been minimized.

Copy link
Author

commented May 20, 2018

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

const commentToDelete = {..}
dispatch(
  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) { ... }
  })
)
@vladminsky

This comment has been minimized.

Copy link

commented May 23, 2019

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

@marijnh

This comment has been minimized.

Copy link
Member

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.