diff --git a/src/lib/components/ui/textarea/textarea.svelte b/src/lib/components/ui/textarea/textarea.svelte index 236b3ab..06d2bd1 100644 --- a/src/lib/components/ui/textarea/textarea.svelte +++ b/src/lib/components/ui/textarea/textarea.svelte @@ -12,6 +12,8 @@ let caretPosition = { top: 10, left: 8, height: 24 }; let lineNo = 1; let column = 1; + let characterCount = 0; // New variable for character count + // Import the textarea-caret module let getCaretCoordinates: any; let updateScheduled = false; // Flag to track if update is already scheduled @@ -33,6 +35,9 @@ // Calculate column (length of last line before caret) column = textBeforeCaret.length - textBeforeCaret.lastIndexOf('\n'); + + // Update character count + characterCount = textarea.value.length; // Update character count } } @@ -111,7 +116,9 @@
- Line: {lineNo}, Column: {column} + Line: {lineNo}, Column: {column}, + {characterCount <= 1 ? 'Character: ' : 'Characters: '} + {characterCount}