I was able to use prosemirror-changeset to compute the differences between two versions of the same document. The problem is that it only shows the differences in the node’s content. If a step changes a node’s marks or a node’s attrs, it does not get reported as a change.
How do I use prosemirror-changeset find changes in marks and attrs? Would I need to modify the code for prosemirror-changeset? What function inside of prosemirror-changeset would I need to modify?
The steps I’m currently taking are:
Start with the JSON of two different versions of the same document.
Create Prosemirror Node objects from the JSON representations
Use a library called modevol-prosemirror-recreate-transform to calculate the transform between the two versions of the same Doc
Get the StepMaps mapping from the transform
Use Changeset.create and Changeset.addSteps to calculate a ChangeSet
prosemirror-changeset, being intended for the use case of highlighting inline changed ranges, doesn’t track mark and attribute changes. Your process seems a bit circuitous — recreate-transform will do diffing between two versions to find changed ranges and then create steps for those changes, then prosemirror-changeset will take the ranges from those steps again, and do another diff to minimize them. It sounds like what you’re interested in are the initially determined changed ranges. Maybe you can figure out how prosemirror-changeset initially finds the changed ranges and see if you can use that part directly.
@marjin What I want is to show a side by side view. The left hand side shows the old document, the right hand side shows the new document. Then on each side I want to highlight what has been changed so that the user can quickly see the differences. I want to highlight when blocks have been added or removed or changed. I want to highlight when marks have been added to inline content.
I don’t have any steps or transform from the old document to the new document. So that is why I’m using modevol-prosemirror-recreate-transform to generate a Transform, mapping, and steps.
I need a function that, given a Transform, will return a Changeset that includes all of the changes. But prosemirror-changeset only returns some of the changes that I want. It doesn’t include changes to marks or attrs.
I’m not sure if I know enough about Transform, Step, and StepMap to write that function.
I could try to do it in a single column view. But it was also messy trying to do it that.