docsify-plugin-toc icon indicating copy to clipboard operation
docsify-plugin-toc copied to clipboard

The head selector needs to be improved

Open caoguanghui opened this issue 3 years ago • 1 comments

 document.querySelector(`#main ${window.$docsify.toc.target}`)

If config like this:

{
     tocMaxLevel: 6,
     target: 'h1, h2, h3, h4, h5, h6'
}

The selector#main h1, h2, h3, h4, h5, h6 will get h2-h5 of whole document and h1 in #main

Therefore, the following code seems more reasonable

const mainElement = document.querySelector('#main')
headings = mainElement.querySelectorAll(window.$docsify.toc.target)

caoguanghui avatar Feb 10 '22 08:02 caoguanghui

What's the difference?

image

justintien avatar May 25 '22 16:05 justintien