【问题标题】:CKEditor - disable image drag and dropCKEditor - 禁用图像拖放
【发布时间】:2019-12-20 03:39:37
【问题描述】:

问题: 将 Firefox 中的图片拖放到 CKEditor 窗口时,图片会自动以 base64 编码。

现在我想禁用它。我试过了:

config.removePlugins = 'dragdrop';

但它根本不起作用。还尝试使用旧插件(imagepaste),但也无法正常工作......

那里有已知的解决方案吗?谢谢!

【问题讨论】:

    标签: javascript ckeditor


    【解决方案1】:

    起初我尝试使用config.removePlugins = 'dragdrop,basket'; 禁用 Base64,但它根本不起作用。

    然后我发现this link, 帮助我解决了这个问题,并找到了wrote a plugin 来完成这项工作。这里有说明:

    要使用它,您必须在 ./plugins 内创建一个名为 dropoff 的文件夹。 然后创建一个名为plugin.js 的文件,内容如下:

    CKEDITOR.plugins.add('dropoff', {
         init: function (editor) {
    
              function rejectDrop(event) {
                  event.data.preventDefault(true);
              };
    
              editor.on('contentDom', function() {
                editor.document.on('drop',rejectDrop);
              });
    
          }
    });
    

    之后,你必须在CKEditor的config.js注册。

    config.extraPlugins = 'dropoff';
    

    如果您已经使用了额外的插件,只需在它们之间添加一个,,如下所示:

    config.extraPlugins = 'mypreviousplugin,dropoff';
    

    祝你快乐! \o/

    【讨论】:

    • 谢谢迈克尔,我正在学习提高我的英语,但还差得很远。
    【解决方案2】:

    在这里我找到了在ckeditor中禁用拖放的解决方案

    ed.on('instanceReady', (ev) =>{
          CKEDITOR.plugins.clipboard.preventDefaultDropOnElement(ev.editor.document);
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-09
      • 1970-01-01
      • 1970-01-01
      • 2019-06-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多