Skip to content

fix: resolve Table of Contents smooth scroll navigation (#169)#170

Merged
ThisIs-Developer merged 1 commit into
mainfrom
fix/toc-scrolling-169
Jun 10, 2026
Merged

fix: resolve Table of Contents smooth scroll navigation (#169)#170
ThisIs-Developer merged 1 commit into
mainfrom
fix/toc-scrolling-169

Conversation

@ThisIs-Developer

Copy link
Copy Markdown
Owner

Description

This PR resolves the issue where clicking Table of Contents (TOC) anchor links updates the URL hash but fails to scroll the preview page to the target heading section (fixes #169).

Root Causes

  1. Missing Heading IDs: Marked.js v9.1.6 does not generate heading id attributes by default, rendering headers without DOM anchors.
  2. Custom Scroll Container: Default browser anchor jumps fail because the markdown viewer uses a custom scroll container (.preview-pane) rather than the document body.

Changes Implemented

  • Heading ID Generation: Added a custom slugifier to renderer.heading in both script.js and preview-worker.js to assign standard GFM-compliant IDs to all headings.
  • Smooth Scroll Link Interceptor: Added a click event listener on the preview pane to intercept all relative hash links, locate the matching target element by ID or text content, and smoothly scroll the .preview-pane scroll container to it.
  • Desktop Synchronisation: Synchronised the changes into the Neutralino desktop resources folder (desktop-app/resources/js/).
  • Tests: Added Playwright integration tests (test_toc_scrolling.spec.js) confirming that TOC clicks correctly transition the .preview-pane scroll offset.

Related Issues

Closes #169

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markdown-viwer Ready Ready Preview, Comment Jun 10, 2026 2:36pm

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploying markdown-viewer with  Cloudflare Pages  Cloudflare Pages

Latest commit: fc5e16f
Status: ✅  Deploy successful!
Preview URL: https://641e71d4.markdown-viewer.pages.dev
Branch Preview URL: https://fix-toc-scrolling-169.markdown-viewer.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploying markdownviewer with  Cloudflare Pages  Cloudflare Pages

Latest commit: fc5e16f
Status: ✅  Deploy successful!
Preview URL: https://3ea00621.markdownviewer.pages.dev
Branch Preview URL: https://fix-toc-scrolling-169.markdownviewer.pages.dev

View logs

@ThisIs-Developer ThisIs-Developer merged commit 841a184 into main Jun 10, 2026
6 checks passed
@ThisIs-Developer ThisIs-Developer deleted the fix/toc-scrolling-169 branch June 10, 2026 14:38
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.

Table of Contents Links Update URL but Do Not Scroll to Target Section

1 participant