admin管理员组

文章数量:1293047

Problem: When drag and drop images in Firefox into the CKEditor Window, the image are automaticly encoded in base64.

Now i want to disable this. I tried it with:

config.removePlugins = 'dragdrop';

but it's not working at all. Also tried it with a old Plugin (imagepaste), but not working either...

Is there a known solution out there? Thx!

Problem: When drag and drop images in Firefox into the CKEditor Window, the image are automaticly encoded in base64.

Now i want to disable this. I tried it with:

config.removePlugins = 'dragdrop';

but it's not working at all. Also tried it with a old Plugin (imagepaste), but not working either...

Is there a known solution out there? Thx!

Share Improve this question asked Feb 25, 2014 at 18:46 user2270134user2270134 992 silver badges8 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

At first I tried to disable Base64 with config.removePlugins = 'dragdrop,basket';, but it didn't work at all.

Then I found this link, which helped me to solve this problem and wrote a plugin to do the job. Here it is with instructions:

To use it you have to create a folder inside of ./plugins named dropoff. Then create a file named plugin.js with this content:

CKEDITOR.plugins.add('dropoff', {
     init: function (editor) {

          function rejectDrop(event) {
              event.data.preventDefault(true);
          };

          editor.on('contentDom', function() {
            editor.document.on('drop',rejectDrop);
          });

      }
});

After that, you have to register it on CKEditor's config.js.

config.extraPlugins = 'dropoff';

If you already using an extra plugin just put a , between them like this:

config.extraPlugins = 'mypreviousplugin,dropoff';

And be Happy! \o/

Here i found the solution to disable the drag and drop in ckeditor

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

I am using a ckeditor5 custom build which includes the Base64UploadAdapter plugin. So, to disable this plugin for some particular views, I just added the "removePlugins" instruction to the editor configuration. Then, dragging and dropping images gets disabled.

  configEditor = {
    removePlugins: [ 'Base64UploadAdapter' ],
    toolbar: ['heading', '|', 'bold', 'bulletedList', 'numberedList'],
  };

本文标签: javascriptCKEditordisable image drag and dropStack Overflow