fix: post length should account for draft mentions (#1202)

pull/1218/head
Emily Medhurst 2023-01-16 10:24:29 +00:00 zatwierdzone przez GitHub
rodzic 46bd13310a
commit 998fa9ccb1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -61,7 +61,19 @@ const { editor } = useTiptap({
},
onPaste: handlePaste,
})
const characterCount = $computed(() => htmlToText(editor.value?.getHTML() || '').length)
const characterCount = $computed(() => {
let length = htmlToText(editor.value?.getHTML() || '').length
if (draft.mentions) {
// + 1 is needed as mentions always need a space seperator at the end
length += draft.mentions.map((mention) => {
const [handle] = mention.split('@')
return `@${handle}`
}).join(' ').length + 1
}
return length
})
async function handlePaste(evt: ClipboardEvent) {
const files = evt.clipboardData?.files