开发者

Override ENTER key handling in CKEditor dialog

开发者 https://www.devze.com 2023-03-23 10:00 出处:网络
I开发者_开发知识库\'m adding an autocomplete feature to CKEditor 3.6 dialog textinput box. The problem is that selecting a value from the list with ENTER key is not possible because it closes the dia

I开发者_开发知识库'm adding an autocomplete feature to CKEditor 3.6 dialog textinput box. The problem is that selecting a value from the list with ENTER key is not possible because it closes the dialog and all the ENTER key events are stopped from bubbling up the dom. I can see that in _source/plugins/dialog/plugin.js:

// ESC, ENTER
var preventKeyBubblingKeys = { 27 :1, 13 :1 };
var preventKeyBubbling = function( e )
{                        
    if ( e.data.getKeystroke() in preventKeyBubblingKeys )
        e.data.stopPropagation();
};

Is there a way to override this behavior without changing the original code? Any other ideas are also welcome!


Looks like I will have to put all the dialog content in iframe just to work around this. It would be nice if the list of keys prevented from bubbling was configurable and not hardcoded.


For CKEditor 4, I have solved this problem by disabling OK button while autocomplete is working and enabling it again when input loses focus:

CKEDITOR.dialog.getCurrent().getButton("ok").disable(); CKEDITOR.dialog.getCurrent().getButton("ok").enable();

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号