Compare commits

..
Author SHA1 Message Date
ShareVB f0c255d2f2 fix: lint 2024-12-15 19:47:20 +01:00
ShareVB 12a974de42 Merge remote-tracking branch 'origin/main' into feat/html-cleaner 2024-12-15 19:37:00 +01:00
ShareVB 07e53f0e2f fix: paste-html 2024-12-15 19:33:46 +01:00
ShareVB ba84e82a8e chore(github workflows): ci and e2e tests: try updating to node 20 2024-04-06 12:17:34 +02:00
ShareVB fbde97572f chore(github workflows): ci and e2e tests: try updating to node 20 2024-04-06 11:58:43 +02:00
sharevb c0c5cfda87 feat(new tool): html cleaner
HTML Cleaner (with paste html)
Fix #537
2024-04-06 11:52:42 +02:00
14 changed files with 2745 additions and 3090 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']>
+5 -3
View File
@@ -82,10 +82,10 @@ declare module '@vue/runtime-core' {
FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default']
GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default']
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
HarSanitizer: typeof import('./src/tools/har-sanitizer/har-sanitizer.vue')['default']
HashText: typeof import('./src/tools/hash-text/hash-text.vue')['default']
HmacGenerator: typeof import('./src/tools/hmac-generator/hmac-generator.vue')['default']
'Home.page': typeof import('./src/pages/Home.page.vue')['default']
HtmlCleaner: typeof import('./src/tools/html-cleaner/html-cleaner.vue')['default']
HtmlEntities: typeof import('./src/tools/html-entities/html-entities.vue')['default']
HtmlWysiwygEditor: typeof import('./src/tools/html-wysiwyg-editor/html-wysiwyg-editor.vue')['default']
HttpStatusCodes: typeof import('./src/tools/http-status-codes/http-status-codes.vue')['default']
@@ -134,15 +134,16 @@ declare module '@vue/runtime-core' {
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NGrid: typeof import('naive-ui')['NGrid']
NFormItem: typeof import('naive-ui')['NFormItem']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NSpace: typeof import('naive-ui')['NSpace']
NScrollbar: typeof import('naive-ui')['NScrollbar']
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']
@@ -161,6 +162,7 @@ declare module '@vue/runtime-core' {
RouterView: typeof import('vue-router')['RouterView']
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
+2 -1
View File
@@ -46,6 +46,7 @@
"@tiptap/starter-kit": "2.1.6",
"@tiptap/vue-3": "2.0.3",
"@types/figlet": "^1.5.8",
"@types/js-beautify": "^1.14.3",
"@types/markdown-it": "^13.0.7",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
@@ -70,6 +71,7 @@
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"js-beautify": "^1.15.1",
"js-base64": "^3.7.6",
"json5": "^2.2.3",
"jwt-decode": "^3.1.2",
@@ -115,7 +117,6 @@
"@types/bcryptjs": "^2.4.2",
"@types/crypto-js": "^4.1.1",
"@types/dompurify": "^3.0.5",
"@types/har-format": "^1.2.16",
"@types/jsdom": "^21.0.0",
"@types/lodash": "^4.14.192",
"@types/mime-types": "^2.1.1",
+2641 -2626
View File
File diff suppressed because it is too large. Load diff
-150
View File
@@ -1,150 +0,0 @@
<script setup lang="ts">
import { downloadFile } from './lib/downloadFile';
import { defaultScrubItems, getHarInfo, sanitize } from './lib/har_sanitize';
type ScrubState = Record<ScrubType, Record<string, boolean>>;
type ScrubType =
| 'cookies'
| 'headers'
| 'queryArgs'
| 'postParams'
| 'mimeTypes';
const typeMap: Record<ScrubType, string> = {
cookies: 'Cookies',
mimeTypes: 'Mime Types',
headers: 'Headers',
postParams: 'Post Body Params',
queryArgs: 'Query String Parameters',
};
const defaulScrubState: ScrubState = {
cookies: {},
headers: {},
queryArgs: {},
postParams: {},
mimeTypes: {},
};
const scrubItemsToClean = ref<ScrubState>(defaulScrubState);
function getScrubableItems(input: string): ScrubState {
const rawItems = getHarInfo(input);
const output = { ...defaulScrubState };
Object.entries(rawItems).forEach(([key, items]: [string, string[]]) => {
output[key as ScrubType] = items.reduce(
(acc, curr) => {
if (!curr) {
return acc;
}
acc[curr] = defaultScrubItems.includes(curr);
return acc;
},
{} as Record<string, boolean>,
);
return null;
});
return output;
}
function sanitizeHar(input: string, scrubItems: ScrubState) {
const words = new Set<string>();
Object.entries(scrubItems.cookies).forEach(([key, val]) => {
if (val) {
words.add(key);
}
});
Object.entries(scrubItems.headers).forEach(([key, val]) => {
if (val) {
words.add(key);
}
});
Object.entries(scrubItems.queryArgs).forEach(([key, val]) => {
if (val) {
words.add(key);
}
});
Object.entries(scrubItems.postParams).forEach(([key, val]) => {
if (val) {
words.add(key);
}
});
const mimeTypes = new Set<string>();
Object.entries(scrubItems.mimeTypes).forEach(([key, val]) => {
if (val) {
mimeTypes.add(key);
}
});
return sanitize(input, {
scrubWords: [...words],
scrubMimetypes: [...mimeTypes],
});
}
const file = ref<File | null>(null);
const error = ref('');
function readAsTextAsync(file: File) {
return new Promise<string>((resolve, reject) => {
const reader = new FileReader();
reader.readAsText(file);
reader.onload = () => resolve(reader.result?.toString() ?? '');
reader.onerror = error => reject(error);
});
}
const harContent = ref('');
async function onFileUploaded(uploadedFile: File) {
file.value = uploadedFile;
harContent.value = await readAsTextAsync(uploadedFile);
error.value = '';
try {
scrubItemsToClean.value = getScrubableItems(harContent.value);
}
catch (e: any) {
error.value = e.toString();
}
}
function processHar() {
downloadFile(sanitizeHar(harContent.value, scrubItemsToClean.value), `sanitized-${file.value?.name}`);
}
</script>
<template>
<div>
<div style="flex: 0 0 100%" mb-3>
<div mx-auto max-w-600px>
<c-file-upload
title="Drag and drop a HAR file here, or click to select a file"
accept=".har" @file-upload="onFileUploaded"
/>
</div>
</div>
<c-alert v-if="error" title="Error">
{{ error }}
</c-alert>
<div v-for="(title, key) in typeMap" :key="key" mb-1>
<c-card v-if="Object.keys(scrubItemsToClean[key]).length" :title="title">
<n-checkbox font-size-5 @update:checked="(allChecked: boolean) => Object.keys(scrubItemsToClean[key]).forEach((name) => scrubItemsToClean[key][name] = allChecked)">
All {{ title }}
</n-checkbox>
<n-space size="large">
<n-checkbox v-for="(checked, name) in scrubItemsToClean[key]" :key="name" v-model:checked="scrubItemsToClean[key][name]" style="width: 150px">
{{ name }}
</n-checkbox>
</n-space>
</c-card>
</div>
<div v-if="!error" mt-3 flex justify-center>
<c-button @click="processHar()">
Sanitize and download
</c-button>
</div>
</div>
</template>
-12
View File
@@ -1,12 +0,0 @@
import { ClearFormatting } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'HAR Sanitizer',
path: '/har-sanitizer',
description: 'HAR Files Sanitizer',
keywords: ['har', 'sanitizer'],
component: () => import('./har-sanitizer.vue'),
icon: ClearFormatting,
createdAt: new Date('2024-06-17'),
});
@@ -1,19 +0,0 @@
export function downloadFile(harOutput: string, name: string) {
const blob = new Blob([harOutput], { type: 'application/json' });
// Create a URL for the Blob
const url = URL.createObjectURL(blob);
// Create an anchor element to trigger the download
const a = document.createElement('a');
a.href = url;
// Set file name
a.download = name;
a.style.display = 'none';
document.body.appendChild(a);
a.click();
// Clean up by removing the anchor and revoking the URL
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
@@ -1,237 +0,0 @@
/* eslint-disable prefer-regex-literals */
import type { Cookie, Har, Header, Param, QueryString } from 'har-format';
export interface PossibleScrubItems {
headers: string[]
cookies: string[]
queryArgs: string[]
postParams: string[]
mimeTypes: string[]
}
const defaultMimeTypesList = ['application/javascript', 'text/javascript'];
const defaultWordList = [
'Authorization',
'SAMLRequest',
'SAMLResponse',
'access_token',
'appID',
'assertion',
'auth',
'authenticity_token',
'challenge',
'client_id',
'client_secret',
'code',
'code_challenge',
'code_verifier',
'email',
'facetID',
'fcParams',
'id_token',
'password',
'refresh_token',
'serverData',
'shdf',
'state',
'token',
'usg',
'vses2',
'x-client-data',
];
export const defaultScrubItems = [...defaultMimeTypesList, ...defaultWordList];
// The default list of regexes that aren't word dependent
// Uses double list so it matches format of word regex
const defaultRegex = [
[
// Redact signature on JWTs
{
regex: new RegExp(
'\\b(ey[A-Za-z0-9-_=]+)\\.(ey[A-Za-z0-9-_=]+)\\.[A-Za-z0-9-_.+/=]+\\b',
'g',
),
replacement: '$1.$2.redacted',
},
],
];
function buildRegex(word: string) {
return [
{
// [full word]=[capture]
regex: new RegExp(
`([\\s";,&?]+${word}=)([\\w+-_/=#|.%&:!*()\`~'"]+?)(&|\\\\",|",|"\\s|"}}|;){1}`,
'g',
),
replacement: `$1[${word} redacted]$3`,
},
// Set up this way in case "value" isn't directly after "name"
// {
// "name": "[word]",
// "something": "not wanted",
// "value": "[capture]"
// }
{
regex: new RegExp(
`("name": "${word}",[\\s\\w+:"-\\%!*()\`~'.,#]*?"value": ")((?:\\\\"|[^"])*?)(")`,
'g',
),
replacement: `$1[${word} redacted]$3`,
},
// "name" comes after "value"
// {
// "value": "[capture]",
// "something": "not wanted",
// "name": "[word]"
// }
{
regex: new RegExp(
`("value": ")([\\w+-_:&+=#$~/()\\\\.\\,*!|%"\\s;]+)("[,\\s}}]+)([\\s\\w+:"-\\\\%!*\`()~'#.]*"name": "${word}")`,
'g',
),
replacement: `$1[${word} redacted]$3$4`,
},
];
}
function removeContentForMimeTypes(input: string, scrubList: string[]) {
const harJSON = JSON.parse(input);
const entries = harJSON.log.entries;
if (!entries) {
throw new Error('failed to find entries in HAR file');
}
for (const entry of entries) {
const response = entry.response;
if (response && scrubList.includes(response.content.mimeType)) {
response.content.text = `[${response.content.mimeType} redacted]`;
}
}
return JSON.stringify(harJSON, null, 2);
}
export function getHarInfo(input: string): PossibleScrubItems {
const output = {
headers: new Set<string>(),
queryArgs: new Set<string>(),
cookies: new Set<string>(),
postParams: new Set<string>(),
mimeTypes: new Set<string>(),
};
const harJSON: Har = JSON.parse(input);
const entries = harJSON.log.entries;
if (!entries) {
throw new Error('failed to find entries in HAR file');
}
for (const entry of entries) {
const response = entry.response;
response.headers.map((header: Header) => output.headers.add(header.name));
response.cookies.map((cookie: Cookie) => output.cookies.add(cookie.name));
output.mimeTypes.add(response.content.mimeType);
const request = entry.request;
request.headers.map((header: Header) => output.headers.add(header.name));
request.queryString.map((arg: QueryString) =>
output.queryArgs.add(arg.name),
);
request.cookies.map((cookie: Cookie) => output.cookies.add(cookie.name));
if (request.postData) {
request.postData.params?.map((param: Param) =>
output.postParams.add(param.name),
);
}
}
return {
headers: [...output.headers].sort((a, b) => a.localeCompare(b)),
queryArgs: [...output.queryArgs].sort((a, b) => a.localeCompare(b)),
cookies: [...output.cookies].sort((a, b) => a.localeCompare(b)),
postParams: [...output.postParams].sort((a, b) => a.localeCompare(b)),
mimeTypes: [...output.mimeTypes].sort((a, b) => a.localeCompare(b)),
};
}
function getScrubMimeTypes(
options?: SanitizeOptions,
possibleScrubItems?: PossibleScrubItems,
) {
if (options?.allMimeTypes && !!possibleScrubItems) {
return possibleScrubItems.mimeTypes;
}
return options?.scrubMimetypes || defaultMimeTypesList;
}
function getScrubWords(
options?: SanitizeOptions,
possibleScrubItems?: PossibleScrubItems,
) {
let scrubWords = options?.scrubWords || [];
if (options?.allCookies && !!possibleScrubItems) {
scrubWords = scrubWords.concat(possibleScrubItems.cookies);
}
if (options?.allHeaders && !!possibleScrubItems) {
scrubWords = scrubWords.concat(possibleScrubItems.headers);
}
if (options?.allQueryArgs && !!possibleScrubItems) {
scrubWords = scrubWords.concat(possibleScrubItems.queryArgs);
}
if (options?.allPostParams && !!possibleScrubItems) {
scrubWords = scrubWords.concat(possibleScrubItems.postParams);
}
return scrubWords || defaultScrubItems;
}
interface SanitizeOptions {
scrubWords?: string[]
scrubMimetypes?: string[]
allCookies?: boolean
allHeaders?: boolean
allQueryArgs?: boolean
allMimeTypes?: boolean
allPostParams?: boolean
}
export function sanitize(input: string, options?: SanitizeOptions) {
let possibleScrubItems: PossibleScrubItems | undefined;
if (
options?.allCookies
|| options?.allHeaders
|| options?.allMimeTypes
|| options?.allQueryArgs
|| options?.allPostParams
) {
// we have to parse the HAR to get the full list of things we could scrub
possibleScrubItems = getHarInfo(input);
}
// Remove specific mime responses first
input = removeContentForMimeTypes(
input,
getScrubMimeTypes(options, possibleScrubItems),
);
// trim the list of words we are looking for down to the ones actually in the HAR file
const wordList = getScrubWords(options, possibleScrubItems).filter(val =>
input.includes(val),
);
// build list of regexes needed to actually scrub the file
const wordSpecificScrubList = wordList.map(word => buildRegex(word));
const allScrubList = defaultRegex.concat(wordSpecificScrubList);
for (const scrubList of allScrubList) {
for (const scrub of scrubList) {
input = input.replace(scrub.regex, scrub.replacement);
}
}
return input;
}
-18
View File
@@ -1,18 +0,0 @@
export type HashMap = Record<string, string[]>;
export function toHashString(obj: HashMap): string {
const params = new URLSearchParams();
Object.entries(obj).forEach(([key, stringArr]) => {
stringArr.forEach((value) => {
params.append(key, value);
});
});
return `#${params.toString()}`;
}
export function getHashMap(hash: string): HashMap {
const existingParams = new URLSearchParams(hash.replace('#', ''));
return Object.fromEntries(
[...existingParams.keys()].map(key => [key, existingParams.getAll(key)]),
);
}
+54
View File
@@ -0,0 +1,54 @@
<script setup lang="ts">
import DOMPurify from 'dompurify';
import beautify from 'js-beautify';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const inputHtml = ref('');
const outputHtml = computed(() => {
const cleanedHtml = DOMPurify.sanitize(inputHtml.value ?? '',
{
ALLOWED_ATTR: [
'href', 'src',
'width', 'height',
'alt',
'colspan', 'rowspan',
],
FORBID_TAGS: ['form', 'span'],
ALLOW_DATA_ATTR: false,
ALLOW_ARIA_ATTR: false,
RETURN_DOM: true,
}).outerHTML;
return beautify.html(cleanedHtml, {
unformatted: ['code', 'pre', 'em', 'strong', 'span'],
indent_inner_html: true,
indent_char: ' ',
indent_size: 2,
eol: '\n',
});
});
</script>
<template>
<div>
<c-input-text
v-model:value="inputHtml"
multiline raw-text
placeholder="Your HTML content..."
rows="8"
autofocus
label="Your HTML to clean (can paste from clipboard):"
paste-html
/>
<n-divider />
<n-form-item label="Output cleaned HTML:">
<TextareaCopyable
:value="outputHtml"
multiline
language="html"
:word-wrap="true"
/>
</n-form-item>
</div>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { BrandHtml5 } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Html cleaner',
path: '/html-cleaner',
description: 'Clean HTML',
keywords: ['html', 'cleaner'],
component: () => import('./html-cleaner.vue'),
icon: BrandHtml5,
createdAt: new Date('2024-02-25'),
});
+3 -10
View File
@@ -7,12 +7,12 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as htmlCleaner } from './html-cleaner';
import { tool as xmlToJson } from './xml-to-json';
import { tool as jsonToXml } from './json-to-xml';
import { tool as regexTester } from './regex-tester';
import { tool as regexMemo } from './regex-memo';
import { tool as markdownToHtml } from './markdown-to-html';
import { tool as harSanitizer } from './har-sanitizer';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -114,6 +114,7 @@ export const toolsByCategory: ToolCategory[] = [
listConverter,
tomlToJson,
tomlToYaml,
htmlCleaner,
xmlToJson,
jsonToXml,
markdownToHtml,
@@ -165,15 +166,7 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Network',
components: [
ipv4SubnetCalculator,
ipv4AddressConverter,
ipv4RangeExpander,
macAddressLookup,
macAddressGenerator,
ipv6UlaGenerator,
harSanitizer,
],
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
},
{
name: 'Math',
+27 -1
View File
@@ -31,6 +31,7 @@ const props = withDefaults(
autosize?: boolean
autofocus?: boolean
monospace?: boolean
pasteHtml?: boolean
}>(),
{
value: '',
@@ -58,13 +59,14 @@ const props = withDefaults(
autosize: false,
autofocus: false,
monospace: false,
pasteHtml: false,
},
);
const emit = defineEmits(['update:value']);
const value = useVModel(props, 'value', emit);
const showPassword = ref(false);
const { id, placeholder, label, validationRules, labelPosition, labelWidth, labelAlign, autosize, readonly, disabled, clearable, type, multiline, rows, rawText, autofocus, monospace } = toRefs(props);
const { id, placeholder, label, validationRules, labelPosition, labelWidth, labelAlign, autosize, readonly, disabled, clearable, type, multiline, rows, rawText, autofocus, monospace, pasteHtml } = toRefs(props);
const validation
= props.validation
@@ -81,6 +83,28 @@ const textareaRef = ref<HTMLTextAreaElement>();
const inputRef = ref<HTMLInputElement>();
const inputWrapperRef = ref<HTMLElement>();
interface HTMLElementWithValue {
value?: string
}
function onPasteInputHtml(evt: ClipboardEvent) {
if (!pasteHtml.value) {
return false;
}
const target = (evt.target as HTMLElementWithValue);
if (!target) {
return false;
}
const textHtmlData = evt.clipboardData?.getData('text/html');
if (textHtmlData && textHtmlData !== '') {
evt.preventDefault();
value.value = textHtmlData;
return true;
}
return false;
}
watch(
[value, autosize, multiline, inputWrapperRef, textareaRef],
() => nextTick(() => {
@@ -171,6 +195,7 @@ defineExpose({
:autocorrect="autocorrect ?? (rawText ? 'off' : undefined)"
:spellcheck="spellcheck ?? (rawText ? false : undefined)"
:rows="rows"
@paste="onPasteInputHtml"
/>
<input
@@ -192,6 +217,7 @@ defineExpose({
:autocomplete="autocomplete ?? (rawText ? 'off' : undefined)"
:autocorrect="autocorrect ?? (rawText ? 'off' : undefined)"
:spellcheck="spellcheck ?? (rawText ? false : undefined)"
@paste="onPasteInputHtml"
>
<c-button v-if="clearable && value" variant="text" circle size="small" @click="value = ''">