fix: respect the length seen (#1310)

This commit is contained in:
Alex Liu 2023-01-19 18:27:08 +08:00 committed by GitHub
parent 09997c2f90
commit c3b9f8fc2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View file

@ -1,5 +1,6 @@
<script setup lang="ts">
import { EditorContent } from '@tiptap/vue-3'
import stringLength from 'string-length'
import type { mastodon } from 'masto'
import type { Draft } from '~/types'
@ -62,7 +63,7 @@ const { editor } = useTiptap({
onPaste: handlePaste,
})
const characterCount = $computed(() => {
let length = htmlToText(editor.value?.getHTML() || '').length
let length = stringLength(htmlToText(editor.value?.getHTML() || ''))
if (draft.mentions) {
// + 1 is needed as mentions always need a space seperator at the end

View file

@ -58,6 +58,7 @@
"shiki": "^0.12.1",
"shiki-es": "^0.1.2",
"slimeform": "^0.8.0",
"string-length": "^5.0.1",
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log",
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store",
"tiny-decode": "^0.1.3",

View file

@ -108,6 +108,7 @@ importers:
slimeform: ^0.8.0
stale-dep: ^0.3.1
std-env: ^3.3.1
string-length: ^5.0.1
tauri-plugin-log-api: github:tauri-apps/tauri-plugin-log
tauri-plugin-store-api: github:tauri-apps/tauri-plugin-store
theme-vitesse: ^0.6.0
@ -160,6 +161,7 @@ importers:
shiki: 0.12.1
shiki-es: 0.1.2
slimeform: 0.8.0
string-length: 5.0.1
tauri-plugin-log-api: github.com/tauri-apps/tauri-plugin-log/9d2a19ad05fafeb80991006e14f0f95fe1109aba
tauri-plugin-store-api: github.com/tauri-apps/tauri-plugin-store/c71665bf5dcf48ae70a88d622eb38b2548b60a5d
tiny-decode: 0.1.3
@ -4369,7 +4371,6 @@ packages:
/ansi-regex/6.0.1:
resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==}
engines: {node: '>=12'}
dev: true
/ansi-styles/3.2.1:
resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==}
@ -4847,6 +4848,11 @@ packages:
snake-case: 3.0.4
tslib: 2.4.1
/char-regex/2.0.1:
resolution: {integrity: sha512-oSvEeo6ZUD7NepqAat3RqoucZ5SeqLJgOvVIwkafu6IP3V0pO38s/ypdVUmDDK6qIIHNlYHJAKX9E7R7HoKElw==}
engines: {node: '>=12.20'}
dev: false
/character-entities-html4/2.1.0:
resolution: {integrity: sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==}
dev: true
@ -10954,6 +10960,14 @@ packages:
engines: {node: '>=0.6.19'}
dev: true
/string-length/5.0.1:
resolution: {integrity: sha512-9Ep08KAMUn0OadnVaBuRdE2l615CQ508kr0XMadjClfYpdCyvrbFp6Taebo8yyxokQ4viUd/xPPUA4FGgUa0ow==}
engines: {node: '>=12.20'}
dependencies:
char-regex: 2.0.1
strip-ansi: 7.0.1
dev: false
/string-width/4.2.3:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'}
@ -11041,7 +11055,6 @@ packages:
engines: {node: '>=12'}
dependencies:
ansi-regex: 6.0.1
dev: true
/strip-bom/3.0.0:
resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==}