From c69eb77878fbdeaa9ff4e6f414c6e19a01a1ced0 Mon Sep 17 00:00:00 2001 From: Alice Hernandez Date: Mon, 8 Jun 2026 19:41:47 +1000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20average=20sentence=20word=20count?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/components/Editor/WordCountBar.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/renderer/components/Editor/WordCountBar.tsx b/src/renderer/components/Editor/WordCountBar.tsx index 8de67c6..a2b32cc 100644 --- a/src/renderer/components/Editor/WordCountBar.tsx +++ b/src/renderer/components/Editor/WordCountBar.tsx @@ -11,6 +11,15 @@ export function WordCountBar(): JSX.Element { const wordCount = activeStoryContent.trim() === '' ? 0 : activeStoryContent.trim().split(/\s+/).length + const avgSentenceWords = (() => { + const text = activeStoryContent.trim() + if (!text) return null + const sentences = text.split(/[.!?]+/).map((s) => s.trim()).filter((s) => s.length > 0) + if (sentences.length === 0) return null + const totalWords = sentences.reduce((sum, s) => sum + s.split(/\s+/).length, 0) + return Math.round(totalWords / sentences.length) + })() + // Determine target: story's own target, or selected market's max const target = story?.meta.wordCountTarget ?? selectedMarket?.wordCountMax ?? null @@ -43,6 +52,11 @@ export function WordCountBar(): JSX.Element { {wordCount.toLocaleString()} + {avgSentenceWords !== null && ( + + {avgSentenceWords}w/s + + )} {target && ( <> / {target.toLocaleString()}