|
|
|
|
@ -1,30 +1,39 @@
|
|
|
|
|
import { memo } from 'react'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
import { useShallow } from 'zustand/react/shallow'
|
|
|
|
|
import { RiCrosshairLine } from '@remixicon/react'
|
|
|
|
|
import type { XYPosition } from 'reactflow'
|
|
|
|
|
import { useReactFlow, useStoreApi } from 'reactflow'
|
|
|
|
|
import { useReactFlow, useStore } from 'reactflow'
|
|
|
|
|
import TooltipPlus from '@/app/components/base/tooltip'
|
|
|
|
|
import { useNodesSyncDraft } from '@/app/components/workflow-app/hooks'
|
|
|
|
|
|
|
|
|
|
type NodePositionProps = {
|
|
|
|
|
nodePosition: XYPosition,
|
|
|
|
|
nodeWidth?: number | null,
|
|
|
|
|
nodeHeight?: number | null,
|
|
|
|
|
nodeId: string
|
|
|
|
|
}
|
|
|
|
|
const NodePosition = ({
|
|
|
|
|
nodePosition,
|
|
|
|
|
nodeWidth,
|
|
|
|
|
nodeHeight,
|
|
|
|
|
nodeId,
|
|
|
|
|
}: NodePositionProps) => {
|
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
const reactflow = useReactFlow()
|
|
|
|
|
const store = useStoreApi()
|
|
|
|
|
const { doSyncWorkflowDraft } = useNodesSyncDraft()
|
|
|
|
|
const {
|
|
|
|
|
nodePosition,
|
|
|
|
|
nodeWidth,
|
|
|
|
|
nodeHeight,
|
|
|
|
|
} = useStore(useShallow((s) => {
|
|
|
|
|
const nodes = s.getNodes()
|
|
|
|
|
const currentNode = nodes.find(node => node.id === nodeId)!
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
nodePosition: currentNode.position,
|
|
|
|
|
nodeWidth: currentNode.width,
|
|
|
|
|
nodeHeight: currentNode.height,
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
const transform = useStore(s => s.transform)
|
|
|
|
|
|
|
|
|
|
if (!nodePosition || !nodeWidth || !nodeHeight) return null
|
|
|
|
|
|
|
|
|
|
const workflowContainer = document.getElementById('workflow-container')
|
|
|
|
|
const { transform } = store.getState()
|
|
|
|
|
const zoom = transform[2]
|
|
|
|
|
|
|
|
|
|
const { clientWidth, clientHeight } = workflowContainer!
|
|
|
|
|
|