2 +-----------------------------------------------------------------------+
3 | Roundcube editor js library |
5 | This file is part of the Roundcube web development suite |
6 | Copyright (C) 2006, The Roundcube Dev Team |
7 | Licensed under the GNU GPL |
9 +-----------------------------------------------------------------------+
10 | Author: Eric Stadtherr <estadtherr@gmail.com> |
11 +-----------------------------------------------------------------------+
13 $Id: editor.js 000 2006-05-18 19:12:28Z roundcube $
16 // Initialize HTML editor
17 function rcmail_editor_init(config)
21 editor_selector: 'mce_editor',
22 apply_source_formatting: true,
24 language: config.lang,
25 content_css: config.skin_path + '/editor_content.css',
26 theme_advanced_toolbar_location: 'top',
27 theme_advanced_toolbar_align: 'left',
28 theme_advanced_buttons3: '',
29 extended_valid_elements: 'font[face|size|color|style],span[id|class|align|style]',
31 remove_script_host: false,
32 gecko_spellcheck: true,
33 convert_urls: false, // #1486944
34 external_image_list_url: 'program/js/editor_images.js',
38 if (config.mode == 'identity')
40 plugins: 'paste,tabfocus',
41 theme_advanced_buttons1: 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr,link,unlink,code,forecolor',
42 theme_advanced_buttons2: ',fontselect,fontsizeselect'
46 plugins: 'paste,emotions,media,nonbreaking,table,searchreplace,visualchars,directionality,tabfocus' + (config.spellcheck ? ',spellchecker' : ''),
47 theme_advanced_buttons1: 'bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent,ltr,rtl,blockquote,|,forecolor,backcolor,fontselect,fontsizeselect',
48 theme_advanced_buttons2: 'link,unlink,table,|,emotions,charmap,image,media,|,code,search' + (config.spellcheck ? ',spellchecker' : '') + ',undo,redo',
49 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'),
50 spellchecker_rpc_url: '?_task=utils&_action=spell_html',
51 spellchecker_enable_learn_rpc: config.spelldict,
52 accessibility_focus: false,
53 oninit: 'rcmail_editor_callback'
56 // support external configuration settings e.g. from skin
57 if (window.rcmail_editor_settings)
58 $.extend(conf, window.rcmail_editor_settings);
63 // react to real individual tinyMCE editor init
64 function rcmail_editor_callback()
66 var elem = rcube_find_object('_from'),
67 fe = rcmail.env.compose_focus_elem;
69 if (elem && elem.type == 'select-one') {
70 rcmail.change_identity(elem);
71 // Focus previously focused element
72 if (fe && fe.id != rcmail.env.composebody) {
73 window.focus(); // for WebKit (#1486674)
78 // set tabIndex and set focus to element that was focused before
79 rcmail_editor_tabindex(fe && fe.id == rcmail.env.composebody);
80 // Trigger resize (needed for proper editor resizing in some browsers using default skin)
84 // set tabIndex on tinyMCE editor
85 function rcmail_editor_tabindex(focus)
87 if (rcmail.env.task == 'mail') {
88 var editor = tinyMCE.get(rcmail.env.composebody);
90 var textarea = editor.getElement();
91 var node = editor.getContentAreaContainer().childNodes[0];
93 node.tabIndex = textarea.tabIndex;
95 editor.getWin().focus();
100 // switch html/plain mode
101 function rcmail_toggle_editor(select, textAreaId, flagElement)
105 if (select.tagName != 'SELECT')
106 ishtml = select.checked;
108 ishtml = select.value == 'html';
110 var res = rcmail.command('toggle-editor', {id:textAreaId, mode:ishtml?'html':'plain'});
114 setTimeout("rcmail_editor_tabindex(true);", 500);
115 if (flagElement && (flag = rcube_find_object(flagElement)))
119 if (flagElement && (flag = rcube_find_object(flagElement)))
122 if (rcmail.env.composebody)
123 rcube_find_object(rcmail.env.composebody).focus();
126 if (select.tagName == 'SELECT')
127 select.value = 'html';
128 else if (select.tagName == 'INPUT')
129 select.checked = true;