diff --git a/.github/actions/install-dependencies/action.yaml b/.github/actions/install-dependencies/action.yaml index e9f40ead0..6dfa7265c 100644 --- a/.github/actions/install-dependencies/action.yaml +++ b/.github/actions/install-dependencies/action.yaml @@ -26,7 +26,7 @@ runs: uses: actions/cache@v4 with: path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a0f38efe2..bca8a51b4 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -54,5 +54,3 @@ jobs: with: install-command: pnpm cypress install command: pnpm run test --cache-dir=.turbo - browser: chrome - component: true diff --git a/examples/vite/src/EasyConnect/EasyConnect.vue b/examples/vite/src/EasyConnect/EasyConnect.vue index ce63463a6..406af19a6 100644 --- a/examples/vite/src/EasyConnect/EasyConnect.vue +++ b/examples/vite/src/EasyConnect/EasyConnect.vue @@ -1,12 +1,10 @@ diff --git a/examples/vite/src/EasyConnect/CustomConnectionLine.vue b/examples/vite/src/EasyConnect/FloatingConnectionLine.vue similarity index 61% rename from examples/vite/src/EasyConnect/CustomConnectionLine.vue rename to examples/vite/src/EasyConnect/FloatingConnectionLine.vue index d7b439f76..4ccff687e 100644 --- a/examples/vite/src/EasyConnect/CustomConnectionLine.vue +++ b/examples/vite/src/EasyConnect/FloatingConnectionLine.vue @@ -1,9 +1,9 @@ diff --git a/packages/core/src/components/ConnectionLine/index.ts b/packages/core/src/components/ConnectionLine/index.ts index e9cc78385..ffda18136 100644 --- a/packages/core/src/components/ConnectionLine/index.ts +++ b/packages/core/src/components/ConnectionLine/index.ts @@ -1,18 +1,11 @@ import { computed, defineComponent, h, inject } from 'vue' import type { HandleElement } from '../../types' import { ConnectionLineType, ConnectionMode, Position } from '../../types' -import { getHandlePosition, getMarkerId } from '../../utils' +import { getHandlePosition, getMarkerId, oppositePosition } from '../../utils' import { useVueFlow } from '../../composables' import { Slots } from '../../context' import { getBezierPath, getSimpleBezierPath, getSmoothStepPath } from '../Edges/utils' -const oppositePosition = { - [Position.Left]: Position.Right, - [Position.Right]: Position.Left, - [Position.Top]: Position.Bottom, - [Position.Bottom]: Position.Top, -} - const ConnectionLine = defineComponent({ name: 'ConnectionLine', compatConfig: { MODE: 3 }, @@ -57,7 +50,7 @@ const ConnectionLine = defineComponent({ return null } - const startHandleId = connectionStartHandle.value.handleId + const startHandleId = connectionStartHandle.value.id const handleType = connectionStartHandle.value.type @@ -78,18 +71,18 @@ const ConnectionLine = defineComponent({ const { x: fromX, y: fromY } = getHandlePosition(fromNode.value, fromHandle, fromPosition) let toHandle: HandleElement | null = null - if (toNode.value && connectionEndHandle.value?.handleId) { + if (toNode.value) { // if connection mode is strict, we only look for handles of the opposite type if (connectionMode.value === ConnectionMode.Strict) { toHandle = toNode.value.handleBounds[handleType === 'source' ? 'target' : 'source']?.find( - (d) => d.id === connectionEndHandle.value?.handleId, + (d) => d.id === connectionEndHandle.value?.id, ) || null } else { // if connection mode is loose, look for the handle in both source and target bounds toHandle = [...(toNode.value.handleBounds.source || []), ...(toNode.value.handleBounds.target || [])]?.find( - (d) => d.id === connectionEndHandle.value?.handleId, + (d) => d.id === connectionEndHandle.value?.id, ) || null } } diff --git a/packages/core/src/components/Edges/EdgeWrapper.ts b/packages/core/src/components/Edges/EdgeWrapper.ts index dc2f9b5f4..95bb3960f 100644 --- a/packages/core/src/components/Edges/EdgeWrapper.ts +++ b/packages/core/src/components/Edges/EdgeWrapper.ts @@ -8,7 +8,7 @@ import { ErrorCode, VueFlowError, elementSelectionKeys, - getHandle, + getEdgeHandle, getHandlePosition, getMarkerId, } from '../../utils' @@ -150,7 +150,7 @@ const EdgeWrapper = defineComponent({ sourceNodeHandles = [...(sourceNode.handleBounds.source || []), ...(sourceNode.handleBounds.target || [])] } - const sourceHandle = getHandle(sourceNodeHandles, edge.value.sourceHandle) + const sourceHandle = getEdgeHandle(sourceNodeHandles, edge.value.sourceHandle) let targetNodeHandles if (connectionMode.value === ConnectionMode.Strict) { @@ -159,7 +159,7 @@ const EdgeWrapper = defineComponent({ targetNodeHandles = [...(targetNode.handleBounds.target || []), ...(targetNode.handleBounds.source || [])] } - const targetHandle = getHandle(targetNodeHandles, edge.value.targetHandle) + const targetHandle = getEdgeHandle(targetNodeHandles, edge.value.targetHandle) const sourcePosition = sourceHandle?.position || Position.Bottom diff --git a/packages/core/src/components/Handle/Handle.vue b/packages/core/src/components/Handle/Handle.vue index aa67fac0e..63433b0e6 100644 --- a/packages/core/src/components/Handle/Handle.vue +++ b/packages/core/src/components/Handle/Handle.vue @@ -19,6 +19,7 @@ const type = toRef(() => props.type ?? 'source') const isValidConnection = toRef(() => props.isValidConnection ?? null) const { + id: flowId, connectionStartHandle, connectionClickStartHandle, connectionEndHandle, @@ -39,17 +40,17 @@ const isConnectableEnd = toRef(() => (typeof connectableEnd !== 'undefined' ? co const isConnecting = toRef( () => (connectionStartHandle.value?.nodeId === nodeId && - connectionStartHandle.value?.handleId === handleId && + connectionStartHandle.value?.id === handleId && connectionStartHandle.value?.type === type.value) || (connectionEndHandle.value?.nodeId === nodeId && - connectionEndHandle.value?.handleId === handleId && + connectionEndHandle.value?.id === handleId && connectionEndHandle.value?.type === type.value), ) const isClickConnecting = toRef( () => connectionClickStartHandle.value?.nodeId === nodeId && - connectionClickStartHandle.value?.handleId === handleId && + connectionClickStartHandle.value?.id === handleId && connectionClickStartHandle.value?.type === type.value, ) @@ -127,6 +128,8 @@ onMounted(() => { position, x: (handleBounds.left - nodeBounds.left) / zoom, y: (handleBounds.top - nodeBounds.top) / zoom, + type: type.value, + nodeId, ...getDimensions(handle.value), } @@ -177,7 +180,7 @@ export default {