Skip to content

Commit

Permalink
update counting code in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
astudentinearth committed Jan 12, 2025
1 parent bf76a6f commit 82fac76
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/app-desktop/src/features/editor/editor-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { countWords } from "@darkwrite/common";
import {
DropdownMenu,
DropdownMenuContent,
Expand Down Expand Up @@ -35,10 +36,7 @@ export function EditorMenu() {
// we don't want to cause issues if the document is very long
const updateWordCount = async () => {
if (!editor || !content) return;
const text = editor.getText();
const words = text.match(/\b\w+\b/g)?.length ?? 0;
const characters = text.length;
console.log(words, ",", characters);
const words = countWords(editor.getText());
setCount({ words });
};

Expand Down

0 comments on commit 82fac76

Please sign in to comment.