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 6483 additions and 8360 deletions

No files matched your search

+3 -2
View File
@@ -83,9 +83,9 @@ declare module '@vue/runtime-core' {
GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default']
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
HashText: typeof import('./src/tools/hash-text/hash-text.vue')['default']
HddCalculator: typeof import('./src/tools/hdd-calculator/hdd-calculator.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']
@@ -131,6 +131,7 @@ declare module '@vue/runtime-core' {
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
@@ -139,10 +140,10 @@ declare module '@vue/runtime-core' {
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
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
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",
+6380 -8267
View File
File diff suppressed because it is too large. Load diff
@@ -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 font-bold text-primary op-60>
<div ml-3 mt-3 text-sm text-primary font-bold op-60>
{{ category }}
</div>
<command-palette-option v-for="option in options" :key="option.name" :option="option" :selected="selectedOptionIndex === getOptionIndex(option)" @activated="activateOption" />
@@ -1,12 +0,0 @@
import { describe, expect, it } from 'vitest';
import { getRealSize } from './hdd-calculator.service';
describe('hdd-calculator', () => {
it('Convert Claimed Size to Real Size', async () => {
expect(getRealSize(10, 'gb', 'tb')).to.equal(0.009094947017729282);
expect(getRealSize(10, 'pb', 'mb')).to.equal(9536743164.0625);
expect(getRealSize(100, 'tb', 'gb')).to.equal(93132.25746154785);
expect(getRealSize(1, 'pb', 'gb')).to.equal(931322.5746154785);
expect(getRealSize(1000, 'tb', 'gb')).to.equal(931322.5746154785);
});
});
@@ -1,14 +0,0 @@
const unitsConversion = {
kb: { dec: 1_000, bin: 1024 },
mb: { dec: 1_000_000, bin: 1024 * 1024 },
gb: { dec: 1_000_000_000, bin: 1024 * 1024 * 1024 },
tb: { dec: 1_000_000_000_000, bin: 1024 * 1024 * 1024 * 1024 },
pb: { dec: 1_000_000_000_000_000, bin: 1024 * 1024 * 1024 * 1024 * 1024 },
};
export type Units = 'kb' | 'mb' | 'gb' | 'tb' | 'pb';
export function getRealSize(claimedCapacity: number, claimedUnit: Units, toUnit: Units) {
const fromUnit = unitsConversion[claimedUnit];
const toUnitBin = unitsConversion[toUnit].bin;
return claimedCapacity * fromUnit.dec / toUnitBin;
};
@@ -1,45 +0,0 @@
<script setup lang="ts">
import InputCopyable from '../../components/InputCopyable.vue';
import type { Units } from './hdd-calculator.service';
import { getRealSize } from './hdd-calculator.service';
const dec_units = [
{ value: 'kb', label: 'kB' },
{ value: 'mb', label: 'MB' },
{ value: 'gb', label: 'GB' },
{ value: 'tb', label: 'TB' },
{ value: 'pb', label: 'PB' },
];
const bin_units = [
{ value: 'kb', label: 'KiB' },
{ value: 'mb', label: 'MiB' },
{ value: 'gb', label: 'GiB' },
{ value: 'tb', label: 'TiB' },
{ value: 'pb', label: 'PiB' },
];
const claimedCapacity = ref(1);
const claimedUnit = ref('tb');
</script>
<template>
<div>
<n-form-item label="Claimed Capacity:">
<n-input-number v-model:value="claimedCapacity" :min="1" />
</n-form-item>
<c-select
v-model:value="claimedUnit"
label="Unit:"
:options="dec_units"
/>
<n-divider />
<InputCopyable
v-for="({ value, label }) in bin_units"
:key="value"
:label="`Capacity in ${label}:`"
:value="getRealSize(claimedCapacity, claimedUnit as Units, value as Units).toFixed(5)"
/>
</div>
</template>
-14
View File
@@ -1,14 +0,0 @@
import { DeviceDesktop } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'HDD calculator',
path: '/hdd-calculator',
description: 'Storage device manufacturers report capacities in decimal form (like GB), while operating systems and other software uses binary form (GiB), although still incorrectly using the decimal unit (GiB). This tool converts decimal form capacity into various binary forms.',
keywords: ['hdd', 'calculator', 'size', 'conversion', 'binary', 'decimal',
'gb', 'mb', 'tb',
'gigabyte', 'gibibyte', 'megabyte', 'mebibyte', 'terabyte', 'tebibyte'],
component: () => import('./hdd-calculator.vue'),
icon: DeviceDesktop,
createdAt: new Date('2024-04-07'),
});
+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'),
});
+2 -2
View File
@@ -7,7 +7,7 @@ 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 hddCalculator } from './hdd-calculator';
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';
@@ -114,7 +114,7 @@ export const toolsByCategory: ToolCategory[] = [
listConverter,
tomlToJson,
tomlToYaml,
hddCalculator,
htmlCleaner,
xmlToJson,
jsonToXml,
markdownToHtml,
+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 = ''">
+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 lh-normal color-current @input="onSearchInput">
<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">
<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 uppercase text-gray-700 dark:bg-#333333 dark:text-gray-400" border-b="1px solid dark:transparent #efeff5">
<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">
<tr>
<th v-for="header in headers" :key="header.key" scope="col" class="px-6 py-3 text-xs">
{{ header.label }}