我在我的网站上使用 tinymce RTF 编辑器。我想在 tinymce textarea 中禁用复制/粘贴选项。我在 stackoverflow 上找到了这个方法,但它对我不起作用。
document.addEventListener('paste', function(e){
e.preventDefault();
});
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"
});
有关示例,请参阅此小提琴。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句