mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
mobile: use word-counter from editor
This commit is contained in:
committed by
Abdullah Atta
parent
9e83e67a0b
commit
cc446f99ee
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import React, { RefObject, useEffect, useRef, useState } from "react";
|
||||
import { getTotalWords, Editor } from "@notesnook/editor";
|
||||
|
||||
function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {
|
||||
const [status, setStatus] = useState({
|
||||
@@ -66,7 +67,7 @@ function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {
|
||||
useEffect(() => {
|
||||
clearInterval(interval.current);
|
||||
interval.current = setInterval(() => {
|
||||
const words = editor?.storage?.characterCount?.words() + " words";
|
||||
const words = getTotalWords(editor as Editor) + " words";
|
||||
if (currentWords.current === words) return;
|
||||
setWords(words);
|
||||
}, 3000) as unknown as number;
|
||||
|
||||
Reference in New Issue
Block a user