Problem/Motivation
CKEditor error after source editing, remove format:
If using the text:
Test
<p>
<span lang="EN-US"></span>
</p>
Test
Error:
ckeditor5-dll.js?v=40.2.0:5 Uncaught CKEditorError: conversion-model-consumable-not-consumed {"items":[{"event":"insert","item":"htmlEmptyElement"}]}
If using the text:
Test
<p>
<span lang="EN-US"></span><span> </span>
</p>
Test
Error:
Cannot read properties of undefined (reading 'name') after clear format
After copy from word document (The file manager do not allows word documents format)
Remove format and click on source.
Steps to reproduce
1. Install using the Standard installation profile on Drupal 10.2.6
2. Create a new text format, setting the editor to "CKEditor 5" and adding the following toolbar items: Styles, Remove Format and Source editor
3. Configure one style for the dropdown, span.orange|Orange span
4. Add the "Limit allowed HTML tags and correct faulty HTML" text format filter.
5. Edit the text format. Under "Source editing"> "Manually editable tags", check that span is present
6. The "Limit allowed HTML tags and correct faulty HTML" will have:
<br> <p> <span class="orange"> <cite> <dl> <dt> <dd> <a hreflang> <blockquote cite> <ul type> <ol type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
6. Save the form.
7. Create a basic page using the format.
8. Copy the following text on source mode:
Test
<p>
<span lang="EN-US"></span>
</p>
Test
9. Change to edit mode and select all
10. Click on "Remove Format"
11. Click on source mode again, the console will output:
ckeditor5-dll.js?v=40.2.0:5 Uncaught CKEditorError: conversion-model-consumable-not-consumed {"items":[{"event":"insert","item":"htmlEmptyElement"}]}
If the "Limit allowed HTML tags and correct faulty HTML" is not enabled and we remove span from source editing, it works properly because convert the empty span into a nbsp, but it does not limit the tags allowed.
If using the text:
Test
<p>
<span lang="EN-US"></span><span> </span>
</p>
Test
The error is:
Cannot read properties of undefined (reading 'name') after clear format
Proposed resolution
Probably the solution will be on the style plugin define also the tag element, not only the class, to avoid forcing adding the span to the source editing.