Problem/Motivation
Postponed on:
#3238333: Roadmap to CKEditor 5 stable in Drupal 9— with only a single Drupal-actionable stable blocker left (and 5 upstream ones, of 4 are already solved, and we'll get in the next CKEditor 5 update that will be released in 8 days), release manager @catch indicated at #3304326-10: Deprecate CKEditor 4 module in 9.5 that we can proceed here 👍- #3270831: Make the CKEditor 4 → 5 upgrade path work even when the CKEditor 4 module is removed
Once the CKEditor 5 module is stable, it needs to replace the CKEditor 4 module in the Standard profile.
Proposed resolution
- Create new basic and full HTML editor default config for CKEditor 5.
- Replace Standard's editor default config with the CKEditor 5 versions.
- Replace
ckeditorwithckeditor5in the Standard requirements. - Update StandardTest to test CKEditor 5 filter formats instead of CKEditor 4 ones.
Remaining tasks
- Wait for CKEditor 5 to be stable to actually commit this.
Decide what to do about <code> tags for Basic HTML. (See #4.)See #12.Decide what to do aboutSee #12.<span>tags for Basic HTML. (See #4.)Figure out what to do for the Full HTML format. (See #4.)See #12. #3268306: [GHS] Custom/unofficial HTML tags not retained: <drupal-media>, <drupal-entity>, <foobar> was one of the last stable blockers needing an upstream fix, it's fixed now!
User interface changes
CKEditor 5 is enabled by default when a new site is installed with the Standard profile.
- Before
-


- After
-


API changes
N/A
Data model changes
Standard default Text Editor config is replaced with CKEditor 5 formats.
Release notes snippet
CKEditor 5 is now used as the default WYSIWYG editor in the Standard profile instead of CKEditor 4.
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | interdiff_38-44.txt | 510 bytes | bnjmnm |
| #44 | 3271097-44.patch | 18.26 KB | bnjmnm |
| #38 | 3271097-38.patch | 18.24 KB | bnjmnm |
| #38 | interdiff_33-38.txt | 1.01 KB | bnjmnm |
| #33 | 3271097-33.patch | 18.23 KB | wim leers |
Issue fork drupal-3271097
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
xjmComment #4
xjmI made a first attempt at exporting new Editor config and updating
StandardTest. A couple notes:<span>tags to the allowed tags for source editing that aren't available via the UI, CKEditor 5 raises the following error:...but that's not quite the same thing. A generic
<span>has much broader use (for adding classes, metadata, etc.) than language formatting. Not sure what do do there; maybe this is something that should be fixed in CKEditor 5?Comment #5
xjmComment #6
xjmI think this might also be blocked on #3270831: Make the CKEditor 4 → 5 upgrade path work even when the CKEditor 4 module is removed.
Comment #7
xjmThe test failures are:
And several errors like:
...which is weird because this config was generated by CKEditor 5 based on existing CKEditor 4 config.
Comment #8
wim leersThis seems impossible, because
settings.toolbar.rowsdoes not exist in CKEditor 5.Investigated … aha, looks like this is why:
(in
\Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::setUp())👆 This is modifying an existing
Editorconfig entity and saving it as a new one, purely for upgrade path testing purposes. But CKEditor 4 is not available anymore, and hence nor is its schema.Updating to
$basic_html_editor_with_media_embed->trustData()->save();is also insufficient, becausecore/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.phpdoes not care about that. You'll need to disable config schema checking during::setUp()and re-enable it afterwards.Comment #9
xjmBut this issue does not include any new tests; those fails are existing test coverage. I'm assuming it's making wrong assumptions about the config? We need CKEditor 5's test suite to pass under four conditions:
Maybe the default config being removed from Standard to either CKEditor 4 or to test fixtures? But we still should have test coverage for the real CKEditor 5 default config that will be in Standard going forward.
I'll look into the default config exports more.
Comment #10
wim leersYes and no.
Comment #12
wim leersNow that CKE5 is almost stable, time to revisit this! 🥳
#4:
<pre>tag too — that's required for blocks of code instead of just inline code.)We should first do #3270831: Make the CKEditor 4 → 5 upgrade path work even when the CKEditor 4 module is removed. Then we should update this MR. The pain points of #4 are a thing of the past.
Comment #13
xjmI think this can be unpostponed now?
Comment #14
wim leersIsn't this still blocked on #3268306: [GHS] Custom/unofficial HTML tags not retained: <drupal-media>, <drupal-entity>, <foobar> and #3222756: Allow using images from external source? And more generally speaking, isn't this blocked on the CKEditor 5 module itself being marked stable?
OTOH, it sure would be good to have this merge request/patch green before marking CKEditor 5 stable, maybe that's what you're looking for? 😊
Comment #15
bnjmnmThis is still blocked on #3222756: Allow using images from external source but the steps to get this green shouldn't be impacted by that issue.
Comment #16
wim leersPer @catch's comment at #3304326-10: Deprecate CKEditor 4 module in 9.5, I think we can consider this unblocked! 👍
In fact, this is now a hard blocker for that issue.
Review
🤯 Is this change really necessary? This seems unrelated?
These changes are also unrelated; they're de facto reverting #3278636: HTMLRestrictions::fromString() bug: multiple occurrences of same tag results in only last one being respected, which landed yesterday.
🤓 Unnecessary change.
🤔 Why this change?
🤩👏
😊 Also accidental.
👍
🤔 AFAICT this should be
false? That's also what the test expectation for\Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTestfor Standard's unchangedbasic_htmlis! See the top of\Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::provider().🐛 We cannot change these — I know that it's really weird. See
\Drupal\filter\Entity\FilterFormat::$rolesand\Drupal\filter\Entity\FilterFormat::toArray()🤷♀️ See #3167198: Deprecate the 'roles' property of text formats and remove it from the UI — it's a known problem.🐛 I know that this happens automatically by just saving this config entity again (either through the API or the UI). But note that it says
status: false, so it's safe to omit. Yes, this too is weird. But adding this is more confusing than it's worth.This too is a known problem: #2385047: Remove disabled filters from text format configuration (reviewed that issue thanks to being made aware of it once again by this!).
Comment #17
bnjmnmAddresses #16
Re #16.4
The tests were failing despite being identical elements because of differences in whitespace. getHtml() makes that predictable.
Comment #18
wim leersFrom 28 KB to 23! 👍
Still seeing unrelated changes in these files? 🤔 I think all of these changes can be dropped?
Comment #19
bnjmnmApparently 80% of the 9.4 MR I turned into a patch wasn't needed. I think this prunes everything?
Comment #21
wim leers28 → 23 → 18 KB! 😄
✅ Explained at the bottom of #17.
👍 This is the way that the automatic upgrade path placed it. And that's fine — it's the automatic upgrade path.
🤓🤔 But I'm wondering if we want to place the
codebutton in a different place, so that it's not quite on its own? Perhaps in the same group asheading? Wouldn't that be better for usability?🐛 Let's remove
<ol reversed>— that's a net addition we don't want.Comment #22
bnjmnmComment #24
wim leersDoing some manual testing prior to RTBC'ing 🤓
Comment #26
wim leersManual test
👍 CKEditor 5 works fine for Basic HTML & Full HTML!
(Added before & after screenshots for both to the issue summary.)
Re-saving both Basic HTML & Full HTML in the config UI should result in empty config diffs
(Other than A)
uuidand_core.default_config_hashbeing added, B)rolesnot being exported infilter_formatconfig — see #3167198: Deprecate the 'roles' property of text formats and remove it from the UI for that, C) even disabled filters being exported infilter_formatconfig — see #2385047: Remove disabled filters from text format configuration for that.)Diff analysis:
This is the only problematic difference — that means this is missing from the patch!
Conclusion
Per @catch's comment at #3304326-10: Deprecate CKEditor 4 module in 9.5, we can consider this not blocked on #3238333: Roadmap to CKEditor 5 stable in Drupal 9, so …
RTBC! 🥳I was going to add the bit pointed out in the diff analysis … but apparently in the mean time there is an unexpected test failure, specifically on the line that was changed:
Can we try reverting this?
Comment #27
wim leersComment #28
bnjmnmThe changes made to CKEditor5AllowedTags test do not appear necessary anymore. I suspect the mix of old code in earlier patches made that change necessary for tests to pass.
Comment #29
phenaproximaWim "Eagle Eye" Leers has already reviewed this one up and down, with his legendary ability to spot defects, and would have RTBCed this but for the test failure. I've confirmed his suggestion in #26 has been implemented. Tests are passing. What else we got? Probably nothing.
I therefore humbly bestow RTBC.
Comment #30
wim leers#28: I suspect the same! If not, we'd have a random failure scenario on our hands, which thankfully is not the case! 😄🥳
#29: Well this 🦅👁 is mostly just using
git diffto spot these things and … the one thing that I said in #26 is missing from the patch is still missing 🙈I see that
\Drupal\Tests\standard\Functional\StandardTestis testing config schema conformance. Since Text Editors using CKEditor 5 are the first config entities in Drupal core that can be fully validated … I'm extending the spirit of that test to also do config entity validation where possible (so for now only Text Editor config entities using CKEditor 5).Adding such test coverage will actually show that what I said in #29 is a problem: it shows that the exported config in the Standard install profile fails validation.
Comment #31
wim leersTest coverage — expected output:
Comment #33
wim leersAdding what I suggested in #26 should fix the failure! 🤞
Comment #34
phenaproximaAh, okay. I misunderstood #26 and thought you were only asking for that one line in the test to be reverted. I don't have the larger context for this issue.
That said, the improved test coverage makes a lot of sense to me, now that I know more about this fancy (but exciting!) config validation stuff you're doing. We've got a fail patch proving that the test actually tests it, and the latest patch is corrected. Restoring RTBC.
Comment #35
wim leersJust realized something!
These are changing in #3222756: Allow using images from external source … so we probably should hold off committing this until that lands.
Alternatively, we can commit this today, and then we'll need to update the default configuration in
core/profiles/standardagain in that issue.Either way, the great news is that thanks to the validation added in #31, that both commit orders are safe: we will always be certain that the default formats + editors in Standard (that use CKEditor 5) are 100% valid 🤓😄
So actually … I think that's a reason to just go ahead here 🤓
Comment #36
lauriiiShould we add
<span>back to the list given that it should be now possible? IMO having span on it's own here does not make a lot of sense but that would make the CKEditor 5 configuration 100% equivalent to the CKEditor 4 configuration.Comment #37
wim leersGREAT catch! I totally missed that in my reviews! 🙈 That is possible since #3273983: Do not assume that plugin supporting <tag attr> also supports <tag> in SourceEditingRedundantTags and upgrade path. I have no idea why it's not like that in this patch 😅
Comment #38
bnjmnmnow
<span>s in a place where it worksnow press save
think about upgrading wonder why you haven't before
just
<span>Comment #40
bnjmnm🤦♂️🤦♂️
'The current CKEditor 5 build requires the following elements and attributes: <br><code><br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <* dir="ltr rtl" lang> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>The following elements are not supported:
<span>'Is #33 fine to work with or do we set things up to accommodate span?
Comment #41
lauriiiI think you’ll have to also configure source editing to enable support for
<span>.Comment #42
wim leersIndeed. The validation added in #31 is doing its job! :)
Comment #43
wim leersIOW: this is missing
<span>.(This actually works correctly when the upgrade path is used, the first test case in
\Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::provider()proves this. I bet that what happened is that a manual config change was made — that's the only way for the Text Editor & Text Format to get out of sync. That makes sense when trying to quickly address feedback 😊)Comment #44
bnjmnmComment #45
wim leersThird time's a charm! 🚀
Comment #49
lauriiiCommitted 9ca6256 and pushed to 10.1.x. Also cherry-picked to 10.0.x and 9.5.x. Thanks!
Comment #50
wim leersThis unblocked #3304326: Deprecate CKEditor 4 module in 9.5! 🥳