From 82fac767b602f610de978b2035130ae0a789c571 Mon Sep 17 00:00:00 2001 From: Burak Date: Sun, 12 Jan 2025 17:41:46 +0300 Subject: [PATCH] update counting code in menu --- packages/app-desktop/src/features/editor/editor-menu.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/app-desktop/src/features/editor/editor-menu.tsx b/packages/app-desktop/src/features/editor/editor-menu.tsx index 10dbf28..ad5cfc1 100644 --- a/packages/app-desktop/src/features/editor/editor-menu.tsx +++ b/packages/app-desktop/src/features/editor/editor-menu.tsx @@ -1,3 +1,4 @@ +import { countWords } from "@darkwrite/common"; import { DropdownMenu, DropdownMenuContent, @@ -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 }); };