feat: add shortcut disable option
This commit is contained in:
@@ -15,7 +15,8 @@ instance.register.shortcutList([
|
|||||||
shift?: boolean;
|
shift?: boolean;
|
||||||
alt?: boolean;
|
alt?: boolean;
|
||||||
isGlobal?: boolean;
|
isGlobal?: boolean;
|
||||||
callback: (command: Command) => any;
|
callback?: (command: Command) => any;
|
||||||
|
disable?: boolean;
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ instance.register.shortcutList([
|
|||||||
shift?: boolean;
|
shift?: boolean;
|
||||||
alt?: boolean;
|
alt?: boolean;
|
||||||
isGlobal?: boolean;
|
isGlobal?: boolean;
|
||||||
callback: (command: Command) => any;
|
callback?: (command: Command) => any;
|
||||||
|
disable?: boolean;
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ export class Shortcut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _addShortcutList(payload: IRegisterShortcut[]) {
|
private _addShortcutList(payload: IRegisterShortcut[]) {
|
||||||
for (let s = 0; s < payload.length; s++) {
|
for (let s = payload.length - 1; s >= 0; s--) {
|
||||||
const shortCut = payload[s]
|
const shortCut = payload[s]
|
||||||
if (shortCut.isGlobal) {
|
if (shortCut.isGlobal) {
|
||||||
this.globalShortcutList.push(shortCut)
|
this.globalShortcutList.unshift(shortCut)
|
||||||
} else {
|
} else {
|
||||||
this.agentShortcutList.push(shortCut)
|
this.agentShortcutList.unshift(shortCut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,8 +69,10 @@ export class Shortcut {
|
|||||||
evt.altKey === !!shortCut.alt &&
|
evt.altKey === !!shortCut.alt &&
|
||||||
evt.key === shortCut.key
|
evt.key === shortCut.key
|
||||||
) {
|
) {
|
||||||
shortCut.callback(this.command)
|
if (!shortCut.disable) {
|
||||||
evt.preventDefault()
|
shortCut?.callback?.(this.command)
|
||||||
|
evt.preventDefault()
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ export interface IRegisterShortcut {
|
|||||||
shift?: boolean
|
shift?: boolean
|
||||||
alt?: boolean // windows:alt || mac:option
|
alt?: boolean // windows:alt || mac:option
|
||||||
isGlobal?: boolean
|
isGlobal?: boolean
|
||||||
callback: (command: Command) => any
|
callback?: (command: Command) => any
|
||||||
|
disable?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user