From fc26cc1789b1309e54473cccbc545145ccbaee31 Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Mon, 10 Jan 2022 11:42:59 +0000 Subject: [PATCH] [FIX] mass_mailing: clean oe_edited_link Task-2729195 closes odoo/odoo#90722 X-original-commit: 99210fc58f7ed35c2c066b6aaba8efc94bcd2931 Signed-off-by: David Monjoie (dmo) --- .../static/src/js/mass_mailing_widget.js | 4 +--- .../static/src/js/backend/field_html.js | 7 +++---- .../static/src/js/wysiwyg/wysiwyg.js | 18 +++++++++--------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/addons/mass_mailing/static/src/js/mass_mailing_widget.js b/addons/mass_mailing/static/src/js/mass_mailing_widget.js index 72b5258cb99..a7a0ce4d3fe 100644 --- a/addons/mass_mailing/static/src/js/mass_mailing_widget.js +++ b/addons/mass_mailing/static/src/js/mass_mailing_widget.js @@ -61,9 +61,7 @@ var MassMailingFieldHtml = FieldHtml.extend({ } var $editable = this.wysiwyg.getEditable(); - if (this.wysiwyg.snippetsMenu) { - await this.wysiwyg.snippetsMenu.cleanForSave(); - } + await this.wysiwyg.cleanForSave(); return this.wysiwyg.saveModifiedImages(this.$content).then(async function () { self._isDirty = self.wysiwyg.isDirty(); self._doAction(); diff --git a/addons/web_editor/static/src/js/backend/field_html.js b/addons/web_editor/static/src/js/backend/field_html.js index 7fb13dbb6fa..9a492f29627 100644 --- a/addons/web_editor/static/src/js/backend/field_html.js +++ b/addons/web_editor/static/src/js/backend/field_html.js @@ -94,15 +94,14 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { * * @override */ - commitChanges: function () { + commitChanges: async function () { if (this.mode == "readonly" || !this.isRendered) { return this._super(); } var _super = this._super.bind(this); - this.wysiwyg.odooEditor.clean(); + await this.wysiwyg.cleanForSave(); this._setValue(this._getValue()); - return this.wysiwyg.saveModifiedImages(this.$content).then(async () => { - await this.wysiwyg.preSavePromise; + return this.wysiwyg.saveModifiedImages(this.$content).then(() => { this._isDirty = this.wysiwyg.isDirty(); _super(); }); diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 0b660f27b47..cadf73a20fe 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -809,11 +809,7 @@ const Wysiwyg = Widget.extend({ this.trigger_up('ready_to_save', {defs: defs}); await Promise.all(defs); - this._cleanForSave(); - - if (this.snippetsMenu) { - await this.snippetsMenu.cleanForSave(); - } + await this.cleanForSave(); const editables = this.options.getContentEditableAreas(); await this.saveModifiedImages(editables.length ? $(editables) : this.$editable); @@ -937,6 +933,14 @@ const Wysiwyg = Widget.extend({ closestElement(...args) { return closestElement(...args); }, + cleanForSave: async function () { + this.odooEditor.clean(); + this.$editable.find('.oe_edited_link').removeClass('oe_edited_link'); + + if (this.snippetsMenu) { + await this.snippetsMenu.cleanForSave(); + } + }, /** * Start or resume the Odoo field changes muation observers. * @@ -1755,10 +1759,6 @@ const Wysiwyg = Widget.extend({ }); } }, - _cleanForSave: function () { - this.odooEditor.clean(); - this.$editable.find('.oe_edited_link').removeClass('oe_edited_link'); - }, _getCommands: function () { const options = this._editorOptions(); const commands = [