Cannot add inline-style tag to element
Closed this issue · 1 comments
remcoov commented
Hi,
I'm trying to add an inline-style tag to a paragraph. For example: my user selects a few words, clicks on Styles and chooses Green Text. What I'd like to see is this being generated:
<p style="color: #385E89;">Green Text</p>
I can't get this to work via the JSON config. Classes do work, but in my specific case I need it to be an inline-style. For now, I won't go into details as to why this is the case. If needed, I will.
What I did try was:
"style": {
"definitions": [
"attributes": {
"style": "color:#385E39;"
},
"classes": [
"text-gg-green"
],
"element": "p",
"name": "Green text"
]
}
I'm using Craft 4.10.3 and CKEditor 3.8.3.
i-just commented
Hi, thanks for getting in touch! CKEditor 5 does not support adding inline attributes via the styles feature - you can only use classes.
Here’s a bit more info on this:
- Style Definitions doc: https://ckeditor.com/docs/ckeditor5/latest/api/module_style_styleconfig-StyleDefinition.html
- similar question on stack overflow: https://stackoverflow.com/questions/58014387/how-do-i-tell-ckeditor-5-to-use-inline-styling-on-the-elements-which-it-creates
- issue from CKEditor’s GitHub: ckeditor/ckeditor5#8473
I hope this helps!