Compare commits

..
Author SHA1 Message Date
ShareVB 880d937d33 fix: pnpm lock 2024-09-01 20:08:47 +02:00
ShareVB 9ebf98352e Merge branch 'feat/qr-decoder' of https://github.com/sharevb/it-tools into feat/qr-decoder 2024-09-01 20:06:23 +02:00
ShareVB d30344beef fix: sonar 2024-09-01 20:06:08 +02:00
sharevb a3a624c292 Merge branch 'main' into feat/qr-decoder 2024-09-01 20:02:28 +02:00
ShareVB 1fb3e1f922 Merge remote-tracking branch 'origin/main' into feat/qr-decoder 2024-09-01 20:01:42 +02:00
ShareVB 951143d63d feat: handle parsing of common qr code types
Fix #1224
2024-09-01 19:36:13 +02:00
sharevbandCorentin THOMASSET 87984e2081 feat(new tool): Markdown to HTML (#916)
* feat(new tool): Markdown to HTML

Fix partially #538

* feat: add print button

* Update src/tools/markdown-to-html/index.ts

* Update src/tools/markdown-to-html/markdown-to-html.vue

---------

Co-authored-by: Corentin THOMASSET <corentin.thomasset74@gmail.com>
2024-08-25 20:57:07 +00:00
sharevb e8cd98c25d Merge branch 'main' into feat/qr-decoder 2024-03-03 12:03:07 +01:00
sharevb dbd4730256 feat(c-file-upload): paste image
Property paste-image to allow pasting an image directly from clipboard
2024-03-03 11:41:01 +01:00
sharevb 6d619603f9 feat(new tool): QRCode decoder
Fix #656
2024-03-03 11:30:06 +01:00
15 changed files with 535 additions and 112 deletions

No files matched your search

+10 -2
View File
@@ -121,6 +121,7 @@ declare module '@vue/runtime-core' {
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default']
MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default']
MarkdownToHtml: typeof import('./src/tools/markdown-to-html/markdown-to-html.vue')['default']
MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default']
MenuBar: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar.vue')['default']
MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default']
@@ -129,18 +130,25 @@ declare module '@vue/runtime-core' {
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NColorPicker: typeof import('naive-ui')['NColorPicker']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NImage: typeof import('naive-ui')['NImage']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSlider: typeof import('naive-ui')['NSlider']
NSwitch: typeof import('naive-ui')['NSwitch']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
@@ -148,7 +156,7 @@ declare module '@vue/runtime-core' {
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
PunycodeConverter: typeof import('./src/tools/punycode-converter/punycode-converter.vue')['default']
QrCodeDecoder: typeof import('./src/tools/qr-code-decoder/qr-code-decoder.vue')['default']
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
+4 -2
View File
@@ -41,8 +41,8 @@
"@tiptap/pm": "2.1.6",
"@tiptap/starter-kit": "2.1.6",
"@tiptap/vue-3": "2.0.3",
"@types/markdown-it": "^13.0.7",
"@types/figlet": "^1.5.8",
"@types/punycode": "^2.1.4",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
"@vueuse/core": "^10.3.0",
@@ -67,10 +67,12 @@
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"js-base64": "^3.7.6",
"ical.js": "^2.0.1",
"json5": "^2.2.3",
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.10.28",
"lodash": "^4.17.21",
"markdown-it": "^14.0.0",
"marked": "^10.0.0",
"mathjs": "^11.9.1",
"mime-types": "^2.1.35",
@@ -82,8 +84,8 @@
"pdf-signature-reader": "^1.4.2",
"pinia": "^2.0.34",
"plausible-tracker": "^0.3.8",
"punycode": "^2.3.1",
"qrcode": "^1.5.1",
"qrcode-parser": "^2.1.3",
"sql-formatter": "^13.0.0",
"ua-parser-js": "^1.0.35",
"ulid": "^2.3.0",
+73 -16
View File
@@ -26,9 +26,9 @@ dependencies:
'@types/figlet':
specifier: ^1.5.8
version: 1.5.8
'@types/punycode':
specifier: ^2.1.4
version: 2.1.4
'@types/markdown-it':
specifier: ^13.0.7
version: 13.0.9
'@vicons/material':
specifier: ^0.12.0
version: 0.12.0
@@ -98,6 +98,9 @@ dependencies:
ibantools:
specifier: ^4.3.3
version: 4.3.3
ical.js:
specifier: ^2.0.1
version: 2.0.1
js-base64:
specifier: ^3.7.6
version: 3.7.7
@@ -113,6 +116,9 @@ dependencies:
lodash:
specifier: ^4.17.21
version: 4.17.21
markdown-it:
specifier: ^14.0.0
version: 14.1.0
marked:
specifier: ^10.0.0
version: 10.0.0
@@ -146,12 +152,12 @@ dependencies:
plausible-tracker:
specifier: ^0.3.8
version: 0.3.8
punycode:
specifier: ^2.3.1
version: 2.3.1
qrcode:
specifier: ^1.5.1
version: 1.5.1
qrcode-parser:
specifier: ^2.1.3
version: 2.1.3
sql-formatter:
specifier: ^13.0.0
version: 13.0.0
@@ -2958,7 +2964,6 @@ packages:
/@types/linkify-it@3.0.2:
resolution: {integrity: sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==}
dev: true
/@types/lodash-es@4.17.10:
resolution: {integrity: sha512-YJP+w/2khSBwbUSFdGsSqmDvmnN3cCKoPOL7Zjle6s30ZtemkkqhjVfFqGwPN7ASil5VyjE2GtyU/yqYY6mC0A==}
@@ -2980,6 +2985,13 @@ packages:
'@types/mdurl': 1.0.2
dev: true
/@types/markdown-it@13.0.9:
resolution: {integrity: sha512-1XPwR0+MgXLWfTn9gCsZ55AHOKW1WN+P9vr0PaQh5aerR9LLQXUbjfEAFhjmEmyoYFWAyuN2Mqkn40MZ4ukjBw==}
dependencies:
'@types/linkify-it': 3.0.2
'@types/mdurl': 1.0.2
dev: false
/@types/mdast@3.0.11:
resolution: {integrity: sha512-Y/uImid8aAwrEA24/1tcRZwpxX3pIFTSilcNDKSPn+Y2iDywSEachzRuvgAYYLR3wpGXAsMbv5lvKLDZLeYPAw==}
dependencies:
@@ -2988,7 +3000,6 @@ packages:
/@types/mdurl@1.0.2:
resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==}
dev: true
/@types/mime-types@2.1.1:
resolution: {integrity: sha512-vXOTGVSLR2jMw440moWTC7H19iUyLtP3Z1YTj7cSsubOICinjMxFeb/V57v9QdyyPGbbWolUFSSmSiRSn94tFw==}
@@ -3038,10 +3049,6 @@ packages:
resolution: {integrity: sha512-ZREFYlpUmPQJ0esjxoG1fMvB2HNaD3z+mjqdSosZvd3RalncI9NEur73P8ZJz4YQdL64CmV1w0RuqoRUlhQRBw==}
dev: true
/@types/punycode@2.1.4:
resolution: {integrity: sha512-trzh6NzBnq8yw5e35f8xe8VTYjqM3NE7bohBtvDVf/dtUer3zYTLK1Ka3DG3p7bdtoaOHZucma6FfVKlQ134pQ==}
dev: false
/@types/qrcode@1.5.0:
resolution: {integrity: sha512-x5ilHXRxUPIMfjtM+1vf/GPTRWZ81nqscursm5gMznJeK9M0YnZ1c3bEvRLQ0zSSgedLx1J6MGL231ObQGGhaA==}
dependencies:
@@ -5026,7 +5033,6 @@ packages:
/entities@4.5.0:
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
engines: {node: '>=0.12'}
dev: true
/errno@0.1.8:
resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==}
@@ -6116,6 +6122,10 @@ packages:
resolution: {integrity: sha512-RUTlGuFj3cU/Qfu5YIrsIZjW34/VDgKOz5fDr64Mc4NWP9b2i48vQ39r5xCl1yyFQeyEG/lASstIQHAUX18rRA==}
dev: false
/ical.js@2.0.1:
resolution: {integrity: sha512-uYYb1CwTXbd9NP/xTtgQZ5ivv6bpUjQu9VM98s3X78L3XRu00uJW5ZtmnLwyxhztpf5fSiRyDpFW7ZNCePlaPw==}
dev: false
/iconv-lite@0.6.3:
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
@@ -6640,6 +6650,10 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
/jsqr@1.4.0:
resolution: {integrity: sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A==}
dev: false
/jwt-decode@3.1.2:
resolution: {integrity: sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==}
dev: false
@@ -6698,6 +6712,12 @@ packages:
dependencies:
uc.micro: 1.0.6
/linkify-it@5.0.0:
resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==}
dependencies:
uc.micro: 2.1.0
dev: false
/local-pkg@0.4.3:
resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==}
engines: {node: '>=14'}
@@ -6835,6 +6855,18 @@ packages:
mdurl: 1.0.1
uc.micro: 1.0.6
/markdown-it@14.1.0:
resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==}
hasBin: true
dependencies:
argparse: 2.0.1
entities: 4.5.0
linkify-it: 5.0.0
mdurl: 2.0.0
punycode.js: 2.3.1
uc.micro: 2.1.0
dev: false
/marked@10.0.0:
resolution: {integrity: sha512-YiGcYcWj50YrwBgNzFoYhQ1hT6GmQbFG8SksnYJX1z4BXTHSOrz1GB5/Jm2yQvMg4nN1FHP4M6r03R10KrVUiA==}
engines: {node: '>= 18'}
@@ -6883,6 +6915,10 @@ packages:
/mdurl@1.0.1:
resolution: {integrity: sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==}
/mdurl@2.0.0:
resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==}
dev: false
/merge-stream@2.0.0:
resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
dev: true
@@ -7692,9 +7728,26 @@ packages:
resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==}
dev: true
/punycode.js@2.3.1:
resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==}
engines: {node: '>=6'}
dev: false
/punycode@2.3.0:
resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==}
engines: {node: '>=6'}
dev: true
/punycode@2.3.1:
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'}
dev: true
/qrcode-parser@2.1.3:
resolution: {integrity: sha512-tyakoHUQXCjH1+RGiqxH3/6XqbQuXuSaW0CkUp1AlYT0+XA4ndG7bxxyyWpdnr0Z2Vuv0GRwgKSq6sOzNiQfog==}
dependencies:
jsqr: 1.4.0
dev: false
/qrcode@1.5.1:
resolution: {integrity: sha512-nS8NJ1Z3md8uTjKtP+SGGhfqmTCs5flU/xR623oI0JX+Wepz9R8UrRVCTBTJm3qGw3rH6jJ6MUHjkDx15cxSSg==}
@@ -8484,7 +8537,7 @@ packages:
engines: {node: '>=6'}
dependencies:
psl: 1.9.0
punycode: 2.3.1
punycode: 2.3.0
universalify: 0.2.0
url-parse: 1.5.10
dev: true
@@ -8499,7 +8552,7 @@ packages:
resolution: {integrity: sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==}
engines: {node: '>=14'}
dependencies:
punycode: 2.3.1
punycode: 2.3.0
dev: true
/treemate@0.3.11:
@@ -8630,6 +8683,10 @@ packages:
/uc.micro@1.0.6:
resolution: {integrity: sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==}
/uc.micro@2.1.0:
resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==}
dev: false
/ufo@1.1.2:
resolution: {integrity: sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==}
@@ -8939,7 +8996,7 @@ packages:
/uri-js@4.4.1:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
dependencies:
punycode: 2.3.1
punycode: 2.3.0
dev: true
/url-parse@1.5.10:
+2
View File
@@ -7,6 +7,7 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
import xmlHljs from 'highlight.js/lib/languages/xml';
import yamlHljs from 'highlight.js/lib/languages/yaml';
import iniHljs from 'highlight.js/lib/languages/ini';
import markdownHljs from 'highlight.js/lib/languages/markdown';
import { useCopy } from '@/composable/copy';
const props = withDefaults(
@@ -30,6 +31,7 @@ hljs.registerLanguage('html', xmlHljs);
hljs.registerLanguage('xml', xmlHljs);
hljs.registerLanguage('yaml', yamlHljs);
hljs.registerLanguage('toml', iniHljs);
hljs.registerLanguage('markdown', markdownHljs);
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
+11 -12
View File
@@ -2,7 +2,6 @@ import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as emailNormalizer } from './email-normalizer';
import { tool as punycodeConverter } from './punycode-converter';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
@@ -10,6 +9,8 @@ import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as xmlToJson } from './xml-to-json';
import { tool as jsonToXml } from './json-to-xml';
import { tool as qrCodeDecoder } from './qr-code-decoder';
import { tool as markdownToHtml } from './markdown-to-html';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -113,6 +114,7 @@ export const toolsByCategory: ToolCategory[] = [
tomlToYaml,
xmlToJson,
jsonToXml,
markdownToHtml,
],
},
{
@@ -138,7 +140,13 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Images and videos',
components: [qrCodeGenerator, wifiQrCodeGenerator, svgPlaceholderGenerator, cameraRecorder],
components: [
qrCodeGenerator,
wifiQrCodeGenerator,
qrCodeDecoder,
svgPlaceholderGenerator,
cameraRecorder,
],
},
{
name: 'Development',
@@ -159,16 +167,7 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Network',
components: [
ipv4SubnetCalculator,
ipv4AddressConverter,
// ipv6AddressConverter,
ipv4RangeExpander,
macAddressLookup,
macAddressGenerator,
ipv6UlaGenerator,
punycodeConverter,
],
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
},
{
name: 'Math',
+12
View File
@@ -0,0 +1,12 @@
import { Markdown } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Markdown to HTML',
path: '/markdown-to-html',
description: 'Convert Markdown to Html and allow to print (as PDF)',
keywords: ['markdown', 'html', 'converter', 'pdf'],
component: () => import('./markdown-to-html.vue'),
icon: Markdown,
createdAt: new Date('2024-08-25'),
});
@@ -0,0 +1,44 @@
<script setup lang="ts">
import markdownit from 'markdown-it';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const inputMarkdown = ref('');
const outputHtml = computed(() => {
const md = markdownit();
return md.render(inputMarkdown.value);
});
function printHtml() {
const w = window.open();
if (w === null) {
return;
}
w.document.body.innerHTML = outputHtml.value;
w.print();
}
</script>
<template>
<div>
<c-input-text
v-model:value="inputMarkdown"
multiline raw-text
placeholder="Your Markdown content..."
rows="8"
autofocus
label="Your Markdown to convert:"
/>
<n-divider />
<n-form-item label="Output HTML:">
<TextareaCopyable :value="outputHtml" :word-wrap="true" language="html" />
</n-form-item>
<div flex justify-center>
<n-button @click="printHtml">
Print as PDF
</n-button>
</div>
</div>
</template>
-12
View File
@@ -1,12 +0,0 @@
import { World } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Punycode Converter',
path: '/punycode-converter',
description: 'Convert international unicode domain names or emails from/to ASCII Punycode version',
keywords: ['punycode', 'converter', 'rfc3492', 'bootstring', 'domain', 'dns'],
component: () => import('./punycode-converter.vue'),
icon: World,
createdAt: new Date('2024-08-15'),
});
@@ -1,66 +0,0 @@
<script setup lang="ts">
import { toASCII, toUnicode } from 'punycode/';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const punycodeInput = ref('');
const intlOutput = computed(
() => {
try {
return toUnicode(punycodeInput.value?.trim());
}
catch (e: any) {
return e.toString();
}
},
);
const intlInput = ref('');
const punycodeOutput = computed(
() => {
try {
return toASCII(intlInput.value?.trim());
}
catch (e: any) {
return e.toString();
}
},
);
</script>
<template>
<div max-w-600>
<c-card title="Punycode to International">
<c-input-text
v-model:value="punycodeInput"
placeholder="Put your punycode domain name or email to decode..."
label="Punycode Domain name/Email"
raw-text
/>
<n-divider />
<TextareaCopyable
label="Decoded Domain name/Email"
:value="intlOutput"
readonly
/>
</c-card>
<c-card title="International to Punycode" mt-5>
<c-input-text
v-model:value="intlInput"
placeholder="Put your international domain or email name here..."
label="Domain name or email to encode"
raw-text
/>
<n-divider />
<TextareaCopyable
label="Punycode Domain name/Email"
:value="punycodeOutput"
readonly
/>
</c-card>
</div>
</template>
+3
View File
@@ -0,0 +1,3 @@
declare module "ical.js" {
export function parse(content: string): object;
}
+12
View File
@@ -0,0 +1,12 @@
import { Qrcode } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'QR Code decoder',
path: '/qr-code-decoder',
description: 'QR Code Reader',
keywords: ['qrcode', 'qr-code', 'decoder', 'reader'],
component: () => import('./qr-code-decoder.vue'),
icon: Qrcode,
createdAt: new Date('2024-09-01'),
});
@@ -0,0 +1,151 @@
import { describe, expect, test } from 'vitest';
import { parseQRData } from './qr-code-decoder.service';
describe('qr-code-decoder', () => {
test('parseQRData should parse content correctly', () => {
expect(parseQRData(null)).toEqual({
type: 'Unknown',
value: '',
});
expect(parseQRData('')).toEqual({
type: 'Unknown',
value: '',
});
expect(parseQRData('TEL:+33123456')).toEqual({
type: 'Phone',
value: '+33123456',
});
expect(parseQRData('MATMSG:TO: email@example.com;SUB:email subject;BODY:Email text;;')).toEqual({
type: 'Email',
value: {
body: 'Email text',
subject: 'email subject',
to: 'email@example.com',
},
});
expect(parseQRData('mailto:email@example.com?subject=email subject&body=Email text')).toEqual({
type: 'Email',
value: {
body: 'Email text',
subject: 'email subject',
to: 'email@example.com',
},
});
expect(parseQRData('SMTP:email@example.com:email subject:Email text')).toEqual({
type: 'Email',
value: {
body: 'Email text',
subject: 'email subject',
to: 'email@example.com',
},
});
expect(parseQRData('smsto:+33315555:message')).toEqual({
type: 'SMS',
value: {
message: 'message',
to: '+33315555',
},
});
expect(parseQRData('WIFI:T:nopass;S:ssid;H:true;')).toEqual({
type: 'Wifi',
value: {
authentication: 'nopass',
hidden: 'true',
name: 'ssid',
password: undefined,
},
});
expect(parseQRData('WIFI:T:WPA;S:ssid;P:password;H:false;')).toEqual({
type: 'Wifi',
value: {
authentication: 'WPA',
hidden: 'false',
name: 'ssid',
password: 'password', // NOSONAR
},
});
expect(parseQRData('BEGIN:VCALENDAR\nPRODID:-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN\nVERSION:2.0\nBEGIN:VEVENT\nDTSTAMP:19960704T120000Z\nUID:uid1@example.com\nORGANIZER:mailto:jsmith@example.com\nDTSTART:19960918T143000Z\nDTEND:19960920T220000Z\nSTATUS:CONFIRMED\nCATEGORIES:CONFERENCE\nSUMMARY:Networld+Interop Conference\nDESCRIPTION:Networld+Interop Conference\n and Exhibit\\nAtlanta World Congress Center\\n\n Atlanta\\, Georgia\nEND:VEVENT\nEND:VCALENDAR'))
.toEqual({
type: 'iCal',
value: [
'vcalendar',
[
[
'prodid',
{},
'text',
'-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN',
],
[
'version',
{},
'text',
'2.0',
],
],
[
[
'vevent',
[
[
'dtstamp',
{},
'date-time',
'1996-07-04T12:00:00Z',
],
[
'uid',
{},
'text',
'uid1@example.com',
],
[
'organizer',
{},
'cal-address',
'mailto:jsmith@example.com',
],
[
'dtstart',
{},
'date-time',
'1996-09-18T14:30:00Z',
],
[
'dtend',
{},
'date-time',
'1996-09-20T22:00:00Z',
],
[
'status',
{},
'text',
'CONFIRMED',
],
[
'categories',
{},
'text',
'CONFERENCE',
],
[
'summary',
{},
'text',
'Networld+Interop Conference',
],
[
'description',
{},
'text',
'Networld+Interop Conference and Exhibit\nAtlanta World Congress Center\nAtlanta, Georgia',
],
],
[],
],
],
],
});
});
});
@@ -0,0 +1,83 @@
import ICAL from 'ical.js';
export function parseQRData(qrContent: string | null) {
if (!qrContent) {
return { type: 'Unknown', value: '' };
}
if (qrContent.startsWith('BEGIN:VCALENDAR')) {
return { type: 'iCal', value: ICAL.parse(qrContent?.trim()) };
}
if (qrContent.startsWith('TEL:')) {
return { type: 'Phone', value: qrContent.substring(4)?.trim() };
}
if (qrContent.startsWith('MATMSG:')) {
// MATMSG:TO: email@example.com;SUB:email subject;BODY:Email text;;
const parsing = /^MATMSG:(?:TO:([^;]*);)?(?:SUB:([^;]*);)?(?:BODY:([^;]*))?;;$/.exec(qrContent) || [];
return {
type: 'Email',
value: {
to: parsing[1]?.trim(),
subject: parsing[2]?.trim(),
body: parsing[3]?.trim(),
},
};
}
if (qrContent.startsWith('mailto:')) {
// mailto:email@example.com?subject=email subject&body=Email text
const parsing = /^mailto:([^\?]+)\?subject=([^\&]*)(?:&body=(.*))$/.exec(qrContent) || [];
return {
type: 'Email',
value: {
to: parsing[1]?.trim(),
subject: parsing[2]?.trim(),
body: parsing[3]?.trim(),
},
};
}
if (qrContent.startsWith('SMTP:')) {
// SMTP:email@example.com:email subject:Email text
const parsing = /^SMTP:([^:]+)(?::([^:]*))(?::([^:]*))?$/.exec(qrContent) || [];
return {
type: 'Email',
value: {
to: parsing[1]?.trim(),
subject: parsing[2]?.trim(),
body: parsing[3]?.trim(),
},
};
}
if (qrContent.startsWith('smsto:')) {
// smsto:${phoneNumber}:${message}
const parsing = /^smsto:([^:]+)(?::(.+))$/.exec(qrContent) || [];
return {
type: 'SMS',
value: {
to: parsing[1]?.trim(),
message: parsing[2]?.trim(),
},
};
}
if (qrContent.startsWith('WIFI:')) {
// WIFI:T:${authentication};S:${name};${authentication !== 'nopass' ? `P:${password};` : ''}H:${hidden};
const parsing = /^WIFI:T:([^;]+);S:([^;]+);(?:P:([^;]+);)?(?:H:([^;]+);)?$/.exec(qrContent) || [];
return {
type: 'Wifi',
value: {
authentication: parsing[1]?.trim(),
name: parsing[2]?.trim(),
password: parsing[3]?.trim(),
hidden: parsing[4]?.trim(),
},
};
}
if (/^(?:https?|ftp):\/\//.test(qrContent)) {
return {
type: 'Url',
value: qrContent,
};
}
return {
type: 'Text',
value: qrContent,
};
}
@@ -0,0 +1,64 @@
<script setup lang="ts">
import type { Ref } from 'vue';
import qrcodeParser from 'qrcode-parser';
import { parseQRData } from './qr-code-decoder.service';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const fileInput = ref() as Ref<File>;
const qrCode = computedAsync(async () => {
try {
return (await qrcodeParser(fileInput.value));
}
catch (e: any) {
return e.toString();
}
});
const qrCodeParsed = computed(() => {
try {
const parsed = parseQRData(qrCode.value);
return `Type: ${parsed.type}\nValue:${JSON.stringify(parsed.value, null, 2)}`;
}
catch (e: any) {
return e.toString();
}
});
async function onUpload(file: File) {
if (file) {
fileInput.value = file;
}
}
</script>
<template>
<div>
<c-file-upload
title="Drag and drop a QR Code here, or click to select a file"
:paste-image="true"
@file-upload="onUpload"
/>
<n-divider />
<div>
<h3>Decoded</h3>
<TextareaCopyable
:value="qrCode"
:word-wrap="true"
/>
</div>
<div>
<h3>Parsed</h3>
<TextareaCopyable
:value="qrCodeParsed"
:word-wrap="true"
/>
</div>
</div>
</template>
<style lang="less" scoped>
::v-deep(.n-upload-trigger) {
width: 100%;
}
</style>
+66 -2
View File
@@ -5,10 +5,12 @@ const props = withDefaults(defineProps<{
multiple?: boolean
accept?: string
title?: string
pasteImage?: boolean
}>(), {
multiple: false,
accept: undefined,
title: 'Drag and drop files here, or click to select files',
pasteImage: false,
});
const emit = defineEmits<{
@@ -16,11 +18,31 @@ const emit = defineEmits<{
(event: 'fileUpload', file: File): void
}>();
const { multiple } = toRefs(props);
const { multiple, pasteImage } = toRefs(props);
const isOverDropZone = ref(false);
function toBase64(file: File) {
return new Promise<string>((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result?.toString() ?? '');
reader.onerror = error => reject(error);
});
}
const fileInput = ref<HTMLInputElement | null>(null);
const imgPreview = ref<HTMLImageElement | null>(null);
async function handlePreview(image: File) {
if (imgPreview.value) {
imgPreview.value.src = await toBase64(image);
}
}
function clearPreview() {
if (imgPreview.value) {
imgPreview.value.src = '';
}
}
function triggerFileInput() {
fileInput.value?.click();
@@ -39,7 +61,30 @@ function handleDrop(event: DragEvent) {
handleUpload(files);
}
function handleUpload(files: FileList | null | undefined) {
async function onPasteImage(evt: ClipboardEvent) {
if (!pasteImage.value) {
return false;
}
const items = evt.clipboardData?.items;
if (!items) {
return false;
}
for (let i = 0; i < items.length; i++) {
if (items[i].type.includes('image')) {
const imageFile = items[i].getAsFile();
if (imageFile) {
await handlePreview(imageFile);
emit('fileUpload', imageFile);
}
}
}
return true;
}
async function handleUpload(files: FileList | null | undefined) {
clearPreview();
if (_.isNil(files) || _.isEmpty(files)) {
return;
}
@@ -49,6 +94,7 @@ function handleUpload(files: FileList | null | undefined) {
return;
}
await handlePreview(files[0]);
emit('fileUpload', files[0]);
}
</script>
@@ -60,6 +106,7 @@ function handleUpload(files: FileList | null | undefined) {
'border-primary border-opacity-100': isOverDropZone,
}"
@click="triggerFileInput"
@paste.prevent="onPasteImage"
@drop.prevent="handleDrop"
@dragover.prevent
@dragenter="isOverDropZone = true"
@@ -73,6 +120,7 @@ function handleUpload(files: FileList | null | undefined) {
:accept="accept"
@change="handleFileInput"
>
<slot>
<span op-70>
{{ title }}
@@ -90,6 +138,22 @@ function handleUpload(files: FileList | null | undefined) {
<c-button>
Browse files
</c-button>
<div v-if="pasteImage">
<!-- separator -->
<div my-4 w-full flex items-center justify-center op-70>
<div class="h-1px max-w-100px flex-1 bg-gray-300 op-50" />
<div class="mx-2 text-gray-400">
or
</div>
<div class="h-1px max-w-100px flex-1 bg-gray-300 op-50" />
</div>
<p>Paste an image from clipboard</p>
</div>
</slot>
<div mt-2>
<img ref="imgPreview" width="150">
</div>
</div>
</template>