Document <li> and <td> edge cases in \Drupal\ckeditor5\HTMLRestrictions::getTextContainerElementList

Created on 30 May 2022, over 2 years ago
Updated 15 August 2023, about 1 year ago

Problem/Motivation

\Drupal\ckeditor5\HTMLRestrictions::getTextContainerElementList provides list of text-container elements. On top of the elements included in the list, <td> and <li> are able to act as text-container elements in the sense that text can be rendered inside the element without wrapping the text with a <p> or <div>. However, these elements are not able to render attributes usually rendered on text-container elements. For this reason we should not consider them as text-container elements.

Proposed resolution

Document the <td> and <li> that are special case text-containers in \Drupal\ckeditor5\HTMLRestrictions::getTextContainerElementList.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

10.0

Component
CKEditor 5 

Last updated 2 days ago

Created by

🇫🇮Finland lauriii Finland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States joshuami Portland, OR

    Adding some use cases to this issue.

    1. An editors uses media library to embed a document into an unordered or ordered list.
    2. An editor uses media library to embed an image into a list.

    CKEditor 5 supports this per https://ckeditor.com/docs/ckeditor5/latest/features/lists/document-lists....

  • 🇺🇸United States joshuami Portland, OR

    After a bit more research with some sites I'm trying to upgrade to D10 with CKEditor5, I think this may be more of a potential data-loss bug than a task.

    If a site has used Media Library and embedded media into a list (ordered or unordered doesn't matter), those lists will be corrupted on the first edit of the entity after enabling CKEditor5.

    While Document Lists (see my previous comment) in CKeditor5 allow paragraphs and images to be inserted into a list—retaining the nesting of those elements within the list item—you cannot do the same with a drupal-media element. I'm not immediately sure why as you can technically manually add divs. I think it might be because drupal-media elements are not explicitly allowed within CKEditor's DocumentList allowed HTML.

    I'm not seeing the same issue with tables. You can have a drupal-media element with a table cell and it doesn't force that to break out of the table cell in the way that it forces the list to break into two list elements.

    Can anyone else reproduce this? Do you agree it would be data loss since there is no path to editing the content that has this pattern?

  • 🇫🇮Finland lauriii Finland

    That sounds like it should potentially get a new issue. This issue was filed for documenting a very specific opinion that CKEditor 5 has, which is that <td> and <li> may contain text without an additional <p> element, but yet those elements don't behave like other text wrappers like <p> or <div>.

Production build 0.71.5 2024