Compare commits

..
Author SHA1 Message Date
ShareVB 0f8463f92c Merge remote-tracking branch 'origin/main' into feat/image-to-css 2024-11-10 19:55:28 +01:00
ShareVB 28699f7b5d fix: replace svg-to-url, ui improve and build 2024-11-10 19:50:41 +01:00
ShareVB e55d4fa5b2 fix: build 2024-06-16 22:53:38 +02:00
ShareVB 5bc8da91d6 fix: eslint 2024-06-16 22:22:37 +02:00
ShareVB 239b7e0600 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-06-16 22:19:04 +02:00
ShareVB 45998fd1f3 fix: last modif 2024-06-16 22:18:40 +02:00
sharevb 42d1bf7d35 feat(TextAreaCopyable): word wrap 2024-06-16 22:06:46 +02:00
sharevb c8dbec756b feat(New tool): Image to CSS
FIx #530
2024-06-16 12:48:53 +02:00
21 changed files with 878 additions and 551 deletions

No files matched your search

+4 -1
View File
@@ -286,6 +286,9 @@
"watchTriggerable": true,
"watchWithFilter": true,
"whenever": true,
"toValue": true
"toValue": true,
"injectLocal": true,
"provideLocal": true,
"useClipboardItems": true
}
}
+3
View File
@@ -36,6 +36,7 @@ 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']
@@ -65,6 +66,7 @@ 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']
@@ -128,6 +130,7 @@ 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']
+36 -3
View File
@@ -58,8 +58,6 @@ declare module '@vue/runtime-core' {
CrontabGenerator: typeof import('./src/tools/crontab-generator/crontab-generator.vue')['default']
CSelect: typeof import('./src/ui/c-select/c-select.vue')['default']
'CSelect.demo': typeof import('./src/ui/c-select/c-select.demo.vue')['default']
CssSelectorsMemo: typeof import('./src/tools/css-selectors-memo/css-selectors-memo.md')['default']
CssXpathConverter: typeof import('./src/tools/css-xpath-converter/css-xpath-converter.vue')['default']
CTable: typeof import('./src/ui/c-table/c-table.vue')['default']
'CTable.demo': typeof import('./src/ui/c-table/c-table.demo.vue')['default']
CTextCopyable: typeof import('./src/ui/c-text-copyable/c-text-copyable.vue')['default']
@@ -92,17 +90,29 @@ declare module '@vue/runtime-core' {
HttpStatusCodes: typeof import('./src/tools/http-status-codes/http-status-codes.vue')['default']
IbanValidatorAndParser: typeof import('./src/tools/iban-validator-and-parser/iban-validator-and-parser.vue')['default']
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
'IconMdi:contentCopy': typeof import('~icons/mdi/content-copy')['default']
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
IconMdiArrowDown: typeof import('~icons/mdi/arrow-down')['default']
IconMdiArrowRightBottom: typeof import('~icons/mdi/arrow-right-bottom')['default']
IconMdiCamera: typeof import('~icons/mdi/camera')['default']
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
IconMdiClose: typeof import('~icons/mdi/close')['default']
IconMdiContentCopy: typeof import('~icons/mdi/content-copy')['default']
IconMdiDeleteOutline: typeof import('~icons/mdi/delete-outline')['default']
IconMdiDownload: typeof import('~icons/mdi/download')['default']
IconMdiEye: typeof import('~icons/mdi/eye')['default']
IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default']
IconMdiHeart: typeof import('~icons/mdi/heart')['default']
IconMdiPause: typeof import('~icons/mdi/pause')['default']
IconMdiPlay: typeof import('~icons/mdi/play')['default']
IconMdiRecord: typeof import('~icons/mdi/record')['default']
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
IconMdiSearch: typeof import('~icons/mdi/search')['default']
IconMdiTranslate: typeof import('~icons/mdi/translate')['default']
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
IconMdiVideo: typeof import('~icons/mdi/video')['default']
ImageToCss: typeof import('./src/tools/image-to-css/image-to-css.vue')['default']
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
@@ -131,20 +141,44 @@ 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']
NDatePicker: typeof import('naive-ui')['NDatePicker']
NDivider: typeof import('naive-ui')['NDivider']
NDynamicInput: typeof import('naive-ui')['NDynamicInput']
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']
NH2: typeof import('naive-ui')['NH2']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NImage: typeof import('naive-ui')['NImage']
NInputGroup: typeof import('naive-ui')['NInputGroup']
NInputGroupLabel: typeof import('naive-ui')['NInputGroupLabel']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NP: typeof import('naive-ui')['NP']
NProgress: typeof import('naive-ui')['NProgress']
NRadio: typeof import('naive-ui')['NRadio']
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSlider: typeof import('naive-ui')['NSlider']
NSpace: typeof import('naive-ui')['NSpace']
NSpin: typeof import('naive-ui')['NSpin']
NStatistic: typeof import('naive-ui')['NStatistic']
NSwitch: typeof import('naive-ui')['NSwitch']
NTable: typeof import('naive-ui')['NTable']
NTag: typeof import('naive-ui')['NTag']
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']
@@ -190,7 +224,6 @@ declare module '@vue/runtime-core' {
WifiQrCodeGenerator: typeof import('./src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue')['default']
XmlFormatter: typeof import('./src/tools/xml-formatter/xml-formatter.vue')['default']
XmlToJson: typeof import('./src/tools/xml-to-json/xml-to-json.vue')['default']
XpathMemo: typeof import('./src/tools/xpath-memo/xpath-memo.md')['default']
YamlToJson: typeof import('./src/tools/yaml-to-json-converter/yaml-to-json.vue')['default']
YamlToToml: typeof import('./src/tools/yaml-to-toml/yaml-to-toml.vue')['default']
YamlViewer: typeof import('./src/tools/yaml-viewer/yaml-viewer.vue')['default']
+4 -3
View File
@@ -59,7 +59,6 @@
"cron-validator": "^1.3.1",
"cronstrue": "^2.26.0",
"crypto-js": "^4.1.1",
"csstoxpath": "^2.0.0",
"date-fns": "^2.29.3",
"dompurify": "^3.0.6",
"email-normalizer": "^1.0.0",
@@ -90,6 +89,7 @@
"qrcode": "^1.5.1",
"randexp": "^0.5.3",
"sql-formatter": "^13.0.0",
"svgo": "^3.3.2",
"ua-parser-js": "^1.0.35",
"ulid": "^2.3.0",
"unicode-emoji-json": "^0.4.0",
@@ -103,7 +103,6 @@
"vuedraggable": "^4.1.0",
"xml-formatter": "^3.3.2",
"xml-js": "^1.6.11",
"xpath-to-css": "^1.2.0",
"yaml": "^2.2.1"
},
"devDependencies": {
@@ -144,11 +143,13 @@
"unplugin-icons": "^0.17.0",
"unplugin-vue-components": "^0.25.0",
"vite": "^4.4.9",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-pwa": "^0.16.0",
"vite-plugin-vue-markdown": "^0.23.5",
"vite-svg-loader": "^4.0.0",
"vitest": "^0.34.0",
"workbox-window": "^7.0.0",
"zx": "^7.2.1"
}
},
"packageManager": "pnpm@8.15.3"
}
+636 -40
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -17,6 +17,7 @@ const props = withDefaults(
language?: string
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
copyMessage?: string
wordWrap?: boolean
}>(),
{
followHeightOf: null,
@@ -49,7 +50,7 @@ const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
>
<n-config-provider :hljs="hljs">
<n-code :code="value" :language="language" :trim="false" data-test-id="area-content" />
<n-code :code="value" :language="language" :word-wrap="wordWrap" :trim="false" data-test-id="area-content" />
</n-config-provider>
</n-scrollbar>
<div absolute right-10px top-10px>
@@ -1,63 +0,0 @@
| Selector | Example | Example description |
|-----------------------|-------------------------|----------------------------------------------------------------------------------------------------------|
| `.class` | `.intro` | Selects all elements with class="intro" |
| `.class1.class2` | `.name1.name2` | Selects all elements with both name1 and name2 set within its class attribute |
| `.class1 .class2` | `.name1 .name2` | Selects all elements with name2 that is a descendant of an element with name1 |
| `#id` | `#firstname` | Selects the element with id="firstname" |
| `*` | `*` | Selects all elements |
| `element` | `p` | Selects all \<p\> elements |
| `element.class` | `p.intro` | Selects all \<p\> elements with class="intro" |
| `element,element` | `div, p` | Selects all \<div\> elements and all \<p\> elements |
| `element element` | `div p` | Selects all \<p\> elements inside \<div\> elements |
| `element>element` | `div > p` | Selects all \<p\> elements where the parent is a \<div\> element |
| `element+element` | `div + p` | Selects the first \<p\> element that is placed immediately after \<div\> elements |
| `element1~element2` | `p ~ ul` | Selects every \<ul\> element that is preceded by a \<p\> element |
| `[attribute]` | `[target]` | Selects all elements with a target attribute |
| `[attribute=value]` | `[target="_blank"]` | Selects all elements with target="_blank" |
| `[attribute~=value]` | `[title~="flower"]` | Selects all elements with a title attribute containing the word "flower" |
| `[attribute\|=value]` | `[lang\|="en"]` | Selects all elements with a lang attribute value equal to "en" or starting with "en-" |
| `[attribute^=value]` | `a[href^="https"]` | Selects every \<a\> element whose href attribute value begins with "https" |
| `[attribute$=value]` | `a[href$=".pdf"]` | Selects every \<a\> element whose href attribute value ends with ".pdf" |
| `[attribute*=value]` | `a[href*="w3schools"]` | Selects every \<a\> element whose href attribute value contains the substring "w3schools" |
| `:active` | `a:active` | Selects the active link |
| `::after` | `p::after` | Insert something after the content of each \<p\> element |
| `::before` | `p::before` | Insert something before the content of each \<p\> element |
| `:checked` | `input:checked` | Selects every checked \<input\> element |
| `:default` | `input:default` | Selects the default \<input\> element |
| `:disabled` | `input:disabled` | Selects every disabled \<input\> element |
| `:empty` | `p:empty` | Selects every \<p\> element that has no children (including text nodes) |
| `:enabled` | `input:enabled` | Selects every enabled \<input\> element |
| `:first-child` | `p:first-child` | Selects every \<p\> element that is the first child of its parent |
| `::first-letter` | `p::first-letter` | Selects the first letter of every \<p\> element |
| `::first-line` | `p::first-line` | Selects the first line of every \<p\> element |
| `:first-of-type` | `p:first-of-type` | Selects every \<p\> element that is the first \<p\> element of its parent |
| `:focus` | `input:focus` | Selects the input element which has focus |
| `:fullscreen` | `:fullscreen` | Selects the element that is in full-screen mode |
| `:has()` | `h2:has(+p)` | Selects h2 elements that are immediately followed by a p element, and applies the style to h2 |
| `:hover` | `a:hover` | Selects links on mouse over |
| `:in-range` | `input:in-range` | Selects input elements with a value within a specified range |
| `:indeterminate` | `input:indeterminate` | Selects input elements that are in an indeterminate state |
| `:invalid` | `input:invalid` | Selects all input elements with an invalid value |
| `:lang()` | `p:lang(it)` | Selects every \<p\> element with a lang attribute equal to "it" (Italian) |
| `:last-child` | `p:last-child` | Selects every \<p\> element that is the last child of its parent |
| `:last-of-type` | `p:last-of-type` | Selects every \<p\> element that is the last \<p\> element of its parent |
| `:link` | `a:link` | Selects all unvisited links |
| `::marker` | `::marker` | Selects the markers of list items |
| `:not()` | `:not(p)` | Selects every element that is not a \<p\> element |
| `:nth-child()` | `p:nth-child(2)` | Selects every \<p\> element that is the second child of its parent |
| `:nth-last-child()` | `p:nth-last-child(2)` | Selects every \<p\> element that is the second child of its parent, counting from the last child |
| `:nth-last-of-type()` | `p:nth-last-of-type(2)` | Selects every \<p\> element that is the second \<p\> element of its parent, counting from the last child |
| `:nth-of-type()` | `p:nth-of-type(2)` | Selects every \<p\> element that is the second \<p\> element of its parent |
| `:only-of-type` | `p:only-of-type` | Selects every \<p\> element that is the only \<p\> element of its parent |
| `:only-child` | `p:only-child` | Selects every \<p\> element that is the only child of its parent |
| `:optional` | `input:optional` | Selects input elements with no "required" attribute |
| `:out-of-range` | `input:out-of-range` | Selects input elements with a value outside a specified range |
| `::placeholder` | `input::placeholder` | Selects input elements with the "placeholder" attribute specified |
| `:read-only` | `input:read-only` | Selects input elements with the "readonly" attribute specified |
| `:read-write` | `input:read-write` | Selects input elements with the "readonly" attribute NOT specified |
| `:required` | `input:required` | Selects input elements with the "required" attribute specified |
| `:root` | `:root` | Selects the document's root element |
| `::selection` | `::selection` | Selects the portion of an element that is selected by a user |
| `:target` | `#news:target` | Selects the current active #news element (clicked on a URL containing that anchor name) |
| `:valid` | `input:valid` | Selects all input elements with a valid value |
| `:visited` | `a:visited` | Selects all visited links |
@@ -1,32 +0,0 @@
<script setup lang="ts">
import { useThemeVars } from 'naive-ui';
import Memo from './css-selectors-memo.md';
const themeVars = useThemeVars();
</script>
<template>
<div>
<Memo style="overflow-x: auto;" />
</div>
</template>
<style lang="less" scoped>
::v-deep(pre) {
margin: 0;
padding: 15px 22px;
background-color: v-bind('themeVars.cardColor');
border-radius: 4px;
overflow: auto;
}
::v-deep(table) {
border-collapse: collapse;
}
::v-deep(table), ::v-deep(td), ::v-deep(th) {
border: 1px solid v-bind('themeVars.textColor1');
padding: 5px;
}
::v-deep(a) {
color: v-bind('themeVars.textColor1');
}
</style>
-12
View File
@@ -1,12 +0,0 @@
import { BrandCss3 } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'CSS Selectors Cheatsheet',
path: '/css-selectors-memo',
description: 'CSS Selectors Syntax Cheatsheet',
keywords: ['css', 'selectors', 'cheatsheet', 'memo'],
component: () => import('./css-selectors-memo.vue'),
icon: BrandCss3,
createdAt: new Date('2024-08-15'),
});
@@ -1,79 +0,0 @@
<script setup lang="ts">
import xPathToCss from 'xpath-to-css';
import cssToXpath from 'csstoxpath';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const cssInput = ref('');
const xpathOutput = computed(
() => {
try {
return cssToXpath(cssInput.value);
}
catch (e: any) {
return e.toString();
}
},
);
const xpathInput = ref('');
const cssOutput = computed(
() => {
try {
return xPathToCss(xpathInput.value);
}
catch (e: any) {
return e.toString();
}
},
);
</script>
<template>
<div max-w-600>
<c-card title="CSS to XPath">
<c-input-text
v-model:value="cssInput"
placeholder="Put your CSS selector here..."
label="CSS selector to convert"
raw-text
mb-5
/>
<router-link target="_blank" to="/css-selectors-memo" mb-1 mt-1>
See CSS Selectors Cheatsheet
</router-link>
<n-divider />
<TextareaCopyable
label="XPath expression"
:value="xpathOutput"
readonly
mb-5
/>
</c-card>
<c-card title="XPath to CSS" mt-5>
<c-input-text
v-model:value="xpathInput"
placeholder="Put your XPath expression here..."
label="XPath expression to convert"
raw-text
mb-5
/>
<router-link target="_blank" to="/xpath-memo" mb-1 mt-1>
See XPath Cheatsheet
</router-link>
<n-divider />
<TextareaCopyable
label="CSS Selector"
:value="cssOutput"
readonly
mb-5
/>
</c-card>
</div>
</template>
-3
View File
@@ -1,3 +0,0 @@
declare module "csstoxpath" {
export default function cssToXPath(xpath: string): string;
}
-12
View File
@@ -1,12 +0,0 @@
import { Braces } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'CSS XPath Converter',
path: '/css-xpath-converter',
description: 'Convert CSS selector to/from XPath expression',
keywords: ['css', 'xpath', 'converter'],
component: () => import('./css-xpath-converter.vue'),
icon: Braces,
createdAt: new Date('2024-08-15'),
});
-3
View File
@@ -1,3 +0,0 @@
declare module "xpath-to-css" {
export default function xpathToCSS(xpath: string): string;
}
@@ -0,0 +1,72 @@
import { type Config, type PluginConfig, optimize } from 'svgo';
function svgo(config: Config) {
return (data: string) => {
const { plugins = [], ...rest } = config || {};
return optimize(data, {
...rest,
plugins: [
...(plugins.length > 0 ? plugins : ['preset-default']),
'removeXMLNS',
] as PluginConfig[],
}).data.replace(/^<svg/g, '<svg xmlns="http://www.w3.org/2000/svg"');
};
}
export function encodeStr(svgStr: string) {
const encoded = encodeURIComponent(svgStr)
.replace(/%20/g, ' ')
.replace(/%3D/g, '=')
.replace(/%3B/g, ';')
.replace(/%3A/g, ':')
.replace(/%2F/g, '/')
.replace(/%2C/g, ',')
.replace(/%22/g, '\'');
return `data:image/svg+xml,${encoded}`;
}
export type CSSType = 'Background' | 'Border' | 'ListItemBullet' | 'Url';
async function fileToDataUrl(file: File) {
if (file.type === 'image/svg+xml') {
const svgContent = (await (new Promise<string>((resolve, reject) => {
const reader = new FileReader();
reader.readAsText(file);
reader.onload = () => resolve(reader.result?.toString() ?? '');
reader.onerror = error => reject(error);
})));
return svgToDataUrl(svgContent);
}
return new Promise<string>((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result?.toString() ?? '');
reader.onerror = error => reject(error);
});
}
function svgToDataUrl(svg: string) {
return encodeStr(svgo({})(svg));
}
export async function imageToCSS(
image: File | string,
type: CSSType,
) {
if (image === '' || !image) {
return '';
}
const dataURI = image instanceof File ? await fileToDataUrl(image) : svgToDataUrl(image);
switch (type) {
case 'Background':
return `background-image: url(${dataURI});`;
case 'Border':
return `border-image-source: url(${dataURI});`;
case 'ListItemBullet':
return `li{\n list-style-image: ${dataURI};\n}\nli::marker{\n font-size: 1.5em;\n}'}`;
default:
return `url(${dataURI})`;
}
}
+102
View File
@@ -0,0 +1,102 @@
<script setup lang="ts">
import type { Ref } from 'vue';
import { type CSSType, imageToCSS } from './image-to-css.service';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const typeOptions = [
{ label: 'Background', value: 'Background' },
{ label: 'Border', value: 'Border' },
{ label: 'ListItem Bullet', value: 'ListItemBullet' },
{ label: 'CSS Data Url', value: 'Url' },
];
const inputType = ref<'file' | 'content'>('file');
const type = ref('Background');
const svgContent = ref('');
const fileInput = ref() as Ref<File | null>;
const cssCode = computedAsync(async () => {
try {
if (inputType.value === 'file' && fileInput.value) {
return (await imageToCSS(fileInput.value, type.value as CSSType));
}
else {
return (await imageToCSS(svgContent.value, type.value as CSSType));
}
}
catch (e: any) {
return e.toString();
}
});
async function onUpload(file: File) {
if (file) {
fileInput.value = file;
}
}
watch(svgContent, (_, newValue) => {
if (newValue !== '') {
fileInput.value = null;
}
});
</script>
<template>
<div>
<n-radio-group v-model:value="inputType" name="radiogroup" mb-2 flex justify-center>
<n-space>
<n-radio
value="file"
label="File"
/>
<n-radio
value="content"
label="Content"
/>
</n-space>
</n-radio-group>
<c-file-upload
v-if="inputType === 'file'"
title="Drag and drop an image here, or click to select a file"
paste-image
@file-upload="onUpload"
/>
<c-input-text
v-if="inputType === 'content'"
v-model:value="svgContent"
multiline
rows="5"
label="SVG Content"
placeholder="Paste your SVG content here"
mb-2
/>
<n-divider />
<c-select
v-model:value="type"
label-position="top"
label="CSS Type:"
:options="typeOptions"
placeholder="Select CSS Type"
/>
<div v-if="cssCode !== ''">
<n-divider />
<h3>CSS Code</h3>
<TextareaCopyable
:value="cssCode"
word-wrap
/>
</div>
</div>
</template>
<style lang="less" scoped>
::v-deep(.n-upload-trigger) {
width: 100%;
}
</style>
+12
View File
@@ -0,0 +1,12 @@
import { BrandCss3 } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Image to CSS',
path: '/image-to-css',
description: 'Convert image to CSS (url, background, ...)',
keywords: ['image', 'css'],
component: () => import('./image-to-css.vue'),
icon: BrandCss3,
createdAt: new Date('2024-05-11'),
});
+4 -6
View File
@@ -2,12 +2,12 @@ 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 emailNormalizer } from './email-normalizer';
import { tool as cssXpathConverter } from './css-xpath-converter';
import { tool as cssSelectorsMemo } from './css-selectors-memo';
import { tool as xpathMemo } from './xpath-memo';
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 imageToCss } from './image-to-css';
import { tool as xmlToJson } from './xml-to-json';
import { tool as jsonToXml } from './json-to-xml';
import { tool as regexTester } from './regex-tester';
@@ -138,6 +138,7 @@ export const toolsByCategory: ToolCategory[] = [
httpStatusCodes,
jsonDiff,
safelinkDecoder,
imageToCss,
],
},
{
@@ -159,9 +160,6 @@ export const toolsByCategory: ToolCategory[] = [
xmlFormatter,
yamlViewer,
emailNormalizer,
cssXpathConverter,
cssSelectorsMemo,
xpathMemo,
regexTester,
regexMemo,
],
-12
View File
@@ -1,12 +0,0 @@
import { Brackets } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'XPath Syntax Cheatsheet',
path: '/xpath-memo',
description: 'XPath Syntax Cheatsheet',
keywords: ['xpath', 'memo', 'cheatsheet'],
component: () => import('./xpath-memo.vue'),
icon: Brackets,
createdAt: new Date('2024-08-15'),
});
-248
View File
@@ -1,248 +0,0 @@
> Credit to the original author: https://gist.github.com/jmaccabee/550a0b9fcfdc7e6b170cd34c6ec7bc56
## 0. XPath Examples.
> More: http://xpath.alephzarro.com/content/cheatsheet.html
| XPath | Description |
| -------------- | ----------- |
| `//hr[@class="edge" and position()=1]` | every first hr of 'edge' class
| `//table[count(tr)=1 and count(tr/td)=2]` | all tables with 1 row and 2 cols
| `//div/form/parent::*` | all divs that have form
| `./div/b` | a relative path
| `//table[parent::div[@class="pad"] and not(@id)]//a` | any anchor in a table without id, contained in a div of "pad" class
| `/html/body/div/*[preceding-sibling::h4]` | give me whatever after h4
| `//tr/td[font[@class="head" and text()="TRACK"]]` | all td that has font of a "head" class and text "TRACK"
| `./table/tr[last()]` | the last row of a table
| `//rdf:Seq/rdf:li/em:id` | using namespaces
| `//a/@href` | hrefs of all anchors
| `//*[count(*)=3]` | all nodes with 3 children
| `//var\|//acronym` | all vars and acronyms
## 1. General.
| XPath | Description |
| -------------- | ----------- |
| `/html` | whole web page (css: html)
| `/html/body` | whole web page body (css: body)
| `//text()` | all text nodes of web page
| `/html/body/.../.../.../E` | element \<E\> by absolute reference (css: body > … > … > … > E)
## 2. Tag.
| XPath | Description |
| -------------- | ----------- |
| `//E` | element \<E\> by relative reference (css: E)
| `(//E)[2]` | second \<E\> element anywhere on page
| `//img` | image element (css: img)
| `//E[@A]` | element \<E\> with attribute A (css: E[A])
| `//E[@A="t"]` | element \<E\> with attribute A containing text 't' exactly (css: E[A='t'])
| `//E[contains(@A,"t")]` | element \<E\> with attribute A containing text 't' (css: E[A*='t'])
| `//E[starts-with(@A, "t")]` | element \<E\> whose attribute A begins with 't' (css: E[A^='t'])
| `//E[ends-with(@A, "t")]` | element \<E\> whose attribute A ends with 't' (css: E[A$='t'])
| `//E[contains(concat(" ", @A, " "), " w ")` | element \<E\> with attribute A containing word 'w' (css: E[A~='w'])
| `//E[matches(@A, "r")]` | element \<E\> with attribute A matching regex ‘r’
| `//E1[@id=I1] \| //E2[@id=I2]` | element \<E1\> with id I1 or element \<E2\> with id I2 (css: E1#I1, E2#I2)
| `//E1[@id=I1 or @id=I2]` | element \<E1\> with id I1 or id I2 (css: E1#I1, E1#I2)
## 3. Attribute.
| XPath | Description |
| -------------- | ----------- |
| `//E/@A` | attribute A of element \<E\> (css: E@A)
| `//*/@A` | attribute A of any element (css: *@A)
| `//E[@A2="t"]/@A1` | attribute A1 of element \<E\> where attribute A2 is 't' exactly (css: E[A2='t']@A1)
| `//E[contains(@A,"t")]/@A` | attribute A of element \<E\> where A contains 't' (css: E[A*='t']@A)
## 4. ID and Name.
| XPath | Description |
| -------------- | ----------- |
| `//*[@id="I"]` | element with id I (css: #I)
| `//E[@id="I"]` | element \<E\> with id I (css: E#I)
| `//*[@name="N"]` | element with name (css: [name='N'])
| `//E[@name="N"]` | element \<E\> with name (css: E[name='N'])
| `//*[@id="X" or @name="X"]` | element with id X or, failing that, a name X
| `//*[@name="N"][v+1]` | element with name N & specified 0-based index ‘v’ (css: [name='N']:nth-child(v+1))
| `//*[@name="N"][@value="v"]` | element with name N & specified value ‘v’ (css: *[name='N'][value='v’])
## 5. Lang and Class.
| XPath | Description |
| -------------- | ----------- |
| `//E[@lang="L" or starts-with(@lang, concat("L", "-"))]` | element \<E\> is explicitly in language L or subcode (css: E[lang\|=L])
| `//*[contains(concat(" ", @class, " "), " C ")]` | element with a class C (css: .C)
| `//E[contains(concat(" ", @class, " "), " C ")]` | element \<E\> with a class C (css: E.C)
## 6. Text and Link.
| XPath | Description |
| -------------- | ----------- |
| `//*[.="t"]` | element containing text 't' exactly
| `//E[contains(text(), "t")]` | element \<E\> containing text 't' (css: E:contains('t'))
| `//a` | link element (css: a)
| `//a[.="t"]` | element \<a\> containing text 't' exactly
| `//a[contains(text(), "t")]` | element \<a\> containing text 't' (css: a:contains('t'))
| `//a[@href="url"]` | \<a\> with target link 'url' (css: a[href='url'])
| `//a[.="t"]/@href` | link URL labeled with text 't' exactly
## 7. Parent and Child.
| XPath | Description |
| -------------- | ----------- |
| `//E/*[1]` | first child of element \<E\> (css: E > *:first-child)
| `//E[1]` | first \<E\> child (css: E:first-of-type)
| `//E/*[last()]` | last child of element E (css: E *:last-child)
| `//E[last()]` | last \<E\> child (css: E:last-of-type)
| `//E[2]` | second \<E\> child (css: E:nth-of-type(2))
| `//*[2][name()="E"]` | second child that is an \<E\> element (css: E:nth-child(2))
| `//E[last()-1]` | second-to-last \<E\> child (css: E:nth-last-of-type(2))
| `//*[last()-1][name()="E"]` | second-to-last child that is an \<E\> element (css: E:nth-last-child(2))
| `//E1/[E2 and not( *[not(self::E2)])]` | element \<E1\> with only \<E2\> children
| `//E/..` | parent of element \<E\>
| `//*[@id="I"]/.../.../.../E` | descendant \<E\> of element with id I using specific path (css: #I > … > … > … > E)
| `//*[@id="I"]//E` | descendant \<E\> of element with id I using unspecified path (css: #I E)
| `//E[count(*)=0]` | element \<E\> with no children (E:empty)
| `//E[count(*)=1]` | element \<E\> with an only child
| `//E[count(preceding-sibling::*)+count(following-sibling::*)=0]` | element \<E\> that is an only child (css: E:only-child)
| `//E[count(../E) = 1]` | element \<E\> with no \<E\> siblings (css: E:only-of-type)
| `//E[position() mod N = M + 1]` | every Nth element starting with the (M+1)th (css: E:nth-child(Nn+M))
## 8. Sibling.
| XPath | Description |
| -------------- | ----------- |
| `//E2/following-sibling::E1` | element \<E1\> following some sibling \<E2\> (css: E2 ~ E1)
| `//E2/following-sibling::*[1][name()="E1"]` | element \<E1\> immediately following sibling \<E2\> (css: E2 + E1)
| `//E2/following-sibling::*[2][name()="E1"]` | element \<E1\> following sibling \<E2\> with one intermediary (css: E2 + * + E1)
| `//E/following-sibling::*` | sibling element immediately following \<E\> (css: E + *)
| `//E2/preceding-sibling::E1` | element \<E1\> preceding some sibling \<E2\>
| `//E2/preceding-sibling::*[1][name()="E1"]` | element \<E1\> immediately preceding sibling \<E2\>
| `//E2/preceding-sibling::*[2][name()="E1"]` | element \<E1\> preceding sibling \<E2\> with one intermediary
| `//E/preceding-sibling::*[1]` | sibling element immediately preceding \<E\>
## 9. Table Cell.
| XPath | Description |
| -------------- | ----------- |
| `//*[@id="TestTable"]//tr[3]//td[2]` | cell by row and column (e.g. 3rd row, 2nd column) (css: #TestTable tr:nth-child(3) td:nth-child(2))
| `//td[preceding-sibling::td="t"]` | cell immediately following cell containing 't' exactly
| `td[preceding-sibling::td[contains(.,"t")]]` | cell immediately following cell containing 't' (css: td:contains('t') ~ td)
## 10. Dynamic.
| XPath | Description |
| -------------- | ----------- |
| `//E[@disabled]` | user interface element \<E\> that is disabled (css: E:disabled)
| `//*[not(@disabled)]` | user interface element that is enabled (css: E:enabled)
| `//*[@checked]` | checkbox (or radio button) that is checked (css: *:checked)
## 11. XPath Functions.
> https://developer.mozilla.org/en-US/docs/Web/XPath/Functions
### 11.1. Conversion.
| XPath | Description |
| -------------- | ----------- |
| `boolean(expression)` | evaluates an expression and returns true or false.
| `string([object])` | converts the given argument to a string.
| `number([object])` | converts an object to a number and returns the number.
### 11.2. Math.
| XPath | Description |
| -------------- | ----------- |
| `ceiling(number)` | evaluates a decimal number and returns the smallest integer greater than or equal to the decimal number.
| `floor(number)` | evaluates a decimal number and returns the largest integer less than or equal to the decimal number.
| `round(decimal)` | returns a number that is the nearest integer to the given number.
| `sum(node-set)` | returns a number that is the sum of the numeric values of each node in a given node-set.
### 11.3. Logic.
| XPath | Description |
| -------------- | ----------- |
| `true()` | returns a boolean value of true.
| `false()` | returns boolean false.
| `not(expression)` | evaluates a boolean expression and returns the opposite value.
### 11.4. Node.
| XPath | Description |
| -------------- | ----------- |
| `lang(string)` | determines whether the context node matches the given language and returns boolean true or false.
| `name([node-set])` | returns a string representing the QName of the first node in a given node-set.
| `namespace-uri([node-set])` | returns a string representing the namespace URI of the first node in a given node-set.
### 11.5. Context.
| XPath | Description |
| -------------- | ----------- |
| `count(node-set)` | counts the number of nodes in a node-set and returns an integer.
| `function-available(name)` | determines if a given function is available and returns boolean true or false.
| `last()` | returns a number equal to the context size from the expression evaluation context.
| `position()` | returns a number equal to the context position from the expression evaluation context.
### 11.6. String.
| XPath | Description |
| -------------- | ----------- |
| `contains(haystack-string, needle-string)` | determines whether the first argument string contains the second argument string and returns boolean true or false.
| `concat(string1, string2 [stringn]*)` | concatenates two or more strings and returns the resulting string.
| `normalize-space(string)` | strips leading and trailing white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string.
| `starts-with(haystack, needle)` | checks whether the first string starts with the second string and returns true or false.
| `string-length([string])` | returns a number equal to the number of characters in a given string.
| `substring(string, start [length])` | returns a part of a given string.
| `substring-after(haystack, needle)` | returns a string that is the rest of a given string after a given substring.
| `substring-before(haystack, needle)` | returns a string that is the rest of a given string before a given substring.
| `translate(string, abc, XYZ)` | evaluates a string and a set of characters to translate and returns the translated string.
## 12. XPath Axes.
| XPath | Description |
| -------------- | ----------- |
| `ancestor` | indicates all the ancestors of the context node beginning with the parent node and traveling through to the root node.
| `ancestor-or-self` | indicates the context node and all of its ancestors, including the root node.
| `attribute (@)` | indicates the attributes of the context node. Only elements have attributes. This axis can be abbreviated with the at sign (@).
| `child (/)` | indicates the children of the context node. If an XPath expression does not specify an axis, this is understood by default. Since only the root node or element nodes have children, any other use will select nothing.
| `descendant (//)` | indicates all of the children of the context node, and all of their children, and so forth. Attribute and namespace nodes are not included - the parent of an attribute node is an element node, but attribute nodes are not the children of their parents.
| `descendant-or-self` | indicates the context node and all of its descendants. Attribute and namespace nodes are not included - the parent of an attribute node is an element node, but attribute nodes are not the children of their parents.
| `following` | indicates all the nodes that appear after the context node, except any descendant, attribute, and namespace nodes.
| `following-sibling` | indicates all the nodes that have the same parent as the context node and appear after the context node in the source document.
| `parent(..)` | indicates the single node that is the parent of the context node. It can be abbreviated as two periods (..).
| `preceding` | indicates all the nodes that precede the context node in the document except any ancestor, attribute and namespace nodes.
| `preceding-sibling` | indicates all the nodes that have the same parent as the context node and appear before the context node in the source document.
| `self (.)` | indicates the context node itself. It can be abbreviated as a single period (.).
-32
View File
@@ -1,32 +0,0 @@
<script setup lang="ts">
import { useThemeVars } from 'naive-ui';
import Memo from './xpath-memo.md';
const themeVars = useThemeVars();
</script>
<template>
<div>
<Memo style="overflow-x: auto;" />
</div>
</template>
<style lang="less" scoped>
::v-deep(pre) {
margin: 0;
padding: 15px 22px;
background-color: v-bind('themeVars.cardColor');
border-radius: 4px;
overflow: auto;
}
::v-deep(table) {
border-collapse: collapse;
}
::v-deep(table), ::v-deep(td), ::v-deep(th) {
border: 1px solid v-bind('themeVars.textColor1');
padding: 5px;
}
::v-deep(a) {
color: v-bind('themeVars.textColor1');
}
</style>
+3 -1
View File
@@ -15,6 +15,7 @@ import { VitePWA } from 'vite-plugin-pwa';
import markdown from 'vite-plugin-vue-markdown';
import svgLoader from 'vite-svg-loader';
import { configDefaults } from 'vitest/config';
import { nodePolyfills } from 'vite-plugin-node-polyfills'
const baseUrl = process.env.BASE_URL ?? '/';
@@ -97,6 +98,7 @@ export default defineConfig({
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
}),
Unocss(),
nodePolyfills(),
],
base: baseUrl,
resolve: {
@@ -113,4 +115,4 @@ export default defineConfig({
build: {
target: 'esnext',
},
});
});