Are there any diffing mechanisms for mobiledoc ?
alexparker opened this issue · 4 comments
Looking at ways to provide quality diffing on rich user input, and there doesn't seem to be a whole lot of options.
I'm interested in something like this too so that we could handle two users editing the same document a little more gracefully server-side. In my initial research I looked at JSON diffing libraries such as https://github.com/andreyvit/json-diff but haven't tried it against mobiledoc yet.
Seems like it'd have to be pretty specific implementation using the json-diff (or the like) coupled to the mobiledoc structure/format.
Creating 2 versions of text:
Version 1:
{"version": "0.3.1", "atoms": [], "cards": [], "markups": [], "sections": [[1, "p", [[0, [], 0, "Hello my name is alex, that's my name."] ] ] ] }
Renders:
Hello my name is alex, that's my name.
Version 2:
{"version": "0.3.1", "atoms": [], "cards": [], "markups": [["strong"] ], "sections": [[1, "p", [[0, [], 0, "Hello my name is "], [0, [0 ], 1, "alex,"], [0, [], 0, " that's my name."] ] ] ] }
Renders:
Hello my name is alex, that's my name.
Exploring the diff:
Using https://benjamine.github.io/jsondiffpatch/demo/index.html
Paste the 2 versions into the left / right inputs
Perhaps someone versed with mobiledoc could pitch in and help explore if this would be easy to render as a visual diff of the two versions.
at bustle we use a fork of a diff/patch for storage of revisions https://github.com/bustle/yadiffjson/
And then render to html and use https://www.npmjs.com/package/htmldiff which is super old but works (haven't touched this part of our code in a long while).