mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 10:56:52 +08:00
feat: workflow add note node (#5164)
This commit is contained in:
@@ -19,10 +19,18 @@ const Icon = () => {
|
||||
type NodeResizerProps = {
|
||||
nodeId: string
|
||||
nodeData: CommonNodeType
|
||||
icon?: JSX.Element
|
||||
minWidth?: number
|
||||
minHeight?: number
|
||||
maxWidth?: number
|
||||
}
|
||||
const NodeResizer = ({
|
||||
nodeId,
|
||||
nodeData,
|
||||
icon = <Icon />,
|
||||
minWidth = 272,
|
||||
minHeight = 176,
|
||||
maxWidth,
|
||||
}: NodeResizerProps) => {
|
||||
const { handleNodeResize } = useNodesInteractions()
|
||||
|
||||
@@ -39,10 +47,11 @@ const NodeResizer = ({
|
||||
position='bottom-right'
|
||||
className='!border-none !bg-transparent'
|
||||
onResize={handleResize}
|
||||
minWidth={272}
|
||||
minHeight={176}
|
||||
minWidth={minWidth}
|
||||
minHeight={minHeight}
|
||||
maxWidth={maxWidth}
|
||||
>
|
||||
<div className='absolute bottom-[1px] right-[1px]'><Icon /></div>
|
||||
<div className='absolute bottom-[1px] right-[1px]'>{icon}</div>
|
||||
</NodeResizeControl>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -64,3 +64,5 @@ export const PanelComponentMap: Record<string, ComponentType<any>> = {
|
||||
[BlockEnum.ParameterExtractor]: ParameterExtractorPanel,
|
||||
[BlockEnum.Iteration]: IterationPanel,
|
||||
}
|
||||
|
||||
export const CUSTOM_NODE_TYPE = 'custom'
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { memo } from 'react'
|
||||
import {
|
||||
memo,
|
||||
useMemo,
|
||||
} from 'react'
|
||||
import type { NodeProps } from 'reactflow'
|
||||
import type { Node } from '../types'
|
||||
import { CUSTOM_NODE } from '../constants'
|
||||
import {
|
||||
NodeComponentMap,
|
||||
PanelComponentMap,
|
||||
@@ -23,14 +27,24 @@ const CustomNode = (props: NodeProps) => {
|
||||
CustomNode.displayName = 'CustomNode'
|
||||
|
||||
export const Panel = memo((props: Node) => {
|
||||
const nodeClass = props.type
|
||||
const nodeData = props.data
|
||||
const PanelComponent = PanelComponentMap[nodeData.type]
|
||||
const PanelComponent = useMemo(() => {
|
||||
if (nodeClass === CUSTOM_NODE)
|
||||
return PanelComponentMap[nodeData.type]
|
||||
|
||||
return (
|
||||
<BasePanel key={props.id} {...props}>
|
||||
<PanelComponent />
|
||||
</BasePanel>
|
||||
)
|
||||
return () => null
|
||||
}, [nodeClass, nodeData.type])
|
||||
|
||||
if (nodeClass === CUSTOM_NODE) {
|
||||
return (
|
||||
<BasePanel key={props.id} {...props}>
|
||||
<PanelComponent />
|
||||
</BasePanel>
|
||||
)
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
|
||||
Panel.displayName = 'Panel'
|
||||
|
||||
Reference in New Issue
Block a user