From da683b6f28cf1efe2afa406cc81ee4b4ce26b44c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 5 Jul 2017 13:04:03 +0530 Subject: [PATCH] [text-editor] dont keep refreshing value --- frappe/public/js/frappe/form/control.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index ae227a6593..bde7fb9233 100755 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -1761,6 +1761,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ }); }, onChange: function(value) { + me._last_change_on = new Date(); me.parse_validate_and_set_in_model(value); }, onKeydown: function(e) { @@ -1877,10 +1878,19 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({ if(value == null) value = ""; value = frappe.dom.remove_script_and_style(value); if(value !== this.get_value()) { - this.editor.summernote('code', value); + this.set_in_editor(value); } this.last_value = value; }, + set_in_editor: function(value) { + // set value after user has stopped editing + let interval = setInterval(() => { + if(moment() - moment(this._last_change_on) < 3000) { + this.editor.summernote('code', value); + clearInterval(interval); + } + }, 1000); + }, set_focus: function() { return this.editor.summernote('focus'); },