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
13 changes: 11 additions & 2 deletions src/plugins/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,17 @@ export function linkClicking() {
event.preventDefault()

if (isLinkToSelfWithHash(linkEl.attributes.href?.value)) {
// Open anchor links directly
location.href = linkEl.attributes.href.value
// 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 in new tab on Ctrl/Cmd + left click
window.open(linkEl.href, '_blank')
Expand Down
Loading