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;
};
// Inserts a predefined response to the compose editor
this.insert_response = function(key)
{
var insert = this.env.textresponses[key] ? this.env.textresponses[key].text : null;
if (!insert)
return false;
this.editor.replace(insert);
return this.editor.replace(this.env.textresponses[key]);
};
/**

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

Loading…
Cancel
Save