[text-editor] dont keep refreshing value
This commit is contained in:
parent
f2c9fd28e8
commit
da683b6f28
1 changed files with 11 additions and 1 deletions
|
|
@ -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');
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue