CKEditor 5 removes <ul> tag altogether when no <li> is provided

Created on 14 December 2023, 11 months ago
Updated 13 June 2024, 5 months ago

Problem/Motivation

We are creating content in CKeditor 5 in FullHTML text format sourceediting with a ul tag with the content<ul id="divisionitemlist" class="text0">&#8203;</ul> along with a script which will populate the child 'li' tags based on events.

The issue is that the HTMLEngine removes the ul altogether, which does not happen in CKEditor 4. Is there a solution to avoid this behavior in CKEditor 5?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

💬 Support request
Status

Postponed: needs info

Version

11.0 🔥

Component
CKEditor 5 

Last updated about 4 hours ago

Created by

🇮🇳India ramprassad

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

Comments & Activities

  • Is this an attribute of CKEditor 5 itself? Can you verify at https://ckeditor.com/ckeditor-5/demo/html-support/?

  • 🇮🇳India ramprassad

    Its not working in https://ckeditor.com/ckeditor-5/demo/html-support/ - here as well it is removing the entire 'ul' tag as in Drupal's CKE5. But I could see this working in https://ckeditor.com/docs/ckeditor5/latest/features/source-editing.html. It just replaces ​ with   intead of removing 'ul'which is fine (pls see attached screenshot cke5souceediting.png)

  • 🇮🇳India ramprassad

    Any suggestions on this issue?

  • Status changed to Postponed: needs info 11 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    A <ul> (or <ol>) without a <li> is:

    1. invalid HTML
    2. impossible to create using the UI (unless you've found a way? 😄 If so: please share it!)
    3. only possible to create by manually typing invalid HTML using the Source Editing plugin

    I don't quite understand what the use case is for this? 😅

  • 🇮🇳India ramprassad

    @Wim,
    The content editors are populating the content with the initial markup <ul id="divisionitemlist" class="text0">&#8203;</ul> and the <li>s will be generated using the script available in the content as mentioned in #5. This has worked fine for them in CKE4, so they expect this to work in CKE5 in D10.

    I checked with the standalone CKE5 and this works fine as in https://ckeditor.com/docs/ckeditor5/latest/features/source-editing.html, the 'ul' doesn't get stripped when we use the GeneralHtmlSupport plugin along with htmlSupport: {allow: [{name: /.*/,attributes: true,classes: true,styles: true}]. But in Drupal 10.1.7 it is getting stripped for some reason, I'm still checking on this. Any ideas or thoughts?

    Regards,
    Ramprassad

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    @ramprassad Can you still reproduce this in Drupal 10.2?

  • 🇺🇸United States Larry Jones

    I still see this issue in Drupal 10.2.7, when I switch from ckeditor4 to ckeditor5.

    In Structure | Content types | custom1 | Manage fields | Default value | Body field, this line:

    <ul class="iti" data-toc="div.fyi">
    </ul>

    allows my custom javascript to build a table of contents of header tags within div class="fyi"

    This has worked fine with ckeditor4 through multiple drupal versions. However, ckeditor5 removes the ul tag, so no ToC is built.

  • Production build 0.71.5 2024