it-tools/src/tools/html-entities/html-entities.vue

65 lines
1.8 KiB
Vue
Raw Normal View History

<template>
<c-card title="Escape html entities">
2022-04-22 23:31:40 +02:00
<n-form-item label="Your string :">
<n-input
v-model:value="escapeInput"
type="textarea"
placeholder="The string to escape"
:autosize="{ minRows: 2 }"
/>
</n-form-item>
<n-form-item label="Your string escaped :">
<n-input
type="textarea"
readonly
placeholder="Your string escaped"
2022-04-22 23:31:40 +02:00
:value="escapeOutput"
:autosize="{ minRows: 2 }"
/>
</n-form-item>
<n-space justify="center">
<c-button @click="copyEscaped"> Copy </c-button>
</n-space>
</c-card>
<c-card title="Unescape html entities">
2022-04-22 23:31:40 +02:00
<n-form-item label="Your escaped string :">
<n-input
v-model:value="unescapeInput"
type="textarea"
placeholder="The string to unescape"
:autosize="{ minRows: 2 }"
/>
</n-form-item>
2022-04-22 23:31:40 +02:00
<n-form-item label="Your string unescaped :">
<n-input
:value="unescapeOutput"
type="textarea"
readonly
placeholder="Your string unescaped"
:autosize="{ minRows: 2 }"
/>
</n-form-item>
<n-space justify="center">
<c-button @click="copyUnescaped"> Copy </c-button>
</n-space>
</c-card>
</template>
<script setup lang="ts">
2022-04-22 23:31:40 +02:00
import { escape, unescape } from 'lodash';
import { computed, ref } from 'vue';
2022-04-22 23:31:40 +02:00
import { useCopy } from '@/composable/copy';
2022-04-22 23:31:40 +02:00
const escapeInput = ref('<title>IT Tool</title>');
const escapeOutput = computed(() => escape(escapeInput.value));
const { copy: copyEscaped } = useCopy({ source: escapeOutput });
2022-04-22 23:31:40 +02:00
const unescapeInput = ref('&lt;title&gt;IT Tool&lt;/title');
const unescapeOutput = computed(() => unescape(unescapeInput.value));
const { copy: copyUnescaped } = useCopy({ source: unescapeOutput });
</script>