2023-12-28 10:46:57 +00:00
|
|
|
<script lang="ts">
|
2025-10-12 00:59:08 +00:00
|
|
|
import { getContext, onMount } from 'svelte';
|
2023-12-28 10:46:57 +00:00
|
|
|
import Modal from '../common/Modal.svelte';
|
2025-10-12 00:59:08 +00:00
|
|
|
import { shortcuts } from '$lib/shortcuts';
|
2025-10-18 04:32:03 +00:00
|
|
|
import { settings } from '$lib/stores';
|
2025-10-12 00:59:08 +00:00
|
|
|
import ShortcutItem from './ShortcutItem.svelte';
|
|
|
|
|
import XMark from '$lib/components/icons/XMark.svelte';
|
|
|
|
|
|
|
|
|
|
type CategorizedShortcuts = {
|
|
|
|
|
[category: string]: {
|
|
|
|
|
left: Shortcut[];
|
|
|
|
|
right: Shortcut[];
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-12-28 10:46:57 +00:00
|
|
|
|
2024-03-02 20:38:51 +00:00
|
|
|
const i18n = getContext('i18n');
|
|
|
|
|
|
2023-12-28 10:46:57 +00:00
|
|
|
export let show = false;
|
2025-10-12 00:59:08 +00:00
|
|
|
|
|
|
|
|
let categorizedShortcuts: CategorizedShortcuts = {};
|
|
|
|
|
let isMac = false;
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
isMac = /Mac/i.test(navigator.userAgent);
|
2025-10-18 04:32:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$: {
|
|
|
|
|
const allShortcuts = Object.values(shortcuts).filter((shortcut) => {
|
|
|
|
|
if (!shortcut.setting) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return $settings[shortcut.setting.id] === shortcut.setting.value;
|
|
|
|
|
});
|
2025-10-12 00:59:08 +00:00
|
|
|
|
|
|
|
|
const result = allShortcuts.reduce((acc, shortcut) => {
|
|
|
|
|
const category = shortcut.category;
|
|
|
|
|
if (!acc[category]) {
|
|
|
|
|
acc[category] = [];
|
|
|
|
|
}
|
|
|
|
|
acc[category].push(shortcut);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
|
2025-10-18 04:32:03 +00:00
|
|
|
const newCategorizedShortcuts = {};
|
2025-10-12 00:59:08 +00:00
|
|
|
for (const category in result) {
|
|
|
|
|
const half = Math.ceil(result[category].length / 2);
|
2025-10-18 04:32:03 +00:00
|
|
|
newCategorizedShortcuts[category] = {
|
2025-10-12 00:59:08 +00:00
|
|
|
left: result[category].slice(0, half),
|
|
|
|
|
right: result[category].slice(half)
|
|
|
|
|
};
|
|
|
|
|
}
|
2025-10-18 04:32:03 +00:00
|
|
|
categorizedShortcuts = newCategorizedShortcuts;
|
|
|
|
|
}
|
2023-12-28 10:46:57 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<Modal bind:show>
|
2024-05-02 09:47:16 +00:00
|
|
|
<div class="text-gray-700 dark:text-gray-100">
|
2025-10-12 00:59:08 +00:00
|
|
|
<div class="flex justify-between dark:text-gray-300 px-5 pt-4">
|
2025-10-18 04:32:03 +00:00
|
|
|
<div class="text-lg font-medium self-center">{$i18n.t('Keyboard Shortcuts')}</div>
|
2025-10-12 00:59:08 +00:00
|
|
|
<button class="self-center" on:click={() => (show = false)}>
|
2025-06-27 11:44:26 +00:00
|
|
|
<XMark className={'size-5'} />
|
2023-12-28 10:46:57 +00:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-10-12 00:59:08 +00:00
|
|
|
{#each Object.entries(categorizedShortcuts) as [category, columns], i}
|
|
|
|
|
{#if i > 0}
|
|
|
|
|
<div class="px-5">
|
|
|
|
|
<div class="w-full border-t dark:border-gray-700 border-gray-200" />
|
2023-12-28 10:46:57 +00:00
|
|
|
</div>
|
2025-10-12 00:59:08 +00:00
|
|
|
{/if}
|
2023-12-28 10:46:57 +00:00
|
|
|
|
2025-10-12 00:59:08 +00:00
|
|
|
<div class="flex justify-between dark:text-gray-300 px-5 pt-4">
|
|
|
|
|
<div class="text-lg font-medium self-center">{$i18n.t(category)}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-col md:flex-row w-full p-5 md:space-x-4 dark:text-gray-200">
|
|
|
|
|
<div class="flex flex-col w-full sm:flex-row sm:justify-center sm:space-x-6">
|
|
|
|
|
<div class="flex flex-col space-y-3 w-full self-start">
|
|
|
|
|
{#each columns.left as shortcut}
|
|
|
|
|
<ShortcutItem {shortcut} {isMac} />
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-col space-y-3 w-full self-start">
|
|
|
|
|
{#each columns.right as shortcut}
|
|
|
|
|
<ShortcutItem {shortcut} {isMac} />
|
|
|
|
|
{/each}
|
2023-12-28 10:46:57 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-10-12 00:59:08 +00:00
|
|
|
{/each}
|
2024-05-03 09:49:58 +00:00
|
|
|
|
2025-06-12 13:47:17 +00:00
|
|
|
<div class="px-5 pb-4 text-xs text-gray-500 dark:text-gray-400">
|
2025-10-12 00:59:08 +00:00
|
|
|
{@html $i18n.t(
|
2025-06-12 13:47:17 +00:00
|
|
|
'Shortcuts with an asterisk (*) are situational and only active under specific conditions.'
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2024-05-03 21:03:22 +00:00
|
|
|
</div>
|
|
|
|
|
</Modal>
|
2023-12-28 10:46:57 +00:00
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
input::-webkit-outer-spin-button,
|
|
|
|
|
input::-webkit-inner-spin-button {
|
|
|
|
|
-webkit-appearance: none;
|
2025-10-12 00:59:08 +00:00
|
|
|
margin: 0;
|
2023-12-28 10:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tabs::-webkit-scrollbar {
|
2025-10-12 00:59:08 +00:00
|
|
|
display: none;
|
2023-12-28 10:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tabs {
|
2025-10-12 00:59:08 +00:00
|
|
|
-ms-overflow-style: none;
|
|
|
|
|
scrollbar-width: none;
|
2023-12-28 10:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input[type='number'] {
|
2025-10-12 00:59:08 +00:00
|
|
|
-moz-appearance: textfield;
|
2023-12-28 10:46:57 +00:00
|
|
|
}
|
2025-10-12 00:59:08 +00:00
|
|
|
</style>
|