File tree Expand file tree Collapse file tree 5 files changed +124
-0
lines changed
pages/extension/InserNodeInPolyline Expand file tree Collapse file tree 5 files changed +124
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ const guide = [
36
36
'extension/adapter' ,
37
37
'extension/bpmn-element' ,
38
38
'extension/extension-node-resize' ,
39
+ 'extension/extension-insert-node-in-polyline.md' ,
39
40
{
40
41
title : '组件' ,
41
42
collapsable : true ,
Original file line number Diff line number Diff line change
1
+ # 连线上插入节点
2
+ ## 功能
3
+ 拖动节点到连线中间,自动成为连线中间的点。
4
+ 举例:存在一条节点A到节点B的折线E,拖拽一个节点N到折线E上,当节点N的中心点恰好在折线E的路径上时松开鼠标,这时节点N就成为A与B的中间节点,原来的连线E被删除,生成两条新的折线,分别是A到N,N到B。示例如下。
5
+ <example href =" /examples/#/extension/InserNodeInPolyline " :height =" 450 " ></example >
6
+
7
+ ## 支持
8
+ 目前仅支持折线
9
+
10
+ ## 使用
11
+ ``` js
12
+ import LogicFlow from ' @logicflow/core' ;
13
+ import { InsertNodeInPolyline } from ' @logicflow/extension' ;
14
+ import ' @logicflow/extension/lib/style/index.css'
15
+ LogicFlow .use (InsertNodeInPolyline);
16
+ ```
17
+ ## 个性化配置
18
+ 节点拖拽分为2种情况:
19
+ - 第一种是从控制面板拖拽到画布中,调用Dnd的Api进行节点添加,本插件默认支持。关闭此功能设置如下:
20
+ ``` js
21
+ InsertNodeInPolyline .dndAdd = false ;
22
+ ```
23
+ - 第二种是画布中的游离节点,即与其他节点没有连线的节点,拖拽调整位置到连线上,本插件默认支持。关闭此功能设置如下:
24
+ ` ` ` js
25
+ InsertNodeInPolyline.dropAdd = false;
26
+ ` ` `
Original file line number Diff line number Diff line change
1
+ .circle .lf-dnd-shape {
2
+ display : inline-block;
3
+ width : 25px ;
4
+ height : 25px ;
5
+ border : 2px solid black;
6
+ border-radius : 20px ;
7
+ }
8
+ .rect .lf-dnd-shape {
9
+ display : inline-block;
10
+ width : 25px ;
11
+ height : 25px ;
12
+ border : 2px solid black;
13
+ }
Original file line number Diff line number Diff line change
1
+ import React , { useEffect } from 'react' ;
2
+ import LogicFlow from '@logicflow/core' ;
3
+ import { InsertNodeInPolyline , DndPanel , SelectionSelect } from '@logicflow/extension' ;
4
+ import ExampleHeader from '../../../components/example-header' ;
5
+ import 'antd/lib/button/style/index.css' ;
6
+ import './index.css' ;
7
+
8
+ const config = {
9
+ grid : {
10
+ type : 'dot' ,
11
+ size : 20 ,
12
+ } ,
13
+ }
14
+
15
+ const data = {
16
+ nodes : [
17
+ {
18
+ id : 10 ,
19
+ type : 'rect' ,
20
+ x : 150 ,
21
+ y : 70 ,
22
+ text : '矩形'
23
+ } ,
24
+ {
25
+ id : 20 ,
26
+ type : 'circle' ,
27
+ x : 400 ,
28
+ y : 70 ,
29
+ text : '圆形'
30
+ }
31
+ ] ,
32
+ edges : [
33
+ {
34
+ type : 'polyline' ,
35
+ sourceNodeId : 10 ,
36
+ targetNodeId : 20 ,
37
+ }
38
+ ]
39
+ } ;
40
+
41
+ const contentStyle = {
42
+ display : 'flex' ,
43
+ alignItems : 'center'
44
+ }
45
+
46
+ let lf : LogicFlow ;
47
+
48
+ export default function SnapshotExample ( ) {
49
+
50
+ useEffect ( ( ) => {
51
+ LogicFlow . use ( InsertNodeInPolyline ) ;
52
+ LogicFlow . use ( DndPanel ) ;
53
+ LogicFlow . use ( SelectionSelect ) ;
54
+ lf = new LogicFlow ( {
55
+ ...config ,
56
+ container : document . querySelector ( '#graph' ) as HTMLElement
57
+ } ) ;
58
+ lf . setPatternItems ( [
59
+ {
60
+ type : 'circle' ,
61
+ text : '圆形' ,
62
+ className : 'circle'
63
+ } ,
64
+ {
65
+ type : 'rect' ,
66
+ text : '矩形' ,
67
+ className : 'rect'
68
+ } ,
69
+ ] ) ;
70
+ lf . render ( data )
71
+ } , [ ] ) ;
72
+
73
+ return (
74
+ < >
75
+ < ExampleHeader contentStyle = { contentStyle } >
76
+ 拖拽节点到线中间进行节点插入:
77
+ </ ExampleHeader >
78
+ < div id = "graph" className = "viewport" />
79
+ </ >
80
+ )
81
+ }
82
+
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import Approve from './pages/usage/approve';
31
31
import ApprovePreview from './pages/usage/approvePreview' ;
32
32
import BpmnElements from './pages/extension/bpmn/Elements' ;
33
33
import AdapterExample from './pages/extension/adapter' ;
34
+ import InserNodeInPolyline from './pages/extension/InserNodeInPolyline' ;
34
35
35
36
36
37
export default (
@@ -62,6 +63,7 @@ export default (
62
63
< Route path = "/extension/bpmn-elements" exact component = { BpmnElements } />
63
64
< Route path = "/extension/adapter" exact component = { AdapterExample } />
64
65
< Route path = "/extension/node-resize" exact component = { NodeResizeExample } />
66
+ < Route path = "/extension/InserNodeInPolyline" exact component = { InserNodeInPolyline } />
65
67
< Route path = "/usage/bpmn" exact component = { Bpmn } />
66
68
< Route path = "/usage/approve" exact component = { Approve } />
67
69
< Route path = "/usage/approve/preview" exact component = { ApprovePreview } />
You can’t perform that action at this time.
0 commit comments