living-documentation 7.7.0 → 7.9.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.
|
@@ -12,6 +12,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
12
12
|
setupSearch();
|
|
13
13
|
wcRestorePrefs();
|
|
14
14
|
if (typeof initFileAttach === "function") initFileAttach();
|
|
15
|
+
if (typeof initSidebarResize === "function") initSidebarResize();
|
|
15
16
|
await loadConfig();
|
|
16
17
|
if (typeof initMarkerState === "function") initMarkerState();
|
|
17
18
|
if (typeof initFullWidthState === "function") initFullWidthState();
|
|
@@ -295,5 +295,5 @@ document.getElementById('darkIcon').textContent =
|
|
|
295
295
|
})();
|
|
296
296
|
|
|
297
297
|
// ── Bootstrap ─────────────────────────────────────────────────────────────────
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
// loadDiagramList() is invoked from the inline IIFE in diagram.html after
|
|
299
|
+
// window.initI18n() resolves, so t() returns localised strings (not raw keys).
|
|
@@ -1225,6 +1225,7 @@
|
|
|
1225
1225
|
<script type="module">
|
|
1226
1226
|
import { NODE_COLORS, NODE_L_RATIOS, DEFAULT_NODE_PALETTE, DEFAULT_EDGE_PALETTE, deriveNodeColors } from '/diagram/constants.js';
|
|
1227
1227
|
import { st } from '/diagram/state.js';
|
|
1228
|
+
import { loadDiagramList } from '/diagram/persistence.js';
|
|
1228
1229
|
(async () => {
|
|
1229
1230
|
// diagramNodePalette: array of 15 bg hex strings (positional, matching DEFAULT_NODE_PALETTE)
|
|
1230
1231
|
// diagramEdgePalette: array of hex strings
|
|
@@ -1273,6 +1274,7 @@
|
|
|
1273
1274
|
ec.appendChild(btn);
|
|
1274
1275
|
});
|
|
1275
1276
|
window.applyI18n();
|
|
1277
|
+
loadDiagramList();
|
|
1276
1278
|
})();
|
|
1277
1279
|
</script>
|
|
1278
1280
|
</body>
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
<script defer src="/dark-mode.js"></script>
|
|
41
41
|
<script defer src="/config.js"></script>
|
|
42
42
|
<script defer src="/sidebar.js"></script>
|
|
43
|
+
<script defer src="/sidebar-resize.js"></script>
|
|
43
44
|
<script defer src="/search.js"></script>
|
|
44
45
|
<script defer src="/image-paste.js"></script>
|
|
45
46
|
<script defer src="/file-attach.js"></script>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// ── Sidebar horizontal resize ───────────────────────────────────────────────
|
|
2
|
+
// Drag a handle on the sidebar's right edge to resize it.
|
|
3
|
+
// Width is persisted in localStorage (`ld-sidebar-w`) across reloads.
|
|
4
|
+
// The toggle (toggleSidebar) keeps working because it only flips the `hidden`
|
|
5
|
+
// class — width stays intact on the element.
|
|
6
|
+
|
|
7
|
+
(function () {
|
|
8
|
+
const STORAGE_KEY = "ld-sidebar-w";
|
|
9
|
+
const MIN_W = 200;
|
|
10
|
+
const MAX_W = 600;
|
|
11
|
+
|
|
12
|
+
function applyStoredWidth() {
|
|
13
|
+
const sidebar = document.getElementById("sidebar");
|
|
14
|
+
if (!sidebar) return;
|
|
15
|
+
let w = parseInt(localStorage.getItem(STORAGE_KEY) || "", 10);
|
|
16
|
+
if (!Number.isFinite(w)) return;
|
|
17
|
+
w = Math.max(MIN_W, Math.min(MAX_W, w));
|
|
18
|
+
sidebar.classList.remove("w-72");
|
|
19
|
+
sidebar.style.width = w + "px";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function initSidebarResize() {
|
|
23
|
+
const sidebar = document.getElementById("sidebar");
|
|
24
|
+
if (!sidebar) return;
|
|
25
|
+
|
|
26
|
+
applyStoredWidth();
|
|
27
|
+
|
|
28
|
+
const handle = document.createElement("div");
|
|
29
|
+
handle.id = "sidebar-resize-handle";
|
|
30
|
+
handle.setAttribute("aria-hidden", "true");
|
|
31
|
+
handle.style.cssText = [
|
|
32
|
+
"position:absolute",
|
|
33
|
+
"top:0",
|
|
34
|
+
"right:-2px",
|
|
35
|
+
"width:6px",
|
|
36
|
+
"height:100%",
|
|
37
|
+
"cursor:col-resize",
|
|
38
|
+
"z-index:20",
|
|
39
|
+
"user-select:none",
|
|
40
|
+
"background:transparent",
|
|
41
|
+
"transition:background 0.15s ease",
|
|
42
|
+
].join(";");
|
|
43
|
+
handle.addEventListener("mouseenter", () => {
|
|
44
|
+
handle.style.background = "rgba(59,130,246,0.35)";
|
|
45
|
+
});
|
|
46
|
+
handle.addEventListener("mouseleave", () => {
|
|
47
|
+
if (!handle.dataset.dragging) handle.style.background = "transparent";
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Sidebar needs `relative` so the absolutely-positioned handle anchors to it.
|
|
51
|
+
sidebar.style.position = "relative";
|
|
52
|
+
sidebar.appendChild(handle);
|
|
53
|
+
|
|
54
|
+
let startX = 0;
|
|
55
|
+
let startW = 0;
|
|
56
|
+
|
|
57
|
+
function onMove(e) {
|
|
58
|
+
const dx = e.clientX - startX;
|
|
59
|
+
let w = startW + dx;
|
|
60
|
+
w = Math.max(MIN_W, Math.min(MAX_W, w));
|
|
61
|
+
sidebar.style.width = w + "px";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function onUp() {
|
|
65
|
+
document.removeEventListener("mousemove", onMove);
|
|
66
|
+
document.removeEventListener("mouseup", onUp);
|
|
67
|
+
document.body.style.cursor = "";
|
|
68
|
+
document.body.style.userSelect = "";
|
|
69
|
+
delete handle.dataset.dragging;
|
|
70
|
+
handle.style.background = "transparent";
|
|
71
|
+
const finalW = parseInt(sidebar.style.width, 10);
|
|
72
|
+
if (Number.isFinite(finalW)) {
|
|
73
|
+
try {
|
|
74
|
+
localStorage.setItem(STORAGE_KEY, String(finalW));
|
|
75
|
+
} catch {
|
|
76
|
+
/* ignore */
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
handle.addEventListener("mousedown", (e) => {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
startX = e.clientX;
|
|
84
|
+
startW = sidebar.getBoundingClientRect().width;
|
|
85
|
+
// Drop the Tailwind width class so inline width takes over for good.
|
|
86
|
+
sidebar.classList.remove("w-72");
|
|
87
|
+
sidebar.style.width = startW + "px";
|
|
88
|
+
handle.dataset.dragging = "1";
|
|
89
|
+
handle.style.background = "rgba(59,130,246,0.55)";
|
|
90
|
+
document.body.style.cursor = "col-resize";
|
|
91
|
+
document.body.style.userSelect = "none";
|
|
92
|
+
document.addEventListener("mousemove", onMove);
|
|
93
|
+
document.addEventListener("mouseup", onUp);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
window.initSidebarResize = initSidebarResize;
|
|
98
|
+
})();
|