* Mail: setting default font-face and -size reliable and remove space in front of cursor

This commit is contained in:
Ralf Becker 2015-03-31 17:04:10 +00:00
parent 82d09611ad
commit 38f4980849
3 changed files with 12 additions and 23 deletions

View File

@ -38,7 +38,9 @@ class etemplate_widget_htmlarea extends etemplate_widget
// 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.'; ':'').'">';
$font_span = '<span style="width: 100%; display: inline-block; '.
($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').
'">&#8203;</span>';
if (empty($font) && empty($font_size)) $font_span = '';
if($font_span)
{

View File

@ -151,22 +151,9 @@ var et2_htmlarea = et2_inputWidget.extend([et2_IResizeable],
// Add in user font preferences
if (self.options.config.preference_style && !e.editor.getData())
{
e.editor.document.getBody().appendHtml(self.options.config.preference_style);
e.editor.document.getBody().setHtml(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();
});
// Drag & drop of images inline won't work, because of database
@ -269,7 +256,7 @@ var et2_htmlarea = et2_inputWidget.extend([et2_IResizeable],
return null;
}
},
/**
* Resize htmlNode tag according to window size
* @param {type} _height excess height which comes from window resize

View File

@ -1051,8 +1051,8 @@ class mail_compose
// User preferences for style
$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
$font_size = egw_ckeditor_config::font_size_from_prefs();
$font_part = '<span '.($font||$font_size?'style="':'').($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
$font_span = $font_part.'&nbsp;'.'</span>';
$font_part = '<span style="width:100%; display: inline-block; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">';
$font_span = $font_part.'&#8203;</span>';
if (empty($font) && empty($font_size)) $font_span = '';
}
// the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span
@ -1084,8 +1084,8 @@ class mail_compose
}
}
if($content['mimeType'] == 'html') {
$before = (!empty($font_span) && !($insertSigOnTop === 'below')?$font_span:'&nbsp;').($disableRuler?''/*($sigTextStartsWithBlockElement?'':'<p style="margin:0px;"/>')*/:'<hr style="border:1px dotted silver; width:90%;">');
$inbetween = '&nbsp;<br>';
$before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">';
$inbetween = '';
} else {
$before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n");
$inbetween = "\r\n";
@ -1101,7 +1101,7 @@ class mail_compose
}
else
{
$content['body'] = $before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body'];
$content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body'];
}
}
else
@ -1289,13 +1289,13 @@ class mail_compose
$etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount']));
// join again mailaccount and identity
$content['mailaccount'] .= ':'.$content['mailidentity'];
// Resolve distribution list before send content to client
foreach(array('to', 'cc', 'bcc', 'replyto') as $f)
{
if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
}
$content['to'] = self::resolveEmailAddressList($content['to']);
//error_log(__METHOD__.__LINE__.array2string($content));
$etpl->exec('mail.mail_compose.compose',$content,$sel_options,$readonlys,$preserv,2);