feat(canvas): 框选 - 新增工具栏「框选」工具,空白处拖动框选后自动回到移动与选择 (#78)

Co-authored-by: sikongyue <3155157671@qq.com>
This commit is contained in:
爱笑的毛毛虫andsikongyue authored and GitHub committed 2026-08-02 14:40:20 +08:00
1 parent 9cbf95dcde
commit f1847f40a1
6 files changed
+24 -7

No files matched your search

@@ -20,6 +20,7 @@ type UseCanvasSelectionControllerOptions = {
onNodeInteractionStart: (selectionModifier: boolean) => void;
onNodeClick: (node: CanvasNodeData) => void;
onDeselect: () => void;
onSelectionBoxEnd?: () => void;
};
type DragState = {
@@ -57,6 +58,7 @@ export function useCanvasSelectionController({
onNodeInteractionStart,
onNodeClick,
onDeselect,
onSelectionBoxEnd,
}: UseCanvasSelectionControllerOptions) {
const dragFrameRef = useRef<number | null>(null);
const pendingNodeDragRef = useRef<Position>({ x: 0, y: 0 });
@@ -296,7 +298,8 @@ export function useCanvasSelectionController({
const wasSelection = selectionActivatedRef.current;
cancelSelectionBox();
if (hadPendingSelection && !wasSelection) deselectCanvas();
}, [cancelSelectionBox, deselectCanvas]);
if (hadPendingSelection) onSelectionBoxEnd?.();
}, [cancelSelectionBox, deselectCanvas, onSelectionBoxEnd]);
useEffect(() => {
const handleMouseUp = (event: MouseEvent) => {