We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to find out the source of copy paste content to RichTextEditor?

Hi Team,

We are using Syncfusion RichTextEditor control in our angular application. Is there a way to find from which type of source( HTML file, MS Word, PDF, etc.) the content was copied and pasted to Syncfusion RichTextEditor?

Thanks,

Shradha Chauhan


3 Replies

VY Vinothkumar Yuvaraj Syncfusion Team April 12, 2023 04:50 AM UTC

Hi Shradha,


You can use the clipboard data from the arguments of actionComplete event to determine which content has been pasted into the Rich Text Editor. Please refer to the following code and attached sample for more information:


<ejs-richtexteditor (actionComplete)='actionComplete($event)'>

</ejs-richtexteditor>


actionComplete (args): void {

if(args.requestType == 'Paste'){

if(args.event.args.clipboardData.getData("text/html").indexOf("MsoNormal") > 0){

console.log("Paste from MS Word"); 

        }

        else if(args.event.args.clipboardData.types.indexOf('text/html') > -1){

console.log('HTML content pasted');

        }

        else if(args.event.args.clipboardData.types.indexOf('text/plain') > -1){

console.log('Plain text content pasted');

        }

    }

  }



Sample : https://stackblitz.com/edit/angular-k3gfxc?file=src%2Fapp.component.ts,src%2Fapp.component.html


Regards,

Vinothkumar



SH Shradha April 14, 2023 06:46 AM UTC

It worked out for me. Thank you very much for resolving my inquiry.



VY Vinothkumar Yuvaraj Syncfusion Team April 17, 2023 08:37 AM UTC

Hi Shradha,


You're welcome! We are glad to assist you.


Loader.
Live Chat Icon For mobile
Up arrow icon