如何在tinymce中禁用复制/粘贴

mad*_*iha 4 javascript jquery codeigniter angularjs

我在我的网站上使用tinymce RTF 编辑器。我想禁用tinymce文本区域中的复制/粘贴选项。我在 stackoverflow 上找到了这个方法,但它对我不起作用。

如何防止/禁用 Tinymce 中的复制和粘贴

document.addEventListener('paste', function(e){
   e.preventDefault(); 
});
Run Code Online (Sandbox Code Playgroud)

And*_*bie 5

paste_preprocess如果包含该插件,您应该能够使用paste。如果您正在使用paste_preprocess,请确保将其作为选项传递给tinymce.init(),并且还包括该插件。例如:

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"
});
Run Code Online (Sandbox Code Playgroud)

有关示例,请参阅更新的小提琴。