2022-04-05 15:02:17 +00:00
|
|
|
import { EditorView } from "@codemirror/view";
|
2022-04-25 08:33:38 +00:00
|
|
|
import * as util from "../../common/util";
|
2022-03-20 08:56:28 +00:00
|
|
|
|
|
|
|
export function StatusBar({ editorView }: { editorView?: EditorView }) {
|
|
|
|
let wordCount = 0,
|
|
|
|
readingTime = 0;
|
|
|
|
if (editorView) {
|
|
|
|
let text = editorView.state.sliceDoc();
|
|
|
|
wordCount = util.countWords(text);
|
|
|
|
readingTime = util.readingTime(wordCount);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div id="bottom">
|
2022-04-04 13:25:07 +00:00
|
|
|
<div className="inner">
|
|
|
|
{wordCount} words | {readingTime} min
|
|
|
|
</div>
|
2022-03-20 08:56:28 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|