How to use pasteCleanupSettingsModel/deniedtags?

Hello. After reading the documentation, I still have questions about how to use the pasteCleanupSettingsModel/deniedtags settings.

I tried to use the setting like that, but after pasting code with nav, the controller didn't remove the denied tag:

html.png

script.png

How is the correct way to handle it?

And also, if the pasted content has e.g. a nav tag and I want to replace it to div, how can I do that?


1 Reply

GK Gunasekar Kuppusamy Syncfusion Team October 25, 2021 12:31 PM UTC

Hi Renan,

Greetings from Syncfusion support.

We have validated your queries.

Query1: How to use pasteCleanupSettingsModel/deniedtags?

You can assign the pasteCleanupSettingModel value directly to the pasteCleanupSettings property. We have prepared a sample for your reference please get it below.

Code Snippets:
app.component.html
 <ejs-richtexteditor id="pasteCleanupRTE" #pasteCleanupRTE    [pasteCleanupSettings]="pasteCleanupSettings"  (afterPasteCleanup)="afterPasteCleanup($event)" >
          <ng-template #valueTemplate> </ng-template>
        </ejs-richtexteditor>

app.component.ts
public pasteCleanupSettings: PasteCleanupSettingsModel = {
    deniedTags: ['nav'],
};

Documentationhttps://ej2.syncfusion.com/documentation/rich-text-editor/paste-cleanup/#denied-tags

Query 2: And also, if the pasted content has e.g. a nav tag and I want to replace it with div, how can I do that?

You can change the pasted value using the afterPasteCleanup event. Using this event, we have changed the nav tag to the div tag using the regex.

Code Snippets:
public afterPasteCleanup(e) {
    e.value = e.value.replace(/(<nav)/gim,'<div').replace(/<\/nav>/gim, '</div>');
}

Gunasekar


Loader.
Up arrow icon