mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00
feat(new tool): Javascript Prettier
Javascript Prettier
This commit is contained in:
parent
7616a35c41
commit
d1d2b6b36d
7 changed files with 241 additions and 18 deletions
|
@ -7,7 +7,7 @@ const outputCSS = computed(() => {
|
|||
return beautify.css(inputCSS.value, {
|
||||
indent_char: ' ',
|
||||
indent_size: 2,
|
||||
sep: '\n',
|
||||
eol: '\n',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -9,7 +9,7 @@ const outputHtml = computed(() => {
|
|||
indent_inner_html: true,
|
||||
indent_char: ' ',
|
||||
indent_size: 2,
|
||||
sep: '\n',
|
||||
eol: '\n',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -6,6 +6,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 javascriptPrettifier } from './javascript-prettifier';
|
||||
import { tool as cssPrettifier } from './css-prettifier';
|
||||
import { tool as htmlPrettifier } from './html-prettifier';
|
||||
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
|
||||
|
@ -152,6 +153,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||
yamlViewer,
|
||||
cssPrettifier,
|
||||
htmlPrettifier,
|
||||
javascriptPrettifier,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
12
src/tools/javascript-prettifier/index.ts
Normal file
12
src/tools/javascript-prettifier/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { BrandJavascript } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Javascript Prettifier',
|
||||
path: '/javascript-prettifier',
|
||||
description: 'JS/Javascript Prettifier',
|
||||
keywords: ['javascript', 'prettifier', 'beautify', 'prettier', 'format'],
|
||||
component: () => import('./javascript-prettifier.vue'),
|
||||
icon: BrandJavascript,
|
||||
createdAt: new Date('2024-03-15'),
|
||||
});
|
37
src/tools/javascript-prettifier/javascript-prettifier.vue
Normal file
37
src/tools/javascript-prettifier/javascript-prettifier.vue
Normal file
|
@ -0,0 +1,37 @@
|
|||
<script setup lang="ts">
|
||||
import beautify from 'js-beautify';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
|
||||
const inputJS = ref('');
|
||||
const outputJS = computed(() => {
|
||||
return beautify(inputJS.value, {
|
||||
indent_char: ' ',
|
||||
indent_size: 2,
|
||||
eol: '\n',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="inputJS"
|
||||
multiline raw-text
|
||||
placeholder="Your JS content..."
|
||||
rows="8"
|
||||
autofocus
|
||||
label="Your JS to format (can paste from clipboard):"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<n-form-item label="Output prettified JS:">
|
||||
<TextareaCopyable
|
||||
:value="outputJS"
|
||||
multiline
|
||||
language="javascript"
|
||||
word-wrap
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</template>
|
Loading…
Add table
Add a link
Reference in a new issue