From 975c2248c5c5fc86be6fdee1a501181620078338 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Sun, 5 Jan 2025 16:03:38 -0500 Subject: [PATCH] Rename Keybinding.targetSelector to targetElementId (#2169) Co-authored-by: github-actions --- src/constants/coreKeybindings.ts | 18 +++++++++--------- src/locales/en/nodeDefs.json | 6 ++++++ src/locales/fr/nodeDefs.json | 6 ++++++ src/locales/ja/nodeDefs.json | 6 ++++++ src/locales/ko/nodeDefs.json | 6 ++++++ src/locales/ru/nodeDefs.json | 6 ++++++ src/locales/zh/nodeDefs.json | 6 ++++++ src/scripts/app.ts | 2 +- src/services/keybindingService.ts | 2 +- src/stores/keybindingStore.ts | 6 +++--- src/types/keyBindingTypes.ts | 4 ++-- 11 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/constants/coreKeybindings.ts b/src/constants/coreKeybindings.ts index 023a63ac92..f5c1cfd8ca 100644 --- a/src/constants/coreKeybindings.ts +++ b/src/constants/coreKeybindings.ts @@ -95,7 +95,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [ alt: true }, commandId: 'Comfy.Canvas.ZoomIn', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, { combo: { @@ -104,7 +104,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [ shift: true }, commandId: 'Comfy.Canvas.ZoomIn', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, // For number pad '+' { @@ -113,7 +113,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [ alt: true }, commandId: 'Comfy.Canvas.ZoomIn', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, { combo: { @@ -121,21 +121,21 @@ export const CORE_KEYBINDINGS: Keybinding[] = [ alt: true }, commandId: 'Comfy.Canvas.ZoomOut', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, { combo: { key: '.' }, commandId: 'Comfy.Canvas.FitView', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, { combo: { key: 'p' }, commandId: 'Comfy.Canvas.ToggleSelected.Pin', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, { combo: { @@ -143,7 +143,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [ alt: true }, commandId: 'Comfy.Canvas.ToggleSelectedNodes.Collapse', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, { combo: { @@ -151,7 +151,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [ ctrl: true }, commandId: 'Comfy.Canvas.ToggleSelectedNodes.Bypass', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, { combo: { @@ -159,7 +159,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [ ctrl: true }, commandId: 'Comfy.Canvas.ToggleSelectedNodes.Mute', - targetSelector: '#graph-canvas' + targetElementId: 'graph-canvas' }, { combo: { diff --git a/src/locales/en/nodeDefs.json b/src/locales/en/nodeDefs.json index 2a0b5b7e23..b442dd1239 100644 --- a/src/locales/en/nodeDefs.json +++ b/src/locales/en/nodeDefs.json @@ -184,6 +184,9 @@ }, "type": { "name": "type" + }, + "device": { + "name": "device" } } }, @@ -1221,6 +1224,9 @@ }, "type": { "name": "type" + }, + "device": { + "name": "device" } } }, diff --git a/src/locales/fr/nodeDefs.json b/src/locales/fr/nodeDefs.json index 12560b4ae6..e133e6f8e9 100644 --- a/src/locales/fr/nodeDefs.json +++ b/src/locales/fr/nodeDefs.json @@ -119,6 +119,9 @@ "clip_name": { "name": "clip_name" }, + "device": { + "name": "appareil" + }, "type": { "name": "type" } @@ -1219,6 +1222,9 @@ "clip_name2": { "name": "nom_clip2" }, + "device": { + "name": "appareil" + }, "type": { "name": "type" } diff --git a/src/locales/ja/nodeDefs.json b/src/locales/ja/nodeDefs.json index ab3a53eee9..a4ef731786 100644 --- a/src/locales/ja/nodeDefs.json +++ b/src/locales/ja/nodeDefs.json @@ -119,6 +119,9 @@ "clip_name": { "name": "clip名" }, + "device": { + "name": "デバイス" + }, "type": { "name": "タイプ" } @@ -1219,6 +1222,9 @@ "clip_name2": { "name": "clip_name2" }, + "device": { + "name": "デバイス" + }, "type": { "name": "タイプ" } diff --git a/src/locales/ko/nodeDefs.json b/src/locales/ko/nodeDefs.json index 0a6a459489..f482b03150 100644 --- a/src/locales/ko/nodeDefs.json +++ b/src/locales/ko/nodeDefs.json @@ -119,6 +119,9 @@ "clip_name": { "name": "CLIP 파일명" }, + "device": { + "name": "장치" + }, "type": { "name": "유형" } @@ -1219,6 +1222,9 @@ "clip_name2": { "name": "CLIP 파일명2" }, + "device": { + "name": "장치" + }, "type": { "name": "유형" } diff --git a/src/locales/ru/nodeDefs.json b/src/locales/ru/nodeDefs.json index c4cf874a47..af7b0994a9 100644 --- a/src/locales/ru/nodeDefs.json +++ b/src/locales/ru/nodeDefs.json @@ -119,6 +119,9 @@ "clip_name": { "name": "имя_clip" }, + "device": { + "name": "устройство" + }, "type": { "name": "тип" } @@ -1219,6 +1222,9 @@ "clip_name2": { "name": "clip_name2" }, + "device": { + "name": "устройство" + }, "type": { "name": "тип" } diff --git a/src/locales/zh/nodeDefs.json b/src/locales/zh/nodeDefs.json index a0958117a7..57ecd2aa4b 100644 --- a/src/locales/zh/nodeDefs.json +++ b/src/locales/zh/nodeDefs.json @@ -119,6 +119,9 @@ "clip_name": { "name": "CLIP名称" }, + "device": { + "name": "设备" + }, "type": { "name": "类型" } @@ -1219,6 +1222,9 @@ "clip_name2": { "name": "CLIP名称2" }, + "device": { + "name": "设备" + }, "type": { "name": "类型" } diff --git a/src/scripts/app.ts b/src/scripts/app.ts index e30a3f77b4..0036d30b9f 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -655,7 +655,7 @@ export class ComfyApp { const keyCombo = KeyComboImpl.fromEvent(e) const keybindingStore = useKeybindingStore() const keybinding = keybindingStore.getKeybinding(keyCombo) - if (keybinding && keybinding.targetSelector === '#graph-canvas') { + if (keybinding && keybinding.targetElementId === 'graph-canvas') { useCommandStore().execute(keybinding.commandId) block_default = true } diff --git a/src/services/keybindingService.ts b/src/services/keybindingService.ts index a5418afc71..5a0b198165 100644 --- a/src/services/keybindingService.ts +++ b/src/services/keybindingService.ts @@ -31,7 +31,7 @@ export const useKeybindingService = () => { } const keybinding = keybindingStore.getKeybinding(keyCombo) - if (keybinding && keybinding.targetSelector !== '#graph-canvas') { + if (keybinding && keybinding.targetElementId !== 'graph-canvas') { // Prevent default browser behavior first, then execute the command event.preventDefault() await commandStore.execute(keybinding.commandId) diff --git a/src/stores/keybindingStore.ts b/src/stores/keybindingStore.ts index 5abfe1ab9d..759ac95aa4 100644 --- a/src/stores/keybindingStore.ts +++ b/src/stores/keybindingStore.ts @@ -6,12 +6,12 @@ import { KeyCombo, Keybinding } from '@/types/keyBindingTypes' export class KeybindingImpl implements Keybinding { commandId: string combo: KeyComboImpl - targetSelector?: string + targetElementId?: string constructor(obj: Keybinding) { this.commandId = obj.commandId this.combo = new KeyComboImpl(obj.combo) - this.targetSelector = obj.targetSelector + this.targetElementId = obj.targetElementId } equals(other: unknown): boolean { @@ -20,7 +20,7 @@ export class KeybindingImpl implements Keybinding { return raw instanceof KeybindingImpl ? this.commandId === raw.commandId && this.combo.equals(raw.combo) && - this.targetSelector === raw.targetSelector + this.targetElementId === raw.targetElementId : false } } diff --git a/src/types/keyBindingTypes.ts b/src/types/keyBindingTypes.ts index 863cae0dd8..31896842fe 100644 --- a/src/types/keyBindingTypes.ts +++ b/src/types/keyBindingTypes.ts @@ -13,11 +13,11 @@ export const zKeyCombo = z.object({ export const zKeybinding = z.object({ commandId: z.string(), combo: zKeyCombo, - // Optional target element CSS selector to limit keybinding to. + // Optional target element ID to limit keybinding to. // Note: Currently only used to distinguish between global keybindings // and litegraph canvas keybindings. // Do NOT use this field in extensions as it has no effect. - targetSelector: z.string().optional() + targetElementId: z.string().optional() }) // Infer types from schemas