-// Initialize the message editor
-
-function rcmail_editor_init(skin_path)
- {
- tinyMCE.init({ mode : 'specific_textareas',
- accessibility_focus : false,
- apply_source_formatting : true,
- theme : 'advanced',
- plugins : 'emotions,media,nonbreaking,table,searchreplace,spellchecker,visualchars',
- theme_advanced_buttons1 : 'bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,emotions,charmap,code,forecolor,backcolor,fontselect,fontsizeselect, separator,undo,redo,image,media',
- theme_advanced_buttons2 : '',
- theme_advanced_buttons3 : '',
- theme_advanced_toolbar_location : 'top',
- theme_advanced_toolbar_align : 'left',
- extended_valid_elements : 'font[face|size|color|style],span[id|class|align|style]',
- content_css : skin_path + '/editor_content.css',
- editor_css : skin_path + '/editor_ui.css',
- external_image_list_url : 'program/js/editor_images.js'
- });
- }
-
-// Set the state of the HTML/Plain toggles based on the _is_html field value
-function rcmail_set_editor_toggle_states()
- {
- // set the editor toggle based on the state of the editor
-
- var htmlFlag = document.getElementsByName('_is_html')[0];
- var toggles = document.getElementsByName('_editorSelect');
- for(var t=0; t<toggles.length; t++)
- {
- if (toggles[t].value == 'html')
- {
- toggles[t].checked = (htmlFlag.value == "1");
- }
- else
- {
- toggles[t].checked = (htmlFlag.value == "0");
- }
- }
+// Initialize HTML editor
+function rcmail_editor_init(config)
+{
+ var ret, conf = {
+ mode: 'textareas',
+ editor_selector: 'mce_editor',
+ apply_source_formatting: true,
+ theme: 'advanced',
+ language: config.lang,
+ content_css: config.skin_path + '/editor_content.css',
+ theme_advanced_toolbar_location: 'top',
+ theme_advanced_toolbar_align: 'left',
+ theme_advanced_buttons3: '',
+ extended_valid_elements: 'font[face|size|color|style],span[id|class|align|style]',
+ relative_urls: false,
+ remove_script_host: false,
+ gecko_spellcheck: true,
+ convert_urls: false, // #1486944
+ external_image_list_url: 'program/js/editor_images.js',
+ rc_client: rcmail
+ };
+
+ if (config.mode == 'identity')
+ $.extend(conf, {
+ plugins: 'paste,tabfocus',
+ theme_advanced_buttons1: 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr,link,unlink,code,forecolor',
+ theme_advanced_buttons2: ',fontselect,fontsizeselect'
+ });
+ else // mail compose
+ $.extend(conf, {
+ plugins: 'paste,emotions,media,nonbreaking,table,searchreplace,visualchars,directionality,tabfocus' + (config.spellcheck ? ',spellchecker' : ''),
+ theme_advanced_buttons1: 'bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent,ltr,rtl,blockquote,|,forecolor,backcolor,fontselect,fontsizeselect',
+ theme_advanced_buttons2: 'link,unlink,table,|,emotions,charmap,image,media,|,code,search' + (config.spellcheck ? ',spellchecker' : '') + ',undo,redo',
+ spellchecker_languages: (rcmail.env.spellcheck_langs ? rcmail.env.spellcheck_langs : 'Dansk=da,Deutsch=de,+English=en,Espanol=es,Francais=fr,Italiano=it,Nederlands=nl,Polski=pl,Portugues=pt,Suomi=fi,Svenska=sv'),
+ spellchecker_rpc_url: '?_task=utils&_action=spell_html',
+ spellchecker_enable_learn_rpc: config.spelldict,
+ accessibility_focus: false,
+ oninit: 'rcmail_editor_callback'
+ });
+
+ // support external configuration settings e.g. from skin
+ if (window.rcmail_editor_settings)
+ $.extend(conf, window.rcmail_editor_settings);
+
+ tinyMCE.init(conf);
+}
+
+// react to real individual tinyMCE editor init
+function rcmail_editor_callback()
+{
+ var elem = rcube_find_object('_from'),
+ fe = rcmail.env.compose_focus_elem;
+
+ if (elem && elem.type == 'select-one') {
+ rcmail.change_identity(elem);
+ // Focus previously focused element
+ if (fe && fe.id != rcmail.env.composebody) {
+ window.focus(); // for WebKit (#1486674)
+ fe.focus();
+ }