forked from extern/egroupware
Apply missing font & size preferences
This commit is contained in:
parent
15fbd6bde8
commit
26f1e351f3
@ -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 = '<span '.($font||$font_size?'style="':'').($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
|
||||
if (empty($font) && empty($font_size)) $font_span = '';
|
||||
if($font_span)
|
||||
{
|
||||
$config['preference_style'] = $font_span;
|
||||
}
|
||||
self::$request->modifications[$form_name]['config'] = $config;
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user