Group selected nodes by Ctrl + g (#663)

* Ctrl + g to group selected noes

* Add playwright test

* nit

* Move button loc

* Update test expectations [skip ci]

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-08-28 11:49:41 -04:00
committed by GitHub
parent 5c2cb00cd6
commit 2c174b5956
9 changed files with 58 additions and 6 deletions

View File

@@ -53,6 +53,7 @@ import { useSettingStore } from '@/stores/settingStore'
import { useToastStore } from '@/stores/toastStore'
import type { ToastMessageOptions } from 'primevue/toast'
import { useWorkspaceStore } from '@/stores/workspaceStateStore'
import { LGraphGroup } from '@comfyorg/litegraph'
export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview'

View File

@@ -5,6 +5,9 @@ import { ComfySettingsDialog } from './ui/settings'
import { ComfyApp, app } from './app'
import { TaskItem } from '@/types/apiTypes'
import { showSettingsDialog } from '@/services/dialogService'
import { useToastStore } from '@/stores/toastStore'
import { LGraphGroup } from '@comfyorg/litegraph'
import { useSettingStore } from '@/stores/settingStore'
export const ComfyDialog = _ComfyDialog
@@ -756,6 +759,31 @@ export class ComfyUI {
onclick: async () => {
app.resetView()
}
}),
$el('button', {
id: 'comfy-group-selected-nodes-button',
textContent: 'Group',
hidden: true,
onclick: () => {
if (
!app.canvas.selected_nodes ||
Object.keys(app.canvas.selected_nodes).length === 0
) {
useToastStore().add({
severity: 'error',
summary: 'No nodes selected',
detail: 'Please select nodes to group',
life: 3000
})
return
}
const group = new LGraphGroup()
const padding = useSettingStore().get(
'Comfy.GroupSelectedNodes.Padding'
)
group.addNodes(Object.values(app.canvas.selected_nodes), padding)
app.canvas.graph.add(group)
}
})
]) as HTMLDivElement

View File

@@ -88,6 +88,7 @@ export class ComfyAppMenu {
app
})
)
this.actionsGroup = new ComfyButtonGroup(
new ComfyButton({
icon: 'refresh',