mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-23 16:24:06 +00:00
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:
@@ -158,6 +158,16 @@ test.describe('Node Interaction', () => {
|
||||
})
|
||||
expect(await comfyPage.page.locator('.node-title-editor').count()).toBe(0)
|
||||
})
|
||||
|
||||
test('Can group selected nodes', async ({ comfyPage }) => {
|
||||
await comfyPage.setSetting('Comfy.GroupSelectedNodes.Padding', 10)
|
||||
await comfyPage.select2Nodes()
|
||||
await comfyPage.page.keyboard.down('Control')
|
||||
await comfyPage.page.keyboard.press('KeyG')
|
||||
await comfyPage.page.keyboard.up('Control')
|
||||
await comfyPage.nextFrame()
|
||||
await expect(comfyPage.canvas).toHaveScreenshot('group-selected-nodes.png')
|
||||
})
|
||||
})
|
||||
|
||||
test.describe('Canvas Interaction', () => {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
8
package-lock.json
generated
8
package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "1.2.38",
|
||||
"dependencies": {
|
||||
"@atlaskit/pragmatic-drag-and-drop": "^1.2.1",
|
||||
"@comfyorg/litegraph": "^0.7.52",
|
||||
"@comfyorg/litegraph": "^0.7.54",
|
||||
"@primevue/themes": "^4.0.0-rc.2",
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
"@vueuse/core": "^11.0.0",
|
||||
@@ -1881,9 +1881,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@comfyorg/litegraph": {
|
||||
"version": "0.7.52",
|
||||
"resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.7.52.tgz",
|
||||
"integrity": "sha512-MtJn4VH3eaP4XYfLQVrc00vJGamOfl5a5xMRJpW8tfPO2iPaetshoB9dkDfNJ6fSolzMt24qvZttkPdh2aNR1Q==",
|
||||
"version": "0.7.54",
|
||||
"resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.7.54.tgz",
|
||||
"integrity": "sha512-nbd68LCFurokYmtq9c/fA9iIRRXAykDqKkAjAle33JlTU6FOr5FrZvg+VmHEk0YbxMTx7WB+4GGHBaaTJdMN9A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@cspotcode/source-map-support": {
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@atlaskit/pragmatic-drag-and-drop": "^1.2.1",
|
||||
"@comfyorg/litegraph": "^0.7.52",
|
||||
"@comfyorg/litegraph": "^0.7.54",
|
||||
"@primevue/themes": "^4.0.0-rc.2",
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
"@vueuse/core": "^11.0.0",
|
||||
|
||||
@@ -40,7 +40,8 @@ app.registerExtension({
|
||||
s: '#comfy-save-button',
|
||||
o: '#comfy-file-input',
|
||||
Backspace: '#comfy-clear-button',
|
||||
d: '#comfy-load-default-button'
|
||||
d: '#comfy-load-default-button',
|
||||
g: '#comfy-group-selected-nodes-button'
|
||||
}
|
||||
|
||||
const modifierKeybindId = modifierKeyIdMap[event.key]
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ export class ComfyAppMenu {
|
||||
app
|
||||
})
|
||||
)
|
||||
|
||||
this.actionsGroup = new ComfyButtonGroup(
|
||||
new ComfyButton({
|
||||
icon: 'refresh',
|
||||
|
||||
@@ -241,6 +241,17 @@ export const useSettingStore = defineStore('setting', {
|
||||
type: 'hidden',
|
||||
defaultValue: ['.safetensors', '.sft']
|
||||
})
|
||||
|
||||
app.ui.settings.addSetting({
|
||||
id: 'Comfy.GroupSelectedNodes.Padding',
|
||||
name: 'Group selected nodes padding',
|
||||
type: 'slider',
|
||||
defaultValue: 10,
|
||||
attrs: {
|
||||
min: 0,
|
||||
max: 100
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
set<K extends keyof Settings>(key: K, value: Settings[K]) {
|
||||
|
||||
Reference in New Issue
Block a user