+
您可以将这些节点拖到左侧的画布中
+
onDragStart(event, 'StringNode')}
+ draggable
+ >
+ String Node
+
+
onDragStart(event, 'TextNode')}
+ draggable
+ >
+ Text Node
+
+
onDragStart(event, 'BasicNode')}
+ draggable
+ >
+ BasicNode Node
+
+
onDragStart(event, 'EditNode')}
+ draggable
+ >
+ EditNode Node
+
+
+ );
+};
diff --git a/docs/caseShow/demos/workflow/styled.ts b/docs/caseShow/demos/workflow/styled.ts
new file mode 100644
index 0000000..a1048dd
--- /dev/null
+++ b/docs/caseShow/demos/workflow/styled.ts
@@ -0,0 +1,73 @@
+import { createStyles } from 'antd-style';
+
+const useStyles = createStyles(() => {
+ return {
+ container: {
+ width: '100%',
+ height: '600px',
+ display: 'flex',
+ flexDirection: 'column',
+ },
+ aside: {
+ width: '200px',
+ height: '100%',
+ position: 'absolute',
+ right: 0,
+ top: 0,
+ zIndex: 10000000,
+ borderRight: '1px solid #eee',
+ padding: '15px 10px',
+ fontSize: '12px',
+ background: '#fcfcfc',
+ marginBottom: '10px',
+ },
+ description: {
+ marginBottom: '10px',
+ },
+ dndnode: {
+ height: '20px',
+ padding: '4px',
+ border: '1px solid #1a192b',
+ borderRadius: '2px',
+ marginBottom: '10px',
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center',
+ cursor: 'grab',
+ },
+ 'dndnode.input': {
+ borderColor: '#0041d0',
+ },
+ 'dndnode.output': {
+ borderColor: '#ff0072',
+ },
+ 'reactflow-wrapper': {
+ flexGrow: '1',
+ height: '100%',
+ },
+ selectall: {
+ marginTop: '10px',
+ },
+ textNode: {
+ width: '300px',
+ height: '300px',
+ background: '#fff',
+ borderRadius: '10px',
+ border: '1px solid #ddd',
+ display: 'flex',
+ justifyContent: 'center',
+ flexWrap: 'wrap',
+ h1: {
+ margin: 0,
+ padding: '10px',
+ borderBottom: '1px solid #ddd',
+ fontSize: '',
+ },
+ textarea: {
+ width: '280px',
+ height: '200px',
+ },
+ },
+ };
+});
+export default useStyles;
diff --git a/docs/caseShow/pipeline.md b/docs/caseShow/pipeline.md
new file mode 100644
index 0000000..233e2c5
--- /dev/null
+++ b/docs/caseShow/pipeline.md
@@ -0,0 +1,23 @@
+---
+nav:
+ title: 案例展示
+ order: 100
+group:
+ title: 场景展示
+ order: 1
+title: 流水线&管道图
+order: 3
+description:
+---
+
+## 流水线
+
+
diff --git a/src/FlowView/helper.tsx b/src/FlowView/helper.tsx
index a9be495..fa1a917 100644
--- a/src/FlowView/helper.tsx
+++ b/src/FlowView/helper.tsx
@@ -30,6 +30,7 @@ export function convertMappingFrom(nodes: FlowViewNode[], edges: FlowViewEdge[],
} = node;
mapping[node.id] = {
+ ...node,
id: node.id,
data: node.data,
select,
@@ -46,8 +47,8 @@ export function convertMappingFrom(nodes: FlowViewNode[], edges: FlowViewEdge[],
edges.forEach((edge) => {
const { source, target } = edge;
- mapping[source].right?.push(target);
- mapping[target].left?.push(source);
+ if (mapping[source]) mapping[source].right?.push(target);
+ if (mapping[target]) mapping[target].left?.push(source);
});
return mapping;
@@ -78,6 +79,10 @@ export function setNodePosition(
const g = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
g.setGraph({
+ rankdir: 'LR',
+ align: 'UL',
+ nodesep: 100,
+ ranksep: 200,
...layoutOptions,
});
@@ -247,6 +252,7 @@ export const getRenderData = (
const { width, height } = getWidthAndHeight(node);
renderNodes.push({
+ ...node,
sourcePosition: Position.Right,
targetPosition: Position.Left,
id: node.id!,
diff --git a/src/FlowView/index.tsx b/src/FlowView/index.tsx
index ed8fc8a..c0d16ab 100644
--- a/src/FlowView/index.tsx
+++ b/src/FlowView/index.tsx
@@ -83,7 +83,8 @@ const FlowView: React.FC
> = (props) => {
const { zoom } = useViewport();
useEffect(() => {
- flowDataAdapter!(nodes, edges, 1, autoLayout, layoutOptions);
+ const _zoom = zoom ? zoom : 1;
+ flowDataAdapter!(nodes, edges, _zoom, autoLayout, layoutOptions);
}, [nodes, edges]);
useEffect(() => {
diff --git a/src/FlowView/index.zh-CN.md b/src/FlowView/index.zh-CN.md
index d092ab7..02abb33 100644
--- a/src/FlowView/index.zh-CN.md
+++ b/src/FlowView/index.zh-CN.md
@@ -44,8 +44,8 @@ description: 基础画布容器
| ------- | ------------------------------ | -------- | ------ | ---- |
| rankdir | `'TB' \| 'BT' \| 'LR' \| 'RL'` | 布局样式 | - | - |
| align | `'UL' \| 'DL' \| 'UR' \| 'DR'` | 左右对齐 | - | - |
-| nodesep | `number` | 列间距 | - | - |
-| ranksep | `number` | 行间距 | - | - |
+| nodesep | `number` | 行间距 | - | - |
+| ranksep | `number` | 列间距 | - | - |
### FlowViewNode
diff --git a/src/FlowView/provider/FlowViewProvider.tsx b/src/FlowView/provider/FlowViewProvider.tsx
index 86b60ff..424b4d9 100644
--- a/src/FlowView/provider/FlowViewProvider.tsx
+++ b/src/FlowView/provider/FlowViewProvider.tsx
@@ -20,6 +20,7 @@ const ProviderInner: FC<{ children: ReactNode }> = ({ children }) => {
nodesep: 100,
ranksep: 200,
});
+
const flowViewRef = useRef();
const convertRenderData = useCallback(() => {
@@ -29,6 +30,7 @@ const ProviderInner: FC<{ children: ReactNode }> = ({ children }) => {
autoLayout,
layoutOptions,
);
+
setNodes(_nodes);
setEdges(_edges);
}, [mapping, initEdges, autoLayout, layoutOptions]);
diff --git a/src/index.ts b/src/index.ts
index 857e122..1acd835 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,6 +3,8 @@ export {
EdgeLabelRenderer,
Handle,
Position,
+ applyEdgeChanges,
+ applyNodeChanges,
getBezierPath,
getSmoothStepPath,
} from 'reactflow';