[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
This commit is contained in:
Guillaume (gdi)
2022-01-25 09:57:19 +00:00
committed by qsm-odoo
parent 8223407a98
commit d88431961c
@@ -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)) {