I am assuming this will need to be either a bug or feature request upstream in CKEditor - but reporting here first to get feedback / ideas.
Problem/Motivation
When using CKeditor4 we had a filter format using "Limit allowed HTML tags and correct faulty HTML" which allowed colgroup and col elements to be used with class attributes. This was primarily used for sizing but also for other formatting needs, such as alignment.
We did not enable the table resize plugin for this, as we were able to rely on either source editing or CKEditor templates to provide the initial markup contain the colgroup
/ col
elements with classes already applied.
In CKEditor5 the colgroup
and col
elements are removed from the markup when editing - even when added to "Manually editable HTML tags" or when using Full HTML format.
Steps to reproduce
- Standard install
- Add
<col class> <colgroup class> <th scope>
to "Manually editable HTML tags" - Create a node, switch to source editing and add the following content:
<table>
<caption>
Superheros and sidekicks
</caption>
<colgroup>
<col />
<col span="2" class="batman" />
<col span="2" class="flash" />
</colgroup>
<thead>
<tr>
<td> </td>
<th scope="col">Batman</th>
<th scope="col">Robin</th>
<th scope="col">The Flash</th>
<th scope="col">Kid Flash</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Skill</th>
<td>Smarts</td>
<td>Dex, acrobat</td>
<td>Super speed</td>
<td>Super speed</td>
</tr>
</tbody>
</table>
- Switch out of source editing and save the node.
Proposed resolution
I believe this is similar to #3335991: [upstream] CKEditor 5 does not retain custom HTML tags that are not defined by CKEditor 5 plugins whenever /.*/ is not allowed (e.g. when filter_html is enabled) except I do not consider colgroup
and col
elements to be custom elements.
#3353010: Add table.TableColumnResize for formats with arbitrary HTML supported will add support for the TableColumnResize
plugin which does define the colgroup
and col
elements. This is in my view a different use case as to allow the colgroup
and col
elements you also need allow all HTML / attributes and the table resizing UI.
In short - I believe col
and colgroup
elements should be supported without requiring the TableColumnResize
plugin / allowing full HTML. The practicalities of that approach I am unsure of.