mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 14:27:40 +00:00
separate into data model and renderer layers
This commit is contained in:
@@ -36,7 +36,10 @@ import { selectionBounds } from '@/renderer/core/layout/utils/layoutMath'
|
||||
import { api } from '@/scripts/api'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useLitegraphService } from '@/services/litegraphService'
|
||||
import {
|
||||
invokeToggleWidgetPromotion,
|
||||
useLitegraphService
|
||||
} from '@/services/litegraphService'
|
||||
import type { ComfyCommand } from '@/stores/commandStore'
|
||||
import { useExecutionStore } from '@/stores/executionStore'
|
||||
import { useHelpCenterStore } from '@/stores/helpCenterStore'
|
||||
@@ -1032,11 +1035,8 @@ export function useCoreCommands(): ComfyCommand[] {
|
||||
icon: 'icon-[lucide--arrow-left-right]',
|
||||
label: 'Toggle promotion of hovered widget',
|
||||
versionAdded: '1.30.1',
|
||||
function: async () => {
|
||||
const { tryToggleWidgetPromotion } = await import(
|
||||
'@/renderer/graph/subgraph/proxyWidgetUtils'
|
||||
)
|
||||
tryToggleWidgetPromotion()
|
||||
function: () => {
|
||||
invokeToggleWidgetPromotion()
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets.ts'
|
||||
import { useToastStore } from '@/platform/updates/common/toastStore'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import {
|
||||
registerAddWidgetPromotionOptions,
|
||||
registerWidgetPromotionHandlers,
|
||||
useLitegraphService
|
||||
} from '@/services/litegraphService'
|
||||
import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore'
|
||||
@@ -115,8 +115,11 @@ function addWidgetPromotionOptions(
|
||||
}
|
||||
}
|
||||
|
||||
registerAddWidgetPromotionOptions(addWidgetPromotionOptions)
|
||||
export function tryToggleWidgetPromotion() {
|
||||
registerWidgetPromotionHandlers({
|
||||
addWidgetPromotionOptions,
|
||||
tryToggleWidgetPromotion
|
||||
})
|
||||
function tryToggleWidgetPromotion() {
|
||||
const canvas = useCanvasStore().getCanvas()
|
||||
const [x, y] = canvas.graph_mouse
|
||||
const node = canvas.graph?.getNodeOnPos(x, y, canvas.visible_nodes)
|
||||
|
||||
@@ -51,7 +51,7 @@ export async function addStylesheet(
|
||||
})
|
||||
}
|
||||
|
||||
/** @knipIgnoreUnusedButUsedByCustomNodes */
|
||||
// @knipIgnoreUnusedButUsedByCustomNodes
|
||||
export { downloadBlob } from '@/base/common/downloadUtil'
|
||||
|
||||
export function uploadFile(accept: string) {
|
||||
|
||||
@@ -62,18 +62,25 @@ import { useExtensionService } from './extensionService'
|
||||
export const CONFIG = Symbol()
|
||||
export const GET_CONFIG = Symbol()
|
||||
|
||||
type AddWidgetPromotionOptionsFn = (
|
||||
options: (IContextMenuValue<unknown> | null)[],
|
||||
widget: IBaseWidget,
|
||||
node: LGraphNode
|
||||
) => void
|
||||
type WidgetPromotionHandlers = {
|
||||
addWidgetPromotionOptions?: (
|
||||
options: (IContextMenuValue<unknown> | null)[],
|
||||
widget: IBaseWidget,
|
||||
node: LGraphNode
|
||||
) => void
|
||||
tryToggleWidgetPromotion?: () => void
|
||||
}
|
||||
|
||||
let addWidgetPromotionOptionsFn: AddWidgetPromotionOptionsFn | undefined
|
||||
let widgetPromotionHandlers: WidgetPromotionHandlers = {}
|
||||
|
||||
export const registerAddWidgetPromotionOptions = (
|
||||
handler: AddWidgetPromotionOptionsFn | undefined
|
||||
export const registerWidgetPromotionHandlers = (
|
||||
handlers: WidgetPromotionHandlers
|
||||
) => {
|
||||
addWidgetPromotionOptionsFn = handler
|
||||
widgetPromotionHandlers = handlers
|
||||
}
|
||||
|
||||
export const invokeToggleWidgetPromotion = () => {
|
||||
widgetPromotionHandlers.tryToggleWidgetPromotion?.()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -840,7 +847,11 @@ export const useLitegraphService = () => {
|
||||
const [x, y] = canvas.graph_mouse
|
||||
const overWidget = this.getWidgetOnPos(x, y, true)
|
||||
if (overWidget) {
|
||||
addWidgetPromotionOptionsFn?.(options, overWidget, this)
|
||||
widgetPromotionHandlers.addWidgetPromotionOptions?.(
|
||||
options,
|
||||
overWidget,
|
||||
this
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user