File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,16 @@ export default function MenuExtension() {
171
171
alert ( '分享成功!' )
172
172
} ,
173
173
} ,
174
+ {
175
+ text : '添加节点' ,
176
+ callback ( data : LogicFlow . Position ) {
177
+ lf . addNode ( {
178
+ type : 'rect' ,
179
+ x : data . x ,
180
+ y : data . y ,
181
+ } )
182
+ } ,
183
+ } ,
174
184
] ,
175
185
} )
176
186
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import LogicFlow from '@logicflow/core'
3
3
import GraphData = LogicFlow . GraphData
4
4
import NodeData = LogicFlow . NodeData
5
5
import EdgeData = LogicFlow . EdgeData
6
+ import Position = LogicFlow . Position
6
7
7
8
type SetType = 'add' | 'reset'
8
9
@@ -29,7 +30,8 @@ class Menu {
29
30
private __container ?: HTMLElement
30
31
private __menuDOM ?: HTMLElement
31
32
private menuTypeMap ?: Map < string , MenuItem [ ] >
32
- private __currentData : EdgeData | NodeData | GraphData | null = null
33
+ private __currentData : EdgeData | NodeData | GraphData | Position | null =
34
+ null
33
35
static pluginName = 'menu'
34
36
35
37
constructor ( { lf } ) {
@@ -209,6 +211,7 @@ class Menu {
209
211
const {
210
212
domOverlayPosition : { x, y } ,
211
213
} = position
214
+ this . __currentData = { ...position . canvasOverlayPosition }
212
215
this . showMenu ( x , y , menuList )
213
216
} )
214
217
this . lf . on ( 'selection:contextmenu' , ( { data, position } ) => {
You can’t perform that action at this time.
0 commit comments