Merge branch 'main' into chore/svelte-typed-context

This commit is contained in:
peterkogo
2025-12-03 11:06:23 +01:00
31 changed files with 369 additions and 39 deletions
@@ -61,7 +61,7 @@
panOnScroll = false,
panOnScrollSpeed = 0.5,
panOnDrag = true,
selectionOnDrag = true,
selectionOnDrag = false,
connectionLineComponent,
connectionLineStyle,
connectionLineContainerStyle,
@@ -75,14 +75,11 @@
},
onChange: (change: XYResizerChange, childChanges: XYResizerChildChange[]) => {
// eslint-disable-next-line svelte/prefer-svelte-reactivity
const changes = new Map<string, Partial<Node>>();
let position = change.x && change.y ? { x: change.x, y: change.y } : undefined;
changes.set(id, { ...change, position });
const changes = new Map<string, XYResizerChange>();
changes.set(id, change);
for (const childChange of childChanges) {
changes.set(childChange.id, {
position: childChange.position
});
changes.set(childChange.id, {x: childChange.position.x, y: childChange.position.y });
}
store.nodes = store.nodes.map((node) => {
@@ -91,11 +88,11 @@
const vertical = !resizeDirection || resizeDirection === 'vertical';
if (change) {
return {
return {
...node,
position: {
x: horizontal ? (change.position?.x ?? node.position.x) : node.position.x,
y: vertical ? (change.position?.y ?? node.position.y) : node.position.y
x: horizontal ? (change.x ?? node.position.x) : node.position.x,
y: vertical ? (change.y ?? node.position.y) : node.position.y
},
width: horizontal ? (change.width ?? node.width) : node.width,
height: vertical ? (change.height ?? node.height) : node.height
+12 -1
View File
@@ -15,7 +15,9 @@ import {
updateAbsolutePositions,
snapPosition,
calculateNodePosition,
type SetCenterOptions
type SetCenterOptions,
getHandlePosition,
Position
} from '@xyflow/system';
import type { EdgeTypes, NodeTypes, Node, Edge, FitViewOptions } from '$lib/types';
@@ -51,6 +53,15 @@ export function createStore<NodeType extends Node = Node, EdgeType extends Edge
const updateNodePositions: UpdateNodePositions = (nodeDragItems, dragging = false) => {
store.nodes = store.nodes.map((node) => {
if (store.connection.inProgress && store.connection.fromNode.id === node.id) {
const internalNode = store.nodeLookup.get(node.id);
if (internalNode) {
store.connection = {
...store.connection,
from: getHandlePosition(internalNode, store.connection.fromHandle, Position.Left, true)
};
}
}
const dragItem = nodeDragItems.get(node.id);
return dragItem ? { ...node, position: dragItem.position, dragging } : node;
});