[FIX] web_editor: fix unbreakable rollback upon column number change
When wrapping the contents of a paragraph into a newly created div, the nodes' ouid (unbreakable id) must be reset in order to prevent a "unbreakable" rollback. This commit makes such property reset and fixes errors related to changing the number of columns of a text snippet. task-3165895 opw-3137951 closes odoo/odoo#112521 X-original-commit: e33b802b05b41df20e13ebc44bc5b78edae50bb8 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
committed by
Rodolpho
parent
d5e0475097
commit
0a77f3279f
@@ -38,6 +38,7 @@ const {SIZES, MEDIAS_BREAKPOINTS} = require('@web/core/ui/ui_service');
|
||||
var qweb = core.qweb;
|
||||
var _t = core._t;
|
||||
const preserveCursor = OdooEditorLib.preserveCursor;
|
||||
const descendants = OdooEditorLib.descendants;
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} el
|
||||
@@ -4983,6 +4984,9 @@ registry.layout_column = SnippetOptionWidget.extend({
|
||||
let $row = this.$('> .row');
|
||||
if (!$row.length) {
|
||||
const restoreCursor = preserveCursor(this.$target[0].ownerDocument);
|
||||
for (const node of descendants(this.$target[0])) {
|
||||
node.ouid = undefined;
|
||||
}
|
||||
$row = this.$target.contents().wrapAll($('<div class="row"><div class="col-lg-12"/></div>')).parent().parent();
|
||||
restoreCursor();
|
||||
}
|
||||
@@ -4995,6 +4999,9 @@ registry.layout_column = SnippetOptionWidget.extend({
|
||||
await new Promise(resolve => setTimeout(resolve));
|
||||
if (nbColumns === 0) {
|
||||
const restoreCursor = preserveCursor(this.$target[0].ownerDocument);
|
||||
for (const node of descendants($row[0])) {
|
||||
node.ouid = undefined;
|
||||
}
|
||||
$row.contents().unwrap().contents().unwrap();
|
||||
restoreCursor();
|
||||
this.trigger_up('activate_snippet', {$snippet: this.$target});
|
||||
|
||||
Reference in New Issue
Block a user