File tree Expand file tree Collapse file tree 3 files changed +64
-40
lines changed Expand file tree Collapse file tree 3 files changed +64
-40
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ const data = {
98
98
] ,
99
99
edges : [
100
100
{
101
- type : 'polyline' ,
101
+ // type: 'polyline',
102
102
sourceNodeId : '1' ,
103
103
targetNodeId : '2' ,
104
104
} ,
Original file line number Diff line number Diff line change @@ -73,46 +73,58 @@ const lf = new LogicFlow({
73
73
plugins: [Menu],
74
74
});
75
75
// Append options to the menu (must be set before lf.render())
76
+ // we can use `lf.addMenuConfig` to add menu options as other options
76
77
lf .extension .menu .addMenuConfig ({
77
78
nodeMenu: [
78
79
{
79
- text: " share " ,
80
+ text: ' 分享 ' ,
80
81
callback () {
81
- alert (" share success! " );
82
+ alert (' 分享成功! ' )
82
83
},
83
84
},
84
85
{
85
- text: " properties " ,
86
- callback (node : any ) {
86
+ text: ' 属性 ' ,
87
+ callback (node : NodeData ) {
87
88
alert (`
88
- nodeId:${ node .id }
89
- nodeType:${ node .type }
90
- nodeCoordinate:(x: ${ node .x } , y: ${ node .y } )` );
89
+ 节点id:${ node .id }
90
+ 节点类型:${ node .type }
91
+ 节点坐标:(x: ${ node .x } , y: ${ node .y } )
92
+ ` )
91
93
},
92
94
},
93
95
],
94
96
edgeMenu: [
95
97
{
96
- text: " properties" ,
97
- callback (edge : any ) {
98
+ text: ' 属性' ,
99
+ callback (edge : EdgeData ) {
100
+ const {
101
+ id ,
102
+ type ,
103
+ startPoint ,
104
+ endPoint ,
105
+ sourceNodeId ,
106
+ targetNodeId ,
107
+ } = edge
98
108
alert (`
99
- edgeId:${ edge .id }
100
- edgeType:${ edge .type }
101
- edgeCoordinate:(x: ${ edge .x } , y: ${ edge .y } )
102
- sourceNodeId:${ edge .sourceNodeId }
103
- targetNodeId:${ edge .targetNodeId } ` );
109
+ 边id:${ id}
110
+ 边类型:${ type}
111
+ 边起点坐标:(startPoint: [${ startPoint .x } , ${ startPoint .y } ])
112
+ 边终点坐标:(endPoint: [${ endPoint .x } , ${ endPoint .y } ])
113
+ 源节点id:${ sourceNodeId}
114
+ 目标节点id:${ targetNodeId}
115
+ ` )
104
116
},
105
117
},
106
118
],
107
119
graphMenu: [
108
120
{
109
- text: " share " ,
121
+ text: ' 分享 ' ,
110
122
callback () {
111
- alert (" share success! " );
123
+ alert (' 分享成功! ' )
112
124
},
113
125
},
114
126
],
115
- });
127
+ })
116
128
lf .render ();
117
129
```
118
130
Original file line number Diff line number Diff line change @@ -65,57 +65,69 @@ LogicFlow.use(Menu);
65
65
通过` lf.extension.menu.addMenuConfig ` 方法可以在原有菜单的基础上追加新的选项,具体配置示例如下:
66
66
67
67
``` jsx | purex | pure
68
- import LogicFlow from " @logicflow/core" ;
69
- import { Menu } from " @logicflow/extension" ;
68
+ import LogicFlow from ' @logicflow/core'
69
+ import { Menu } from ' @logicflow/extension'
70
70
71
71
// 实例化 Logic Flow
72
72
const lf = new LogicFlow ({
73
- container: document .getElementById (" app" ),
73
+ container: document .getElementById (' app' ),
74
74
// 注册组件
75
75
plugins: [Menu],
76
- });
76
+ })
77
77
// 为菜单追加选项(必须在 lf.render() 之前设置)
78
+ // 或者直接通过 lf.addMenuConfig 也可以调用
78
79
lf .extension .menu .addMenuConfig ({
79
80
nodeMenu: [
80
81
{
81
- text: " 分享 " ,
82
+ text: ' 分享 ' ,
82
83
callback () {
83
- alert (" 分享成功!" );
84
+ alert (' 分享成功!' )
84
85
},
85
86
},
86
87
{
87
- text: " 属性 " ,
88
- callback (node : any ) {
88
+ text: ' 属性 ' ,
89
+ callback (node : NodeData ) {
89
90
alert (`
90
- 节点id:${ node .id }
91
- 节点类型:${ node .type }
92
- 节点坐标:(x: ${ node .x } , y: ${ node .y } )` );
91
+ 节点id:${ node .id }
92
+ 节点类型:${ node .type }
93
+ 节点坐标:(x: ${ node .x } , y: ${ node .y } )
94
+ ` )
93
95
},
94
96
},
95
97
],
96
98
edgeMenu: [
97
99
{
98
- text: " 属性" ,
99
- callback (edge : any ) {
100
+ text: ' 属性' ,
101
+ callback (edge : EdgeData ) {
102
+ const {
103
+ id ,
104
+ type ,
105
+ startPoint ,
106
+ endPoint ,
107
+ sourceNodeId ,
108
+ targetNodeId ,
109
+ } = edge
100
110
alert (`
101
- 边id:${ edge .id }
102
- 边类型:${ edge .type }
103
- 边坐标:(x: ${ edge .x } , y: ${ edge .y } )
104
- 源节点id:${ edge .sourceNodeId }
105
- 目标节点id:${ edge .targetNodeId } ` );
111
+ 边id:${ id}
112
+ 边类型:${ type}
113
+ 边起点坐标:(startPoint: [${ startPoint .x } , ${ startPoint .y } ])
114
+ 边终点坐标:(endPoint: [${ endPoint .x } , ${ endPoint .y } ])
115
+ 源节点id:${ sourceNodeId}
116
+ 目标节点id:${ targetNodeId}
117
+ ` )
106
118
},
107
119
},
108
120
],
109
121
graphMenu: [
110
122
{
111
- text: " 分享 " ,
123
+ text: ' 分享 ' ,
112
124
callback () {
113
- alert (" 分享成功!" );
125
+ alert (' 分享成功!' )
114
126
},
115
127
},
116
128
],
117
- });
118
- lf .render ();
129
+ })
130
+ lf .render ()
119
131
```
120
132
121
133
## 重置菜单
You can’t perform that action at this time.
0 commit comments