mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-22 14:01:42 +03:00
Merge branch 'feat/unicode-search' into chore/all-my-stuffs
# Conflicts: # package.json # pnpm-lock.yaml # src/tools/index.ts # vite.config.ts
This commit is contained in:
commit
d7ad5bdf64
6 files changed
+166
-1
No files matched your search
@@ -89,6 +89,10 @@
|
|||||||
"@types/memorystream": "^0.3.4",
|
"@types/memorystream": "^0.3.4",
|
||||||
"@types/sshpk": "^1.17.4",
|
"@types/sshpk": "^1.17.4",
|
||||||
"@unicode/unicode-15.1.0": "^1.5.2",
|
"@unicode/unicode-15.1.0": "^1.5.2",
|
||||||
|
"@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.11.1",
|
"@vueuse/core": "^10.11.1",
|
||||||
@@ -232,6 +236,7 @@
|
|||||||
"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",
|
||||||
"vite-plugin-node-polyfills": "^0.22.0",
|
"vite-plugin-node-polyfills": "^0.22.0",
|
||||||
"vite-plugin-node-polyfills": "^0.21.0",
|
"vite-plugin-node-polyfills": "^0.21.0",
|
||||||
|
|||||||
Generated
+16
-1
@@ -128,8 +128,11 @@ dependencies:
|
|||||||
'@types/turndown':
|
'@types/turndown':
|
||||||
specifier: ^5.0.4
|
specifier: ^5.0.4
|
||||||
version: 5.0.5
|
version: 5.0.5
|
||||||
|
'@types/utf8':
|
||||||
|
specifier: ^3.0.3
|
||||||
|
version: 3.0.3
|
||||||
'@unicode/unicode-15.1.0':
|
'@unicode/unicode-15.1.0':
|
||||||
specifier: ^1.5.2
|
specifier: ^1.6.0
|
||||||
version: 1.6.0
|
version: 1.6.0
|
||||||
'@vicons/material':
|
'@vicons/material':
|
||||||
specifier: ^0.12.0
|
specifier: ^0.12.0
|
||||||
@@ -506,6 +509,9 @@ dependencies:
|
|||||||
unplugin-auto-import:
|
unplugin-auto-import:
|
||||||
specifier: ^0.16.4
|
specifier: ^0.16.4
|
||||||
version: 0.16.4(@vueuse/core@10.11.1)(rollup@2.79.1)
|
version: 0.16.4(@vueuse/core@10.11.1)(rollup@2.79.1)
|
||||||
|
utf8:
|
||||||
|
specifier: ^3.0.0
|
||||||
|
version: 3.0.0
|
||||||
uuid:
|
uuid:
|
||||||
specifier: ^9.0.0
|
specifier: ^9.0.0
|
||||||
version: 9.0.0
|
version: 9.0.0
|
||||||
@@ -5382,6 +5388,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
|
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@types/utf8@3.0.3:
|
||||||
|
resolution: {integrity: sha512-+lqLGxWZsEe4Z6OrzBI7Ym4SMUTaMS5yOrHZ0/IL0bpIye1Qbs4PpobJL2mLDbftUXlPFZR7fu6d1yM+bHLX1w==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@types/uuid@9.0.0:
|
/@types/uuid@9.0.0:
|
||||||
resolution: {integrity: sha512-kr90f+ERiQtKWMz5rP32ltJ/BtULDI5RVO0uavn1HQUOwjx0R1h0rnDYNL0CepF1zL5bSY6FISAfd9tOdDhU5Q==}
|
resolution: {integrity: sha512-kr90f+ERiQtKWMz5rP32ltJ/BtULDI5RVO0uavn1HQUOwjx0R1h0rnDYNL0CepF1zL5bSY6FISAfd9tOdDhU5Q==}
|
||||||
dev: true
|
dev: true
|
||||||
@@ -10547,6 +10557,7 @@ packages:
|
|||||||
/jsesc@2.5.2:
|
/jsesc@2.5.2:
|
||||||
resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==}
|
resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
/jsesc@3.0.2:
|
/jsesc@3.0.2:
|
||||||
resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==}
|
resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==}
|
||||||
@@ -14615,6 +14626,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-i/I1Omf6lADjVBlwJpQifZOePV15snHny9w04+lc71+3t8PyWuLC/7clyoOSHOBNGXFe2PAGxmTiZ+Z4HWsPyw==}
|
resolution: {integrity: sha512-i/I1Omf6lADjVBlwJpQifZOePV15snHny9w04+lc71+3t8PyWuLC/7clyoOSHOBNGXFe2PAGxmTiZ+Z4HWsPyw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/utf8@3.0.0:
|
||||||
|
resolution: {integrity: sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/utif@2.0.1:
|
/utif@2.0.1:
|
||||||
resolution: {integrity: sha512-Z/S1fNKCicQTf375lIP9G8Sa1H/phcysstNrrSdZKj1f9g58J4NMgb5IgiEZN9/nLMPDwF0W7hdOe9Qq2IYoLg==}
|
resolution: {integrity: sha512-Z/S1fNKCicQTf375lIP9G8Sa1H/phcysstNrrSdZKj1f9g58J4NMgb5IgiEZN9/nLMPDwF0W7hdOe9Qq2IYoLg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import { tool as sslCertConverter } from './ssl-cert-converter';
|
|||||||
import { tool as stacktracePrettier } from './stacktrace-prettier';
|
import { tool as stacktracePrettier } from './stacktrace-prettier';
|
||||||
import { tool as dataTransferRateConverter } from './data-transfer-rate-converter';
|
import { tool as dataTransferRateConverter } from './data-transfer-rate-converter';
|
||||||
import { tool as dataStorageUnitConverter } from './data-storage-unit-converter';
|
import { tool as dataStorageUnitConverter } from './data-storage-unit-converter';
|
||||||
|
import { tool as unicodeSearch } from './unicode-search';
|
||||||
|
|
||||||
import { tool as cssXpathConverter } from './css-xpath-converter';
|
import { tool as cssXpathConverter } from './css-xpath-converter';
|
||||||
import { tool as cssSelectorsMemo } from './css-selectors-memo';
|
import { tool as cssSelectorsMemo } from './css-selectors-memo';
|
||||||
@@ -277,6 +278,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
phpArrayToJson,
|
phpArrayToJson,
|
||||||
maliciousLinksTester,
|
maliciousLinksTester,
|
||||||
torrentToMagnet,
|
torrentToMagnet,
|
||||||
|
unicodeSearch,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user