diff --git a/program/js/app.js b/program/js/app.js index 844973569..63c6894a5 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -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]); }; /** diff --git a/program/js/editor.js b/program/js/editor.js index 6eb473b62..4bc6ae406 100644 --- a/program/js/editor.js +++ b/program/js/editor.js @@ -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, '
'); 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;