mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
7753ba2d37
Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yeuoly <admin@srmxy.cn> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: jyong <jyong@dify.ai> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: jyong <718720800@qq.com>
73 lines
1.4 KiB
TypeScript
73 lines
1.4 KiB
TypeScript
import { memo } from 'react'
|
|
import { useViewport } from 'reactflow'
|
|
import { useStore } from '../store'
|
|
import type {
|
|
HelpLineHorizontalPosition,
|
|
HelpLineVerticalPosition,
|
|
} from './types'
|
|
|
|
const HelpLineHorizontal = memo(({
|
|
top,
|
|
left,
|
|
width,
|
|
}: HelpLineHorizontalPosition) => {
|
|
const { x, y, zoom } = useViewport()
|
|
|
|
return (
|
|
<div
|
|
className='absolute h-[1px] bg-primary-300 z-[9]'
|
|
style={{
|
|
top: top * zoom + y,
|
|
left: left * zoom + x,
|
|
width: width * zoom,
|
|
}}
|
|
/>
|
|
)
|
|
})
|
|
HelpLineHorizontal.displayName = 'HelpLineBase'
|
|
|
|
const HelpLineVertical = memo(({
|
|
top,
|
|
left,
|
|
height,
|
|
}: HelpLineVerticalPosition) => {
|
|
const { x, y, zoom } = useViewport()
|
|
|
|
return (
|
|
<div
|
|
className='absolute w-[1px] bg-primary-300 z-[9]'
|
|
style={{
|
|
top: top * zoom + y,
|
|
left: left * zoom + x,
|
|
height: height * zoom,
|
|
}}
|
|
/>
|
|
)
|
|
})
|
|
HelpLineVertical.displayName = 'HelpLineVertical'
|
|
|
|
const HelpLine = () => {
|
|
const helpLineHorizontal = useStore(s => s.helpLineHorizontal)
|
|
const helpLineVertical = useStore(s => s.helpLineVertical)
|
|
|
|
if (!helpLineHorizontal && !helpLineVertical)
|
|
return null
|
|
|
|
return (
|
|
<>
|
|
{
|
|
helpLineHorizontal && (
|
|
<HelpLineHorizontal {...helpLineHorizontal} />
|
|
)
|
|
}
|
|
{
|
|
helpLineVertical && (
|
|
<HelpLineVertical {...helpLineVertical} />
|
|
)
|
|
}
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default memo(HelpLine)
|