File size: 22,361 Bytes
8866644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
import {app} from "../../../../scripts/app.js";
import {api} from "../../../../scripts/api.js";
import {$el} from "../../../../scripts/ui.js";

const propmts = ["easy wildcards", "easy positive", "easy negative", "easy stylesSelector", "easy promptConcat", "easy promptReplace"]
const loaders = ["easy a1111Loader", "easy comfyLoader", "easy fullLoader", "easy svdLoader", "easy cascadeLoader", "easy sv3dLoader"]
const preSamplingNodes = ["easy preSampling", "easy preSamplingAdvanced", "easy preSamplingNoiseIn", "easy preSamplingCustom", "easy preSamplingDynamicCFG","easy preSamplingSdTurbo", "easy preSamplingLayerDiffusion"]
const kSampler = ["easy kSampler", "easy kSamplerTiled","easy kSamplerInpainting", "easy kSamplerDownscaleUnet", "easy kSamplerSDTurbo"]
const controlNetNodes = ["easy controlnetLoader", "easy controlnetLoaderADV"]
const instantIDNodes = ["easy instantIDApply", "easy instantIDApplyADV"]
const ipadapterNodes = ["easy ipadapterApply", "easy ipadapterApplyADV" , "easy ipadapterStyleComposition"]
const pipeNodes = ['easy pipeIn','easy pipeOut', 'easy pipeEdit']
const xyNodes = ['easy XYPlot', 'easy XYPlotAdvanced']
const extraNodes = ['easy setNode']
const modelNormalNodes = [...["Reroute"],...['RescaleCFG','LoraLoaderModelOnly','LoraLoader','FreeU','FreeU_v2'],...ipadapterNodes,...extraNodes]
const suggestions = {
    // prompt
    "easy seed":{
        "from":{
            "INT": [...["Reroute"],...preSamplingNodes,...['easy fullkSampler']]
        }
    },
    "easy positive":{
       "from":{
           "STRING": [...["Reroute"],...propmts]
       }
    },
    "easy negative":{
       "from":{
           "STRING": [...["Reroute"],...propmts]
       }
    },
    "easy wildcards":{
        "from":{
           "STRING": [...["Reroute","easy showAnything"],...propmts,]
       }
    },
    "easy stylesSelector":{
        "from":{
           "STRING": [...["Reroute","easy showAnything"],...propmts,]
       }
    },
    "easy promptConcat":{
        "from":{
           "STRING": [...["Reroute","easy showAnything"],...propmts,]
       }
    },
    "easy promptReplace":{
        "from":{
           "STRING": [...["Reroute","easy showAnything"],...propmts,]
       }
    },
    // sd相关
    "easy fullLoader": {
        "from":{
            "PIPE_LINE": [...["Reroute"],...preSamplingNodes,...['easy fullkSampler'],...pipeNodes,...extraNodes],
            "MODEL":modelNormalNodes
        },
        "to":{
            "STRING": [...["Reroute"],...propmts]
        }
    },
    "easy a1111Loader": {
        "from": {
            "PIPE_LINE": [...["Reroute"], ...preSamplingNodes, ...controlNetNodes, ...instantIDNodes, ...pipeNodes, ...extraNodes],
            "MODEL": modelNormalNodes
        },
        "to":{
            "STRING": [...["Reroute"],...propmts]
        }
    },
    "easy comfyLoader": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...preSamplingNodes, ...controlNetNodes, ...instantIDNodes, ...pipeNodes, ...extraNodes],
             "MODEL": modelNormalNodes
         },
        "to":{
            "STRING": [...["Reroute"],...propmts]
        }
    },
    "easy svdLoader":{
         "from": {
             "PIPE_LINE": [...["Reroute"], ...["easy preSampling", "easy preSamplingAdvanced", "easy preSamplingDynamicCFG"], ...pipeNodes, ...extraNodes],
             "MODEL": modelNormalNodes
         },
         "to":{
            "STRING": [...["Reroute"],...propmts]
         }
    },
    "easy zero123Loader":{
         "from": {
             "PIPE_LINE": [...["Reroute"], ...["easy preSampling", "easy preSamplingAdvanced", "easy preSamplingDynamicCFG"], ...pipeNodes, ...extraNodes],
             "MODEL": modelNormalNodes
         },
         "to":{
            "STRING": [...["Reroute"],...propmts]
         }
    },
    "easy sv3dLoader":{
         "from": {
             "PIPE_LINE": [...["Reroute"], ...["easy preSampling", "easy preSamplingAdvanced", "easy preSamplingDynamicCFG"], ...pipeNodes, ...extraNodes],
             "MODEL": modelNormalNodes
         },
         "to":{
            "STRING": [...["Reroute"],...propmts]
         }
    },
    "easy preSampling": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...kSampler, ...pipeNodes, ...controlNetNodes, ...xyNodes, ...extraNodes]
         },
    },
    "easy preSamplingAdvanced": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...kSampler, ...pipeNodes, ...controlNetNodes, ...xyNodes, ...extraNodes]
         }
    },
    "easy preSamplingDynamicCFG": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...kSampler, ...pipeNodes, ...controlNetNodes, ...xyNodes, ...extraNodes]
         }
    },
     "easy preSamplingCustom": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...kSampler, ...pipeNodes, ...controlNetNodes, ...xyNodes, ...extraNodes]
         }
    },
    "easy preSamplingLayerDiffusion": {
         "from": {
             "PIPE_LINE": [...["Reroute", "easy kSamplerLayerDiffusion"], ...kSampler, ...pipeNodes, ...controlNetNodes, ...xyNodes, ...extraNodes]
         }
    },
    "easy preSamplingNoiseIn": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...kSampler, ...pipeNodes, ...controlNetNodes, ...xyNodes, ...extraNodes]
         }
    },
    // ksampler
    "easy fullkSampler": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...pipeNodes.reverse(), ...['easy preDetailerFix', 'easy preMaskDetailerFix'], ...preSamplingNodes, ...extraNodes]
         }
    },
    "easy kSampler": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...pipeNodes.reverse(), ...['easy preDetailerFix', 'easy preMaskDetailerFix', 'easy hiresFix'], ...preSamplingNodes, ...extraNodes],
         }
    },
    // cn
    "easy controlnetLoader": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...preSamplingNodes, ...controlNetNodes, ...instantIDNodes, ...pipeNodes, ...extraNodes]
         }
    },
    "easy controlnetLoaderADV":{
         "from": {
             "PIPE_LINE": [...["Reroute"], ...preSamplingNodes, ...controlNetNodes, ...instantIDNodes, ...pipeNodes, ...extraNodes]
         }
    },
    // instant
    "easy instantIDApply": {
        "from": {
            "PIPE_LINE": [...["Reroute"], ...preSamplingNodes, ...controlNetNodes, ...instantIDNodes, ...pipeNodes, ...extraNodes],
             "MODEL": modelNormalNodes
        },
        "to":{
            "COMBO": [...["Reroute", "easy promptLine"]]
        }
    },
    "easy instantIDApplyADV":{
        "from": {
            "PIPE_LINE": [...["Reroute"], ...preSamplingNodes, ...controlNetNodes, ...instantIDNodes, ...pipeNodes, ...extraNodes],
            "MODEL": modelNormalNodes
        },
        "to":{
            "COMBO": [...["Reroute", "easy promptLine"]]
        }
    },
    "easy ipadapterApply":{
        "to":{
            "COMBO": [...["Reroute", "easy promptLine"]]
        }
    },
    "easy ipadapterApplyADV":{
        "to":{
          "STRING": [...["Reroute", "easy sliderControl"], ...propmts],
          "COMBO": [...["Reroute", "easy promptLine"]]
        }
    },
    "easy ipadapterStyleComposition":{
        "to":{
            "COMBO": [...["Reroute", "easy promptLine"]]
        }
    },
    // fix
    "easy preDetailerFix":{
        "from": {
            "PIPE_LINE": [...["Reroute", "easy detailerFix"], ...pipeNodes, ...extraNodes]
        },
        "to":{
            "PIPE_LINE": [...["Reroute", "easy ultralyticsDetectorPipe", "easy samLoaderPipe", "easy kSampler", "easy fullkSampler"]]
        }
    },
    "easy preMaskDetailerFix":{
        "from": {
            "PIPE_LINE": [...["Reroute", "easy detailerFix"], ...pipeNodes, ...extraNodes]
        }
    },
    "easy samLoaderPipe": {
        "from":{
            "PIPE_LINE": [...["Reroute", "easy preDetailerFix"], ...pipeNodes, ...extraNodes]
        }
    },
    "easy ultralyticsDetectorPipe": {
        "from":{
            "PIPE_LINE": [...["Reroute", "easy preDetailerFix"], ...pipeNodes, ...extraNodes]
        }
    },
    // cascade相关
    "easy cascadeLoader":{
         "from": {
             "PIPE_LINE": [...["Reroute"], ...["easy fullCascadeKSampler", 'easy preSamplingCascade'], ...controlNetNodes, ...pipeNodes, ...extraNodes],
             "MODEL": modelNormalNodes.filter(cate => !ipadapterNodes.includes(cate))
         }
    },
    "easy fullCascadeKSampler":{
         "from": {
             "PIPE_LINE": [...["Reroute"], ...["easy preSampling", "easy preSamplingAdvanced"], ...pipeNodes, ...extraNodes]
         }
    },
    "easy preSamplingCascade":{
         "from": {
             "PIPE_LINE": [...["Reroute"], ...["easy cascadeKSampler",], ...pipeNodes, ...extraNodes]
         }
    },
    "easy cascadeKSampler": {
         "from": {
             "PIPE_LINE": [...["Reroute"], ...["easy preSampling", "easy preSamplingAdvanced"], ...pipeNodes, ...extraNodes]
         }
    },
}


app.registerExtension({
    name: "comfy.easyuse.suggestions",
    async setup(app) {
        LGraphCanvas.prototype.createDefaultNodeForSlot = function(optPass) { // addNodeMenu for connection
            var optPass = optPass || {};
            var opts = Object.assign({   nodeFrom: null // input
                                        ,slotFrom: null // input
                                        ,nodeTo: null   // output
                                        ,slotTo: null   // output
                                        ,position: []	// pass the event coords
                                        ,nodeType: null	// choose a nodetype to add, AUTO to set at first good
                                        ,posAdd:[0,0]	// adjust x,y
                                        ,posSizeFix:[0,0] // alpha, adjust the position x,y based on the new node size w,h
                                    }
                                    ,optPass
                                );
            var that = this;

            var isFrom = opts.nodeFrom && opts.slotFrom!==null;
            var isTo = !isFrom && opts.nodeTo && opts.slotTo!==null;

            if (!isFrom && !isTo){
                console.warn("No data passed to createDefaultNodeForSlot "+opts.nodeFrom+" "+opts.slotFrom+" "+opts.nodeTo+" "+opts.slotTo);
                return false;
            }
            if (!opts.nodeType){
                console.warn("No type to createDefaultNodeForSlot");
                return false;
            }

            var nodeX = isFrom ? opts.nodeFrom : opts.nodeTo;
            var slotX = isFrom ? opts.slotFrom : opts.slotTo;
            var nodeType = nodeX.type

            var iSlotConn = false;
            switch (typeof slotX){
                case "string":
                    iSlotConn = isFrom ? nodeX.findOutputSlot(slotX,false) : nodeX.findInputSlot(slotX,false);
                    slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX];
                break;
                case "object":
                    // ok slotX
                    iSlotConn = isFrom ? nodeX.findOutputSlot(slotX.name) : nodeX.findInputSlot(slotX.name);
                break;
                case "number":
                    iSlotConn = slotX;
                    slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX];
                break;
                case "undefined":
                default:
                    // bad ?
                    //iSlotConn = 0;
                    console.warn("Cant get slot information "+slotX);
                    return false;
            }

            if (slotX===false || iSlotConn===false){
                console.warn("createDefaultNodeForSlot bad slotX "+slotX+" "+iSlotConn);
            }

            // check for defaults nodes for this slottype
            var fromSlotType = slotX.type==LiteGraph.EVENT?"_event_":slotX.type;
            var slotTypesDefault = isFrom ? LiteGraph.slot_types_default_out : LiteGraph.slot_types_default_in;
            if(slotTypesDefault && slotTypesDefault[fromSlotType]){
                if (slotX.link !== null) {
                    // is connected
                }else{
                    // is not not connected
                }
                let nodeNewType = false;
                const fromOrTo = isFrom ? 'from' : 'to'
                if(suggestions[nodeType] && suggestions[nodeType][fromOrTo] && suggestions[nodeType][fromOrTo][fromSlotType]?.length>0){
                    for(var typeX in suggestions[nodeType][fromOrTo][fromSlotType]){
                        if (opts.nodeType == suggestions[nodeType][fromOrTo][fromSlotType][typeX] || opts.nodeType == "AUTO") {
                            nodeNewType = suggestions[nodeType][fromOrTo][fromSlotType][typeX];
                            break
                        }
                    }
                }
                else if(typeof slotTypesDefault[fromSlotType] == "object" || typeof slotTypesDefault[fromSlotType] == "array"){
                    for(var typeX in slotTypesDefault[fromSlotType]){
                        if (opts.nodeType == slotTypesDefault[fromSlotType][typeX] || opts.nodeType == "AUTO"){
                            nodeNewType = slotTypesDefault[fromSlotType][typeX];
                            // console.log("opts.nodeType == slotTypesDefault[fromSlotType][typeX] :: "+opts.nodeType);
                            break; // --------
                        }
                    }
                }else{
                    if (opts.nodeType == slotTypesDefault[fromSlotType] || opts.nodeType == "AUTO") nodeNewType = slotTypesDefault[fromSlotType];
                }
                if (nodeNewType) {
                    var nodeNewOpts = false;
                    if (typeof nodeNewType == "object" && nodeNewType.node){
                        nodeNewOpts = nodeNewType;
                        nodeNewType = nodeNewType.node;
                    }

                    //that.graph.beforeChange();

                    var newNode = LiteGraph.createNode(nodeNewType);
                    if(newNode){
                        // if is object pass options
                        if (nodeNewOpts){
                            if (nodeNewOpts.properties) {
                                for (var i in nodeNewOpts.properties) {
                                    newNode.addProperty( i, nodeNewOpts.properties[i] );
                                }
                            }
                            if (nodeNewOpts.inputs) {
                                newNode.inputs = [];
                                for (var i in nodeNewOpts.inputs) {
                                    newNode.addOutput(
                                        nodeNewOpts.inputs[i][0],
                                        nodeNewOpts.inputs[i][1]
                                    );
                                }
                            }
                            if (nodeNewOpts.outputs) {
                                newNode.outputs = [];
                                for (var i in nodeNewOpts.outputs) {
                                    newNode.addOutput(
                                        nodeNewOpts.outputs[i][0],
                                        nodeNewOpts.outputs[i][1]
                                    );
                                }
                            }
                            if (nodeNewOpts.title) {
                                newNode.title = nodeNewOpts.title;
                            }
                            if (nodeNewOpts.json) {
                                newNode.configure(nodeNewOpts.json);
                            }

                        }

                        // add the node
                        that.graph.add(newNode);
                        newNode.pos = [	opts.position[0]+opts.posAdd[0]+(opts.posSizeFix[0]?opts.posSizeFix[0]*newNode.size[0]:0)
                                        ,opts.position[1]+opts.posAdd[1]+(opts.posSizeFix[1]?opts.posSizeFix[1]*newNode.size[1]:0)]; //that.last_click_position; //[e.canvasX+30, e.canvasX+5];*/

                        //that.graph.afterChange();

                        // connect the two!
                        if (isFrom){
                            opts.nodeFrom.connectByType( iSlotConn, newNode, fromSlotType );
                        }else{
                            opts.nodeTo.connectByTypeOutput( iSlotConn, newNode, fromSlotType );
                        }

                        // if connecting in between
                        if (isFrom && isTo){
                            // TODO
                        }

                        return true;

                    }else{
                        console.log("failed creating "+nodeNewType);
                    }
                }
            }
            return false;
        }

        LGraphCanvas.prototype.showConnectionMenu = function(optPass) { // addNodeMenu for connection
            var optPass = optPass || {};
            var opts = Object.assign({   nodeFrom: null  // input
                                        ,slotFrom: null // input
                                        ,nodeTo: null   // output
                                        ,slotTo: null   // output
                                        ,e: null
                                    }
                                    ,optPass
                                );
            var that = this;

            var isFrom = opts.nodeFrom && opts.slotFrom;
            var isTo = !isFrom && opts.nodeTo && opts.slotTo;

            if (!isFrom && !isTo){
                console.warn("No data passed to showConnectionMenu");
                return false;
            }

            var nodeX = isFrom ? opts.nodeFrom : opts.nodeTo;
            var slotX = isFrom ? opts.slotFrom : opts.slotTo;

            var iSlotConn = false;
            switch (typeof slotX){
                case "string":
                    iSlotConn = isFrom ? nodeX.findOutputSlot(slotX,false) : nodeX.findInputSlot(slotX,false);
                    slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX];
                break;
                case "object":
                    // ok slotX
                    iSlotConn = isFrom ? nodeX.findOutputSlot(slotX.name) : nodeX.findInputSlot(slotX.name);
                break;
                case "number":
                    iSlotConn = slotX;
                    slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX];
                break;
                default:
                    // bad ?
                    //iSlotConn = 0;
                    console.warn("Cant get slot information "+slotX);
                    return false;
            }

            var options = ["Add Node",null];

            if (that.allow_searchbox){
                options.push("Search");
                options.push(null);
            }

            // get defaults nodes for this slottype
            var fromSlotType = slotX.type==LiteGraph.EVENT?"_event_":slotX.type;
            var slotTypesDefault = isFrom ? LiteGraph.slot_types_default_out : LiteGraph.slot_types_default_in;
            var nodeType = nodeX.type
            if(slotTypesDefault && slotTypesDefault[fromSlotType]){
                const fromOrTo = isFrom ? 'from' : 'to'
                if(suggestions[nodeType] && suggestions[nodeType][fromOrTo] && suggestions[nodeType][fromOrTo][fromSlotType]?.length>0){
                    for(var typeX in suggestions[nodeType][fromOrTo][fromSlotType]){
                        options.push(suggestions[nodeType][fromOrTo][fromSlotType][typeX]);
                    }
                }
                else if(typeof slotTypesDefault[fromSlotType] == "object" || typeof slotTypesDefault[fromSlotType] == "array"){
                    for(var typeX in slotTypesDefault[fromSlotType]){
                        options.push(slotTypesDefault[fromSlotType][typeX]);
                    }
                }else{
                    options.push(slotTypesDefault[fromSlotType]);
                }
            }

            // build menu
            var menu = new LiteGraph.ContextMenu(options, {
                event: opts.e,
                title: (slotX && slotX.name!="" ? (slotX.name + (fromSlotType?" | ":"")) : "")+(slotX && fromSlotType ? fromSlotType : ""),
                callback: inner_clicked
            });

            // callback
            function inner_clicked(v,options,e) {
                //console.log("Process showConnectionMenu selection");
                switch (v) {
                    case "Add Node":
                        LGraphCanvas.onMenuAdd(null, null, e, menu, function(node){
                            if (isFrom){
                                opts.nodeFrom.connectByType( iSlotConn, node, fromSlotType );
                            }else{
                                opts.nodeTo.connectByTypeOutput( iSlotConn, node, fromSlotType );
                            }
                        });
                        break;
                    case "Search":
                        if(isFrom){
                            that.showSearchBox(e,{node_from: opts.nodeFrom, slot_from: slotX, type_filter_in: fromSlotType});
                        }else{
                            that.showSearchBox(e,{node_to: opts.nodeTo, slot_from: slotX, type_filter_out: fromSlotType});
                        }
                        break;
                    default:
                        // check for defaults nodes for this slottype
                        var nodeCreated = that.createDefaultNodeForSlot(Object.assign(opts,{ position: [opts.e.canvasX, opts.e.canvasY]
                                                                                            ,nodeType: v
                                                                                        }));
                        if (nodeCreated){
                            // new node created
                            //console.log("node "+v+" created")
                        }else{
                            // failed or v is not in defaults
                        }
                        break;
                }
            }

            return false;
        };
    }
})