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

Open
opened 2023-03-16 11:45:28 +01:00 by whawker · 3 comments
whawker commented 2023-03-16 11:45:28 +01:00 (Migrated from github.com)

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.

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 commented 2023-03-17 11:35:24 +01:00 (Migrated from github.com)

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.

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 commented 2023-03-17 11:47:10 +01:00 (Migrated from github.com)

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?

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 commented 2023-03-17 19:38:39 +01:00 (Migrated from github.com)

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

You'd want to compare the spans too, I guess, and only return when the sets are entirely identical.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-changeset#19
No description provided.