aboutsummaryrefslogtreecommitdiff
path: root/src/tools/html-entities/html-entities.vue
blob: 3fd3748312cbb08f44f47e872c93e7fbe0c428d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<template>
  <n-card title="Escape html entities">
    <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
        :value="escapeOutput"
        type="textarea"
        readonly
        placeholder="Your string escaped"
        :autosize="{ minRows: 2 }"
      />
    </n-form-item>

    <n-space justify="center">
      <n-button
        secondary
        @click="copyEscaped"
      >
        Copy
      </n-button>
    </n-space>
  </n-card>
  <br>
  <n-card title="Unescape html entities">
    <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>

    <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">
      <n-button
        secondary
        @click="copyUnescaped"
      >
        Copy
      </n-button>
    </n-space>
  </n-card>
</template>

<script setup lang="ts">
import {escape,unescape} from 'lodash'
import { computed, ref } from 'vue';
 import { useCopy } from '@/composable/copy';

const escapeInput = ref('<title>IT Tool</title>')
const escapeOutput = computed(() => escape(escapeInput.value))
const {copy: copyEscaped} = useCopy({source: escapeOutput})

const unescapeInput = ref('&lt;title&gt;IT Tool&lt;/title')
const unescapeOutput = computed(() => unescape(unescapeInput.value))
const {copy: copyUnescaped} = useCopy({source: unescapeOutput})
</script>