Skip to content

Commit 5f9d7e2

Browse files
committed
fix: in markdown, clickin on image within a href tag not opening link
1 parent 5f4e3b3 commit 5f9d7e2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/extensionsIntegrated/Phoenix-live-preview/markdown.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,19 @@
9999
href: location.href
100100
}, "{{{PARENT_ORIGIN}}}");
101101
}
102+
103+
let target = event.target;
104+
// Traverse up the DOM tree to find if the target is within an <a> tag
105+
while (target && target.tagName !== 'A') {
106+
target = target.parentNode;
107+
}
108+
102109
// in desktop phoenix builds, tauri will not open anchor tags in browser if it is in
103110
// an iframe(except for the intel mac bug)
104111
// in normal browsers, we dont need to do this.
105112
if (window.__PHOENIX_EMBED_INFO && window.__PHOENIX_EMBED_INFO.isTauri &&
106-
event.target.tagName === 'A' && (event.target.target === '_blank')) {
107-
const href = getAbsoluteUrl(event.target.getAttribute('href'));
113+
target.tagName === 'A' && (target.target === '_blank')) {
114+
const href = getAbsoluteUrl(target.getAttribute('href'));
108115
window.parent.postMessage({
109116
handlerName: "ph-liveServer",
110117
eventName: 'embeddedIframeHrefClick',

0 commit comments

Comments
 (0)