mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 13:29:13 -04:00
Merge d812c072d0
into e1b4f9aafe
This commit is contained in:
commit
aecc02646a
15 changed files with 125 additions and 56 deletions
|
@ -64,7 +64,7 @@
|
||||||
"highlight.js": "^11.7.0",
|
"highlight.js": "^11.7.0",
|
||||||
"iarna-toml-esm": "^3.0.5",
|
"iarna-toml-esm": "^3.0.5",
|
||||||
"ibantools": "^4.3.3",
|
"ibantools": "^4.3.3",
|
||||||
"js-base64": "^3.7.6",
|
"js-base64": "^3.7.7",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"libphonenumber-js": "^1.10.28",
|
"libphonenumber-js": "^1.10.28",
|
||||||
|
|
73
pnpm-lock.yaml
generated
73
pnpm-lock.yaml
generated
|
@ -93,7 +93,7 @@ dependencies:
|
||||||
specifier: ^4.3.3
|
specifier: ^4.3.3
|
||||||
version: 4.3.3
|
version: 4.3.3
|
||||||
js-base64:
|
js-base64:
|
||||||
specifier: ^3.7.6
|
specifier: ^3.7.7
|
||||||
version: 3.7.7
|
version: 3.7.7
|
||||||
json5:
|
json5:
|
||||||
specifier: ^2.2.3
|
specifier: ^2.2.3
|
||||||
|
@ -166,7 +166,7 @@ dependencies:
|
||||||
version: 3.3.4
|
version: 3.3.4
|
||||||
vue-i18n:
|
vue-i18n:
|
||||||
specifier: ^9.9.1
|
specifier: ^9.9.1
|
||||||
version: 9.9.1(vue@3.3.4)
|
version: 9.13.1(vue@3.3.4)
|
||||||
vue-router:
|
vue-router:
|
||||||
specifier: ^4.1.6
|
specifier: ^4.1.6
|
||||||
version: 4.1.6(vue@3.3.4)
|
version: 4.1.6(vue@3.3.4)
|
||||||
|
@ -189,7 +189,7 @@ devDependencies:
|
||||||
version: 1.1.50
|
version: 1.1.50
|
||||||
'@intlify/unplugin-vue-i18n':
|
'@intlify/unplugin-vue-i18n':
|
||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
version: 2.0.0(rollup@2.79.1)(vue-i18n@9.9.1)
|
version: 2.0.0(rollup@2.79.1)(vue-i18n@9.13.1)
|
||||||
'@playwright/test':
|
'@playwright/test':
|
||||||
specifier: ^1.32.3
|
specifier: ^1.32.3
|
||||||
version: 1.32.3
|
version: 1.32.3
|
||||||
|
@ -2209,8 +2209,8 @@ packages:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@intlify/bundle-utils@7.5.0(vue-i18n@9.9.1):
|
/@intlify/bundle-utils@7.5.1(vue-i18n@9.13.1):
|
||||||
resolution: {integrity: sha512-6DymqusddBQ8kVtVBsVFFF7arNfIhuLacOmmsqayT2vl427j9m0VX12mMC+cgoVIodSpRfzYPaPTdPuJq7mK0Q==}
|
resolution: {integrity: sha512-UovJl10oBIlmYEcWw+VIHdKY5Uv5sdPG0b/b6bOYxGLln3UwB75+2dlc0F3Fsa0RhoznQ5Rp589/BZpABpE4Xw==}
|
||||||
engines: {node: '>= 14.16'}
|
engines: {node: '>= 14.16'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
petite-vue-i18n: '*'
|
petite-vue-i18n: '*'
|
||||||
|
@ -2221,8 +2221,8 @@ packages:
|
||||||
vue-i18n:
|
vue-i18n:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/message-compiler': 9.9.1
|
'@intlify/message-compiler': 9.13.1
|
||||||
'@intlify/shared': 9.9.1
|
'@intlify/shared': 9.13.1
|
||||||
acorn: 8.11.2
|
acorn: 8.11.2
|
||||||
escodegen: 2.1.0
|
escodegen: 2.1.0
|
||||||
estree-walker: 2.0.2
|
estree-walker: 2.0.2
|
||||||
|
@ -2230,29 +2230,29 @@ packages:
|
||||||
magic-string: 0.30.5
|
magic-string: 0.30.5
|
||||||
mlly: 1.4.2
|
mlly: 1.4.2
|
||||||
source-map-js: 1.0.2
|
source-map-js: 1.0.2
|
||||||
vue-i18n: 9.9.1(vue@3.3.4)
|
vue-i18n: 9.13.1(vue@3.3.4)
|
||||||
yaml-eslint-parser: 1.2.2
|
yaml-eslint-parser: 1.2.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@intlify/core-base@9.9.1:
|
/@intlify/core-base@9.13.1:
|
||||||
resolution: {integrity: sha512-qsV15dg7jNX2faBRyKMgZS8UcFJViWEUPLdzZ9UR0kQZpFVeIpc0AG7ZOfeP7pX2T9SQ5jSiorq/tii9nkkafA==}
|
resolution: {integrity: sha512-+bcQRkJO9pcX8d0gel9ZNfrzU22sZFSA0WVhfXrf5jdJOS24a+Bp8pozuS9sBI9Hk/tGz83pgKfmqcn/Ci7/8w==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/message-compiler': 9.9.1
|
'@intlify/message-compiler': 9.13.1
|
||||||
'@intlify/shared': 9.9.1
|
'@intlify/shared': 9.13.1
|
||||||
|
|
||||||
/@intlify/message-compiler@9.9.1:
|
/@intlify/message-compiler@9.13.1:
|
||||||
resolution: {integrity: sha512-zTvP6X6HeumHOXuAE1CMMsV6tTX+opKMOxO1OHTCg5N5Sm/F7d8o2jdT6W6L5oHUsJ/vvkGefHIs7Q3hfowmsA==}
|
resolution: {integrity: sha512-SKsVa4ajYGBVm7sHMXd5qX70O2XXjm55zdZB3VeMFCvQyvLew/dLvq3MqnaIsTMF1VkkOb9Ttr6tHcMlyPDL9w==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/shared': 9.9.1
|
'@intlify/shared': 9.13.1
|
||||||
source-map-js: 1.0.2
|
source-map-js: 1.0.2
|
||||||
|
|
||||||
/@intlify/shared@9.9.1:
|
/@intlify/shared@9.13.1:
|
||||||
resolution: {integrity: sha512-b3Pta1nwkz5rGq434v0psHwEwHGy1pYCttfcM22IE//K9owbpkEvFptx9VcuRAxjQdrO2If249cmDDjBu5wMDA==}
|
resolution: {integrity: sha512-u3b6BKGhE6j/JeRU6C/RL2FgyJfy6LakbtfeVF8fJXURpZZTzfh3e05J0bu0XPw447Q6/WUp3C4ajv4TMS4YsQ==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
|
|
||||||
/@intlify/unplugin-vue-i18n@2.0.0(rollup@2.79.1)(vue-i18n@9.9.1):
|
/@intlify/unplugin-vue-i18n@2.0.0(rollup@2.79.1)(vue-i18n@9.13.1):
|
||||||
resolution: {integrity: sha512-1oKvm92L9l2od2H9wKx2ZvR4tzn7gUtd7bPLI7AWUmm7U9H1iEypndt5d985ypxGsEs0gToDaKTrytbBIJwwSg==}
|
resolution: {integrity: sha512-1oKvm92L9l2od2H9wKx2ZvR4tzn7gUtd7bPLI7AWUmm7U9H1iEypndt5d985ypxGsEs0gToDaKTrytbBIJwwSg==}
|
||||||
engines: {node: '>= 14.16'}
|
engines: {node: '>= 14.16'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
@ -2267,8 +2267,8 @@ packages:
|
||||||
vue-i18n-bridge:
|
vue-i18n-bridge:
|
||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/bundle-utils': 7.5.0(vue-i18n@9.9.1)
|
'@intlify/bundle-utils': 7.5.1(vue-i18n@9.13.1)
|
||||||
'@intlify/shared': 9.9.1
|
'@intlify/shared': 9.13.1
|
||||||
'@rollup/pluginutils': 5.0.5(rollup@2.79.1)
|
'@rollup/pluginutils': 5.0.5(rollup@2.79.1)
|
||||||
'@vue/compiler-sfc': 3.3.4
|
'@vue/compiler-sfc': 3.3.4
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
|
@ -2279,7 +2279,7 @@ packages:
|
||||||
picocolors: 1.0.0
|
picocolors: 1.0.0
|
||||||
source-map-js: 1.0.2
|
source-map-js: 1.0.2
|
||||||
unplugin: 1.4.0
|
unplugin: 1.4.0
|
||||||
vue-i18n: 9.9.1(vue@3.3.4)
|
vue-i18n: 9.13.1(vue@3.3.4)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- rollup
|
- rollup
|
||||||
- supports-color
|
- supports-color
|
||||||
|
@ -3354,7 +3354,7 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@unhead/dom': 0.5.1
|
'@unhead/dom': 0.5.1
|
||||||
'@unhead/schema': 0.5.1
|
'@unhead/schema': 0.5.1
|
||||||
'@vueuse/shared': 10.8.0(vue@3.3.4)
|
'@vueuse/shared': 10.11.0(vue@3.3.4)
|
||||||
unhead: 0.5.1
|
unhead: 0.5.1
|
||||||
vue: 3.3.4
|
vue: 3.3.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
@ -3987,19 +3987,19 @@ packages:
|
||||||
- vue
|
- vue
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@vueuse/shared@10.3.0(vue@3.3.4):
|
/@vueuse/shared@10.11.0(vue@3.3.4):
|
||||||
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
|
resolution: {integrity: sha512-fyNoIXEq3PfX1L3NkNhtVQUSRtqYwJtJg+Bp9rIzculIZWHTkKSysujrOk2J+NrRulLTQH9+3gGSfYLWSEWU1A==}
|
||||||
dependencies:
|
dependencies:
|
||||||
vue-demi: 0.14.5(vue@3.3.4)
|
vue-demi: 0.14.10(vue@3.3.4)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@vue/composition-api'
|
- '@vue/composition-api'
|
||||||
- vue
|
- vue
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@vueuse/shared@10.8.0(vue@3.3.4):
|
/@vueuse/shared@10.3.0(vue@3.3.4):
|
||||||
resolution: {integrity: sha512-dUdy6zwHhULGxmr9YUg8e+EnB39gcM4Fe2oKBSrh3cOsV30JcMPtsyuspgFCUo5xxFNaeMf/W2yyKfST7Bg8oQ==}
|
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
vue-demi: 0.14.7(vue@3.3.4)
|
vue-demi: 0.14.5(vue@3.3.4)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@vue/composition-api'
|
- '@vue/composition-api'
|
||||||
- vue
|
- vue
|
||||||
|
@ -9143,8 +9143,8 @@ packages:
|
||||||
vue: 3.3.4
|
vue: 3.3.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/vue-demi@0.14.5(vue@3.3.4):
|
/vue-demi@0.14.10(vue@3.3.4):
|
||||||
resolution: {integrity: sha512-o9NUVpl/YlsGJ7t+xuqJKx8EBGf1quRhCiT6D/J0pfwmk9zUwYkC7yrF4SZCe6fETvSM3UNL2edcbYrSyc4QHA==}
|
resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
|
@ -9158,8 +9158,8 @@ packages:
|
||||||
vue: 3.3.4
|
vue: 3.3.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/vue-demi@0.14.7(vue@3.3.4):
|
/vue-demi@0.14.5(vue@3.3.4):
|
||||||
resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==}
|
resolution: {integrity: sha512-o9NUVpl/YlsGJ7t+xuqJKx8EBGf1quRhCiT6D/J0pfwmk9zUwYkC7yrF4SZCe6fETvSM3UNL2edcbYrSyc4QHA==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
|
@ -9191,14 +9191,14 @@ packages:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/vue-i18n@9.9.1(vue@3.3.4):
|
/vue-i18n@9.13.1(vue@3.3.4):
|
||||||
resolution: {integrity: sha512-xyQ4VspLdNSPTKBFBPWa1tvtj+9HuockZwgFeD2OhxxXuC2CWeNvV4seu2o9+vbQOyQbhAM5Ez56oxUrrnTWdw==}
|
resolution: {integrity: sha512-mh0GIxx0wPtPlcB1q4k277y0iKgo25xmDPWioVVYanjPufDBpvu5ySTjP5wOrSvlYQ2m1xI+CFhGdauv/61uQg==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.0.0
|
vue: ^3.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/core-base': 9.9.1
|
'@intlify/core-base': 9.13.1
|
||||||
'@intlify/shared': 9.9.1
|
'@intlify/shared': 9.13.1
|
||||||
'@vue/devtools-api': 6.5.0
|
'@vue/devtools-api': 6.5.0
|
||||||
vue: 3.3.4
|
vue: 3.3.4
|
||||||
|
|
||||||
|
@ -9449,6 +9449,7 @@ packages:
|
||||||
|
|
||||||
/workbox-google-analytics@7.0.0:
|
/workbox-google-analytics@7.0.0:
|
||||||
resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==}
|
resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==}
|
||||||
|
deprecated: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained
|
||||||
dependencies:
|
dependencies:
|
||||||
workbox-background-sync: 7.0.0
|
workbox-background-sync: 7.0.0
|
||||||
workbox-core: 7.0.0
|
workbox-core: 7.0.0
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { Base64 } from 'js-base64';
|
||||||
import type { UseValidationRule } from '@/composable/validation';
|
import type { UseValidationRule } from '@/composable/validation';
|
||||||
import CInputText from '@/ui/c-input-text/c-input-text.vue';
|
import CInputText from '@/ui/c-input-text/c-input-text.vue';
|
||||||
|
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
@ -12,6 +14,8 @@ const props = withDefaults(
|
||||||
inputDefault?: string
|
inputDefault?: string
|
||||||
outputLabel?: string
|
outputLabel?: string
|
||||||
outputLanguage?: string
|
outputLanguage?: string
|
||||||
|
downloadFileName?: string
|
||||||
|
downloadButtonText?: string
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
transformer: _.identity,
|
transformer: _.identity,
|
||||||
|
@ -21,16 +25,27 @@ const props = withDefaults(
|
||||||
inputPlaceholder: 'Input...',
|
inputPlaceholder: 'Input...',
|
||||||
outputLabel: 'Output',
|
outputLabel: 'Output',
|
||||||
outputLanguage: '',
|
outputLanguage: '',
|
||||||
|
downloadFileName: '',
|
||||||
|
downloadButtonText: 'Download',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const { transformer, inputValidationRules, inputLabel, outputLabel, outputLanguage, inputPlaceholder, inputDefault }
|
const {
|
||||||
= toRefs(props);
|
transformer, inputValidationRules, inputLabel, outputLabel, outputLanguage,
|
||||||
|
inputPlaceholder, inputDefault, downloadFileName, downloadButtonText,
|
||||||
|
} = toRefs(props);
|
||||||
|
|
||||||
const inputElement = ref<typeof CInputText>();
|
const inputElement = ref<typeof CInputText>();
|
||||||
|
|
||||||
const input = ref(inputDefault.value);
|
const input = ref(inputDefault.value);
|
||||||
const output = computed(() => transformer.value(input.value));
|
const output = computed(() => transformer.value(input.value));
|
||||||
|
|
||||||
|
const outputBase64 = computed(() => Base64.encode(output.value));
|
||||||
|
const { download } = useDownloadFileFromBase64(
|
||||||
|
{
|
||||||
|
source: outputBase64,
|
||||||
|
filename: downloadFileName,
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -53,5 +68,11 @@ const output = computed(() => transformer.value(input.value));
|
||||||
{{ outputLabel }}
|
{{ outputLabel }}
|
||||||
</div>
|
</div>
|
||||||
<textarea-copyable :value="output" :language="outputLanguage" :follow-height-of="inputElement?.inputWrapperRef" />
|
<textarea-copyable :value="output" :language="outputLanguage" :follow-height-of="inputElement?.inputWrapperRef" />
|
||||||
|
|
||||||
|
<div v-if="downloadFileName !== '' && output !== ''" mt-5 flex justify-center>
|
||||||
|
<c-button secondary @click="download">
|
||||||
|
{{ downloadButtonText }}
|
||||||
|
</c-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -7,7 +7,15 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
|
||||||
import xmlHljs from 'highlight.js/lib/languages/xml';
|
import xmlHljs from 'highlight.js/lib/languages/xml';
|
||||||
import yamlHljs from 'highlight.js/lib/languages/yaml';
|
import yamlHljs from 'highlight.js/lib/languages/yaml';
|
||||||
import iniHljs from 'highlight.js/lib/languages/ini';
|
import iniHljs from 'highlight.js/lib/languages/ini';
|
||||||
|
import bashHljs from 'highlight.js/lib/languages/bash';
|
||||||
|
import markdownHljs from 'highlight.js/lib/languages/markdown';
|
||||||
|
import jsHljs from 'highlight.js/lib/languages/javascript';
|
||||||
|
import cssHljs from 'highlight.js/lib/languages/css';
|
||||||
|
import goHljs from 'highlight.js/lib/languages/go';
|
||||||
|
import csharpHljs from 'highlight.js/lib/languages/csharp';
|
||||||
|
import { Base64 } from 'js-base64';
|
||||||
import { useCopy } from '@/composable/copy';
|
import { useCopy } from '@/composable/copy';
|
||||||
|
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
@ -16,12 +24,17 @@ const props = withDefaults(
|
||||||
language?: string
|
language?: string
|
||||||
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
|
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
|
||||||
copyMessage?: string
|
copyMessage?: string
|
||||||
|
wordWrap?: boolean
|
||||||
|
downloadFileName?: string
|
||||||
|
downloadButtonText?: string
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
followHeightOf: null,
|
followHeightOf: null,
|
||||||
language: 'txt',
|
language: 'txt',
|
||||||
copyPlacement: 'top-right',
|
copyPlacement: 'top-right',
|
||||||
copyMessage: 'Copy to clipboard',
|
copyMessage: 'Copy to clipboard',
|
||||||
|
downloadFileName: '',
|
||||||
|
downloadButtonText: 'Download',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
hljs.registerLanguage('sql', sqlHljs);
|
hljs.registerLanguage('sql', sqlHljs);
|
||||||
|
@ -30,12 +43,25 @@ hljs.registerLanguage('html', xmlHljs);
|
||||||
hljs.registerLanguage('xml', xmlHljs);
|
hljs.registerLanguage('xml', xmlHljs);
|
||||||
hljs.registerLanguage('yaml', yamlHljs);
|
hljs.registerLanguage('yaml', yamlHljs);
|
||||||
hljs.registerLanguage('toml', iniHljs);
|
hljs.registerLanguage('toml', iniHljs);
|
||||||
|
hljs.registerLanguage('bash', bashHljs);
|
||||||
|
hljs.registerLanguage('markdown', markdownHljs);
|
||||||
|
hljs.registerLanguage('css', cssHljs);
|
||||||
|
hljs.registerLanguage('javascript', jsHljs);
|
||||||
|
hljs.registerLanguage('go', goHljs);
|
||||||
|
hljs.registerLanguage('csharp', csharpHljs);
|
||||||
|
|
||||||
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
|
const { value, language, followHeightOf, copyPlacement, copyMessage, downloadFileName, downloadButtonText } = toRefs(props);
|
||||||
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
|
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
|
||||||
|
|
||||||
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
||||||
const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.value);
|
const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.value);
|
||||||
|
|
||||||
|
const valueBase64 = computed(() => Base64.encode(value.value));
|
||||||
|
const { download } = useDownloadFileFromBase64(
|
||||||
|
{
|
||||||
|
source: valueBase64,
|
||||||
|
filename: downloadFileName,
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -47,11 +73,16 @@ const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.
|
||||||
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
|
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
|
||||||
>
|
>
|
||||||
<n-config-provider :hljs="hljs">
|
<n-config-provider :hljs="hljs">
|
||||||
<n-code :code="value" :language="language" :trim="false" data-test-id="area-content" />
|
<n-code :code="value" :language="language" :word-wrap="wordWrap" :trim="false" data-test-id="area-content" />
|
||||||
</n-config-provider>
|
</n-config-provider>
|
||||||
</n-scrollbar>
|
</n-scrollbar>
|
||||||
<div absolute right-10px top-10px>
|
<div
|
||||||
<c-tooltip v-if="value" :tooltip="tooltipText" position="left">
|
v-if="value && copyPlacement !== 'none'"
|
||||||
|
absolute right-10px
|
||||||
|
:top-10px="copyPlacement === 'top-right' ? '' : 'no'"
|
||||||
|
:bottom-10px="copyPlacement === 'bottom-right' ? '' : 'no'"
|
||||||
|
>
|
||||||
|
<c-tooltip v-if="value && copyPlacement !== 'outside'" :tooltip="tooltipText" position="left">
|
||||||
<c-button circle important:h-10 important:w-10 @click="copy()">
|
<c-button circle important:h-10 important:w-10 @click="copy()">
|
||||||
<n-icon size="22" :component="Copy" />
|
<n-icon size="22" :component="Copy" />
|
||||||
</c-button>
|
</c-button>
|
||||||
|
@ -63,6 +94,11 @@ const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.
|
||||||
{{ tooltipText }}
|
{{ tooltipText }}
|
||||||
</c-button>
|
</c-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="downloadFileName !== '' && value !== ''" mt-5 flex justify-center>
|
||||||
|
<c-button secondary @click="download">
|
||||||
|
{{ downloadButtonText }}
|
||||||
|
</c-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
|
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
|
||||||
import type { Ref } from 'vue';
|
import type { MaybeRef, Ref } from 'vue';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { get } from '@vueuse/core';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getMimeTypeFromBase64,
|
getMimeTypeFromBase64,
|
||||||
|
@ -75,21 +76,11 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
|
||||||
}
|
}
|
||||||
|
|
||||||
function useDownloadFileFromBase64(
|
function useDownloadFileFromBase64(
|
||||||
{ source, filename, extension, fileMimeType }:
|
|
||||||
{ source: Ref<string>; filename?: string; extension?: string; fileMimeType?: string }) {
|
|
||||||
return {
|
|
||||||
download() {
|
|
||||||
downloadFromBase64({ sourceValue: source.value, filename, extension, fileMimeType });
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function useDownloadFileFromBase64Refs(
|
|
||||||
{ source, filename, extension }:
|
{ source, filename, extension }:
|
||||||
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
|
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
|
||||||
return {
|
return {
|
||||||
download() {
|
download() {
|
||||||
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
|
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -116,3 +107,13 @@ function previewImageFromBase64(base64String: string): HTMLImageElement {
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function useDownloadFileFromBase64Refs(
|
||||||
|
{ source, filename, extension }:
|
||||||
|
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
|
||||||
|
return {
|
||||||
|
download() {
|
||||||
|
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -23,5 +23,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
output-language="json"
|
output-language="json"
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.json"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -28,5 +28,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
output-label="CSV version of your JSON"
|
output-label="CSV version of your JSON"
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.csv"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -24,5 +24,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
output-language="toml"
|
output-language="toml"
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.toml"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -23,5 +23,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
output-language="yaml"
|
output-language="yaml"
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.yaml"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -119,5 +119,6 @@ function transformer(value: string) {
|
||||||
input-placeholder="Paste your input data here..."
|
input-placeholder="Paste your input data here..."
|
||||||
output-label="Your transformed data"
|
output-label="Your transformed data"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.txt"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -22,5 +22,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
output-language="json"
|
output-language="json"
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.json"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -23,5 +23,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
output-language="yaml"
|
output-language="yaml"
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.yaml"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -42,5 +42,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
:input-default="defaultValue"
|
:input-default="defaultValue"
|
||||||
|
download-file-name="output.xml"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -27,5 +27,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
output-language="json"
|
output-language="json"
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.json"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -24,5 +24,6 @@ const rules: UseValidationRule<string>[] = [
|
||||||
output-language="toml"
|
output-language="toml"
|
||||||
:input-validation-rules="rules"
|
:input-validation-rules="rules"
|
||||||
:transformer="transformer"
|
:transformer="transformer"
|
||||||
|
download-file-name="output.toml"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue