Problem/Motivation

Testing the upgrade from CKEditor 4 to 5 on Drupal 9.3 and with Entity Embed, according to the steps on drupal.org/test-cke-4-to-5.
The site was initially build in Drupal 6 or so, and content got migrated and updated over time.

The text formats were probably touched for the last time when the site got migrated from Drupal 7 to 8, and the ticking and sorting of filters were probably done because "they were always set up like that" and "it's not broken so there's no need to change anything".

The site uses three different buttons to embed three different media types into a text field. Users can choose one of several pre-selected display modes, can choose alignment, and add additional captions.

Testing the upgrade path

I encountered three rounds of error messages before I was able to save the text format configuration again.




I fixed them without knowing whether it would break anything, just so that I would be able to save the configuration. A message that specific errors are to be expected, and that changing the configuration is okay, would be useful.

Also, what happens if the configuration pages are not changed and resaved?

Testing existing content

Everything tested still works and looks as expected.

Comments

ifrik created an issue. See original summary.

cilefen’s picture

Title: CKE5 and Entity Embed: error messages » CKE5 and Entity Embed: CKEditor-specific error messages about text filters could be clearer
Version: 9.3.x-dev » 9.4.x-dev
Category: Bug report » Task

Changing the configuration is not necessarily ok depending on how a given site has been using a text format.

wim leers’s picture

Issue tags: +drupaldevdays

THANK YOU!!!!! 🙏🥳

Does CKEditor 5 work as expected?

Everything tested still works and looks as expected.

🥳

Does switching to CKEditor 5 in the admin UI work as expected?

Not quite, clearly. 😓

You got 3 error message:

  1. CKEditor 5 only works with HTML-based text formats. The "Convert line breaks to HTML (i.e. <br> and <p>)" (filter_autop) filter implies this text format is not HTML anymore.
  2. The Display embedded entities filter needs to be placed after the following filters: Align images, Caption images.
  3. CKEditor 5 only works with HTML-based text formats. The "Convert URLs into links" (filter_url) filter implies this text format is not HTML anymore.

This is only happening because the text format was actually not correctly configured to use CKEditor 4 😅🙈

  • A. CKEditor 4 is not guaranteed to work correctly because of the first (filter_autop) and third (filter_url) enabled text filters, but you happened to never run into problems. With CKEditor 5, we're now explicitly validating this, which is why you're being informed of it.
  • B. The entity_embed filter (second problem) is a validation error that is coming from entity_embed_filter_format_edit_form_validate(), not CKEditor 5. It's also been configured incorrectly all this time I'm afraid 😅 You're lucky you haven't run into issues!

Conclusion

Maybe we should special case text formats that are already using CKEditor 4 and trigger these kinds of fundamental compatibility errors? But still, that could/will cause problems down the line. So it feels wrong to just ignore it. 😬

But really, there isn't any other way to solve this other than … automatically dropping filters that violate the fundamental compatibility. We have to assume that the existing text format's incompatible filters were already not having any effect. Otherwise we cannot generate a compatible CKEditor 5 configuration. Will create a new issue for that.

ifrik’s picture

Issue summary: View changes
ifrik’s picture

After f2f conversation during DevDays:

The configuration for text formats was probably not touched since the site was migrated from D7 to D8, so any validation error would not have been noticed by the sitebuilder.
When trying to resave the configuration for the text format, one of the error messages also appears for CKEditor 4:
The Display embedded entities filter needs to be placed after the following filters: Align images, Caption images.
The other two errors about URL conversion and about p and br tags does not appear.

wim leers’s picture

Conclusion

Maybe we should special case text formats that are already using CKEditor 4 and trigger these kinds of fundamental compatibility errors? But still, that could/will cause problems down the line. So it feels wrong to just ignore it. 😬

But really, there isn't any other way to solve this other than … automatically dropping filters that violate the fundamental compatibility. We have to assume that the existing text format's incompatible filters were already not having any effect. Otherwise we cannot generate a compatible CKEditor 5 configuration. Will create a new issue for that.

Followed through on this: #3273312: Upgrading from CKEditor 4 for a text format that has FilterInterface::TYPE_MARKUP_LANGUAGE filters enabled.

wim leers’s picture

Category: Task » Support request
Issue tags: +Upgrade path

Since I extracted the concrete work out of this (excellent!) report, I'm recategorizing this as a support request!

wim leers’s picture

Issue tags: -drupaldevdays +ddd2022
wim leers’s picture

Status: Active » Fixed

#3273312: Upgrading from CKEditor 4 for a text format that has FilterInterface::TYPE_MARKUP_LANGUAGE filters enabled has been fixed, which removes 2 of the 3 messages shown in the screenshots in the issue summary! 👍

The entity_embed message is unrelated to CKEditor 5, that's provided by the https://www.drupal.org/project/entity_embed module.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.