From bfe0c5fedf172f4c77002a4f54803b376ada43ce Mon Sep 17 00:00:00 2001 From: Rodolpho Lima Date: Mon, 25 Sep 2023 18:13:49 +0200 Subject: [PATCH] [FIX] web_editor: use Node from editable's document Steps to reproduce: - In website, paste a URL like "odoo.com" as plain text. The expected result is a transformed link, just like it happens when pasting is done in an html field (ex: project.task description), but a simple text node is inserted instead. The reason for this is that an element created by the iframe document's `createElement` method has in its prototype chain the iframe context's global `Node` constructor, which is a distinct constructor object from the main window's `Node` constructor. task-3521152 closes odoo/odoo#136597 X-original-commit: 392d78dab632f67721ec2ba8810d5c8053640b86 Related: odoo/enterprise#48136 Signed-off-by: David Monjoie (dmo) --- .../static/src/js/editor/odoo-editor/src/commands/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js index 0a5b5bb5cf5..239acce5349 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js @@ -165,7 +165,7 @@ export const editorCommands = { const containerFirstChild = document.createElement('fake-element-fc'); const containerLastChild = document.createElement('fake-element-lc'); - if (content instanceof Node) { + if (content instanceof editor.document.defaultView.Node) { container.replaceChildren(content); } else { container.textContent = content;