From f466e27884116cf19ab5420fb750abed29991ff3 Mon Sep 17 00:00:00 2001 From: Luke Leppan Date: Wed, 20 Jan 2021 00:41:11 +0200 Subject: [PATCH 1/2] Add file count to non-markdown files #5 --- src/main.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8b5eca0..5bbb555 100644 --- a/src/main.ts +++ b/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; From 02ef5383bf7b878121e4faa08fd66e8d96d539de Mon Sep 17 00:00:00 2001 From: Luke Leppan Date: Tue, 19 Jan 2021 22:53:03 +0200 Subject: [PATCH 2/2] bump --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 0a61cd6..9001f7c 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/package.json b/package.json index a17bf48..6233115 100644 --- a/package.json +++ b/package.json @@ -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": {