We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e37a346 commit 6c97d5cCopy full SHA for 6c97d5c
packages/client/pages/overview.vue
@@ -49,7 +49,20 @@ function toggleRoute(route: SlideRoute) {
49
}
50
51
function wordCount(str: string) {
52
- return str.match(/[\w`'\-]+/g)?.length || 0
+ const pattern = /[\w`'\-\u0392-\u03C9\u00C0-\u00FF\u0600-\u06FF\u0400-\u04FF]+|[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF\u3040-\u309F\uAC00-\uD7AF]+/g
53
+ const m = str.match(pattern)
54
+ let count = 0
55
+ if (!m)
56
+ return 0
57
+ for (let i = 0; i < m.length; i++) {
58
+ if (m[i].charCodeAt(0) >= 0x4E00) {
59
+ count += m[i].length
60
+ }
61
+ else {
62
+ count += 1
63
64
65
+ return count
66
67
68
function isElementInViewport(el: HTMLElement) {
0 commit comments