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

Comments

lauriii created an issue. See original summary.

wim leers’s picture

However, these elements are not able to render attributes usually rendered on text-container elements.

… not able in CKEditor 5, but able in HTML in general, right?

joshuami’s picture

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

joshuami’s picture

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?

lauriii’s picture

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

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.