Hi,
Here is my config :
Drupal 9.5.0
Theme : Bootstrap 5
I've activated CKEditor 5 to replace V4 then selected it in text format. But when I edit a content, I lose some inline style.
For example :
<span style="font-weight:600">This is bold text</span>
becomes :
<strong>This is bold text</strong>
This is only an example, I know semantically talking "strong" can replace "font-weight". But I don't dare editing all my other contents or I might lose other inline style more important which would break the pages.
How can I prevent this ? it was working fine in CKEditor 4.
Tanks.
Comments
Comment #2
cilefen commentedComment #3
wim leersComment #4
lucky723 commented@Wim Leers
1. I've created a personnalized text format from FULL HTML, to not change the default one.
2. Which commands should I run exactly to answer you ?
Thx
Comment #5
wim leersdrush cex <the ID of your text format>+drush cex <the ID of your text editor>Comment #6
le72With enabled "Limit allowed HTML tags and correct faulty HTML" filter you can't have style attribute.
Comment #7
svdhout commentedWe use the style plugin to add inline styles, like this:
span.highlight|HighlightSaving the editor configuration throws the following error
The Style plugin needs another plugin to create <span>, for it to be able to create the following attributes: <span class="highlight">. Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.Which is correct, because we do not have a plugin defining that we can use span tags.
The approach for adding the source editing plugin works, and allows me to add the styling i want.
However, i do not really like having to add the Source editing plugin for this.
I can solve the problem in a module by adding this configuration inside a .ckeditor5.yml file:
Is allowing span tags something we want to do in core, or would it be best to create a contrib module for this?
Comment #8
wim leersThat's the only way, sorry.
Clever work-around for your particular use case! 😄 But that now means you can create
<span>tags using the UI. Which is not actually true.In fact, most people seem to be really annoyed by
<span>in general — we used to be more pragmatic but got a lot of backlash. See #3273983: Do not assume that plugin supporting <tag attr> also supports <tag> in SourceEditingRedundantTags and upgrade path.I think an
ckeditor5_implicitly_allow_spanscontrib module would make sense, yes!