In Kentico 13 Rich Text stripping out css code.

Saurabh Kumar asked on June 22, 2023 06:40

Before in Kentico's older version, we were able to put CSS style code or js code along with the HTML code in the rich text code body but now it strips out style code or script code and keeps only HTML-related code only.

Is there any way to configure the rich text so it is able to accept CSS code?

Recent Answers


Radek Macalik answered on June 22, 2023 12:20

Hello.

In general, for similar tasks, you could utilize our HTMLSanitizer as per https://docs.xperience.io/configuring-xperience/configuring-the-environment-for-content-editors/configuring-the-rich-text-editor-for-page-builder which has been introduced in hotfix 13.0.110.

However, can you please clarify what particular tags/style properties you have this problem with? I ask since we support standard CSS styles so maybe you are using some special property that is not allowed by default? Can you provide particular examples, please? Thank you.

Best Regards, Radek Macalik

0 votesVote for this answer Mark as a Correct answer

Rory Aherne answered on October 10, 2023 10:02

I am also having this issue (using v13.0.124) with the justify-content property in my css.

This is not a tag or attribute so I don't see how the HTMLSanitizer helps (unless the documentation isn't complete?).

This is my custom config:

configurations["default"] = {
    toolbarVisibleWithoutSelection: true,
    htmlUntouched: true,
    paragraphFormat: {
        N: "Normal",
        H1: "Headline 1",
        H2: "Headline 2",
        H3: "Headline 3",
        H4: "Headline 4",
        H5: "Headline 5",
        H6: "Headline 6",
    },
    htmlRemoveTags: [],
    htmlAllowedTags: ['.*'],
    htmlAllowedStyleProps: ['.*'], //this is the default anyway
};

Yes I cleared the browser cache (and checked in the network tab to see if the new config loaded).

I don't think it's Froala stripping it away as when I click apply and close in the Froala editor and open it again the property justify-content is still there.

Only when I click Apply on the widget properties dialog does it get stripped away.

Is there some sort of CMSHtmlSanitizerAllowedStyles like property not mentioned in the docs? Searching for CMSHtmlSanitizerAllowed* only gives us tags and attributes.

Thanks,

Rory

0 votesVote for this answer Mark as a Correct answer

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