如何在TinyMCE 4上禁用拖动图像?我用jQuery
:
jQuery('#tinymce img').on('dragstart', function(event) {
event.preventDefault();
});
但它不起作用......
我找到了一些更好的解决方案。您可以使用paste_block_drop
插件中的paste
选项
tinymce.init({
plugins: 'paste image',
paste_block_drop: true
)};
这个选项的作用就是让你阻止从/向编辑器及其内部的拖放。
注意:测试版本4.7.4虽然我没有找到它们当前(当我回答时)paste
插件documentation,而是我发现它在他们的存档documentation版本4.3.12
如果您使用的是Power Paste Plugin,则可以使用powerpaste_block_drop: true
选项来禁用所有拖放内容到编辑器中。你会找到关于这个here的文档(感谢评论中的@Kurt)
使用tinymce配置参数setup
并为此使用处理程序:
setup: function(editor) {
editor.on('init', function(event) {
$(editor.getBody().parentNode).bind('dragover dragenter dragend drag drop', function(e) {
e.stopPropagation();
e.preventDefault();
});
$(editor.getDoc()).bind('draggesture', function(e) {
e.stopPropagation();
e.preventDefault();
});
});
}