+
{item.logo && (
-
+
)}
-
-
{item.title}
-
{item.des}
+
+
)}
- {des && {des}
}
+ {des && {des}
}
);
diff --git a/docs/guide/demos/customNode/components/custom.style.ts b/docs/guide/demos/customNode/components/custom.style.ts
new file mode 100644
index 0000000..592e1aa
--- /dev/null
+++ b/docs/guide/demos/customNode/components/custom.style.ts
@@ -0,0 +1,93 @@
+import { createStyles } from 'antd-style';
+
+const useStyles = createStyles(() => {
+ return {
+ techUIpipeNodeWrap: {
+ width: '260px',
+ minHeight: '100px',
+ backgroundColor: '#f6f8fa',
+ padding: '12px 6px',
+ boxSizing: 'border-box',
+ borderRadius: '8px',
+ },
+
+ pipeNode: {
+ width: '100%',
+ borderRadius: '4px',
+ backgroundColor: '#fff',
+ paddingBottom: '12px',
+ },
+ mainBox: {
+ width: '100%',
+ padding: '12px',
+ height: '45px',
+ backgroundColor: 'white',
+ display: 'flex',
+ borderBottom: 'none',
+ borderRadius: '8px',
+ boxSizing: 'border-box',
+ position: 'relative',
+ },
+ logo: {
+ display: 'flex',
+ alignItems: 'center',
+ img: { width: '16px', height: '16px' },
+ },
+ title: {
+ marginLeft: '8px',
+ fontSize: '14px',
+ fontWeight: '500',
+ color: '#000',
+ lineHeight: '22px',
+ whiteSpace: 'nowrap',
+ },
+ lineTitle: {
+ marginLeft: '8px',
+ fontSize: '14px',
+ fontWeight: '500',
+ color: '#000',
+ lineHeight: '22px',
+ whiteSpace: 'nowrap',
+ },
+ subLogo: {
+ position: 'absolute',
+ right: '6px',
+ top: '8px',
+ img: { width: '80px', height: '25px' },
+ },
+ des: {
+ marginTop: '16px',
+ color: '#00000073',
+ fontSize: '10px',
+ },
+ children: {
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'center',
+ paddingBottom: '8px',
+ },
+ childrenBox: {
+ width: '220px',
+ height: '30px',
+ paddingLeft: '5px',
+ backgroundColor: 'white',
+ display: 'flex',
+ alignItems: 'center',
+ border: '1px solid #f1f1f1',
+ borderRadius: '3px',
+ boxSizing: 'border-box',
+ marginTop: '3px',
+ position: 'relative',
+ },
+ wrap: {
+ marginLeft: '8px',
+ display: 'flex',
+ flexDirection: 'column',
+ },
+ container: {
+ width: '100%',
+ height: '600px',
+ },
+ };
+});
+export default useStyles;
diff --git a/docs/guide/demos/customNode/css/index.less b/docs/guide/demos/customNode/css/index.less
deleted file mode 100644
index a2265d9..0000000
--- a/docs/guide/demos/customNode/css/index.less
+++ /dev/null
@@ -1,13 +0,0 @@
-.wrap {
- width: 200px;
- height: 83px;
- background-color: white;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.container {
- width: 100%;
- height: 300px;
-}
diff --git a/docs/guide/demos/customNode/css/multi.less b/docs/guide/demos/customNode/css/multi.less
deleted file mode 100644
index a6ca569..0000000
--- a/docs/guide/demos/customNode/css/multi.less
+++ /dev/null
@@ -1,21 +0,0 @@
-.wrap {
- width: 200px;
- height: 83px;
- background-color: white;
- display: flex;
- align-items: center;
- justify-content: center;
-
- &.default {
- border: none;
- }
-
- &.select {
- border: 1px solid red;
- }
-}
-
-.container {
- width: 100%;
- height: 300px;
-}
diff --git a/docs/guide/demos/customNode/index.tsx b/docs/guide/demos/customNode/index.tsx
index e789cab..e44fd76 100644
--- a/docs/guide/demos/customNode/index.tsx
+++ b/docs/guide/demos/customNode/index.tsx
@@ -4,13 +4,16 @@
*/
import { FlowView } from '@ant-design/pro-flow';
import CustomNode from './components/CustomNode';
+import useStyles from './css/index.style';
import { nodes } from './data/index';
const nodeTypes = { customNode: CustomNode };
function App() {
+ const { styles } = useStyles();
+
return (
-
+
);
diff --git a/docs/guide/demos/customNode/multiHandle.tsx b/docs/guide/demos/customNode/multiHandle.tsx
index b011b1a..5cc4790 100644
--- a/docs/guide/demos/customNode/multiHandle.tsx
+++ b/docs/guide/demos/customNode/multiHandle.tsx
@@ -4,13 +4,16 @@
*/
import { FlowView } from '@ant-design/pro-flow';
import CustomNode from './components/CustomNode';
+import useStyles from './css/index.style';
import { edges, nodes } from './data/multi';
const nodeTypes = { customNode: CustomNode };
function App() {
+ const { styles } = useStyles();
+
return (
-
+
);
diff --git a/docs/guide/demos/flowEditor/EditorNode.tsx b/docs/guide/demos/flowEditor/EditorNode.tsx
index 6dca250..e4a7ed8 100644
--- a/docs/guide/demos/flowEditor/EditorNode.tsx
+++ b/docs/guide/demos/flowEditor/EditorNode.tsx
@@ -1,12 +1,13 @@
import { EditNode, Handle, Position } from '@ant-design/pro-flow';
import { FC } from 'react';
-import './css/editNode.less';
+import useStyles from './css/index.style';
export const EditorNode: FC = (node: any) => {
const { handles, id, selected } = node;
+ const { styles, cx } = useStyles();
return (
-
+
{
const { handles, id, selected } = node;
+ const { styles, cx } = useStyles();
return (
-
+
{
const editor = useFlowEditor();
+ const { styles } = useStyles();
useEffect(() => {
editor.addNode({
@@ -22,7 +24,7 @@ const ProFlowDemo = () => {
}, [editor]);
return (
-
+
);
diff --git a/docs/guide/demos/flowEditor/css/dragAddNode.less b/docs/guide/demos/flowEditor/css/dragAddNode.less
deleted file mode 100644
index d2a9449..0000000
--- a/docs/guide/demos/flowEditor/css/dragAddNode.less
+++ /dev/null
@@ -1,47 +0,0 @@
-.container {
- width: 100%;
- height: 800px;
- display: flex;
- flex-direction: column;
-
- .aside {
- width: 100%;
- box-sizing: border-box;
- border-right: 1px solid #eee;
- padding: 15px 10px;
- font-size: 12px;
- background: #fcfcfc;
- }
-
- .aside .description {
- margin-bottom: 10px;
- }
-
- .dndnode {
- height: 20px;
- padding: 4px;
- border: 1px solid #1a192b;
- border-radius: 2px;
- margin-bottom: 10px;
- display: flex;
- justify-content: center;
- align-items: center;
- cursor: grab;
- }
-
- .dndnode.input {
- border-color: #0041d0;
- }
- .dndnode.output {
- border-color: #ff0072;
- }
-
- .reactflow-wrapper {
- flex-grow: 1;
- height: 100%;
- }
-
- .selectall {
- margin-top: 10px;
- }
-}
diff --git a/docs/guide/demos/flowEditor/css/editNode.less b/docs/guide/demos/flowEditor/css/editNode.less
deleted file mode 100644
index 578608d..0000000
--- a/docs/guide/demos/flowEditor/css/editNode.less
+++ /dev/null
@@ -1,4 +0,0 @@
-.editNode{
- width: 400px;
-
-}
diff --git a/docs/guide/demos/flowEditor/css/editNode.style.ts b/docs/guide/demos/flowEditor/css/editNode.style.ts
deleted file mode 100644
index b2ec866..0000000
--- a/docs/guide/demos/flowEditor/css/editNode.style.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { createStyles } from 'antd-style';
-
-const useStyles = createStyles(() => {
- return {
- editNode: {
- width: '400px',
- },
- };
-});
-export default useStyles;
diff --git a/docs/guide/demos/flowEditor/css/index.less b/docs/guide/demos/flowEditor/css/index.less
deleted file mode 100644
index 19d4ca0..0000000
--- a/docs/guide/demos/flowEditor/css/index.less
+++ /dev/null
@@ -1,13 +0,0 @@
-.stringNode {
- width: 150px;
- height: 30px;
- text-align: center;
- background-color: white;
- border: 1px solid aqua;
- border-radius: 4px;
- line-height: 30px;
-}
-
-.selected {
- border: 1px solid #007bff;
-}
diff --git a/docs/guide/demos/flowEditor/css/index.style.ts b/docs/guide/demos/flowEditor/css/index.style.ts
index 1815ab1..2c0c8bf 100644
--- a/docs/guide/demos/flowEditor/css/index.style.ts
+++ b/docs/guide/demos/flowEditor/css/index.style.ts
@@ -2,6 +2,10 @@ import { createStyles } from 'antd-style';
const useStyles = createStyles(() => {
return {
+ container: {
+ width: '100%',
+ height: '600px',
+ },
stringNode: {
width: '150px',
height: '30px',
@@ -14,6 +18,9 @@ const useStyles = createStyles(() => {
selected: {
border: '1px solid #007bff',
},
+ editNode: {
+ width: '400px',
+ },
};
});
export default useStyles;
diff --git a/docs/guide/demos/flowEditor/css/probase.less b/docs/guide/demos/flowEditor/css/probase.less
deleted file mode 100644
index 0ba5ae2..0000000
--- a/docs/guide/demos/flowEditor/css/probase.less
+++ /dev/null
@@ -1,15 +0,0 @@
-.container {
- width: 100%;
- height: 600px;
-
- button {
- width: 100px;
- height: 30px;
- line-height: 24px;
- box-sizing: border-box;
- text-align: center;
- user-select: none;
- margin-right: 10px;
- margin-top: 10px;
- }
-}
diff --git a/docs/guide/demos/flowEditor/css/sidebar.less b/docs/guide/demos/flowEditor/css/sidebar.less
deleted file mode 100644
index 3118497..0000000
--- a/docs/guide/demos/flowEditor/css/sidebar.less
+++ /dev/null
@@ -1,49 +0,0 @@
-.aside {
- border-right: 1px solid #eee;
- padding: 15px 10px;
- font-size: 12px;
- background: #fcfcfc;
-}
-
-.aside .description {
- margin-bottom: 10px;
-}
-
-.dndnode {
- height: 20px;
- padding: 4px;
- border: 1px solid #1a192b;
- border-radius: 2px;
- margin-bottom: 10px;
- display: flex;
- justify-content: center;
- align-items: center;
- cursor: grab;
-}
-
-.dndnode.input {
- border-color: #0041d0;
-}
-.dndnode.output {
- border-color: #ff0072;
-}
-
-.reactflow-wrapper {
- flex-grow: 1;
- height: 100%;
-}
-
-.selectall {
- margin-top: 10px;
-}
-
-@media screen and (min-width: 768px) {
- // .dndflow {
- // flex-direction: row;
- // }
-
- .aside {
- width: 20%;
- max-width: 250px;
- }
-}
diff --git a/docs/guide/demos/flowEditor/dragAddNode.tsx b/docs/guide/demos/flowEditor/dragAddNode.tsx
index 2e4758c..a0de51c 100644
--- a/docs/guide/demos/flowEditor/dragAddNode.tsx
+++ b/docs/guide/demos/flowEditor/dragAddNode.tsx
@@ -11,7 +11,7 @@ import {
} from '@ant-design/pro-flow';
import { useCallback, useEffect } from 'react';
import { StringRender } from './StringNode';
-import './css/dragAddNode.less';
+import useStyles from './css/dragAddNode.style';
import Sidebar from './sidebar';
let id = 0;
@@ -24,6 +24,7 @@ const nodeTypes = {
};
const ProFlowDemo = () => {
const editor = useFlowEditor();
+ const { styles } = useStyles();
const onDragOver = useCallback((event) => {
event.preventDefault();
@@ -75,7 +76,7 @@ const ProFlowDemo = () => {
}, [editor]);
return (
-
+
{
const editor = useFlowEditor();
+ const { styles } = useStyles();
useEffect(() => {
editor.addNode({
@@ -22,7 +24,7 @@ const ProFlowDemo = () => {
}, [editor]);
return (
-
+
);
diff --git a/docs/guide/demos/flowEditor/proBase.tsx b/docs/guide/demos/flowEditor/proBase.tsx
index 87276db..cbe51e0 100644
--- a/docs/guide/demos/flowEditor/proBase.tsx
+++ b/docs/guide/demos/flowEditor/proBase.tsx
@@ -6,10 +6,11 @@ import { FlowEditor, FlowEditorProvider, FlowPanel, useFlowEditor } from '@ant-d
import { useEffect } from 'react';
import { StringRender } from './StringNode';
import { BtnGroup } from './btnGroup';
-import './css/probase.less';
+import useStyles from './css/probase.style';
const ProFlowDemo = () => {
const editor = useFlowEditor();
+ const { styles } = useStyles();
useEffect(() => {
editor.addNode({
@@ -27,7 +28,7 @@ const ProFlowDemo = () => {
}, [editor]);
return (
-
+
diff --git a/docs/guide/demos/flowEditor/sidebar.tsx b/docs/guide/demos/flowEditor/sidebar.tsx
index b63f71d..a740c3e 100644
--- a/docs/guide/demos/flowEditor/sidebar.tsx
+++ b/docs/guide/demos/flowEditor/sidebar.tsx
@@ -1,24 +1,32 @@
+import useStyles from './css/sidebar.style.ts';
+
export default () => {
+ const { styles, cx } = useStyles();
+
const onDragStart = (event, nodeType) => {
event.dataTransfer.setData('application/reactflow', nodeType);
event.dataTransfer.effectAllowed = 'move';
};
return (
-
-
您可以将这些节点拖到上面的画布中
+
+
您可以将这些节点拖到上面的画布中
onDragStart(event, 'StringNode')}
draggable
>
String Node
-
onDragStart(event, 'BasicNode')} draggable>
+
onDragStart(event, 'BasicNode')}
+ draggable
+ >
BasicNode Node
onDragStart(event, 'EditNode')}
draggable
>
diff --git a/docs/guide/demos/flowViewIntro/autoFlow.tsx b/docs/guide/demos/flowViewIntro/autoFlow.tsx
index e12702e..a994b74 100644
--- a/docs/guide/demos/flowViewIntro/autoFlow.tsx
+++ b/docs/guide/demos/flowViewIntro/autoFlow.tsx
@@ -3,12 +3,14 @@
* defaultShowCode: true
*/
import { FlowView } from '@ant-design/pro-flow';
-import './css/index.less';
+import useStyles from './css/index.style';
import { edges, nodes } from './data/data2';
function App() {
+ const { styles } = useStyles();
+
return (
-
+
+
);
diff --git a/docs/guide/demos/flowViewIntro/css/index.less b/docs/guide/demos/flowViewIntro/css/index.less
deleted file mode 100644
index bc08136..0000000
--- a/docs/guide/demos/flowViewIntro/css/index.less
+++ /dev/null
@@ -1,4 +0,0 @@
-.container {
- width: 100%;
- height: 600px;
-}
diff --git a/docs/guide/demos/flowViewIntro/css/index.style.ts b/docs/guide/demos/flowViewIntro/css/index.style.ts
index 53fae6b..995eb00 100644
--- a/docs/guide/demos/flowViewIntro/css/index.style.ts
+++ b/docs/guide/demos/flowViewIntro/css/index.style.ts
@@ -4,7 +4,7 @@ const useStyles = createStyles(() => {
return {
container: {
width: '100%',
- height: '600px',
+ height: '400px',
},
};
});
diff --git a/docs/guide/demos/flowViewIntro/noAutoFlow.tsx b/docs/guide/demos/flowViewIntro/noAutoFlow.tsx
index 7ffc77b..753384b 100644
--- a/docs/guide/demos/flowViewIntro/noAutoFlow.tsx
+++ b/docs/guide/demos/flowViewIntro/noAutoFlow.tsx
@@ -3,12 +3,14 @@
* defaultShowCode: true
*/
import { FlowView } from '@ant-design/pro-flow';
-import './css/index.less';
+import useStyles from './css/index.style';
import { edges, nodes } from './data/data3';
function App() {
+ const { styles } = useStyles();
+
return (
-
+
);
diff --git a/docs/guide/demos/flowViewIntro/noMiniMap.tsx b/docs/guide/demos/flowViewIntro/noMiniMap.tsx
index d46eb21..8b1dbc0 100644
--- a/docs/guide/demos/flowViewIntro/noMiniMap.tsx
+++ b/docs/guide/demos/flowViewIntro/noMiniMap.tsx
@@ -4,13 +4,15 @@
*/
import { FlowPanel, FlowView } from '@ant-design/pro-flow';
import { useState } from 'react';
-import './css/index.less';
+import useStyles from './css/index.style';
import { nodes } from './data/data';
function App() {
const [open, setOpen] = useState(true);
+ const { styles } = useStyles();
+
return (
-
+
diff --git a/docs/guide/demos/muchNode/CustomNode.tsx b/docs/guide/demos/muchNode/CustomNode.tsx
deleted file mode 100644
index 7ee195d..0000000
--- a/docs/guide/demos/muchNode/CustomNode.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import { Handle, Position } from '@ant-design/pro-flow';
-import { FC } from 'react';
-
-interface PipeNodeChild {
- title: string;
- logo?: string;
- id: string;
-}
-
-interface PipeNode {
- title: string;
- logo: string;
- des?: string;
- children?: PipeNodeChild[];
-}
-
-const CustomNode: FC<{
- data: PipeNode;
-}> = ({ data }) => {
- const { title, des, logo, children = [] } = data;
-
- console.log('reload');
-
- return (
-
-
-
-
-
![]({logo})
-
-
{title}
-
-
![]({)
-
-
-
- {children.length > 0 && (
-
- {children.map((item, index) => (
- <>
-
-
- {item.logo && (
-
-
![]({item.logo})
-
- )}
-
-
{item.title}
-
{item.des}
-
-
-
- >
- ))}
-
- )}
-
- {des &&
{des}
}
-
-
- );
-};
-
-export default CustomNode;
diff --git a/docs/guide/demos/muchNode/data.tsx b/docs/guide/demos/muchNode/data.tsx
deleted file mode 100644
index 63ea6ff..0000000
--- a/docs/guide/demos/muchNode/data.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-export const nodes = [
- {
- id: 'a1',
- type: 'customNode',
- data: {
- title: 'XXX_API_a1',
- logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original',
- des: 'XXX_XXX_XXX_API',
- },
- },
- {
- id: 'a2',
- data: {
- title: 'XXX_API_a2',
- logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original',
- describe: 'XXX_XXX_XXX_API',
- },
- },
- {
- id: 'a3',
- label: 'aaaa3',
- data: {
- title: 'XXX_API_a3',
- logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original',
- describe: 'XXX_XXX_XXX_API',
- },
- },
-];
-export const edges = [
- {
- id: 'a1-a2',
- source: 'a1',
- target: 'a2',
- },
- {
- id: 'a1-a3',
- source: 'a1',
- target: 'a3',
- type: 'radius',
- },
-];
diff --git a/docs/guide/demos/muchNode/index.tsx b/docs/guide/demos/muchNode/index.tsx
deleted file mode 100644
index 8bf065c..0000000
--- a/docs/guide/demos/muchNode/index.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * compact: true
- * defaultShowCode: true
- */
-import { FlowPanel, FlowView, FlowViewProvider, useFlowViewer } from '@ant-design/pro-flow';
-import { useState } from 'react';
-// import './css/index.less';
-import CustomNode from './CustomNode';
-import { edges, nodes } from './data';
-
-const nodeTypes = { customNode: CustomNode };
-
-function App() {
- const { selectNode, selectEdges, selectNodes } = useFlowViewer();
- const [node, setNode] = useState(null);
-
- return (
-
-
-
-
- {node ? `当前选中的是:${node.id}` : `当前没有选中节点`}
-
-
-
-
- );
-}
-
-function ProApp() {
- return (
-
-
-
- );
-}
-
-export default ProApp;
diff --git a/docs/guide/demos/quickUse/baseFlow.tsx b/docs/guide/demos/quickUse/baseFlow.tsx
index 0368639..f61d5cd 100644
--- a/docs/guide/demos/quickUse/baseFlow.tsx
+++ b/docs/guide/demos/quickUse/baseFlow.tsx
@@ -3,12 +3,14 @@
* defaultShowCode: true
*/
import { FlowView } from '@ant-design/pro-flow';
-import './css/index.less';
+import useStyles from './css/index.style';
import { edges, nodes } from './data';
function App() {
+ const { styles } = useStyles();
+
return (
-
+
);
diff --git a/docs/guide/demos/quickUse/css/index.less b/docs/guide/demos/quickUse/css/index.less
deleted file mode 100644
index bc08136..0000000
--- a/docs/guide/demos/quickUse/css/index.less
+++ /dev/null
@@ -1,4 +0,0 @@
-.container {
- width: 100%;
- height: 600px;
-}
diff --git a/docs/guide/demos/quickUse/emptyFLow.tsx b/docs/guide/demos/quickUse/emptyFLow.tsx
index 8a29376..1a80d4c 100644
--- a/docs/guide/demos/quickUse/emptyFLow.tsx
+++ b/docs/guide/demos/quickUse/emptyFLow.tsx
@@ -3,11 +3,13 @@
* defaultShowCode: true
*/
import { FlowView } from '@ant-design/pro-flow';
-import './css/index.less';
+import useStyles from './css/index.style';
function App() {
+ const { styles } = useStyles();
+
return (
-
+
);
diff --git a/docs/guide/demos/quickUse/selectFlow.tsx b/docs/guide/demos/quickUse/selectFlow.tsx
index cc6eb96..1bd268e 100644
--- a/docs/guide/demos/quickUse/selectFlow.tsx
+++ b/docs/guide/demos/quickUse/selectFlow.tsx
@@ -10,18 +10,18 @@ import {
useFlowViewer,
} from '@ant-design/pro-flow';
import { useState } from 'react';
-import './css/index.less';
+import useStyles from './css/index.style';
import { edges, nodes } from './data';
function App() {
const { selectNode, selectEdges, selectNodes } = useFlowViewer();
const [node, setNode] = useState(null);
+ const { styles } = useStyles();
return (
-
+
{
- console.log(node);
setNode(node);
selectNodes(['a1', 'a2', 'a3'], SelectType.SUB_SELECT);
selectNode(node.id, SelectType.SELECT);
diff --git a/docs/guide/test.txt b/docs/guide/test.txt
deleted file mode 100644
index c7c596e..0000000
--- a/docs/guide/test.txt
+++ /dev/null
@@ -1,13 +0,0 @@
----
-nav:
- title: 快速上手
- order: 10
-group:
- title: test
- order: 2
-title: 安装使用
-order: 1
-description:
----
-
-
diff --git a/src/FlowEditor/store/slices/nodesSlice.ts b/src/FlowEditor/store/slices/nodesSlice.ts
index ae4f60e..6202c14 100644
--- a/src/FlowEditor/store/slices/nodesSlice.ts
+++ b/src/FlowEditor/store/slices/nodesSlice.ts
@@ -70,8 +70,8 @@ export interface PublicNodesAction {
/**
* 更新节点数据
* @param id 要更新的节点 id
- * @param key 要更新的内容键名
- * @param value 要更新的内容值
+ * @param newData 要更新的数据
+ * @param forceReplace 是否强制替换整个数据
* @param options 节点操作的选项
*/
updateNodeData: (
diff --git a/src/FlowView/index.tsx b/src/FlowView/index.tsx
index d892220..296e648 100644
--- a/src/FlowView/index.tsx
+++ b/src/FlowView/index.tsx
@@ -15,7 +15,6 @@ import DefaultNode from './components/DefaultNode';
import { FlowViewContext } from './provider/provider';
import { useStyles } from './styles';
-const MIN_ZOOM = 0.1;
export const FlowContext = createContext({});
const initFn = () => {};
@@ -35,6 +34,8 @@ const FlowView: React.FC> = (props) => {
autoLayout = true,
stepLessZooming = true,
flowProps,
+ minZoom = 0.1,
+ maxZoom = 2,
} = props;
const {
miniMapPosition,
@@ -117,7 +118,8 @@ const FlowView: React.FC> = (props) => {
edgeTypes={edgeTypesMemo}
panOnScroll
fitView
- minZoom={MIN_ZOOM}
+ minZoom={minZoom}
+ maxZoom={maxZoom}
{...flowProps}
>
{miniMap && }
diff --git a/src/FlowView/index.zh-CN.md b/src/FlowView/index.zh-CN.md
index b30e75d..90b1826 100644
--- a/src/FlowView/index.zh-CN.md
+++ b/src/FlowView/index.zh-CN.md
@@ -18,18 +18,20 @@ description:
### FlowView
-| 属性名 | 类型 | 描述 | 默认值 | 必选 |
-| ---------- | ------------------------------------------------ | -------- | ------ | ---- |
-| nodes | `FlowViewNode` | 边数据 | - | - |
-| edges | `FlowViewEdge` | 节点数据 | - | - |
-| className | `string` | 边数据 | - | - |
-| style | `CSSProperties` | 节点数据 | - | - |
-| miniMap | `boolean` | 边数据 | - | - |
-| autoLayout | `boolean` | 自动布局 | true | - |
-| background | `boolean` | 节点数据 | - | - |
-| children | `React.ReactNode` | 边数据 | - | - |
-| nodeTypes | `Record>` | 节点类型 | - | - |
-| edgeTypes | `Record>` | 边缘类型 | - | - |
+| 属性名 | 类型 | 描述 | 默认值 | 必选 |
+| ---------- | ------------------------------------------------ | ------------ | ------ | ---- |
+| nodes | `FlowViewNode` | 边数据 | - | - |
+| edges | `FlowViewEdge` | 节点数据 | - | - |
+| className | `string` | 边数据 | - | - |
+| style | `CSSProperties` | 节点数据 | - | - |
+| miniMap | `boolean` | 边数据 | - | - |
+| autoLayout | `boolean` | 自动布局 | true | - |
+| background | `boolean` | 节点数据 | - | - |
+| children | `React.ReactNode` | 边数据 | - | - |
+| nodeTypes | `Record>` | 节点类型 | - | - |
+| edgeTypes | `Record>` | 边缘类型 | - | - |
+| minZoom | `number` | 最小缩放比例 | - | - |
+| maxZoom | `number` | 最大缩放比例 | - | - |
### FlowViewNode
diff --git a/src/constants.tsx b/src/constants.tsx
index fe377fa..d749a69 100644
--- a/src/constants.tsx
+++ b/src/constants.tsx
@@ -95,6 +95,8 @@ export interface FlowViewProps {
children?: React.ReactNode;
autoLayout?: boolean;
stepLessZooming?: boolean;
+ minZoom?: number;
+ maxZoom?: number;
}
export interface MiniMapPosition {