mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-28 02:02:08 +00:00
Support keybinding customization (#1081)
* Basic keybinding panel nit Make row selectable Reduce padding Better key seq render Show actions on demand Turn off autocomplete nit Persist keybindings Autofocus Fix set unsetted keybinding bug Refactor Add reset button Add back default keybinding logic Report key conflict error Adjust style fix bug Highlight modified keybindings * Set current editing command's id as dialog header
This commit is contained in:
@@ -53,6 +53,25 @@ describe('useKeybindingStore', () => {
|
||||
expect(store.getKeybinding(userKeybinding.combo)).toEqual(userKeybinding)
|
||||
})
|
||||
|
||||
it('Should allow binding to unsetted default keybindings', () => {
|
||||
const store = useKeybindingStore()
|
||||
const defaultKeybinding = new KeybindingImpl({
|
||||
commandId: 'test.command1',
|
||||
combo: { key: 'C', ctrl: true }
|
||||
})
|
||||
store.addDefaultKeybinding(defaultKeybinding)
|
||||
store.unsetKeybinding(defaultKeybinding)
|
||||
|
||||
const userKeybinding = new KeybindingImpl({
|
||||
commandId: 'test.command2',
|
||||
combo: { key: 'C', ctrl: true }
|
||||
})
|
||||
store.addUserKeybinding(userKeybinding)
|
||||
|
||||
expect(store.keybindings).toHaveLength(1)
|
||||
expect(store.getKeybinding(userKeybinding.combo)).toEqual(userKeybinding)
|
||||
})
|
||||
|
||||
it('should unset user keybindings', () => {
|
||||
const store = useKeybindingStore()
|
||||
const keybinding = new KeybindingImpl({
|
||||
@@ -119,4 +138,29 @@ describe('useKeybindingStore', () => {
|
||||
|
||||
expect(() => store.unsetKeybinding(keybinding)).toThrow()
|
||||
})
|
||||
|
||||
it('should remove unset keybinding when adding back a default keybinding', () => {
|
||||
const store = useKeybindingStore()
|
||||
const defaultKeybinding = new KeybindingImpl({
|
||||
commandId: 'test.command',
|
||||
combo: { key: 'I', ctrl: true }
|
||||
})
|
||||
|
||||
// Add default keybinding
|
||||
store.addDefaultKeybinding(defaultKeybinding)
|
||||
expect(store.keybindings).toHaveLength(1)
|
||||
|
||||
// Unset the default keybinding
|
||||
store.unsetKeybinding(defaultKeybinding)
|
||||
expect(store.keybindings).toHaveLength(0)
|
||||
|
||||
// Add the same keybinding as a user keybinding
|
||||
store.addUserKeybinding(defaultKeybinding)
|
||||
|
||||
// Check that the keybinding is back and not in the unset list
|
||||
expect(store.keybindings).toHaveLength(1)
|
||||
expect(store.getKeybinding(defaultKeybinding.combo)).toEqual(
|
||||
defaultKeybinding
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user