Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/plugins/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,14 @@ export function linkClicking(openLink: (href: string) => void = (href) => {
event.preventDefault()

if (isLinkToSelfWithHash(linkEl.href)) {
// Open anchor links directly
location.href = linkEl.href
// Directly scroll to anchor links
const url = new URL(linkEl.href, window.location.href)
const hash = url.hash
if (hash) {
const target = view.dom.querySelector(hash)
target?.scrollIntoView({ block: 'start', behavior: 'smooth' })
}
window.history.replaceState({}, '', url.href)
} else if (event.ctrlKey || event.metaKey) {
// Open link directly on Ctrl/Cmd + left click
openLink(linkEl.href)
Expand Down
Loading