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()}