Instead of messing with the Bootstrap source, I re-attached the focus event handler.
I looked in the Bootstrap Modal (unminified) code to find where the event handler is being defined, under Modal.enforceFocus():
var that = this
$(document).on('focusin.modal', function (e) {
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
that.$element.focus()
}
})
I then added a method to CKEditor that ammended this function. You can put this wherever; maybe in a file just for CKEditor overrides.
CKEDITOR.bootstrapModalFix = function (modal, $) {
modal.on('shown', function () {
var that = $(this).data('modal');
$(document)
.off('focusin.modal')
.on('focusin.modal', function (e) {
// Add this line
if( e.target.className && e.target.className.indexOf('cke_') == 0 ) return;
// Original
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
that.$element.focus()
}
});
});
};
So now, if I know I am going to load a CKEditor in a Bootstrap modal, I call this method, assuming jQuery is $
:
CKEDITOR.bootstrapModalFix( $('#myModal'), $ )