diff --git a/frontend/src/components/Editor.jsx b/frontend/src/components/Editor.jsx index 1f6f108..33271a4 100644 --- a/frontend/src/components/Editor.jsx +++ b/frontend/src/components/Editor.jsx @@ -4,6 +4,10 @@ import EnhancedPageControls from './EnhancedPageControls'; import './Editor.css'; import './LatexRenderer'; +function countWords(text) { + if (!text) return 0; + return text.trim().split(/\s+/).filter(Boolean).length; +} function EditorCanvas({ pages, currentPageIndex, @@ -21,6 +25,10 @@ function EditorCanvas({ handleDragOver, handleDragLeave, handleEditorClick + const [wordCount, setWordCount] = useState(0); + function handleInput(event) { + const text = event.target.innerText || ''; + setWordCount(countWords(text)); }) { return (
@@ -51,6 +59,9 @@ function EditorCanvas({ onClick={handleEditorClick} />
+
+

Word Count: {wordCount}

+
); }