blob: 326b2b9d820d598edf7b8522132e1124ead7c31f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<template>
<n-card>
<n-input v-model:value="text" type="textarea" placeholder="Your text..." rows="5" />
<n-space justify="space-around" mt-5>
<n-statistic label="Character count" :value="text.length" />
<n-statistic label="Word count" :value="text === '' ? 0 : text.split(/\s+/).length" />
<n-statistic label="Line count" :value="text === '' ? 0 : text.split(/\r\n|\r|\n/).length" />
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" />
</n-space>
</n-card>
</template>
<script setup lang="ts">
import { formatBytes } from '@/utils/convert';
import { ref } from 'vue';
import { getStringSizeInBytes } from './text-statistics.service';
const text = ref('');
</script>
|