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

Is there a way to compare if two change sets are equal? #19

Open
whawker opened this issue Mar 16, 2023 · 3 comments
Open

Is there a way to compare if two change sets are equal? #19

whawker opened this issue Mar 16, 2023 · 3 comments

Comments

@whawker
Copy link

whawker commented Mar 16, 2023

Hi, I'm working on a plugin that creates changesets.

I was wondering, is there any way to compare if two changesets are equal? (I'm thinking along the lines of the .eq() functions in ProseMirror model).

Basically, I was hoping to compare the plugins prevState with current state to determine whether to update decorations.

@marijnh
Copy link
Member

marijnh commented Mar 17, 2023

It looks like this doesn't exist yet, but it should be rather straightforward to implement. I'd be open to a pull request that adds such a method.

@whawker
Copy link
Author

whawker commented Mar 17, 2023

Sure thing, any general advice?

Should comparing the fromA/fromB/toA/toB suffice? Also I suppose we could bail out quickly if the arrays are different lengths?

@marijnh
Copy link
Member

marijnh commented Mar 17, 2023

You'd want to compare the spans too, I guess, and only return when the sets are entirely identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants