Merge branch 'master' into develop

This commit is contained in:
Jan Prochazka
2022-04-18 11:10:12 +02:00
8 changed files with 108 additions and 8 deletions

View File

@@ -13,7 +13,7 @@
keyText += e.key;
const commandsValue = get(commandsCustomized);
const commandsFiltered: any = Object.values(commandsValue).filter(
let commandsFiltered: any = Object.values(commandsValue).filter(
(x: any) =>
x.keyText &&
resolveKeyText(x.keyText)
@@ -34,7 +34,20 @@
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);
if (notGroup.length > 1) {
console.log('Warning, multiple commands mapped to', keyText, notGroup);
}
if (notGroup.length == 1) {
const command = notGroup[0];
if (command.onClick) command.onClick();
@@ -44,6 +57,10 @@
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) {
const command = group[0];
runGroupCommand(command.group);

View File

@@ -28,6 +28,7 @@ export interface GlobalCommand {
toolbarOrder?: number;
disableHandleKeyText?: string;
isRelatedToTab?: boolean,
systemCommand?: boolean;
}
export default function registerCommand(command: GlobalCommand) {

View File

@@ -690,6 +690,55 @@ registerCommand({
onClick: () => getElectron().send('window-action', 'zoomreset'),
});
registerCommand({
id: 'edit.undo',
category: 'Edit',
name: 'Undo',
keyText: 'CtrlOrCommand+Z',
systemCommand: true,
testEnabled: () => getElectron() != null,
onClick: () => getElectron().send('window-action', 'undo'),
});
registerCommand({
id: 'edit.redo',
category: 'Edit',
name: 'Redo',
systemCommand: true,
testEnabled: () => getElectron() != null,
onClick: () => getElectron().send('window-action', 'redo'),
});
registerCommand({
id: 'edit.cut',
category: 'Edit',
name: 'Cut',
keyText: 'CtrlOrCommand+X',
systemCommand: true,
testEnabled: () => getElectron() != null,
onClick: () => getElectron().send('window-action', 'cut'),
});
registerCommand({
id: 'edit.copy',
category: 'Edit',
name: 'Copy',
keyText: 'CtrlOrCommand+C',
systemCommand: true,
testEnabled: () => getElectron() != null,
onClick: () => getElectron().send('window-action', 'copy'),
});
registerCommand({
id: 'edit.paste',
category: 'Edit',
name: 'Paste',
keyText: 'CtrlOrCommand+V',
systemCommand: true,
testEnabled: () => getElectron() != null,
onClick: () => getElectron().send('window-action', 'paste'),
});
const electron = getElectron();
if (electron) {
electron.addEventListener('run-command', (e, commandId) => runCommand(commandId));

View File

@@ -47,7 +47,7 @@
name: 'Insert new row',
toolbarName: 'New row',
icon: 'icon add',
keyText: 'Insert',
keyText: isMac() ? 'Command+I' : 'Insert',
testEnabled: () => getCurrentDataGrid()?.getGrider()?.editable,
onClick: () => getCurrentDataGrid().insertNewRow(),
});
@@ -191,7 +191,6 @@
id: 'dataGrid.clearFilter',
category: 'Data grid',
name: 'Clear filter',
keyText: 'CtrlOrCommand+I',
testEnabled: () => getCurrentDataGrid()?.clearFilterEnabled(),
onClick: () => getCurrentDataGrid().clearFilter(),
});
@@ -306,7 +305,7 @@
import EditJsonModal from '../modals/EditJsonModal.svelte';
import { apiCall } from '../utility/api';
import getElectron from '../utility/getElectron';
import { isCtrlOrCommandKey } from '../utility/common';
import { isCtrlOrCommandKey, isMac } from '../utility/common';
export let onLoadNextData = undefined;
export let grider = undefined;

View File

@@ -16,7 +16,7 @@
{#if !isMac()}
<div class="icon"><img src="logo192.png" width="20" height="20" /></div>
<div class="menu">
<HorizontalMenu items={mainMenuDefinition} />
<HorizontalMenu items={mainMenuDefinition({ editMenu: !!electron })} />
</div>
{/if}
<div class="title">{title}</div>

View File

@@ -76,7 +76,7 @@
const rect = domMainMenu.getBoundingClientRect();
const left = rect.right;
const top = rect.top;
const items = mainMenuDefinition;
const items = mainMenuDefinition({ editMenu: false });
currentDropDownMenu.set({ left, top, items });
}