feat(nodes): add nodeRef injection
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import { useVModel } from '@vueuse/core'
|
import { useVModel } from '@vueuse/core'
|
||||||
import { useDrag, useNodeHooks, useVueFlow } from '../../composables'
|
import { useDrag, useNodeHooks, useVueFlow } from '../../composables'
|
||||||
import type { GraphNode, NodeComponent, SnapGrid, XYZPosition } from '../../types'
|
import type { GraphNode, NodeComponent, SnapGrid, XYZPosition } from '../../types'
|
||||||
import { NodeId } from '../../context'
|
import { NodeId, NodeRef } from '../../context'
|
||||||
import { getConnectedEdges, getXYZPos, handleNodeClick } from '../../utils'
|
import { getConnectedEdges, getXYZPos, handleNodeClick } from '../../utils'
|
||||||
|
|
||||||
const { id, type, name, draggable, selectable, connectable, snapGrid, ...props } = defineProps<{
|
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()
|
const nodeElement = ref()
|
||||||
|
|
||||||
|
provide(NodeRef, nodeElement)
|
||||||
|
|
||||||
const { emit, on } = useNodeHooks(node, emits)
|
const { emit, on } = useNodeHooks(node, emits)
|
||||||
|
|
||||||
const dragging = useDrag({
|
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'
|
import type { VueFlowStore } from '~/types'
|
||||||
|
|
||||||
export const VueFlow: InjectionKey<VueFlowStore> = Symbol('vueFlow')
|
export const VueFlow: InjectionKey<VueFlowStore> = Symbol('vueFlow')
|
||||||
export const NodeId: InjectionKey<string> = Symbol('nodeId')
|
export const NodeId: InjectionKey<string> = Symbol('nodeId')
|
||||||
|
export const NodeRef: InjectionKey<Ref<HTMLDivElement>> = Symbol('nodeRef')
|
||||||
export const Slots: InjectionKey<TSlots> = Symbol('slots')
|
export const Slots: InjectionKey<TSlots> = Symbol('slots')
|
||||||
|
|||||||
Reference in New Issue
Block a user