mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-23 22:31:10 +03:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
476172af16 | ||
|
|
ba1b5bc5b6 | ||
|
|
318fb6efb9 | ||
|
|
f1a5489e21 | ||
|
|
e1b4f9aafe |
No files matched your search
Vendored
+9
-5
@@ -72,6 +72,7 @@ declare module '@vue/runtime-core' {
|
||||
DockerRunToDockerComposeConverter: typeof import('./src/tools/docker-run-to-docker-compose-converter/docker-run-to-docker-compose-converter.vue')['default']
|
||||
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
|
||||
Editor: typeof import('./src/tools/html-wysiwyg-editor/editor/editor.vue')['default']
|
||||
EmailNormalizer: typeof import('./src/tools/email-normalizer/email-normalizer.vue')['default']
|
||||
EmojiCard: typeof import('./src/tools/emoji-picker/emoji-card.vue')['default']
|
||||
EmojiGrid: typeof import('./src/tools/emoji-picker/emoji-grid.vue')['default']
|
||||
EmojiPicker: typeof import('./src/tools/emoji-picker/emoji-picker.vue')['default']
|
||||
@@ -110,6 +111,7 @@ declare module '@vue/runtime-core' {
|
||||
JsonMinify: typeof import('./src/tools/json-minify/json-minify.vue')['default']
|
||||
JsonToCsv: typeof import('./src/tools/json-to-csv/json-to-csv.vue')['default']
|
||||
JsonToToml: typeof import('./src/tools/json-to-toml/json-to-toml.vue')['default']
|
||||
JsonToXml: typeof import('./src/tools/json-to-xml/json-to-xml.vue')['default']
|
||||
JsonToYaml: typeof import('./src/tools/json-to-yaml-converter/json-to-yaml.vue')['default']
|
||||
JsonViewer: typeof import('./src/tools/json-viewer/json-viewer.vue')['default']
|
||||
JwtParser: typeof import('./src/tools/jwt-parser/jwt-parser.vue')['default']
|
||||
@@ -130,20 +132,20 @@ declare module '@vue/runtime-core' {
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
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']
|
||||
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']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NSpin: typeof import('naive-ui')['NSpin']
|
||||
NStatistic: typeof import('naive-ui')['NStatistic']
|
||||
NSlider: typeof import('naive-ui')['NSlider']
|
||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OcrImage: typeof import('./src/tools/ocr-image/ocr-image.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']
|
||||
PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.vue')['default']
|
||||
@@ -152,6 +154,7 @@ declare module '@vue/runtime-core' {
|
||||
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.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']
|
||||
RemoveExif: typeof import('./src/tools/remove-exif/remove-exif.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']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
@@ -184,6 +187,7 @@ declare module '@vue/runtime-core' {
|
||||
UuidGenerator: typeof import('./src/tools/uuid-generator/uuid-generator.vue')['default']
|
||||
WifiQrCodeGenerator: typeof import('./src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue')['default']
|
||||
XmlFormatter: typeof import('./src/tools/xml-formatter/xml-formatter.vue')['default']
|
||||
XmlToJson: typeof import('./src/tools/xml-to-json/xml-to-json.vue')['default']
|
||||
YamlToJson: typeof import('./src/tools/yaml-to-json-converter/yaml-to-json.vue')['default']
|
||||
YamlToToml: typeof import('./src/tools/yaml-to-toml/yaml-to-toml.vue')['default']
|
||||
YamlViewer: typeof import('./src/tools/yaml-viewer/yaml-viewer.vue')['default']
|
||||
|
||||
+6
-4
@@ -41,8 +41,8 @@
|
||||
"@tiptap/pm": "2.1.6",
|
||||
"@tiptap/starter-kit": "2.1.6",
|
||||
"@tiptap/vue-3": "2.0.3",
|
||||
"@types/pdfjs-dist": "^2.10.378",
|
||||
"@types/figlet": "^1.5.8",
|
||||
"@types/memorystream": "^0.3.4",
|
||||
"@vicons/material": "^0.12.0",
|
||||
"@vicons/tabler": "^0.12.0",
|
||||
"@vueuse/core": "^10.3.0",
|
||||
@@ -58,7 +58,9 @@
|
||||
"crypto-js": "^4.1.1",
|
||||
"date-fns": "^2.29.3",
|
||||
"dompurify": "^3.0.6",
|
||||
"email-normalizer": "^1.0.0",
|
||||
"emojilib": "^3.0.10",
|
||||
"exif-be-gone": "^1.5.1",
|
||||
"figlet": "^1.7.0",
|
||||
"figue": "^1.2.0",
|
||||
"fuse.js": "^6.6.2",
|
||||
@@ -72,20 +74,18 @@
|
||||
"lodash": "^4.17.21",
|
||||
"marked": "^10.0.0",
|
||||
"mathjs": "^11.9.1",
|
||||
"memorystream": "^0.3.1",
|
||||
"mime-types": "^2.1.35",
|
||||
"monaco-editor": "^0.43.0",
|
||||
"naive-ui": "^2.35.0",
|
||||
"netmask": "^2.0.2",
|
||||
"node-forge": "^1.3.1",
|
||||
"oui-data": "^1.0.10",
|
||||
"path2d-polyfill": "^3.0.1",
|
||||
"pdf-signature-reader": "^1.4.2",
|
||||
"pdfjs-dist": "^4.0.379",
|
||||
"pinia": "^2.0.34",
|
||||
"plausible-tracker": "^0.3.8",
|
||||
"qrcode": "^1.5.1",
|
||||
"sql-formatter": "^13.0.0",
|
||||
"tesseract.js": "^5.0.4",
|
||||
"ua-parser-js": "^1.0.35",
|
||||
"ulid": "^2.3.0",
|
||||
"unicode-emoji-json": "^0.4.0",
|
||||
@@ -96,6 +96,7 @@
|
||||
"vue-router": "^4.1.6",
|
||||
"vue-tsc": "^1.8.1",
|
||||
"xml-formatter": "^3.3.2",
|
||||
"xml-js": "^1.6.11",
|
||||
"yaml": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -136,6 +137,7 @@
|
||||
"unplugin-icons": "^0.17.0",
|
||||
"unplugin-vue-components": "^0.25.0",
|
||||
"vite": "^4.4.9",
|
||||
"vite-plugin-node-polyfills": "^0.22.0",
|
||||
"vite-plugin-pwa": "^0.16.0",
|
||||
"vite-plugin-vue-markdown": "^0.23.5",
|
||||
"vite-svg-loader": "^4.0.0",
|
||||
|
||||
Generated
+713
-427
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
||||
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 { get } from '@vueuse/core';
|
||||
|
||||
export {
|
||||
getMimeTypeFromBase64,
|
||||
@@ -75,21 +76,11 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
|
||||
}
|
||||
|
||||
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: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
|
||||
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
|
||||
return {
|
||||
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;
|
||||
}
|
||||
|
||||
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 });
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useRouteQuery } from '@vueuse/router';
|
||||
import { computed } from 'vue';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
|
||||
export { useQueryParam, useQueryParamOrStorage };
|
||||
export { useQueryParam };
|
||||
|
||||
const transformers = {
|
||||
number: {
|
||||
@@ -17,12 +16,6 @@ const transformers = {
|
||||
fromQuery: (value: string) => value.toLowerCase() === 'true',
|
||||
toQuery: (value: boolean) => (value ? 'true' : 'false'),
|
||||
},
|
||||
object: {
|
||||
fromQuery: (value: string) => {
|
||||
return JSON.parse(value);
|
||||
},
|
||||
toQuery: (value: object) => JSON.stringify(value),
|
||||
},
|
||||
};
|
||||
|
||||
function useQueryParam<T>({ name, defaultValue }: { name: string; defaultValue: T }) {
|
||||
@@ -40,27 +33,3 @@ function useQueryParam<T>({ name, defaultValue }: { name: string; defaultValue:
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function useQueryParamOrStorage<T>({ name, storageName, defaultValue }: { name: string; storageName: string; defaultValue: T }) {
|
||||
const type = typeof defaultValue;
|
||||
const transformer = transformers[type as keyof typeof transformers] ?? transformers.string;
|
||||
|
||||
const storageRef = useStorage(storageName, defaultValue);
|
||||
const proxyDefaultValue = transformer.toQuery(defaultValue as never);
|
||||
const proxy = useRouteQuery(name, proxyDefaultValue);
|
||||
|
||||
const r = ref(defaultValue);
|
||||
|
||||
watch(r,
|
||||
(value) => {
|
||||
proxy.value = transformer.toQuery(value as never);
|
||||
storageRef.value = value as never;
|
||||
},
|
||||
{ deep: true });
|
||||
|
||||
r.value = (proxy.value && proxy.value !== proxyDefaultValue
|
||||
? transformer.fromQuery(proxy.value) as unknown as T
|
||||
: storageRef.value as T) as never;
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<script setup lang="ts">
|
||||
import { normalizeEmail } from 'email-normalizer';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const emails = ref('');
|
||||
const normalizedEmails = computed(() => {
|
||||
if (!emails.value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return emails.value
|
||||
.split('\n')
|
||||
.map((email) => {
|
||||
return withDefaultOnError(() => normalizeEmail({ email }), `Unable to parse email: ${email}`);
|
||||
})
|
||||
.join('\n');
|
||||
});
|
||||
|
||||
const { copy } = useCopy({ source: normalizedEmails, text: 'Normalized emails copied to the clipboard', createToast: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="mb-2">
|
||||
Raw emails to normalize:
|
||||
</div>
|
||||
<c-input-text
|
||||
v-model:value="emails"
|
||||
placeholder="Put your emails here (one per line)..."
|
||||
rows="3"
|
||||
multiline
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
autofocus
|
||||
monospace
|
||||
/>
|
||||
|
||||
<div class="mb-2 mt-4">
|
||||
Normalized emails:
|
||||
</div>
|
||||
<c-input-text
|
||||
:value="normalizedEmails"
|
||||
placeholder="Normalized emails will appear here..."
|
||||
rows="3"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
multiline
|
||||
readonly
|
||||
monospace
|
||||
/>
|
||||
<div class="mt-4 flex justify-center gap-2">
|
||||
<c-button @click="emails = ''">
|
||||
Clear emails
|
||||
</c-button>
|
||||
<c-button :disabled="!normalizedEmails" @click="copy()">
|
||||
Copy normalized emails
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Mail } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Email normalizer',
|
||||
path: '/email-normalizer',
|
||||
description: 'Normalize email addresses to a standard format for easier comparison. Useful for deduplication and data cleaning.',
|
||||
keywords: ['email', 'normalizer'],
|
||||
component: () => import('./email-normalizer.vue'),
|
||||
icon: Mail,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
+8
-2
@@ -1,12 +1,15 @@
|
||||
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 asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
import { tool as textToUnicode } from './text-to-unicode';
|
||||
import { tool as ocrImage } from './ocr-image';
|
||||
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 jsonToXml } from './json-to-xml';
|
||||
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
|
||||
import { tool as numeronymGenerator } from './numeronym-generator';
|
||||
import { tool as macAddressGenerator } from './mac-address-generator';
|
||||
@@ -108,6 +111,8 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
listConverter,
|
||||
tomlToJson,
|
||||
tomlToYaml,
|
||||
xmlToJson,
|
||||
jsonToXml,
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -138,7 +143,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
wifiQrCodeGenerator,
|
||||
svgPlaceholderGenerator,
|
||||
cameraRecorder,
|
||||
ocrImage,
|
||||
removeExif,
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -155,6 +160,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
dockerRunToDockerComposeConverter,
|
||||
xmlFormatter,
|
||||
yamlViewer,
|
||||
emailNormalizer,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Braces } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'JSON to XML',
|
||||
path: '/json-to-xml',
|
||||
description: 'Convert JSON to XML',
|
||||
keywords: ['json', 'xml'],
|
||||
component: () => import('./json-to-xml.vue'),
|
||||
icon: Braces,
|
||||
createdAt: new Date('2024-08-09'),
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import convert from 'xml-js';
|
||||
import JSON5 from 'json5';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
|
||||
const defaultValue = '{"a":{"_attributes":{"x":"1.234","y":"It\'s"}}}';
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => {
|
||||
return convert.js2xml(JSON5.parse(value), { compact: true });
|
||||
}, '');
|
||||
}
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: (v: string) => v === '' || JSON5.parse(v),
|
||||
message: 'Provided JSON is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your JSON content"
|
||||
:input-default="defaultValue"
|
||||
input-placeholder="Paste your JSON content here..."
|
||||
output-label="Converted XML"
|
||||
output-language="xml"
|
||||
:transformer="transformer"
|
||||
:input-validation-rules="rules"
|
||||
/>
|
||||
</template>
|
||||
@@ -2,6 +2,7 @@
|
||||
import { generateLoremIpsum } from './lorem-ipsum-generator.service';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { randIntFromInterval } from '@/utils/random';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
|
||||
const paragraphs = ref(1);
|
||||
const sentences = ref([3, 8]);
|
||||
@@ -9,7 +10,7 @@ const words = ref([8, 15]);
|
||||
const startWithLoremIpsum = ref(true);
|
||||
const asHTML = ref(false);
|
||||
|
||||
const loremIpsumText = computed(() =>
|
||||
const [loremIpsumText, refreshLoremIpsum] = computedRefreshable(() =>
|
||||
generateLoremIpsum({
|
||||
paragraphCount: paragraphs.value,
|
||||
asHTML: asHTML.value,
|
||||
@@ -18,6 +19,7 @@ const loremIpsumText = computed(() =>
|
||||
startWithLoremIpsum: startWithLoremIpsum.value,
|
||||
}),
|
||||
);
|
||||
|
||||
const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to the clipboard' });
|
||||
</script>
|
||||
|
||||
@@ -41,10 +43,13 @@ const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to
|
||||
|
||||
<c-input-text :value="loremIpsumText" multiline placeholder="Your lorem ipsum..." readonly mt-5 rows="5" />
|
||||
|
||||
<div mt-5 flex justify-center>
|
||||
<div mt-5 flex justify-center gap-3>
|
||||
<c-button autofocus @click="copy()">
|
||||
Copy
|
||||
</c-button>
|
||||
<c-button @click="refreshLoremIpsum">
|
||||
Refresh
|
||||
</c-button>
|
||||
</div>
|
||||
</c-card>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Scan } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'OCRize image and PDF',
|
||||
path: '/ocr-image',
|
||||
description: 'Perform OCR (Tesseract) on an image or PDF',
|
||||
keywords: ['ocr', 'image', 'tesseract', 'pdf'],
|
||||
component: () => import('./ocr-image.vue'),
|
||||
icon: Scan,
|
||||
createdAt: new Date('2024-03-09'),
|
||||
});
|
||||
@@ -1,251 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { Ref } from 'vue';
|
||||
import { createWorker } from 'tesseract.js';
|
||||
import { getDocument } from 'pdfjs-dist';
|
||||
import * as pdfJS from 'pdfjs-dist';
|
||||
import pdfJSWorkerURL from 'pdfjs-dist/build/pdf.worker?url';
|
||||
import { textStatistics } from '../text-statistics/text-statistics.service';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
|
||||
const languages = [
|
||||
{ name: 'English', code: 'eng' },
|
||||
{ name: 'Portuguese', code: 'por' },
|
||||
{ name: 'Afrikaans', code: 'afr' },
|
||||
{ name: 'Albanian', code: 'sqi' },
|
||||
{ name: 'Amharic', code: 'amh' },
|
||||
{ name: 'Arabic', code: 'ara' },
|
||||
{ name: 'Assamese', code: 'asm' },
|
||||
{ name: 'Azerbaijani', code: 'aze' },
|
||||
{ name: 'Azerbaijani - Cyrillic', code: 'aze_cyrl' },
|
||||
{ name: 'Basque', code: 'eus' },
|
||||
{ name: 'Belarusian', code: 'bel' },
|
||||
{ name: 'Bengali', code: 'ben' },
|
||||
{ name: 'Bosnian', code: 'bos' },
|
||||
{ name: 'Bulgarian', code: 'bul' },
|
||||
{ name: 'Burmese', code: 'mya' },
|
||||
{ name: 'Catalan; Valencian', code: 'cat' },
|
||||
{ name: 'Cebuano', code: 'ceb' },
|
||||
{ name: 'Central Khmer', code: 'khm' },
|
||||
{ name: 'Cherokee', code: 'chr' },
|
||||
{ name: 'Chinese - Simplified', code: 'chi_sim' },
|
||||
{ name: 'Chinese - Traditional', code: 'chi_tra' },
|
||||
{ name: 'Croatian', code: 'hrv' },
|
||||
{ name: 'Czech', code: 'ces' },
|
||||
{ name: 'Danish', code: 'dan' },
|
||||
{ name: 'Dutch; Flemish', code: 'nld' },
|
||||
{ name: 'Dzongkha', code: 'dzo' },
|
||||
{ name: 'English, Middle (1100-1500)', code: 'enm' },
|
||||
{ name: 'Esperanto', code: 'epo' },
|
||||
{ name: 'Estonian', code: 'est' },
|
||||
{ name: 'Finnish', code: 'fin' },
|
||||
{ name: 'French', code: 'fra' },
|
||||
{ name: 'French, Middle (ca. 1400-1600)', code: 'frm' },
|
||||
{ name: 'Galician', code: 'glg' },
|
||||
{ name: 'Georgian', code: 'kat' },
|
||||
{ name: 'German', code: 'deu' },
|
||||
{ name: 'German Fraktur', code: 'frk' },
|
||||
{ name: 'Greek, Modern (1453-)', code: 'ell' },
|
||||
{ name: 'Greek, Ancient (-1453)', code: 'grc' },
|
||||
{ name: 'Gujarati', code: 'guj' },
|
||||
{ name: 'Haitian; Haitian Creole', code: 'hat' },
|
||||
{ name: 'Hebrew', code: 'heb' },
|
||||
{ name: 'Hindi', code: 'hin' },
|
||||
{ name: 'Hungarian', code: 'hun' },
|
||||
{ name: 'Icelandic', code: 'isl' },
|
||||
{ name: 'Indonesian', code: 'ind' },
|
||||
{ name: 'Inuktitut', code: 'iku' },
|
||||
{ name: 'Irish', code: 'gle' },
|
||||
{ name: 'Italian', code: 'ita' },
|
||||
{ name: 'Japanese', code: 'jpn' },
|
||||
{ name: 'Javanese', code: 'jav' },
|
||||
{ name: 'Kannada', code: 'kan' },
|
||||
{ name: 'Kazakh', code: 'kaz' },
|
||||
{ name: 'Kirghiz; Kyrgyz', code: 'kir' },
|
||||
{ name: 'Korean', code: 'kor' },
|
||||
{ name: 'Kurdish', code: 'kur' },
|
||||
{ name: 'Lao', code: 'lao' },
|
||||
{ name: 'Latin', code: 'lat' },
|
||||
{ name: 'Latvian', code: 'lav' },
|
||||
{ name: 'Lithuanian', code: 'lit' },
|
||||
{ name: 'Macedonian', code: 'mkd' },
|
||||
{ name: 'Malay', code: 'msa' },
|
||||
{ name: 'Malayalam', code: 'mal' },
|
||||
{ name: 'Maltese', code: 'mlt' },
|
||||
{ name: 'Marathi', code: 'mar' },
|
||||
{ name: 'Nepali', code: 'nep' },
|
||||
{ name: 'Norwegian', code: 'nor' },
|
||||
{ name: 'Oriya', code: 'ori' },
|
||||
{ name: 'Panjabi; Punjabi', code: 'pan' },
|
||||
{ name: 'Persian', code: 'fas' },
|
||||
{ name: 'Polish', code: 'pol' },
|
||||
{ name: 'Pushto; Pashto', code: 'pus' },
|
||||
{ name: 'Romanian; Moldavian; Moldovan', code: 'ron' },
|
||||
{ name: 'Russian', code: 'rus' },
|
||||
{ name: 'Sanskrit', code: 'san' },
|
||||
{ name: 'Serbian', code: 'srp' },
|
||||
{ name: 'Serbian - Latin', code: 'srp_latn' },
|
||||
{ name: 'Sinhala; Sinhalese', code: 'sin' },
|
||||
{ name: 'Slovak', code: 'slk' },
|
||||
{ name: 'Slovenian', code: 'slv' },
|
||||
{ name: 'Spanish; Castilian', code: 'spa' },
|
||||
{ name: 'Swahili', code: 'swa' },
|
||||
{ name: 'Swedish', code: 'swe' },
|
||||
{ name: 'Syriac', code: 'syr' },
|
||||
{ name: 'Tagalog', code: 'tgl' },
|
||||
{ name: 'Tajik', code: 'tgk' },
|
||||
{ name: 'Tamil', code: 'tam' },
|
||||
{ name: 'Telugu', code: 'tel' },
|
||||
{ name: 'Thai', code: 'tha' },
|
||||
{ name: 'Tibetan', code: 'bod' },
|
||||
{ name: 'Tigrinya', code: 'tir' },
|
||||
{ name: 'Turkish', code: 'tur' },
|
||||
{ name: 'Uighur; Uyghur', code: 'uig' },
|
||||
{ name: 'Ukrainian', code: 'ukr' },
|
||||
{ name: 'Urdu', code: 'urd' },
|
||||
{ name: 'Uzbek', code: 'uzb' },
|
||||
{ name: 'Uzbek - Cyrillic', code: 'uzb_cyrl' },
|
||||
{ name: 'Vietnamese', code: 'vie' },
|
||||
{ name: 'Welsh', code: 'cym' },
|
||||
{ name: 'Yiddish', code: 'yid' },
|
||||
];
|
||||
const languagesOptions = Array.from(languages.map(l => ({
|
||||
label: l.name,
|
||||
value: l.code,
|
||||
})));
|
||||
|
||||
const language = useQueryParamOrStorage({ name: 'lang', storageName: 'ocr-image:lang', defaultValue: 'eng' });
|
||||
|
||||
const pageSeparator = '\n=============\n';
|
||||
const ocrInProgress = ref(false);
|
||||
const fileInput = ref() as Ref<File>;
|
||||
const ocrText = computedAsync(async () => {
|
||||
try {
|
||||
return (await ocr(fileInput.value, language.value));
|
||||
}
|
||||
catch (e: any) {
|
||||
return e.toString();
|
||||
}
|
||||
});
|
||||
const stats = computed(() => textStatistics(ocrText.value?.replace(new RegExp(pageSeparator, 'g'), ' ') || ''));
|
||||
const pageCount = computed(() => ocrText.value?.split(new RegExp(pageSeparator, 'g')).length || 0);
|
||||
|
||||
async function onUpload(file: File) {
|
||||
if (file) {
|
||||
fileInput.value = file;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPdfFile(file: File) {
|
||||
const arrBuffer = await file.arrayBuffer();
|
||||
const byteArray = new Uint8Array(arrBuffer);
|
||||
return getDocument({ data: byteArray }).promise;
|
||||
}
|
||||
|
||||
async function convertPdfToImage(file: File) {
|
||||
const pdf = await loadPdfFile(file);
|
||||
const container = document.getElementById('container');
|
||||
const images = [];
|
||||
for (let pageNumber = 1; pageNumber <= pdf.numPages; pageNumber++) {
|
||||
const page = await pdf.getPage(pageNumber);
|
||||
const viewport = page.getViewport({ scale: 1.5 });
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.height = viewport.height;
|
||||
canvas.width = viewport.width;
|
||||
container?.appendChild(canvas);
|
||||
await page.render({
|
||||
canvasContext: canvas.getContext('2d') as CanvasRenderingContext2D,
|
||||
viewport,
|
||||
}).promise;
|
||||
images.push(canvas.toDataURL('image/png'));
|
||||
}
|
||||
return images;
|
||||
};
|
||||
|
||||
async function ocr(file: File, language: string) {
|
||||
if (!file) {
|
||||
return '';
|
||||
}
|
||||
ocrInProgress.value = true;
|
||||
const worker = await createWorker();
|
||||
await worker.reinitialize(language);
|
||||
const allTexts = [];
|
||||
if (file.type.match('^image/')) {
|
||||
const ret = await worker.recognize(file);
|
||||
allTexts.push(ret.data.text);
|
||||
}
|
||||
else {
|
||||
pdfJS.GlobalWorkerOptions.workerSrc = pdfJSWorkerURL;
|
||||
|
||||
for (const image of (await convertPdfToImage(file))) {
|
||||
const ret = await worker.recognize(image);
|
||||
allTexts.push(ret.data.text);
|
||||
}
|
||||
}
|
||||
await worker.terminate();
|
||||
ocrInProgress.value = false;
|
||||
return allTexts.join(pageSeparator);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="max-width: 600px;">
|
||||
<c-select
|
||||
v-model:value="language"
|
||||
label="Language"
|
||||
:options="languagesOptions"
|
||||
searchable mb-2
|
||||
/>
|
||||
|
||||
<c-file-upload
|
||||
title="Drag and drop a Image or PDF here, or click to select a file"
|
||||
:paste-image="true"
|
||||
@file-upload="onUpload"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<div id="container" style="display: none;" />
|
||||
|
||||
<div>
|
||||
<h3>OCR</h3>
|
||||
<TextareaCopyable
|
||||
v-if="!ocrInProgress"
|
||||
v-model:value="ocrText"
|
||||
:word-wrap="true"
|
||||
/>
|
||||
<n-spin
|
||||
v-if="ocrInProgress"
|
||||
size="small"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<c-card v-if="!ocrInProgress && stats" title="Statistics">
|
||||
<n-space mt-3>
|
||||
<n-statistic label="Character count" :value="stats.chars" />
|
||||
<n-statistic label="Word count" :value="stats.words" />
|
||||
<n-statistic label="Line count" :value="stats.lines" />
|
||||
<n-statistic label="Pages count" :value="pageCount" />
|
||||
<n-statistic label="Sentences count" :value="stats.sentences" />
|
||||
</n-space>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<n-space>
|
||||
<n-statistic label="Chars (no spaces)" :value="stats.chars_no_spaces" />
|
||||
<n-statistic label="Uppercase chars" :value="stats.chars_upper" />
|
||||
<n-statistic label="Lowercase chars" :value="stats.chars_lower" />
|
||||
<n-statistic label="Digit chars" :value="stats.chars_digits" />
|
||||
<n-statistic label="Punctuations" :value="stats.chars_puncts" />
|
||||
<n-statistic label="Spaces chars" :value="stats.chars_spaces" />
|
||||
<n-statistic label="Word count (no punct)" :value="stats.words_no_puncs" />
|
||||
</n-space>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
::v-deep(.n-upload-trigger) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
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'),
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
<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>
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { getStringSizeInBytes, textStatistics } from './text-statistics.service';
|
||||
import { getStringSizeInBytes } from './text-statistics.service';
|
||||
|
||||
describe('text-statistics', () => {
|
||||
describe('getStringSizeInBytes', () => {
|
||||
@@ -11,114 +11,4 @@ describe('text-statistics', () => {
|
||||
expect(getStringSizeInBytes('aaaaaaaaaa')).toEqual(10);
|
||||
});
|
||||
});
|
||||
|
||||
describe('textStatistics', () => {
|
||||
it('should return text statistics', () => {
|
||||
expect(textStatistics('a')).toEqual({
|
||||
chars: 1,
|
||||
chars_digits: 0,
|
||||
chars_lower: 1,
|
||||
chars_no_spaces: 1,
|
||||
chars_puncts: 0,
|
||||
chars_spaces: 0,
|
||||
chars_upper: 0,
|
||||
lines: 1,
|
||||
sentences: 1,
|
||||
words: 1,
|
||||
words_no_puncs: 1,
|
||||
});
|
||||
expect(textStatistics('A')).toEqual({
|
||||
chars: 1,
|
||||
chars_digits: 0,
|
||||
chars_lower: 0,
|
||||
chars_no_spaces: 1,
|
||||
chars_puncts: 0,
|
||||
chars_spaces: 0,
|
||||
chars_upper: 1,
|
||||
lines: 1,
|
||||
sentences: 1,
|
||||
words: 1,
|
||||
words_no_puncs: 1,
|
||||
});
|
||||
expect(textStatistics('a a')).toEqual({
|
||||
chars: 3,
|
||||
chars_digits: 0,
|
||||
chars_lower: 2,
|
||||
chars_no_spaces: 2,
|
||||
chars_puncts: 0,
|
||||
chars_spaces: 1,
|
||||
chars_upper: 0,
|
||||
lines: 1,
|
||||
sentences: 1,
|
||||
words: 2,
|
||||
words_no_puncs: 2,
|
||||
});
|
||||
expect(textStatistics('A a ; 1')).toEqual({
|
||||
chars: 7,
|
||||
chars_digits: 1,
|
||||
chars_lower: 1,
|
||||
chars_no_spaces: 4,
|
||||
chars_puncts: 1,
|
||||
chars_spaces: 3,
|
||||
chars_upper: 1,
|
||||
lines: 1,
|
||||
sentences: 1,
|
||||
words: 4,
|
||||
words_no_puncs: 3,
|
||||
});
|
||||
expect(textStatistics('Some sentence! Une autre phrase ? « et avec des chiffres 1234 ! »')).toEqual({
|
||||
chars: 65,
|
||||
chars_digits: 4,
|
||||
chars_lower: 41,
|
||||
chars_no_spaces: 52,
|
||||
chars_puncts: 5,
|
||||
chars_spaces: 13,
|
||||
chars_upper: 2,
|
||||
lines: 1,
|
||||
sentences: 3,
|
||||
words: 14,
|
||||
words_no_puncs: 10,
|
||||
});
|
||||
expect(textStatistics(`Some sentence! Une autre phrase ?
|
||||
« et avec des chiffres 1234 ! »`)).toEqual({
|
||||
chars: 72,
|
||||
chars_digits: 4,
|
||||
chars_lower: 41,
|
||||
chars_no_spaces: 52,
|
||||
chars_puncts: 5,
|
||||
chars_spaces: 20,
|
||||
chars_upper: 2,
|
||||
lines: 2,
|
||||
sentences: 3,
|
||||
words: 14,
|
||||
words_no_puncs: 10,
|
||||
});
|
||||
expect(textStatistics('12 35')).toEqual({
|
||||
chars: 5,
|
||||
chars_digits: 4,
|
||||
chars_lower: 0,
|
||||
chars_no_spaces: 4,
|
||||
chars_puncts: 0,
|
||||
chars_spaces: 1,
|
||||
chars_upper: 0,
|
||||
lines: 1,
|
||||
sentences: 1,
|
||||
words: 2,
|
||||
words_no_puncs: 2,
|
||||
});
|
||||
expect(textStatistics(' 1 2 3. Other ')).toEqual({
|
||||
chars: 14,
|
||||
chars_digits: 3,
|
||||
chars_lower: 4,
|
||||
chars_no_spaces: 9,
|
||||
chars_puncts: 1,
|
||||
chars_spaces: 5,
|
||||
chars_upper: 1,
|
||||
lines: 1,
|
||||
sentences: 2,
|
||||
words: 4,
|
||||
words_no_puncs: 4,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,19 +1,3 @@
|
||||
export function getStringSizeInBytes(text: string) {
|
||||
return new TextEncoder().encode(text).buffer.byteLength;
|
||||
}
|
||||
|
||||
export function textStatistics(text: string) {
|
||||
return {
|
||||
chars: text.length,
|
||||
chars_no_spaces: text.replace(/\s+/ug, '').length,
|
||||
chars_upper: text.replace(/[^\p{Lu}]/ug, '').length,
|
||||
chars_lower: text.replace(/[^\p{Ll}]/ug, '').length,
|
||||
chars_digits: text.replace(/\D+/ug, '').length,
|
||||
chars_puncts: text.replace(/[^\p{P}]/ug, '').length,
|
||||
chars_spaces: text.replace(/\S/ug, '').length,
|
||||
words: text.trim().split(/\s+/).length,
|
||||
words_no_puncs: text.replace(/\p{P}/ug, '').trim().split(/\s+/).length,
|
||||
sentences: (`${text} `).split(/\w\s*[\.!\?][\s\p{P}]*\s/u).filter(s => s && s?.length > 0).length,
|
||||
lines: text.split(/\r\n|\r|\n/).length,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Braces } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'XML to JSON',
|
||||
path: '/xml-to-json',
|
||||
description: 'Convert XML to JSON',
|
||||
keywords: ['xml', 'json'],
|
||||
component: () => import('./xml-to-json.vue'),
|
||||
icon: Braces,
|
||||
createdAt: new Date('2024-08-09'),
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import convert from 'xml-js';
|
||||
import { isValidXML } from '../xml-formatter/xml-formatter.service';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import type { UseValidationRule } from '@/composable/validation';
|
||||
|
||||
const defaultValue = '<a x="1.234" y="It\'s"/>';
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => {
|
||||
return JSON.stringify(convert.xml2js(value, { compact: true }), null, 2);
|
||||
}, '');
|
||||
}
|
||||
|
||||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: isValidXML,
|
||||
message: 'Provided XML is not valid.',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your XML content"
|
||||
:input-default="defaultValue"
|
||||
input-placeholder="Paste your XML content here..."
|
||||
output-label="Converted JSON"
|
||||
output-language="json"
|
||||
:transformer="transformer"
|
||||
:input-validation-rules="rules"
|
||||
/>
|
||||
</template>
|
||||
@@ -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
-8
@@ -15,6 +15,7 @@ import { VitePWA } from 'vite-plugin-pwa';
|
||||
import markdown from 'vite-plugin-vue-markdown';
|
||||
import svgLoader from 'vite-svg-loader';
|
||||
import { configDefaults } from 'vitest/config';
|
||||
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
||||
|
||||
const baseUrl = process.env.BASE_URL ?? '/';
|
||||
|
||||
@@ -97,6 +98,7 @@ export default defineConfig({
|
||||
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
|
||||
}),
|
||||
Unocss(),
|
||||
nodePolyfills(),
|
||||
],
|
||||
base: baseUrl,
|
||||
resolve: {
|
||||
@@ -113,12 +115,4 @@ export default defineConfig({
|
||||
build: {
|
||||
target: 'esnext',
|
||||
},
|
||||
optimizeDeps: {
|
||||
include: ['pdfjs-dist'], // optionally specify dependency name
|
||||
esbuildOptions: {
|
||||
supported: {
|
||||
'top-level-await': true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user