Skip to content

Commit

Permalink
Fix anchcors scrolling
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Myakshin <molodchick@gmail.com>
  • Loading branch information
Koc committed Mar 21, 2024
1 parent 9ae7f48 commit c45360f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/mixins/editorMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ export default {
onOutlineToggle: (visible) => {
this.toggleOutlineFromEditor(visible)
},
onLoaded: () => {
if (document.location.hash) {
// scroll to the corresponding header if the page was loaded with a hash
const element = document.querySelector(`[href="${document.location.hash}"]`)
element?.click()
}
},
})

if (!this.loading('pageContent')) {
this.reader.setContent(this.pageContent)
}
Expand Down

0 comments on commit c45360f

Please sign in to comment.