From 4bdd483d4eefcd5cf6504c5f35cb004c98f56768 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 8 Jul 2017 10:05:55 +0530 Subject: [PATCH 1/5] [fix] summernote for firefox --- frappe/public/js/frappe/form/control.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index cc7c4f35e9..2cbc2ab302 100755 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -1723,11 +1723,10 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ }); }, onChange: function(value) { - if(this._setting_value) return; me.parse_validate_and_set_in_model(value); }, onKeydown: function(e) { - this._last_change_on = new Date(); + me._last_change_on = new Date(); var key = frappe.ui.keys.get_key(e); // prevent 'New DocType (Ctrl + B)' shortcut in editor if(['ctrl+b', 'meta+b'].indexOf(key) !== -1) { @@ -1846,20 +1845,34 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ this.last_value = value; }, set_in_editor: function(value) { - // set value after user has stopped editing + // set values in editor only if + // 1. value not be set in the last 500ms + // 2. user has not typed anything in the last 3seconds + // --- + // we will attempt to cleanup the user's DOM, hence if this happens + // in the middle of the user is typing, it creates a lot of issues + // also firefox tends to reset the cursor for some reason if the values + // are reset + + if(this.__setting_value) { // we don't understand how the internal triggers work, // so quit return; } - if(!this._last_change_on || (moment() - moment(this._last_change_on) > 3000)) { + let time_since_last_keystroke = moment() - moment(this._last_change_on); + + if(!this._last_change_on || (time_since_last_keystroke > 3000)) { this.__setting_value = setTimeout(() => this.__setting_value = null, 500); this.editor.summernote('code', value); } else { this._setting_value = setInterval(() => { - if(moment() - moment(this._last_change_on) > 3000) { - this.editor.summernote('code', this.last_value); + if(time_since_last_keystroke > 3000) { + if(this.last_value !== this.get_input_value()) { + // if not already in sync, reset + this.editor.summernote('code', this.last_value); + } clearInterval(this._setting_value); this._setting_value = null; } From 4fbb05d1ef44d072f18fbc9da360bcb867d971a5 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 8 Jul 2017 13:10:17 +0530 Subject: [PATCH 2/5] [fix] attach image refresh, fixes frappe/erpnext#9725 --- frappe/public/js/frappe/form/control.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index 2cbc2ab302..a6b4a1130b 100755 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -1166,6 +1166,7 @@ frappe.ui.form.ControlAttachImage = frappe.ui.form.ControlAttach.extend({ this.set_image(); }, refresh_input: function() { + this._super(); $(this.wrapper).find('.btn-attach').addClass('hidden'); this.set_image(); if(this.get_status()=="Read") { From 698e2d8c6907268e2bc457d5549205cd3e5e04a0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 8 Jul 2017 13:53:00 +0530 Subject: [PATCH 3/5] Escaped success msg in web form. Fixes frappe/erpnext#9729 (#3643) --- frappe/docs/user/en/guides/basics/apps.md | 2 +- frappe/website/doctype/web_form/templates/web_form.html | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/docs/user/en/guides/basics/apps.md b/frappe/docs/user/en/guides/basics/apps.md index 13731f8b2c..5805ad38af 100755 --- a/frappe/docs/user/en/guides/basics/apps.md +++ b/frappe/docs/user/en/guides/basics/apps.md @@ -12,7 +12,7 @@ Frappe ships with a boiler plate for a new app. The command `bench make-app app-name` helps you start a new app by starting an interactive shell. - % bench make-app sample_app + % bench new-app sample_app App Name: sample_app App Title: Sample App App Description: This is a sample app. diff --git a/frappe/website/doctype/web_form/templates/web_form.html b/frappe/website/doctype/web_form/templates/web_form.html index a1cbbb0240..476f084b22 100644 --- a/frappe/website/doctype/web_form/templates/web_form.html +++ b/frappe/website/doctype/web_form/templates/web_form.html @@ -350,9 +350,10 @@ {% block script %}