Problem/Motivation
<i class="fa fa-drupal">Drupal</i>
Steps to reproduce
Entering
<i class="fa fa-twitter">Twitter</i>
(as suggested here for icons) using the CKEditor 5 "Sourcecode" button results in
<p>
<em><i class="fa fa-twitter">Twitter</i></em>
</p>
when leaving the source code edit area and back.
Expected result
<p>
<i class="fa fa-twitter">Twitter</i>
</p>
without the wrapping <em>.
I have no idea why and where this is done, but I wouldn't rate this as expected?
Also, I don't think it's totally untypical that such kinds of iconfonts are used in Drupal WYSIWYG by site builders?
This can be easily reproduced in a fresh Drupal 10 installation using https://simplytest.me/ for example.
Testing the same on the CKEditor 5 Demo page leads to different (expected) results:
https://ckeditor.com/docs/ckeditor5/latest/features/source-editing.html
<p>
<i class="fa fa-twitter">Twitter</i>
</p>Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Release notes snippet
TBD
Issue fork drupal-3341280
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodySorry, I had to correct the details as I wrongly used "Basic HTML" in my reproduction. Should have been "Full HTML".
Basic HTML works as expected, as
<i>was not allowed there!For Full HTML I'll now try, if entering in "Source Editing" fixes this.
Comment #3
anybodyComment #4
anybodyNo, that doesn't change anything. The
<i>is always wrapped into<em>when leaving the "Source" editing.Comment #5
anybodyComment #6
cilefen commented#2722451: <i> tags without content are stripped by CKEditor even with "Full HTML" (i.e. without ACF) reappeared as #3337298: [upstream] [GHS] CKEditor 5 removes empty inline elements.
Is this intrinsic to Drupal or is it CKEditor behavior?
Comment #7
anybodySeems to be Drupal-specific!
https://ckeditor.com/docs/ckeditor5/latest/features/source-editing.html
Trying that here leads to expected results:
Comment #8
anybodyComment #9
wim leers<i>?This is related to #3337298: [upstream] [GHS] CKEditor 5 removes empty inline elements but is definitely a different problem.
I'm 99% certain this is caused by
DrupalEmphasisEditing— seecore/modules/ckeditor5/js/ckeditor5_plugins/drupalEmphasis/src/drupalemphasisediting.js.Comment #10
wim leersComment #11
anybodyI'd very much like to, but currently missing spare time. I'll add an entry for our team, hopefully someone has some time to do it. Do you know a similar example to copy as a quick start? Especially for the CKEditor setup and interaction? That would speed things up a lot, I think.
I'll also ask to test 2. but if ANYONE coming here can do it, please do it and don't wait!
Comment #12
wim leersThank you!
Actually, 99% of what you need is already provided by
\Drupal\Tests\ckeditor5\FunctionalJavascript\EmphasisTest— you just want to explicitly test with .Basically, you want to copy
\Drupal\Tests\ckeditor5\FunctionalJavascript\EmphasisTest::testEmphasis(), rename ittestEmphasisWithoutFilterHtml()and modify the text format config entity'sfilter_htmlto be disabled. That should reproduce it 🤓I think that'll help you get started! 🤞
Comment #13
karamveersingh commentedwe also facing a similar issue on Ckeditor5 and would like to know a fixed solution. Do we've to downgrade it to 1 version means Ckeditor4?
Comment #14
anybody@Wim Leers: FYI: Thanks for #12! We'll do it, but we didn't have the time yet. If anyone can do this earlier, I'd of course appreciate that. Sorry.
Comment #15
jcandan commentedThis is bothersome. Any workarounds until a patch can be made?
Note: Additionally, when no element content is supplied, the
<i>tag get filtered out completely.Becomes
Comment #16
jcandan commentedIn an attempt to work around, I tried to use an
<svg>. But, it gets pushed outside the<a>it's in.This is unrelated to the issue described above, but also annoying.
Becomes
Comment #19
ravi.shankar commentedWorking on it.
Comment #22
grevil commentedTried adding a failing test, to show the problem, but it succeeds...
Comment #23
anybody@Grevil: testEmphasisWithoutFilterHtml is failing as expected, but we should be sure the result is what we expect. Could you please check the test result again? Could we perhaps explicitly compare the expected result so the test shows XX expected, actual result YY?
Thanks for picking this up for me!
Comment #24
grevil commentedUnfortunately, this is NOT the "expected" failure...
I'll have a look later.
Comment #25
grevil commentedFound the problem, I forgot to copy over all changes, as I am still struggling to set up a proper dev environment for core issues...
Comment #26
grevil commentedNow, comment #22 should apply, and the test will succeed (but it is expected to fail).
Comment #27
grevil commentedI adjusted the test accordingly, it should fail now.