From facd1370ffe3588a7931f261276c2bfa5fb30bd5 Mon Sep 17 00:00:00 2001 From: abose Date: Mon, 9 Sep 2024 11:33:54 +0530 Subject: [PATCH] fix: in markdown, clickin on image within a href tag not opening link --- .../Phoenix-live-preview/markdown.html | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/extensionsIntegrated/Phoenix-live-preview/markdown.html b/src/extensionsIntegrated/Phoenix-live-preview/markdown.html index ed1c7f65fc..0bfd935d11 100644 --- a/src/extensionsIntegrated/Phoenix-live-preview/markdown.html +++ b/src/extensionsIntegrated/Phoenix-live-preview/markdown.html @@ -99,12 +99,19 @@ href: location.href }, "{{{PARENT_ORIGIN}}}"); } + + let target = event.target; + // Traverse up the DOM tree to find if the target is within an tag + while (target && target.tagName !== 'A') { + target = target.parentNode; + } + // in desktop phoenix builds, tauri will not open anchor tags in browser if it is in // an iframe(except for the intel mac bug) // in normal browsers, we dont need to do this. if (window.__PHOENIX_EMBED_INFO && window.__PHOENIX_EMBED_INFO.isTauri && - event.target.tagName === 'A' && (event.target.target === '_blank')) { - const href = getAbsoluteUrl(event.target.getAttribute('href')); + target.tagName === 'A' && (target.target === '_blank')) { + const href = getAbsoluteUrl(target.getAttribute('href')); window.parent.postMessage({ handlerName: "ph-liveServer", eventName: 'embeddedIframeHrefClick',