Compare commits

..
Author SHA1 Message Date
ShareVB 8371d208b1 fix: sonar 2024-12-15 20:59:48 +01:00
ShareVB 3f7745de2c Merge remote-tracking branch 'origin/main' into feat/md-toc-generator 2024-12-15 20:45:15 +01:00
ShareVB cb37d5837f fix: codeql alerts 2024-12-15 20:38:44 +01:00
ShareVB 786991433a feat: better UI 2024-07-14 22:27:05 +02:00
ShareVB d92a285cb2 fix: lock file 2024-07-12 23:26:26 +02:00
sharevb 4c014a63e1 Merge branch 'main' into feat/md-toc-generator 2024-07-12 23:14:59 +02:00
ShareVB dbfe5113b0 chore: fix strange corepack message
Fix corepack claiming strange thing : UsageError: This project is configured to use yarn because /home/runner/work/it-tools/it-tools/package.json has a "packageManager" field
2024-07-12 23:12:16 +02:00
sharevb e32d38c057 feat(new tool): Markdown TOC Generator
Fix #573
2024-07-12 23:11:51 +02:00
22 changed files with 2620 additions and 2701 deletions

No files matched your search

+1 -4
View File
@@ -286,9 +286,6 @@
"watchTriggerable": true,
"watchWithFilter": true,
"whenever": true,
"toValue": true,
"injectLocal": true,
"provideLocal": true,
"useClipboardItems": true
"toValue": true
}
}
-9
View File
@@ -36,7 +36,6 @@ declare global {
const h: typeof import('vue')['h']
const ignorableWatch: typeof import('@vueuse/core')['ignorableWatch']
const inject: typeof import('vue')['inject']
const injectLocal: typeof import('@vueuse/core')['injectLocal']
const isDefined: typeof import('@vueuse/core')['isDefined']
const isProxy: typeof import('vue')['isProxy']
const isReactive: typeof import('vue')['isReactive']
@@ -66,7 +65,6 @@ declare global {
const onUpdated: typeof import('vue')['onUpdated']
const pausableWatch: typeof import('@vueuse/core')['pausableWatch']
const provide: typeof import('vue')['provide']
const provideLocal: typeof import('@vueuse/core')['provideLocal']
const reactify: typeof import('@vueuse/core')['reactify']
const reactifyObject: typeof import('@vueuse/core')['reactifyObject']
const reactive: typeof import('vue')['reactive']
@@ -130,7 +128,6 @@ declare global {
const useBrowserLocation: typeof import('@vueuse/core')['useBrowserLocation']
const useCached: typeof import('@vueuse/core')['useCached']
const useClipboard: typeof import('@vueuse/core')['useClipboard']
const useClipboardItems: typeof import('@vueuse/core')['useClipboardItems']
const useCloned: typeof import('@vueuse/core')['useCloned']
const useColorMode: typeof import('@vueuse/core')['useColorMode']
const useConfirmDialog: typeof import('@vueuse/core')['useConfirmDialog']
@@ -329,7 +326,6 @@ declare module 'vue' {
readonly h: UnwrapRef<typeof import('vue')['h']>
readonly ignorableWatch: UnwrapRef<typeof import('@vueuse/core')['ignorableWatch']>
readonly inject: UnwrapRef<typeof import('vue')['inject']>
readonly injectLocal: UnwrapRef<typeof import('@vueuse/core')['injectLocal']>
readonly isDefined: UnwrapRef<typeof import('@vueuse/core')['isDefined']>
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
@@ -359,7 +355,6 @@ declare module 'vue' {
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly pausableWatch: UnwrapRef<typeof import('@vueuse/core')['pausableWatch']>
readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly provideLocal: UnwrapRef<typeof import('@vueuse/core')['provideLocal']>
readonly reactify: UnwrapRef<typeof import('@vueuse/core')['reactify']>
readonly reactifyObject: UnwrapRef<typeof import('@vueuse/core')['reactifyObject']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
@@ -423,7 +418,6 @@ declare module 'vue' {
readonly useBrowserLocation: UnwrapRef<typeof import('@vueuse/core')['useBrowserLocation']>
readonly useCached: UnwrapRef<typeof import('@vueuse/core')['useCached']>
readonly useClipboard: UnwrapRef<typeof import('@vueuse/core')['useClipboard']>
readonly useClipboardItems: UnwrapRef<typeof import('@vueuse/core')['useClipboardItems']>
readonly useCloned: UnwrapRef<typeof import('@vueuse/core')['useCloned']>
readonly useColorMode: UnwrapRef<typeof import('@vueuse/core')['useColorMode']>
readonly useConfirmDialog: UnwrapRef<typeof import('@vueuse/core')['useConfirmDialog']>
@@ -616,7 +610,6 @@ declare module '@vue/runtime-core' {
readonly h: UnwrapRef<typeof import('vue')['h']>
readonly ignorableWatch: UnwrapRef<typeof import('@vueuse/core')['ignorableWatch']>
readonly inject: UnwrapRef<typeof import('vue')['inject']>
readonly injectLocal: UnwrapRef<typeof import('@vueuse/core')['injectLocal']>
readonly isDefined: UnwrapRef<typeof import('@vueuse/core')['isDefined']>
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
@@ -646,7 +639,6 @@ declare module '@vue/runtime-core' {
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
readonly pausableWatch: UnwrapRef<typeof import('@vueuse/core')['pausableWatch']>
readonly provide: UnwrapRef<typeof import('vue')['provide']>
readonly provideLocal: UnwrapRef<typeof import('@vueuse/core')['provideLocal']>
readonly reactify: UnwrapRef<typeof import('@vueuse/core')['reactify']>
readonly reactifyObject: UnwrapRef<typeof import('@vueuse/core')['reactifyObject']>
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
@@ -710,7 +702,6 @@ declare module '@vue/runtime-core' {
readonly useBrowserLocation: UnwrapRef<typeof import('@vueuse/core')['useBrowserLocation']>
readonly useCached: UnwrapRef<typeof import('@vueuse/core')['useCached']>
readonly useClipboard: UnwrapRef<typeof import('@vueuse/core')['useClipboard']>
readonly useClipboardItems: UnwrapRef<typeof import('@vueuse/core')['useClipboardItems']>
readonly useCloned: UnwrapRef<typeof import('@vueuse/core')['useCloned']>
readonly useColorMode: UnwrapRef<typeof import('@vueuse/core')['useColorMode']>
readonly useConfirmDialog: UnwrapRef<typeof import('@vueuse/core')['useConfirmDialog']>
+10 -4
View File
@@ -114,7 +114,6 @@ declare module '@vue/runtime-core' {
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']
JwtGenerator: typeof import('./src/tools/jwt-generator/jwt-generator.vue')['default']
JwtParser: typeof import('./src/tools/jwt-parser/jwt-parser.vue')['default']
KeycodeInfo: typeof import('./src/tools/keycode-info/keycode-info.vue')['default']
ListConverter: typeof import('./src/tools/list-converter/list-converter.vue')['default']
@@ -122,7 +121,7 @@ declare module '@vue/runtime-core' {
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']
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']
MarkdownTocGenerator: typeof import('./src/tools/markdown-toc-generator/markdown-toc-generator.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']
MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default']
@@ -130,24 +129,31 @@ declare module '@vue/runtime-core' {
MenuLayout: typeof import('./src/components/MenuLayout.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']
NAlert: typeof import('naive-ui')['NAlert']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NColorPicker: typeof import('naive-ui')['NColorPicker']
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']
NGi: typeof import('naive-ui')['NGi']
NGrid: typeof import('naive-ui')['NGrid']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NImage: typeof import('naive-ui')['NImage']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLabel: typeof import('naive-ui')['NLabel']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NP: typeof import('naive-ui')['NP']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NTable: typeof import('naive-ui')['NTable']
NSpace: typeof import('naive-ui')['NSpace']
NSpin: typeof import('naive-ui')['NSpin']
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']
+2 -1
View File
@@ -70,7 +70,6 @@
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"jose": "^5.9.6",
"js-base64": "^3.7.6",
"json5": "^2.2.3",
"jwt-decode": "^3.1.2",
@@ -89,6 +88,7 @@
"pinia": "^2.0.34",
"plausible-tracker": "^0.3.8",
"qrcode": "^1.5.1",
"sanitize-html": "^2.13.1",
"randexp": "^0.5.3",
"sql-formatter": "^13.0.0",
"ua-parser-js": "^1.0.35",
@@ -123,6 +123,7 @@
"@types/node": "^18.15.11",
"@types/node-forge": "^1.3.2",
"@types/qrcode": "^1.5.0",
"@types/sanitize-html": "^2.13.0",
"@types/ua-parser-js": "^0.7.36",
"@types/uuid": "^9.0.0",
"@unocss/eslint-config": "^0.57.0",
+1868 -2331
View File
File diff suppressed because it is too large. Load diff
+4 -38
View File
@@ -7,15 +7,8 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
import xmlHljs from 'highlight.js/lib/languages/xml';
import yamlHljs from 'highlight.js/lib/languages/yaml';
import iniHljs from 'highlight.js/lib/languages/ini';
import bashHljs from 'highlight.js/lib/languages/bash';
import markdownHljs from 'highlight.js/lib/languages/markdown';
import jsHljs from 'highlight.js/lib/languages/javascript';
import cssHljs from 'highlight.js/lib/languages/css';
import goHljs from 'highlight.js/lib/languages/go';
import csharpHljs from 'highlight.js/lib/languages/csharp';
import { Base64 } from 'js-base64';
import { useCopy } from '@/composable/copy';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
const props = withDefaults(
defineProps<{
@@ -24,17 +17,12 @@ const props = withDefaults(
language?: string
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
copyMessage?: string
wordWrap?: boolean
downloadFileName?: string
downloadButtonText?: string
}>(),
{
followHeightOf: null,
language: 'txt',
copyPlacement: 'top-right',
copyMessage: 'Copy to clipboard',
downloadFileName: '',
downloadButtonText: 'Download',
},
);
hljs.registerLanguage('sql', sqlHljs);
@@ -43,25 +31,13 @@ hljs.registerLanguage('html', xmlHljs);
hljs.registerLanguage('xml', xmlHljs);
hljs.registerLanguage('yaml', yamlHljs);
hljs.registerLanguage('toml', iniHljs);
hljs.registerLanguage('bash', bashHljs);
hljs.registerLanguage('markdown', markdownHljs);
hljs.registerLanguage('css', cssHljs);
hljs.registerLanguage('javascript', jsHljs);
hljs.registerLanguage('go', goHljs);
hljs.registerLanguage('csharp', csharpHljs);
const { value, language, followHeightOf, copyPlacement, copyMessage, downloadFileName, downloadButtonText } = toRefs(props);
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.value);
const valueBase64 = computed(() => Base64.encode(value.value));
const { download } = useDownloadFileFromBase64(
{
source: valueBase64,
filename: downloadFileName,
});
</script>
<template>
@@ -73,16 +49,11 @@ const { download } = useDownloadFileFromBase64(
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
>
<n-config-provider :hljs="hljs">
<n-code :code="value" :language="language" :word-wrap="wordWrap" :trim="false" data-test-id="area-content" />
<n-code :code="value" :language="language" :trim="false" data-test-id="area-content" />
</n-config-provider>
</n-scrollbar>
<div
v-if="value && copyPlacement !== 'none'"
absolute right-10px
:top-10px="copyPlacement === 'top-right' ? '' : 'no'"
:bottom-10px="copyPlacement === 'bottom-right' ? '' : 'no'"
>
<c-tooltip v-if="value && copyPlacement !== 'outside'" :tooltip="tooltipText" position="left">
<div absolute right-10px top-10px>
<c-tooltip v-if="value" :tooltip="tooltipText" position="left">
<c-button circle important:h-10 important:w-10 @click="copy()">
<n-icon size="22" :component="Copy" />
</c-button>
@@ -94,11 +65,6 @@ const { download } = useDownloadFileFromBase64(
{{ tooltipText }}
</c-button>
</div>
<div v-if="downloadFileName !== '' && value !== ''" mt-5 flex justify-center>
<c-button secondary @click="download">
{{ downloadButtonText }}
</c-button>
</div>
</div>
</template>
+14 -15
View File
@@ -1,7 +1,6 @@
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
import type { MaybeRef, Ref } from 'vue';
import type { Ref } from 'vue';
import _ from 'lodash';
import { get } from '@vueuse/core';
export {
getMimeTypeFromBase64,
@@ -76,11 +75,21 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
}
function useDownloadFileFromBase64(
{ source, filename, extension }:
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
{ source, filename, extension, fileMimeType }:
{ source: Ref<string>; filename?: string; extension?: string; fileMimeType?: string }) {
return {
download() {
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
downloadFromBase64({ sourceValue: source.value, filename, extension, fileMimeType });
},
};
}
function useDownloadFileFromBase64Refs(
{ source, filename, extension }:
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
return {
download() {
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
},
};
}
@@ -107,13 +116,3 @@ function previewImageFromBase64(base64String: string): HTMLImageElement {
return img;
}
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 });
},
};
}
@@ -128,7 +128,7 @@ function activateOption(option: PaletteOption) {
<c-input-text ref="inputRef" v-model:value="searchPrompt" raw-text placeholder="Type to search a tool or a command..." autofocus clearable />
<div v-for="(options, category) in filteredSearchResult" :key="category">
<div ml-3 mt-3 text-sm text-primary font-bold op-60>
<div ml-3 mt-3 text-sm font-bold text-primary op-60>
{{ category }}
</div>
<command-palette-option v-for="option in options" :key="option.name" :option="option" :selected="selectedOptionIndex === getOptionIndex(option)" @activated="activateOption" />
+2 -2
View File
@@ -1,8 +1,8 @@
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 markdownTocGenerator } from './markdown-toc-generator';
import { tool as emailNormalizer } from './email-normalizer';
import { tool as jwtGenerator } from './jwt-generator';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
@@ -114,6 +114,7 @@ export const toolsByCategory: ToolCategory[] = [
listConverter,
tomlToJson,
tomlToYaml,
markdownTocGenerator,
xmlToJson,
jsonToXml,
markdownToHtml,
@@ -131,7 +132,6 @@ export const toolsByCategory: ToolCategory[] = [
otpCodeGeneratorAndValidator,
mimeTypes,
jwtParser,
jwtGenerator,
keycodeInfo,
slugifyString,
htmlWysiwygEditor,
-29
View File
@@ -1,29 +0,0 @@
import { Key } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'JWT Generator',
path: '/jwt-generator',
description: 'JWT Token generator and editor',
keywords: [
'jwt',
'generator',
'editor',
'encode',
'typ',
'alg',
'iss',
'sub',
'aud',
'exp',
'nbf',
'iat',
'jti',
'json',
'web',
'token',
],
component: () => import('./jwt-generator.vue'),
icon: Key,
createdAt: new Date('2024-08-15'),
});
@@ -1,15 +0,0 @@
export const jwsAlgorithms = [
{ alg: 'HS256', keyDesc: '256 bit (32 byte) secret', key: 'secret', verify: 'HMAC-SHA256' },
{ alg: 'HS384', keyDesc: '384 bit (48 byte) secret', key: 'secret', verify: 'HMAC-SHA384' },
{ alg: 'HS512', keyDesc: '512 bit (64 byte) secret', key: 'secret', verify: 'HMAC-SHA512' },
{ alg: 'ES256', keyDesc: 'NIST P-256 elliptic curve key', key: 'keyspair', verify: 'ECDSA-SHA256' },
{ alg: 'ES256K', keyDesc: 'secp256k1 elliptic curve key', key: 'keyspair', verify: 'ECDSA-SHA256(secp256k1)' },
{ alg: 'ES384', keyDesc: 'NIST P-384 elliptic curve key', key: 'keyspair', verify: 'ECDSA-SHA384' },
{ alg: 'ES512', keyDesc: 'NIST P-521 elliptic curve key', key: 'keyspair', verify: 'ECDSA-SHA512' },
{ alg: 'PS256', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-PSS-SHA256' },
{ alg: 'PS384', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-PSS-SHA384' },
{ alg: 'PS512', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-PSS-SHA512' },
{ alg: 'RS256', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-SHA256' },
{ alg: 'RS384', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-SHA384' },
{ alg: 'RS512', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-SHA512' },
];
-187
View File
@@ -1,187 +0,0 @@
<script setup lang="ts">
import * as jose from 'jose';
import { type KeyLike } from 'jose';
import JSON5 from 'json5';
import { jwsAlgorithms } from './jwt-generator.constants';
import { useValidation } from '@/composable/validation';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const payload = ref(`{
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
}`);
const alg = useQueryParamOrStorage({ name: 'alg', storageName: 'jwt-gen:alg', defaultValue: 'HS512' });
const algInfo = computed(() => jwsAlgorithms.find(a => a.alg === alg.value) || { alg: 'UNK', keyDesc: '', key: 'secret', verify: '' });
const isSecret = computed(() => algInfo.value.key === 'secret');
const secret = ref('');
const publicKeyPEM = ref('');
const publicKeyJWK = ref('');
const privateKeyJWK = ref('');
const privateKeyPEM = ref('');
watch(publicKeyPEM, async (newValue) => {
try {
publicKeyJWK.value = JSON.stringify(await jose.exportJWK(await jose.importSPKI(newValue, alg.value, { extractable: true })), null, 2);
}
catch {
}
}, { immediate: true });
watch(privateKeyPEM, async (newValue) => {
try {
privateKeyJWK.value = JSON.stringify(await jose.exportJWK(await jose.importPKCS8(newValue, alg.value, { extractable: true })), null, 2);
}
catch {
}
}, { immediate: true });
watch(publicKeyJWK, async (newValue) => {
try {
publicKeyPEM.value = await jose.exportSPKI(await jose.importJWK({ ...JSON.parse(newValue), ...{ ext: true } }, alg.value) as KeyLike);
}
catch {
}
}, { immediate: true });
watch(privateKeyJWK, async (newValue) => {
try {
privateKeyPEM.value = await jose.exportPKCS8(await jose.importJWK({ ...JSON.parse(newValue), ...{ ext: true } }, alg.value) as KeyLike);
}
catch {
}
}, { immediate: true });
watchEffect(async () => {
if (isSecret.value) {
secret.value = 'your-secret';
privateKeyJWK.value = '';
publicKeyJWK.value = '';
privateKeyPEM.value = '';
publicKeyPEM.value = '';
}
else {
const { publicKey, privateKey } = await jose.generateKeyPair(alg.value, { extractable: true });
privateKeyJWK.value = JSON.stringify(await jose.exportJWK(privateKey), null, 2);
publicKeyJWK.value = JSON.stringify(await jose.exportJWK(publicKey), null, 2);
privateKeyPEM.value = await jose.exportPKCS8(privateKey);
publicKeyPEM.value = await jose.exportSPKI(publicKey);
}
});
const header = computed(() => JSON.stringify({ alg: alg.value, typ: 'JWT' }, null, 2));
const encodedJWT = computedAsync(async () => {
const isSecretValue = isSecret.value;
const secretValue = secret.value;
const privateKeyValue = privateKeyJWK.value;
const algValue = alg.value;
const payloadValue = payload.value;
try {
let privateKeyOrSecret;
if (isSecretValue) {
privateKeyOrSecret = new TextEncoder().encode(secretValue);
}
else {
privateKeyOrSecret = await jose.importJWK(JSON.parse(privateKeyValue), algValue);
}
return {
token: await (new jose.SignJWT(JSON5.parse(payloadValue))
.setProtectedHeader({ alg: algValue })
.sign(privateKeyOrSecret)),
error: '',
};
}
catch (e: any) {
return { error: e.toString(), token: '' };
}
});
const jsonInputValidation = useValidation({
source: payload,
rules: [
{
message: 'Invalid JSON string',
validator: value => JSON5.parse(value),
},
],
});
</script>
<template>
<div>
<c-select
v-model:value="alg"
:options="jwsAlgorithms.map(a => ({ value: a.alg, label: `${a.alg}: ${a.verify}` }))"
placeholder="Algorithms"
mb-2
/>
<n-form-item label="Description:" label-placement="left" mb-2>
{{ algInfo.alg }}: {{ algInfo.keyDesc }} (verify with {{ algInfo.verify }})
</n-form-item>
<c-card title="Token Content" mb-2>
<n-form-item label="Header:">
<textarea-copyable :value="header" language="json" />
</n-form-item>
<c-input-text
v-model:value="payload"
label="Payload:"
multiline
rows="5"
autosize
placeholder="JSON payload"
:validation="jsonInputValidation"
/>
</c-card>
<c-card :title="isSecret ? 'Token Secret' : 'Token Keys'" mb-2>
<c-input-text v-if="isSecret" v-model:value="secret" />
<div v-if="!isSecret">
<n-form-item label="Public Key (PEM):">
<c-input-text
v-model:value="publicKeyPEM"
multiline
rows="5"
autosize
/>
</n-form-item>
<n-form-item label="Private Key (PEM):">
<c-input-text
v-model:value="privateKeyPEM"
multiline
rows="5"
autosize
/>
</n-form-item>
<n-divider />
<n-form-item label="Public Key (JWK):">
<c-input-text
v-model:value="publicKeyJWK"
multiline
rows="5"
autosize
/>
</n-form-item>
<n-form-item label="Private Key (JWK):">
<c-input-text
v-model:value="privateKeyJWK"
multiline
rows="5"
autosize
/>
</n-form-item>
</div>
</c-card>
<c-card v-if="encodedJWT" title="Generated JWT Token:" mb-2>
<textarea-copyable v-if="encodedJWT.token" :value="encodedJWT.token" word-wrap />
<c-alert v-if="encodedJWT.error">
{{ encodedJWT.error }}
</c-alert>
</c-card>
</div>
</template>
+3 -2
View File
@@ -1,10 +1,11 @@
import { Key } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: 'JWT parser',
name: translate('tools.jwt-parser.title'),
path: '/jwt-parser',
description: 'Parse and decode your JSON Web Token (jwt) and display its content.',
description: translate('tools.jwt-parser.description'),
keywords: [
'jwt',
'parser',
+2 -6
View File
@@ -2,11 +2,7 @@ import jwtDecode, { type JwtHeader, type JwtPayload } from 'jwt-decode';
import _ from 'lodash';
import { ALGORITHM_DESCRIPTIONS, CLAIM_DESCRIPTIONS } from './jwt-parser.constants';
export { decodeJwt, getJwtAlgorithm };
function getJwtAlgorithm({ jwt }: { jwt: string }) {
return jwtDecode<JwtHeader>(jwt, { header: true }).alg;
}
export { decodeJwt };
function decodeJwt({ jwt }: { jwt: string }) {
const rawHeader = jwtDecode<JwtHeader>(jwt, { header: true });
@@ -23,7 +19,7 @@ function decodeJwt({ jwt }: { jwt: string }) {
function parseClaims({ claim, value }: { claim: string; value: unknown }) {
const claimDescription = CLAIM_DESCRIPTIONS[claim];
const formattedValue = _.isPlainObject(value) ? JSON.stringify(value, null, 3) : _.toString(value);
const formattedValue = _.isPlainObject(value) || _.isArray(value) ? JSON.stringify(value, null, 3) : _.toString(value);
const friendlyValue = getFriendlyValue({ claim, value });
return {
+3 -55
View File
@@ -1,7 +1,5 @@
<script setup lang="ts">
import * as jose from 'jose';
import JSON5 from 'json5';
import { decodeJwt, getJwtAlgorithm } from './jwt-parser.service';
import { decodeJwt } from './jwt-parser.service';
import { useValidation } from '@/composable/validation';
import { isNotThrowing } from '@/utils/boolean';
import { withDefaultOnError } from '@/utils/defaults';
@@ -28,41 +26,6 @@ const validation = useValidation({
},
],
});
const secretOrPublicKey = ref('');
const signatureVerification = computedAsync(async () => {
const secretOrPublicKeyValue = secretOrPublicKey.value?.trim();
if (!secretOrPublicKeyValue) {
return { error: 'No secret or key provided' };
}
const jwt = rawJwt.value?.trim();
if (!jwt) {
return { error: 'No JWT token provided' };
}
try {
const alg = getJwtAlgorithm({ jwt }) || 'unk';
if (secretOrPublicKeyValue.startsWith('{')) {
const jwk = JSON5.parse(secretOrPublicKeyValue);
const publicKey = await jose.importJWK(jwk, alg);
await jose.jwtVerify(jwt, publicKey);
}
else if (secretOrPublicKeyValue.includes('-----BEGIN PUBLIC KEY-----')) {
const publicKey = await jose.importSPKI(secretOrPublicKeyValue, alg);
await jose.jwtVerify(jwt, publicKey);
}
else {
const secret = new TextEncoder().encode(secretOrPublicKeyValue);
await jose.jwtVerify(jwt, secret);
}
return { error: '' };
}
catch (e: any) {
return { error: `Key or secret or verification error: ${e.toString()}` };
}
});
</script>
<template>
@@ -76,7 +39,7 @@ const signatureVerification = computedAsync(async () => {
{{ section.title }}
</th>
<tr v-for="{ claim, claimDescription, friendlyValue, value } in decodedJWT[section.key]" :key="claim + value">
<td class="claims">
<td class="claims" style="vertical-align: top;">
<span font-bold>
{{ claim }}
</span>
@@ -84,7 +47,7 @@ const signatureVerification = computedAsync(async () => {
({{ claimDescription }})
</span>
</td>
<td>
<td style="word-wrap: break-word;word-break: break-all;">
<span>{{ value }}</span>
<span v-if="friendlyValue" ml-2 op-70>
({{ friendlyValue }})
@@ -94,21 +57,6 @@ const signatureVerification = computedAsync(async () => {
</template>
</tbody>
</n-table>
<c-card title="Signature Validation">
<c-input-text
v-model:value="secretOrPublicKey" label="Secret or Public Key (SPKI or JWK)"
placeholder="Put your secret or Public key here..." rows="5" multiline raw-text autofocus mb-3
/>
<c-alert v-if="signatureVerification?.error">
{{ signatureVerification.error }}
</c-alert>
<n-alert v-if="!signatureVerification?.error" type="success">
Signature verified
</n-alert>
</c-card>
</c-card>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { Table } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Markdown toc generator',
path: '/markdown-toc-generator',
description: 'Generate a TOC from a markdown file/content',
keywords: ['markdown', 'md', 'toc', 'generator'],
component: () => import('./markdown-toc-generator.vue'),
icon: Table,
createdAt: new Date('2024-05-11'),
});
@@ -0,0 +1,6 @@
declare module 'markdown-contents'{
declare class MarkdownContents {
markdown(): string;
}
export default function Create(markdown: string):MarkdownContents;
}
@@ -0,0 +1,380 @@
import { describe, expect, it } from 'vitest';
import {
getTocMarkdown,
} from './markdown-toc-generator.service';
describe('markdown-toc-generator', () => {
it('Generate TOC correctly', async () => {
expect(getTocMarkdown({
markdown: '',
})).to.equal('');
const sourceMarkdown = `# Some main title
[TOC]
## First Title
Some text
## Second Spaced Title
Some text
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
### Title with code \`var\`
Some text
## Last Title`;
expect(getTocMarkdown({
markdown: sourceMarkdown,
anchorPrefix: 'h-',
})).to.equal(`# Some main title
<!-- TOC START -->
- [First Title](#h-first-title)
- [Second Spaced Title](#h-second-spaced-title)
* [Title with Link TOC](#h-title-with-link-toc)
* [Title with code \`var\`](#h-title-with-code-var)
- [Last Title](#h-last-title)
<!-- TOC END -->
<!-- TOC ANCHOR --><a name="first-title"></a>
## First Title
Some text
<!-- TOC ANCHOR --><a name="second-spaced-title"></a>
## Second Spaced Title
Some text
<!-- TOC ANCHOR --><a name="title-with-link-toc"></a>
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
<!-- TOC ANCHOR --><a name="title-with-code-var"></a>
### Title with code \`var\`
Some text
<!-- TOC ANCHOR --><a name="last-title"></a>
## Last Title`);
expect(getTocMarkdown({
markdown: sourceMarkdown,
maxLevel: 2,
})).to.equal(`# Some main title
<!-- TOC START -->
- [First Title](#first-title)
- [Second Spaced Title](#second-spaced-title)
- [Last Title](#last-title)
<!-- TOC END -->
<!-- TOC ANCHOR --><a name="first-title"></a>
## First Title
Some text
<!-- TOC ANCHOR --><a name="second-spaced-title"></a>
## Second Spaced Title
Some text
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
### Title with code \`var\`
Some text
<!-- TOC ANCHOR --><a name="last-title"></a>
## Last Title`);
expect(getTocMarkdown({
markdown: sourceMarkdown,
commentStyle: 'liquid',
})).to.equal(`# Some main title
{%- # TOC START -%}
- [First Title](#first-title)
- [Second Spaced Title](#second-spaced-title)
* [Title with Link TOC](#title-with-link-toc)
* [Title with code \`var\`](#title-with-code-var)
- [Last Title](#last-title)
{%- # TOC END -%}
{%- # TOC ANCHOR -%}<a name="first-title"></a>
## First Title
Some text
{%- # TOC ANCHOR -%}<a name="second-spaced-title"></a>
## Second Spaced Title
Some text
{%- # TOC ANCHOR -%}<a name="title-with-link-toc"></a>
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
{%- # TOC ANCHOR -%}<a name="title-with-code-var"></a>
### Title with code \`var\`
Some text
{%- # TOC ANCHOR -%}<a name="last-title"></a>
## Last Title`);
expect(getTocMarkdown({
markdown: sourceMarkdown,
generateAnchors: false,
})).to.equal(`# Some main title
<!-- TOC START -->
- [First Title](#first-title)
- [Second Spaced Title](#second-spaced-title)
* [Title with Link TOC](#title-with-link-toc)
* [Title with code \`var\`](#title-with-code-var)
- [Last Title](#last-title)
<!-- TOC END -->
## First Title
Some text
## Second Spaced Title
Some text
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
### Title with code \`var\`
Some text
## Last Title`);
expect(getTocMarkdown({
markdown: sourceMarkdown,
indentSpaces: 4,
indentChars: '-',
concatSpaces: false,
})).to.equal(`# Some main title
<!-- TOC START -->
- [First Title](#first-title)
- [Second Spaced Title](#second--spaced--title)
- [Title with Link TOC](#title-with-link-toc)
- [Title with code \`var\`](#title-with-code-var)
- [Last Title](#last-title)
<!-- TOC END -->
<!-- TOC ANCHOR --><a name="first-title"></a>
## First Title
Some text
<!-- TOC ANCHOR --><a name="second--spaced--title"></a>
## Second Spaced Title
Some text
<!-- TOC ANCHOR --><a name="title-with-link-toc"></a>
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
<!-- TOC ANCHOR --><a name="title-with-code-var"></a>
### Title with code \`var\`
Some text
<!-- TOC ANCHOR --><a name="last-title"></a>
## Last Title`);
});
it('Regenerate TOC correctly', async () => {
expect(getTocMarkdown({
markdown: `# Some main title
<!-- TOC START -->
- [First Title](#first-title)
- [Second Spaced Title](#second--spaced--title)
- [Title with Link TOC](#title-with-link-toc)
- [Title with code \`var\`](#title-with-code-var)
- [Last Title](#last-title)
<!-- TOC END -->
<!-- TOC ANCHOR --><a name="first-title"></a>
## First Title
Some text
<!-- TOC ANCHOR --><a name="second--spaced--title"></a>
## Second Spaced Title
Some text
<!-- TOC ANCHOR --><a name="title-with-link-toc"></a>
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
<!-- TOC ANCHOR --><a name="title-with-code-var"></a>
### Title with code \`var\`
Some text
<!-- TOC ANCHOR --><a name="last-title"></a>
## Last Title`,
anchorPrefix: 'h-',
})).to.equal(`# Some main title
<!-- TOC START -->
- [First Title](#h-first-title)
- [Second Spaced Title](#h-second-spaced-title)
* [Title with Link TOC](#h-title-with-link-toc)
* [Title with code \`var\`](#h-title-with-code-var)
- [Last Title](#h-last-title)
<!-- TOC END -->
<!-- TOC ANCHOR --><a name="first-title"></a>
## First Title
Some text
<!-- TOC ANCHOR --><a name="second-spaced-title"></a>
## Second Spaced Title
Some text
<!-- TOC ANCHOR --><a name="title-with-link-toc"></a>
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
<!-- TOC ANCHOR --><a name="title-with-code-var"></a>
### Title with code \`var\`
Some text
<!-- TOC ANCHOR --><a name="last-title"></a>
## Last Title`);
});
it('Generate distinct TOC ids', async () => {
expect(getTocMarkdown({
markdown: `# Some main title
[TOC]
## Same Title 1
Some text
## Same Title 1
Some text
### Same title 1
Some text`,
anchorPrefix: 'h-',
})).to.equal(`# Some main title
<!-- TOC START -->
- [Same Title 1](#h-same-title-1)
- [Same Title 1](#h-same-title-1-1)
* [Same title 1](#h-same-title-1-2)
<!-- TOC END -->
<!-- TOC ANCHOR --><a name="same-title-1"></a>
## Same Title 1
Some text
<!-- TOC ANCHOR --><a name="same-title-1-1"></a>
## Same Title 1
Some text
<!-- TOC ANCHOR --><a name="same-title-1-2"></a>
### Same title 1
Some text`);
});
it('Generate ids for non latin', async () => {
expect(getTocMarkdown({
markdown: `# Some main title
[TOC]
## Привет non-latin 你好
Some text
## 😄 emoji
Some text
### Other title 1
Some text`,
anchorPrefix: 'h-',
})).to.equal(`# Some main title
<!-- TOC START -->
- [Привет non-latin 你好](#h--non-latin-)
- [😄 emoji](#h--emoji)
* [Other title 1](#h-other-title-1)
<!-- TOC END -->
<!-- TOC ANCHOR --><a name="-non-latin-"></a>
## Привет non-latin 你好
Some text
<!-- TOC ANCHOR --><a name="-emoji"></a>
## 😄 emoji
Some text
<!-- TOC ANCHOR --><a name="other-title-1"></a>
### Other title 1
Some text`);
});
});
@@ -0,0 +1,183 @@
import sanitizeHtml from 'sanitize-html';
function stripNonLatinCharacters(text: string) {
return text.replace(/[^A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u02BB\u02EE\uA78C\d\s_-]/g, '');
};
function transformInlineCode(text: string, transform: (s: string) => string) {
return text.replace(/`(.*?)`/g, (_, p) => {
return `\`${transform(p)}\``;
});
};
function spacesToDash(text: string) {
return text.replace(/\s/g, '-');
};
function stripHtmlTags(text: string) {
return sanitizeHtml(text, {
allowedTags: [],
allowedAttributes: {},
});
}
function stripMarkdownLinks(text: string, replacement: string = '$1') {
return text.replace(/\[([^\]]*)\]\([^\)]*\)/g, replacement); // NOSONAR
};
function concatDashes(text: string) {
return text.replace(/--+/g, '-');
};
function removeUnderscoreBoldAndItalics(text: string) {
const underscoreBoldAndItalicsRegexes = ['__', '_'].map((it) => {
return new RegExp(`\\b${it}([^_\\s]|[^_\\s].*?[^_\\s])${it}\\b`, 'g');
});
let result = text;
underscoreBoldAndItalicsRegexes.forEach((regex) => {
result = result.replace(regex, '$1');
});
return result;
};
function genericAnchorGenerator(text: string, concatSpaces: boolean) {
let result = text;
result = result.toLowerCase();
result = transformInlineCode(result, (s: string) => {
return stripNonLatinCharacters(s);
});
result = removeUnderscoreBoldAndItalics(result);
result = stripHtmlTags(result);
result = stripMarkdownLinks(result);
result = result.trim();
result = stripNonLatinCharacters(result);
result = spacesToDash(result);
if (concatSpaces) {
result = concatDashes(result);
}
return result;
};
function escapeRegExp(string: string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
interface Title {
level: number
id: string
name: string
md: string
}
function getTitles(markdown: string, idGenerator: (titleMarkdownContent: string) => string) {
const titles: Title[] = [];
markdown = markdown.replace(/^```[\s\S]*?\n```/mg, () => {
return '';
});
markdown = markdown.replace(/^~~~[\s\S]*?\n~~~/mg, () => {
return '';
});
[...markdown.matchAll(/^(#+)(.*$)/mg)].forEach( // NOSONAR
([match, levelString, titleContent]) => {
const level = levelString.length;
titles.push({
md: match,
level,
id: idGenerator(titleContent),
name: titleContent.trim(),
});
});
return titles;
};
export function getTocMarkdown({
markdown,
generateAnchors = true,
indentChars = '-*+',
indentSpaces = 2,
maxLevel = -1,
anchorPrefix = '',
concatSpaces = true,
commentStyle = 'html',
}: {
markdown: string
generateAnchors?: boolean
indentChars?: string
indentSpaces?: number
maxLevel?: number
anchorPrefix?: string
concatSpaces?: boolean
commentStyle?: 'html' | 'liquid'
}) {
const allIds: { [id: string]: number } = {};
const getFinalId = (id: string) => {
if (typeof allIds[id] === 'undefined') {
allIds[id] = 0;
return id;
}
else {
allIds[id] += 1;
return `${id}-${allIds[id]}`;
}
};
const titles = getTitles(markdown, titleContent => getFinalId(genericAnchorGenerator(titleContent, concatSpaces)));
const createLink = (linkText: string, url: string) => {
return `[${linkText.replace(/\[/g, '\\[').replace(/\]/g, '\\]')}](${url.replace(/\(/g, '%28').replace(/\(/g, '%29')})`;
};
let markdownTOC = '';
let resultMarkdown = markdown;
const commentOpen = commentStyle === 'html' ? '<!--' : '{%- #';
const commentClose = commentStyle === 'html' ? '-->' : '-%}';
resultMarkdown = resultMarkdown.replace(
new RegExp(`\n${escapeRegExp(commentOpen)} TOC START.*?TOC END ${escapeRegExp(commentClose)}\n`, 'smg'),
'\n[TOC]\n',
);
resultMarkdown = resultMarkdown.replace(
new RegExp(`^${escapeRegExp(commentOpen)} TOC ANCHOR.*?\n`, 'mg'),
'',
);
titles.forEach((title) => {
if (title.level === 1) {
return;
}
if (maxLevel > 0 && title.level > maxLevel) {
return;
}
const level = title.level - 2;
let offset = '';
if (level) {
offset = `${Array.from({ length: level * indentSpaces }).join(' ')} `;
}
const bulletChar = indentChars[level] ?? indentChars.slice(-1)[0];
const anchorName = `${anchorPrefix}${title.id}`;
markdownTOC += `${offset}${bulletChar} ${createLink(stripMarkdownLinks(title.name), `#${anchorName}`)}\n`;
if (generateAnchors) {
resultMarkdown = resultMarkdown.replace(
new RegExp(`(?<!^${commentOpen} TOC ANCHOR.*\n)^${escapeRegExp(title.md)}`, 'm'),
`${commentOpen} TOC ANCHOR ${commentClose}<a name="${title.id}"></a>\n${title.md}`,
);
}
});
resultMarkdown = resultMarkdown.replace(
/^\[TOC\]\n/mg,
`${commentOpen} TOC START ${commentClose}\n${markdownTOC}${commentOpen} TOC END ${commentClose}\n`,
);
return resultMarkdown;
}
@@ -0,0 +1,127 @@
<script setup lang="ts">
import { withDefaultOnError } from '../../utils/defaults';
import {
getTocMarkdown,
} from './markdown-toc-generator.service';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const markdown = ref(`# Some main title
[TOC]
## First Title
Some text
## Second Spaced Title
Some text
### Title with Link [TOC](http://it-tools.tech)
\`\`\`
## some bash code
echo 'test';
\`\`\`
### Title with code \`var\`
Some text
## Last Title`);
const generateAnchors = useQueryParamOrStorage({ name: 'anchors', storageName: 'md-toc-gen:anchors', defaultValue: true });
const indentChars = useQueryParamOrStorage({ name: 'bullets', storageName: 'md-toc-gen:bullets', defaultValue: '-*+' });
const indentSpaces = ref(3);
const maxLevel = useQueryParamOrStorage({ name: 'max', storageName: 'md-toc-gen:max', defaultValue: -1 });
const anchorPrefix = useQueryParamOrStorage({ name: 'prefix', storageName: 'md-toc-gen:prefix', defaultValue: '' });
const concatSpaces = useQueryParamOrStorage({ name: 'concat', storageName: 'md-toc-gen:concat', defaultValue: false });
const commentStyle = useQueryParamOrStorage({ name: 'comment', storageName: 'md-toc-gen:comment', defaultValue: 'html' });
const markdownWithTOC = computed(() => withDefaultOnError(() => {
return getTocMarkdown({
markdown: markdown.value,
anchorPrefix: anchorPrefix.value,
commentStyle: commentStyle.value as ('html' | 'liquid'),
concatSpaces: concatSpaces.value,
generateAnchors: generateAnchors.value,
indentChars: indentChars.value,
indentSpaces: indentSpaces.value,
maxLevel: maxLevel.value,
});
}, ''));
</script>
<template>
<div>
<c-card title="Options" mb-2>
<n-space>
<n-form-item label-placement="left">
<n-checkbox v-model:checked="generateAnchors">
Generate Anchors
</n-checkbox>
</n-form-item>
<n-form-item label="Max Heading Level:" label-placement="left">
<n-input-number
v-model:value="maxLevel"
placeholder="Max Heading Level..."
:max="6" :min="-1"
/>
</n-form-item>
</n-space>
<details>
<summary>Advanced</summary>
<n-space>
<n-form-item label-placement="left">
<n-checkbox v-model:checked="concatSpaces">
Concat Spaces
</n-checkbox>
</n-form-item>
<c-input-text
v-model:value="indentChars"
label="Bullet Chars"
label-position="left"
placeholder="Bullet Chars"
/>
<c-input-text
v-model:value="anchorPrefix"
label="Anchors Prefix"
label-position="left"
placeholder="Anchors Prefix"
/>
<n-form-item label="Indents: " label-placement="left">
<n-input-number
v-model:value="indentSpaces"
placeholder="Indents..."
:max="10" :min="1"
/>
</n-form-item>
<c-select
v-model:value="commentStyle"
label="Comment Styles"
label-position="left"
:options="['html', 'liquid']"
placeholder="Comment Styles"
/>
</n-space>
</details>
</c-card>
<c-card title="Input markdown" mb-2>
<n-p>You can paste a document with existing TOC (generated by this tool) or add a <code>[TOC]</code> marker in your document (on a single line)</n-p>
<c-input-text
v-model:value="markdown"
placeholder="Put your markdown here..."
multiline
rows="8"
/>
</c-card>
<c-card title="Output markdown with TOC" mb-2>
<textarea-copyable
language="markdown"
:value="markdownWithTOC"
/>
</c-card>
</div>
</template>
+1 -1
View File
@@ -151,7 +151,7 @@ function onSearchInput() {
>
<div flex-1 truncate>
<slot name="displayed-value">
<input v-if="searchable && isOpen" ref="searchInputRef" v-model="searchQuery" type="text" placeholder="Search..." class="search-input" w-full color-current lh-normal @input="onSearchInput">
<input v-if="searchable && isOpen" ref="searchInputRef" v-model="searchQuery" type="text" placeholder="Search..." class="search-input" w-full lh-normal color-current @input="onSearchInput">
<span v-else-if="selectedOption" lh-normal>
{{ selectedOption.label }}
</span>
+1 -1
View File
@@ -39,7 +39,7 @@ const headers = computed(() => {
<template>
<div class="relative overflow-x-auto rounded">
<table class="w-full border-collapse text-left text-sm text-gray-500 dark:text-gray-400" role="table" :aria-label="description">
<thead v-if="!hideHeaders" class="bg-#ffffff text-gray-700 uppercase dark:bg-#333333 dark:text-gray-400" border-b="1px solid dark:transparent #efeff5">
<thead v-if="!hideHeaders" class="bg-#ffffff uppercase text-gray-700 dark:bg-#333333 dark:text-gray-400" border-b="1px solid dark:transparent #efeff5">
<tr>
<th v-for="header in headers" :key="header.key" scope="col" class="px-6 py-3 text-xs">
{{ header.label }}