diff --git a/frappe/public/js/frappe/form/controls/text_editor.js b/frappe/public/js/frappe/form/controls/text_editor.js
index 9e27dcf0f8..5203c57e7f 100644
--- a/frappe/public/js/frappe/form/controls/text_editor.js
+++ b/frappe/public/js/frappe/form/controls/text_editor.js
@@ -34,7 +34,7 @@ class HiddenBlock extends Block {
}
}
HiddenBlock.blotName = 'hiddenblot';
-HiddenBlock.tagName = 'DIV';
+HiddenBlock.tagName = 'SPAN';
Quill.register(HiddenBlock, true);
// image uploader
diff --git a/frappe/public/js/frappe/form/footer/timeline.js b/frappe/public/js/frappe/form/footer/timeline.js
index 83b0f386c3..0782f57b91 100644
--- a/frappe/public/js/frappe/form/footer/timeline.js
+++ b/frappe/public/js/frappe/form/footer/timeline.js
@@ -78,10 +78,17 @@ frappe.ui.form.Timeline = class Timeline {
var selector = this.frm.doctype === "Communication"? ".btn-reply-email": ".btn-new-email";
this.email_button = this.wrapper.find(selector)
.on("click", function() {
+ const $btn = $(this);
+ let is_a_reply = true;
+ if ($btn.is('.btn-new-email')) {
+ is_a_reply = false;
+ }
+
var args = {
doc: me.frm.doc,
frm: me.frm,
- recipients: me.get_recipient()
+ recipients: me.get_recipient(),
+ is_a_reply
}
if(me.frm.doctype === "Communication") {
@@ -286,7 +293,8 @@ frappe.ui.form.Timeline = class Timeline {
txt: "",
title: __('Reply'),
frm: me.frm,
- last_email: last_email
+ last_email: last_email,
+ is_a_reply: true
});
});
}
@@ -336,7 +344,7 @@ frappe.ui.form.Timeline = class Timeline {
});
} else {
if(c.communication_type=="Communication" && c.communication_medium=="Email") {
- c.content = c.content.split('
')[0];
+ c.content = c.content.split('Reply To')[0];
c.content = frappe.utils.strip_original_content(c.content);
c.original_content = c.content;
diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js
index ec7db29b9d..46f25bc23b 100755
--- a/frappe/public/js/frappe/views/communication.js
+++ b/frappe/public/js/frappe/views/communication.js
@@ -498,7 +498,9 @@ frappe.views.CommunicationComposer = Class.extend({
save_as_draft: function() {
if (this.dialog) {
try {
- localStorage.setItem(this.frm.doctype + this.frm.docname, this.dialog.get_value('content'));
+ let message = this.dialog.get_value('content');
+ message = message.split('Reply To')[0];
+ localStorage.setItem(this.frm.doctype + this.frm.docname, message);
} catch (e) {
// silently fail
console.log(e);
@@ -621,7 +623,7 @@ frappe.views.CommunicationComposer = Class.extend({
signature = signature.replace(/\n/g, "
");
}
- if (this.txt) {
+ if(this.txt) {
this.message = this.txt + (this.message ? ("
" + this.message) : "");
} else {
// saved draft in localStorage
@@ -636,8 +638,50 @@ frappe.views.CommunicationComposer = Class.extend({
+ this.real_name + ",
" + (this.message || "");
}
- var reply = (this.message || "") + (signature ? ("
" + signature) : "");
+ let reply = (this.message || "") + (signature ? ("
" + signature) : "");
+ let content = '';
- fields.content.set_value(reply);
+ if (this.is_a_reply === 'undefined') {
+ this.is_a_reply = true;
+ }
+
+ if (this.is_a_reply) {
+ let last_email = this.last_email;
+
+ if (!last_email) {
+ last_email = this.frm && this.frm.timeline.get_last_email(true);
+ }
+
+ if (!last_email) return;
+
+ let last_email_content = last_email.original_comment || last_email.content;
+
+ last_email_content = last_email_content
+ .replace(/<meta[\s\S]*meta>/g, '') // remove tags
+ .replace(/<style[\s\S]*<\/style>/g, ''); // // remove