fix(core): add connection target handle id to result type
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -42,17 +42,21 @@ const sourceHandle = $computed(
|
|||||||
sourceNode.handleBounds[type.value ?? 'source']?.[0],
|
sourceNode.handleBounds[type.value ?? 'source']?.[0],
|
||||||
)
|
)
|
||||||
|
|
||||||
const targetHandle = $computed(
|
const targetHandle = $computed(() => {
|
||||||
() =>
|
return (
|
||||||
(targetNode &&
|
(targetNode &&
|
||||||
|
connectionStartHandle?.result?.handleId &&
|
||||||
((connectionMode === ConnectionMode.Strict
|
((connectionMode === ConnectionMode.Strict
|
||||||
? targetNode.handleBounds[type.value === 'source' ? 'target' : 'source']?.find((d) => d.id === handleId)
|
? targetNode.handleBounds[type.value === 'source' ? 'target' : 'source']?.find(
|
||||||
|
(d) => d.id === connectionStartHandle?.result?.handleId,
|
||||||
|
)
|
||||||
: [...(targetNode.handleBounds.source || []), ...(targetNode.handleBounds.target || [])]?.find(
|
: [...(targetNode.handleBounds.source || []), ...(targetNode.handleBounds.target || [])]?.find(
|
||||||
(d) => d.id === handleId,
|
(d) => d.id === connectionStartHandle?.result?.handleId,
|
||||||
)) ||
|
)) ||
|
||||||
targetNode.handleBounds[type.value ?? 'source']?.[0])) ||
|
targetNode.handleBounds[type.value ?? 'target']?.[0])) ||
|
||||||
null,
|
null
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
|
||||||
const sourceHandleX = $computed(() => (sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : sourceNode.dimensions.width / 2))
|
const sourceHandleX = $computed(() => (sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : sourceNode.dimensions.width / 2))
|
||||||
const sourceHandleY = $computed(() => (sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : sourceNode.dimensions.height))
|
const sourceHandleY = $computed(() => (sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : sourceNode.dimensions.height))
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export interface ConnectionHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ValidHandleResult {
|
export interface ValidHandleResult {
|
||||||
|
handleId: string | null
|
||||||
handleDomNode: Element | null
|
handleDomNode: Element | null
|
||||||
isValid: boolean
|
isValid: boolean
|
||||||
connection: Connection
|
connection: Connection
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ export function isValidHandle(
|
|||||||
const handleToCheck = handleBelow?.classList.contains('vue-flow__handle') ? handleBelow : handleDomNode
|
const handleToCheck = handleBelow?.classList.contains('vue-flow__handle') ? handleBelow : handleDomNode
|
||||||
|
|
||||||
const result: ValidHandleResult = {
|
const result: ValidHandleResult = {
|
||||||
|
handleId: null,
|
||||||
handleDomNode: handleToCheck,
|
handleDomNode: handleToCheck,
|
||||||
isValid: false,
|
isValid: false,
|
||||||
connection: { source: '', target: '', sourceHandle: null, targetHandle: null },
|
connection: { source: '', target: '', sourceHandle: null, targetHandle: null },
|
||||||
@@ -103,6 +104,7 @@ export function isValidHandle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.connection = connection
|
result.connection = connection
|
||||||
|
result.handleId = handleId
|
||||||
|
|
||||||
// in strict mode we don't allow target to target or source to source connections
|
// in strict mode we don't allow target to target or source to source connections
|
||||||
const isValid =
|
const isValid =
|
||||||
|
|||||||
Reference in New Issue
Block a user