Events CKEditor';s单击事件不触发

Events CKEditor';s单击事件不触发,events,ckeditor,Events,Ckeditor,我正在使用CKEditor 4.4.3并尝试收听编辑的点击事件: editor.on('click', function (e) { console.log('click event from attaching to the editor'); }); 由于某些原因,click事件从不触发。但是,如果我收听双击事件,则在双击编辑器时会触发该事件 我之前在editor.editable上收听了click事件,但对于未内联的编辑器,它似乎不起作用。为什么单击事件不起作用 一些进一步的

我正在使用CKEditor 4.4.3并尝试收听编辑的点击事件:

editor.on('click', function (e) {
      console.log('click event from attaching to the editor');
});
由于某些原因,click事件从不触发。但是,如果我收听
双击事件,则在双击编辑器时会触发该事件

我之前在
editor.editable
上收听了click事件,但对于未内联的编辑器,它似乎不起作用。为什么
单击事件不起作用

一些进一步的调查:

editor.document
上附加事件处理程序会为每次单击触发,包括在编辑器外的单击

将事件处理程序附加到
编辑器.container
会触发对容器(包括工具栏)的单击


Fiddle:

使用将事件处理程序附加到编辑器的
可编辑的
。这需要在编辑器准备就绪后完成:

editor.on('instanceReady', function (e) {
    editor.editable().on('click', function (event) {
        console.log('clicked');
    });
});

Fiddle:

使用将事件处理程序附加到编辑器的
可编辑的
。这需要在编辑器准备就绪后完成:

editor.on('instanceReady', function (e) {
    editor.editable().on('click', function (event) {
        console.log('clicked');
    });
});

Fiddle:

将侦听器附加到CKEditor中可编辑元素的正确方法:

editor.on( 'contentDom', function() {
    var editable = editor.editable();
    editable.attachListener( editable, 'click', function() {
        // ...
    } );
} );

阅读更多关于为什么必须使用
contentDom
事件而不是在.CKEditor中将侦听器附加到可编辑元素的正确方法的原因:

editor.on( 'contentDom', function() {
    var editable = editor.editable();
    editable.attachListener( editable, 'click', function() {
        // ...
    } );
} );

阅读更多关于为什么必须使用
contentDom
事件而不是在模式之间切换的原因,您的侦听器将被列出。请参阅文档。@Reinmar这是一个更好的解决方案。你能把它作为一个答案吗?@F21+1对于fiddle,在模式之间切换一个lotSwitch,你的听众将被列出。请参阅文档。@Reinmar这是一个更好的解决方案。你能把它作为一个答案吗?@F21+1对于fiddle,有很多当前文档不包含字符串
instancerady
。您可以直接在答案中附加一些文档吗?当前文档不包含字符串
instancerady
。你能把一些文件直接附在答案上吗?