DEV: A few more fixes (#27)
- fix `Ctrl` + clicking on other links in a page with DiscoTOC - visually show third level in TOC - fix overlapping levels for long TOCs - remove support for h6 headings
This commit is contained in:
parent
ca7fe6b644
commit
7bf7b95901
|
@ -36,11 +36,14 @@ $padding-basis: 0.75em;
|
||||||
&.active,
|
&.active,
|
||||||
.d-toc-wrapper.overlay & {
|
.d-toc-wrapper.overlay & {
|
||||||
ul {
|
ul {
|
||||||
max-height: 50em;
|
max-height: 150em;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
> a:hover {
|
||||||
|
color: var(--primary-high);
|
||||||
|
}
|
||||||
&.direct-active > a {
|
&.direct-active > a {
|
||||||
position: relative;
|
position: relative;
|
||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
|
@ -61,8 +64,16 @@ $padding-basis: 0.75em;
|
||||||
// it's odd that we need this
|
// it's odd that we need this
|
||||||
margin-left: -1px;
|
margin-left: -1px;
|
||||||
}
|
}
|
||||||
ul {
|
|
||||||
margin-bottom: 0.5em;
|
li.d-toc-h2 ~ li.d-toc-h3,
|
||||||
|
li.d-toc-h2 ~ li.d-toc-h4,
|
||||||
|
li.d-toc-h2 ~ li.d-toc-h5,
|
||||||
|
li.d-toc-h3 ~ li.d-toc-h4,
|
||||||
|
li.d-toc-h3 ~ li.d-toc-h5,
|
||||||
|
li.d-toc-h4 ~ li.d-toc-h5 {
|
||||||
|
> a {
|
||||||
|
padding-left: $padding-basis;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
let dTocHeadingSelectors =
|
let dTocHeadingSelectors =
|
||||||
":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6";
|
":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5";
|
||||||
const headings = el.querySelectorAll(dTocHeadingSelectors);
|
const headings = el.querySelectorAll(dTocHeadingSelectors);
|
||||||
|
|
||||||
if (headings.length < 1) {
|
if (headings.length < 1) {
|
||||||
|
@ -193,16 +193,18 @@ export default {
|
||||||
top: rect.bottom + window.scrollY - headerOffset() - 10,
|
top: rect.bottom + window.scrollY - headerOffset() - 10,
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// close overlay
|
// close overlay
|
||||||
if (e.target.closest("a").classList.contains("d-toc-close")) {
|
if (e.target.closest("a").classList.contains("d-toc-close")) {
|
||||||
document.querySelector(".d-toc-wrapper").classList.remove("overlay");
|
document.querySelector(".d-toc-wrapper").classList.remove("overlay");
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!document.querySelector(".d-toc-wrapper.overlay")) {
|
if (!document.querySelector(".d-toc-wrapper.overlay")) {
|
||||||
|
@ -263,6 +265,7 @@ export default {
|
||||||
clonedNode.querySelector("span.clicks")?.remove();
|
clonedNode.querySelector("span.clicks")?.remove();
|
||||||
const li = document.createElement("li");
|
const li = document.createElement("li");
|
||||||
li.classList.add("d-toc-item");
|
li.classList.add("d-toc-item");
|
||||||
|
li.classList.add(`d-toc-${clonedNode.tagName.toLowerCase()}`);
|
||||||
|
|
||||||
li.innerHTML = `<a data-d-toc="${clonedNode.getAttribute("id")}">${
|
li.innerHTML = `<a data-d-toc="${clonedNode.getAttribute("id")}">${
|
||||||
clonedNode.textContent
|
clonedNode.textContent
|
||||||
|
|
Loading…
Reference in New Issue