1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-16 13:59:59 +00:00

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

View file

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

View file

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