Skip to content

feat: add PDF navigation history controls#46

Open
FP2003 wants to merge 1 commit into
mathematic-inc:mainfrom
FP2003:feat/pdf-navigation-history
Open

feat: add PDF navigation history controls#46
FP2003 wants to merge 1 commit into
mathematic-inc:mainfrom
FP2003:feat/pdf-navigation-history

Conversation

@FP2003

@FP2003 FP2003 commented Jun 20, 2026

Copy link
Copy Markdown

Summary

Adds Back and Forward buttons to the PDF toolbar for navigating between internal link sources and destinations.
This was suggested in #43 (Issues section)

For extra context, it seems like you were already able to press on the contents and navigate but there was no controls/history to be able to return.

Changes

File Changes
assets/main.mjs Creates the navigation controls, connects them to PDF.js history, and updates their enabled state using viewer events.
assets/main.css Adds icon-mask styling for the new toolbar buttons.
assets/navigation-back.svg Adds the Back toolbar icon.
assets/navigation-forward.svg Adds the Forward toolbar icon.
assets/pdf.js/web/viewer.mjs Enables PDF.js history in the embedded VS Code webview, exposes Back/Forward availability, and clears Forward history after branching.
patches/pdf.js.patch Records the PDF.js modifications so they are preserved during future PDF.js updates.

Behaviour

  • Buttons are initially disabled when no navigation history exists.
  • Following an internal PDF link enables Back navigation.
  • Back returns to the previous source position.
  • Forward returns to the linked destination.
  • Multiple internal jumps can be traversed in both directions.
  • Following a new link after navigating Back clears the previous Forward path.
  • Exact PDF destinations, including position and zoom, are preserved by PDF.js history.
  • The controls use PDF.js’s existing toolbar styling and responsive behaviour.

Validation

  • Manually tested in a VS Code Extension Development Host with internal PDF academic files content pages.
  • pnpm run lint passes.
  • pnpm run build passes.
  • PDF.js patch dry-run succeeds.
  • JavaScript syntax and Git whitespace checks pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant