fix(svelte): repair selection, add multi selection closes #3557

This commit is contained in:
moklick
2023-10-31 18:31:24 +01:00
parent ce1680ba71
commit d2b140ce5e
12 changed files with 204 additions and 117 deletions

View File

@@ -46,7 +46,7 @@ type StoreItems = {
selectNodesOnDrag: boolean;
nodeDragThreshold: number;
panBy: PanBy;
unselectNodesAndEdges: () => void;
unselectNodesAndEdges: (params?: { nodes?: NodeBase[]; edges?: EdgeBase[] }) => void;
onError?: OnError;
onNodeDragStart?: OnNodeDrag;
onNodeDrag?: OnNodeDrag;
@@ -63,7 +63,7 @@ export type XYDragParams = {
onDragStart?: OnDrag;
onDrag?: OnDrag;
onDragStop?: OnDrag;
onNodeClick?: () => void;
onNodeMouseDown?: (id: string) => void;
};
export type XYDragInstance = {
@@ -81,7 +81,7 @@ export type DragUpdateParams = {
export function XYDrag({
domNode,
onNodeClick,
onNodeMouseDown,
getStoreItems,
onDragStart,
onDrag,
@@ -217,8 +217,8 @@ export function XYDrag({
}
}
if (isSelectable && selectNodesOnDrag) {
onNodeClick?.();
if (isSelectable && selectNodesOnDrag && nodeId) {
onNodeMouseDown?.(nodeId);
}
const pointerPos = getPointerPosition(event.sourceEvent, { transform, snapGrid, snapToGrid });