mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fix keybindings
This commit is contained in:
parent
0122b0accc
commit
97eff2b113
@ -13,7 +13,7 @@
|
|||||||
keyText += e.key;
|
keyText += e.key;
|
||||||
|
|
||||||
const commandsValue = get(commandsCustomized);
|
const commandsValue = get(commandsCustomized);
|
||||||
const commandsFiltered: any = Object.values(commandsValue).filter(
|
let commandsFiltered: any = Object.values(commandsValue).filter(
|
||||||
(x: any) =>
|
(x: any) =>
|
||||||
x.keyText &&
|
x.keyText &&
|
||||||
resolveKeyText(x.keyText)
|
resolveKeyText(x.keyText)
|
||||||
@ -34,7 +34,20 @@
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
commandsFiltered.length > 1 &&
|
||||||
|
commandsFiltered.find(x => x.systemCommand) &&
|
||||||
|
commandsFiltered.find(x => !x.systemCommand)
|
||||||
|
) {
|
||||||
|
commandsFiltered = commandsFiltered.filter(x => !x.systemCommand);
|
||||||
|
}
|
||||||
|
|
||||||
const notGroup = commandsFiltered.filter(x => x.enabled && !x.isGroupCommand);
|
const notGroup = commandsFiltered.filter(x => x.enabled && !x.isGroupCommand);
|
||||||
|
|
||||||
|
if (notGroup.length > 1) {
|
||||||
|
console.log('Warning, multiple commands mapped to', keyText, notGroup);
|
||||||
|
}
|
||||||
|
|
||||||
if (notGroup.length == 1) {
|
if (notGroup.length == 1) {
|
||||||
const command = notGroup[0];
|
const command = notGroup[0];
|
||||||
if (command.onClick) command.onClick();
|
if (command.onClick) command.onClick();
|
||||||
@ -44,6 +57,10 @@
|
|||||||
|
|
||||||
const group = commandsFiltered.filter(x => x.enabled && x.isGroupCommand);
|
const group = commandsFiltered.filter(x => x.enabled && x.isGroupCommand);
|
||||||
|
|
||||||
|
if (group.length > 1) {
|
||||||
|
console.log('Warning, multiple commands mapped to', keyText, group);
|
||||||
|
}
|
||||||
|
|
||||||
if (group.length == 1) {
|
if (group.length == 1) {
|
||||||
const command = group[0];
|
const command = group[0];
|
||||||
runGroupCommand(command.group);
|
runGroupCommand(command.group);
|
||||||
|
@ -28,6 +28,7 @@ export interface GlobalCommand {
|
|||||||
toolbarOrder?: number;
|
toolbarOrder?: number;
|
||||||
disableHandleKeyText?: string;
|
disableHandleKeyText?: string;
|
||||||
isRelatedToTab?: boolean,
|
isRelatedToTab?: boolean,
|
||||||
|
systemCommand?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function registerCommand(command: GlobalCommand) {
|
export default function registerCommand(command: GlobalCommand) {
|
||||||
|
@ -695,6 +695,7 @@ registerCommand({
|
|||||||
category: 'Edit',
|
category: 'Edit',
|
||||||
name: 'Undo',
|
name: 'Undo',
|
||||||
keyText: 'CtrlOrCommand+Z',
|
keyText: 'CtrlOrCommand+Z',
|
||||||
|
systemCommand: true,
|
||||||
testEnabled: () => getElectron() != null,
|
testEnabled: () => getElectron() != null,
|
||||||
onClick: () => getElectron().send('window-action', 'undo'),
|
onClick: () => getElectron().send('window-action', 'undo'),
|
||||||
});
|
});
|
||||||
@ -703,6 +704,7 @@ registerCommand({
|
|||||||
id: 'edit.redo',
|
id: 'edit.redo',
|
||||||
category: 'Edit',
|
category: 'Edit',
|
||||||
name: 'Redo',
|
name: 'Redo',
|
||||||
|
systemCommand: true,
|
||||||
testEnabled: () => getElectron() != null,
|
testEnabled: () => getElectron() != null,
|
||||||
onClick: () => getElectron().send('window-action', 'redo'),
|
onClick: () => getElectron().send('window-action', 'redo'),
|
||||||
});
|
});
|
||||||
@ -712,6 +714,7 @@ registerCommand({
|
|||||||
category: 'Edit',
|
category: 'Edit',
|
||||||
name: 'Cut',
|
name: 'Cut',
|
||||||
keyText: 'CtrlOrCommand+X',
|
keyText: 'CtrlOrCommand+X',
|
||||||
|
systemCommand: true,
|
||||||
testEnabled: () => getElectron() != null,
|
testEnabled: () => getElectron() != null,
|
||||||
onClick: () => getElectron().send('window-action', 'cut'),
|
onClick: () => getElectron().send('window-action', 'cut'),
|
||||||
});
|
});
|
||||||
@ -721,6 +724,7 @@ registerCommand({
|
|||||||
category: 'Edit',
|
category: 'Edit',
|
||||||
name: 'Copy',
|
name: 'Copy',
|
||||||
keyText: 'CtrlOrCommand+C',
|
keyText: 'CtrlOrCommand+C',
|
||||||
|
systemCommand: true,
|
||||||
testEnabled: () => getElectron() != null,
|
testEnabled: () => getElectron() != null,
|
||||||
onClick: () => getElectron().send('window-action', 'copy'),
|
onClick: () => getElectron().send('window-action', 'copy'),
|
||||||
});
|
});
|
||||||
@ -730,6 +734,7 @@ registerCommand({
|
|||||||
category: 'Edit',
|
category: 'Edit',
|
||||||
name: 'Paste',
|
name: 'Paste',
|
||||||
keyText: 'CtrlOrCommand+V',
|
keyText: 'CtrlOrCommand+V',
|
||||||
|
systemCommand: true,
|
||||||
testEnabled: () => getElectron() != null,
|
testEnabled: () => getElectron() != null,
|
||||||
onClick: () => getElectron().send('window-action', 'paste'),
|
onClick: () => getElectron().send('window-action', 'paste'),
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user