简体   繁体   中英

Copy Pasting Content in bootstrap-wysiwyg

im new to jquery.im building CRM that takes content from User.For the description field i have used bootstrap-wysiwyg editor.Problem comes when i try to copy content from other websites to RTE it retains formatting of copied text. How can i remove that formatting and convert it to plain text? So that user can only upload content using editor controls. When i searched for the solution eveything i got it suggestion for client to format it as 'Paste as Plain Text' in Wordpad and then paste to editor but what will be the smartest way to handle it via coding rather then depending upon user.

You could try catching the paste event and then sanitizing the contents that land into your wysiwyg:

$("#my-wysiwyg").bind("paste", function(){ ... a paste happened... } );

You can't actually (reliably) get the contents of the paste and the event fires before the content lands in the wysiwyg - therefore you might have to add a timer for the sanitizing function to pick up the content once it's landed after the paste.

Remember to sanitize at the server as well for security reasons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM