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

Are there any diffing mechanisms for mobiledoc ? #653

Open
alexparker opened this issue Oct 27, 2018 · 4 comments
Open

Are there any diffing mechanisms for mobiledoc ? #653

alexparker opened this issue Oct 27, 2018 · 4 comments
Labels

Comments

@alexparker
Copy link

Looking at ways to provide quality diffing on rich user input, and there doesn't seem to be a whole lot of options.

@kevinansfield
Copy link
Collaborator

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.

@alexparker
Copy link
Author

Seems like it'd have to be pretty specific implementation using the json-diff (or the like) coupled to the mobiledoc structure/format.

@alexparker
Copy link
Author

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
diff

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.

@reconbot
Copy link
Contributor

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).

screen shot 2018-10-29 at 4 52 30 pm

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

No branches or pull requests

4 participants