feat(nodes): add nodeRef injection
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user