Skip to content

Commit

Permalink
feat: use data from statsManager to render
Browse files Browse the repository at this point in the history
Signed-off-by: edonyzpc <[email protected]>
  • Loading branch information
edonyzpc committed Mar 21, 2024
1 parent ee96bf0 commit 094d462
Show file tree
Hide file tree
Showing 10 changed files with 793 additions and 797 deletions.
13 changes: 13 additions & 0 deletions src/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// icons
export const PluginAST_STAT_ICON = "PluginAST_STAT";

// stats
export const MATCH_COMMENT = new RegExp("%%[\\s\\S]*?(?!%%)[\\s\\S]+?%%", "g");
export const MATCH_HTML_COMMENT = new RegExp(
"<!--[\\s\\S]*?(?:-->)?" +
"<!---+>?" +
"|<!(?![dD][oO][cC][tT][yY][pP][eE]|\\[CDATA\\[)[^>]*>?" +
"|<[?][^>]*>?",
"g"
);
export const STATS_FILE_NAME = "stats.json";
9 changes: 5 additions & 4 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import { ThemeUpdater } from './themeManifest';
import { monkeyPatchConsole } from './obsidian-hack/obsidian-mobile-debug';
import { CalloutModal } from './callout';
import { RecordPreview, RECORD_PREVIEW_TYPE } from './preview';
import { STAT_PREVIEW_TYPE, Stat } from './stat'
import StatsManager from './stats/StatsManager'
import { pluginField, statusBarEditorPlugin, sectionWordCountEditorPlugin } from './stats/EditorPlugin'
import { STAT_PREVIEW_TYPE, Stat } from './statsView'
import StatsManager from './stats/statsManager'
import { pluginField, statusBarEditorPlugin, sectionWordCountEditorPlugin } from './stats/editorPlugin'
import { STATS_FILE_NAME } from './constant'

const debug = (debug: boolean, ...msg: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
if (debug) console.log(...msg);
Expand Down Expand Up @@ -88,7 +89,7 @@ export class PluginManager extends Plugin {
RECORD_PREVIEW_TYPE,
(leaf) => { return new RecordPreview(this.app, this, leaf); }
);
const staticsDataDir = this.app.vault.configDir + "/vault-stats.json";
const staticsDataDir = this.app.vault.configDir + "/" + STATS_FILE_NAME;
const staticsFileData = await this.app.vault.adapter.read(staticsDataDir);
this.registerView(
STAT_PREVIEW_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { App, PluginSettingTab, Setting } from "obsidian";
import Picker from "vanilla-picker";

import { PluginManager } from "./plugin"
import { STAT_PREVIEW_TYPE } from './stat'
import { STAT_PREVIEW_TYPE } from './statsView'

export interface ResizeStyle {
width: number,
Expand Down
Loading

0 comments on commit 094d462

Please sign in to comment.