Sanitize pasted content on RTE

I have a external library to do the sanitizing of my RTE control and I'm trying to sanitize the control value on beforePasteCleanup ​but I can't find a way to update the editor value after the sanitizing is done. How can I do that? If I simple update the value with the returned value returned by beforePasteCleanup, the old value misses.


3 Replies

BS Buvana Sathasivam Syncfusion Team March 17, 2022 12:51 PM UTC

Hi Renan, 

Greetings from Syncfusion support. 

We suggest using the afterPasteCleanup event argument value to achieve your requirement. In the below sample, we have changed the pasted content to a custom element and returned it as args.value at the afterPasteCleanup event. Here, you can sanitize the pasted content and return it as args.value. Please see below the code and sample. 

Index.js 
 
var defaultRTE = new ej.richtexteditor.RichTextEditor({ 
  afterPasteCleanup: afterPasteCleanup, 
}); 
defaultRTE.appendTo('#defaultRTE'); 
 
function afterPasteCleanup(args) { 
  // Here, you can sanitize the args.value 
  args.value = '<div>sanitize text</div>'; 
} 



Regards, 
Buvana S 



RM Renan Monteiro da Silva March 18, 2022 06:59 AM UTC

Thanks a lot Buvana, that solves my problem. Unfortunately the documentation hasn't a example of how do it.


Regards.



BS Buvana Sathasivam Syncfusion Team March 18, 2022 07:14 AM UTC

Hi Renan, 

Welcome. We will include documentation and make it available in any of our upcoming releases. 

Regards, 
Buvana S 



Loader.
Up arrow icon