Skip to content

Commit c6cbfd5

Browse files
authored
Merge pull request #5 from yhlchao/master
feat(extension): v0.2.0
2 parents 4b01254 + ee67636 commit c6cbfd5

File tree

74 files changed

+1369
-418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1369
-418
lines changed

examples/src/App.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414

1515
.viewport {
1616
height: 100%;
17+
overflow: hidden;
18+
position: relative;
1719
}

examples/src/components/example-header/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
margin-bottom: 10px;
44
border-bottom: 1px rgb(230, 230, 230) solid;
55
color: rgb(90, 90, 90);
6+
flex-shrink: 0;
67
display: flex;
78
justify-content: space-between;
89
align-items: center;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
type RegisterProcessType = {
2+
LineEdge: any;
3+
LineEdgeModel: any;
4+
};
5+
6+
export const registerProcess: any = ({
7+
LineEdge,
8+
LineEdgeModel,
9+
}: RegisterProcessType) => {
10+
class ProcessView extends LineEdge {
11+
getAttributes() {
12+
const attr = super.getAttributes();
13+
if (attr.properties.isExecuted) {
14+
attr.stroke = 'green';
15+
}
16+
return attr;
17+
}
18+
getArrowStyle() {
19+
const style = super.getArrowStyle();
20+
style.fill = "transparent";
21+
return style;
22+
}
23+
}
24+
return {
25+
view: ProcessView,
26+
model: LineEdgeModel,
27+
};
28+
};

examples/src/pages/advance/custom-edge/index.tsx renamed to examples/src/pages/advance/custom-edge/arrow/index.tsx

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,72 @@
11
import React, { useEffect } from 'react';
22
import LogicFlow from '@logicflow/core';
3-
import { registerCustomPolylineEdge } from './customPolylineEdge';
3+
import { registerProcess } from './arrow';
44

55
const config = {
66
stopScrollGraph: true,
77
stopZoomGraph: true,
8-
tool: {
9-
menu: false,
10-
control: false
11-
}
128
};
139

1410
const data = {
1511
nodes: [
1612
{
1713
id: 10,
1814
type: 'rect',
19-
x: 150,
20-
y: 70,
21-
text: '矩形'
15+
x: 100,
16+
y: 110,
17+
text: '审批通过'
2218
},
2319
{
2420
id: 20,
25-
type: 'circle',
26-
x: 400,
27-
y: 70,
28-
text: '圆形'
21+
type: 'rect',
22+
x: 300,
23+
y: 110,
24+
text: '审批中'
25+
},
26+
{
27+
id: 30,
28+
type: 'rect',
29+
x: 500,
30+
y: 110,
31+
text: '未开始'
2932
}
3033
],
3134
edges: [
3235
{
33-
type: 'customPolyline',
36+
type: 'process',
3437
sourceNodeId: 10,
3538
targetNodeId: 20,
36-
text: '自定义直角折线和箭头',
3739
startPoint: {
3840
id: '150-110',
3941
x: 150,
4042
y: 110
4143
},
4244
endPoint: {
43-
id: '150-60',
44-
x: 400,
45-
y: 120
45+
id: '250-110',
46+
x: 250,
47+
y: 110
4648
},
4749
properties: {
4850
isExecuted: true
4951
}
52+
},
53+
{
54+
type: 'process',
55+
sourceNodeId: 20,
56+
targetNodeId: 30,
57+
startPoint: {
58+
id: '350-110',
59+
x: 350,
60+
y: 110
61+
},
62+
endPoint: {
63+
id: '450-110',
64+
x: 450,
65+
y: 110
66+
},
67+
properties: {
68+
isExecuted: false
69+
}
5070
}
5171
]
5272
};
@@ -58,7 +78,7 @@ export default function CustomEdgeExample() {
5878
...config,
5979
container: document.querySelector('#graph') as HTMLElement
6080
});
61-
lf.register('customPolyline', registerCustomPolylineEdge);
81+
lf.register('process', registerProcess);
6282
lf.render(data);
6383
}, []);
6484

examples/src/pages/advance/custom-edge/customPolylineEdge.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, { useEffect } from 'react';
2+
import LogicFlow from '@logicflow/core';
3+
import { registerProcess } from './process';
4+
5+
const config = {
6+
stopScrollGraph: true,
7+
stopZoomGraph: true,
8+
};
9+
10+
const data = {
11+
nodes: [
12+
{
13+
id: 10,
14+
type: 'rect',
15+
x: 100,
16+
y: 110,
17+
text: '审批通过'
18+
},
19+
{
20+
id: 20,
21+
type: 'rect',
22+
x: 300,
23+
y: 110,
24+
text: '审批中'
25+
},
26+
{
27+
id: 30,
28+
type: 'rect',
29+
x: 500,
30+
y: 110,
31+
text: '未开始'
32+
}
33+
],
34+
edges: [
35+
{
36+
type: 'process',
37+
sourceNodeId: 10,
38+
targetNodeId: 20,
39+
startPoint: {
40+
id: '150-110',
41+
x: 150,
42+
y: 110
43+
},
44+
endPoint: {
45+
id: '250-110',
46+
x: 250,
47+
y: 110
48+
},
49+
properties: {
50+
isExecuted: true
51+
}
52+
},
53+
{
54+
type: 'process',
55+
sourceNodeId: 20,
56+
targetNodeId: 30,
57+
startPoint: {
58+
id: '350-110',
59+
x: 350,
60+
y: 110
61+
},
62+
endPoint: {
63+
id: '450-110',
64+
x: 450,
65+
y: 110
66+
},
67+
properties: {
68+
isExecuted: false
69+
}
70+
}
71+
]
72+
};
73+
74+
export default function CustomEdgeExample() {
75+
76+
useEffect(() => {
77+
const lf = new LogicFlow({
78+
...config,
79+
container: document.querySelector('#graph') as HTMLElement
80+
});
81+
lf.register('process', registerProcess);
82+
lf.render(data);
83+
}, []);
84+
85+
return <div id="graph" className="viewport" />;
86+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
type RegisterProcessType = {
2+
LineEdge: any;
3+
LineEdgeModel: any;
4+
};
5+
6+
export const registerProcess: any = ({
7+
LineEdge,
8+
LineEdgeModel,
9+
}: RegisterProcessType) => {
10+
class ProcessView extends LineEdge {
11+
getAttributes() {
12+
const attr = super.getAttributes();
13+
if (attr.properties.isExecuted) {
14+
attr.stroke = "green";
15+
}
16+
return attr;
17+
}
18+
}
19+
return {
20+
view: ProcessView,
21+
model: LineEdgeModel,
22+
};
23+
};

examples/src/pages/advance/custom-node/properties/beginNode.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/src/pages/advance/custom-node/properties/index.tsx

Lines changed: 0 additions & 48 deletions
This file was deleted.

examples/src/pages/advance/custom-node/edge/index.tsx renamed to examples/src/pages/advance/custom-node/rule/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import React, { useEffect } from 'react';
22
import LogicFlow from '@logicflow/core';
33
import { registerGatewayNode } from './gatewayNode';
4-
import { registerUserTaskNode } from '../content/userTaskNode';
4+
import { registerUserTaskNode } from '../userTask/userTask';
55
import ExampleHeader from '../../../../components/example-header';
66

77
const config = {
88
stopScrollGraph: true,
99
stopZoomGraph: true,
10-
tool: {
11-
menu: false,
12-
control: false
13-
},
1410
style: {
1511
circle: {
1612
r: 40

examples/src/pages/advance/custom-node/shape/index.tsx renamed to examples/src/pages/advance/custom-node/triangle/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ const config = {
66
isSilentMode: true,
77
stopScrollGraph: true,
88
stopZoomGraph: true,
9-
tool: {
10-
menu: false,
11-
control: false
12-
}
139
};
1410

1511
const data = {

0 commit comments

Comments
 (0)