feat: 收口 tree-first graph 主链与前端测试修复

This commit is contained in:
lix-2026
2026-04-18 05:43:49 +08:00
parent d8de820d93
commit d3876e56eb
33 changed files with 2421 additions and 345 deletions
@@ -21,7 +21,12 @@ import { Button } from "@/components/ui/button";
import { DocumentToc } from "@/components/editor/document-toc";
import { DocumentReadView } from "@/components/editor/document-read-view";
import { buildPageSubtreeProjection, extractPageBlocks, type PageSubtreeProjection } from "@/lib/documents/page-subtree";
import { moveDocumentCommand, renameDocumentCommand } from "@/lib/documents/tree-command-client";
import {
deleteDocumentCommand,
embedDocumentCommand,
moveDocumentCommand,
renameDocumentCommand,
} from "@/lib/documents/tree-command-client";
const BlockNoteEditor = dynamic(
() => import("@/components/editor/blocknote-editor").then((mod) => mod.BlockNoteEditor),
@@ -602,19 +607,16 @@ export function DocumentContent({
if (readOnly) return;
const ok = window.confirm("确定删除该页面吗?删除后会进入垃圾桶。");
if (!ok) return;
const resp = await fetch("/api/documents/delete", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ documentId }),
});
if (!resp.ok) {
const payload = await resp.json().catch(() => ({}));
window.alert(payload?.error ?? "删除失败");
try {
await deleteDocumentCommand({ documentId, workspaceId });
} catch (error) {
const payload = error instanceof Error ? error.message : null;
window.alert(payload ?? "删除失败");
return;
}
router.push("/");
router.refresh();
}, [documentId, readOnly, router]);
}, [documentId, readOnly, router, workspaceId]);
const handleOpenMoveEmbed = useCallback(() => {
if (readOnly) return;
@@ -642,16 +644,22 @@ export function DocumentContent({
return;
}
const resp = await fetch("/api/documents/embed", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ sourceId: documentId, targetId }),
});
if (!resp.ok) {
const payload = await resp.json().catch(() => ({}));
window.alert(payload?.error ?? "嵌入失败");
if (!targetId) {
window.alert("请选择目标页面");
return;
}
try {
await embedDocumentCommand({
sourceId: documentId,
targetId,
});
} catch (error) {
const message = error instanceof Error ? error.message : "嵌入失败";
window.alert(message);
return;
}
window.alert("已嵌入到目标页面");
},
});