File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed
src/tools/text-statistics Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,9 @@ declare module '@vue/runtime-core' {
144
144
NLayoutSider : typeof import ( 'naive-ui' ) [ 'NLayoutSider' ]
145
145
NMenu : typeof import ( 'naive-ui' ) [ 'NMenu' ]
146
146
NScrollbar : typeof import ( 'naive-ui' ) [ 'NScrollbar' ]
147
+ NSpace : typeof import ( 'naive-ui' ) [ 'NSpace' ]
147
148
NSpin : typeof import ( 'naive-ui' ) [ 'NSpin' ]
149
+ NStatistic : typeof import ( 'naive-ui' ) [ 'NStatistic' ]
148
150
NumeronymGenerator : typeof import ( './src/tools/numeronym-generator/numeronym-generator.vue' ) [ 'default' ]
149
151
OtpCodeGeneratorAndValidator : typeof import ( './src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue' ) [ 'default' ]
150
152
PasswordStrengthAnalyser : typeof import ( './src/tools/password-strength-analyser/password-strength-analyser.vue' ) [ 'default' ]
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
- import { getStringSizeInBytes } from ' ./text-statistics.service' ;
2
+ import { getStringSizeInBytes , textStatistics } from ' ./text-statistics.service' ;
3
3
import { formatBytes } from ' @/utils/convert' ;
4
4
5
5
const text = ref (' ' );
6
+ const stats = computed (() => textStatistics (text .value ));
6
7
</script >
7
8
8
9
<template >
9
10
<c-card >
10
11
<c-input-text v-model:value =" text" multiline placeholder =" Your text..." rows =" 5" />
11
12
12
- <div mt-5 flex >
13
- <n-statistic label =" Character count" :value =" text.length" flex-1 />
14
- <n-statistic label =" Word count" :value =" text === '' ? 0 : text.split(/\s+/).length" flex-1 />
15
- <n-statistic label =" Line count" :value =" text === '' ? 0 : text.split(/\r\n|\r|\n/).length" flex-1 />
16
- <n-statistic label =" Byte size" :value =" formatBytes(getStringSizeInBytes(text))" flex-1 />
17
- </div >
13
+ <n-space mt-3 >
14
+ <n-statistic label =" Character count" :value =" stats.chars" />
15
+ <n-statistic label =" Word count" :value =" stats.words" />
16
+ <n-statistic label =" Sentences count" :value =" stats.sentences" />
17
+ <n-statistic label =" Line count" :value =" stats.lines" />
18
+ <n-statistic label =" Byte size" :value =" formatBytes(getStringSizeInBytes(text))" />
19
+ </n-space >
20
+
21
+ <n-divider />
22
+
23
+ <n-space >
24
+ <n-statistic label =" Chars (no spaces)" :value =" stats.chars_no_spaces" />
25
+ <n-statistic label =" Uppercase chars" :value =" stats.chars_upper" />
26
+ <n-statistic label =" Lowercase chars" :value =" stats.chars_lower" />
27
+ <n-statistic label =" Digit chars" :value =" stats.chars_digits" />
28
+ <n-statistic label =" Punctuations" :value =" stats.chars_puncts" />
29
+ <n-statistic label =" Spaces chars" :value =" stats.chars_spaces" />
30
+ <n-statistic label =" Word count (no punct)" :value =" stats.words_no_puncs" />
31
+ </n-space >
18
32
</c-card >
19
33
</template >
You can’t perform that action at this time.
0 commit comments