diff --git a/src_web/comfyui/menu_auto_nest.ts b/src_web/comfyui/menu_auto_nest.ts index c9c1f7e..c1267ab 100644 --- a/src_web/comfyui/menu_auto_nest.ts +++ b/src_web/comfyui/menu_auto_nest.ts @@ -63,7 +63,7 @@ app.registerExtension({ } const newValue = typeof value === "string" ? { content: value } : Object.assign({}, value); newValue.rgthree_originalValue = value.rgthree_originalValue || value; - const valueContent = newValue.content; + const valueContent = newValue.content || ''; const splitBy = valueContent.indexOf("/") > -1 ? "/" : "\\"; const valueSplit = valueContent.split(splitBy); if (valueSplit.length > 1) { diff --git a/src_web/comfyui/menu_copy_image.ts b/src_web/comfyui/menu_copy_image.ts index 7c43436..c1a6e4a 100644 --- a/src_web/comfyui/menu_copy_image.ts +++ b/src_web/comfyui/menu_copy_image.ts @@ -43,7 +43,7 @@ app.registerExtension({ if (this.imgs?.length) { let img = this.imgs[this.imageIndex || 0] || this.imgs[this.overIndex || 0] || this.imgs[0]; - const foundIdx = options.findIndex((option) => option?.content.includes("Copy Image")); + const foundIdx = options.findIndex((option) => option?.content?.includes("Copy Image")); if (img && foundIdx === -1) { const menuItem: ContextMenuItem = { content: "Copy Image (rgthree)", @@ -58,7 +58,7 @@ app.registerExtension({ }); }, }; - let idx = options.findIndex((option) => option?.content.includes("Open Image")) + 1; + let idx = options.findIndex((option) => option?.content?.includes("Open Image")) + 1; if (idx != null) { options.splice(idx, 0, menuItem); } else { diff --git a/src_web/comfyui/menu_queue_node.ts b/src_web/comfyui/menu_queue_node.ts index a87c9e5..c31fe38 100644 --- a/src_web/comfyui/menu_queue_node.ts +++ b/src_web/comfyui/menu_queue_node.ts @@ -60,7 +60,7 @@ function showQueueGroupNodesMenuIfGroupIsSelected(existingOptions: ContextMenuIt disabled: !outputNodes?.length, }; - let idx = existingOptions.findIndex((o) => o?.content.startsWith("Queue Selected ")) + 1; + let idx = existingOptions.findIndex((o) => o?.content?.startsWith("Queue Selected ")) + 1; idx = idx || existingOptions.findIndex((o) => o?.content === "Outputs") + 1; idx = idx || existingOptions.findIndex((o) => o?.content === "Align") + 1; idx = idx || 3; diff --git a/src_web/comfyui/utils.ts b/src_web/comfyui/utils.ts index 1cb1a9a..ec78309 100644 --- a/src_web/comfyui/utils.ts +++ b/src_web/comfyui/utils.ts @@ -133,7 +133,7 @@ export function addMenuItemOnExtraMenuOptions( .reverse() .findIndex((option) => (option as any)?.isRgthree); if (idx == -1) { - idx = menuOptions.findIndex((option) => option?.content.includes(after)) + 1; + idx = menuOptions.findIndex((option) => option?.content?.includes(after)) + 1; if (!idx) { idx = menuOptions.length - 1; } @@ -176,8 +176,8 @@ export function addMenuItemOnExtraMenuOptions( if (config.property) { node.properties = node.properties || {}; node.properties[config.property] = config.prepareValue - ? config.prepareValue(subValue!.content, node) - : subValue!.content; + ? config.prepareValue(subValue!.content || '', node) + : subValue!.content || ''; } config.callback && config.callback(node, subValue?.content); }, diff --git a/src_web/typings/litegraph.d.ts b/src_web/typings/litegraph.d.ts index 2c41f27..5bbc238 100644 --- a/src_web/typings/litegraph.d.ts +++ b/src_web/typings/litegraph.d.ts @@ -175,7 +175,8 @@ export interface ITextWidget extends IWidget { } export interface IContextMenuItem { - content: string; + // @rgthree - Make optional because, I guess it is? + content?: string; value?: any; callback?: ContextMenuEventListener; /** Used as innerHTML for extra child element */ diff --git a/web/comfyui/menu_auto_nest.js b/web/comfyui/menu_auto_nest.js index e56d44a..da251ce 100644 --- a/web/comfyui/menu_auto_nest.js +++ b/web/comfyui/menu_auto_nest.js @@ -42,7 +42,7 @@ app.registerExtension({ } const newValue = typeof value === "string" ? { content: value } : Object.assign({}, value); newValue.rgthree_originalValue = value.rgthree_originalValue || value; - const valueContent = newValue.content; + const valueContent = newValue.content || ''; const splitBy = valueContent.indexOf("/") > -1 ? "/" : "\\"; const valueSplit = valueContent.split(splitBy); if (valueSplit.length > 1) { diff --git a/web/comfyui/menu_copy_image.js b/web/comfyui/menu_copy_image.js index 3119ba8..4a0be8f 100644 --- a/web/comfyui/menu_copy_image.js +++ b/web/comfyui/menu_copy_image.js @@ -30,7 +30,7 @@ app.registerExtension({ getExtraMenuOptions ? getExtraMenuOptions.apply(this, arguments) : undefined; if ((_a = this.imgs) === null || _a === void 0 ? void 0 : _a.length) { let img = this.imgs[this.imageIndex || 0] || this.imgs[this.overIndex || 0] || this.imgs[0]; - const foundIdx = options.findIndex((option) => option === null || option === void 0 ? void 0 : option.content.includes("Copy Image")); + const foundIdx = options.findIndex((option) => { var _a; return (_a = option === null || option === void 0 ? void 0 : option.content) === null || _a === void 0 ? void 0 : _a.includes("Copy Image"); }); if (img && foundIdx === -1) { const menuItem = { content: "Copy Image (rgthree)", @@ -45,7 +45,7 @@ app.registerExtension({ }); }, }; - let idx = options.findIndex((option) => option === null || option === void 0 ? void 0 : option.content.includes("Open Image")) + 1; + let idx = options.findIndex((option) => { var _a; return (_a = option === null || option === void 0 ? void 0 : option.content) === null || _a === void 0 ? void 0 : _a.includes("Open Image"); }) + 1; if (idx != null) { options.splice(idx, 0, menuItem); } diff --git a/web/comfyui/menu_queue_node.js b/web/comfyui/menu_queue_node.js index e857f70..2f28fb3 100644 --- a/web/comfyui/menu_queue_node.js +++ b/web/comfyui/menu_queue_node.js @@ -41,7 +41,7 @@ function showQueueGroupNodesMenuIfGroupIsSelected(existingOptions) { }, disabled: !(outputNodes === null || outputNodes === void 0 ? void 0 : outputNodes.length), }; - let idx = existingOptions.findIndex((o) => o === null || o === void 0 ? void 0 : o.content.startsWith("Queue Selected ")) + 1; + let idx = existingOptions.findIndex((o) => { var _a; return (_a = o === null || o === void 0 ? void 0 : o.content) === null || _a === void 0 ? void 0 : _a.startsWith("Queue Selected "); }) + 1; idx = idx || existingOptions.findIndex((o) => (o === null || o === void 0 ? void 0 : o.content) === "Outputs") + 1; idx = idx || existingOptions.findIndex((o) => (o === null || o === void 0 ? void 0 : o.content) === "Align") + 1; idx = idx || 3; diff --git a/web/comfyui/utils.js b/web/comfyui/utils.js index 4ea14e3..dad76b2 100644 --- a/web/comfyui/utils.js +++ b/web/comfyui/utils.js @@ -76,7 +76,7 @@ export function addMenuItemOnExtraMenuOptions(node, config, menuOptions, after = .reverse() .findIndex((option) => option === null || option === void 0 ? void 0 : option.isRgthree); if (idx == -1) { - idx = menuOptions.findIndex((option) => option === null || option === void 0 ? void 0 : option.content.includes(after)) + 1; + idx = menuOptions.findIndex((option) => { var _a; return (_a = option === null || option === void 0 ? void 0 : option.content) === null || _a === void 0 ? void 0 : _a.includes(after); }) + 1; if (!idx) { idx = menuOptions.length - 1; } @@ -102,8 +102,8 @@ export function addMenuItemOnExtraMenuOptions(node, config, menuOptions, after = if (config.property) { node.properties = node.properties || {}; node.properties[config.property] = config.prepareValue - ? config.prepareValue(subValue.content, node) - : subValue.content; + ? config.prepareValue(subValue.content || '', node) + : subValue.content || ''; } config.callback && config.callback(node, subValue === null || subValue === void 0 ? void 0 : subValue.content); },