From ce49ff9742b6b064229c053a967044444b3630e2 Mon Sep 17 00:00:00 2001 From: divy-odoo Date: Tue, 6 Jun 2023 08:54:30 +0000 Subject: [PATCH] [FIX] web_editor: preserve content around on unlink images Before this, we were considering only the case where only a single element is wrapped by the anchor tag, like ``. So it simply replaces parent node `` with childNode ``. However, cases like `text` (where there are multiple element within the tag) were failing. To handle such cases, this commit replaced the code that considering multiple childNodes and replacing parentNode with all the childNode. task-3231606 closes odoo/odoo#132531 X-original-commit: 08432308819e83fd0122a8e87170ec8ff27ca2a1 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Divyesh Vyas (divy) --- addons/web_editor/static/src/js/editor/snippets.options.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 22abc6d7f0e..3e6246918b1 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -5537,7 +5537,9 @@ registry.ReplaceMedia = SnippetOptionWidget.extend({ this.$target[0].src = src; } } else { - parentEl.replaceWith(this.$target[0]); + const fragment = document.createDocumentFragment(); + fragment.append(...parentEl.childNodes); + parentEl.replaceWith(fragment); } }, /**