cancel
Showing results for 
Search instead for 
Did you mean: 

CKEditor: disable Advanced Content Filter (ACF)

0 Kudos

When I add custom html code into a paragraph component in SmartEdit, the default CKEditor setup will in most cases delete "unsafe" html and thus mess up my custom html code.

How can I add custom html code to my content pages via SmartEdit?

Accepted Solutions (0)

Answers (3)

Answers (3)

safin
Advisor
Advisor
0 Kudos

Hi Martin,

You can try this to disable ACF:

  • Doesn't set cms.components.allowUnsafeJavaScript to true
  • Open and edit hybris/bin/modules/smartedit/smartedit/apps/smartedit-commons/src/components/genericEditor/widgets/RichTextField/RichTextFieldModule.ts to disable ACF like this:
import { CommonModule } from '@angular/common';
...
@NgModule({
    imports: [CommonModule, FormsModule, TranslateModule.forChild(), BadgeLabelModule],
    providers: [
        ...
        {
            provide: RICH_TEXT_CONFIGURATION,
            useValue: {
                toolbar: 'full',
                toolbar_full: [
                    ...
                ],
                ...
                allowedContent: true,
                ...
            }
        }
    ],
    ...
})
export class RichTextFieldModule {}
  • Go to <HYBRIS_BIN_DIR>/platform and clean build your system: ant clean build.
safin
Advisor
Advisor
0 Kudos

i just tried to set cms.components.allowUnsafeJavaScript to true, the content value in CMSParagraph component will kept the same as you input.

My experiment env is as follows:

  • use SAP Commerce 2205 version
  • set cms.components.allowUnsafeJavaScript to true in local.properties
  • startup SAP Commerce server, then open SmartEdit, create and insert a new CMSParagraph component in the electronics homepage
  • set the content for the new created CMSParagraph component as "<body><h1>hello</h1></body>"
  • after it's inserted, open backoffice, find the new created CMSParagraph component, the content is still "<body><h1>hello</h1></body>"

Please note, if you edit the new created CMSParagraph component in SmartEdit, click the source button, you will find it becomes "<h1>hello</h1>", i think this is processed by SmartEdit editor to show just valid part, but the content value is not changed.

0 Kudos

Thanks for your input.

I use SAP CC 2011.

For simple HTML examples it works fine, but still in some cases the editor completely messes up my code as soon as I switch from the source code view to WYSIWYG view or if I save and close the paragraph component.

If there's no other option I would have to wait for the 2205 update of my environment and try again.

safin
Advisor
Advisor
0 Kudos

If you want to add custom html code in paragraph component, please set the value of the cms.components.allowUnsafeJavaScript property to true in the local.properties, the default value for cms.components.allowUnsafeJavaScript is false

0 Kudos

Thanks for your quick reply, but we already set this to true and it didn't help.

I found this information regarding the CKEditor setting: https://ckeditor.com/docs/ckeditor4/latest/guide/dev_acf.html#allow-everything-disable-acf

But it seems the ACF of CKEditor cannot be disabled in SmartEdit 😕

safin
Advisor
Advisor

Hi Martin,

As you set cms.components.allowUnsafeJavaScript to true, the html content in paragraph component should not be sanitized in the current implementation.

So this is strange as you said it doesn't work, would you please help to paste some custom html code which will be sanitized even though cms.components.allowUnsafeJavaScript is set to true?

Thanks