mirror of
https://github.com/sharevb/it-tools.git
synced 2026-12-01 01:14:13 +03:00
commit d20c027957ddbdd26194550cfbf5917c43585779 Merge: d91a867c63fbd3b4Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Dec 12 23:42:30 2024 +0100 Merge branch 'main' into translatable commit d91a867cf113369bd23b297b15040042ac74daca Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sun Oct 27 13:48:36 2024 +0000 update commit 9c023636c655554a560f03035cfbeaf7d0fed8f7 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sun Oct 27 13:48:03 2024 +0000 update commit 32ca8e35de981811b6445d166367918bb64df67c Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sun Oct 27 13:47:19 2024 +0000 update commit 2b94b06ac1236788018617b2ad77c35a8e65355e Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sun Oct 27 13:46:19 2024 +0000 update commit aca9d139434ead3b6f6b827928f1ccddfcacf68f Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sun Oct 27 13:43:36 2024 +0000 update commit 78267978388d756879bb059d02e19b8ff37001e0 Merge: f9031a980b1b98f9Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sat Oct 26 00:08:54 2024 +0200 Merge branch 'main' into translatable commit f9031a98f66ef9ef94dec43ca3eec49a070e6a59 Merge: eaab7a8bf8366664Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Oct 24 22:24:45 2024 +0200 Merge branch 'main' into translatable commit eaab7a8ba26c07603c46a4f48d7b77bc79588c5f Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sun Sep 29 20:22:32 2024 +0000 regex update commit 3cc6a2547e6de9b99fddf527e5c2eda1de9a3d53 Merge: e02917301c35ac37Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sun Sep 29 22:20:54 2024 +0200 Merge branch 'main' into translatable commit e02917305eb5ee50efa67c6b3918a6e6253a2999 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sat Sep 21 10:11:08 2024 +0000 improve regex commit c69d55afe1b20570102f5b3a57e53983d8366f10 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sat Sep 21 09:41:53 2024 +0000 fix commit 24c9131f80377a74543e0ed1a4a6d2fc470225d6 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sat Sep 21 09:40:54 2024 +0000 search commit e3992d9187f06f74ef9222fb94d66d57717dc25e Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Sat Sep 21 09:30:17 2024 +0000 copy commit 563900dc1130495293d2db418f86922a6c31f9e0 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Fri Sep 20 20:11:39 2024 +0000 improve commit 95a1939cfcaf8fee797d86beba809ffa27f93c14 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Fri Sep 20 20:09:47 2024 +0000 improve commit 75c790062da0e115494a6b1440fd6d81427205db Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Fri Sep 20 20:02:57 2024 +0000 fix commit bb7d703cc5f1583fbbeca6cf1f30b87cf1045de5 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Fri Sep 20 19:59:02 2024 +0000 regex commit 6b8cfca29d62c775f3b790e025707283d235be51 Merge: 9fa9dc04f5c4ab19Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Fri Sep 20 20:50:51 2024 +0200 Merge branch 'main' into translatable commit 9fa9dc047ea3d93fba242c77aef2ba747f6f9240 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Sep 5 17:28:55 2024 +0000 revert commit 3eefdacf9c7281b845fae5a418815cb0f018ce9e Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Sep 5 17:26:23 2024 +0000 fix commit ab7b3a6588f9d1f05db5286a722717b359b37177 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Sep 5 17:21:43 2024 +0000 copy commit 917ff521ea6073e5fbf4862e3af5f81fbc6747ef Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Sep 5 17:01:34 2024 +0000 more tools commit c756058c5c759066bbc4672f29cc39b52f55a0da Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Sep 5 16:46:55 2024 +0000 json xml texts commit f5a5ca65507cf33a9c0aaf11aa8702f691941762 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Sep 5 16:31:40 2024 +0000 email-normalizer-texts commit 0a72a2b24b128fccee6349966d7c5047bfc849ba Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Sep 5 16:12:26 2024 +0000 ascii-texts commit 8e4a2206a72e087d3e06b7c6864350ba21a97921 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Tue Sep 3 16:54:31 2024 +0000 qr code generator commit ff46f178ce8073cc0ce574a39b8f0caf0b53c612 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Tue Aug 27 17:04:48 2024 +0000 fix commit 42170052eca699b68610299c0f50103ef9ba2234 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Tue Aug 27 17:02:01 2024 +0000 fix commit 867d415fea8e5fd7d48c9d6c3ac2dd702d3da582 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Tue Aug 27 16:47:17 2024 +0000 copy commit a97e1897e59d5701aef9f99349d24600a12ca505 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Tue Aug 27 16:28:27 2024 +0000 markdown-to-html commit b986c49df60c28f4256cf6e53e2ca007d97bba89 Merge: 028a4ce387984e20Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Tue Aug 27 18:12:30 2024 +0200 Merge branch 'main' into translatable commit 028a4ce3258342467dc1d9b8c9847706fa3e3816 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Aug 15 19:13:03 2024 +0000 fix commit bff4984998a293e6455ad2695061c2aff2c08569 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Aug 15 18:58:26 2024 +0000 fix commit c6ca07e7a0374aeb3f97c0afde1a4b16976cebaf Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Aug 15 16:51:14 2024 +0000 fix commit 6892b68819f036580bbf302a3ab3bd9d03bf07b4 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Aug 15 16:43:17 2024 +0000 more texts commit 7c5f6e7797ec91d42a1a6bef6a241f2be1c38a91 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Aug 15 14:44:39 2024 +0000 email normalizer commit 174046079e3b35ee1e7cb505d3456b394eadab79 Merge: a81514d3318fb6efAuthor: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Thu Aug 15 16:38:40 2024 +0200 Merge branch 'main' into translatable commit a81514d383bec3049c00ed434904bb7363864388 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Mon Aug 12 17:39:18 2024 +0000 more tools commit 5ceb46855df890280e6256cc8665512c676d8ae8 Merge: 703e5e6af1a5489eAuthor: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Mon Aug 12 19:30:26 2024 +0200 Merge branch 'main' into translatable commit 703e5e6abb7cad27d5a3bd60fd1b31e0427cb1c0 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Fri Aug 2 14:58:35 2024 +0000 update commit 1d15baaf291e5898b9ffcab58d85033a5fca5f7e Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Fri Jun 21 20:34:05 2024 +0000 package commit e926a79180e4c93a3b899a0f81ea925a03d208a1 Author: steffenrapp <88974099+steffenrapp@users.noreply.github.com> Date: Fri Jun 21 20:25:47 2024 +0000 fix(i18n): Make rest of the tools translatable and translate them to German
159 lines
3.9 KiB
Vue
159 lines
3.9 KiB
Vue
<script setup lang="ts">
|
|
import { storeToRefs } from 'pinia';
|
|
import _ from 'lodash';
|
|
import { useCommandPaletteStore } from './command-palette.store';
|
|
import type { PaletteOption } from './command-palette.types';
|
|
|
|
const isModalOpen = ref(false);
|
|
const inputRef = ref();
|
|
const router = useRouter();
|
|
const isMac = computed(() => window.navigator.userAgent.toLowerCase().includes('mac'));
|
|
|
|
const commandPaletteStore = useCommandPaletteStore();
|
|
const { searchPrompt, filteredSearchResult } = storeToRefs(commandPaletteStore);
|
|
|
|
const keys = useMagicKeys({
|
|
passive: false,
|
|
onEventFired(e) {
|
|
if (e.ctrlKey && e.key === 'k' && e.type === 'keydown') {
|
|
e.preventDefault();
|
|
}
|
|
|
|
if (e.metaKey && e.key === 'k' && e.type === 'keydown') {
|
|
e.preventDefault();
|
|
}
|
|
},
|
|
});
|
|
|
|
whenever(isModalOpen, () => inputRef.value?.focus());
|
|
|
|
whenever(keys.ctrl_k, open);
|
|
whenever(keys.meta_k, open);
|
|
whenever(keys.escape, close);
|
|
|
|
function open() {
|
|
return isModalOpen.value = true;
|
|
}
|
|
|
|
function close() {
|
|
isModalOpen.value = false;
|
|
searchPrompt.value = '';
|
|
}
|
|
|
|
const selectedOptionIndex = ref(0);
|
|
|
|
function handleKeydown(event: KeyboardEvent) {
|
|
const { key } = event;
|
|
const isEnterPressed = key === 'Enter';
|
|
const isArrowUpOrDown = ['ArrowUp', 'ArrowDown'].includes(key);
|
|
const isArrowDown = key === 'ArrowDown';
|
|
|
|
if (isArrowUpOrDown) {
|
|
const increment = isArrowDown ? 1 : -1;
|
|
const maxIndex = Math.max(_.chain(filteredSearchResult.value).values().flatten().size().value() - 1, 0);
|
|
|
|
selectedOptionIndex.value = Math.min(Math.max(selectedOptionIndex.value + increment, 0), maxIndex);
|
|
|
|
return;
|
|
}
|
|
|
|
if (isEnterPressed) {
|
|
const option = _.chain(filteredSearchResult.value)
|
|
.values()
|
|
.flatten()
|
|
.nth(selectedOptionIndex.value)
|
|
.value();
|
|
|
|
activateOption(option);
|
|
}
|
|
}
|
|
|
|
function getOptionIndex(option: PaletteOption) {
|
|
return _.chain(filteredSearchResult.value)
|
|
.values()
|
|
.flatten()
|
|
.findIndex(o => o === option)
|
|
.value();
|
|
}
|
|
|
|
function activateOption(option: PaletteOption) {
|
|
const { closeOnSelect } = option;
|
|
|
|
if (option.action) {
|
|
option.action();
|
|
|
|
if (closeOnSelect) {
|
|
close();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
const closeAfterNavigation = closeOnSelect || _.isUndefined(closeOnSelect);
|
|
|
|
if (option.to) {
|
|
router.push(option.to);
|
|
|
|
if (closeAfterNavigation) {
|
|
close();
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (option.href) {
|
|
window.open(option.href, '_blank');
|
|
|
|
if (closeAfterNavigation) {
|
|
close();
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div flex-1>
|
|
<c-button w-full important:justify-start @click="isModalOpen = true">
|
|
<span flex items-center gap-3 op-40>
|
|
|
|
<icon-mdi-search />
|
|
{{ $t('search.label') }}
|
|
|
|
<span hidden flex-1 border border-current border-op-40 rounded border-solid px-5px py-3px sm:inline>
|
|
{{ isMac ? 'Cmd' : 'Ctrl' }} + K
|
|
</span>
|
|
</span>
|
|
</c-button>
|
|
|
|
<c-modal v-model:open="isModalOpen" class="palette-modal" overflow-y-auto shadow-xl important:max-w-650px pretty-scrollbar important:pa-12px @keydown="handleKeydown">
|
|
<c-input-text ref="inputRef" v-model:value="searchPrompt" raw-text :placeholder="$t('search.placeholder')" autofocus clearable />
|
|
|
|
<div v-for="(options, category) in filteredSearchResult" :key="category">
|
|
<div ml-3 mt-3 text-sm font-bold text-primary op-60>
|
|
{{ category }}
|
|
</div>
|
|
<command-palette-option v-for="option in options" :key="option.name" :option="option" :selected="selectedOptionIndex === getOptionIndex(option)" @activated="activateOption" />
|
|
</div>
|
|
</c-modal>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped lang="less">
|
|
.c-input-text {
|
|
font-size: 18px;
|
|
|
|
::v-deep(.input-wrapper) {
|
|
padding: 4px;
|
|
padding-left: 18px;
|
|
}
|
|
}
|
|
|
|
::v-deep(.palette-modal) {
|
|
max-height: 80vh;
|
|
}
|
|
|
|
.c-modal--overlay {
|
|
align-items: flex-start !important;
|
|
padding-top: 80px;
|
|
}
|
|
</style>
|