feat(nodes): add nodeRef injection

This commit is contained in:
braks
2022-10-06 18:22:43 +02:00
committed by Braks
parent 70871df469
commit 7d992b5ed7
2 changed files with 5 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
import { useVModel } from '@vueuse/core'
import { useDrag, useNodeHooks, useVueFlow } from '../../composables'
import type { GraphNode, NodeComponent, SnapGrid, XYZPosition } from '../../types'
import { NodeId } from '../../context'
import { NodeId, NodeRef } from '../../context'
import { getConnectedEdges, getXYZPos, handleNodeClick } from '../../utils'
const { id, type, name, draggable, selectable, connectable, snapGrid, ...props } = defineProps<{
@@ -41,6 +41,8 @@ const parentNode = $computed(() => (node.parentNode ? getNode(node.parentNode) :
const nodeElement = ref()
provide(NodeRef, nodeElement)
const { emit, on } = useNodeHooks(node, emits)
const dragging = useDrag({

View File

@@ -1,6 +1,7 @@
import type { InjectionKey, Slots as TSlots } from 'vue'
import type { InjectionKey, Ref, Slots as TSlots } from 'vue'
import type { VueFlowStore } from '~/types'
export const VueFlow: InjectionKey<VueFlowStore> = Symbol('vueFlow')
export const NodeId: InjectionKey<string> = Symbol('nodeId')
export const NodeRef: InjectionKey<Ref<HTMLDivElement>> = Symbol('nodeRef')
export const Slots: InjectionKey<TSlots> = Symbol('slots')