Page MenuHomePhabricator

Make the visual diff functionality in the visual editor a standalone tool
Open, LowPublic

Description

The VisualDiff tool inside VisualEditor is the best I've seen for showing a human-readable difference between revisions of HTML. I'd like to use it in a stand-alone diff tool, but it's proving hard to extract. I'm not sure how to instantiate a VisualEditor DataModel DocumentNodes object from a string, like is done here:

https://tchanders.github.io/treeDiffer.js

Has anyone done this before or does anyone have any tips on how to populate a ve.dm.DocumentNode from HTML not in the VisualEditor?

Event Timeline

Has anyone done this before or does anyone have any tips on how to populate a ve.dm.DocumentNode from HTML not in the VisualEditor?

The VE data model (with ve.dm.DocumentNode at the root) is designed for our specific representation of documents in HTML. You can convert any HTML document into VE DM, but it is designed to extract and make editable the information that VE considers important (for example, text colour is not easily accessible in the model).

The closest we have to comparing two HTML documents is the historical diff viewer, which uses ve.init.mw.DiffLoader to load two revisions from Parsoid. It requires most of the VE codebase (and extensions) to parse the document, and render the diff. (Sepcifically ve.dm.Converter, and all the ve.dm.*Nodes/Annotations which the converter calls out to).

The example you link to is the closest we have to a demo of tree diffing outside of VE right now, and most of our future efforts are going to be focused on the VE integration, but we're always interested to see downstream uses of our libraries!

Deskana renamed this task from VisualDiff Help to Make the visual diff functionality in the visual editor a standalone tool.May 29 2018, 6:49 PM
Deskana triaged this task as Low priority.
Deskana added a project: Epic.
Deskana moved this task from To Triage to Freezer on the VisualEditor board.

Wow, that's a big compliment! Thank you! Unfortunately, this is a lot of work, and it's not something we're going to get around to doing for a very long time.

That's understandable. I'm using CKEditor 5 in my app, and they have their own data model and virtual DOM. A standalone tool does seem the best for a generic solution. Almost every diff tool out there assumes the content you're diffing is strings but the need is certainly out there to diff HTML. Daisy diff is difficult to integrate and very old, and other packages like nokogiri-diff are broken out of the box. I'll come back and comment if I develop my own solution.

Cheers!

Vvjjkkii renamed this task from Make the visual diff functionality in the visual editor a standalone tool to q1caaaaaaa.Jul 1 2018, 1:10 AM
Vvjjkkii raised the priority of this task from Low to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot renamed this task from q1caaaaaaa to Make the visual diff functionality in the visual editor a standalone tool.Jul 2 2018, 3:06 PM
CommunityTechBot lowered the priority of this task from High to Low.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added a subscriber: Aklapper.