[FIX] web_editor: undo after dropping a snippet

The commit 1b80fe9b56acea09a6784691561df65fe6349f50 made impossible
to undo after dropping a snippet.

Task-2688104

closes odoo/odoo#79649

X-original-commit: 92b1f78e8de6c343a9d1ef19459522b868cf108f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet <age@odoo.com>
This commit is contained in:
Nicolas Bayet
2021-11-15 11:22:34 +00:00
parent 8087bd00e8
commit 6f972d9f9c
@@ -2435,22 +2435,27 @@ var SnippetsMenu = Widget.extend({
}
self.getEditableArea().find('.oe_drop_zone').droppable('destroy').remove();
let $toInsertParent;
let prev;
let next;
if (dropped) {
prev = $toInsert.first()[0].previousSibling;
next = $toInsert.last()[0].nextSibling;
$toInsertParent = $toInsert.parent();
$toInsert.detach();
}
self.options.wysiwyg.odooEditor.observerActive('dragAndDropCreateSnippet');
if (dropped) {
var prev = $toInsert.first()[0].previousSibling;
var next = $toInsert.last()[0].nextSibling;
if (prev) {
$toInsert.detach();
$toInsert.insertAfter(prev);
} else if (next) {
$toInsert.detach();
$toInsert.insertBefore(next);
} else {
var $parent = $toInsert.parent();
$toInsert.detach();
$parent.prepend($toInsert);
$toInsertParent.prepend($toInsert);
}
var $target = $toInsert;