简体   繁体   English

在bootstrap-wysiwyg中复制粘贴内容

[英]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. 我是jquery.im的新用户,它构建了从用户那里获取内容的CRM。对于描述字段,我使用了bootstrap-wysiwyg编辑器。当我尝试将内容从其他网站复制到RTE时,问题来了,它保留了复制文本的格式。 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. 出于安全原因,请记住还要在服务器上进行清理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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