2 +-----------------------------------------------------------------------+
3 | Roundcube editor js library |
5 | This file is part of the Roundcube web development suite |
6 | Copyright (C) 2006, Roundcube Dev, - Switzerland |
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)
19 if (mode == 'identity')
22 editor_selector: 'mce_editor',
23 apply_source_formatting: true,
25 language: editor_lang,
26 content_css: skin_path + '/editor_content.css',
27 plugins: 'paste,tabfocus',
28 theme_advanced_toolbar_location: 'top',
29 theme_advanced_toolbar_align: 'left',
30 theme_advanced_buttons1: 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr,link,unlink,code,forecolor',
31 theme_advanced_buttons2: ',fontselect,fontsizeselect',
32 theme_advanced_buttons3: '',
34 remove_script_host: false,
35 gecko_spellcheck: true
40 editor_selector: 'mce_editor',
41 accessibility_focus: false,
42 apply_source_formatting: true,
44 language: editor_lang,
45 plugins: 'paste,emotions,media,nonbreaking,table,searchreplace,visualchars,directionality,tabfocus' + (spellcheck ? ',spellchecker' : ''),
46 theme_advanced_buttons1: 'bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent,ltr,rtl,blockquote,|,forecolor,backcolor,fontselect,fontsizeselect',
47 theme_advanced_buttons2: 'link,unlink,code,|,emotions,charmap,image,media,|,search' + (spellcheck ? ',spellchecker' : '') + ',undo,redo',
48 theme_advanced_buttons3: '',
49 theme_advanced_toolbar_location: 'top',
50 theme_advanced_toolbar_align: 'left',
51 extended_valid_elements: 'font[face|size|color|style],span[id|class|align|style]',
52 content_css: skin_path + '/editor_content.css',
53 external_image_list_url: 'program/js/editor_images.js',
54 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'),
55 spellchecker_rpc_url: '?_task=utils&_action=spell&tiny=1',
56 gecko_spellcheck: true,
57 remove_script_host: false,
59 convert_urls: false, // #1486944
61 oninit: 'rcmail_editor_callback'
65 // react to real individual tinyMCE editor init
66 function rcmail_editor_callback()
68 var elem = rcube_find_object('_from'),
69 fe = rcmail.env.compose_focus_elem;
71 if (elem && elem.type == 'select-one') {
72 rcmail.change_identity(elem);
73 // Focus previously focused element
74 if (fe && fe.id != rcmail.env.composebody) {
75 window.focus(); // for WebKit (#1486674)
80 // set tabIndex and set focus to element that was focused before
81 rcmail_editor_tabindex(fe && fe.id == rcmail.env.composebody);
82 // Trigger resize (needed for proper editor resizing in some browsers using default skin)
86 // set tabIndex on tinyMCE editor
87 function rcmail_editor_tabindex(focus)
89 if (rcmail.env.task == 'mail') {
90 var editor = tinyMCE.get(rcmail.env.composebody);
92 var textarea = editor.getElement();
93 var node = editor.getContentAreaContainer().childNodes[0];
95 node.tabIndex = textarea.tabIndex;
97 editor.getWin().focus();
102 // switch html/plain mode
103 function rcmail_toggle_editor(select, textAreaId, flagElement)
107 if (select.tagName != 'SELECT')
108 ishtml = select.checked;
110 ishtml = select.value == 'html';
112 var res = rcmail.command('toggle-editor', {id:textAreaId, mode:ishtml?'html':'plain'});
116 setTimeout("rcmail_editor_tabindex(true);", 500);
117 if (flagElement && (flag = rcube_find_object(flagElement)))
121 if (!res && select.tagName == 'SELECT')
122 select.value = 'html';
123 if (flagElement && (flag = rcube_find_object(flagElement)))
126 if (rcmail.env.composebody)
127 rcube_find_object(rcmail.env.composebody).focus();