FIX: Restore support for docs plugin (#24)
This commit is contained in:
parent
ff434a4f7b
commit
0bc2aa28a3
|
@ -212,3 +212,10 @@ a.d-toc-close {
|
|||
content: "#{$composer_toc_text}";
|
||||
}
|
||||
}
|
||||
|
||||
// Docs plugin outlet
|
||||
.below-docs-topic-outlet.d-toc-wrapper {
|
||||
position: sticky;
|
||||
top: calc(var(--header-offset, 60px) + 1em);
|
||||
max-height: calc(100vh - 2em - var(--header-offset, 60px));
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{{!-- Docs TOC placeholder --}}
|
|
@ -76,11 +76,26 @@ export default {
|
|||
}
|
||||
});
|
||||
|
||||
api.onAppEvent("docs-topic:current-post-scrolled", () => {
|
||||
this.updateTOCSidebar();
|
||||
});
|
||||
|
||||
api.onAppEvent("topic:current-post-scrolled", (args) => {
|
||||
if (args.postIndex !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateTOCSidebar();
|
||||
});
|
||||
|
||||
api.cleanupStream(() => {
|
||||
document.body.classList.remove("d-toc-timeline-visible");
|
||||
document.removeEventListener("click", this.clickTOC, false);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
updateTOCSidebar() {
|
||||
if (!document.querySelector(".d-toc-cooked")) {
|
||||
return;
|
||||
}
|
||||
|
@ -93,10 +108,7 @@ export default {
|
|||
const distance = Math.abs(
|
||||
domUtils.offset(heading).top - headerOffset() - window.scrollY
|
||||
);
|
||||
if (
|
||||
closestHeadingDistance == null ||
|
||||
distance < closestHeadingDistance
|
||||
) {
|
||||
if (closestHeadingDistance == null || distance < closestHeadingDistance) {
|
||||
closestHeadingDistance = distance;
|
||||
closestHeading = heading;
|
||||
} else {
|
||||
|
@ -122,13 +134,6 @@ export default {
|
|||
liParent.classList.add("active");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
api.cleanupStream(() => {
|
||||
document.body.classList.remove("d-toc-timeline-visible");
|
||||
document.removeEventListener("click", this.clickTOC, false);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
insertTOC(headings) {
|
||||
|
|
Loading…
Reference in New Issue