diff --git a/etemplate/inc/class.etemplate_widget_htmlarea.inc.php b/etemplate/inc/class.etemplate_widget_htmlarea.inc.php index f92ab425a7..f585722f29 100644 --- a/etemplate/inc/class.etemplate_widget_htmlarea.inc.php +++ b/etemplate/inc/class.etemplate_widget_htmlarea.inc.php @@ -35,6 +35,15 @@ class etemplate_widget_htmlarea extends etemplate_widget $config = egw_ckeditor_config::get_ckeditor_config_array($this->attrs['mode'], $this->attrs['height'], $this->attrs['expand_toolbar'],$this->attrs['base_href'] ); + // User preferences + $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; + $font_size = egw_ckeditor_config::font_size_from_prefs(); + $font_span = ''; + if (empty($font) && empty($font_size)) $font_span = ''; + if($font_span) + { + $config['preference_style'] = $font_span; + } self::$request->modifications[$form_name]['config'] = $config; } diff --git a/etemplate/js/et2_widget_htmlarea.js b/etemplate/js/et2_widget_htmlarea.js index 1036ab4502..1c53d51535 100644 --- a/etemplate/js/et2_widget_htmlarea.js +++ b/etemplate/js/et2_widget_htmlarea.js @@ -136,6 +136,33 @@ var et2_htmlarea = et2_inputWidget.extend( delete self.value; } } + + if(this.ckeditor && this.options.config.preference_style) + { + this.ckeditor.on('instanceReady', function(e) { + + // Add in user font preferences + if (self.options.config.preference_style && !e.editor.getData()) + { + e.editor.document.getBody().appendHtml(self.options.config.preference_style); + delete self.options.config.preference_style; + } + + var range = e.editor.createRange(); + range.collapse(true); + range.selectNodeContents(e.editor.document.getBody()); + range.collapse(true); + range.select(); + + //this stuff is needed, as the above places the caret just before the span tag + var sN = range.startContainer.getNextSourceNode(); + //FF is selecting the span with getNextSourceNode, other browsers need to fetch it with getNext + range.selectNodeContents(((typeof sN.getName==="function") && sN.getName()=="span"?range.startContainer.getNextSourceNode():range.startContainer.getNextSourceNode().getNext())); + range.collapse(true); + range.select(); + }); + } + }, destroy: function() {