diff --git a/.gitignore b/.gitignore index 4776cd7..10185d8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ package-lock.json main.js *.js.map test-vault/ -*.zip \ No newline at end of file +*.zip + +dist/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3fa32b2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Luke Leppan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 65efa7d..cdca81c 100644 --- a/README.md +++ b/README.md @@ -2,26 +2,26 @@ ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/lukeleppan/better-word-count/Build%20Release?logo=github&style=for-the-badge) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/lukeleppan/better-word-count?style=for-the-badge) ![GitHub All Releases](https://img.shields.io/github/downloads/lukeleppan/better-word-count/total?style=for-the-badge) -This plugin is the same as the built-in **Word Count** plugin, except when you select text, it will count the selected word instead of the whole document. I recommend turning off the built-in **Word Count** because this plugin is designed to replace that. +This plugin is the same as the built-in **Word Count** plugin, except when you select text, it will count the selected word instead of the whole document. I recommend turning off the built-in **Word Count** because this plugin is designed to replace that. This plugin also has the ability to store statistics about your vault. ![Better Count Word](https://raw.githubusercontent.com/lukeleppan/better-word-count/master/assets/better-word-count.gif) ### Features -All Optional: +- Allows you to store statistics about your vault. +- Works with all languages. +- Can display a variety of different stats. Including: + - Words, Characters and Sentences in current file. + - Total Words, Characters and Sentences in vault. + - Words, Characters and Sentences typed today. + - Total Files in vault. +- Highly Customizable status bar that can be adapted to your needs. -- Show word count (total when no text selected). -- Show character count. -- Show sentence count. -- Show file count (on non-markdown windows). +#### TODO: -Works with all languages. - -#### Coming soon: - -- Complete Customization -- Customization presets -- More stats +- [ ] add statistic view +- [ ] add more statistics (make suggestions) +- [ ] add goals ### Contributors @@ -37,3 +37,6 @@ Works with all languages. - @aproximate - @Quorafind - @torantine +- @lammersma +- @aknighty74 +- @dhruvik7 diff --git a/package.json b/package.json index 44c6219..c444c31 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,13 @@ "description": "Counts the words of selected text in the editor.", "main": "main.js", "scripts": { + "lint": "svelte-check && eslint . --ext .ts", "dev": "rollup --config rollup.config.js -w", "build": "rollup --config rollup.config.js" }, + "repository": { + "url": "https://github.com/lukeleppan/better-word-count.git" + }, "keywords": [ "obsidian", "obsidian-md", @@ -18,11 +22,20 @@ "@rollup/plugin-commonjs": "^15.1.0", "@rollup/plugin-node-resolve": "^9.0.0", "@rollup/plugin-typescript": "^6.0.0", - "@types/node": "^14.14.2", + "@tsconfig/svelte": "^1.0.13", + "@types/moment": "^2.13.0", + "@types/node": "^14.17.3", "obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master", "rollup": "^2.32.1", "rollup-plugin-copy": "^3.3.0", + "rollup-plugin-svelte": "^7.1.0", + "svelte-check": "^2.2.0", + "svelte-preprocess": "^4.7.3", + "ts-node": "^9.1.1", "tslib": "^2.0.3", "typescript": "^4.0.3" + }, + "dependencies": { + "svelte": "^3.38.3" } } diff --git a/presets/default.md b/presets/default.md new file mode 100644 index 0000000..1d04638 --- /dev/null +++ b/presets/default.md @@ -0,0 +1,5 @@ +Query: +{word_count} words {character_count} characters + +Alt Query: +{files} files {total_words} words {total_characters} characters diff --git a/rollup.config.js b/rollup.config.js index d6cc18a..eb6d451 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,7 +1,9 @@ import typescript from '@rollup/plugin-typescript'; -import {nodeResolve} from '@rollup/plugin-node-resolve'; +import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import copy from 'rollup-plugin-copy'; +import svelte from "rollup-plugin-svelte"; +import autoPreprocess from "svelte-preprocess"; const TEST_VAULT = 'test-vault/.obsidian/plugins/better-word-count'; export default { @@ -15,8 +17,11 @@ export default { external: ['obsidian'], plugins: [ typescript(), - nodeResolve({browser: true}), + nodeResolve({ browser: true }), commonjs(), + svelte({ + preprocess: autoPreprocess(), + }), copy({ targets: [ { src: 'dist/main.js', dest: TEST_VAULT }, diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..bc0b177 --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,11 @@ +export const VIEW_TYPE_STATS = "vault-stats"; +export const STATS_FILE = ".vault-stats"; +export const STATS_ICON = ``; +export const STATS_ICON_NAME = "stats-graph"; +export const MATCH_COMMENT = new RegExp( + ")?" + + "