mirror of
https://github.com/elk-zone/elk
synced 2024-11-23 22:56:09 +09:00
fix: post length should account for draft mentions (#1202)
This commit is contained in:
parent
46bd13310a
commit
998fa9ccb1
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user