Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: in markdown, clickin on image within a href tag not opening link #1838

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/extensionsIntegrated/Phoenix-live-preview/markdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a> 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',
Expand Down
Loading