mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-27 13:34:28 -04:00
Merge pull request #1043 from SISheogorath/fix/tocEmptyHead
Fix ToC breaking documents with empty h* elements
This commit is contained in:
commit
271dff3808
3 changed files with 9 additions and 6 deletions
|
@ -846,11 +846,13 @@ const linkifyAnchors = (level, containingElement) => {
|
|||
let header = headers[i]
|
||||
if (header.getElementsByClassName('anchor').length === 0) {
|
||||
if (typeof header.id === 'undefined' || header.id === '') {
|
||||
// to escape characters not allow in css and humanize
|
||||
// to escape characters not allow in css and humanize
|
||||
const id = slugifyWithUTF8(getHeaderContent(header))
|
||||
header.id = id
|
||||
}
|
||||
header.insertBefore(anchorForId(header.id), header.firstChild)
|
||||
if (!(typeof header.id === 'undefined' || header.id === '')) {
|
||||
header.insertBefore(anchorForId(header.id), header.firstChild)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2788,6 +2788,7 @@ function updateViewInner () {
|
|||
renderTOC(ui.area.markdown)
|
||||
generateToc('ui-toc')
|
||||
generateToc('ui-toc-affix')
|
||||
autoLinkify(ui.area.markdown)
|
||||
generateScrollspy()
|
||||
updateScrollspy()
|
||||
smoothHashScroll()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue