enh: ctrl+shift+delete chat delete support

This commit is contained in:
Timothy J. Baek 2024-10-19 01:06:30 -07:00
parent 99f70cac8b
commit 0556479cbe
4 changed files with 16 additions and 13 deletions

View File

@ -1,12 +1,11 @@
<script lang="ts">
import { onMount, getContext, createEventDispatcher } from 'svelte';
import { fade } from 'svelte/transition';
const i18n = getContext('i18n');
import { flyAndScale } from '$lib/utils/transitions';
const dispatch = createEventDispatcher();
import { fade } from 'svelte/transition';
import { flyAndScale } from '$lib/utils/transitions';
export let title = '';
export let message = '';
@ -27,6 +26,12 @@
console.log('Escape');
show = false;
}
if (event.key === 'Enter') {
console.log('Enter');
show = false;
dispatch('confirm', inputValue);
}
};
onMount(() => {
@ -56,7 +61,7 @@
}}
>
<div
class=" m-auto rounded-2xl max-w-full w-[32rem] mx-2 bg-gray-50 dark:bg-gray-950 max-h-[100dvh] shadow-3xl border border-gray-850"
class=" m-auto rounded-2xl max-w-full w-[32rem] mx-2 bg-gray-50 dark:bg-gray-950 max-h-[100dvh] shadow-3xl"
in:flyAndScale
on:mousedown={(e) => {
e.stopPropagation();

View File

@ -58,13 +58,7 @@
let shiftKey = false;
let selectedChatId = null;
let deleteChat = null;
let showDeleteConfirm = false;
let showDropdown = false;
let selectedTagName = null;
let showPinnedChat = true;
// Pagination variables

View File

@ -389,7 +389,7 @@
id="delete-chat-button"
class="hidden"
on:click={() => {
dispatch('delete');
showDeleteConfirm = true;
}}
>
<svg

View File

@ -165,7 +165,11 @@
}
// Check if Ctrl + Shift + Backspace is pressed
if (isCtrlPressed && isShiftPressed && event.key === 'Backspace') {
if (
isCtrlPressed &&
isShiftPressed &&
(event.key === 'Backspace' || event.key === 'Delete')
) {
event.preventDefault();
console.log('deleteChat');
document.getElementById('delete-chat-button')?.click();