diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 4022348ceb0..b906c16261f 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -98,11 +98,12 @@ const Wysiwyg = Widget.extend({ const self = this; var options = this._editorOptions(); - this._value = options.value; this.options.isInternalUser = await session.user_has_group('base.group_user'); this.$editable = this.$editable || this.$el; - this.$editable.html(this._value); + if (options.value) { + this.$editable.html(options.value); + } this.$editable.data('wysiwyg', this); this.$editable.data('oe-model', options.recordInfo.res_model); this.$editable.data('oe-id', options.recordInfo.res_id); @@ -178,6 +179,7 @@ const Wysiwyg = Widget.extend({ this.odooEditor.document.addEventListener("keyup", this._signalOnline, true); } + this._initialValue = this.getValue(); const $wrapwrap = $('#wrapwrap'); if ($wrapwrap.length) { $wrapwrap[0].addEventListener('scroll', this.odooEditor.multiselectionRefresh, { passive: true }); @@ -742,7 +744,7 @@ const Wysiwyg = Widget.extend({ * @returns {Boolean} */ isDirty: function () { - return this._value !== (this.$editable.html() || this.$editable.val()); + return this._initialValue !== (this.getValue() || this.$editable.val()); }, /** * Get the value of the editable element. @@ -759,6 +761,7 @@ const Wysiwyg = Widget.extend({ $editable.find('[title=""]').removeAttr('title'); $editable.find('[alt=""]').removeAttr('alt'); $editable.find('[data-original-title=""]').removeAttr('data-original-title'); + $editable.find('[data-editor-message]').removeAttr('data-editor-message'); $editable.find('a.o_image, span.fa, i.fa').html(''); $editable.find('[aria-describedby]').removeAttr('aria-describedby').removeAttr('data-original-title'); this.odooEditor.cleanForSave($editable[0]); @@ -780,7 +783,7 @@ const Wysiwyg = Widget.extend({ } else { this.$editable.html(html); } - return Promise.resolve({isDirty:isDirty, html:html}); + return Promise.resolve({isDirty: isDirty, html: html}); }, /** * Save the content for the normal mode or the translation mode. diff --git a/addons/website/static/src/js/menu/edit.js b/addons/website/static/src/js/menu/edit.js index 7c9ca6949f8..253cd51910b 100644 --- a/addons/website/static/src/js/menu/edit.js +++ b/addons/website/static/src/js/menu/edit.js @@ -116,7 +116,9 @@ var EditPageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ self.destroy(); }; if (!this.wysiwyg.isDirty()) { - return destroy(); + destroy(); + window.location.reload(); + return; } return this.wysiwyg.saveContent(false).then((result) => { var $wrapwrap = $('#wrapwrap');