MCPcopy Index your code
hub / github.com/pythongosssss/ComfyUI-Custom-Scripts / beforeRegisterNodeDef

Function beforeRegisterNodeDef

web/js/workflows.js:307–342  ·  view source on GitHub ↗
(nodeType, nodeData, app)

Source from the content-addressed store, hash-verified

305 };
306 },
307 async beforeRegisterNodeDef(nodeType, nodeData, app) {
308 const getExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
309 nodeType.prototype.getExtraMenuOptions = function (_, options) {
310 const r = getExtraMenuOptions?.apply?.(this, arguments);
311 let img;
312 if (this.imageIndex != null) {
313 // An image is selected so select that
314 img = this.imgs[this.imageIndex];
315 } else if (this.overIndex != null) {
316 // No image is selected but one is hovered
317 img = this.imgs[this.overIndex];
318 }
319
320 if (img) {
321 let pos = options.findIndex((o) => o.content === "Save Image");
322 if (pos === -1) {
323 pos = 0;
324 } else {
325 pos++;
326 }
327
328 options.splice(pos, 0, {
329 content: "Send to workflow",
330 has_submenu: true,
331 submenu: {
332 options: [
333 { callback: () => sendToWorkflow(img), title: "[Current workflow]" },
334 ...workflows.getMenuOptions(sendToWorkflow.bind(null, img)),
335 ],
336 },
337 });
338 }
339
340 return r;
341 };
342 },
343});

Callers

nothing calls this directly

Calls 2

sendToWorkflowFunction · 0.85
getMenuOptionsMethod · 0.80

Tested by

no test coverage detected