Add file count to non-markdown files #5
This commit is contained in:
parent
bc5b2f82e6
commit
f466e27884
1 changed files with 17 additions and 2 deletions
19
src/main.ts
19
src/main.ts
|
@ -1,4 +1,10 @@
|
|||
import { MarkdownView, Plugin, TFile, WorkspaceSidedock } from "obsidian";
|
||||
import {
|
||||
MarkdownView,
|
||||
Plugin,
|
||||
TFile,
|
||||
MetadataCache,
|
||||
getAllTags,
|
||||
} from "obsidian";
|
||||
import { BetterWordCountSettingsTab } from "./settings/settings-tab";
|
||||
import { BetterWordCountSettings } from "./settings/settings";
|
||||
import { StatusBar } from "./status-bar";
|
||||
|
@ -13,6 +19,8 @@ export default class BetterWordCount extends Plugin {
|
|||
let statusBarEl = this.addStatusBarItem();
|
||||
this.statusBar = new StatusBar(statusBarEl);
|
||||
|
||||
this.updateAltCount();
|
||||
|
||||
this.recentlyTyped = false;
|
||||
|
||||
this.settings = (await this.loadData()) || new BetterWordCountSettings();
|
||||
|
@ -69,7 +77,7 @@ export default class BetterWordCount extends Plugin {
|
|||
this.recentlyTyped = true;
|
||||
this.updateWordCount(contents);
|
||||
} else {
|
||||
this.updateWordCount("");
|
||||
this.updateAltCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +91,13 @@ export default class BetterWordCount extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
async updateAltCount() {
|
||||
// Thanks to Eleanor Konik for the alternate count idea.
|
||||
const files = this.app.vault.getFiles().length;
|
||||
|
||||
this.statusBar.displayText(`${files} files`);
|
||||
}
|
||||
|
||||
updateWordCount(text: string) {
|
||||
let words: number = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue