mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
Add convert to subgraph command
This commit is contained in:
@@ -18,7 +18,7 @@ import { useDialogService } from '@/services/dialogService'
|
|||||||
import { useLitegraphService } from '@/services/litegraphService'
|
import { useLitegraphService } from '@/services/litegraphService'
|
||||||
import { useWorkflowService } from '@/services/workflowService'
|
import { useWorkflowService } from '@/services/workflowService'
|
||||||
import type { ComfyCommand } from '@/stores/commandStore'
|
import type { ComfyCommand } from '@/stores/commandStore'
|
||||||
import { useTitleEditorStore } from '@/stores/graphStore'
|
import { useCanvasStore, useTitleEditorStore } from '@/stores/graphStore'
|
||||||
import { useQueueSettingsStore, useQueueStore } from '@/stores/queueStore'
|
import { useQueueSettingsStore, useQueueStore } from '@/stores/queueStore'
|
||||||
import { useSettingStore } from '@/stores/settingStore'
|
import { useSettingStore } from '@/stores/settingStore'
|
||||||
import { useToastStore } from '@/stores/toastStore'
|
import { useToastStore } from '@/stores/toastStore'
|
||||||
@@ -37,6 +37,7 @@ export function useCoreCommands(): ComfyCommand[] {
|
|||||||
const colorPaletteStore = useColorPaletteStore()
|
const colorPaletteStore = useColorPaletteStore()
|
||||||
const firebaseAuthActions = useFirebaseAuthActions()
|
const firebaseAuthActions = useFirebaseAuthActions()
|
||||||
const toastStore = useToastStore()
|
const toastStore = useToastStore()
|
||||||
|
const canvasStore = useCanvasStore()
|
||||||
const getTracker = () => workflowStore.activeWorkflow?.changeTracker
|
const getTracker = () => workflowStore.activeWorkflow?.changeTracker
|
||||||
|
|
||||||
const getSelectedNodes = (): LGraphNode[] => {
|
const getSelectedNodes = (): LGraphNode[] => {
|
||||||
@@ -718,6 +719,27 @@ export function useCoreCommands(): ComfyCommand[] {
|
|||||||
label: 'Move Selected Nodes Right',
|
label: 'Move Selected Nodes Right',
|
||||||
versionAdded: moveSelectedNodesVersionAdded,
|
versionAdded: moveSelectedNodesVersionAdded,
|
||||||
function: () => moveSelectedNodes(([x, y], gridSize) => [x + gridSize, y])
|
function: () => moveSelectedNodes(([x, y], gridSize) => [x + gridSize, y])
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'Comfy.Graph.ConvertToSubgraph',
|
||||||
|
icon: 'pi pi-sitemap',
|
||||||
|
label: 'Convert Selection to Subgraph',
|
||||||
|
versionAdded: '1.20.1',
|
||||||
|
function: () => {
|
||||||
|
const canvas = canvasStore.getCanvas()
|
||||||
|
const res = canvas.graph?.convertToSubgraph(canvas.selectedItems)
|
||||||
|
if (!res) {
|
||||||
|
toastStore.add({
|
||||||
|
severity: 'error',
|
||||||
|
summary: t('toastMessages.cannotCreateSubgraph'),
|
||||||
|
detail: t('toastMessages.failedToConvertToSubgraph'),
|
||||||
|
life: 3000
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const { node } = res
|
||||||
|
canvas.select(node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -173,5 +173,13 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
|
|||||||
key: 'f'
|
key: 'f'
|
||||||
},
|
},
|
||||||
commandId: 'Workspace.ToggleFocusMode'
|
commandId: 'Workspace.ToggleFocusMode'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
combo: {
|
||||||
|
key: 'e',
|
||||||
|
ctrl: true,
|
||||||
|
shift: true
|
||||||
|
},
|
||||||
|
commandId: 'Comfy.Graph.ConvertToSubgraph'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1302,7 +1302,9 @@
|
|||||||
"failedToPurchaseCredits": "Failed to purchase credits: {error}",
|
"failedToPurchaseCredits": "Failed to purchase credits: {error}",
|
||||||
"unauthorizedDomain": "Your domain {domain} is not authorized to use this service. Please contact {email} to add your domain to the whitelist.",
|
"unauthorizedDomain": "Your domain {domain} is not authorized to use this service. Please contact {email} to add your domain to the whitelist.",
|
||||||
"useApiKeyTip": "Tip: Can't access normal login? Use the Comfy API Key option.",
|
"useApiKeyTip": "Tip: Can't access normal login? Use the Comfy API Key option.",
|
||||||
"nothingSelected": "Nothing selected"
|
"nothingSelected": "Nothing selected",
|
||||||
|
"cannotCreateSubgraph": "Cannot create subgraph",
|
||||||
|
"failedToConvertToSubgraph": "Failed to convert items to subgraph"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"apiKey": {
|
"apiKey": {
|
||||||
|
|||||||
Reference in New Issue
Block a user