feat(nodes): add store id as class to handles
* for better identification, add a class to handle according to the current store id Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useHandle } from '../../composables'
|
import { useHandle, useStore } from '../../composables'
|
||||||
import { Position, ValidConnectionFunc } from '../../types'
|
import { Position, ValidConnectionFunc } from '../../types'
|
||||||
import { NodeId } from '../../context'
|
import { NodeId } from '../../context'
|
||||||
|
|
||||||
@@ -11,6 +11,7 @@ interface HandleProps {
|
|||||||
connectable?: boolean
|
connectable?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const store = useStore()
|
||||||
const props = withDefaults(defineProps<HandleProps>(), {
|
const props = withDefaults(defineProps<HandleProps>(), {
|
||||||
id: '',
|
id: '',
|
||||||
type: 'source',
|
type: 'source',
|
||||||
@@ -37,6 +38,7 @@ export default {
|
|||||||
:class="[
|
:class="[
|
||||||
'vue-flow__handle',
|
'vue-flow__handle',
|
||||||
`vue-flow__handle-${props.position}`,
|
`vue-flow__handle-${props.position}`,
|
||||||
|
`vue-flow__handle-${store.id}`,
|
||||||
'nodrag',
|
'nodrag',
|
||||||
{
|
{
|
||||||
source: props.type !== 'target',
|
source: props.type !== 'target',
|
||||||
|
|||||||
+4
-6
@@ -9,9 +9,7 @@ export const getHandleBoundsByHandleType = (
|
|||||||
): HandleElement[] | null => {
|
): HandleElement[] | null => {
|
||||||
const handles = nodeElement.querySelectorAll(selector)
|
const handles = nodeElement.querySelectorAll(selector)
|
||||||
|
|
||||||
if (!handles || !handles.length) {
|
if (!handles || !handles.length) return null
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const handlesArray = Array.from(handles) as HTMLDivElement[]
|
const handlesArray = Array.from(handles) as HTMLDivElement[]
|
||||||
|
|
||||||
@@ -31,11 +29,11 @@ export const getHandleBoundsByHandleType = (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getHandleBounds = (nodeElement: HTMLDivElement, scale: number) => {
|
export const getHandleBounds = (nodeElement: HTMLDivElement, scale: number, id?: string) => {
|
||||||
const bounds = nodeElement.getBoundingClientRect()
|
const bounds = nodeElement.getBoundingClientRect()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
source: getHandleBoundsByHandleType('.source', nodeElement, bounds, scale) ?? undefined,
|
source: getHandleBoundsByHandleType(`.source${id ? `.vue-flow__handle-${id}` : ''}`, nodeElement, bounds, scale) ?? undefined,
|
||||||
target: getHandleBoundsByHandleType('.target', nodeElement, bounds, scale) ?? undefined,
|
target: getHandleBoundsByHandleType(`.target${id ? `.vue-flow__handle-${id}` : ''}`, nodeElement, bounds, scale) ?? undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user