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(skin_path, editor_lang, spellcheck, mode)
21 editor_selector: 'mce_editor',
22 apply_source_formatting: true,
24 language: editor_lang,
25 content_css: 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 (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' + (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' + (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 accessibility_focus: false,
52 oninit: 'rcmail_editor_callback'
55 // support external configuration settings e.g. from skin
56 if (window.rcmail_editor_settings)
57 $.extend(conf, window.rcmail_editor_settings);
62 // react to real individual tinyMCE editor init
63 function rcmail_editor_callback()
65 var elem = rcube_find_object('_from'),
66 fe = rcmail.env.compose_focus_elem;
68 if (elem && elem.type == 'select-one') {
69 rcmail.change_identity(elem);
70 // Focus previously focused element
71 if (fe && fe.id != rcmail.env.composebody) {
72 window.focus(); // for WebKit (#1486674)
77 // set tabIndex and set focus to element that was focused before
78 rcmail_editor_tabindex(fe && fe.id == rcmail.env.composebody);
79 // Trigger resize (needed for proper editor resizing in some browsers using default skin)
83 // set tabIndex on tinyMCE editor
84 function rcmail_editor_tabindex(focus)
86 if (rcmail.env.task == 'mail') {
87 var editor = tinyMCE.get(rcmail.env.composebody);
89 var textarea = editor.getElement();
90 var node = editor.getContentAreaContainer().childNodes[0];
92 node.tabIndex = textarea.tabIndex;
94 editor.getWin().focus();
99 // switch html/plain mode
100 function rcmail_toggle_editor(select, textAreaId, flagElement)
104 if (select.tagName != 'SELECT')
105 ishtml = select.checked;
107 ishtml = select.value == 'html';
109 var res = rcmail.command('toggle-editor', {id:textAreaId, mode:ishtml?'html':'plain'});
113 setTimeout("rcmail_editor_tabindex(true);", 500);
114 if (flagElement && (flag = rcube_find_object(flagElement)))
118 if (!res && select.tagName == 'SELECT')
119 select.value = 'html';
120 if (flagElement && (flag = rcube_find_object(flagElement)))
123 if (rcmail.env.composebody)
124 rcube_find_object(rcmail.env.composebody).focus();