diff --git a/program/actions/mail/compose.php b/program/actions/mail/compose.php index 6d81b68a4ec..760404ad7f9 100644 --- a/program/actions/mail/compose.php +++ b/program/actions/mail/compose.php @@ -513,17 +513,19 @@ public static function spellchecker_init() // include GoogieSpell $rcmail->output->include_script('googiespell.js'); - $rcmail->output->set_env('googiespell_asset_url', $rcmail->output->asset_url($rcmail->output->get_skin_path())); - $rcmail->output->set_env('googiespell_base_url', $rcmail->url(['_task' => 'utils', '_action' => 'spell', '_remote' => 1])); - $rcmail->output->set_env('googiespell_use_dict', !empty($dictionary) ? 'true' : 'false'); - $rcmail->output->set_env('googiespell_lang_chck_spell', rcube::JQ(rcube::Q($rcmail->gettext('checkspelling')))); - $rcmail->output->set_env('googiespell_lang_rsm_edt', rcube::JQ(rcube::Q($rcmail->gettext('resumeediting')))); - $rcmail->output->set_env('googiespell_lang_close', rcube::JQ(rcube::Q($rcmail->gettext('close')))); - $rcmail->output->set_env('googiespell_lang_revert', rcube::JQ(rcube::Q($rcmail->gettext('revertto')))); - $rcmail->output->set_env('googiespell_lang_no_error_found', rcube::JQ(rcube::Q($rcmail->gettext('nospellerrors')))); - $rcmail->output->set_env('googiespell_lang_learn_word', rcube::JQ(rcube::Q($rcmail->gettext('addtodict')))); - $rcmail->output->set_env('googiespell_languages', $spellcheck_langs); - $rcmail->output->set_env('googiespell_currentLanguage', $lang); + $rcmail->output->set_env('googiespell_conf', [ + 'asset_url' => $rcmail->output->asset_url($rcmail->output->get_skin_path()), + 'base_url' => $rcmail->url(['_task' => 'utils', '_action' => 'spell', '_remote' => 1]), + 'use_dict' => !empty($dictionary) ? 'true' : 'false', + 'lang_chck_spell' => $rcmail->gettext('checkspelling'), + 'lang_rsm_edt' => $rcmail->gettext('resumeediting'), + 'lang_close' => $rcmail->gettext('close'), + 'lang_revert' => $rcmail->gettext('revertto'), + 'lang_no_error_found' => $rcmail->gettext('nospellerrors'), + 'lang_learn_word' => $rcmail->gettext('addtodict'), + 'languages' => $spellcheck_langs, + 'currentLanguage' => $lang, + ]); $rcmail->output->add_label('checking'); $rcmail->output->set_env('spell_langs', $spellcheck_langs); diff --git a/program/js/app.js b/program/js/app.js index ed30c5b738b..828ce4c8d28 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -424,7 +424,7 @@ function rcube_webmail() { // initialize HTML editor this.editor_init(null, this.env.composebody); - if (window.googie) { + if (this.editor.spellchecker) { this.env.compose_commands.push('spellcheck'); this.enable_command('spellcheck', true); } @@ -4170,7 +4170,7 @@ function rcube_webmail() { // re-enable commands that operate on the compose body ref.enable_command('toggle-editor', 'insert-response', true); - ref.enable_command('spellcheck', !!window.googie); + ref.enable_command('spellcheck', !!ref.editor.spellchecker); ref.enable_command('insert-sig', !!(ref.env.signatures && ref.env.identity && ref.env.signatures[ref.env.identity])); ref.triggerEvent('compose-encrypted', { active: false }); diff --git a/program/js/editor.js b/program/js/editor.js index 8592a4932ab..c9171731f7d 100644 --- a/program/js/editor.js +++ b/program/js/editor.js @@ -78,15 +78,12 @@ function rcube_text_editor(config, id) { }; this.init = function () { - this.googiespell_init(); - if (window.googie) { - config.spellchecker = window.googie; - } + var googie = this.googiespell_init(); // register spellchecker for plain text editor this.spellcheck_observer = function () {}; - if (config.spellchecker) { - this.spellchecker = config.spellchecker; + if (googie) { + this.spellchecker = googie; if (config.spellcheck_observer) { this.spellchecker.spelling_state_observer = this.spellcheck_observer = config.spellcheck_observer; } @@ -957,23 +954,26 @@ function rcube_text_editor(config, id) { this.googiespell_init = function () { // Don't initialize if it's already present or dependencies are not met. - if (window.googie || !window.GoogieSpell || !rcmail.env.googiespell_asset_url) { + if (!window.GoogieSpell || !rcmail.env.googiespell_conf) { return; } - window.googie = new window.GoogieSpell( - rcmail.env.googiespell_asset_url + '/images/googiespell/', - rcmail.env.googiespell_base_url + '&lang=', - rcmail.env.googiespell_use_dict + var conf = rcmail.env.googiespell_conf; + var googie = new window.GoogieSpell( + conf.asset_url + '/images/googiespell/', + conf.base_url + '&lang=', + conf.use_dict ); - googie.lang_chck_spell = rcmail.env.googiespell_lang_chck_spell; - googie.lang_rsm_edt = rcmail.env.googiespell_lang_rsm_edt; - googie.lang_close = rcmail.env.googiespell_lang_close; - googie.lang_revert = rcmail.env.googiespell_lang_revert; - googie.lang_no_error_found = rcmail.env.googiespell_lang_no_error_found; - googie.lang_learn_word = rcmail.env.googiespell_lang_learn_word; - googie.setLanguages(rcmail.env.googiespell_languages); - googie.setCurrentLanguage(rcmail.env.googiespell_currentLanguage); + googie.lang_chck_spell = conf.lang_chck_spell; + googie.lang_rsm_edt = conf.lang_rsm_edt; + googie.lang_close = conf.lang_close; + googie.lang_revert = conf.lang_revert; + googie.lang_no_error_found = conf.lang_no_error_found; + googie.lang_learn_word = conf.lang_learn_word; + googie.setLanguages(conf.languages); + googie.setCurrentLanguage(conf.currentLanguage); googie.setDecoration(false); googie.decorateTextarea(rcmail.env.composebody); + + return googie; }; }