[FIX] web_editor: fix traceback for some CTRL+A cases in mass_mailing
closes odoo/odoo#69486 X-original-commit: 22926d0bfca472daad8cebddbc19e6bb3e846904 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -860,13 +860,21 @@ const Wysiwyg = Widget.extend({
|
||||
if (e && e.key === 'a' && (e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault();
|
||||
const selection = this.odooEditor.document.getSelection();
|
||||
const deepestParent =
|
||||
const containerSelector = '#wrap>*, [contenteditable], .oe_structure>*';
|
||||
let $deepestParent =
|
||||
selection ?
|
||||
$(selection.anchorNode).parentsUntil('#wrap>*, [contenteditable], .oe_structure>*').last() :
|
||||
[];
|
||||
if(deepestParent.length) {
|
||||
$(selection.anchorNode).parentsUntil(containerSelector).last() :
|
||||
$();
|
||||
|
||||
if ($deepestParent.is('html')) {
|
||||
// In case we didn't find a suitable container
|
||||
// we need to restrict the selection inside to the editable area.
|
||||
$deepestParent = this.$editable.find(containerSelector);
|
||||
}
|
||||
|
||||
if ($deepestParent.length) {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(deepestParent.parent()[0]);
|
||||
range.selectNodeContents($deepestParent.parent()[0]);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user