How to add styles directly in Rich Text Editor in Umbraco 10
Hi all,
I'm tring to write styles directly in the content of Rich text Editor in Umbraco 10, but that was not working and after writing style and saving it, the whole RTE getting white and when opening the source code all content and styles are dissapearing.I've searched the forums and haven't found a solution that could fix the issue for me.
Can anyone help me?
I don't believe the Style tag is allowed by default in TinyMCE within Umbraco. So in order to allow it you'd have to update the "Valid Elements" configuration option.
You really shouldn't be adding style declartions to your RTE content, you should be defining it in a proper stylesheet and then assign the classes to your RTE elements.
If you think you must do it this way (I would not recomend it) then you will need to add the style tag to the allowed elements in your appsettings.json file
I haven't added it to any projects, as I said it is not something that I would recommend doing, you really should not be adding style tags in your content
How to add styles directly in Rich Text Editor in Umbraco 10
Hi all,
I'm tring to write styles directly in the content of Rich text Editor in Umbraco 10, but that was not working and after writing style and saving it, the whole RTE getting white and when opening the source code all content and styles are dissapearing.I've searched the forums and haven't found a solution that could fix the issue for me. Can anyone help me?
Hi Vijay,
What exactly do you mean by
Need to write styles like this individually in content itself
Hi Vijay,
I don't believe the Style tag is allowed by default in TinyMCE within Umbraco. So in order to allow it you'd have to update the "Valid Elements" configuration option.
You can see how to do that here: https://docs.umbraco.com/umbraco-cms/reference/configuration/richtexteditorsettings#valid-elements
You'll then need to make sure your editor has the Source View enabled so you can get to the source input to add them.
Thanks
Nik
Hi Vijay,
You really shouldn't be adding style declartions to your RTE content, you should be defining it in a proper stylesheet and then assign the classes to your RTE elements.
If you think you must do it this way (I would not recomend it) then you will need to add the style tag to the allowed elements in your appsettings.json file
To allow the style element you would add 'style' to this list of valid elements,
however like I said I would not recomend doing this, it is really not good practice.
you may also need to set SanitizeTinyMce to false in appsettings file
Added it, but still not working. Could you please share any screenshots if possible which you added it in any of your projects and if it is working.
I haven't added it to any projects, as I said it is not something that I would recommend doing, you really should not be adding style tags in your content
style tags belong in the
<head>
section of your document you really should not be adding them to your content.What is the reason you are attempting to do this?
is working on a reply...