diff --git a/web/app/(commonLayout)/workflow/page.tsx b/web/app/(commonLayout)/workflow/page.tsx index 9aac248e26..bebd7ba994 100644 --- a/web/app/(commonLayout)/workflow/page.tsx +++ b/web/app/(commonLayout)/workflow/page.tsx @@ -8,13 +8,45 @@ const initialNodes = [ { id: '1', type: 'custom', - position: { x: 330, y: 30 }, + position: { x: 130, y: 130 }, data: { type: 'start' }, }, + { + id: '2', + type: 'custom', + position: { x: 434, y: 130 }, + data: { type: 'code' }, + }, + { + id: '3', + type: 'custom', + position: { x: 738, y: 130 }, + data: { type: 'llm' }, + }, + { + id: '4', + type: 'custom', + position: { x: 738, y: 330 }, + data: { type: 'llm' }, + }, ] const initialEdges = [ - + { + id: '0', + source: '1', + target: '2', + }, + { + id: '1', + source: '2', + target: '3', + }, + { + id: '2', + source: '2', + target: '4', + }, ] const Page: FC = () => { diff --git a/web/app/components/workflow/custom-edge.tsx b/web/app/components/workflow/custom-edge.tsx index 73fc0c8880..f0d6086d01 100644 --- a/web/app/components/workflow/custom-edge.tsx +++ b/web/app/components/workflow/custom-edge.tsx @@ -28,7 +28,7 @@ const CustomEdge = ({ return ( <> - +
{ - const prevNodeDom = document.querySelector(`.react-flow__node-custom[data-id="${prevNode.id}"]`) - const prevNodeDomHeight = prevNodeDom?.getBoundingClientRect().height || 0 - const nextNode = { id: `node-${Date.now()}`, type: 'custom', position: { - x: prevNode.position.x, - y: prevNode.position.y + prevNodeDomHeight + 64, + x: prevNode.position.x + 304, + y: prevNode.position.y, }, data: NodeInitialData[nextNodeType], } diff --git a/web/app/components/workflow/index.tsx b/web/app/components/workflow/index.tsx index 954a2949be..c55506e386 100644 --- a/web/app/components/workflow/index.tsx +++ b/web/app/components/workflow/index.tsx @@ -8,6 +8,7 @@ import ReactFlow, { useReactFlow, } from 'reactflow' import 'reactflow/dist/style.css' +import './style.css' import { WorkflowContext, useWorkflowContext, diff --git a/web/app/components/workflow/nodes/_base/node.tsx b/web/app/components/workflow/nodes/_base/node.tsx index 69e471f4a0..1e51253658 100644 --- a/web/app/components/workflow/nodes/_base/node.tsx +++ b/web/app/components/workflow/nodes/_base/node.tsx @@ -59,7 +59,7 @@ const BaseNode: FC = ({ return (
) diff --git a/web/app/components/workflow/style.css b/web/app/components/workflow/style.css new file mode 100644 index 0000000000..e820a05164 --- /dev/null +++ b/web/app/components/workflow/style.css @@ -0,0 +1,3 @@ +.react-flow__edge-path { + stroke-width: 2px !important; +} \ No newline at end of file diff --git a/web/app/components/workflow/zoom-in-out.tsx b/web/app/components/workflow/zoom-in-out.tsx index f7d2f6f4a3..b1dd7effc2 100644 --- a/web/app/components/workflow/zoom-in-out.tsx +++ b/web/app/components/workflow/zoom-in-out.tsx @@ -4,6 +4,7 @@ import { memo, useState, } from 'react' +import { useWorkflowContext } from './context' import { PortalToFollowElem, PortalToFollowElemContent, @@ -42,8 +43,20 @@ const ZOOM_IN_OUT_OPTIONS = [ ] const ZoomInOut: FC = () => { + const { reactFlow } = useWorkflowContext() const [open, setOpen] = useState(false) + const handleZoom = (type: string) => { + if (type === 'in') + reactFlow.zoomIn() + + if (type === 'out') + reactFlow.zoomOut() + + if (type === 'fit') + reactFlow.fitView() + } + return ( {
handleZoom(option.key)} > {option.text}