mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
feat(HTML WYSIWYG Editor): add XHTML output option
This commit is contained in:
1 parent
7ba56bf81b
commit
252b5e7696
2 files changed
+12
-2
No files matched your search
@@ -749,6 +749,7 @@ tools:
|
||||
tag-hey: Hey!
|
||||
tag-welcome-to-this-html-wysiwyg-editor: Welcome to this html wysiwyg editor
|
||||
tag-click-here-to-paste-or-edit-raw-html: Click here to paste or edit raw html
|
||||
label-xhtmlfy: 'XHtml:'
|
||||
yaml-to-toml:
|
||||
title: YAML to TOML
|
||||
description: Parse and convert YAML to TOML.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { minify, prettify } from 'htmlfy';
|
||||
import { toStrictXhtml } from '../html-to-xhtml/html-to-xhtml.service';
|
||||
import Editor from './editor/editor.vue';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
@@ -9,15 +10,20 @@ const { t } = useI18n();
|
||||
|
||||
const html = useITStorage('html-wysiwyg-editor--html', '<h1>Hey!</h1><p>Welcome to this html wysiwyg editor</p>');
|
||||
|
||||
const xhtmlOutput = useQueryParamOrStorage({ name: 'xhtml', storageName: 'html-wysiwyg-editor--xhtml', defaultValue: false });
|
||||
const minifyOutput = useQueryParamOrStorage({ name: 'minify', storageName: 'html-wysiwyg-editor--min', defaultValue: false });
|
||||
|
||||
const formattedHtml = computed(() => {
|
||||
try {
|
||||
let htmlValue = html.value;
|
||||
if (xhtmlOutput.value) {
|
||||
htmlValue = toStrictXhtml(htmlValue);
|
||||
}
|
||||
if (minifyOutput.value) {
|
||||
return minify(html.value);
|
||||
return minify(htmlValue);
|
||||
}
|
||||
|
||||
return prettify(html.value);
|
||||
return prettify(htmlValue);
|
||||
}
|
||||
catch {
|
||||
return html.value;
|
||||
@@ -43,6 +49,9 @@ const formattedHtml = computed(() => {
|
||||
<n-form-item :label="t('tools.html-wysiwyg-editor.texts.label-minify')" label-placement="left" mt-2>
|
||||
<NSwitch v-model:value="minifyOutput" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('tools.html-wysiwyg-editor.texts.label-xhtmlfy')" label-placement="left" mt-2>
|
||||
<NSwitch v-model:value="xhtmlOutput" />
|
||||
</n-form-item>
|
||||
</NSpace>
|
||||
<TextareaCopyable :value="formattedHtml" language="html" />
|
||||
</template>
|
||||
Reference in new issue
Block a user