copy and paste in the menu

This commit is contained in:
Yiqun Xu
2025-06-14 11:47:57 -07:00
parent 1e2b16f14d
commit 199bb8bc9f
3 changed files with 36 additions and 1 deletions

View File

@@ -18,7 +18,7 @@ import { useDialogService } from '@/services/dialogService'
import { useLitegraphService } from '@/services/litegraphService'
import { useWorkflowService } from '@/services/workflowService'
import type { ComfyCommand } from '@/stores/commandStore'
import { useTitleEditorStore } from '@/stores/graphStore'
import { useCanvasStore, useTitleEditorStore } from '@/stores/graphStore'
import { useQueueSettingsStore, useQueueStore } from '@/stores/queueStore'
import { useSettingStore } from '@/stores/settingStore'
import { useToastStore } from '@/stores/toastStore'
@@ -156,6 +156,30 @@ export function useCoreCommands(): ComfyCommand[] {
await getTracker()?.redo?.()
}
},
{
id: 'Comfy.Edit.Copy',
icon: 'pi pi-copy',
label: 'Copy',
function: () => {
// Leverage existing copy logic
const canvas = useCanvasStore().canvas
if (canvas?.selectedItems) {
canvas.copyToClipboard()
}
}
},
{
id: 'Comfy.Edit.Paste',
icon: 'pi pi-clipboard',
label: 'Paste',
function: () => {
// Leverage existing paste logic, position at last interaction point
const canvas = useCanvasStore().canvas
if (canvas) {
canvas.pasteFromClipboard()
}
}
},
{
id: 'Comfy.ClearWorkflow',
icon: 'pi pi-trash',

View File

@@ -173,5 +173,15 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
key: 'f'
},
commandId: 'Workspace.ToggleFocusMode'
},
{
combo: { ctrl: true, key: 'c' },
commandId: 'Comfy.Edit.Copy',
targetElementId: 'graph-canvas'
},
{
combo: { ctrl: true, key: 'v' },
commandId: 'Comfy.Edit.Paste',
targetElementId: 'graph-canvas'
}
]

View File

@@ -11,6 +11,7 @@ export const CORE_MENU_COMMANDS = [
]
],
[['Edit'], ['Comfy.Undo', 'Comfy.Redo']],
[['Edit'], ['Comfy.Edit.Copy', 'Comfy.Edit.Paste']],
[['Edit'], ['Comfy.RefreshNodeDefinitions']],
[['Edit'], ['Comfy.ClearWorkflow']],
[['Edit'], ['Comfy.OpenClipspace']],