Skip to content

Commit 2e30edf

Browse files
committed
Merge branch 'feat/format-transformer-download' into chore/all-my-stuffs
# Conflicts: # package.json # pnpm-lock.yaml # src/components/TextareaCopyable.vue
2 parents 6617d45 + d812c07 commit 2e30edf

File tree

14 files changed

+35
-12
lines changed

14 files changed

+35
-12
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
"js-base64": "^3.7.7",
100100
"jsbarcode": "^3.11.6",
101101
"iconv-lite": "^0.6.3",
102-
"js-base64": "^3.7.6",
103102
"js-base64": "^3.7.7",
104103
"json5": "^2.2.3",
105104
"jwt-decode": "^3.1.2",

pnpm-lock.yaml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/FormatTransformer.vue

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script setup lang="ts">
22
import _ from 'lodash';
3+
import { Base64 } from 'js-base64';
34
import type { UseValidationRule } from '@/composable/validation';
45
import CInputText from '@/ui/c-input-text/c-input-text.vue';
6+
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
57
68
const props = withDefaults(
79
defineProps<{
@@ -12,6 +14,8 @@ const props = withDefaults(
1214
inputDefault?: string
1315
outputLabel?: string
1416
outputLanguage?: string
17+
downloadFileName?: string
18+
downloadButtonText?: string
1519
}>(),
1620
{
1721
transformer: _.identity,
@@ -21,16 +25,27 @@ const props = withDefaults(
2125
inputPlaceholder: 'Input...',
2226
outputLabel: 'Output',
2327
outputLanguage: '',
28+
downloadFileName: '',
29+
downloadButtonText: 'Download',
2430
},
2531
);
2632
27-
const { transformer, inputValidationRules, inputLabel, outputLabel, outputLanguage, inputPlaceholder, inputDefault }
28-
= toRefs(props);
33+
const {
34+
transformer, inputValidationRules, inputLabel, outputLabel, outputLanguage,
35+
inputPlaceholder, inputDefault, downloadFileName, downloadButtonText,
36+
} = toRefs(props);
2937
3038
const inputElement = ref<typeof CInputText>();
3139
3240
const input = ref(inputDefault.value);
3341
const output = computed(() => transformer.value(input.value));
42+
43+
const outputBase64 = computed(() => Base64.encode(output.value));
44+
const { download } = useDownloadFileFromBase64(
45+
{
46+
source: outputBase64,
47+
filename: downloadFileName,
48+
});
3449
</script>
3550

3651
<template>
@@ -53,5 +68,11 @@ const output = computed(() => transformer.value(input.value));
5368
{{ outputLabel }}
5469
</div>
5570
<textarea-copyable :value="output" :language="outputLanguage" :follow-height-of="inputElement?.inputWrapperRef" />
71+
72+
<div v-if="downloadFileName !== '' && output !== ''" mt-5 flex justify-center>
73+
<c-button secondary @click="download">
74+
{{ downloadButtonText }}
75+
</c-button>
76+
</div>
5677
</div>
5778
</template>

src/components/TextareaCopyable.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,8 @@ const props = withDefaults(
2525
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
2626
copyMessage?: string
2727
wordWrap?: boolean
28-
<<<<<<< HEAD
29-
<<<<<<< HEAD
3028
downloadFileName?: string
3129
downloadButtonText?: string
32-
=======
33-
>>>>>>> feat/cert-key-parser
34-
=======
35-
downloadFileName?: string
36-
downloadButtonText?: string
37-
>>>>>>> feat/email-parser
3830
}>(),
3931
{
4032
followHeightOf: null,

src/tools/json-minify/json-minify.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ const rules: UseValidationRule<string>[] = [
2323
output-language="json"
2424
:input-validation-rules="rules"
2525
:transformer="transformer"
26+
download-file-name="output.json"
2627
/>
2728
</template>

src/tools/json-to-csv/json-to-csv.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ const rules: UseValidationRule<string>[] = [
2828
output-label="CSV version of your JSON"
2929
:input-validation-rules="rules"
3030
:transformer="transformer"
31+
download-file-name="output.csv"
3132
/>
3233
</template>

src/tools/json-to-toml/json-to-toml.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ const rules: UseValidationRule<string>[] = [
2424
output-language="toml"
2525
:input-validation-rules="rules"
2626
:transformer="transformer"
27+
download-file-name="output.toml"
2728
/>
2829
</template>

src/tools/json-to-yaml-converter/json-to-yaml.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ const rules: UseValidationRule<string>[] = [
2323
output-language="yaml"
2424
:input-validation-rules="rules"
2525
:transformer="transformer"
26+
download-file-name="output.yaml"
2627
/>
2728
</template>

src/tools/list-converter/list-converter.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,6 @@ function transformer(value: string) {
119119
input-placeholder="Paste your input data here..."
120120
output-label="Your transformed data"
121121
:transformer="transformer"
122+
download-file-name="output.txt"
122123
/>
123124
</template>

src/tools/toml-to-json/toml-to-json.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ const rules: UseValidationRule<string>[] = [
2222
output-language="json"
2323
:input-validation-rules="rules"
2424
:transformer="transformer"
25+
download-file-name="output.json"
2526
/>
2627
</template>

0 commit comments

Comments
 (0)