[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) <dmo@odoo.com>
This commit is contained in:
Rodolpho Lima
2023-09-29 14:48:14 +00:00
parent a9dd388a11
commit bfe0c5fedf
@@ -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;