@hyperbook/markdown 0.44.0 → 0.45.0
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/dist/assets/client.js +32 -27
- package/dist/assets/dexie-export-import.js +15 -3497
- package/dist/assets/directive-collapsible/style.css +19 -23
- package/dist/assets/directive-tabs/client.js +31 -27
- package/dist/assets/directive-tabs/style.css +95 -12
- package/dist/assets/shell.css +55 -22
- package/dist/index.js +141 -93
- package/dist/index.js.map +2 -2
- package/package.json +4 -3
package/dist/assets/client.js
CHANGED
|
@@ -4,34 +4,39 @@ var hyperbook = (function () {
|
|
|
4
4
|
* @param {HTMLElement} root - The root element to initialize.
|
|
5
5
|
*/
|
|
6
6
|
const initCollapsibles = (root) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
// Handle both navigation sections and directive-collapsible elements
|
|
8
|
+
const detailsEls = root.querySelectorAll("details.section, details.directive-collapsible");
|
|
9
|
+
for (let details of detailsEls) {
|
|
10
|
+
const id = details.getAttribute("data-id");
|
|
11
|
+
|
|
12
|
+
// Prevent link clicks from toggling the details element in navigation
|
|
13
|
+
if (id && id.startsWith("_nav:") && !details.classList.contains("empty")) {
|
|
14
|
+
const link = details.querySelector("summary a");
|
|
13
15
|
link?.addEventListener("click", (event) => {
|
|
14
16
|
event.stopPropagation();
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
// Listen for toggle events to persist state and sync with other elements
|
|
21
|
+
details.addEventListener("toggle", () => {
|
|
19
22
|
if (id) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
if (details.open) {
|
|
24
|
+
store.collapsibles.put({ id });
|
|
25
|
+
} else {
|
|
26
|
+
store.collapsibles.delete(id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Sync all elements with the same ID
|
|
30
|
+
const allWithSameId = document.querySelectorAll(`[data-id="${id}"]`);
|
|
31
|
+
for (let el of allWithSameId) {
|
|
32
|
+
if (el !== details && el.tagName === "DETAILS") {
|
|
33
|
+
el.open = details.open;
|
|
29
34
|
}
|
|
30
|
-
}
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
setTimeout(() => {
|
|
34
|
-
window.dispatchEvent(new Event("resize")); // geogebra
|
|
39
|
+
window.dispatchEvent(new Event("resize")); // geogebra needs this to resize the applet
|
|
35
40
|
}, 100);
|
|
36
41
|
});
|
|
37
42
|
}
|
|
@@ -43,15 +48,15 @@ var hyperbook = (function () {
|
|
|
43
48
|
*/
|
|
44
49
|
const updateCollapsibles = (root) => {
|
|
45
50
|
store.collapsibles.toArray().then((collapsibles) => {
|
|
46
|
-
const
|
|
47
|
-
for (let
|
|
48
|
-
const id =
|
|
51
|
+
const detailsEls = root.querySelectorAll("details.section, details.directive-collapsible");
|
|
52
|
+
for (let details of detailsEls) {
|
|
53
|
+
const id = details.getAttribute("data-id");
|
|
49
54
|
if (id) {
|
|
50
|
-
const
|
|
51
|
-
if
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const shouldBeOpen = collapsibles.some((c) => c.id === id);
|
|
56
|
+
// Only update if state differs and it's not a navigation section
|
|
57
|
+
// (navigation sections are auto-expanded based on current page)
|
|
58
|
+
if (!id.startsWith("_nav:") && details.open !== shouldBeOpen) {
|
|
59
|
+
details.open = shouldBeOpen;
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
}
|