Better handling of rcube_text_editor.replace()'s input argument, some simplification

pull/5490/head
Aleksander Machniak 8 years ago
parent edea8732a6
commit 1727071816

@ -4446,14 +4446,10 @@ function rcube_webmail()
return result; return result;
}; };
// Inserts a predefined response to the compose editor
this.insert_response = function(key) this.insert_response = function(key)
{ {
var insert = this.env.textresponses[key] ? this.env.textresponses[key].text : null; return this.editor.replace(this.env.textresponses[key]);
if (!insert)
return false;
this.editor.replace(insert);
}; };
/** /**

@ -412,15 +412,21 @@ function rcube_text_editor(config, id)
{ {
var format, ed = this.editor; var format, ed = this.editor;
if (!input)
return false;
// insert into tinymce editor // insert into tinymce editor
if (ed) { if (ed) {
ed.getWin().focus(); // correct focus in IE & Chrome ed.getWin().focus(); // correct focus in IE & Chrome
if ($.type(input) == 'object') { if ($.type(input) == 'object' && ('html' in input)) {
input = input.html; input = input.html;
format = 'html'; format = 'html';
} }
else { else {
if ($.type(input) == 'object')
input = input.text || '';
input = rcmail.quote_html(input).replace(/\r?\n/g, '<br/>'); input = rcmail.quote_html(input).replace(/\r?\n/g, '<br/>');
format = 'text'; format = 'text';
} }
@ -435,7 +441,7 @@ function rcube_text_editor(config, id)
end = value.substring(selection.end, value.length); end = value.substring(selection.end, value.length);
if ($.type(input) == 'object') if ($.type(input) == 'object')
input = input.text; input = input.text || '';
// insert response text // insert response text
ed.value = pre + input + end; ed.value = pre + input + end;

Loading…
Cancel
Save