[FIX] web_editor: avoid onbeforeunload pop-up issue

Remove onbeforeunload pop-up if editor has no snippet.
This fix pop-ups wrongly showing outside website editing.

see: #79731

task-2666177

closes odoo/odoo#79781

X-original-commit: 2f587eea4eea947597f0c4f7e5473c08e2175bcd
Signed-off-by: Antoine Guenet <age@odoo.com>
This commit is contained in:
Sébastien Geelen (sge)
2021-11-15 15:54:42 +00:00
parent 20758a8d16
commit c3bff57df2
@@ -206,16 +206,17 @@ const Wysiwyg = Widget.extend({
selectorEditableArea: '.o_editable',
}, options));
await this._insertSnippetMenu();
window.addEventListener('beforeunload', (event) => {
if (this.isDirty()) {
event.returnValue = _t('This document is not saved!');
}
});
}
if (this.options.getContentEditableAreas) {
$(this.options.getContentEditableAreas()).find('*').off('mousedown mouseup click');
}
window.onbeforeunload = (event) => {
if (this.isDirty()) {
return _t('This document is not saved!');
}
};
// The toolbar must be configured after the snippetMenu is loaded
// because if snippetMenu is loaded in an iframe, binding of the color
// buttons must use the jquery loaded in that iframe. See