mirror of
https://github.com/discourse/DiscoTOC.git
synced 2025-03-07 01:39:50 +00:00
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}";
|
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) => {
|
api.onAppEvent("topic:current-post-scrolled", (args) => {
|
||||||
if (args.postIndex !== 1) {
|
if (args.postIndex !== 1) {
|
||||||
return;
|
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")) {
|
if (!document.querySelector(".d-toc-cooked")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -93,10 +108,7 @@ export default {
|
|||||||
const distance = Math.abs(
|
const distance = Math.abs(
|
||||||
domUtils.offset(heading).top - headerOffset() - window.scrollY
|
domUtils.offset(heading).top - headerOffset() - window.scrollY
|
||||||
);
|
);
|
||||||
if (
|
if (closestHeadingDistance == null || distance < closestHeadingDistance) {
|
||||||
closestHeadingDistance == null ||
|
|
||||||
distance < closestHeadingDistance
|
|
||||||
) {
|
|
||||||
closestHeadingDistance = distance;
|
closestHeadingDistance = distance;
|
||||||
closestHeading = heading;
|
closestHeading = heading;
|
||||||
} else {
|
} else {
|
||||||
@ -122,13 +134,6 @@ export default {
|
|||||||
liParent.classList.add("active");
|
liParent.classList.add("active");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
api.cleanupStream(() => {
|
|
||||||
document.body.classList.remove("d-toc-timeline-visible");
|
|
||||||
document.removeEventListener("click", this.clickTOC, false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
insertTOC(headings) {
|
insertTOC(headings) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user