Problem/Motivation

Postponed on:

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 ckeditor with ckeditor5 in the Standard requirements.
  • Update StandardTest to test CKEditor 5 filter formats instead of CKEditor 4 ones.

Remaining tasks

  1. Wait for CKEditor 5 to be stable to actually commit this.
  2. Decide what to do about <code> tags for Basic HTML. (See #4.) See #12.
  3. Decide what to do about <span> tags for Basic HTML. (See #4.) See #12.
  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.

Issue fork drupal-3271097

Command icon 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

xjm created an issue. See original summary.

xjm’s picture

Title: Replace CKEditor 4 with CKEditor 5 in the Standard profile and StandardTest » [P-1] Replace CKEditor 4 with CKEditor 5 in the Standard profile and StandardTest
Issue summary: View changes
Related issues: +#3238333: Roadmap to CKEditor 5 stable in Drupal 9

xjm’s picture

I made a first attempt at exporting new Editor config and updating StandardTest. A couple notes:

  1. The CKEditor 4 Editor configuration allowed <code> tags in the souce, but did not provide UI options for them. In CKEditor 5, we can't do this; either we use the available code formatting buttons or we don't. I was unsure whether it'd be better to more closely match the user experience or the allowed tags. Code snippets are a very developer-centric feature so I've left that out of Basic HTML for now.
     
  2. If I try to add <span> tags to the allowed tags for source editing that aren't available via the UI, CKEditor 5 raises the following error:

    The following tag(s) are already supported by available plugins and should not be added to the Source Editing "Manually editable HTML tags" field. Instead, enable the following plugins to support these tags: Language ().

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

  3. Full HTML is... not even remotely Full HTML. While deprecating Full HTML is desirable in the long-term, it's way out of scope here. I think this has to do with something called "GHS" that's a CKEditor 5 feature under development but I don't know how to add it to my editor config or if it's even ready yet.
xjm’s picture

Issue summary: View changes
xjm’s picture

Title: [P-1] Replace CKEditor 4 with CKEditor 5 in the Standard profile and StandardTest » [P-2] Replace CKEditor 4 with CKEditor 5 in the Standard profile and StandardTest
Issue summary: View changes
Related issues: +#3270831: Make the CKEditor 4 → 5 upgrade path work even when the CKEditor 4 module is removed
xjm’s picture

The test failures are:

1) Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5AllowedTagsTest::testFullHtml
Behat\Mink\Exception\ExpectationException: The string "NASA is an acronym." was not found anywhere in the HTML response of the current page.

/var/www/html/vendor/behat/mink/src/WebAssert.php:768
/var/www/html/vendor/behat/mink/src/WebAssert.php:324
/var/www/html/core/tests/Drupal/Tests/WebAssert.php:524
/var/www/html/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php:473
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:726

And several errors like:

1) Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::test with data set "basic_html can be switched to CKEditor 5 without problems (3 upgrade messages)" ('basic_html', array(), array(array(array('bold', 'italic', '|', 'link', '|', 'bulletedList', 'numberedList', '|', 'blockQuote', 'uploadImage', '|', 'heading', '|', 'sourceEditing', '|', 'code', 'textPartLanguage')), array(array(array('', '', '', '', '', '', '', '', '', '', '', '', '')), array(array('heading2', 'heading3', 'heading4', 'heading5', 'heading6')), array(true), array('un'))), '', array(), array('The following plugins were en....', 'The following tags were permi...d&gt;.', 'This format's HTML filters in...d&gt;.'))
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for editor.editor.basic_html_with_media_embed with the following errors: editor.editor.basic_html_with_media_embed:settings.toolbar.rows missing schema

/var/www/html/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php:94
/var/www/html/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:142
/var/www/html/core/lib/Drupal/Core/Config/Config.php:229
/var/www/html/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:274
/var/www/html/core/lib/Drupal/Core/Entity/EntityStorageBase.php:524
/var/www/html/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:253
/var/www/html/core/lib/Drupal/Core/Entity/EntityBase.php:339
/var/www/html/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:607
/var/www/html/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php:159
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:726

...which is weird because this config was generated by CKEditor 5 based on existing CKEditor 4 config.

wim leers’s picture

...which is weird because this config was generated by CKEditor 5 based on existing CKEditor 4 config.

This seems impossible, because settings.toolbar.rows does not exist in CKEditor 5.

Investigated … aha, looks like this is why:

    // Add "insert media from library" button to CKEditor 4 configuration, the
    // pre-existing toolbar item group labeled "Media".
    $settings['toolbar']['rows'][0][3]['items'][] = 'DrupalMediaLibrary';
    $basic_html_editor_with_media_embed->setSettings($settings);
    $basic_html_editor_with_media_embed->save();

(in \Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::setUp())

👆 This is modifying an existing Editor config 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, because core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php does not care about that. You'll need to disable config schema checking during ::setUp() and re-enable it afterwards.

xjm’s picture

Updating to $basic_html_editor_with_media_embed->trustData()->save(); is also insufficient, because core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php does not care about that. You'll need to disable config schema checking during ::setUp() and re-enable it afterwards.

But 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:

  1. CKEditor 4 is in Standard and CKEditor 5 is in core.
  2. CKEditor 5 is in Standard, but CKEditor 4 is still in core as a stable module.
  3. CKEditor 5 is in Standard, but CKEditor 4 is in core as a deprecated module.
  4. CKEditor 5 is in Standard, and CKEditor 4 has been fully removed to contrib.

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.

wim leers’s picture

But 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?

Yes and no.

  1. The current tests are correct.
  2. But the current tests also assume that they can create new text editor config entities (to simulate different upgrade path scenarios!) without violating config schema.
  3. Since this MR is removing the config schema for CKEditor 4 … that assumption no longer is true.
  4. Therefore it's this MR's responsibility to remove that assumption … because it's this MR that's removing the CKEditor 4 module. (Of course, you can create a separate issue for it too, but then we have no way to verify that it actually works — only the MR that removes the module can test that.)

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

Now that CKE5 is almost stable, time to revisit this! 🥳

#4:

  1. Agreed that code snippets are developer-centric. Most sites don't need it. Also, since #3263384: Add ckeditor5-code-block package and CodeBlock plugin, it's become easy to add it! (Note that that adds support for the <pre> tag too — that's required for blocks of code instead of just inline code.)
  2. ✅ This was fixed recently in #3273983: Do not assume that plugin supporting <tag attr> also supports <tag> in SourceEditingRedundantTags and upgrade path.
  3. There have been many fixes to the "GHS" functionality since then. There is one known remaining stable blocker: #3268306: [GHS] Custom/unofficial HTML tags not retained: <drupal-media>, <drupal-entity>, <foobar> — but that too has been fixed upstream already and is coming in the next CKEditor 5 release! 🥳

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.

xjm’s picture

Status: Postponed » Active

I think this can be unpostponed now?

wim leers’s picture

Isn'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? 😊

bnjmnm’s picture

StatusFileSize
new28.01 KB

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

wim leers’s picture

Title: [P-2] Replace CKEditor 4 with CKEditor 5 in the Standard profile and StandardTest » Replace CKEditor 4 with CKEditor 5 in the Standard profile and StandardTest
Status: Active » Needs work
Issue tags: +blocker
Related issues: +#3167198: Deprecate the 'roles' property of text formats and remove it from the UI, +#2385047: Remove disabled filters from text format configuration

Per @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

  1. +++ b/core/lib/Drupal/Core/Config/FileStorage.php
    @@ -154,7 +154,10 @@ public function write($name, array $data) {
    -      throw new StorageException('Failed to write configuration file: ' . $target);
    +      throw new StorageException('Failed to write configuration file: ' . $this->getFilePath($name));
    +    }
    +    else {
    +      $this->getFileSystem()->chmod($target);
    

    🤯 Is this change really necessary? This seems unrelated?

  2. @@ -629,8 +629,7 @@ media_media:
         class: Drupal\ckeditor5\Plugin\CKEditor5Plugin\Media
         elements:
           - <drupal-media>
    -      - <drupal-media data-entity-type data-entity-uuid alt>
    -      - <drupal-media data-view-mode>
    +      - <drupal-media data-entity-type data-entity-uuid alt data-view-mode>
         conditions:
           filter: media_embed
    <snip>
    -    return $subset;
    +    // @todo Simplify in https://www.drupal.org/project/drupal/issues/3278636, that will allow removing all uses of HTMLRestrictions in this class.
    +    return array_merge(['<drupal-media>'], $subset->toCKEditor5ElementsArray());
    

    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.

  3. +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
    @@ -465,7 +465,6 @@ public function testFullHtml() {
    -
    

    🤓 Unnecessary change.

  4. +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
    @@ -507,7 +506,7 @@ public function testFullHtml() {
    -    $assert_session->responseContains('<p><a foo="bar" hreflang="en" href="https://example.com"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a></p>');
    +    $this->assertSame('<a href="https://example.com" foo="bar" hreflang="en"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a>', $page->find('css', 'article p')->getHtml());
    

    🤔 Why this change?

  5. +++ b/core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php
    @@ -84,22 +84,22 @@ protected function setUp(): void {
    -      Yaml::parseFile('core/profiles/standard/config/install/filter.format.full_html.yml')
    +      Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/filter.format.full_html.yml')
         )
           ->setSyncing(TRUE)
           ->save();
         Editor::create(
    -      Yaml::parseFile('core/profiles/standard/config/install/editor.editor.full_html.yml')
    +      Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.full_html.yml')
         )->save();
     
    -    $basic_html_format = Yaml::parseFile('core/profiles/standard/config/install/filter.format.basic_html.yml');
    +    $basic_html_format = Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/filter.format.basic_html.yml');
         FilterFormat::create($basic_html_format)->save();
         Editor::create(
    -      Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
    +      Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
         )->save();
     
         FilterFormat::create(
    -      Yaml::parseFile('core/profiles/standard/config/install/filter.format.restricted_html.yml')
    +      Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/filter.format.restricted_html.yml')
         )->save();
     
         $allowed_html_parents = ['filters', 'filter_html', 'settings', 'allowed_html'];
    @@ -113,7 +113,7 @@ protected function setUp(): void {
    
    @@ -113,7 +113,7 @@ protected function setUp(): void {
         Editor::create(
           ['format' => 'basic_html_without_h4_h6']
           +
    -      Yaml::parseFile('core/profiles/standard/config/install/editor.editor.basic_html.yml')
    +      Yaml::parseFile('core/modules/ckeditor5/tests/fixtures/ckeditor4_config/editor.editor.basic_html.yml')
    

    🤩👏

  6. +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
    @@ -266,29 +266,12 @@ public function getHTMLRestrictions() {
    -      // All attributes are already allowed on this tag, this is the most
    -      // permissive configuration, no additional processing is required.
    -      if (isset($restrictions['allowed'][$tag]) && $restrictions['allowed'][$tag] === TRUE) {
    -        continue;
    -      }
    

    😊 Also accidental.

  7. +++ b/core/modules/help/tests/src/Functional/HelpTest.php
    @@ -149,6 +149,12 @@ protected function verifyHelp($response = 200) {
    +        // The help for CKEditor 5 intentionally has escaped '<' so leave this
    +        // iteration before the assertion below.
    +        if ($module === 'ckeditor5') {
    +          continue;
    +        }
             // Ensure there are no escaped '<' characters.
             $this->assertSession()->assertNoEscaped('<');
    

    👍

  8. +++ b/core/profiles/standard/config/install/editor.editor.basic_html.yml
    @@ -4,42 +4,56 @@ dependencies:
    +      reversed: true
    

    🤔 AFAICT this should be false? That's also what the test expectation for \Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest for Standard's unchanged basic_html is! See the top of \Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::provider().

  9. +++ b/core/profiles/standard/config/install/filter.format.basic_html.yml
    @@ -6,8 +6,6 @@ dependencies:
    -roles:
    -  - authenticated
    
    +++ b/core/profiles/standard/config/install/filter.format.full_html.yml
    @@ -6,8 +6,6 @@ dependencies:
    -roles:
    -  - administrator
    

    🐛 We cannot change these — I know that it's really weird. See \Drupal\filter\Entity\FilterFormat::$roles and \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.

  10. +++ b/core/profiles/standard/config/install/filter.format.full_html.yml
    @@ -33,3 +31,12 @@ filters:
    +  filter_html:
    +    id: filter_html
    +    provider: filter
    +    status: false
    +    weight: -10
    +    settings:
    +      allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <s> <sup> <sub> <img src alt data-entity-type data-entity-uuid data-align data-caption> <table> <caption> <tbody> <thead> <tfoot> <th> <td> <tr> <hr> <p> <h1> <pre>'
    +      filter_html_help: true
    +      filter_html_nofollow: false
    

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

bnjmnm’s picture

StatusFileSize
new23.23 KB
new8.29 KB

Addresses #16
Re #16.4
The tests were failing despite being identical elements because of differences in whitespace. getHtml() makes that predictable.

wim leers’s picture

From 28 KB to 23! 👍

--- a/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php
+++ b/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php
…
--- a/core/modules/ckeditor5/tests/src/Unit/SourceEditingPluginTest.php
+++ b/core/modules/ckeditor5/tests/src/Unit/SourceEditingPluginTest.php
…

Still seeing unrelated changes in these files? 🤔 I think all of these changes can be dropped?

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new18.05 KB

Apparently 80% of the 9.4 MR I turned into a patch wasn't needed. I think this prunes everything?

The last submitted patch, 17: 3271097-17.patch, failed testing. View results

wim leers’s picture

Status: Needs review » Needs work

28 → 23 → 18 KB! 😄

  1. +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
    @@ -507,7 +507,7 @@ public function testFullHtml() {
    -    $assert_session->responseContains('<p><a foo="bar" hreflang="en" href="https://example.com"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a></p>');
    +    $this->assertSame('<a href="https://example.com" foo="bar" hreflang="en"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a>', $page->find('css', 'article p')->getHtml());
    

    ✅ Explained at the bottom of #17.

  2. +++ b/core/profiles/standard/config/install/editor.editor.basic_html.yml
    @@ -4,42 +4,56 @@ dependencies:
    +      - '|'
    +      - code
    

    👍 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 code button in a different place, so that it's not quite on its own? Perhaps in the same group as heading? Wouldn't that be better for usability?

  3. +++ b/core/profiles/standard/config/install/filter.format.basic_html.yml
    @@ -15,7 +15,7 @@ filters:
    -      allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <span> <img src alt height width data-entity-type data-entity-uuid data-align data-caption>'
    +      allowed_html: '<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type reversed> <strong> <em> <code> <li> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>'
    

    🐛 Let's remove <ol reversed> — that's a net addition we don't want.

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new18.03 KB
new1.57 KB

The last submitted patch, 19: 3271097-19.patch, failed testing. View results

wim leers’s picture

Assigned: Unassigned » wim leers

Doing some manual testing prior to RTBC'ing 🤓

Status: Needs review » Needs work

The last submitted patch, 22: 3271097-22.patch, failed testing. View results

wim leers’s picture

Issue summary: View changes
StatusFileSize
new3.4 KB
new118.15 KB
new119.31 KB
new126.12 KB
new124.29 KB
new676 bytes

Manual 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) uuid and _core.default_config_hash being added, B) roles not being exported in filter_format config — see #3167198: Deprecate the 'roles' property of text formats and remove it from the UI for that, C) even disabled filters being exported in filter_format config — see #2385047: Remove disabled filters from text format configuration for that.)

Diff analysis:

+++ b/core/profiles/standard/config/install/editor.editor.full_html.yml
@@ -41,6 +44,9 @@ settings:
+    ckeditor5_list:
+      reversed: true
+      startIndex: true

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:

+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
@@ -507,7 +507,7 @@ public function testFullHtml() {
-    $assert_session->responseContains('<p><a foo="bar" hreflang="en" href="https://example.com"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a></p>');
+    $this->assertSame('<a href="https://example.com" foo="bar" hreflang="en"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a>', $page->find('css', 'article p')->getHtml());

Can we try reverting this?

wim leers’s picture

Assigned: wim leers » Unassigned
bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new16.96 KB
new1.06 KB

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

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Wim "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.

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

#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 diff to 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\StandardTest is 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.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests
Related issues: +#2164373: [META] Untie config validation from form validation — enables validatable Recipes, decoupled admin UIs …
StatusFileSize
new1.9 KB
new18.17 KB

Test coverage — expected output:

There was 1 failure:

1) Drupal\Tests\standard\Functional\StandardTest::testStandard
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
-Array &0 ()
+Array &0 (
+    0 => 'Configuration for the enabled plugin "<em class="placeholder">List</em>" (<em class="placeholder">ckeditor5_list</em>) is missing.'
+)

Status: Needs review » Needs work

The last submitted patch, 31: 3271097-31.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new676 bytes
new18.23 KB

Adding what I suggested in #26 should fix the failure! 🤞

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Ah, 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.

wim leers’s picture

Just realized something!

+++ b/core/profiles/standard/config/install/editor.editor.basic_html.yml
@@ -4,42 +4,55 @@ dependencies:
+      - uploadImage

+++ b/core/profiles/standard/config/install/editor.editor.full_html.yml
@@ -4,50 +4,48 @@ dependencies:
+      - uploadImage

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/standard again 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 🤓

lauriii’s picture

+++ b/core/profiles/standard/config/install/filter.format.basic_html.yml
@@ -15,7 +15,7 @@ filters:
-      allowed_html: '<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <span> <img src alt height width data-entity-type data-entity-uuid data-align data-caption>'
+      allowed_html: '<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <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>'

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

wim leers’s picture

Status: Reviewed & tested by the community » Needs work

GREAT 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 😅

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new1.01 KB
new18.24 KB

now <span>s in a place where it works

now press save
think about upgrading wonder why you haven't before

just <span>

Status: Needs review » Needs work

The last submitted patch, 38: 3271097-38.patch, failed testing. View results

bnjmnm’s picture

🤦‍♂️🤦‍♂️
'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?

lauriii’s picture

I think you’ll have to also configure source editing to enable support for <span>.

wim leers’s picture

Indeed. The validation added in #31 is doing its job! :)

wim leers’s picture

+++ b/core/profiles/standard/config/install/editor.editor.basic_html.yml
@@ -4,42 +4,55 @@ dependencies:
+    ckeditor5_sourceEditing:
+      allowed_tags:
+        - '<cite>'
+        - '<dl>'
+        - '<dt>'
+        - '<dd>'
+        - '<a hreflang>'
+        - '<blockquote cite>'
+        - '<ul type>'
+        - '<ol start type>'
+        - '<h2 id>'
+        - '<h3 id>'
+        - '<h4 id>'
+        - '<h5 id>'
+        - '<h6 id>'

IOW: 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 😊)

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new18.26 KB
new510 bytes
wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Third time's a charm! 🚀

  • lauriii committed 9ca6256 on 10.1.x
    Issue #3271097 by bnjmnm, xjm, Wim Leers, phenaproxima: Replace CKEditor...

  • lauriii committed c61a652 on 10.0.x
    Issue #3271097 by bnjmnm, xjm, Wim Leers, phenaproxima: Replace CKEditor...

  • lauriii committed 9600a0b on 9.5.x
    Issue #3271097 by bnjmnm, xjm, Wim Leers, phenaproxima: Replace CKEditor...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed 9ca6256 and pushed to 10.1.x. Also cherry-picked to 10.0.x and 9.5.x. Thanks!

wim leers’s picture

Status: Fixed » Closed (fixed)

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