Hi Marijn, I’m working on building a version history system similar to the one shown in NYTs article and wanted to run my plan by someone who better understands prosemirror:
Currently my plan is to:
- Collect steps as they are applied to the document server-side in our collaboration server
- Store versions with a snapshot of the document at the start of the version and the steps applied in that version
- Use the snapshot and the steps applied to build a diff document with any additions wrapped in an addition mark and any deletions instead wrapped in a deletion mark
Thorny problems seem to be:
How to apply some step B after a deletion step A has caused it’s
topositions to point to incorrect locations?
Theory: Use the inverse mapping of A to get B-before-A is applied then use the mapping from A-deletion (the A with deletion marks applied instead of text deleted) to map B-before-A into B-after-A-deletion?
How to decide when to create a new version versus appending to an existing one?
Theory: Use recency (within 5 mins of last update to a version), the author is the same, and how close the step is to the steps in the version
How to display changes to NodeViews?
Theory: Highly dependent on each NodeView. Using decorations we can tell the node view of it’s diffs then each NodeView would need to display those differences on a case by case basis. Simplest approach, just wrap the whole NodeView in a “changed” style
Does this sound like a reasonable approach?