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:
@@ -19,6 +19,15 @@ export const useLinks = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (href.startsWith("#")) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user