I think electron is right, that ckeditor changes the DOM element directly, and there is no copying onBlur happening. Also there is no "native" ckeditor onBlur event.
That said, I found a way to generate onFocus and onBlur events:
ckeditior provides an currentInstance event that is fired whenever
there is a focus change.
http://docs.ckeditor.com/#!/api/CKEDITOR-event-currentInstance
There is a css class .cke_focus added to the currently
focused element.
Using these two facts (and jQuery for an easy demo) we can write our own onBlur and onFocus Events:
var onCurrentInstance = function(){
var focused = $();
var onBlur = function(obj){
console.log("Blur:", obj);
};
var onFocus = function(obj){
console.log("Focus:", obj);
};
return function(e){
var cke_focus = $(".cke_focus");
if(cke_focus.size() > 0) onFocus(cke_focus);
if(focused.size() > 0) onBlur(focused);
focused = cke_focus;
};
};
CKEDITOR.on( "currentInstance", onCurrentInstance());
This is a very basic example that can be copy&pasted into the samples/inlineall.html example that comes with ckeditor.
Don't forget to add jQuery to the example:
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
UPDATE: here is the same functionality in a more generic way to allow to bind multiple onFocus and onBlur events:
var bindFocusBlur = function(onFocus, onBlur){
var focused = $();
return function(e){
var cke_focus = $(".cke_focus");
if(cke_focus.size() > 0 && typeof onFocus === "function"){
onFocus(cke_focus);
}
if(focused.size() > 0 && typeof onBlur === "function"){
onBlur(focused);
}
focused = cke_focus;
};
};
Used like this:
var onFocus = function(){};
var onBlur = function(){};
var onFocus2 = function(){};
CKEDITOR.on( "currentInstance", bindFocusBlur( onFocus, onBlur ));
CKEDITOR.on( "currentInstance", bindFocusBlur( onFocus2 ));