markshelf 0.1.3 → 0.1.5
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/app-path-routes-manifest.json +1 -0
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/routes-manifest.json +6 -0
- 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/api/diff/route.js +3 -2
- package/.next/standalone/.next/server/app/api/diff/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/file/route.js +3 -2
- package/.next/standalone/.next/server/app/api/file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/graph/route.js +3 -2
- package/.next/standalone/.next/server/app/api/graph/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/history/route.js +3 -2
- package/.next/standalone/.next/server/app/api/history/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/search/route.js +3 -2
- package/.next/standalone/.next/server/app/api/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/timeline/route.js +3 -2
- package/.next/standalone/.next/server/app/api/timeline/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/tree/route.js +3 -2
- package/.next/standalone/.next/server/app/api/tree/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/watch/route/app-paths-manifest.json +3 -0
- package/.next/standalone/.next/server/app/api/watch/route/build-manifest.json +9 -0
- package/.next/standalone/.next/server/app/api/watch/route/server-reference-manifest.json +4 -0
- package/.next/standalone/.next/server/app/api/watch/route.js +6 -0
- package/.next/standalone/.next/server/app/api/watch/route.js.map +5 -0
- package/.next/standalone/.next/server/app/api/watch/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/watch/route_client-reference-manifest.js +3 -0
- package/.next/standalone/.next/server/app/favicon.ico/route.js +2 -1
- package/.next/standalone/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- 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.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +1 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-_k816._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__04otwp7._.js → [root-of-the-server]__01e7zo7._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0zoyna0._.js → [root-of-the-server]__053gm34._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0_gt~a4._.js → [root-of-the-server]__0d.-s5p._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0i.wyss._.js +6 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0qnrcw7._.js → [root-of-the-server]__0nr71d2._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0op9af~._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__01cq2u6._.js → [root-of-the-server]__0rwylex._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0yvq0sd._.js → [root-of-the-server]__13vatcq._.js} +2 -2
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_watch_route_actions_0go0kk3.js +3 -0
- package/.next/standalone/.next/server/chunks/node_modules_next_04~_e52._.js +13 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__05ar4zx._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09qrkq5._.js +5 -5
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0serya4._.js → [root-of-the-server]__11e9~iq._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_10cz306._.js → node_modules_02chd8n._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_0eva9q1._.js → node_modules_08z1b9i._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_05e-8m3._.js → node_modules_0f-9xhq._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_06r3o30._.js → node_modules_0u-.0s2._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_09.cbx4._.js → node_modules_0vqo_80._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_11wp0ye._.js → node_modules_0xmn29o._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_0ic-wja._.js → node_modules_0~k33bz._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_0w2-q.z._.js → node_modules_10a06qi._.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/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/0b42--.p9znhl.css +1 -0
- package/.next/standalone/.next/static/chunks/0wy.nfhujao0b.js +11 -0
- package/.next/standalone/docs//344/273/225/346/247/230/README.md +9 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC1-CLI/README.md +3 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC1-CLI/SPEC1.1-bin-cli.md +14 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC2-/343/202/260/343/203/251/343/203/225/346/217/217/347/224/273/README.md +3 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC2-/343/202/260/343/203/251/343/203/225/346/217/217/347/224/273/SPEC2.1-graph-api.md +16 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC2-/343/202/260/343/203/251/343/203/225/346/217/217/347/224/273/SPEC2.2-breadthfirst-layout.md +10 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC3-UI/343/202/263/343/203/263/343/203/235/343/203/274/343/203/215/343/203/263/343/203/210/README.md +3 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC3-UI/343/202/263/343/203/263/343/203/235/343/203/274/343/203/215/343/203/263/343/203/210/SPEC3.1-PreviewPopup.md +10 -0
- package/.next/standalone/docs//344/273/225/346/247/230/SPEC3-UI/343/202/263/343/203/263/343/203/235/343/203/274/343/203/215/343/203/263/343/203/210/SPEC3.2-TreeView.md +10 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/Cytoscape.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/Markdown.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/Nextjs.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/breadthfirst.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/npx.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206/standalone.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206//343/203/204/343/203/252/343/203/274/343/203/223/343/203/245/343/203/274.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206//343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/203/235/343/203/203/343/203/227/343/202/242/343/203/203/343/203/227.md +5 -0
- package/.next/standalone/docs//347/224/250/350/252/236/351/233/206//343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225.md +5 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/README.md +9 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ1-/343/203/223/343/203/245/343/203/274/343/202/242/350/265/267/345/213/225/README.md +3 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ1-/343/203/223/343/203/245/343/203/274/343/202/242/350/265/267/345/213/225/REQ1.1-npx/350/265/267/345/213/225.md +13 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ2-/343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225/README.md +3 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ2-/343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225/REQ2.1-/343/202/260/343/203/251/343/203/225/346/217/217/347/224/273.md +11 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ2-/343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225/REQ2.2-/351/232/216/345/261/244/345/210/207/346/233/277.md +10 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ2-/343/203/252/343/203/263/343/202/257/343/202/260/343/203/251/343/203/225/REQ2.3-/343/203/225/343/202/251/343/203/253/343/203/200/351/231/244/345/244/226.md +10 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ3-/343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/201/250/343/203/204/343/203/252/343/203/274/README.md +3 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ3-/343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/201/250/343/203/204/343/203/252/343/203/274/REQ3.1-/343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/203/235/343/203/203/343/203/227/343/202/242/343/203/203/343/203/227.md +15 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ3-/343/203/227/343/203/254/343/203/223/343/203/245/343/203/274/343/201/250/343/203/204/343/203/252/343/203/274/REQ3.2-/343/203/204/343/203/252/343/203/274/343/203/223/343/203/245/343/203/274.md +14 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ4-/343/203/212/343/203/223/343/202/262/343/203/274/343/202/267/343/203/247/343/203/263/README.md +3 -0
- package/.next/standalone/docs//350/246/201/344/273/266/345/256/232/347/276/251/REQ4-/343/203/212/343/203/223/343/202/262/343/203/274/343/202/267/343/203/247/343/203/263/REQ4.1-/346/210/273/343/202/213/351/200/262/343/202/200.md +10 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R1-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/262/350/246/247/346/200/247/R1.1-/347/213/254/347/253/213/343/203/223/343/203/245/343/203/274/343/202/242.md +11 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R1-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/262/350/246/247/346/200/247/R1.2-/345/244/247/347/224/273/351/235/242/350/241/250/347/244/272.md +11 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R1-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/262/350/246/247/346/200/247/R1.3-/343/203/212/343/203/223/343/202/262/343/203/274/343/202/267/343/203/247/343/203/263/345/261/245/346/255/264.md +9 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R1-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/262/350/246/247/346/200/247/README.md +7 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R2-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/242/344/277/202/343/201/256/345/217/257/350/246/226/345/214/226/R2.1-/344/276/235/345/255/230/351/226/242/344/277/202/343/201/256/346/212/212/346/217/241.md +9 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R2-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/242/344/277/202/343/201/256/345/217/257/350/246/226/345/214/226/R2.2-/345/217/202/347/205/247/345/205/203/343/201/256/346/212/212/346/217/241.md +9 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R2-/343/203/211/343/202/255/343/203/245/343/203/241/343/203/263/343/203/210/351/226/242/344/277/202/343/201/256/345/217/257/350/246/226/345/214/226/README.md +8 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R3-/343/202/252/343/203/263/343/203/234/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/346/224/257/346/217/264/R3.1-/347/224/250/350/252/236/343/201/256/345/215/263/346/231/202/347/242/272/350/252/215.md +11 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/R3-/343/202/252/343/203/263/343/203/234/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/346/224/257/346/217/264/README.md +7 -0
- package/.next/standalone/docs//350/246/201/346/261/202/345/256/232/347/276/251/README.md +9 -0
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/src/app/api/watch/route.ts +89 -0
- package/.next/standalone/src/app/page.tsx +41 -8
- package/.next/standalone/src/components/DetailPanel.tsx +38 -6
- package/.next/standalone/src/components/HistoryPanel.tsx +3 -1
- package/.next/standalone/src/components/LinkGraph.tsx +247 -21
- package/.next/standalone/src/components/Markdown.tsx +60 -5
- package/.next/standalone/src/components/PreviewPopup.tsx +4 -2
- package/.next/standalone/src/components/TimelinePanel.tsx +3 -1
- package/.next/standalone/src/components/TreeView.tsx +36 -9
- package/.next/standalone/src/lib/links.ts +98 -25
- package/.next/standalone/src/lib/useRefreshTick.ts +43 -0
- package/.next/standalone/tsconfig.tsbuildinfo +1 -1
- package/.next/static/chunks/0b42--.p9znhl.css +1 -0
- package/.next/static/chunks/0wy.nfhujao0b.js +11 -0
- package/package.json +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0j8-xkl._.js +0 -13
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0owpp0l._.js +0 -3
- package/.next/standalone/.next/static/chunks/00.xwfz0gk8.7.css +0 -1
- package/.next/standalone/.next/static/chunks/0rozoj9pfglno.js +0 -11
- package/.next/standalone/AGENTS.md +0 -5
- package/.next/standalone/CLAUDE.md +0 -1
- package/.next/standalone/markshelf-0.1.0.tgz +0 -0
- package/.next/standalone/markshelf-0.1.2.tgz +0 -0
- package/.next/static/chunks/00.xwfz0gk8.7.css +0 -1
- package/.next/static/chunks/0rozoj9pfglno.js +0 -11
- /package/.next/standalone/.next/static/{eGdxHn4o2ccaRraueWazx → pOQs5i4GMjDH6W5XDSjRs}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{eGdxHn4o2ccaRraueWazx → pOQs5i4GMjDH6W5XDSjRs}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{eGdxHn4o2ccaRraueWazx → pOQs5i4GMjDH6W5XDSjRs}/_ssgManifest.js +0 -0
- /package/.next/static/{eGdxHn4o2ccaRraueWazx → pOQs5i4GMjDH6W5XDSjRs}/_buildManifest.js +0 -0
- /package/.next/static/{eGdxHn4o2ccaRraueWazx → pOQs5i4GMjDH6W5XDSjRs}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{eGdxHn4o2ccaRraueWazx → pOQs5i4GMjDH6W5XDSjRs}/_ssgManifest.js +0 -0
|
@@ -6,17 +6,27 @@ import { HistoryPanel } from "./HistoryPanel";
|
|
|
6
6
|
import { TableOfContents, HeadingInfo } from "./TableOfContents";
|
|
7
7
|
import { PreviewPopup } from "./PreviewPopup";
|
|
8
8
|
import { LinkGraph } from "./LinkGraph";
|
|
9
|
-
import {
|
|
9
|
+
import { useRefreshTick } from "@/lib/useRefreshTick";
|
|
10
|
+
import { FileText, History, Network, ArrowLeft, ArrowRight } from "lucide-react";
|
|
11
|
+
|
|
12
|
+
interface FolderInfo {
|
|
13
|
+
path: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
depth: number;
|
|
16
|
+
}
|
|
10
17
|
|
|
11
18
|
interface Props {
|
|
12
19
|
filePath: string;
|
|
13
20
|
fileRefs?: FileRef[];
|
|
21
|
+
folders?: FolderInfo[];
|
|
14
22
|
onNavigate?: (path: string) => void;
|
|
15
23
|
onGoBack?: () => void;
|
|
24
|
+
onGoForward?: () => void;
|
|
16
25
|
canGoBack?: boolean;
|
|
26
|
+
canGoForward?: boolean;
|
|
17
27
|
}
|
|
18
28
|
|
|
19
|
-
export function DetailPanel({ filePath, fileRefs, onNavigate, onGoBack, canGoBack }: Props) {
|
|
29
|
+
export function DetailPanel({ filePath, fileRefs, folders, onNavigate, onGoBack, onGoForward, canGoBack, canGoForward }: Props) {
|
|
20
30
|
const [content, setContent] = useState<string | null>(null);
|
|
21
31
|
const [tab, setTab] = useState<"content" | "history" | "links">("content");
|
|
22
32
|
const [headings, setHeadings] = useState<HeadingInfo[]>([]);
|
|
@@ -35,20 +45,23 @@ export function DetailPanel({ filePath, fileRefs, onNavigate, onGoBack, canGoBac
|
|
|
35
45
|
const [previewPos, setPreviewPos] = useState<{ x: number; y: number } | null>(null);
|
|
36
46
|
const showTimer = useRef<ReturnType<typeof setTimeout>>(null);
|
|
37
47
|
const hideTimer = useRef<ReturnType<typeof setTimeout>>(null);
|
|
48
|
+
const refreshTick = useRefreshTick();
|
|
38
49
|
|
|
39
50
|
useEffect(() => {
|
|
40
51
|
setContent(null);
|
|
41
52
|
setHeadings([]);
|
|
42
|
-
// Clear preview popup state and cancel any pending timers on navigation
|
|
43
53
|
if (showTimer.current) clearTimeout(showTimer.current);
|
|
44
54
|
if (hideTimer.current) clearTimeout(hideTimer.current);
|
|
45
55
|
setPreviewPath(null);
|
|
46
56
|
setPreviewPos(null);
|
|
57
|
+
}, [filePath]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
47
60
|
fetch(`/api/file?path=${encodeURIComponent(filePath)}`)
|
|
48
61
|
.then((r) => r.json())
|
|
49
62
|
.then((data) => setContent(data.content ?? null))
|
|
50
63
|
.catch(() => setContent(null));
|
|
51
|
-
}, [filePath]);
|
|
64
|
+
}, [filePath, refreshTick]);
|
|
52
65
|
|
|
53
66
|
const handlePreviewShow = useCallback((path: string, rect: DOMRect) => {
|
|
54
67
|
if (hideTimer.current) clearTimeout(hideTimer.current);
|
|
@@ -113,6 +126,15 @@ export function DetailPanel({ filePath, fileRefs, onNavigate, onGoBack, canGoBac
|
|
|
113
126
|
<ArrowLeft size={14} />
|
|
114
127
|
</button>
|
|
115
128
|
)}
|
|
129
|
+
{canGoForward && (
|
|
130
|
+
<button
|
|
131
|
+
onClick={onGoForward}
|
|
132
|
+
className="shrink-0 p-0.5 rounded hover:bg-[var(--bg-muted)] text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors"
|
|
133
|
+
title="進む"
|
|
134
|
+
>
|
|
135
|
+
<ArrowRight size={14} />
|
|
136
|
+
</button>
|
|
137
|
+
)}
|
|
116
138
|
<h2 className="font-semibold text-[14px] leading-snug truncate text-[var(--text-primary)]">
|
|
117
139
|
{fileName}
|
|
118
140
|
</h2>
|
|
@@ -163,7 +185,10 @@ export function DetailPanel({ filePath, fileRefs, onNavigate, onGoBack, canGoBac
|
|
|
163
185
|
onHeadingsExtracted={setHeadings}
|
|
164
186
|
fileRefs={fileRefs}
|
|
165
187
|
currentPath={filePath}
|
|
166
|
-
onNavigate={
|
|
188
|
+
onNavigate={(p) => {
|
|
189
|
+
setTab("content");
|
|
190
|
+
onNavigate?.(p);
|
|
191
|
+
}}
|
|
167
192
|
onPreviewShow={handlePreviewShow}
|
|
168
193
|
onPreviewHide={handlePreviewHide}
|
|
169
194
|
>
|
|
@@ -195,7 +220,13 @@ export function DetailPanel({ filePath, fileRefs, onNavigate, onGoBack, canGoBac
|
|
|
195
220
|
</div>
|
|
196
221
|
) : (
|
|
197
222
|
<div className="flex-1 overflow-hidden">
|
|
198
|
-
<LinkGraph
|
|
223
|
+
<LinkGraph
|
|
224
|
+
currentPath={filePath}
|
|
225
|
+
folders={folders ?? []}
|
|
226
|
+
onNavigate={(p) => onNavigate?.(p)}
|
|
227
|
+
onPreviewShow={handlePreviewShow}
|
|
228
|
+
onPreviewHide={handlePreviewHide}
|
|
229
|
+
/>
|
|
199
230
|
</div>
|
|
200
231
|
)}
|
|
201
232
|
|
|
@@ -205,6 +236,7 @@ export function DetailPanel({ filePath, fileRefs, onNavigate, onGoBack, canGoBac
|
|
|
205
236
|
onNavigate={(p) => {
|
|
206
237
|
setPreviewPath(null);
|
|
207
238
|
setPreviewPos(null);
|
|
239
|
+
setTab("content");
|
|
208
240
|
onNavigate?.(p);
|
|
209
241
|
}}
|
|
210
242
|
onMouseEnter={handlePreviewEnter}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { GitCommit, ChevronDown, ChevronRight } from "lucide-react";
|
|
5
5
|
import { DiffView } from "./DiffView";
|
|
6
|
+
import { useRefreshTick } from "@/lib/useRefreshTick";
|
|
6
7
|
|
|
7
8
|
interface CommitEntry {
|
|
8
9
|
hash: string;
|
|
@@ -20,6 +21,7 @@ export function HistoryPanel({ filePath }: Props) {
|
|
|
20
21
|
const [history, setHistory] = useState<CommitEntry[]>([]);
|
|
21
22
|
const [loading, setLoading] = useState(true);
|
|
22
23
|
const [expandedHash, setExpandedHash] = useState<string | null>(null);
|
|
24
|
+
const refreshTick = useRefreshTick();
|
|
23
25
|
|
|
24
26
|
useEffect(() => {
|
|
25
27
|
setLoading(true);
|
|
@@ -31,7 +33,7 @@ export function HistoryPanel({ filePath }: Props) {
|
|
|
31
33
|
setLoading(false);
|
|
32
34
|
})
|
|
33
35
|
.catch(() => setLoading(false));
|
|
34
|
-
}, [filePath]);
|
|
36
|
+
}, [filePath, refreshTick]);
|
|
35
37
|
|
|
36
38
|
if (loading) {
|
|
37
39
|
return <div className="p-4 text-[var(--text-muted)] text-[13px]">読み込み中...</div>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import cytoscape from "cytoscape";
|
|
5
|
+
import { useRefreshTick } from "@/lib/useRefreshTick";
|
|
6
|
+
import { Filter } from "lucide-react";
|
|
5
7
|
|
|
6
8
|
interface GraphNode {
|
|
7
9
|
id: string;
|
|
@@ -13,17 +15,107 @@ interface GraphEdge {
|
|
|
13
15
|
target: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
interface FolderInfo {
|
|
19
|
+
path: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
depth: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
interface Props {
|
|
17
25
|
currentPath: string;
|
|
26
|
+
folders: FolderInfo[];
|
|
18
27
|
onNavigate: (path: string) => void;
|
|
28
|
+
onPreviewShow?: (path: string, rect: DOMRect) => void;
|
|
29
|
+
onPreviewHide?: () => void;
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
const DEPTH_KEY = "markshelf:linkGraphDepth";
|
|
33
|
+
const EXCLUDE_KEY = "markshelf:linkGraphExclude";
|
|
34
|
+
const ZOOM_KEY = "markshelf:linkGraphZoom";
|
|
35
|
+
const DEPTH_OPTIONS: { value: number; label: string }[] = [
|
|
36
|
+
{ value: 1, label: "1階層" },
|
|
37
|
+
{ value: 2, label: "2階層" },
|
|
38
|
+
{ value: 3, label: "3階層" },
|
|
39
|
+
{ value: Infinity, label: "全階層" },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export function LinkGraph({ currentPath, folders, onNavigate, onPreviewShow, onPreviewHide }: Props) {
|
|
22
43
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
23
44
|
const cyRef = useRef<cytoscape.Core | null>(null);
|
|
45
|
+
const filterPopoverRef = useRef<HTMLDivElement>(null);
|
|
24
46
|
const [loading, setLoading] = useState(true);
|
|
25
47
|
const [empty, setEmpty] = useState(false);
|
|
26
48
|
const [ready, setReady] = useState(false);
|
|
49
|
+
const [depth, setDepth] = useState<number>(1);
|
|
50
|
+
const [excluded, setExcluded] = useState<string[]>([]);
|
|
51
|
+
const [showFilter, setShowFilter] = useState(false);
|
|
52
|
+
const refreshTick = useRefreshTick();
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const saved = localStorage.getItem(DEPTH_KEY);
|
|
56
|
+
if (saved === null) return;
|
|
57
|
+
const v = saved === "all" ? Infinity : Number(saved);
|
|
58
|
+
if (Number.isFinite(v) || v === Infinity) setDepth(v);
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const saved = localStorage.getItem(EXCLUDE_KEY);
|
|
63
|
+
if (!saved) return;
|
|
64
|
+
try {
|
|
65
|
+
const arr = JSON.parse(saved);
|
|
66
|
+
if (Array.isArray(arr)) setExcluded(arr.filter((s) => typeof s === "string"));
|
|
67
|
+
} catch {
|
|
68
|
+
/* ignore */
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!showFilter) return;
|
|
74
|
+
const onClick = (e: MouseEvent) => {
|
|
75
|
+
if (filterPopoverRef.current && !filterPopoverRef.current.contains(e.target as Node)) {
|
|
76
|
+
setShowFilter(false);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
document.addEventListener("mousedown", onClick);
|
|
80
|
+
return () => document.removeEventListener("mousedown", onClick);
|
|
81
|
+
}, [showFilter]);
|
|
82
|
+
|
|
83
|
+
const changeDepth = (d: number) => {
|
|
84
|
+
setDepth(d);
|
|
85
|
+
localStorage.setItem(DEPTH_KEY, d === Infinity ? "all" : String(d));
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const toggleExclude = (folderPath: string) => {
|
|
89
|
+
setExcluded((prev) => {
|
|
90
|
+
const next = prev.includes(folderPath)
|
|
91
|
+
? prev.filter((p) => p !== folderPath)
|
|
92
|
+
: [...prev, folderPath];
|
|
93
|
+
localStorage.setItem(EXCLUDE_KEY, JSON.stringify(next));
|
|
94
|
+
return next;
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const isPathExcluded = useMemo(() => {
|
|
99
|
+
const prefixes = excluded.map((f) => f + "/");
|
|
100
|
+
const currentExcluded = excluded.some(
|
|
101
|
+
(f) => currentPath === f || currentPath.startsWith(f + "/"),
|
|
102
|
+
);
|
|
103
|
+
return (p: string): boolean => {
|
|
104
|
+
if (currentExcluded) return false;
|
|
105
|
+
if (p === currentPath) return false;
|
|
106
|
+
return prefixes.some((pre) => p.startsWith(pre));
|
|
107
|
+
};
|
|
108
|
+
}, [excluded, currentPath]);
|
|
109
|
+
|
|
110
|
+
// Latest-callback refs to keep Cytoscape handlers without re-initializing on parent re-renders
|
|
111
|
+
const onNavigateRef = useRef(onNavigate);
|
|
112
|
+
const onPreviewShowRef = useRef(onPreviewShow);
|
|
113
|
+
const onPreviewHideRef = useRef(onPreviewHide);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
onNavigateRef.current = onNavigate;
|
|
116
|
+
onPreviewShowRef.current = onPreviewShow;
|
|
117
|
+
onPreviewHideRef.current = onPreviewHide;
|
|
118
|
+
});
|
|
27
119
|
|
|
28
120
|
useEffect(() => {
|
|
29
121
|
let cancelled = false;
|
|
@@ -37,19 +129,41 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
37
129
|
.then((data: { nodes: GraphNode[]; edges: GraphEdge[] }) => {
|
|
38
130
|
if (cancelled || !containerRef.current) return;
|
|
39
131
|
|
|
40
|
-
//
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
132
|
+
// Apply folder exclusion filter
|
|
133
|
+
const filteredNodes = data.nodes.filter((n) => !isPathExcluded(n.id));
|
|
134
|
+
const filteredEdges = data.edges.filter(
|
|
135
|
+
(e) => !isPathExcluded(e.source) && !isPathExcluded(e.target),
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// Show only nodes reachable from currentPath (undirected connected component)
|
|
139
|
+
const adj = new Map<string, string[]>();
|
|
140
|
+
for (const e of filteredEdges) {
|
|
141
|
+
(adj.get(e.source) ?? adj.set(e.source, []).get(e.source)!).push(e.target);
|
|
142
|
+
(adj.get(e.target) ?? adj.set(e.target, []).get(e.target)!).push(e.source);
|
|
143
|
+
}
|
|
144
|
+
const connectedPaths = new Set<string>([currentPath]);
|
|
145
|
+
const queue: [string, number][] = [[currentPath, 0]];
|
|
146
|
+
while (queue.length > 0) {
|
|
147
|
+
const [cur, lvl] = queue.shift()!;
|
|
148
|
+
if (lvl >= depth) continue;
|
|
149
|
+
for (const nb of adj.get(cur) ?? []) {
|
|
150
|
+
if (!connectedPaths.has(nb)) {
|
|
151
|
+
connectedPaths.add(nb);
|
|
152
|
+
queue.push([nb, lvl + 1]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
46
155
|
}
|
|
47
156
|
|
|
48
|
-
const localNodes =
|
|
49
|
-
const localEdges =
|
|
157
|
+
const localNodes = filteredNodes.filter((n) => connectedPaths.has(n.id));
|
|
158
|
+
const localEdges = filteredEdges.filter(
|
|
50
159
|
(e) => connectedPaths.has(e.source) && connectedPaths.has(e.target),
|
|
51
160
|
);
|
|
52
161
|
|
|
162
|
+
// roots = nodes with no incoming edge within the component
|
|
163
|
+
const hasIncoming = new Set<string>();
|
|
164
|
+
for (const e of localEdges) hasIncoming.add(e.target);
|
|
165
|
+
const rootPaths = localNodes.map((n) => n.id).filter((id) => !hasIncoming.has(id));
|
|
166
|
+
|
|
53
167
|
if (localNodes.length === 0) {
|
|
54
168
|
setEmpty(true);
|
|
55
169
|
setLoading(false);
|
|
@@ -93,7 +207,7 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
93
207
|
"border-color": "#3b7ddb",
|
|
94
208
|
width: 28,
|
|
95
209
|
height: 28,
|
|
96
|
-
"text-max-width": "
|
|
210
|
+
"text-max-width": "180px",
|
|
97
211
|
"text-wrap": "ellipsis",
|
|
98
212
|
"cursor": "pointer",
|
|
99
213
|
} as cytoscape.Css.Node,
|
|
@@ -128,14 +242,15 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
128
242
|
},
|
|
129
243
|
],
|
|
130
244
|
layout: {
|
|
131
|
-
name: "
|
|
245
|
+
name: "breadthfirst",
|
|
132
246
|
animate: false,
|
|
133
247
|
padding: 50,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
248
|
+
spacingFactor: 1.2,
|
|
249
|
+
directed: true,
|
|
250
|
+
grid: false,
|
|
251
|
+
roots: rootPaths.length > 0 ? rootPaths : [currentPath],
|
|
252
|
+
transform: (_node, pos) => ({ x: pos.x, y: -pos.y }),
|
|
253
|
+
} as cytoscape.BreadthFirstLayoutOptions,
|
|
139
254
|
userZoomingEnabled: true,
|
|
140
255
|
userPanningEnabled: true,
|
|
141
256
|
boxSelectionEnabled: false,
|
|
@@ -145,12 +260,40 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
145
260
|
// Defer fit/center until container has layout dimensions
|
|
146
261
|
requestAnimationFrame(() => {
|
|
147
262
|
cy.resize();
|
|
148
|
-
|
|
149
|
-
if (
|
|
263
|
+
const savedZoom = Number(localStorage.getItem(ZOOM_KEY));
|
|
264
|
+
if (Number.isFinite(savedZoom) && savedZoom > 0) {
|
|
265
|
+
cy.zoom({
|
|
266
|
+
level: savedZoom,
|
|
267
|
+
renderedPosition: {
|
|
268
|
+
x: containerRef.current!.clientWidth / 2,
|
|
269
|
+
y: containerRef.current!.clientHeight / 2,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
} else {
|
|
273
|
+
cy.fit(undefined, 50);
|
|
274
|
+
if (cy.zoom() > 0.9) {
|
|
275
|
+
cy.zoom({
|
|
276
|
+
level: 0.9,
|
|
277
|
+
renderedPosition: {
|
|
278
|
+
x: containerRef.current!.clientWidth / 2,
|
|
279
|
+
y: containerRef.current!.clientHeight / 2,
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
150
284
|
cy.center(cy.nodes("[?isCurrent]"));
|
|
151
285
|
setReady(true);
|
|
152
286
|
});
|
|
153
287
|
|
|
288
|
+
// Persist zoom level on user interaction (debounced)
|
|
289
|
+
let zoomWriteTimer: ReturnType<typeof setTimeout> | null = null;
|
|
290
|
+
cy.on("zoom", () => {
|
|
291
|
+
if (zoomWriteTimer) clearTimeout(zoomWriteTimer);
|
|
292
|
+
zoomWriteTimer = setTimeout(() => {
|
|
293
|
+
localStorage.setItem(ZOOM_KEY, String(cy.zoom()));
|
|
294
|
+
}, 200);
|
|
295
|
+
});
|
|
296
|
+
|
|
154
297
|
// Hover effects
|
|
155
298
|
cy.on("mouseover", "node", (e) => {
|
|
156
299
|
const node = e.target;
|
|
@@ -162,6 +305,26 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
162
305
|
});
|
|
163
306
|
}
|
|
164
307
|
containerRef.current!.style.cursor = "pointer";
|
|
308
|
+
|
|
309
|
+
const path = node.id();
|
|
310
|
+
if (onPreviewShowRef.current && containerRef.current) {
|
|
311
|
+
const bb = node.renderedBoundingBox();
|
|
312
|
+
const cRect = containerRef.current.getBoundingClientRect();
|
|
313
|
+
const left = cRect.left + bb.x1;
|
|
314
|
+
const top = cRect.top + bb.y1;
|
|
315
|
+
const rect = {
|
|
316
|
+
left,
|
|
317
|
+
top,
|
|
318
|
+
right: cRect.left + bb.x2,
|
|
319
|
+
bottom: cRect.top + bb.y2,
|
|
320
|
+
width: bb.w,
|
|
321
|
+
height: bb.h,
|
|
322
|
+
x: left,
|
|
323
|
+
y: top,
|
|
324
|
+
toJSON: () => ({}),
|
|
325
|
+
} as DOMRect;
|
|
326
|
+
onPreviewShowRef.current(path, rect);
|
|
327
|
+
}
|
|
165
328
|
});
|
|
166
329
|
|
|
167
330
|
cy.on("mouseout", "node", (e) => {
|
|
@@ -174,13 +337,14 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
174
337
|
});
|
|
175
338
|
}
|
|
176
339
|
containerRef.current!.style.cursor = "default";
|
|
340
|
+
onPreviewHideRef.current?.();
|
|
177
341
|
});
|
|
178
342
|
|
|
179
343
|
// Click to navigate
|
|
180
344
|
cy.on("tap", "node", (e) => {
|
|
181
345
|
const path = e.target.id();
|
|
182
346
|
if (path !== currentPath) {
|
|
183
|
-
|
|
347
|
+
onNavigateRef.current(path);
|
|
184
348
|
}
|
|
185
349
|
});
|
|
186
350
|
|
|
@@ -199,10 +363,72 @@ export function LinkGraph({ currentPath, onNavigate }: Props) {
|
|
|
199
363
|
cyRef.current?.destroy();
|
|
200
364
|
cyRef.current = null;
|
|
201
365
|
};
|
|
202
|
-
}, [currentPath,
|
|
366
|
+
}, [currentPath, depth, isPathExcluded, refreshTick]);
|
|
203
367
|
|
|
204
368
|
return (
|
|
205
369
|
<div className="h-full flex flex-col relative">
|
|
370
|
+
<div className="flex items-center gap-1.5 px-3 py-2 shrink-0">
|
|
371
|
+
<span className="text-[11px] text-[var(--text-muted)] mr-1">表示範囲</span>
|
|
372
|
+
{DEPTH_OPTIONS.map((opt) => {
|
|
373
|
+
const active = depth === opt.value;
|
|
374
|
+
return (
|
|
375
|
+
<button
|
|
376
|
+
key={opt.label}
|
|
377
|
+
onClick={() => changeDepth(opt.value)}
|
|
378
|
+
className={`px-2 py-0.5 rounded-md text-[11px] font-medium transition-colors ${
|
|
379
|
+
active
|
|
380
|
+
? "bg-[var(--brand-primary)] text-white"
|
|
381
|
+
: "text-[var(--text-muted)] hover:bg-[var(--bg-muted)] hover:text-[var(--text-secondary)]"
|
|
382
|
+
}`}
|
|
383
|
+
>
|
|
384
|
+
{opt.label}
|
|
385
|
+
</button>
|
|
386
|
+
);
|
|
387
|
+
})}
|
|
388
|
+
<div className="ml-auto relative" ref={filterPopoverRef}>
|
|
389
|
+
<button
|
|
390
|
+
onClick={() => setShowFilter((v) => !v)}
|
|
391
|
+
className={`flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium transition-colors ${
|
|
392
|
+
excluded.length > 0
|
|
393
|
+
? "bg-[var(--brand-primary)] text-white"
|
|
394
|
+
: "text-[var(--text-muted)] hover:bg-[var(--bg-muted)] hover:text-[var(--text-secondary)]"
|
|
395
|
+
}`}
|
|
396
|
+
title="フォルダを除外"
|
|
397
|
+
>
|
|
398
|
+
<Filter size={11} />
|
|
399
|
+
除外
|
|
400
|
+
{excluded.length > 0 && <span className="ml-0.5">({excluded.length})</span>}
|
|
401
|
+
</button>
|
|
402
|
+
{showFilter && (
|
|
403
|
+
<div className="absolute right-0 top-full mt-1 w-56 max-h-72 overflow-y-auto bg-[var(--bg-surface)] border border-[var(--border-default)] rounded-md shadow-lg z-20 py-1">
|
|
404
|
+
{folders.length === 0 ? (
|
|
405
|
+
<div className="px-3 py-2 text-[11px] text-[var(--text-muted)]">
|
|
406
|
+
フォルダがありません
|
|
407
|
+
</div>
|
|
408
|
+
) : (
|
|
409
|
+
folders.map((f) => {
|
|
410
|
+
const checked = excluded.includes(f.path);
|
|
411
|
+
return (
|
|
412
|
+
<label
|
|
413
|
+
key={f.path}
|
|
414
|
+
className="flex items-center gap-2 px-3 py-1 text-[12px] cursor-pointer hover:bg-[var(--bg-muted)]"
|
|
415
|
+
style={{ paddingLeft: `${12 + f.depth * 12}px` }}
|
|
416
|
+
>
|
|
417
|
+
<input
|
|
418
|
+
type="checkbox"
|
|
419
|
+
checked={checked}
|
|
420
|
+
onChange={() => toggleExclude(f.path)}
|
|
421
|
+
className="shrink-0"
|
|
422
|
+
/>
|
|
423
|
+
<span className="truncate text-[var(--text-secondary)]">{f.displayName}</span>
|
|
424
|
+
</label>
|
|
425
|
+
);
|
|
426
|
+
})
|
|
427
|
+
)}
|
|
428
|
+
</div>
|
|
429
|
+
)}
|
|
430
|
+
</div>
|
|
431
|
+
</div>
|
|
206
432
|
{(loading || empty) && (
|
|
207
433
|
<div className="absolute inset-0 flex items-center justify-center text-[13px] text-[var(--text-muted)] z-10 bg-[var(--bg-surface)]">
|
|
208
434
|
{loading ? "グラフを構築中..." : "このドキュメントへのリンクはありません"}
|
|
@@ -100,6 +100,53 @@ export function Markdown({
|
|
|
100
100
|
return new RegExp(`(${escaped.join("|")})`, "g");
|
|
101
101
|
}, [autolinkMap]);
|
|
102
102
|
|
|
103
|
+
const fileSet = useMemo(
|
|
104
|
+
() => new Set((fileRefs ?? []).map((f) => f.path)),
|
|
105
|
+
[fileRefs],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
function resolveRelativeLink(href: string): string | null {
|
|
109
|
+
const cleanUrl = href.split("#")[0].split("?")[0].trim();
|
|
110
|
+
if (!cleanUrl) return null;
|
|
111
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(cleanUrl)) return null;
|
|
112
|
+
if (cleanUrl.startsWith("//")) return null;
|
|
113
|
+
|
|
114
|
+
let decoded: string;
|
|
115
|
+
try {
|
|
116
|
+
decoded = decodeURI(cleanUrl);
|
|
117
|
+
} catch {
|
|
118
|
+
decoded = cleanUrl;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const currentDir =
|
|
122
|
+
currentPath && currentPath.includes("/")
|
|
123
|
+
? currentPath.slice(0, currentPath.lastIndexOf("/"))
|
|
124
|
+
: "";
|
|
125
|
+
const joined = decoded.startsWith("/")
|
|
126
|
+
? decoded.slice(1)
|
|
127
|
+
: currentDir
|
|
128
|
+
? currentDir + "/" + decoded
|
|
129
|
+
: decoded;
|
|
130
|
+
|
|
131
|
+
const parts = joined.split("/");
|
|
132
|
+
const normalized: string[] = [];
|
|
133
|
+
for (const p of parts) {
|
|
134
|
+
if (p === "" || p === ".") continue;
|
|
135
|
+
if (p === "..") {
|
|
136
|
+
normalized.pop();
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
normalized.push(p);
|
|
140
|
+
}
|
|
141
|
+
const resolved = normalized.join("/");
|
|
142
|
+
if (!resolved) return null;
|
|
143
|
+
|
|
144
|
+
if (fileSet.has(resolved)) return resolved;
|
|
145
|
+
if (fileSet.has(resolved + "/README.md")) return resolved + "/README.md";
|
|
146
|
+
if (!/\.md$/i.test(resolved) && fileSet.has(resolved + ".md")) return resolved + ".md";
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
103
150
|
function getIdForHeading(text: string): string {
|
|
104
151
|
const ids = headingIdMap.get(text);
|
|
105
152
|
if (!ids) return slugify(text) || "heading";
|
|
@@ -153,21 +200,29 @@ export function Markdown({
|
|
|
153
200
|
}
|
|
154
201
|
return <pre>{children}</pre>;
|
|
155
202
|
},
|
|
156
|
-
// Auto-link rendering: intercept <a> with "autolink:" prefix
|
|
203
|
+
// Auto-link rendering: intercept <a> with "autolink:" prefix,
|
|
204
|
+
// and resolve relative markdown links to docs paths so they behave like autolinks.
|
|
157
205
|
a: ({ href, children: linkChildren, ...rest }) => {
|
|
206
|
+
let targetPath: string | null = null;
|
|
158
207
|
if (href?.startsWith("autolink:")) {
|
|
159
|
-
|
|
208
|
+
targetPath = href.slice("autolink:".length);
|
|
209
|
+
} else if (href) {
|
|
210
|
+
targetPath = resolveRelativeLink(href);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (targetPath) {
|
|
214
|
+
const resolved = targetPath;
|
|
160
215
|
return (
|
|
161
216
|
<span
|
|
162
|
-
className="text-[var(--brand-primary)]
|
|
217
|
+
className="text-[var(--brand-primary)] font-medium cursor-pointer hover:underline transition-colors"
|
|
163
218
|
onClick={(e) => {
|
|
164
219
|
e.preventDefault();
|
|
165
220
|
onPreviewHide?.();
|
|
166
|
-
onNavigate?.(
|
|
221
|
+
onNavigate?.(resolved);
|
|
167
222
|
}}
|
|
168
223
|
onMouseEnter={(e) => {
|
|
169
224
|
const rect = (e.target as HTMLElement).getBoundingClientRect();
|
|
170
|
-
onPreviewShow?.(
|
|
225
|
+
onPreviewShow?.(resolved, rect);
|
|
171
226
|
}}
|
|
172
227
|
onMouseLeave={() => onPreviewHide?.()}
|
|
173
228
|
>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState, useRef, useCallback } from "react";
|
|
4
4
|
import { Markdown, FileRef } from "./Markdown";
|
|
5
|
+
import { useRefreshTick } from "@/lib/useRefreshTick";
|
|
5
6
|
import { ExternalLink } from "lucide-react";
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
@@ -27,6 +28,7 @@ export function PreviewPopup({ path, position, onNavigate, onMouseEnter, onMouse
|
|
|
27
28
|
const [nestedPos, setNestedPos] = useState<{ x: number; y: number } | null>(null);
|
|
28
29
|
const nestedShowTimer = useRef<ReturnType<typeof setTimeout>>(null);
|
|
29
30
|
const nestedHideTimer = useRef<ReturnType<typeof setTimeout>>(null);
|
|
31
|
+
const refreshTick = useRefreshTick();
|
|
30
32
|
|
|
31
33
|
useEffect(() => {
|
|
32
34
|
// Cancel any pending nested popup timers whenever path changes
|
|
@@ -48,7 +50,7 @@ export function PreviewPopup({ path, position, onNavigate, onMouseEnter, onMouse
|
|
|
48
50
|
.then((data) => setContent(data.content ?? null))
|
|
49
51
|
.catch(() => setContent(null))
|
|
50
52
|
.finally(() => setLoading(false));
|
|
51
|
-
}, [path]);
|
|
53
|
+
}, [path, refreshTick]);
|
|
52
54
|
|
|
53
55
|
// Adjust position to stay within viewport
|
|
54
56
|
useEffect(() => {
|
|
@@ -113,7 +115,7 @@ export function PreviewPopup({ path, position, onNavigate, onMouseEnter, onMouse
|
|
|
113
115
|
// Also hide nested if mouse leaves this popup entirely
|
|
114
116
|
handleNestedHide();
|
|
115
117
|
}}
|
|
116
|
-
className="fixed bg-[var(--bg-surface)] border border-[var(--border-default)] rounded-lg shadow-xl w-[480px] max-h-[420px] overflow-y-auto"
|
|
118
|
+
className="fixed bg-[var(--bg-surface)] border border-[var(--border-default)] rounded-lg shadow-xl w-[min(480px,30vw)] max-h-[min(420px,30vh)] overflow-y-auto"
|
|
117
119
|
style={{
|
|
118
120
|
left: adjustedPos?.x ?? position.x,
|
|
119
121
|
top: adjustedPos?.y ?? position.y,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { GitCommit, FileText, ChevronDown, ChevronRight, X, Clock } from "lucide-react";
|
|
5
5
|
import { DiffView } from "./DiffView";
|
|
6
|
+
import { useRefreshTick } from "@/lib/useRefreshTick";
|
|
6
7
|
|
|
7
8
|
interface TimelineEntry {
|
|
8
9
|
hash: string;
|
|
@@ -44,6 +45,7 @@ export function TimelinePanel({ onNavigate, onClose }: Props) {
|
|
|
44
45
|
const [loading, setLoading] = useState(true);
|
|
45
46
|
const [expandedHash, setExpandedHash] = useState<string | null>(null);
|
|
46
47
|
const [expandedFile, setExpandedFile] = useState<{ hash: string; file: string } | null>(null);
|
|
48
|
+
const refreshTick = useRefreshTick();
|
|
47
49
|
|
|
48
50
|
useEffect(() => {
|
|
49
51
|
setLoading(true);
|
|
@@ -54,7 +56,7 @@ export function TimelinePanel({ onNavigate, onClose }: Props) {
|
|
|
54
56
|
setLoading(false);
|
|
55
57
|
})
|
|
56
58
|
.catch(() => setLoading(false));
|
|
57
|
-
}, []);
|
|
59
|
+
}, [refreshTick]);
|
|
58
60
|
|
|
59
61
|
useEffect(() => {
|
|
60
62
|
const handleKeyDown = (e: KeyboardEvent) => {
|