it-tools/src/tools/text-statistics/text-statistics.vue

22 lines
757 B
Vue
Raw Normal View History

2022-04-14 01:06:06 +02:00
<template>
<n-card>
2022-04-22 23:31:40 +02:00
<n-input v-model:value="text" type="textarea" placeholder="Your text..." rows="5" />
<br />
<br />
2022-04-14 01:06:06 +02:00
<n-space justify="space-around">
2022-04-22 23:31:40 +02:00
<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" />
2022-04-22 23:31:40 +02:00
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" />
2022-04-14 01:06:06 +02:00
</n-space>
</n-card>
</template>
<script setup lang="ts">
2022-04-22 23:31:40 +02:00
import { formatBytes } from '@/utils/convert';
import { ref } from 'vue';
2022-04-22 23:31:40 +02:00
import { getStringSizeInBytes } from './text-statistics.service';
2022-04-14 01:06:06 +02:00
const text = ref('');
2022-04-14 01:06:06 +02:00
</script>