[FIX] web_editor: prevent class to create history steps

There is some classes that are technical and should not create steps.
Otherwise it compromise the ability to undo/redo or compromise the
ability to detect the dirty elements properly.

This commit prevent thoses classes additions and removals to create
history steps.

task-2836351

closes odoo/odoo#91074

Forward-port-of: #90064
X-original-commit: 41d8a0f246a134e2b5292da4db11e67aa9cfb4ed
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2022-05-11 14:54:28 +02:00
parent 57d3211c99
commit 7dfd2e071e
3 changed files with 29 additions and 1 deletions
@@ -6892,7 +6892,9 @@ registry.ColoredLevelBackground = registry.BackgroundToggler.extend({
* @private
*/
_markColorLevel: function () {
this.options.wysiwyg.odooEditor.observerUnactive('_markColorLevel');
this.$target.addClass('o_colored_level');
this.options.wysiwyg.odooEditor.observerActive('_markColorLevel');
},
});
@@ -76,13 +76,19 @@ const LinkPopoverWidget = Widget.extend({
container: this.options.wysiwyg.odooEditor.document.body,
})
.on('show.bs.popover.link_popover', () => {
this.options.wysiwyg.odooEditor.observerUnactive('show.bs.popover');
this._loadAsyncLinkPreview();
popoverShown = true;
})
.on('inserted.bs.popover', () => {
this.options.wysiwyg.odooEditor.observerActive('show.bs.popover');
})
.on('hide.bs.popover.link_popover', () => {
this.options.wysiwyg.odooEditor.observerUnactive('hide.bs.popover');
popoverShown = false;
})
.on('hidden.bs.popover.link_popover', () => {
this.options.wysiwyg.odooEditor.observerActive('hide.bs.popover');
for (const tooltip of tooltips) {
tooltip.hide();
}
@@ -261,7 +267,15 @@ LinkPopoverWidget.createFor = async function (parent, targetEl, options) {
return null;
}
const popoverWidget = new this(parent, targetEl, options);
return popoverWidget.appendTo(targetEl).then(() => popoverWidget);
const wysiwyg = $('#wrapwrap').data('wysiwyg');
if (wysiwyg) {
wysiwyg.odooEditor.observerUnactive('LinkPopoverWidget');
}
await popoverWidget.appendTo(targetEl)
if (wysiwyg) {
wysiwyg.odooEditor.observerActive('LinkPopoverWidget');
}
return popoverWidget;
};
export default LinkPopoverWidget;
@@ -56,6 +56,18 @@ tour.register('link_tools', {
content: "The new link content should be odoo website and url odoo.be",
trigger: '#toolbar button[data-original-title="Link Style"]',
},
{
trigger: 'body',
run: () => {
// When doing automated testing, the link popover takes time to
// hide. While hidding, the editor observer is unactive in order to
// prevent the popover mutation to be recorded. In a manual
// scenario, the popover has plenty of time to be hidden and the
// obsever would be re-activated in time. As this problem arise only
// in test, we activate the observer here for the popover.
$('#wrapwrap').data('wysiwyg').odooEditor.observerActive('hide.bs.popover');
},
},
{
content: "Click on the secondary style button.",
trigger: '#toolbar we-button[data-value="secondary"]',