mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 00:36:01 +00:00
editor context menu, focus fix
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
<script lang="ts" context="module">
|
||||
import { commands } from '../stores';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
function handleKeyDown(e) {
|
||||
export function handleCommandKeyDown(e) {
|
||||
let keyText = '';
|
||||
if (e.ctrlKey) keyText += 'Ctrl+';
|
||||
if (e.shiftKey) keyText += 'Shift+';
|
||||
@@ -20,7 +20,13 @@
|
||||
.toLowerCase()
|
||||
.split('|')
|
||||
.map(x => x.trim())
|
||||
.includes(keyText.toLowerCase())
|
||||
.includes(keyText.toLowerCase()) &&
|
||||
(x.disableHandleKeyText == null ||
|
||||
!x.disableHandleKeyText
|
||||
.toLowerCase()
|
||||
.split('|')
|
||||
.map(x => x.trim())
|
||||
.includes(keyText.toLowerCase()))
|
||||
);
|
||||
|
||||
if (command) {
|
||||
@@ -30,4 +36,4 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown={handleKeyDown} />
|
||||
<svelte:window on:keydown={handleCommandKeyDown} />
|
||||
|
||||
@@ -31,7 +31,13 @@
|
||||
|
||||
$: selectedIndex = true ? 0 : filter;
|
||||
|
||||
onMount(() => domInput.focus());
|
||||
onMount(() => {
|
||||
const oldFocus = document.activeElement;
|
||||
domInput.focus();
|
||||
return () => {
|
||||
if (oldFocus) oldFocus.focus();
|
||||
};
|
||||
});
|
||||
|
||||
$: sortedComands = _.sortBy(
|
||||
Object.values($commands).filter(x => x.enabled),
|
||||
|
||||
@@ -20,6 +20,7 @@ export interface GlobalCommand {
|
||||
showDisabled?: boolean;
|
||||
toolbarName?: string;
|
||||
toolbarOrder?: number;
|
||||
disableHandleKeyText?: string;
|
||||
}
|
||||
|
||||
export default function registerCommand(command: GlobalCommand) {
|
||||
|
||||
Reference in New Issue
Block a user