From 4a230f720e7af3b22d575fe5b3da1fbc3ac94a06 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 2 Sep 2024 20:20:40 -0400 Subject: [PATCH] Edit group name on group creation (With Ctrl + g) (#715) * Editor store * Merge editors * nit * Edit on group creation * nit --- browser_tests/interaction.spec.ts | 3 + src/components/graph/GraphCanvas.vue | 6 +- src/components/graph/GroupTitleEditor.vue | 104 -------------- src/components/graph/NodeTitleEditor.vue | 101 ------------- src/components/graph/TitleEditor.vue | 166 ++++++++++++++++++++++ src/scripts/ui.ts | 2 + src/stores/graphStore.ts | 11 ++ 7 files changed, 184 insertions(+), 209 deletions(-) delete mode 100644 src/components/graph/GroupTitleEditor.vue delete mode 100644 src/components/graph/NodeTitleEditor.vue create mode 100644 src/components/graph/TitleEditor.vue create mode 100644 src/stores/graphStore.ts diff --git a/browser_tests/interaction.spec.ts b/browser_tests/interaction.spec.ts index 9948a2458..a0f1f2d23 100644 --- a/browser_tests/interaction.spec.ts +++ b/browser_tests/interaction.spec.ts @@ -165,6 +165,9 @@ test.describe('Node Interaction', () => { await comfyPage.page.keyboard.press('KeyG') await comfyPage.page.keyboard.up('Control') await comfyPage.nextFrame() + // Confirm group title + await comfyPage.page.keyboard.press('Enter') + await comfyPage.nextFrame() await expect(comfyPage.canvas).toHaveScreenshot('group-selected-nodes.png') }) }) diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 775ec73e4..533ba8948 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -5,8 +5,7 @@ - - + @@ -14,8 +13,7 @@ - - diff --git a/src/components/graph/NodeTitleEditor.vue b/src/components/graph/NodeTitleEditor.vue deleted file mode 100644 index 99d466ef7..000000000 --- a/src/components/graph/NodeTitleEditor.vue +++ /dev/null @@ -1,101 +0,0 @@ - - - - - diff --git a/src/components/graph/TitleEditor.vue b/src/components/graph/TitleEditor.vue new file mode 100644 index 000000000..b565f2650 --- /dev/null +++ b/src/components/graph/TitleEditor.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/src/scripts/ui.ts b/src/scripts/ui.ts index 18f5e07b7..625d61463 100644 --- a/src/scripts/ui.ts +++ b/src/scripts/ui.ts @@ -8,6 +8,7 @@ import { showSettingsDialog } from '@/services/dialogService' import { useToastStore } from '@/stores/toastStore' import { LGraphGroup } from '@comfyorg/litegraph' import { useSettingStore } from '@/stores/settingStore' +import { useTitleEditorStore } from '@/stores/graphStore' export const ComfyDialog = _ComfyDialog @@ -783,6 +784,7 @@ export class ComfyUI { ) group.addNodes(Object.values(app.canvas.selected_nodes), padding) app.canvas.graph.add(group) + useTitleEditorStore().titleEditorTarget = group } }) ]) as HTMLDivElement diff --git a/src/stores/graphStore.ts b/src/stores/graphStore.ts new file mode 100644 index 000000000..74b03d82a --- /dev/null +++ b/src/stores/graphStore.ts @@ -0,0 +1,11 @@ +import { LGraphNode, LGraphGroup } from '@comfyorg/litegraph' +import { defineStore } from 'pinia' +import { ref } from 'vue' + +export const useTitleEditorStore = defineStore('titleEditor', () => { + const titleEditorTarget = ref(null) + + return { + titleEditorTarget + } +})