🐛 fix wpm calc again

This commit is contained in:
2026-06-15 22:02:20 +10:00
parent 79f42f5b0f
commit 22d664a450

View File

@@ -122,7 +122,7 @@ export function MarkdownEditor(): JSX.Element {
const now = Date.now()
// Close active interval if still ongoing
const activeMs = s.activeMs + (now - s.lastKeystroke < IDLE_MS ? now - s.intervalStart : 0)
const wordsEnd = wordCount(useBorgesStore.getState().activeStoryContent)
const wordsEnd = wordCount(viewRef.current?.state.doc.toString() ?? useBorgesStore.getState().activeStoryContent)
const durationMs = now - s.startedAt
const typedWords = wordsEnd - s.wordsStart - s.pastedWords
const wpm = activeMs > 0 ? Math.round(Math.max(0, typedWords) / (activeMs / 60_000)) : 0