fix(HTML Editor): Update preview when form changes (#7108)

This commit is contained in:
Faris Ansari 2019-03-22 18:56:22 +05:30 committed by GitHub
parent f544dcafbe
commit f01130d1da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -54,7 +54,7 @@ frappe.ui.form.ControlCode = frappe.ui.form.ControlText.extend({
},
set_formatted_input(value) {
this.load_lib().then(() => {
return this.load_lib().then(() => {
if (!this.editor) return;
if (!value) value = '';
if (value === this.get_input_value()) return;

View file

@ -5,6 +5,7 @@ frappe.ui.form.ControlHTMLEditor = frappe.ui.form.ControlMarkdownEditor.extend({
this._super();
},
update_preview() {
if (!this.markdown_preview) return;
let value = this.get_value() || '';
value = frappe.dom.remove_script_and_style(value);
this.markdown_preview.html(value);

View file

@ -35,5 +35,12 @@ frappe.ui.form.ControlMarkdownEditor = frappe.ui.form.ControlCode.extend({
update_preview() {
const value = this.get_value() || "";
this.markdown_preview.html(frappe.markdown(value));
},
set_formatted_input(value) {
this._super(value)
.then(() => {
this.update_preview();
});
}
});