Rename Keybinding.targetSelector to targetElementId (#2169)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2025-01-05 16:03:38 -05:00
committed by GitHub
parent 477f4b275d
commit 975c2248c5
11 changed files with 52 additions and 16 deletions

View File

@@ -95,7 +95,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
alt: true alt: true
}, },
commandId: 'Comfy.Canvas.ZoomIn', commandId: 'Comfy.Canvas.ZoomIn',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
{ {
combo: { combo: {
@@ -104,7 +104,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
shift: true shift: true
}, },
commandId: 'Comfy.Canvas.ZoomIn', commandId: 'Comfy.Canvas.ZoomIn',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
// For number pad '+' // For number pad '+'
{ {
@@ -113,7 +113,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
alt: true alt: true
}, },
commandId: 'Comfy.Canvas.ZoomIn', commandId: 'Comfy.Canvas.ZoomIn',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
{ {
combo: { combo: {
@@ -121,21 +121,21 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
alt: true alt: true
}, },
commandId: 'Comfy.Canvas.ZoomOut', commandId: 'Comfy.Canvas.ZoomOut',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
{ {
combo: { combo: {
key: '.' key: '.'
}, },
commandId: 'Comfy.Canvas.FitView', commandId: 'Comfy.Canvas.FitView',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
{ {
combo: { combo: {
key: 'p' key: 'p'
}, },
commandId: 'Comfy.Canvas.ToggleSelected.Pin', commandId: 'Comfy.Canvas.ToggleSelected.Pin',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
{ {
combo: { combo: {
@@ -143,7 +143,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
alt: true alt: true
}, },
commandId: 'Comfy.Canvas.ToggleSelectedNodes.Collapse', commandId: 'Comfy.Canvas.ToggleSelectedNodes.Collapse',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
{ {
combo: { combo: {
@@ -151,7 +151,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
ctrl: true ctrl: true
}, },
commandId: 'Comfy.Canvas.ToggleSelectedNodes.Bypass', commandId: 'Comfy.Canvas.ToggleSelectedNodes.Bypass',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
{ {
combo: { combo: {
@@ -159,7 +159,7 @@ export const CORE_KEYBINDINGS: Keybinding[] = [
ctrl: true ctrl: true
}, },
commandId: 'Comfy.Canvas.ToggleSelectedNodes.Mute', commandId: 'Comfy.Canvas.ToggleSelectedNodes.Mute',
targetSelector: '#graph-canvas' targetElementId: 'graph-canvas'
}, },
{ {
combo: { combo: {

View File

@@ -184,6 +184,9 @@
}, },
"type": { "type": {
"name": "type" "name": "type"
},
"device": {
"name": "device"
} }
} }
}, },
@@ -1221,6 +1224,9 @@
}, },
"type": { "type": {
"name": "type" "name": "type"
},
"device": {
"name": "device"
} }
} }
}, },

View File

@@ -119,6 +119,9 @@
"clip_name": { "clip_name": {
"name": "clip_name" "name": "clip_name"
}, },
"device": {
"name": "appareil"
},
"type": { "type": {
"name": "type" "name": "type"
} }
@@ -1219,6 +1222,9 @@
"clip_name2": { "clip_name2": {
"name": "nom_clip2" "name": "nom_clip2"
}, },
"device": {
"name": "appareil"
},
"type": { "type": {
"name": "type" "name": "type"
} }

View File

@@ -119,6 +119,9 @@
"clip_name": { "clip_name": {
"name": "clip名" "name": "clip名"
}, },
"device": {
"name": "デバイス"
},
"type": { "type": {
"name": "タイプ" "name": "タイプ"
} }
@@ -1219,6 +1222,9 @@
"clip_name2": { "clip_name2": {
"name": "clip_name2" "name": "clip_name2"
}, },
"device": {
"name": "デバイス"
},
"type": { "type": {
"name": "タイプ" "name": "タイプ"
} }

View File

@@ -119,6 +119,9 @@
"clip_name": { "clip_name": {
"name": "CLIP 파일명" "name": "CLIP 파일명"
}, },
"device": {
"name": "장치"
},
"type": { "type": {
"name": "유형" "name": "유형"
} }
@@ -1219,6 +1222,9 @@
"clip_name2": { "clip_name2": {
"name": "CLIP 파일명2" "name": "CLIP 파일명2"
}, },
"device": {
"name": "장치"
},
"type": { "type": {
"name": "유형" "name": "유형"
} }

View File

@@ -119,6 +119,9 @@
"clip_name": { "clip_name": {
"name": "имя_clip" "name": "имя_clip"
}, },
"device": {
"name": "устройство"
},
"type": { "type": {
"name": "тип" "name": "тип"
} }
@@ -1219,6 +1222,9 @@
"clip_name2": { "clip_name2": {
"name": "clip_name2" "name": "clip_name2"
}, },
"device": {
"name": "устройство"
},
"type": { "type": {
"name": "тип" "name": "тип"
} }

View File

@@ -119,6 +119,9 @@
"clip_name": { "clip_name": {
"name": "CLIP名称" "name": "CLIP名称"
}, },
"device": {
"name": "设备"
},
"type": { "type": {
"name": "类型" "name": "类型"
} }
@@ -1219,6 +1222,9 @@
"clip_name2": { "clip_name2": {
"name": "CLIP名称2" "name": "CLIP名称2"
}, },
"device": {
"name": "设备"
},
"type": { "type": {
"name": "类型" "name": "类型"
} }

View File

@@ -655,7 +655,7 @@ export class ComfyApp {
const keyCombo = KeyComboImpl.fromEvent(e) const keyCombo = KeyComboImpl.fromEvent(e)
const keybindingStore = useKeybindingStore() const keybindingStore = useKeybindingStore()
const keybinding = keybindingStore.getKeybinding(keyCombo) const keybinding = keybindingStore.getKeybinding(keyCombo)
if (keybinding && keybinding.targetSelector === '#graph-canvas') { if (keybinding && keybinding.targetElementId === 'graph-canvas') {
useCommandStore().execute(keybinding.commandId) useCommandStore().execute(keybinding.commandId)
block_default = true block_default = true
} }

View File

@@ -31,7 +31,7 @@ export const useKeybindingService = () => {
} }
const keybinding = keybindingStore.getKeybinding(keyCombo) 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 // Prevent default browser behavior first, then execute the command
event.preventDefault() event.preventDefault()
await commandStore.execute(keybinding.commandId) await commandStore.execute(keybinding.commandId)

View File

@@ -6,12 +6,12 @@ import { KeyCombo, Keybinding } from '@/types/keyBindingTypes'
export class KeybindingImpl implements Keybinding { export class KeybindingImpl implements Keybinding {
commandId: string commandId: string
combo: KeyComboImpl combo: KeyComboImpl
targetSelector?: string targetElementId?: string
constructor(obj: Keybinding) { constructor(obj: Keybinding) {
this.commandId = obj.commandId this.commandId = obj.commandId
this.combo = new KeyComboImpl(obj.combo) this.combo = new KeyComboImpl(obj.combo)
this.targetSelector = obj.targetSelector this.targetElementId = obj.targetElementId
} }
equals(other: unknown): boolean { equals(other: unknown): boolean {
@@ -20,7 +20,7 @@ export class KeybindingImpl implements Keybinding {
return raw instanceof KeybindingImpl return raw instanceof KeybindingImpl
? this.commandId === raw.commandId && ? this.commandId === raw.commandId &&
this.combo.equals(raw.combo) && this.combo.equals(raw.combo) &&
this.targetSelector === raw.targetSelector this.targetElementId === raw.targetElementId
: false : false
} }
} }

View File

@@ -13,11 +13,11 @@ export const zKeyCombo = z.object({
export const zKeybinding = z.object({ export const zKeybinding = z.object({
commandId: z.string(), commandId: z.string(),
combo: zKeyCombo, 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 // Note: Currently only used to distinguish between global keybindings
// and litegraph canvas keybindings. // and litegraph canvas keybindings.
// Do NOT use this field in extensions as it has no effect. // Do NOT use this field in extensions as it has no effect.
targetSelector: z.string().optional() targetElementId: z.string().optional()
}) })
// Infer types from schemas // Infer types from schemas