From d88431961c77633d2a3dc46eb7b0ef604f98f1fe Mon Sep 17 00:00:00 2001 From: "Guillaume (gdi)" Date: Mon, 17 Jan 2022 15:15:54 +0000 Subject: [PATCH] [FIX] web_editor: support media link tool shortcut on firefox The CTRL + K shortcut to activate the media link tool did not worked on firefox. This commit fixes that. task-2666467 X-original-commit: 13375c5f079597abadb77ba5e17bc2087f6c24fc Part-of: odoo/odoo#83295 --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 061716a84e7..8b3566a7484 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1319,7 +1319,7 @@ const Wysiwyg = Widget.extend({ // Open the link tool when CTRL+K is pressed. if (e && e.key === 'k' && (e.ctrlKey || e.metaKey)) { e.preventDefault(); - const targetEl = this.odooEditor.document.getSelection().baseNode; // FIXME this is undefined on Firefox after clicking on an image and hitting CTRL-K + const targetEl = this.odooEditor.document.getSelection().getRangeAt(0).startContainer; // Link tool is different if the selection is an image or a text. if (targetEl instanceof HTMLElement && (targetEl.tagName === 'IMG' || targetEl.querySelectorAll('img').length === 1)) {