Repository navigation
fix: links in a PDF or HTML page and files dropped outside Files no longer take the reader away - #218
Merged
Merged
Conversation
…onger take the reader away from what they are reading - A PDF's internal links turn to the page they name; its web links open in a new tab instead of replacing the app. - An HTML page's web links open in a new tab, and its links within the page scroll to their place, which the sandbox kept from working before. - A file dropped where nothing takes it is ignored instead of opening in the tab.
…ter the page, and look a link's place up as written before decoding it
This was referenced Oct 26, 2026
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.
Three natural gestures took the reader away from what they were reading: following a link in a PDF, following a link in an HTML page, and dropping a file anywhere but Files.
PDF (#189)
<Document>getsonItemClick, so a table of contents, "see Figure 3" or citation turns the page the way the outline does. react-pdf keeps the firstonItemClickin a ref (viewer = useRef({ scrollPageIntoView })), whenpageCountis still 0 andnavigatereturns early — so the handler reaches the currentnavigatethroughnavigateRef.externalLinkTarget="_blank": without a target, pdf.js's web links replaced the app in the tab.HTML page and HTML embedded in a note (#204)
withLibraryImagesinhtml-images.ts, nowframePageinhtml-page.tssince it does more) giveshttp(s)linkstarget="_blank", the ruleMarkdownAnchorfollows; both frames addallow-popups allow-popups-to-escape-sandbox, so the new tab is an ordinary page. Noallow-same-originorallow-top-navigation: the page still cannot reach the library or replace the app.#section) never worked in the sandboxed blob frame — Chrome ignores the fragment navigation, confirmed against the oldallow-scriptssandbox alone. A page that has one now gets a few lines of script that scroll to the element by id orname— looked up as written first, then decoded, as the browser does —#/#topto the top, and step aside when the page handled the click itself. Only the displayed copy changes; the file and its Source are untouched.<base href>, still navigate the frame. The injected script has no unit test: jsdom does not run it, so it is verified in the browser, including a malformed%in an id.Files dropped outside Files (#185)
main.tsxcancelsdragover/dropcarryingFilesat the window, so a missed drop no longer opens the file in the tab. Files and the composer handle their drops first, as before; tab reordering is untouched.dropEffectis left alone so a drop into the Source editor still behaves as CodeMirror makes it.Verification
pnpm checkpasses. The two tests that pinnedsandbox="allow-scripts"now pin the new value.#method, a percent-encoded Chinese id, a<a name>anchor and#topeach scroll to their place; a link the page handles itself is left to the page;dragover/dropare cancelled and nothing is imported; on Files the file is imported; on the composer it is attached; a tab drag is not cancelled.HTML charset
The frame's blob was
text/htmlwith no charset, so a page without its own<meta charset>was read as Latin-1 and its Chinese showed as mojibake. A Blob always writes text as UTF-8, so the blob now saystext/html;charset=utf-8. The file itself is untouched. Verified end to end: a Chinese page with no meta renders its headings and links correctly.Closes #189, closes #204, closes #185