0.1.06文件树的选择问题及思维导图删除问题

This commit is contained in:
liaibo
2026-01-07 22:06:49 +08:00
parent afad811d85
commit 9de2d69c55
4 changed files with 109 additions and 8 deletions
@@ -5,6 +5,7 @@ import { cn } from "@/lib/utils";
import type { FileTreeRow } from "@/lib/file-tree/types";
import { getFileTreeRowLabel } from "@/lib/file-tree/types";
import { isRealFileAsset } from "@/lib/file-tree/asset";
import { isTextInputTarget } from "@/lib/file-tree/clipboard";
interface FileTreeProps {
rows: FileTreeRow[];
@@ -69,7 +70,7 @@ export function FileTree({
const draggable =
row.kind === "doc" || (row.kind === "asset" && isRealFileAsset(row.asset));
const baseClass =
"flex items-center gap-2 rounded-md px-2 py-1.5 text-sm text-gray-700 hover:bg-[#f5f7fb]";
"flex select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm text-gray-700 hover:bg-[#f5f7fb]";
const activeClass =
row.kind === "index"
? "text-[#2563eb] font-medium"
@@ -85,9 +86,16 @@ export function FileTree({
className={cn(baseClass, active && activeClass, selected && "bg-[#e8f2ff] text-[#2563eb]")}
style={{ paddingLeft }}
onClick={(event) => onRowClick(row, event)}
onDoubleClick={(event) => onRowDoubleClick(row, event)}
onContextMenu={(event) => onRowContextMenu(row, event)}
draggable={draggable}
onDoubleClick={(event) => onRowDoubleClick(row, event)}
onContextMenu={(event) => onRowContextMenu(row, event)}
onMouseDown={(event) => {
// 避免 Shift 多选时触发浏览器默认的文本范围选择(VS Code 资源管理器不会出现该行为)
if (event.button !== 0) return;
if (!event.shiftKey) return;
if (isTextInputTarget(event.target)) return;
event.preventDefault();
}}
draggable={draggable}
onDragStart={(event) => {
if (!draggable) return;
if (!selectedRowIds.has(row.rowId)) {