覆盖 CKEditor 对话框中的 ENTER 键处理
我正在向 CKEditor 3.6 对话框文本输入框添加自动完成功能。 问题在于,无法使用 ENTER 键从列表中选择一个值,因为它会关闭对话框,并且所有 ENTER 键事件都会停止在 dom 中冒泡。 我可以在 _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();
};
有没有办法在不更改原始代码的情况下覆盖此行为? 也欢迎任何其他想法!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来我必须将所有对话框内容放入 iframe 中才能解决此问题。
如果防止冒泡的键列表是可配置的而不是硬编码的,那就太好了。
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.
对于 CKEditor 4,我通过在自动完成工作时禁用“确定”按钮并在输入失去焦点时再次启用它来解决了这个问题:
CKEDITOR.dialog.getCurrent().getButton("ok").disable();
CKEDITOR.dialog.getCurrent().getButton("ok").enable();
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();