mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-28 16:19:48 +03:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
880d937d33 | ||
|
|
9ebf98352e | ||
|
|
d30344beef | ||
|
|
a3a624c292 | ||
|
|
1fb3e1f922 | ||
|
|
951143d63d | ||
|
|
87984e2081 | ||
|
|
e8cd98c25d | ||
|
|
dbd4730256 | ||
|
|
6d619603f9 |
No files matched your search
Vendored
+5
-1
@@ -121,6 +121,7 @@ declare module '@vue/runtime-core' {
|
|||||||
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
|
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']
|
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']
|
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']
|
MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default']
|
||||||
MenuBar: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar.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']
|
MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default']
|
||||||
@@ -129,8 +130,10 @@ declare module '@vue/runtime-core' {
|
|||||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||||
|
NButton: typeof import('naive-ui')['NButton']
|
||||||
NCode: typeof import('naive-ui')['NCode']
|
NCode: typeof import('naive-ui')['NCode']
|
||||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||||
|
NColorPicker: typeof import('naive-ui')['NColorPicker']
|
||||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||||
NForm: typeof import('naive-ui')['NForm']
|
NForm: typeof import('naive-ui')['NForm']
|
||||||
@@ -138,6 +141,7 @@ declare module '@vue/runtime-core' {
|
|||||||
NH1: typeof import('naive-ui')['NH1']
|
NH1: typeof import('naive-ui')['NH1']
|
||||||
NH3: typeof import('naive-ui')['NH3']
|
NH3: typeof import('naive-ui')['NH3']
|
||||||
NIcon: typeof import('naive-ui')['NIcon']
|
NIcon: typeof import('naive-ui')['NIcon']
|
||||||
|
NImage: typeof import('naive-ui')['NImage']
|
||||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
||||||
NLayout: typeof import('naive-ui')['NLayout']
|
NLayout: typeof import('naive-ui')['NLayout']
|
||||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||||
@@ -152,9 +156,9 @@ declare module '@vue/runtime-core' {
|
|||||||
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
|
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']
|
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']
|
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.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']
|
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']
|
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
||||||
RemoveExif: typeof import('./src/tools/remove-exif/remove-exif.vue')['default']
|
|
||||||
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
|
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
|
||||||
RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default']
|
RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
|
|||||||
+4
-4
@@ -41,8 +41,8 @@
|
|||||||
"@tiptap/pm": "2.1.6",
|
"@tiptap/pm": "2.1.6",
|
||||||
"@tiptap/starter-kit": "2.1.6",
|
"@tiptap/starter-kit": "2.1.6",
|
||||||
"@tiptap/vue-3": "2.0.3",
|
"@tiptap/vue-3": "2.0.3",
|
||||||
|
"@types/markdown-it": "^13.0.7",
|
||||||
"@types/figlet": "^1.5.8",
|
"@types/figlet": "^1.5.8",
|
||||||
"@types/memorystream": "^0.3.4",
|
|
||||||
"@vicons/material": "^0.12.0",
|
"@vicons/material": "^0.12.0",
|
||||||
"@vicons/tabler": "^0.12.0",
|
"@vicons/tabler": "^0.12.0",
|
||||||
"@vueuse/core": "^10.3.0",
|
"@vueuse/core": "^10.3.0",
|
||||||
@@ -60,7 +60,6 @@
|
|||||||
"dompurify": "^3.0.6",
|
"dompurify": "^3.0.6",
|
||||||
"email-normalizer": "^1.0.0",
|
"email-normalizer": "^1.0.0",
|
||||||
"emojilib": "^3.0.10",
|
"emojilib": "^3.0.10",
|
||||||
"exif-be-gone": "^1.5.1",
|
|
||||||
"figlet": "^1.7.0",
|
"figlet": "^1.7.0",
|
||||||
"figue": "^1.2.0",
|
"figue": "^1.2.0",
|
||||||
"fuse.js": "^6.6.2",
|
"fuse.js": "^6.6.2",
|
||||||
@@ -68,13 +67,14 @@
|
|||||||
"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.6",
|
||||||
|
"ical.js": "^2.0.1",
|
||||||
"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",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"markdown-it": "^14.0.0",
|
||||||
"marked": "^10.0.0",
|
"marked": "^10.0.0",
|
||||||
"mathjs": "^11.9.1",
|
"mathjs": "^11.9.1",
|
||||||
"memorystream": "^0.3.1",
|
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
"monaco-editor": "^0.43.0",
|
"monaco-editor": "^0.43.0",
|
||||||
"naive-ui": "^2.35.0",
|
"naive-ui": "^2.35.0",
|
||||||
@@ -85,6 +85,7 @@
|
|||||||
"pinia": "^2.0.34",
|
"pinia": "^2.0.34",
|
||||||
"plausible-tracker": "^0.3.8",
|
"plausible-tracker": "^0.3.8",
|
||||||
"qrcode": "^1.5.1",
|
"qrcode": "^1.5.1",
|
||||||
|
"qrcode-parser": "^2.1.3",
|
||||||
"sql-formatter": "^13.0.0",
|
"sql-formatter": "^13.0.0",
|
||||||
"ua-parser-js": "^1.0.35",
|
"ua-parser-js": "^1.0.35",
|
||||||
"ulid": "^2.3.0",
|
"ulid": "^2.3.0",
|
||||||
@@ -137,7 +138,6 @@
|
|||||||
"unplugin-icons": "^0.17.0",
|
"unplugin-icons": "^0.17.0",
|
||||||
"unplugin-vue-components": "^0.25.0",
|
"unplugin-vue-components": "^0.25.0",
|
||||||
"vite": "^4.4.9",
|
"vite": "^4.4.9",
|
||||||
"vite-plugin-node-polyfills": "^0.22.0",
|
|
||||||
"vite-plugin-pwa": "^0.16.0",
|
"vite-plugin-pwa": "^0.16.0",
|
||||||
"vite-plugin-vue-markdown": "^0.23.5",
|
"vite-plugin-vue-markdown": "^0.23.5",
|
||||||
"vite-svg-loader": "^4.0.0",
|
"vite-svg-loader": "^4.0.0",
|
||||||
|
|||||||
Generated
+66
-654
File diff suppressed because it is too large.
Load diff
@@ -7,6 +7,7 @@ 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 markdownHljs from 'highlight.js/lib/languages/markdown';
|
||||||
import { useCopy } from '@/composable/copy';
|
import { useCopy } from '@/composable/copy';
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
@@ -30,6 +31,7 @@ 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('markdown', markdownHljs);
|
||||||
|
|
||||||
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
|
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
|
||||||
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
|
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
|
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
|
||||||
import type { MaybeRef, Ref } from 'vue';
|
import type { Ref } from 'vue';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { get } from '@vueuse/core';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getMimeTypeFromBase64,
|
getMimeTypeFromBase64,
|
||||||
@@ -76,11 +75,21 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
|
|||||||
}
|
}
|
||||||
|
|
||||||
function useDownloadFileFromBase64(
|
function useDownloadFileFromBase64(
|
||||||
{ source, filename, extension }:
|
{ source, filename, extension, fileMimeType }:
|
||||||
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
|
{ source: Ref<string>; filename?: string; extension?: string; fileMimeType?: string }) {
|
||||||
return {
|
return {
|
||||||
download() {
|
download() {
|
||||||
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
|
downloadFromBase64({ sourceValue: source.value, filename, extension, fileMimeType });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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 });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -107,13 +116,3 @@ 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 });
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
+4
-2
@@ -7,9 +7,10 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
|||||||
|
|
||||||
import { tool as textToUnicode } from './text-to-unicode';
|
import { tool as textToUnicode } from './text-to-unicode';
|
||||||
import { tool as safelinkDecoder } from './safelink-decoder';
|
import { tool as safelinkDecoder } from './safelink-decoder';
|
||||||
import { tool as removeExif } from './remove-exif';
|
|
||||||
import { tool as xmlToJson } from './xml-to-json';
|
import { tool as xmlToJson } from './xml-to-json';
|
||||||
import { tool as jsonToXml } from './json-to-xml';
|
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 pdfSignatureChecker } from './pdf-signature-checker';
|
||||||
import { tool as numeronymGenerator } from './numeronym-generator';
|
import { tool as numeronymGenerator } from './numeronym-generator';
|
||||||
import { tool as macAddressGenerator } from './mac-address-generator';
|
import { tool as macAddressGenerator } from './mac-address-generator';
|
||||||
@@ -113,6 +114,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
tomlToYaml,
|
tomlToYaml,
|
||||||
xmlToJson,
|
xmlToJson,
|
||||||
jsonToXml,
|
jsonToXml,
|
||||||
|
markdownToHtml,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -141,9 +143,9 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
components: [
|
components: [
|
||||||
qrCodeGenerator,
|
qrCodeGenerator,
|
||||||
wifiQrCodeGenerator,
|
wifiQrCodeGenerator,
|
||||||
|
qrCodeDecoder,
|
||||||
svgPlaceholderGenerator,
|
svgPlaceholderGenerator,
|
||||||
cameraRecorder,
|
cameraRecorder,
|
||||||
removeExif,
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
declare module "ical.js" {
|
||||||
|
export function parse(content: string): object;
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { PictureInPictureOff } from '@vicons/tabler';
|
|
||||||
import { defineTool } from '../tool';
|
|
||||||
|
|
||||||
export const tool = defineTool({
|
|
||||||
name: 'Remove EXIF',
|
|
||||||
path: '/remove-exif',
|
|
||||||
description: 'Remove Exif from JPEG Files',
|
|
||||||
keywords: ['remove', 'exif', 'jpeg'],
|
|
||||||
component: () => import('./remove-exif.vue'),
|
|
||||||
icon: PictureInPictureOff,
|
|
||||||
createdAt: new Date('2024-07-14'),
|
|
||||||
});
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { Buffer } from 'node:buffer';
|
|
||||||
import { Base64 } from 'js-base64';
|
|
||||||
import ExifTransformer from 'exif-be-gone';
|
|
||||||
import MemoryStream from 'memorystream';
|
|
||||||
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
|
||||||
|
|
||||||
const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle');
|
|
||||||
const file = ref<File | null>(null);
|
|
||||||
|
|
||||||
interface ToBufferMemoryStream extends MemoryStream {
|
|
||||||
toBuffer(): Buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
const base64OutputFile = ref('');
|
|
||||||
const fileName = ref('');
|
|
||||||
const { download } = useDownloadFileFromBase64(
|
|
||||||
{
|
|
||||||
source: base64OutputFile,
|
|
||||||
filename: fileName,
|
|
||||||
extension: 'jpg',
|
|
||||||
});
|
|
||||||
|
|
||||||
async function onFileUploaded(uploadedFile: File) {
|
|
||||||
file.value = uploadedFile;
|
|
||||||
const fileBuffer = await uploadedFile.arrayBuffer();
|
|
||||||
|
|
||||||
fileName.value = `noexif_${uploadedFile.name}`;
|
|
||||||
status.value = 'processing';
|
|
||||||
try {
|
|
||||||
const inStream = MemoryStream.createReadStream(Buffer.from(fileBuffer));
|
|
||||||
const outStream = MemoryStream.createWriteStream();
|
|
||||||
const trans = new ExifTransformer();
|
|
||||||
await new Promise((resolve, _reject) => {
|
|
||||||
inStream.pipe(trans).pipe(outStream).on('finish', () => resolve(true));
|
|
||||||
});
|
|
||||||
|
|
||||||
const outFileBuffer = (outStream as ToBufferMemoryStream).toBuffer();
|
|
||||||
base64OutputFile.value = `data:image/File;base64,${Base64.fromUint8Array(outFileBuffer)}`;
|
|
||||||
status.value = 'done';
|
|
||||||
|
|
||||||
download();
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
status.value = 'error';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<div style="flex: 0 0 100%">
|
|
||||||
<div mx-auto max-w-600px>
|
|
||||||
<c-file-upload title="Drag and drop a Image file here, or click to select a file" accept="image/*" @file-upload="onFileUploaded" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div mt-3 flex justify-center>
|
|
||||||
<c-alert v-if="status === 'error'" type="error">
|
|
||||||
An error occured processing {{ fileName }}
|
|
||||||
</c-alert>
|
|
||||||
<n-spin
|
|
||||||
v-if="status === 'processing'"
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -5,10 +5,12 @@ const props = withDefaults(defineProps<{
|
|||||||
multiple?: boolean
|
multiple?: boolean
|
||||||
accept?: string
|
accept?: string
|
||||||
title?: string
|
title?: string
|
||||||
|
pasteImage?: boolean
|
||||||
}>(), {
|
}>(), {
|
||||||
multiple: false,
|
multiple: false,
|
||||||
accept: undefined,
|
accept: undefined,
|
||||||
title: 'Drag and drop files here, or click to select files',
|
title: 'Drag and drop files here, or click to select files',
|
||||||
|
pasteImage: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -16,11 +18,31 @@ const emit = defineEmits<{
|
|||||||
(event: 'fileUpload', file: File): void
|
(event: 'fileUpload', file: File): void
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { multiple } = toRefs(props);
|
const { multiple, pasteImage } = toRefs(props);
|
||||||
|
|
||||||
const isOverDropZone = ref(false);
|
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 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() {
|
function triggerFileInput() {
|
||||||
fileInput.value?.click();
|
fileInput.value?.click();
|
||||||
@@ -39,7 +61,30 @@ function handleDrop(event: DragEvent) {
|
|||||||
handleUpload(files);
|
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)) {
|
if (_.isNil(files) || _.isEmpty(files)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -49,6 +94,7 @@ function handleUpload(files: FileList | null | undefined) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await handlePreview(files[0]);
|
||||||
emit('fileUpload', files[0]);
|
emit('fileUpload', files[0]);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -60,6 +106,7 @@ function handleUpload(files: FileList | null | undefined) {
|
|||||||
'border-primary border-opacity-100': isOverDropZone,
|
'border-primary border-opacity-100': isOverDropZone,
|
||||||
}"
|
}"
|
||||||
@click="triggerFileInput"
|
@click="triggerFileInput"
|
||||||
|
@paste.prevent="onPasteImage"
|
||||||
@drop.prevent="handleDrop"
|
@drop.prevent="handleDrop"
|
||||||
@dragover.prevent
|
@dragover.prevent
|
||||||
@dragenter="isOverDropZone = true"
|
@dragenter="isOverDropZone = true"
|
||||||
@@ -73,6 +120,7 @@ function handleUpload(files: FileList | null | undefined) {
|
|||||||
:accept="accept"
|
:accept="accept"
|
||||||
@change="handleFileInput"
|
@change="handleFileInput"
|
||||||
>
|
>
|
||||||
|
|
||||||
<slot>
|
<slot>
|
||||||
<span op-70>
|
<span op-70>
|
||||||
{{ title }}
|
{{ title }}
|
||||||
@@ -90,6 +138,22 @@ function handleUpload(files: FileList | null | undefined) {
|
|||||||
<c-button>
|
<c-button>
|
||||||
Browse files
|
Browse files
|
||||||
</c-button>
|
</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>
|
</slot>
|
||||||
|
<div mt-2>
|
||||||
|
<img ref="imgPreview" width="150">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -15,7 +15,6 @@ import { VitePWA } from 'vite-plugin-pwa';
|
|||||||
import markdown from 'vite-plugin-vue-markdown';
|
import markdown from 'vite-plugin-vue-markdown';
|
||||||
import svgLoader from 'vite-svg-loader';
|
import svgLoader from 'vite-svg-loader';
|
||||||
import { configDefaults } from 'vitest/config';
|
import { configDefaults } from 'vitest/config';
|
||||||
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
|
||||||
|
|
||||||
const baseUrl = process.env.BASE_URL ?? '/';
|
const baseUrl = process.env.BASE_URL ?? '/';
|
||||||
|
|
||||||
@@ -98,7 +97,6 @@ export default defineConfig({
|
|||||||
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
|
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
|
||||||
}),
|
}),
|
||||||
Unocss(),
|
Unocss(),
|
||||||
nodePolyfills(),
|
|
||||||
],
|
],
|
||||||
base: baseUrl,
|
base: baseUrl,
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|||||||
Reference in new issue
Block a user