Closed (fixed)
Project:
Drupal core
Version:
10.1.x-dev
Component:
ckeditor5.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Jan 2023 at 21:30 UTC
Updated:
21 Apr 2025 at 16:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
norman.lolComment #3
norman.lolComment #4
norman.lolComment #5
wim leersVery interesting! Thanks for doing this research! 🙏👏
CKEditor 5 should never strip explicitly allowed markup, not even more obscure markup like this. Bumping to and tagging .
Second critical GHS bug in a week: #3335991: [upstream] [GHS] 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).
But … frankly, the https://www.drupal.org/project/fontawesome module should provide a filter instead. Because markup like
which the corresponding filter plugin then transforms to
would be far clearer, and it'd make it much easier to do transformations on existing content, e.g. to update icons 😅
Comment #7
wim leersDiscussed this with @Reinmar from CKEditor 5!
Observations:
<p><i class="fab fa-drupal"></i> asdflksjdflaskdfj</p>pasted ⇒<i class="fab fa-drupal"></i>gets stripped!— source
That being said, this should work. They confirmed this, and they are planning to work on this in the next few months! 👍 Just know that in the mean time, you could work around it by adding explicit support for this custom tag in a CKEditor 5 plugin in #3274028: CKEditor 5 compatibility 😊 If that weren't the case, I'd have tagged this .
Comment #8
norman.lolWow, thanks for the update, Wim!! 🤗
But I just double-checked that this wasn't an issue in Drupal 9 CKE 4. So I've quickly set up a D 9.4, logged in, and created an article, putting
<span></span> My spanin the editor, after clicking "Source", and saved. Visiting the article, inspecting the markup and saw that the empty tag persisted.BUT as soon as I went to edit the article again, clicking "Source" again, the empty
<span></span>was gone. 🤯Comment #9
daniel.moberly commentedTo address the "filter" idea in #5 - this markup is not custom to the Fontawesome module, but rather the actual implementation of Fontawesome itself (see https://fontawesome.com/docs/web/setup/get-started). Changing the way the tags are added prevents folks from using any of the Font Awesome documentation or writing the code themselves site-agnostic.
Comment #10
gaboo commentedHaving the same problem here for something other than FontAwesome.
Please allow whatever we want to put in the HTML source, including unkwnow or empty tag, when we use full HTML.
Comment #11
wim leers#8: So … that does mean that plain CKEditor 4 exhibited the same behavior, right? That's why it also only works in CKEditor 4 with that custom plugin installed. The problem is that no equivalent API exists in CKEditor 5, so even writing that plugin is impossible today.
#9 fair point!
#10: that's definitely always been the goal.
Comment #12
glynster commented@Wim Leers we are having the same issue with an a tag wrapped around a custom picture block:
CKeditor source view:
CKeditor default view:
And indeed dataloss. We migrated to CKeditor 5 and just notcied all links were stripped from our adblocks.
Comment #13
wim leers#12: wow, that's a whole new kind of data loss, separate from this one! Created new issue at #3349893: [upstream] [GHS] CKEditor 5 removes <a>s that wrap HTML elements not natively supported by CKEditor 5 and credited you 👍 Discussing with the CKE5 team later today.
Comment #15
wim leersClosed #3348139: CKEditor 5 not supporting fa fa icon as a duplicate.
Comment #16
glynster commented@Wim Leers thanks so much! I responded in the other issue as well along with our workaround/solution.
Comment #17
anybodyConfirming this issue still exists in Drupal 10.1.0
We tried:
<a href="#" class="button"><i class="fa fa-drupal"></i></a>which is being erased, while
<a href="#" class="button"><i class="fa fa-drupal">XXXXX</i></a>is kept.
Comment #18
wim leershttps://github.com/ckeditor/ckeditor5/issues/9888 has not yet been fixed upstream, so it's also not in #3370989: Update CKEditor 5 to 38.1.0, so
10.1.1won't fix it either.Comment #19
ed-media commentedI was preparing one of our sites to migrate to Drupal 10 but it looks like the issue is also there with Drupal 9.5.10 and CKEditor 5 enabled see attached screenshots.
Comment #20
wim leershttps://github.com/ckeditor/ckeditor5/issues/9888 landed upstream 1 hour ago!
Comment #21
wim leersBetter yet: so far, that upstream issue is looking likely to ship in a
38.x.0minor release — meaning that we could update Drupal10.1.xto a version that includes the fix! 😊No guarantees though.
Comment #22
wim leersWe need test coverage to prove this is broken today and will be fixed in #3377562: Update CKEditor 5 to 39.0.0.
Comment #23
wim leersSince markup like
<i class="fab fa-drupal"></i>or<span class="icon my-icon"></span>can only be created through theSourceEditingCKEditor 5 plugin, I added the necessary test coverage there.Comment #26
wim leersI discussed #23 in detail with @Reinmar and @witeksocha.
Conclusion:
So, adjusting the test coverage slightly for that: even for unrestricted text formats, we should expect
to be transformed to
Comment #27
wim leersGreen test result for https://git.drupalcode.org/project/drupal/-/merge_requests/4530/diffs?co... 🚀
See #3377562-22: Update CKEditor 5 to 39.0.0.
Comment #28
smustgrave commentedSince https://www.drupal.org/project/drupal/issues/3377562 was merged into 11.x and hopefully soon 10.1.x
Comment #30
ramprassad commentedI'm experiencing this issue with 'ul' tag
<ul id="divisionitemlist" class="text0">​</ul>and related the issue here, any suggestions n fixing the issue much appreciated.Comment #31
cscottjames commentedIs the update to ckeditor only supposed to address FontAwesome and/or icon elements? I'm still having trouble adding empty inline elements. From the comments above, it sounds like this is still a bug?
Steps to reproduce:
-install Drupal Core 10.4.6 (which has CKEditor v44, according to core.libraries.yml)
-create node; body field using Full HTML text format
-click "Source" to edit source HTML
-add
<span class="foobar"></span>-toggle the Source button back and forth
-span element has now disappeared