Problem/Motivation

We either need this to be fixed or #3274635: [upstream] Use CKEditor 5's native <ol type> and <ul type> UX.

Upstream bug report: https://github.com/ckeditor/ckeditor5/issues/11615

Steps to reproduce

  1. Allow <ol type> or <ul type> with GHS
  2. Edit content that contains <ol type="A"> or <ul type="disc">, and observe that CKE5 loses it.

Proposed resolution

We were informed by the CKEditor 5 team that the List plugin in the ckeditor5-list package has never been updated to integrate with GHS, so the above behavior is expected.

The solution is to use DocumentList, which is new in v34.0.0. Unfortunately, it's not available in the DLL build of ckeditor5-list.

The CKEditor 5 team will tag a v34.0.1 release of CKEditor 5 which will add DocumentList to ckeditor5-list's DLL build. This will increase the size of the JS to be downloaded. Fortunately, the List plugin will be sunset (and removed) in the near future, which means that the JS size will automatically decrease in a future release.

(See #6)

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Status: Active » Needs review
Issue tags: -Needs tests +stable blocker
FileSize
11.39 KB

Failing tests.

Wim Leers’s picture

Status: Needs review » Postponed
Wim Leers’s picture

4 expected failures, all somewhat like this:

Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'<ol type="A"><li>foo</li><li>bar</li></ol>'
+'<ol><li>foo</li><li>bar</li></ol>'

IOW: the test coverage works as expected 👍

Wim Leers’s picture

Tested locally after #3274767: Update to CKEditor 5 v34.0.0 landed, still failing.

Wim Leers’s picture

I was informed by the CKEditor 5 team that the List plugin in the ckeditor5-list package has never been updated to integrate with GHS, so this is expected.

The solution is to use DocumentList, which is new in v34.0.0. Unfortunately, it's not available in the DLL build of ckeditor5-list.

The CKEditor 5 team will tag a v34.0.1 release of CKEditor 5 which will add DocumentList to ckeditor5-list's DLL build. This will increase the size of the JS to be downloaded. Fortunately, the List plugin will be sunset (and removed) in the near future, which means that the JS size will automatically decrease in a future release.

Wim Leers’s picture

FileSize
8.25 MB

Confirmed that <ol type> works fine out of the box in CKEditor 4 in Drupal 9's Basic HTML text format. Also reported upstream: https://github.com/ckeditor/ckeditor5/issues/11615#issuecomment-1099321116.

Wim Leers’s picture

Title: [upstream] Impossible to enable <ol type> or <ul type> with GHS » [PP-1] [upstream] Impossible to enable <ol type> or <ul type> with GHS
Related issues: +#3277405: Update @ckeditor/ckeditor5-list to v34.0.1
Wim Leers’s picture

  1. Testing the <ol type="A"> test case in #2 with HEAD:
    1) Drupal\Tests\ckeditor5\FunctionalJavascript\SourceEditingTest::testAllowingExtraAttributes with data set "<ol type="A">" ('<ol type="A"><li>foo</li><li>...></ol>', '<ol type="A"><li>foo</li><li>...></ol>', '<ol type="A">')
    Failed asserting that two strings are identical.
    --- Expected
    +++ Actual
    @@ @@
    -'<ol type="A"><li>foo</li><li>bar</li></ol>'
    +'<ol><li>foo</li><li>bar</li></ol>'
    
  2. Testing that same test case with #3277405: Update @ckeditor/ckeditor5-list to v34.0.1 applied and this tiny diff:
    diff --git a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml
    index e91e43604c..aa0b6059d2 100644
    --- a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml
    +++ b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml
    @@ -304,7 +304,7 @@ ckeditor5_linkMedia:
     
     ckeditor5_list:
       ckeditor5:
    -    plugins: [list.List]
    +    plugins: [list.DocumentList]
       drupal:
         label: List
         library: core/ckeditor5.list
    

    results in:

    Testing /Users/wim.leers/Work/d8/core/modules/ckeditor5/tests/src/FunctionalJavascript
    .                                                                   1 / 1 (100%)
    
    Time: 29.14 seconds, Memory: 8.00 MB
    
    OK (1 test, 15 assertions)
    

So … that means we have another stable blocker almost fixed! 🥳

kim.pepper’s picture

Title: [PP-1] [upstream] Impossible to enable <ol type> or <ul type> with GHS » [upstream] Impossible to enable <ol type> or <ul type> with GHS
Status: Postponed » Active

#3277405: Update @ckeditor/ckeditor5-list to v34.0.1 is in so this should be un-postponed.

Wim Leers’s picture

Status: Needs review » Needs work

The last submitted patch, 11: 3274651-11--branches-with-3261599.patch, failed testing. View results

Wim Leers’s picture

Status: Needs work » Needs review
FileSize
12.19 KB
805 bytes

Silly oversight for the --branches-with-3261599 patch … 🙈

Wim Leers’s picture

Wim Leers’s picture

Same patch, but now running the entire core test suite.

I've proven in #11 that this will also work in 9.4.x and 9.3.x. That only requires a different patch because #3261599: Use CKEditor 5's native <ol start> support (and also support <ol reversed>) didn't land yet in those two branches.

So, this patch should be tested and committed against all 3. But for now, only testing against 10.0.x.

catch’s picture

Title: [upstream] Impossible to enable <ol type> or <ul type> with GHS » Impossible to enable <ol type> or <ul type> with GHS
Wim Leers’s picture

#3261599: Use CKEditor 5's native <ol start> support (and also support <ol reversed>) was just committed to 9.4.x and 9.3.x too — queuing tests of #17.

Wim Leers’s picture

Status: Needs review » Needs work
+++ b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml
@@ -353,8 +353,8 @@ ckeditor5_linkMedia:
-     - list.List
-     - list.ListProperties
+     - list.DocumentList
+     - list.DocumentListProperties

Per https://github.com/ckeditor/ckeditor5/pull/11668#discussion_r859487538, this means we should also update \Drupal\ckeditor5\HTMLRestrictions::getTextContainerElementList().

Wim Leers’s picture

Status: Needs review » Needs work

The last submitted patch, 21: 3274651-21.patch, failed testing. View results

Wim Leers’s picture

Status: Needs work » Needs review

Random unrelated fail.

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.

nod_’s picture

The CKE5 part looks good, but in claro there is a CSS conflict. We have claro's elements.css:

ol {
  margin: 0.25em 0 0.25em 2em; /* LTR */
  padding: 0;
  list-style-type: decimal;
}

So even when there is a type attribute on the list it's always the decimal version that is shown, and it makes it seems it doesn't work. Not sure if that's a followup or a fix to make in this issue.

Wim Leers’s picture

Wow — interesting! 🤯

That is a pre-existing bug in Claro then, because it means other list style types already do not work in Claro. The scope of this issue is to make CKEditor 5 support this (because it is currently a data loss issue).

Claro making it look like it does not work correctly still is better than today: today it is a data loss issue.

Apparently that line was added in #3079738: Add Claro administration theme to core — i.e. the original commit of Claro in 2019. I cannot find a pre-existing bug report for this: https://www.drupal.org/project/issues/drupal?text=ordered+list+ol&status.... Created one: #3282598: Claro should not hardcode decimal list style type for <ol>.

nod_’s picture

Status: Needs review » Reviewed & tested by the community

sounds good to me :D

lauriii’s picture

Since we're changing from List plugin to DocumentList plugin, it would be useful to at minimum useful to document that in the issue summary. We might want to also retitle this because even though the change makes sense, it seems like we're doing more than what this issue suggests.

Wim Leers’s picture

Title: Impossible to enable <ol type> or <ul type> with GHS » Impossible to enable <ol type> or <ul type> with GHS: switch to List's successor, DocumentList
Issue summary: View changes
Issue tags: -Needs issue summary update
Wim Leers’s picture

Issue summary: View changes
alexpott’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/ckeditor5/src/HTMLRestrictions.php
@@ -1167,7 +1167,7 @@ public function toGeneralHtmlSupportConfig(): array {
   private static function getTextContainerElementList(): array {
     return [
-      'div', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'li',
+      'div', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre',
     ];
   }

Reading the documentation for this method...

   * This list is highly opinionated. It is based on decisions made upstream in
   * CKEditor 5. For example, `<blockquote>` is not considered as a `$block`
   * text container, meaning that text inside `<blockquote>` needs to always be
   * wrapped by an element that is `$block` text container such as `<p>`. This
   * list also excludes some special case text container elements like
   * `<caption>` that allow containing text directly inside the element, yet do
   * not fully implement the `$block` text container interface.

That seems really quite significant - does this really mean that an li will always need a div or a p inside it? Does this documentation need updating in light of this change? I'm guessing that the DocumentList plugin does not require li's to have a p or a div inside them.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

<li>s will not always need a <div> or <p> inside — but if you apply an alignment, then yes, it will generate a <p>: CKEditor 5 will generate <li><p class="text-align-…">...</p></li>, not <li class="text-align-…">...</li>.

See https://github.com/ckeditor/ckeditor5/pull/11668#discussion_r859487538 (previously linked from ##2).

lauriii’s picture

It seems like li is a really confusing special case. It is a text-container element because it allows <li>foo</li> but it doesn't allow any of the formatting that is usually allowed for text-containers 🙈 It seems like DocumentList uses Paragraph + attributes for the model. 🤯 For our purposes, I'm pretty sure we shouldn't consider it as a text-container element since what we care about is whether formatting is allowed on the element or not.

lauriii’s picture

Filed an issue for improving the docs regarding the special case elements: #3283173: Document <li> and <td> edge cases in \Drupal\ckeditor5\HTMLRestrictions::getTextContainerElementList.

alexpott’s picture

Thanks for creating the follow-up @lauriii - +1 to rtbc let's get this done.

  • lauriii committed 9018da4 on 10.0.x
    Issue #3274651 by Wim Leers, nod_, alexpott: Impossible to enable...

  • lauriii committed 47c9c02 on 9.5.x
    Issue #3274651 by Wim Leers, nod_, alexpott: Impossible to enable...

  • lauriii committed 997186e on 9.4.x
    Issue #3274651 by Wim Leers, nod_, alexpott: Impossible to enable...

  • lauriii committed 97a241b on 9.3.x
    Issue #3274651 by Wim Leers, nod_, alexpott: Impossible to enable...
lauriii’s picture

Version: 9.5.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Got a confirmation from @alexpott that #32, #33, and #34 addresses concerns raised in #31.

Committed 9018da4 and pushed to 10.0.x. Also cherry-picked to 9.5.x, 9.4.x, and 9.3.x. Thanks!

Status: Fixed » Closed (fixed)

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