Problem/Motivation

I used CKEditor 4 module of Core in the past. I switched to CKEditor 5. It works well, but leads to a major regression.

The HTML is now saved as a single line. This means that revision comparison (via Diff module) have become impossible. Every change you make leads to the single line HTML being different, and the entire line being highlighted as a difference. Good luck figuring out what has changed then.

I looked at CKEditor configuration, Diff configuration, but nothing seems to be there to solve this. Also, I checked the database, and the HTML is now really saved as a single line there, while before it was stored in multiple lines, matching what CKEditor shows when viewing the source of the content.

I reported this for the CKEditor 5 core module at https://www.drupal.org/project/drupal/issues/3351660, but there are no replies.

Steps to reproduce

Use CKEditor 5, create a node, then change the node, and compare the revisions with the Diff module.

Proposed resolution

An ideal solution would be to store in the database the multiline HTML that is also shown by CKEditor in its Source view, as it did with CKEditor 4. That is the aim of https://www.drupal.org/project/drupal/issues/3351660. Maybe the Diff community could way in there, to create more interest?

For the Diff module itself, it would be great if If the XML could be pretty printed, and then compared.

Comments

dhendriks created an issue. See original summary.

luke.leber’s picture

Hey @dhendriks - you might consider checking out https://www.drupal.org/project/diff_plus for some of the more bleeding edge support for things.

We ran into shortcomings and spun this up to work around things like HTML5 support, layout builder, etc.

The intention is to battle test some stuff and get them absorbed into diff proper, but we'll see :-).

bingol@ciandt.com’s picture

StatusFileSize
new1.83 KB
dhendriks’s picture

I've been trying out Diff Plus for a few months, and I like it.

I also just tested the patch from #3, with Drupal 10.2.1, with Diff 8.x-1.1 and Diff Plus 1.0.0. It also works well.

bkosborne’s picture

See also #3351660: [DrupalHtmlEngine] CKEditor 5 saves content as single line HTML making revision diffing impossible which should help alleviate this a bit, by setting the default comparison method to strip tags.

acbramley’s picture

Status: Active » Closed (won't fix)

This looks like something that needs to be fixed in core, not Diff.

leo liao’s picture

StatusFileSize
new1.76 KB

We will continue to use this solution in 2.0.0 beta4 until a better solution is available.

ahhua’s picture

StatusFileSize
new1.98 KB

update the #3 patch for multi-language content.

pere orga’s picture

Project: Diff » Drupal core
Version: 8.x-1.1 » 11.3.x-dev
Component: Diff builder plugins » ckeditor5.module
Priority: Major » Normal
Status: Closed (won't fix) » Active

Moving it to Drupal core, as per #6

pere orga’s picture

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.