diff --git a/frappe/public/js/frappe/event_emitter.js b/frappe/public/js/frappe/event_emitter.js
index 6c721b90aa..aeed656e4e 100644
--- a/frappe/public/js/frappe/event_emitter.js
+++ b/frappe/public/js/frappe/event_emitter.js
@@ -1,26 +1,26 @@
frappe.provide('frappe.utils');
/**
- * Simple EventEmitter which uses jQuery's event system
+ * Simple EventEmitterMixin which uses jQuery's event system
*/
-class EventEmitter {
+const EventEmitterMixin = {
init() {
this.jq = jQuery(this);
- }
+ },
trigger(evt, data) {
!this.jq && this.init();
this.jq.trigger(evt, data);
- }
+ },
once(evt, handler) {
!this.jq && this.init();
this.jq.one(evt, (e, data) => handler(data));
- }
+ },
on(evt, handler) {
!this.jq && this.init();
this.jq.bind(evt, (e, data) => handler(data));
- }
+ },
off(evt, handler) {
!this.jq && this.init();
@@ -29,8 +29,8 @@ class EventEmitter {
}
frappe.utils.make_event_emitter = function(object) {
- Object.assign(object, EventEmitter.prototype);
+ Object.assign(object, EventEmitterMixin);
return object;
};
-export default EventEmitter;
+export default EventEmitterMixin;
diff --git a/frappe/public/js/frappe/form/controls/text_editor.js b/frappe/public/js/frappe/form/controls/text_editor.js
index 94528b4113..8222732849 100644
--- a/frappe/public/js/frappe/form/controls/text_editor.js
+++ b/frappe/public/js/frappe/form/controls/text_editor.js
@@ -16,6 +16,10 @@ Table.create = (value) => {
}
Quill.register(Table, true);
+// image uploader
+const Uploader = Quill.import('modules/uploader');
+Uploader.DEFAULTS.mimetypes.push('image/gif');
+
// inline style
const BackgroundStyle = Quill.import('attributors/style/background');
const ColorStyle = Quill.import('attributors/style/color');
@@ -150,8 +154,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
return;
}
- this.quill.setText('');
- this.quill.clipboard.dangerouslyPasteHTML(0, value);
+ this.quill.root.innerHTML = value;
},
get_input_value() {
diff --git a/frappe/public/js/frappe/form/footer/timeline.js b/frappe/public/js/frappe/form/footer/timeline.js
index 0e4f362242..47dcdf724d 100644
--- a/frappe/public/js/frappe/form/footer/timeline.js
+++ b/frappe/public/js/frappe/form/footer/timeline.js
@@ -92,8 +92,9 @@ frappe.ui.form.Timeline = class Timeline {
subject: __("Re: {0}", [me.frm.doc.subject]),
});
} else {
+ const comment_value = frappe.markdown(me.comment_area.get_value());
$.extend(args, {
- txt: frappe.markdown(me.comment_area.get_value())
+ txt: strip_html(comment_value) ? comment_value : ''
});
}
new frappe.views.CommunicationComposer(args)
diff --git a/frappe/public/js/frappe/misc/utils.js b/frappe/public/js/frappe/misc/utils.js
index 75afda26ed..e93a45decc 100644
--- a/frappe/public/js/frappe/misc/utils.js
+++ b/frappe/public/js/frappe/misc/utils.js
@@ -3,7 +3,7 @@
frappe.provide('frappe.utils');
-frappe.utils = {
+Object.assign(frappe.utils, {
get_random: function(len) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -648,7 +648,7 @@ frappe.utils = {
}
return route;
}
-};
+});
// Array de duplicate
if (!Array.prototype.uniqBy) {
diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js
index 9ea08bc9e4..fe503ad268 100755
--- a/frappe/public/js/frappe/views/communication.js
+++ b/frappe/public/js/frappe/views/communication.js
@@ -17,6 +17,7 @@ frappe.views.CommunicationComposer = Class.extend({
fields: this.get_fields(),
primary_action_label: __("Send"),
primary_action: function() {
+ me.delete_saved_draft();
me.send_action();
}
});
@@ -82,8 +83,7 @@ frappe.views.CommunicationComposer = Class.extend({
label:__("Message"),
fieldtype:"Text Editor", reqd: 1,
fieldname:"content",
- onchange: frappe.utils.debounce(this.save_as_draft.bind(this), 300),
- default: localStorage.getItem(this.frm.doctype + this.frm.docname) || ''
+ onchange: frappe.utils.debounce(this.save_as_draft.bind(this), 300)
},
{fieldtype: "Section Break"},
@@ -135,9 +135,7 @@ frappe.views.CommunicationComposer = Class.extend({
}
this.dialog.fields_dict.subject.set_value(this.subject || '');
- if(!localStorage.getItem(this.frm.doctype + this.frm.docname)) {
- this.setup_earlier_reply();
- }
+ this.setup_earlier_reply();
},
setup_subject_and_recipients: function() {
@@ -509,6 +507,12 @@ frappe.views.CommunicationComposer = Class.extend({
}
},
+ delete_saved_draft() {
+ if (this.dialog) {
+ localStorage.removeItem(this.frm.doctype + this.frm.docname);
+ }
+ },
+
send_email: function(btn, form_values, selected_attachments, print_html, print_format) {
var me = this;
me.dialog.hide();
@@ -629,6 +633,9 @@ frappe.views.CommunicationComposer = Class.extend({
if(this.txt) {
this.message = this.txt + (this.message ? ("
" + this.message) : "");
+ } else {
+ // saved draft in localStorage
+ this.message = localStorage.getItem(this.frm.doctype + this.frm.docname) || '';
}
if(this.real_name) {