mirror of
https://github.com/langgenius/dify.git
synced 2026-03-20 05:57:59 +08:00
Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
29 lines
1009 B
TypeScript
29 lines
1009 B
TypeScript
import type { FC } from 'react'
|
|
import type { CommonNodeType } from '../types'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useNodes } from 'reactflow'
|
|
import { cn } from '@/utils/classnames'
|
|
import { scrollToWorkflowNode } from '../utils/node-navigation'
|
|
|
|
const ScrollToSelectedNodeButton: FC = () => {
|
|
const { t } = useTranslation()
|
|
const nodes = useNodes<CommonNodeType>()
|
|
const selectedNode = nodes.find(node => node.data.selected)
|
|
|
|
if (!selectedNode)
|
|
return null
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'flex h-6 cursor-pointer items-center justify-center whitespace-nowrap rounded-md border-[0.5px] border-effects-highlight bg-components-actionbar-bg px-3 text-text-tertiary shadow-lg backdrop-blur-sm transition-colors duration-200 system-xs-medium hover:text-text-accent',
|
|
)}
|
|
onClick={() => scrollToWorkflowNode(selectedNode.id)}
|
|
>
|
|
{t('panel.scrollToSelectedNode', { ns: 'workflow' })}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ScrollToSelectedNodeButton
|