In Kentico 13 Rich Text removed CSS/Script code.

Kaur Navneet asked on February 27, 2024 08:10

Hi Team

I have an issue (using v13.0.116) with the CSS/script automatically removing from the Rich Text editor. when I add a script/CSS in the rich text editor they remove it automatically.

I already added a custom config in the appsettings.json file.

"CMSHtmlSanitizerAllowedTags": ["script", "a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "queue", "rp", "rt", "ruby", "s", "samp", "section", "select", "small", "source", "span", "strike", "strong", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr" ], Is there any way to configure the rich text so it can accept CSS/script code?

Best Regards, Navneet

Recent Answers


Brenden Kehren answered on February 27, 2024 15:40

Is it removing the tags in the Page Builder application or on the Form tab? There are two different WYSIWYG editors in the system. The CKEditor is used on the Form tab and the Froala editor is used in Page Builder.

While this article is a few years old, it's still applicable to the Kentico CMS v13 UI for CKEditor.

This documentation is in regards to the Froala editor

0 votesVote for this answer Mark as a Correct answer

Kaur Navneet answered on February 28, 2024 06:44

Hi Brenden Kehren Thanks for update It's removing the tags in the Page Builder application and I already used them in the appsettings.json file but still, there are issues with the Rich text editor.

I used <editable-area area-identifier="TextZoneArea" /> in page template/master page and CMSHtmlSanitizerAllowedTags in appsettings.json file in Kentico 13

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 28, 2024 06:50

Is the editor stripping the tags or is your live site not displaying the HTML? Are you using Html.Raw(model.fieldname) to output the actual HTML field value?

0 votesVote for this answer Mark as a Correct answer

Kaur Navneet answered on February 28, 2024 07:30

No, I'm adding html and script tags under the rich text editor code.

0 votesVote for this answer Mark as a Correct answer

Wolic Kent answered on February 28, 2024 11:04

Hi Navneet,

It seems like your issue might be related to how the Page Builder's Froala editor is handling the script and HTML tags, rather than the CKEditor. Since you've already tried updating the appsettings.json, you might want to ensure that your HTML output is being rendered correctly on the live site. Using Html.Raw(model.fieldname) in your views can ensure that your HTML and script tags are not being sanitized or stripped away when rendered. This approach allows you to output the actual HTML field value directly, preserving your script and style tags.

Best regards.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.