如何在tinymce中禁用复制/粘贴 [英] How to Disable Copy/Paste in tinymce
本文介绍了如何在tinymce中禁用复制/粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的网站上使用了tinymce RTF编辑器。我想在tinymce textarea中禁用复制/粘贴选项。我在stackoverflow上找到了这个方法,但它对我不起作用。
i'm using tinymce RTF editor on my website. i want to disable copy/paste option in tinymce textarea. i found this method on stackoverflow but it didn't work for me.
document.addEventListener('paste', function(e){
e.preventDefault();
});
推荐答案
你应该可以使用 paste_preprocess
如果包含粘贴
插件。如果您使用 paste_preprocess
,请确保将其作为选项传递给 tinymce.init()
,还包括插件。例如:
You should be able to use paste_preprocess
if you include the paste
plugin. If you're using paste_preprocess
, make sure you're passing it as an option to tinymce.init()
, and also including the plugin. For example:
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
paste_preprocess: function (plugin, args) {
console.log("Attempted to paste: ", args.content);
// replace copied text with empty string
args.content = '';
},
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
参见这个小提琴的例子。
这篇关于如何在tinymce中禁用复制/粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文