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
},
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: {

View File

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

View File

@@ -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"
}

View File

@@ -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": "タイプ"
}

View File

@@ -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": "유형"
}

View File

@@ -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": "тип"
}

View File

@@ -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": "类型"
}

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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
}
}

View File

@@ -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