lildocs 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/cli.mjs +304 -432
- package/dist/render/Layout.tsrx +362 -0
- package/dist/render/Search.tsrx +409 -0
- package/dist/render/client.tsrx +50 -0
- package/dist/render/copy-code.ts +56 -0
- package/dist/render/heading-links.ts +50 -0
- package/dist/render/navigation.ts +16 -0
- package/dist/render/paths.ts +47 -0
- package/dist/render/renderPage.tsrx +14 -0
- package/dist/render/section-highlight.ts +63 -0
- package/dist/render/sidebar.ts +31 -0
- package/dist/render/styles.css +392 -95
- package/dist/render/table-viewer.ts +98 -0
- package/dist/render/tabler-icons.css +16 -0
- package/dist/render/types.ts +9 -0
- package/package.json +15 -11
- package/dist/render/copy-code.js +0 -54
- package/dist/render/navigation.js +0 -14
- package/dist/render/search.js +0 -3254
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const sectionHighlightStorageKey = "lildocs:section-highlight";
|
|
2
|
+
let pendingSectionUrl: string | undefined;
|
|
3
|
+
|
|
4
|
+
export function initSectionHighlights() {
|
|
5
|
+
document.addEventListener("click", (event) => {
|
|
6
|
+
if (!(event.target instanceof Element)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const link = event.target.closest<HTMLAnchorElement>('.toc a[href^="#"]');
|
|
11
|
+
if (link) {
|
|
12
|
+
queueSectionHighlight(link.href);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
document.addEventListener("lildocs:page-view", highlightPendingSection);
|
|
16
|
+
window.addEventListener("hashchange", highlightPendingSection);
|
|
17
|
+
highlightPendingSection();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function queueSectionHighlight(href: string) {
|
|
21
|
+
pendingSectionUrl = href;
|
|
22
|
+
try {
|
|
23
|
+
window.sessionStorage.setItem(sectionHighlightStorageKey, href);
|
|
24
|
+
} catch {}
|
|
25
|
+
window.requestAnimationFrame(highlightPendingSection);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function highlightPendingSection() {
|
|
29
|
+
let href = pendingSectionUrl;
|
|
30
|
+
if (!href) {
|
|
31
|
+
try {
|
|
32
|
+
href =
|
|
33
|
+
window.sessionStorage.getItem(sectionHighlightStorageKey) ?? undefined;
|
|
34
|
+
} catch {}
|
|
35
|
+
}
|
|
36
|
+
if (!href) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const targetUrl = new URL(href, document.baseURI);
|
|
41
|
+
if (
|
|
42
|
+
targetUrl.origin !== window.location.origin ||
|
|
43
|
+
targetUrl.pathname !== window.location.pathname ||
|
|
44
|
+
targetUrl.search !== window.location.search ||
|
|
45
|
+
targetUrl.hash !== window.location.hash
|
|
46
|
+
) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const target = document.getElementById(
|
|
51
|
+
decodeURIComponent(targetUrl.hash.slice(1)),
|
|
52
|
+
);
|
|
53
|
+
if (!target) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
pendingSectionUrl = undefined;
|
|
58
|
+
try {
|
|
59
|
+
window.sessionStorage.removeItem(sectionHighlightStorageKey);
|
|
60
|
+
} catch {}
|
|
61
|
+
target.classList.remove("sectionHighlight");
|
|
62
|
+
window.requestAnimationFrame(() => target.classList.add("sectionHighlight"));
|
|
63
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function initSidebar() {
|
|
2
|
+
const sidebar = document.querySelector("#lildocs-sidebar");
|
|
3
|
+
const collapseButton = document.querySelector<HTMLButtonElement>(
|
|
4
|
+
"#lildocs-sidebar-toggle",
|
|
5
|
+
);
|
|
6
|
+
const expandButton = document.querySelector<HTMLButtonElement>(
|
|
7
|
+
"#lildocs-sidebar-expand",
|
|
8
|
+
);
|
|
9
|
+
const searchButton = document.querySelector<HTMLButtonElement>(
|
|
10
|
+
"#lildocs-floating-search",
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
if (!sidebar || !collapseButton || !expandButton || !searchButton) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const setCollapsed = (collapsed: boolean) => {
|
|
18
|
+
document.documentElement.classList.toggle("sidebar-collapsed", collapsed);
|
|
19
|
+
collapseButton.setAttribute(
|
|
20
|
+
"aria-label",
|
|
21
|
+
collapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
collapseButton.addEventListener("click", () => setCollapsed(true));
|
|
26
|
+
expandButton.addEventListener("click", () => setCollapsed(false));
|
|
27
|
+
searchButton.addEventListener("click", () => {
|
|
28
|
+
setCollapsed(false);
|
|
29
|
+
document.dispatchEvent(new CustomEvent("lildocs:search-toggle"));
|
|
30
|
+
});
|
|
31
|
+
}
|