mirror of
https://github.com/sharevb/it-tools.git
synced 2026-12-05 18:55:11 +03:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fdb31b55b | ||
|
|
67094980c9 | ||
|
|
87984e2081 |
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB |
@@ -1,4 +1,8 @@
|
|||||||

|
<picture>
|
||||||
|
<source srcset="./.github/logo-dark.png" media="(prefers-color-scheme: light)">
|
||||||
|
<source srcset="./.github/logo-white.png" media="(prefers-color-scheme: dark)">
|
||||||
|
<img src="./.github/logo-dark.png" alt="logo">
|
||||||
|
</picture>
|
||||||
|
|
||||||
Useful tools for developer and people working in IT. [Have a look !](https://it-tools.tech).
|
Useful tools for developer and people working in IT. [Have a look !](https://it-tools.tech).
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
@@ -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,6 +130,7 @@ 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']
|
||||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||||
|
|||||||
+6
-2
@@ -35,7 +35,6 @@
|
|||||||
"release": "node ./scripts/release.mjs"
|
"release": "node ./scripts/release.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@huggingface/transformers": "3.0.0-alpha.14",
|
|
||||||
"@it-tools/bip39": "^0.0.4",
|
"@it-tools/bip39": "^0.0.4",
|
||||||
"@it-tools/oggen": "^1.3.0",
|
"@it-tools/oggen": "^1.3.0",
|
||||||
"@sindresorhus/slugify": "^2.2.1",
|
"@sindresorhus/slugify": "^2.2.1",
|
||||||
@@ -43,6 +42,9 @@
|
|||||||
"@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/figlet": "^1.5.8",
|
"@types/figlet": "^1.5.8",
|
||||||
|
"@types/markdown-it": "^13.0.7",
|
||||||
|
"@types/utf8": "^3.0.3",
|
||||||
|
"@unicode/unicode-15.1.0": "^1.6.0",
|
||||||
"@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",
|
||||||
@@ -71,6 +73,7 @@
|
|||||||
"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",
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
@@ -88,10 +91,10 @@
|
|||||||
"ulid": "^2.3.0",
|
"ulid": "^2.3.0",
|
||||||
"unicode-emoji-json": "^0.4.0",
|
"unicode-emoji-json": "^0.4.0",
|
||||||
"unplugin-auto-import": "^0.16.4",
|
"unplugin-auto-import": "^0.16.4",
|
||||||
|
"utf8": "^3.0.0",
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-i18n": "^9.9.1",
|
"vue-i18n": "^9.9.1",
|
||||||
"vue-mathjax-next": "^0.0.6",
|
|
||||||
"vue-router": "^4.1.6",
|
"vue-router": "^4.1.6",
|
||||||
"vue-tsc": "^1.8.1",
|
"vue-tsc": "^1.8.1",
|
||||||
"xml-formatter": "^3.3.2",
|
"xml-formatter": "^3.3.2",
|
||||||
@@ -136,6 +139,7 @@
|
|||||||
"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
+693
-563
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) };
|
||||||
|
|||||||
+5
-7
@@ -2,7 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
|
|||||||
import { tool as base64StringConverter } from './base64-string-converter';
|
import { tool as base64StringConverter } from './base64-string-converter';
|
||||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||||
import { tool as emailNormalizer } from './email-normalizer';
|
import { tool as emailNormalizer } from './email-normalizer';
|
||||||
import { tool as mathOcr } from './math-ocr';
|
import { tool as unicodeSearch } from './unicode-search';
|
||||||
|
|
||||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ 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 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 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,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -134,6 +136,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
httpStatusCodes,
|
httpStatusCodes,
|
||||||
jsonDiff,
|
jsonDiff,
|
||||||
safelinkDecoder,
|
safelinkDecoder,
|
||||||
|
unicodeSearch,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -163,12 +166,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Math',
|
name: 'Math',
|
||||||
components: [
|
components: [mathEvaluator, etaCalculator, percentageCalculator],
|
||||||
mathEvaluator,
|
|
||||||
etaCalculator,
|
|
||||||
percentageCalculator,
|
|
||||||
mathOcr,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Measurement',
|
name: 'Measurement',
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { MathSymbols } from '@vicons/tabler';
|
|
||||||
import { defineTool } from '../tool';
|
|
||||||
|
|
||||||
export const tool = defineTool({
|
|
||||||
name: 'Math OCR',
|
|
||||||
path: '/math-ocr',
|
|
||||||
description: 'Convert Math Formula images to Latex',
|
|
||||||
keywords: ['math', 'ocr', 'latex', 'formula', 'image'],
|
|
||||||
component: () => import('./math-ocr.vue'),
|
|
||||||
icon: MathSymbols,
|
|
||||||
createdAt: new Date('2024-08-15'),
|
|
||||||
});
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import type { Ref } from 'vue';
|
|
||||||
import { pipeline } from '@huggingface/transformers';
|
|
||||||
import VueMathjax from 'vue-mathjax-next';
|
|
||||||
import { useScriptTag } from '@vueuse/core';
|
|
||||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
|
||||||
|
|
||||||
useScriptTag('https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_HTML');
|
|
||||||
|
|
||||||
const ocrInProgress = ref(false);
|
|
||||||
const fileInput = ref() as Ref<File>;
|
|
||||||
const latexResult = computedAsync(async () => {
|
|
||||||
try {
|
|
||||||
return (await ocr(fileInput.value));
|
|
||||||
}
|
|
||||||
catch (e: any) {
|
|
||||||
return e.toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function onUpload(file: File) {
|
|
||||||
if (file) {
|
|
||||||
fileInput.value = file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
type TexifyResult = Array<{ generated_text: string }>;
|
|
||||||
|
|
||||||
async function ocr(file: File) {
|
|
||||||
if (!file) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
ocrInProgress.value = true;
|
|
||||||
|
|
||||||
const imgBase64 = await toBase64(file);
|
|
||||||
|
|
||||||
const pipe = await pipeline('image-to-text', 'Xenova/texify');
|
|
||||||
const out: TexifyResult = (await pipe(imgBase64, { max_new_tokens: 384 })) as TexifyResult;
|
|
||||||
|
|
||||||
ocrInProgress.value = false;
|
|
||||||
return out.map(t => t.generated_text).join('\n');
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div style="max-width: 600px;">
|
|
||||||
<c-alert type="warning" mb-2>
|
|
||||||
NB: processing is done in your browser, so be patient, processing can take a while
|
|
||||||
<br>
|
|
||||||
This tool required internet connection (to access models)
|
|
||||||
</c-alert>
|
|
||||||
|
|
||||||
<c-file-upload
|
|
||||||
title="Drag and drop a Image here, or click to select a file"
|
|
||||||
paste-image
|
|
||||||
@file-upload="onUpload"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<n-divider />
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h3>Latex Result</h3>
|
|
||||||
<TextareaCopyable
|
|
||||||
v-if="!ocrInProgress"
|
|
||||||
v-model:value="latexResult"
|
|
||||||
:word-wrap="true" mb-2
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div style="text-align: center">
|
|
||||||
<VueMathjax
|
|
||||||
v-if="!ocrInProgress"
|
|
||||||
:formula="latexResult"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<n-spin
|
|
||||||
v-if="ocrInProgress"
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="less" scoped>
|
|
||||||
::v-deep(.n-upload-trigger) {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
declare module "vue-mathjax-next" {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { FileText } from '@vicons/tabler';
|
||||||
|
import { defineTool } from '../tool';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: 'Unicode Search',
|
||||||
|
path: '/unicode-search',
|
||||||
|
description: 'Search in Unicode Characters',
|
||||||
|
keywords: ['unicode', 'search'],
|
||||||
|
component: () => import('./unicode-search.vue'),
|
||||||
|
icon: FileText,
|
||||||
|
createdAt: new Date('2024-08-15'),
|
||||||
|
});
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import unicodeNames from '@unicode/unicode-15.1.0/Names/index.js';
|
||||||
|
import unicodeCategories from '@unicode/unicode-15.1.0/General_Category';
|
||||||
|
import utf8 from 'utf8';
|
||||||
|
|
||||||
|
import { useFuzzySearch } from '@/composable/fuzzySearch';
|
||||||
|
import useDebouncedRef from '@/composable/debouncedref';
|
||||||
|
|
||||||
|
function toPaddedHex(num: number) {
|
||||||
|
return num.toString(16).padStart(4, '0').toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
function toUTF8(codePoint: number) {
|
||||||
|
const utf8String = utf8.encode(String.fromCodePoint(codePoint));
|
||||||
|
return [...utf8String].map(c => `\\x${c.codePointAt(0)?.toString(16).toUpperCase()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchQuery = useDebouncedRef('', 500);
|
||||||
|
const parsedSearchQuery = computed(() => {
|
||||||
|
const parsedRegex = /^\s*(?:\&#x(?<hex1>[\da-f]+);|\&#(?<dec>\d+);|(?:U\+|\\u)?\s*(?<hex2>[\da-f]+))\s*$/gi; // NOSONAR
|
||||||
|
const parsedQuery = parsedRegex.exec(searchQuery.value);
|
||||||
|
if (parsedQuery) {
|
||||||
|
if (parsedQuery.groups?.hex1 || parsedQuery.groups?.hex2) {
|
||||||
|
return `=${toPaddedHex(Number.parseInt(parsedQuery.groups.hex1 || parsedQuery.groups.hex2, 16))}`;
|
||||||
|
}
|
||||||
|
if (parsedQuery.groups?.dec) {
|
||||||
|
return `=${toPaddedHex(Number.parseInt(parsedQuery.groups.dec, 10))}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return searchQuery.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
const unicodeSearchData = [...unicodeNames].map(([codePoint, characterName]) => {
|
||||||
|
const hex = toPaddedHex(codePoint);
|
||||||
|
return {
|
||||||
|
codePoint,
|
||||||
|
characterName: `${characterName} (U+${hex})`,
|
||||||
|
hex,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const { searchResult } = useFuzzySearch({
|
||||||
|
search: parsedSearchQuery,
|
||||||
|
data: unicodeSearchData,
|
||||||
|
options: {
|
||||||
|
keys: ['characterName', 'hex'],
|
||||||
|
threshold: 0.2,
|
||||||
|
isCaseSensitive: false,
|
||||||
|
minMatchCharLength: 3,
|
||||||
|
useExtendedSearch: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div mx-auto max-w-2400px important:flex-1>
|
||||||
|
<div flex items-center gap-3>
|
||||||
|
<c-input-text
|
||||||
|
v-model:value="searchQuery"
|
||||||
|
placeholder="Search Unicode by name (e.g. 'zero width') or code point..."
|
||||||
|
mx-auto max-w-600px
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<icon-mdi-search mr-6px color-black op-70 dark:color-white />
|
||||||
|
</template>
|
||||||
|
</c-input-text>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="searchQuery.trim().length > 0">
|
||||||
|
<div
|
||||||
|
v-if="searchResult.length === 0"
|
||||||
|
mt-4
|
||||||
|
text-20px
|
||||||
|
font-bold
|
||||||
|
>
|
||||||
|
No results
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else>
|
||||||
|
<div mt-4 text-20px font-bold>
|
||||||
|
Search result
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<n-table>
|
||||||
|
<thead>
|
||||||
|
<th>UCOD</th>
|
||||||
|
<th>Display/UTF8</th>
|
||||||
|
<th style="width:30%">
|
||||||
|
Category
|
||||||
|
</th>
|
||||||
|
<th>Html</th>
|
||||||
|
<th style="width:30%">
|
||||||
|
Name
|
||||||
|
</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(result, ix) in searchResult" :key="ix">
|
||||||
|
<td>
|
||||||
|
<input-copyable :value="`U+${toPaddedHex(result.codePoint)}`" mb-1 />
|
||||||
|
<!-- //NOSONAR --><n-a :href="`https://unicodeplus.com/U+${toPaddedHex(result.codePoint)}`" target="_blank">
|
||||||
|
> More info
|
||||||
|
</n-a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input-copyable :value="String.fromCodePoint(result.codePoint)" mb-1 />
|
||||||
|
<input-copyable :value="toUTF8(result.codePoint)" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input-copyable :value="unicodeCategories.get(result.codePoint)" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input-copyable :value="`\&\#x${toPaddedHex(result.codePoint)};`" mb-1 />
|
||||||
|
<input-copyable :value="`\&\#${result.codePoint};`" />
|
||||||
|
</td>
|
||||||
|
<td><input-copyable :value="result.characterName" /></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</n-table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
declare module '@unicode/unicode-15.1.0/Names/index.js'{
|
||||||
|
const unicode: HashSet<number, string>;
|
||||||
|
export default unicode;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@unicode/unicode-15.1.0/General_Category'{
|
||||||
|
const unicode: HashSet<number, string>;
|
||||||
|
export default unicode;
|
||||||
|
}
|
||||||
@@ -5,12 +5,10 @@ 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<{
|
||||||
@@ -18,31 +16,11 @@ const emit = defineEmits<{
|
|||||||
(event: 'fileUpload', file: File): void
|
(event: 'fileUpload', file: File): void
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { multiple, pasteImage } = toRefs(props);
|
const { multiple } = 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();
|
||||||
@@ -61,30 +39,7 @@ function handleDrop(event: DragEvent) {
|
|||||||
handleUpload(files);
|
handleUpload(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPasteImage(evt: ClipboardEvent) {
|
function handleUpload(files: FileList | null | undefined) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -94,7 +49,6 @@ async function handleUpload(files: FileList | null | undefined) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await handlePreview(files[0]);
|
|
||||||
emit('fileUpload', files[0]);
|
emit('fileUpload', files[0]);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -106,7 +60,6 @@ async 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"
|
||||||
@@ -120,7 +73,6 @@ async function handleUpload(files: FileList | null | undefined) {
|
|||||||
:accept="accept"
|
:accept="accept"
|
||||||
@change="handleFileInput"
|
@change="handleFileInput"
|
||||||
>
|
>
|
||||||
|
|
||||||
<slot>
|
<slot>
|
||||||
<span op-70>
|
<span op-70>
|
||||||
{{ title }}
|
{{ title }}
|
||||||
@@ -138,22 +90,6 @@ async 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,6 +15,7 @@ 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 ?? '/';
|
||||||
|
|
||||||
@@ -97,6 +98,7 @@ 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