问题
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