Merge branch 'release/0.5.0'
This commit is contained in:
commit
b24b1e8154
3 changed files with 19 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "better-word-count",
|
||||
"name": "Better Word Count",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "Counts the words of selected text in the editor.",
|
||||
"author": "Luke Leppan",
|
||||
"authorUrl": "https://lukeleppan.com",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "better-word-count",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "Counts the words of selected text in the editor.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
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