Fix tinymce steals focus from already focused element after executing a command

This commit is contained in:
Hadi Nategh
2018-11-22 15:42:14 +01:00
parent 0326f67f90
commit b6e0cc7fcc

View File

@ -136,12 +136,13 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
file_picker_callback: jQuery.proxy(this._file_picker_callback, this), file_picker_callback: jQuery.proxy(this._file_picker_callback, this),
images_upload_handler: this.options.images_upload_handler, images_upload_handler: this.options.images_upload_handler,
init_instance_callback : jQuery.proxy(this._instanceIsReady, this), init_instance_callback : jQuery.proxy(this._instanceIsReady, this),
auto_focus: false,
plugins: [ plugins: [
"print searchreplace autolink directionality "+ "print searchreplace autolink directionality ",
"visualblocks visualchars image link media template "+ "visualblocks visualchars image link media template ",
"codesample table charmap hr pagebreak nonbreaking anchor toc "+ "codesample table charmap hr pagebreak nonbreaking anchor toc ",
"insertdatetime advlist lists textcolor wordcount imagetools "+ "insertdatetime advlist lists textcolor wordcount imagetools ",
"colorpicker textpattern help paste code searchreplace" "colorpicker textpattern help paste code searchreplace tabfocus"
], ],
toolbar: "formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+ toolbar: "formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+
"link | alignleft aligncenter alignright alignjustify | numlist "+ "link | alignleft aligncenter alignright alignjustify | numlist "+
@ -243,12 +244,17 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
*/ */
_instanceIsReady: function(_editor) { _instanceIsReady: function(_editor) {
console.log("Editor: " + _editor.id + " is now initialized."); console.log("Editor: " + _editor.id + " is now initialized.");
// try to reserve focus state as running command on editor may steal the
// current focus.
var focusedEl = JQuery(':focus');
this.editor = _editor; this.editor = _editor;
this.editor.execCommand('fontName', true, egw.preference('rte_font', 'common')); this.editor.execCommand('fontName', true, egw.preference('rte_font', 'common'));
this.editor.execCommand('fontSize', true, egw.preference('rte_font_size', 'common') this.editor.execCommand('fontSize', true, egw.preference('rte_font_size', 'common')
+ egw.preference('rte_font_unit', 'common')); + egw.preference('rte_font_unit', 'common'));
if (!this.disabled) jQuery(this.editor.editorContainer).css('display', 'flex'); if (!this.disabled) jQuery(this.editor.editorContainer).css('display', 'flex');
this.tinymce_container = this.editor.editorContainer; this.tinymce_container = this.editor.editorContainer;
// go back to reserved focused element
focusedEl.focus();
}, },
/** /**