How to blur caret in CKEditor?

痴心易碎 提交于 2019-12-12 02:48:11

问题


I am using CKEditor in inline mode. I am focusing and immediately blurring (for testing) using the following:

var editor = CKEDITOR.dom.element.get( e.currentTarget.getDOMNode());

editor.getEditor().focus();
editor.getEditor().focusManager.blur(true);

I want to blur the editor and focusManger.blur(true) results in the toolbar being hidden. However, the caret is still focused. For some reason, I cannot find a way to defocus and remove the caret. I have tried calling focus() on another DOM element, but the caret still persists.

How can I call blur() to remove the caret as well?


回答1:


Isn't this enough?

editor.editable().$.blur();

It works for me.




回答2:


The only way I was able to solve this is to blur the contenteditable div:

CKEDITOR.currentInstance.element.$; //Grab the DOM node which is the contenteditable
CKEDITOR.currentInstance.element.$.blur(); //Blur it
CKEDITOR.currentInstance.focusManager.blur(true); //CKEditor's blur hides the toolbar


来源:https://stackoverflow.com/questions/23541839/how-to-blur-caret-in-ckeditor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!