mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 15:25:59 +00:00
close tab with confirmation on double ctrl+W
This commit is contained in:
@@ -1,15 +1,28 @@
|
||||
<script lang="ts">
|
||||
import { get } from 'svelte/store';
|
||||
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
||||
|
||||
import FormProvider from '../forms/FormProvider.svelte';
|
||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
import { getKeyTextFromEvent, resolveKeyText } from '../utility/common';
|
||||
import ModalBase from './ModalBase.svelte';
|
||||
import { closeCurrentModal } from './modalTools';
|
||||
import { commandsCustomized } from '../stores';
|
||||
|
||||
export let tabs;
|
||||
export let onConfirm;
|
||||
export let onCancel;
|
||||
|
||||
function handleKeyDown(e) {
|
||||
const commandsValue = get(commandsCustomized);
|
||||
|
||||
const command = commandsValue['tabs.closeTab'];
|
||||
if (resolveKeyText(command.keyText).toLowerCase() == getKeyTextFromEvent(e).toLowerCase()) {
|
||||
closeCurrentModal();
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<FormProvider>
|
||||
@@ -45,3 +58,5 @@
|
||||
</svelte:fragment>
|
||||
</ModalBase>
|
||||
</FormProvider>
|
||||
|
||||
<svelte:window on:keydown={handleKeyDown} />
|
||||
|
||||
Reference in New Issue
Block a user