mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
[Refactor] Move isImageNode to litegraphUtil (#2450)
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
|||||||
} from '@/types/comfyWorkflow'
|
} from '@/types/comfyWorkflow'
|
||||||
import { ExtensionManager } from '@/types/extensionTypes'
|
import { ExtensionManager } from '@/types/extensionTypes'
|
||||||
import { ColorAdjustOptions, adjustColor } from '@/utils/colorUtil'
|
import { ColorAdjustOptions, adjustColor } from '@/utils/colorUtil'
|
||||||
|
import { isImageNode } from '@/utils/litegraphUtil'
|
||||||
import { deserialiseAndCreate } from '@/utils/vintageClipboard'
|
import { deserialiseAndCreate } from '@/utils/vintageClipboard'
|
||||||
|
|
||||||
import { type ComfyApi, api } from './api'
|
import { type ComfyApi, api } from './api'
|
||||||
@@ -185,6 +186,13 @@ export class ComfyApp {
|
|||||||
return useExecutionStore()._executingNodeProgress
|
return useExecutionStore()._executingNodeProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link isImageNode} from @/utils/litegraphUtil instead
|
||||||
|
*/
|
||||||
|
static isImageNode(node: LGraphNode) {
|
||||||
|
return isImageNode(node)
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.vueAppReady = false
|
this.vueAppReady = false
|
||||||
this.ui = new ComfyUI(this)
|
this.ui = new ComfyUI(this)
|
||||||
@@ -232,15 +240,6 @@ export class ComfyApp {
|
|||||||
return '&rand=' + Math.random()
|
return '&rand=' + Math.random()
|
||||||
}
|
}
|
||||||
|
|
||||||
static isImageNode(node) {
|
|
||||||
return (
|
|
||||||
node.imgs ||
|
|
||||||
(node &&
|
|
||||||
node.widgets &&
|
|
||||||
node.widgets.findIndex((obj) => obj.name === 'image') >= 0)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
static onClipspaceEditorSave() {
|
static onClipspaceEditorSave() {
|
||||||
if (ComfyApp.clipspace_return_node) {
|
if (ComfyApp.clipspace_return_node) {
|
||||||
ComfyApp.pasteFromClipspace(ComfyApp.clipspace_return_node)
|
ComfyApp.pasteFromClipspace(ComfyApp.clipspace_return_node)
|
||||||
@@ -502,7 +501,7 @@ export class ComfyApp {
|
|||||||
if (
|
if (
|
||||||
this.canvas.current_node &&
|
this.canvas.current_node &&
|
||||||
this.canvas.current_node.is_selected &&
|
this.canvas.current_node.is_selected &&
|
||||||
ComfyApp.isImageNode(this.canvas.current_node)
|
isImageNode(this.canvas.current_node)
|
||||||
) {
|
) {
|
||||||
imageNode = this.canvas.current_node
|
imageNode = this.canvas.current_node
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { useToastStore } from '@/stores/toastStore'
|
|||||||
import { ComfyNodeDef, ExecutedWsMessage } from '@/types/apiTypes'
|
import { ComfyNodeDef, ExecutedWsMessage } from '@/types/apiTypes'
|
||||||
import type { NodeId } from '@/types/comfyWorkflow'
|
import type { NodeId } from '@/types/comfyWorkflow'
|
||||||
import { normalizeI18nKey } from '@/utils/formatUtil'
|
import { normalizeI18nKey } from '@/utils/formatUtil'
|
||||||
|
import { isImageNode } from '@/utils/litegraphUtil'
|
||||||
|
|
||||||
import { useExtensionService } from './extensionService'
|
import { useExtensionService } from './extensionService'
|
||||||
|
|
||||||
@@ -337,7 +338,7 @@ export const useLitegraphService = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ComfyApp.isImageNode(this)) {
|
if (isImageNode(this)) {
|
||||||
options.push({
|
options.push({
|
||||||
content: 'Open in MaskEditor',
|
content: 'Open in MaskEditor',
|
||||||
callback: (obj) => {
|
callback: (obj) => {
|
||||||
|
|||||||
10
src/utils/litegraphUtil.ts
Normal file
10
src/utils/litegraphUtil.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { IWidget, LGraphNode } from '@comfyorg/litegraph'
|
||||||
|
|
||||||
|
export function isImageNode(node: LGraphNode) {
|
||||||
|
return (
|
||||||
|
node.imgs ||
|
||||||
|
(node &&
|
||||||
|
node.widgets &&
|
||||||
|
node.widgets.findIndex((obj: IWidget) => obj.name === 'image') >= 0)
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user