mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
handle ctrl & command key
This commit is contained in:
parent
5a42e8e963
commit
cc639df566
@ -306,6 +306,7 @@
|
|||||||
import EditJsonModal from '../modals/EditJsonModal.svelte';
|
import EditJsonModal from '../modals/EditJsonModal.svelte';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
|
import { isCtrlOrCommandKey } from '../utility/common';
|
||||||
|
|
||||||
export let onLoadNextData = undefined;
|
export let onLoadNextData = undefined;
|
||||||
export let grider = undefined;
|
export let grider = undefined;
|
||||||
@ -976,7 +977,7 @@
|
|||||||
const oldCurrentCell = currentCell;
|
const oldCurrentCell = currentCell;
|
||||||
currentCell = cell;
|
currentCell = cell;
|
||||||
|
|
||||||
if (event.ctrlKey) {
|
if (isCtrlOrCommandKey(event)) {
|
||||||
if (isRegularCell(cell)) {
|
if (isRegularCell(cell)) {
|
||||||
if (selectedCells.find(x => x[0] == cell[0] && x[1] == cell[1])) {
|
if (selectedCells.find(x => x[0] == cell[0] && x[1] == cell[1])) {
|
||||||
selectedCells = selectedCells.filter(x => x[0] != cell[0] || x[1] != cell[1]);
|
selectedCells = selectedCells.filter(x => x[0] != cell[0] || x[1] != cell[1]);
|
||||||
@ -1116,6 +1117,7 @@
|
|||||||
if (
|
if (
|
||||||
!event.ctrlKey &&
|
!event.ctrlKey &&
|
||||||
!event.altKey &&
|
!event.altKey &&
|
||||||
|
!event.metaKey &&
|
||||||
((event.keyCode >= keycodes.a && event.keyCode <= keycodes.z) ||
|
((event.keyCode >= keycodes.a && event.keyCode <= keycodes.z) ||
|
||||||
(event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) ||
|
(event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) ||
|
||||||
(event.keyCode >= keycodes.numPad0 && event.keyCode <= keycodes.numPad9) ||
|
(event.keyCode >= keycodes.numPad0 && event.keyCode <= keycodes.numPad9) ||
|
||||||
@ -1150,7 +1152,7 @@
|
|||||||
function handleCursorMove(event) {
|
function handleCursorMove(event) {
|
||||||
if (!isRegularCell(currentCell)) return null;
|
if (!isRegularCell(currentCell)) return null;
|
||||||
let rowCount = grider.rowCount;
|
let rowCount = grider.rowCount;
|
||||||
if (event.ctrlKey) {
|
if (isCtrlOrCommandKey(event)) {
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
case keycodes.upArrow:
|
case keycodes.upArrow:
|
||||||
case keycodes.pageUp:
|
case keycodes.pageUp:
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
import createRef from '../utility/createRef';
|
import createRef from '../utility/createRef';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { arrayToHexString, parseCellValue, stringifyCellValue } from 'dbgate-tools';
|
import { arrayToHexString, parseCellValue, stringifyCellValue } from 'dbgate-tools';
|
||||||
|
import { isCtrlOrCommandKey } from '../utility/common';
|
||||||
|
|
||||||
export let inplaceEditorState;
|
export let inplaceEditorState;
|
||||||
export let dispatchInsplaceEditor;
|
export let dispatchInsplaceEditor;
|
||||||
@ -43,7 +44,7 @@
|
|||||||
dispatchInsplaceEditor({ type: 'close', mode: 'enter' });
|
dispatchInsplaceEditor({ type: 'close', mode: 'enter' });
|
||||||
break;
|
break;
|
||||||
case keycodes.s:
|
case keycodes.s:
|
||||||
if (event.ctrlKey) {
|
if (isCtrlOrCommandKey(event)) {
|
||||||
if (isChangedRef.get()) {
|
if (isChangedRef.get()) {
|
||||||
onSetValue(parseCellValue(domEditor.value));
|
onSetValue(parseCellValue(domEditor.value));
|
||||||
// grider.setCellValue(rowIndex, uniqueName, editor.value);
|
// grider.setCellValue(rowIndex, uniqueName, editor.value);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import { currentThemeDefinition } from '../stores';
|
import { currentThemeDefinition } from '../stores';
|
||||||
import VirtualForeignKeyEditorModal from '../tableeditor/VirtualForeignKeyEditorModal.svelte';
|
import VirtualForeignKeyEditorModal from '../tableeditor/VirtualForeignKeyEditorModal.svelte';
|
||||||
|
import { isCtrlOrCommandKey } from '../utility/common';
|
||||||
import contextMenu from '../utility/contextMenu';
|
import contextMenu from '../utility/contextMenu';
|
||||||
import moveDrag from '../utility/moveDrag';
|
import moveDrag from '../utility/moveDrag';
|
||||||
import ColumnLine from './ColumnLine.svelte';
|
import ColumnLine from './ColumnLine.svelte';
|
||||||
@ -217,7 +218,7 @@
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onBringToFront(table);
|
onBringToFront(table);
|
||||||
if (settings?.canSelectTables && !table?.isSelectedTable) {
|
if (settings?.canSelectTables && !table?.isSelectedTable) {
|
||||||
onSelectTable(table, e.ctrlKey);
|
onSelectTable(table, isCtrlOrCommandKey(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -177,6 +177,7 @@
|
|||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import { copyTextToClipboard, extractRowCopiedValue } from '../utility/clipboard';
|
import { copyTextToClipboard, extractRowCopiedValue } from '../utility/clipboard';
|
||||||
|
import { isCtrlOrCommandKey } from '../utility/common';
|
||||||
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
import createReducer from '../utility/createReducer';
|
import createReducer from '../utility/createReducer';
|
||||||
@ -383,6 +384,7 @@
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
!event.ctrlKey &&
|
!event.ctrlKey &&
|
||||||
|
!event.metaKey &&
|
||||||
!event.altKey &&
|
!event.altKey &&
|
||||||
((event.keyCode >= keycodes.a && event.keyCode <= keycodes.z) ||
|
((event.keyCode >= keycodes.a && event.keyCode <= keycodes.z) ||
|
||||||
(event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) ||
|
(event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) ||
|
||||||
@ -472,7 +474,7 @@
|
|||||||
return moveCurrentCell(columnIndex % formDisplay.columns.length, Math.floor(columnIndex / rowCount) * 2);
|
return moveCurrentCell(columnIndex % formDisplay.columns.length, Math.floor(columnIndex / rowCount) * 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (event.ctrlKey) {
|
if (isCtrlOrCommandKey(event)) {
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
case keycodes.leftArrow:
|
case keycodes.leftArrow:
|
||||||
return moveCurrentCell(currentCell[0], 0);
|
return moveCurrentCell(currentCell[0], 0);
|
||||||
|
@ -64,3 +64,10 @@ export function resolveKeyText(keyText: string): string {
|
|||||||
}
|
}
|
||||||
return keyText.replace('CtrlOrCommand+', 'Ctrl+');
|
return keyText.replace('CtrlOrCommand+', 'Ctrl+');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isCtrlOrCommandKey(event) {
|
||||||
|
if (isMac()) {
|
||||||
|
return event.metaKey;
|
||||||
|
}
|
||||||
|
return event.ctrlKey;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user