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