mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 10:00:17 +05:30
feat(renderer): StatusBar reads from editor store (word count, cursor pos)
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
import { useEditorStore } from '@/stores/editor-store';
|
||||
|
||||
function countWords(text: string): number {
|
||||
return text.trim().length === 0 ? 0 : text.trim().split(/\s+/).length;
|
||||
}
|
||||
|
||||
export function StatusBar() {
|
||||
const { buffers, activeId } = useEditorStore();
|
||||
const buf = activeId ? buffers.get(activeId) : null;
|
||||
const wordCount = buf ? countWords(buf.content) : 0;
|
||||
const cursor = buf?.cursor ?? { line: 1, column: 1 };
|
||||
|
||||
return (
|
||||
<footer className="flex h-7 items-center justify-between border-t border-border bg-card/20 px-3 text-xs text-muted-foreground">
|
||||
<div className="flex items-center gap-4">
|
||||
<span>0 words</span>
|
||||
<span>{wordCount} words</span>
|
||||
<span>UTF-8</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<span>Ln 1, Col 1</span>
|
||||
<span>Ln {cursor.line}, Col {cursor.column}</span>
|
||||
<span>Markdown</span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
Reference in New Issue
Block a user