Compare commits

..
13 changed files with 62 additions and 412 deletions

No files matched your search

+4 -3
View File
@@ -133,7 +133,6 @@ declare module '@vue/runtime-core' {
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']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NForm: typeof import('naive-ui')['NForm']
@@ -141,22 +140,24 @@ declare module '@vue/runtime-core' {
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NImage: typeof import('naive-ui')['NImage']
NInput: typeof import('naive-ui')['NInput']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NLi: typeof import('naive-ui')['NLi']
NMenu: typeof import('naive-ui')['NMenu']
NP: typeof import('naive-ui')['NP']
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']
PasteAsMarkdown: typeof import('./src/tools/paste-as-markdown/paste-as-markdown.vue')['default']
PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.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']
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']
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']
+1 -2
View File
@@ -35,6 +35,7 @@
"release": "node ./scripts/release.mjs"
},
"dependencies": {
"@github/paste-markdown": "^1.5.3",
"@it-tools/bip39": "^0.0.4",
"@it-tools/oggen": "^1.3.0",
"@sindresorhus/slugify": "^2.2.1",
@@ -67,7 +68,6 @@
"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",
@@ -85,7 +85,6 @@
"pinia": "^2.0.34",
"plausible-tracker": "^0.3.8",
"qrcode": "^1.5.1",
"qrcode-parser": "^2.1.3",
"sql-formatter": "^13.0.0",
"ua-parser-js": "^1.0.35",
"ulid": "^2.3.0",
+7 -20
View File
@@ -5,6 +5,9 @@ settings:
excludeLinksFromLockfile: false
dependencies:
'@github/paste-markdown':
specifier: ^1.5.3
version: 1.5.3
'@it-tools/bip39':
specifier: ^0.0.4
version: 0.0.4
@@ -98,9 +101,6 @@ 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
@@ -155,9 +155,6 @@ dependencies:
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
@@ -2171,6 +2168,10 @@ packages:
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/@github/paste-markdown@1.5.3:
resolution: {integrity: sha512-PzZ1b3PaqBzYqbT4fwKEhiORf38h2OcGp2+JdXNNM7inZ7egaSmfmhyNkQILpqWfS0AYtRS3CDq6z03eZ8yOMQ==}
dev: false
/@humanwhocodes/config-array@0.11.10:
resolution: {integrity: sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==}
engines: {node: '>=10.10.0'}
@@ -6122,10 +6123,6 @@ 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'}
@@ -6650,10 +6647,6 @@ 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
@@ -7743,12 +7736,6 @@ packages:
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==}
engines: {node: '>=10.13.0'}
+3 -8
View File
@@ -9,7 +9,7 @@ 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 pasteAsMarkdown } from './paste-as-markdown';
import { tool as markdownToHtml } from './markdown-to-html';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
@@ -140,13 +140,7 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Images and videos',
components: [
qrCodeGenerator,
wifiQrCodeGenerator,
qrCodeDecoder,
svgPlaceholderGenerator,
cameraRecorder,
],
components: [qrCodeGenerator, wifiQrCodeGenerator, svgPlaceholderGenerator, cameraRecorder],
},
{
name: 'Development',
@@ -187,6 +181,7 @@ export const toolsByCategory: ToolCategory[] = [
textDiff,
numeronymGenerator,
asciiTextDrawer,
pasteAsMarkdown,
],
},
{
+12
View File
@@ -0,0 +1,12 @@
import { Markdown } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Paste as Markdown',
path: '/paste-as-markdown',
description: 'Paste cells/tables and links from clipboard content as Markdown',
keywords: ['paste', 'cell', 'table', 'links', 'md', 'markdown'],
component: () => import('./paste-as-markdown.vue'),
icon: Markdown,
createdAt: new Date('2024-07-14'),
});
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { subscribe } from '@github/paste-markdown';
import CInputText from '@/ui/c-input-text/c-input-text.vue';
const inputElement = ref<typeof CInputText>();
const markdown = ref('');
// Subscribe the behavior to the textarea.
onMounted(() => {
subscribe(inputElement.value?.textareaRef as never);
});
</script>
<template>
<c-card title="Paste in Markdown" class="paste-zone">
<n-ul>
<n-li>Paste spreadsheet cells and HTML tables as a Markdown tables.</n-li>
<n-li>Paste URLs on selected text as Markdown links.</n-li>
<n-li>Paste text containing links as text containing Markdown links.</n-li>
<n-li>Paste image URLs as Markdown image links.</n-li>
</n-ul>
<CInputText
ref="inputElement"
v-model:value="markdown"
multiline
placeholder="Paste your content here..."
rows="10"
w-full
/>
</c-card>
</template>
-3
View File
@@ -1,3 +0,0 @@
declare module "ical.js" {
export function parse(content: string): object;
}
-12
View File
@@ -1,12 +0,0 @@
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'),
});
@@ -1,151 +0,0 @@
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',
],
],
[],
],
],
],
});
});
});
@@ -1,83 +0,0 @@
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,
};
}
@@ -1,64 +0,0 @@
<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>
+2 -66
View File
@@ -5,12 +5,10 @@ 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<{
@@ -18,31 +16,11 @@ const emit = defineEmits<{
(event: 'fileUpload', file: File): void
}>();
const { multiple, pasteImage } = toRefs(props);
const { multiple } = 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();
@@ -61,30 +39,7 @@ function handleDrop(event: DragEvent) {
handleUpload(files);
}
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();
function handleUpload(files: FileList | null | undefined) {
if (_.isNil(files) || _.isEmpty(files)) {
return;
}
@@ -94,7 +49,6 @@ async function handleUpload(files: FileList | null | undefined) {
return;
}
await handlePreview(files[0]);
emit('fileUpload', files[0]);
}
</script>
@@ -106,7 +60,6 @@ async 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"
@@ -120,7 +73,6 @@ async function handleUpload(files: FileList | null | undefined) {
:accept="accept"
@change="handleFileInput"
>
<slot>
<span op-70>
{{ title }}
@@ -138,22 +90,6 @@ async 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>
+2
View File
@@ -137,6 +137,8 @@ onMounted(() => {
defineExpose({
inputWrapperRef,
textareaRef,
inputRef,
focus,
blur,
});