[FIX] web_editor: prevent deleting content outside the editable area
When checking whether an element was removable or not, we failed to check whether it was within the editable area. As a result it was sometimes possible to accidentally delete something outside of it. To reproduce the bug, insert a link in a blank editor, then press delete repeatedly until the whole link is gone, and then one more time. This deleted an element from Odoo's UI. task-2993740 closes odoo/odoo#104268 X-original-commit: 55e4e0577ac8a62d57f759572b8a5e608c7582b2 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -1337,14 +1337,13 @@ export function isUnbreakable(node) {
|
||||
}
|
||||
|
||||
export function isUnremovable(node) {
|
||||
if (node.nodeType !== Node.ELEMENT_NODE && node.nodeType !== Node.TEXT_NODE) {
|
||||
return true;
|
||||
}
|
||||
return (
|
||||
(node.nodeType !== Node.ELEMENT_NODE && node.nodeType !== Node.TEXT_NODE) ||
|
||||
node.oid === 'root' ||
|
||||
(node.nodeType === Node.ELEMENT_NODE &&
|
||||
(node.classList.contains('o_editable') || node.getAttribute('t-set') || node.getAttribute('t-call'))) ||
|
||||
(node.classList && node.classList.contains('oe_unremovable'))
|
||||
(node.classList && node.classList.contains('oe_unremovable')) ||
|
||||
(node.ownerDocument && node.ownerDocument.defaultWindow && !ancestors(node).find(ancestor => ancestor.oid === 'root')) // Node is in DOM but not in editable.
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user