mirror of
https://github.com/status-im/codimd.git
synced 2025-01-26 01:38:48 +00:00
Fix wrong anchors
While experimenting with the ToC changes, it became obvious that anchors for those unnamed headers don't work. This patch fixes those links by running the autolinkify twice and make sure linkify only adds links to non-empty ids. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
This commit is contained in:
parent
9951b7df7c
commit
d6dd33620c
@ -850,9 +850,11 @@ const linkifyAnchors = (level, containingElement) => {
|
|||||||
const id = slugifyWithUTF8(getHeaderContent(header))
|
const id = slugifyWithUTF8(getHeaderContent(header))
|
||||||
header.id = id
|
header.id = id
|
||||||
}
|
}
|
||||||
|
if (!(typeof header.id === 'undefined' || header.id === '')) {
|
||||||
header.insertBefore(anchorForId(header.id), header.firstChild)
|
header.insertBefore(anchorForId(header.id), header.firstChild)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function autoLinkify (view) {
|
export function autoLinkify (view) {
|
||||||
|
@ -2786,6 +2786,7 @@ function updateViewInner () {
|
|||||||
renderTOC(ui.area.markdown)
|
renderTOC(ui.area.markdown)
|
||||||
generateToc('ui-toc')
|
generateToc('ui-toc')
|
||||||
generateToc('ui-toc-affix')
|
generateToc('ui-toc-affix')
|
||||||
|
autoLinkify(ui.area.markdown)
|
||||||
generateScrollspy()
|
generateScrollspy()
|
||||||
updateScrollspy()
|
updateScrollspy()
|
||||||
smoothHashScroll()
|
smoothHashScroll()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user