Problem/Motivation
The Remove Format button does not remove inline styles. When I have some text that contains inline styles, I select/highlight some text in the editor but the Remove Format button remains gray/inactive, and clicking it does nothing; formatting is not stripped. For example paragraph and span tags with some inline styles, and those inline styles don't get removed. There are no JavaScript errors in the console, either in Chrome or Firefox.
Steps to reproduce
Select some text in the editor and click the Remove Format button.
Proposed resolution
https://github.com/ckeditor/ckeditor5/issues/13983
Remaining tasks
No idea
User interface changes
None
API changes
On https://ckeditor.com/docs/ckeditor5/latest/features/remove-format.html I see there's a Ckeditor5 API for extending the Remove Format plugin to allow removing specific elements using the isFormatting property, but I think this is not needed here; somehow it seems the default Remove Format functionality isn't working, at least not for me.
Data model changes
No idea
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | filter.settings.yml | 141 bytes | caspervoogt |
| #5 | editor.editor.full_html.yml | 498 bytes | caspervoogt |
| #2 | Screenshot 2022-11-14 112821.jpg | 5.6 KB | caspervoogt |
| #2 | Screenshot 2022-11-14 112803.jpg | 14.81 KB | caspervoogt |
Comments
Comment #2
caspervoogt commentedComment #3
wim leersThanks for taking the time to report this!
Can you please provide exact steps to reproduce? That means the CKEditor 5 configuration (export the
editorandfilter_formatconfig entities please) as well as the sample HTML you're testing this with.Comment #4
caspervoogt commentedComment #5
caspervoogt commentedI attached config exports. Also, here's a ~2 min screencast showing the issue.
I did not allow the style attribute (I don't think I need to?!); I am able to add it into my source HTML and save it, though. Yet CKeditor5 won't strip it with Remove Formatting. I am also not using any filters.
Essentially, inline styles don't get stripped, whereas in CKeditor 4 they did (as far as I can recall). Manually removing inline styles can be a pain.
Comment #6
wim leersThanks, @caspervoogt!
Comment #7
nod_Seems like a feature, not a bug.
Per CKE5 documentation : "Note that block-level formatting (headings, images) and semantic data (links) will not be removed by this feature." the p tag is block-level so it makes sense it will not remove the style as documented.
Comment #8
wim leersWould this be a better description then?
Comment #9
nod_Comment #10
caspervoogt commentedIn my case neither block nor inline styles get removed.
I take another look at my test case in this brief video.
No style attributes get removed from either paragraph or span elements. I *can* format
<b>,<strong>,<i>,<em>,<u>, but only if those buttons are present in the editor; adding one of those elements AND having their button present in the editor is the only only way I can get the Remove Button to activate, but it still doesn't remove style attributes / inline styles.Comment #11
caspervoogt commentedComment #12
caspervoogt commentedComment #13
caspervoogt commentedComment #15
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge require as a guide.
Moving to NW as there still appears to be more discussion vs anything to actually review from what I can tell. Maybe we need to expand the functionality of the remove formatter button (if that's possible)
Comment #16
wim leersIt was marked as needing review in #7, but there's no actual patch yet. So … moving to .
Comment #17
caspervoogt commentedThanks for the update, smustgrave and Wim. I think this is likely more an issue with Ckeditor itself and not Drupal, judging by the issues at https://github.com/ckeditor/ckeditor5/issues/11574, but I can't say for sure. I'm not the only one running into these issues, based on some of the the threads there.
Comment #18
smustgrave commentedWill admit its very confusing to have a remove formatting button that doesn’t actually remove all formatting. Couldn’t imagine having to explain that to a client..
Comment #19
wim leersAgreed.
The upstream issue is https://github.com/ckeditor/ckeditor5/issues/11580.
Comment #20
mohithasmukh commentedHi there,
I am also facing the same issue, when the content editors go in to remove the formatting the inline styles are not removed. Has anyone found any workaround this?
Thank you.
Comment #21
aaronbaumanThe workaround we're advising clients is to use the "paste as plain text" button, or cmd-shift-v
Comment #22
caspervoogt commentedThis apparently just got fixed on the ckeditor5 master branch. See https://github.com/ckeditor/ckeditor5/pull/13949.
Comment #23
wim leersWonderful! Looks like many
Style-related bugs are being fixed in the current development cycle: https://github.com/ckeditor/ckeditor5/milestone/67?closed=1.… but it did not yet ship in CKEditor 37.1.0, which we just updated to yesterday: #3355358: Update CKEditor 5 to 37.1.0.
So it looks like this will be for either 37.2.0 or 38.x. Still, great news! 😊
Comment #24
witeksochaJust keep in mind we improved the Remove format for inline, as it was the fastest :) The Remove format for blocks will be tracked here: https://github.com/ckeditor/ckeditor5/issues/13983
Comment #25
wim leersThanks for that clarification! 😊
Comment #26
caspervoogt commentedWitek beat me here.. I was going to post the same thing. Very happy to see this progressing.
Comment #27
sachbearbeiter commentedTop :)
And thankful ...
Comment #28
wim leersStill tracking for https://github.com/ckeditor/ckeditor5/issues/13983 — updating target version.
Comment #29
caspervoogt commentedhttps://github.com/ckeditor/ckeditor5/issues/13983 has only 7 votes; maybe if some more Drupal folks can log into Github and upvote it, the CKEditor maintainers will give it higher priority :)
Comment #30
montogro commentedDoesn't work for me either. Even somehow pasting as plain text with right click didn't solve this problem for text copied directly from word which is using its own fonts and styles.
Update: looks like it was text's issue itself, once I pasted it even notepad couldn't bring it back to plain text, but leaving empty squares only. Everything seems to be fine now.
Comment #31
eduardo morales albertiAs Wim Leers says in the comment https://www.drupal.org/project/drupal/issues/3321254#comment-15025068 it was fixed on https://github.com/ckeditor/ckeditor5/releases/tag/v38.0.0 but Drupal 9.5.x require "ckeditor5": "~35.4.0", on 11.x "ckeditor5": and 10.x seems that is required "~39.0.1".
Comment #32
mohithasmukh commentedHi all,
I am confused but what is the workaround for websites that are still on 9.5 core?
Thanks.
Comment #33
eduardo morales alberti@mohithasmukh There are no workarounds (or I did not find any at least), the solution is to keep CKEditor 4 until update Drupal to version 10 and then use CKEditor 5, the 9.5 support ends in November.
Comment #34
wim leers#31: #3321254: [upstream] Remove Format button does not remove `style` attributes from block-level elements is referring to the
Styleplugin and theRemove Formatbutton working with that.This issue is about the
Remove Formatbutton removingstyleattributes. That's a very different problem space.https://github.com/ckeditor/ckeditor5/issues/13983 is the blocker, and it now has 28 votes already.
Comment #36
wim leersReported once more, now by @igorbarato, at https://drupal.slack.com/archives/C01GWN3QYJD/p1695231744469799.
Clarifying issue title.
Comment #37
aasarava commentedUnfortunately, the fix to remove inline formatting still excludes classes/styles on links. I've opened a followup issue:
https://github.com/ckeditor/ckeditor5/issues/15318
Comment #38
wim leersThanks, @aasarava!
Comment #39
hephaestus commentedAs it doesn't look like this is going to be implemented upstream in the near future, is anyone aware of a workaround to force this behaviour, if you're happy to take a scorched earth approach to attributes on elements?
We've got clients trying to paste in a lot of documents from Word, and the "remove formatting" button only stripping styles from inline elements tends to leave the document with a broken mix of styling, mostly relating to sizing and spacing. Stripping styles after the fact in the filter prevents intentional styling and makes the editing experience very inconsistent when they're still visible within the editor.
Comment #40
scott_euser commentedWe have been using the 'CK editor 5 Paste Filter' module as a temp fix to catch things on paste. Not quite the same so might not work for you.
Comment #41
hephaestus commentedThanks Scott, that does solve our immediate issue.
Comment #42
caspervoogt commentedGood news!
https://github.com/ckeditor/ckeditor5/issues/15318 was just merged into the CKEditor master branch. Here's the relevant PR; https://github.com/ckeditor/ckeditor5/pull/18603, which resolves a number of 'remove format' issues.
Next I suppose core/modules/ckeditor5/ckeditor5.libraries.yml and core/assets/vendor/ckeditor5 should be updated to use the latest ckeditor5 library.
Comment #43
jackfoust commentedWould love to see this roll out to 10.5 and 11.2, but I'm guessing there may be some hesitation with the still prevalent issues when we started using CKEditor 45.2.0?
Comment #44
ken hawkins commentedThis one has been a recurrent thorn in our side since leaving CKEditor 4 and I've yet to find an existing fix in Drupal.
I believe we're waiting on v46.0.0 to make its way to Drupal https://github.com/ckeditor/ckeditor5/releases/tag/v46.0.0 as it has the revised clear formatting PR mentioned at https://www.drupal.org/project/drupal/issues/3321254#comment-16136275 (https://ckeditor.com/docs/ckeditor5/latest/features/remove-format.html)
- 10.5.x and 11.2.x are still on 45.2.2: https://git.drupalcode.org/project/drupal/-/blob/10.5.x/core/package.jso...
- 10.6.x ann 11.4.x should move to 47.0.0: https://git.drupalcode.org/project/drupal/-/blob/10.6.x/core/package.jso...
Using simplytestme for 10.6.x it appears this is a change of behaviour for the remove formatting button.
<= v45= clear CKeditor styles,>= v46clear all styles.(aside: I imagine some editors will be taken off guard by the change).
Before I realize the above, I made a small workaround module that others may find helpful: https://github.com/khawkins98/ckeditor_clean_styles
Comment #46
ken hawkins commentedVerified that this is now working as expected in D10.6 (see earlier comment). Hurrah!
Being bold and closing.
Comment #48
andrew.wang commentedMarking this issue as fixed in #3340578: [meta] [upstream] Prioritized CKEditor 5 upstream blockers!
PS: @ken hawkins I think you meant 46.0.0 in #44 😛