繁体   English   中英

不会触发ckeditor drop事件

[英]ckeditor drop event not being fired

我能够使用基本的javascript和html触发drop事件:

<div class="drop" style="width: 200px; height: 200px; background: red;"></div>
<a href="#" title="Drag Me">Drag Me</a>

<script>
    $('.drop').on('dragenter',function(e){
        e.preventDefault();
    })
    $('.drop').on('dragover',function(e){
        e.preventDefault();
    })
    $('.drop').on('drop dragdrop',function(){
        console.log("Element was dropped");
    });
</script>

以上工作完全正常。 但是,当我在包含textarea字段的ckeditor对象上放置链接时,绝对没有任何反应:

  $(document).ready(function(){
      var ckeditor = CKEDITOR.instances.quickdoc_editor;
      console.log(ckeditor);
      ckeditor.on('dragenter',function(e){
          e.preventDefault();
      })
      ckeditor.on('dragover',function(e){
          e.preventDefault();
      })
      ckeditor.on('drop dragdrop',function(){
          console.log("Element was dropped");
      });
  })

这是控制台输出中的ckeditor对象:

a {element: CKEDITOR.dom.element, elementMode: 1, name: "quickdoc_editor", _: Object, commands: Object…}_: ObjectactiveEnterMode: 1activeFilter: CKEDITOR.filteractiveShiftEnterMode: 2addMenuGroup: function (b,a){m[b]=a||100}addMenuItem: function (a,c){m[c.group]&&(l[a]=new CKEDITOR.menuItem(this,a,c))}addMenuItems: function (a){for(var c in a)this.addMenuItem(c,a[c])}blockless: falsecommands: Objectconfig: dcontainer: CKEDITOR.dom.elementcontextMenu: CKEDITOR.plugins.contextMenu.CKEDITOR.tools.createClass.$dataProcessor: CKEDITOR.htmlDataProcessordocument: CKEDITOR.dom.documentelement: CKEDITOR.dom.elementelementMode: 1enterMode: 1filter: CKEDITOR.filterfocusManager: CKEDITOR.focusManagergetClipboardData: function (a,d){function c(a){a.removeListener();a.cancel();d(a.data)}function j(a){a.removeListener();a.cancel();i=!0;d({type:f,dataValue:a.data})}function l(){this.customTitle=a&&a.title}var g=!1,f="auto",i=!1;d||(d=a,a=null);b.on("paste",c,null,null,0);b.on("beforePaste",function(a){a.removeListener();g=true;f=a.data.type},getColorFromDialog: function (c,f){var d=function(a){this.removeListener("ok",d);this.removeListener("cancel",d);a="ok"==a.name?this.getValueOf("picker","selectedColor"):null;c.call(f,a)},e=function(a){a.on("ok",d);a.on("cancel",d)};b.execCommand("colordialog");if(b._.storedDialogs&&getMenuItem: function (a){return l[a]}id: "cke_1"instanceReady: truekeystrokeHandler: CKEDITOR.keystrokeHandlerlang: dlangCode: "en"loaded: truemode: "wysiwyg"name: "quickdoc_editor"plugins: ObjectreadOnly: falseremoveMenuItem: function (a){delete l[a]}resetUndo: function (){b.reset();a.fire("saveSnapshot")}shiftEnterMode: 2status: "ready"tabIndex: 0templates: Objecttitle: "Rich Text Editor, quickdoc_editor"toolbar: Array[15]toolbox: uui: CKEDITOR.uiundoManager: gwindow: CKEDITOR.dom.window__proto__: CKEDITOR.editor.CKEDITOR.editor 

我可能做错了什么?

更新:

我能够使Dragenter和Dragover正常工作。 但是仍然拖放不起作用:

  $(document).ready(function(){
      CKEDITOR.on('instanceReady', function (ev) {

          console.log(ev.editor);
          console.log(ev.editor.document);

          ev.editor.document.on('dragenter',function(ev){
              console.log("Yep we get here")
              ev.data.preventDefault(true);
          })

          ev.editor.document.on('dragover',function(ev){
              console.log("Yep we get here too")
              ev.data.preventDefault(true);
          })
          ev.editor.document.on('drop dragdrop',function(){
              console.log("Element was dropped");
          });
      });


  })

终于成功了。 识别到放置事件,但没有拖放。 后者导致没有被解雇。

  $(document).ready(function(){
      CKEDITOR.on('instanceReady', function (ev) {

          ev.editor.document.on('drop',function(){
              console.log("Element was dropped");
          });

          ev.editor.document.on('dragenter',function(ev){
          //    ev.data.preventDefault(true);
          })

          ev.editor.document.on('dragover',function(ev){
          //    ev.data.preventDefault(true);
          })
      });


  })

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM