0.1.07 文件树拖拽与多思维导图

This commit is contained in:
liaibo
2026-01-08 06:28:14 +08:00
parent 9de2d69c55
commit 9af8b9e489
30 changed files with 817 additions and 410 deletions
@@ -46,14 +46,21 @@ export function FileTree({
<div
className="space-y-0.5"
onDragOver={(event) => {
if (onDropFiles) event.preventDefault();
if (!onDropFiles) return;
event.preventDefault();
if (event.dataTransfer.files?.length) {
event.dataTransfer.dropEffect = "copy";
}
}}
onDrop={(event) => {
if (onDropFiles && event.dataTransfer.files?.length) {
event.preventDefault();
const files = event.dataTransfer.files;
const activeDocRow = rows.find(
(row) => row.kind === "doc" && row.docId === activeId,
);
const firstDocRow = rows.find((row) => row.kind === "doc");
const targetDocId = firstDocRow?.docId ?? "";
const targetDocId = activeDocRow?.docId ?? firstDocRow?.docId ?? "";
onDropFiles(targetDocId, files);
}
}}
@@ -119,7 +126,11 @@ export function FileTree({
event.dataTransfer.dropEffect = event.altKey ? "copy" : "move";
return;
}
if (onDropFiles) event.preventDefault();
if (!onDropFiles) return;
event.preventDefault();
if (event.dataTransfer.files?.length) {
event.dataTransfer.dropEffect = "copy";
}
}}
onDrop={(event) => {
const types = Array.from(event.dataTransfer.types ?? []);