Skip to content

Commit 3305c81

Browse files
committed
feat(new tool): Morse converter
Fix CorentinTh#1001
1 parent 80e46c9 commit 3305c81

File tree

6 files changed

+94
-6
lines changed

6 files changed

+94
-6
lines changed

components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ declare module '@vue/runtime-core' {
137137
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
138138
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
139139
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
140+
MorseConverter: typeof import('./src/tools/morse-converter/morse-converter.vue')['default']
140141
NAlert: typeof import('naive-ui')['NAlert']
141142
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
142143
NCheckbox: typeof import('naive-ui')['NCheckbox']

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@tiptap/pm": "2.1.6",
4242
"@tiptap/starter-kit": "2.1.6",
4343
"@tiptap/vue-3": "2.0.3",
44+
"@types/morsee": "^1.0.2",
4445
"@vicons/material": "^0.12.0",
4546
"@vicons/tabler": "^0.12.0",
4647
"@vueuse/core": "^10.3.0",
@@ -70,6 +71,7 @@
7071
"mathjs": "^11.9.1",
7172
"mime-types": "^2.1.35",
7273
"monaco-editor": "^0.43.0",
74+
"morsee": "^1.0.9",
7375
"naive-ui": "^2.35.0",
7476
"netmask": "^2.0.2",
7577
"node-forge": "^1.3.1",

pnpm-lock.yaml

Lines changed: 21 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { tool as base64FileConverter } from './base64-file-converter';
22
import { tool as base64StringConverter } from './base64-string-converter';
33
import { tool as basicAuthGenerator } from './basic-auth-generator';
4+
import { tool as morseConverter } from './morse-converter';
45
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
56
import { tool as numeronymGenerator } from './numeronym-generator';
67
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -100,6 +101,7 @@ export const toolsByCategory: ToolCategory[] = [
100101
listConverter,
101102
tomlToJson,
102103
tomlToYaml,
104+
morseConverter,
103105
],
104106
},
105107
{

src/tools/morse-converter/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ArrowsShuffle } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Morse Code Converter',
6+
path: '/morse-converter',
7+
description: 'Encode/Decode to Morse code',
8+
keywords: ['morse', 'converter'],
9+
component: () => import('./morse-converter.vue'),
10+
icon: ArrowsShuffle,
11+
createdAt: new Date('2024-04-20'),
12+
});
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<script setup lang="ts">
2+
import { decode, encode } from 'morsee';
3+
import { computedCatch } from '@/composable/computed/catchedComputed';
4+
5+
const encodeInput = ref('');
6+
const encodeOutput = computed(() => encode(encodeInput.value));
7+
8+
const decodeInput = ref('');
9+
const [decodeOutput, decodeError] = computedCatch(() => decode(decodeInput.value), {
10+
defaultValue: '',
11+
defaultErrorMessage: 'Unable to decode your text',
12+
});
13+
</script>
14+
15+
<template>
16+
<c-card title="Encode">
17+
<div flex gap-3>
18+
<c-input-text
19+
v-model:value="encodeInput"
20+
label="Your text:"
21+
placeholder="The string to encode"
22+
rows="4"
23+
multiline raw-text monospace autosize flex-1
24+
/>
25+
</div>
26+
<c-input-text
27+
label="Your text encoded to Morse code:"
28+
:value="encodeOutput"
29+
rows="3"
30+
placeholder="Your string encoded"
31+
multiline monospace readonly autosize mt-5
32+
/>
33+
</c-card>
34+
<c-card title="Decode">
35+
<div flex gap-3>
36+
<c-input-text
37+
v-model:value="decodeInput"
38+
label="Your Morse encoded text:"
39+
placeholder="The string to decode"
40+
rows="4"
41+
multiline raw-text monospace autosize flex-1
42+
/>
43+
</div>
44+
<c-alert v-if="decodeError" type="error" mt-12 title="Error while decoding">
45+
{{ decodeError }}
46+
</c-alert>
47+
<c-input-text
48+
v-else
49+
label="Your decoded text:"
50+
:value="decodeOutput"
51+
placeholder="Your string decoded"
52+
rows="3"
53+
multiline monospace readonly autosize mt-5
54+
/>
55+
</c-card>
56+
</template>

0 commit comments

Comments
 (0)