feat(navigation): smooth scroll for in-note anchor links

Pure-fragment links (#heading) used to fall through to the browser's
default jump. Handle them in the click listener and scope the lookup
to the same stacked note so identical heading ids in other notes
don't win, with smooth scroll behavior to match cross-note anchors
into already-stacked notes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Julien Calixte
2026-04-26 09:59:12 +02:00
parent c00065ce4a
commit 181ffd1e5c

View File

@@ -19,6 +19,15 @@ export const useLinks = (
}
if (href.startsWith("#")) {
event.preventDefault()
const id = href.slice(1)
const container = document.querySelector(`.${toValue(className)}`)
const heading = container?.querySelector(`#${CSS.escape(id)}`)
heading?.scrollIntoView({
block: "start",
inline: "nearest",
behavior: "smooth"
})
return
}