diff --git a/apps/client/package.json b/apps/client/package.json index c8d5fe7e..b1c935c2 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -25,6 +25,7 @@ "@tabler/icons-react": "^3.34.0", "@tanstack/react-query": "^5.80.6", "@tiptap/extension-character-count": "^2.10.3", + "alfaaz": "^1.1.0", "axios": "^1.9.0", "clsx": "^2.1.1", "emoji-mart": "^5.6.0", diff --git a/apps/client/src/features/editor/extensions/extensions.ts b/apps/client/src/features/editor/extensions/extensions.ts index eb0e62f2..96b520ad 100644 --- a/apps/client/src/features/editor/extensions/extensions.ts +++ b/apps/client/src/features/editor/extensions/extensions.ts @@ -73,6 +73,7 @@ import i18n from "@/i18n.ts"; import { MarkdownClipboard } from "@/features/editor/extensions/markdown-clipboard.ts"; import EmojiCommand from "./emoji-command"; import { CharacterCount } from "@tiptap/extension-character-count"; +import { countWords } from "alfaaz"; const lowlight = createLowlight(common); lowlight.register("mermaid", plaintext); @@ -213,7 +214,9 @@ export const mainExtensions = [ MarkdownClipboard.configure({ transformPastedText: true, }), - CharacterCount + CharacterCount.configure({ + wordCounter: (text) => countWords(text), + }), ] as any; type CollabExtensions = (provider: HocuspocusProvider, user: IUser) => any[]; @@ -229,4 +232,4 @@ export const collabExtensions: CollabExtensions = (provider, user) => [ color: randomElement(userColors), }, }), -]; \ No newline at end of file +]; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6e078f47..b248afbe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -248,6 +248,9 @@ importers: '@tiptap/extension-character-count': specifier: ^2.10.3 version: 2.14.0(@tiptap/core@2.14.0(@tiptap/pm@2.14.0))(@tiptap/pm@2.14.0) + alfaaz: + specifier: ^1.1.0 + version: 1.1.0 axios: specifier: ^1.9.0 version: 1.9.0 @@ -4680,6 +4683,9 @@ packages: ajv@8.17.1: resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} + alfaaz@1.1.0: + resolution: {integrity: sha512-J/P07R41APslK7NmD5303bwStN8jpRA4DdvtLeAr1Jhfj6XWGrASUWI0G6jbWjJAZyw3Lu1Pb4J8rsM/cb+xDQ==} + ansi-align@3.0.1: resolution: {integrity: sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==} @@ -14556,6 +14562,8 @@ snapshots: json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + alfaaz@1.1.0: {} + ansi-align@3.0.1: dependencies: string-width: 4.2.3