Repository navigation
fix: open links in the browser or markpad, never inside the app window - #160
Merged
Merged
Conversation
Build the main window in Rust with navigation and new-window guards. The webview may only show the app's own page; web, mail and phone links are handed to the system's default handler, and every other navigation or pop-up (forms, target=_blank, window.open, dropped URLs, relative paths resolved against the app origin) is refused. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Every link click in the preview is now handled explicitly, including middle-clicks, image-map areas and SVG links in Graphviz diagrams: - web, mail and phone links open in the system's default app; - links to .md/.markdown/.json/.yaml/.yml files open them in markpad, resolved relative to the current document (a missing file reports an error instead of adding a broken recent); - #heading links keep scrolling the preview; - anything else does nothing, and raw-HTML forms never submit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Clicking a link in the preview used to point markpad's own window at the link's target, hiding the editor and turning the window into a browser. Now the window only ever shows markpad.
Native guard (
src-tauri/src/navigation.rs)The main window is now built in Rust, with
"create": falseintauri.conf.json, so that navigation and new-window guards can be attached:tauri://localhost/,http(s)://tauri.localhost/, and the Vite dev server in dev builds only. Any other path on the app origin is blocked, since that is a relative link resolved against the app.http,https,mailtoandtelURLs go to the system's default handler, and everything else is refused.target="_blank"/window.openin a popup window of its own.This catches forms, scripts, dropped URLs, and context-menu "Open Link" actions, whatever the frontend misses.
Preview link handling (
src/lib/previewLinks.ts)Every link activation is now handled explicitly: click and middle-click, HTML
<a>, image-map<area>, and SVG<a xlink:href>from GraphvizURL=attributes.@tauri-apps/plugin-opener..md/.markdown/.json/.yaml/.ymlfiles open in markpad. This covers relative, absolute and localfile://links, resolved against the current document's folder, with Windows paths supported. A missing target shows an error banner instead of adding a broken recent item.#headinglinks keep scrolling the preview.<form>s never submit.README feature list updated.
Not included
other.md#sectionopens the file but doesn't scroll to the heading.Test plan
npm run lint,npm test(284 passed, 11 new),npm run buildcargo test(4 new navigation tests),cargo clippy -D warnings,cargo fmt --checktauri dev: web, mail,target=_blankand Graphviz links open in the browser; relative.md,.jsonand nested links with spaces open in markpad; a missing file shows an error; image links,/index.html,file:///etc/passwdand form submits do nothing;#anchorscrolls🤖 Generated with Claude Code