[FIX] web_editor: make only one step when creating a link

Before this commit, creating a link through the link tool made two
steps instead of one.

task-3147819

closes odoo/odoo#113135

X-original-commit: d967c21b6abdccd45f3c767925de29e874497dd4
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2023-02-20 14:50:51 +01:00
parent a1c6a75d91
commit bd0d00b80d
@@ -1217,6 +1217,7 @@ const Wysiwyg = Widget.extend({
}
} else {
const historyStepIndex = this.odooEditor.historySize() - 1;
this.odooEditor.historyPauseSteps();
let { link } = Link.getOrCreateLink({
containerNode: this.odooEditor.editable,
startNode: options.link,
@@ -1241,6 +1242,7 @@ const Wysiwyg = Widget.extend({
data.rel = 'ugc';
}
linkWidget.applyLinkToDom(data);
this.odooEditor.historyUnpauseSteps();
this.odooEditor.historyStep();
link = linkWidget.$link[0];
this.odooEditor.setContenteditableLink(linkWidget.$link[0]);
@@ -1255,6 +1257,7 @@ const Wysiwyg = Widget.extend({
Promise.resolve().then(() => link.focus());
});
linkDialog.on('closed', this, function () {
this.odooEditor.historyUnpauseSteps();
// If the linkDialog content has been saved
// the previous selection in not relevant anymore.
if (linkDialog.destroyAction !== 'save') {