markshelf 0.1.3 → 0.1.4
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09qrkq5._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/static/chunks/{00.xwfz0gk8.7.css → 04x.fjh8sw0s1.css} +1 -1
- package/.next/{static/chunks/0rozoj9pfglno.js → standalone/.next/static/chunks/0z_707.y37o2..js} +4 -4
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/src/components/LinkGraph.tsx +69 -13
- package/.next/standalone/tsconfig.tsbuildinfo +1 -1
- package/.next/static/chunks/{00.xwfz0gk8.7.css → 04x.fjh8sw0s1.css} +1 -1
- package/.next/{standalone/.next/static/chunks/0rozoj9pfglno.js → static/chunks/0z_707.y37o2..js} +4 -4
- package/package.json +1 -1
- /package/.next/standalone/.next/static/{eGdxHn4o2ccaRraueWazx → JkyieJgBB2eU8MtnlBGvG}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{eGdxHn4o2ccaRraueWazx → JkyieJgBB2eU8MtnlBGvG}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{eGdxHn4o2ccaRraueWazx → JkyieJgBB2eU8MtnlBGvG}/_ssgManifest.js +0 -0
- /package/.next/static/{eGdxHn4o2ccaRraueWazx → JkyieJgBB2eU8MtnlBGvG}/_buildManifest.js +0 -0
- /package/.next/static/{eGdxHn4o2ccaRraueWazx → JkyieJgBB2eU8MtnlBGvG}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{eGdxHn4o2ccaRraueWazx → JkyieJgBB2eU8MtnlBGvG}/_ssgManifest.js +0 -0
|
@@ -18,12 +18,33 @@ interface Props {
|
|
|
18
18
|
onNavigate: (path: string) => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const DEPTH_KEY = "markshelf:linkGraphDepth";
|
|
22
|
+
const DEPTH_OPTIONS: { value: number; label: string }[] = [
|
|
23
|
+
{ value: 1, label: "1階層" },
|
|
24
|
+
{ value: 2, label: "2階層" },
|
|
25
|
+
{ value: 3, label: "3階層" },
|
|
26
|
+
{ value: Infinity, label: "全階層" },
|
|
27
|
+
];
|
|
28
|
+
|
|
21
29
|
export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
22
30
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
23
31
|
const cyRef = useRef<cytoscape.Core | null>(null);
|
|
24
32
|
const [loading, setLoading] = useState(true);
|
|
25
33
|
const [empty, setEmpty] = useState(false);
|
|
26
34
|
const [ready, setReady] = useState(false);
|
|
35
|
+
const [depth, setDepth] = useState<number>(1);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const saved = localStorage.getItem(DEPTH_KEY);
|
|
39
|
+
if (saved === null) return;
|
|
40
|
+
const v = saved === "all" ? Infinity : Number(saved);
|
|
41
|
+
if (Number.isFinite(v) || v === Infinity) setDepth(v);
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const changeDepth = (d: number) => {
|
|
45
|
+
setDepth(d);
|
|
46
|
+
localStorage.setItem(DEPTH_KEY, d === Infinity ? "all" : String(d));
|
|
47
|
+
};
|
|
27
48
|
|
|
28
49
|
useEffect(() => {
|
|
29
50
|
let cancelled = false;
|
|
@@ -37,12 +58,23 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
37
58
|
.then((data: { nodes: GraphNode[]; edges: GraphEdge[] }) => {
|
|
38
59
|
if (cancelled || !containerRef.current) return;
|
|
39
60
|
|
|
40
|
-
//
|
|
41
|
-
const
|
|
42
|
-
connectedPaths.add(currentPath);
|
|
61
|
+
// Show only nodes reachable from currentPath (undirected connected component)
|
|
62
|
+
const adj = new Map<string, string[]>();
|
|
43
63
|
for (const e of data.edges) {
|
|
44
|
-
|
|
45
|
-
|
|
64
|
+
(adj.get(e.source) ?? adj.set(e.source, []).get(e.source)!).push(e.target);
|
|
65
|
+
(adj.get(e.target) ?? adj.set(e.target, []).get(e.target)!).push(e.source);
|
|
66
|
+
}
|
|
67
|
+
const connectedPaths = new Set<string>([currentPath]);
|
|
68
|
+
const queue: [string, number][] = [[currentPath, 0]];
|
|
69
|
+
while (queue.length > 0) {
|
|
70
|
+
const [cur, lvl] = queue.shift()!;
|
|
71
|
+
if (lvl >= depth) continue;
|
|
72
|
+
for (const nb of adj.get(cur) ?? []) {
|
|
73
|
+
if (!connectedPaths.has(nb)) {
|
|
74
|
+
connectedPaths.add(nb);
|
|
75
|
+
queue.push([nb, lvl + 1]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
46
78
|
}
|
|
47
79
|
|
|
48
80
|
const localNodes = data.nodes.filter((n) => connectedPaths.has(n.id));
|
|
@@ -50,6 +82,11 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
50
82
|
(e) => connectedPaths.has(e.source) && connectedPaths.has(e.target),
|
|
51
83
|
);
|
|
52
84
|
|
|
85
|
+
// roots = nodes with no incoming edge within the component
|
|
86
|
+
const hasIncoming = new Set<string>();
|
|
87
|
+
for (const e of localEdges) hasIncoming.add(e.target);
|
|
88
|
+
const rootPaths = localNodes.map((n) => n.id).filter((id) => !hasIncoming.has(id));
|
|
89
|
+
|
|
53
90
|
if (localNodes.length === 0) {
|
|
54
91
|
setEmpty(true);
|
|
55
92
|
setLoading(false);
|
|
@@ -93,7 +130,7 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
93
130
|
"border-color": "#3b7ddb",
|
|
94
131
|
width: 28,
|
|
95
132
|
height: 28,
|
|
96
|
-
"text-max-width": "
|
|
133
|
+
"text-max-width": "180px",
|
|
97
134
|
"text-wrap": "ellipsis",
|
|
98
135
|
"cursor": "pointer",
|
|
99
136
|
} as cytoscape.Css.Node,
|
|
@@ -128,14 +165,14 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
128
165
|
},
|
|
129
166
|
],
|
|
130
167
|
layout: {
|
|
131
|
-
name: "
|
|
168
|
+
name: "breadthfirst",
|
|
132
169
|
animate: false,
|
|
133
170
|
padding: 50,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} as cytoscape.
|
|
171
|
+
spacingFactor: 1.2,
|
|
172
|
+
directed: true,
|
|
173
|
+
grid: false,
|
|
174
|
+
roots: rootPaths.length > 0 ? rootPaths : [currentPath],
|
|
175
|
+
} as cytoscape.BreadthFirstLayoutOptions,
|
|
139
176
|
userZoomingEnabled: true,
|
|
140
177
|
userPanningEnabled: true,
|
|
141
178
|
boxSelectionEnabled: false,
|
|
@@ -199,10 +236,29 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
199
236
|
cyRef.current?.destroy();
|
|
200
237
|
cyRef.current = null;
|
|
201
238
|
};
|
|
202
|
-
}, [currentPath, onNavigate]);
|
|
239
|
+
}, [currentPath, onNavigate, depth]);
|
|
203
240
|
|
|
204
241
|
return (
|
|
205
242
|
<div className="h-full flex flex-col relative">
|
|
243
|
+
<div className="flex items-center gap-1.5 px-3 py-2 shrink-0">
|
|
244
|
+
<span className="text-[11px] text-[var(--text-muted)] mr-1">表示範囲</span>
|
|
245
|
+
{DEPTH_OPTIONS.map((opt) => {
|
|
246
|
+
const active = depth === opt.value;
|
|
247
|
+
return (
|
|
248
|
+
<button
|
|
249
|
+
key={opt.label}
|
|
250
|
+
onClick={() => changeDepth(opt.value)}
|
|
251
|
+
className={`px-2 py-0.5 rounded-md text-[11px] font-medium transition-colors ${
|
|
252
|
+
active
|
|
253
|
+
? "bg-[var(--brand-primary)] text-white"
|
|
254
|
+
: "text-[var(--text-muted)] hover:bg-[var(--bg-muted)] hover:text-[var(--text-secondary)]"
|
|
255
|
+
}`}
|
|
256
|
+
>
|
|
257
|
+
{opt.label}
|
|
258
|
+
</button>
|
|
259
|
+
);
|
|
260
|
+
})}
|
|
261
|
+
</div>
|
|
206
262
|
{(loading || empty) && (
|
|
207
263
|
<div className="absolute inset-0 flex items-center justify-center text-[13px] text-[var(--text-muted)] z-10 bg-[var(--bg-surface)]">
|
|
208
264
|
{loading ? "グラフを構築中..." : "このドキュメントへのリンクはありません"}
|