mirror of
https://github.com/hyeonseonam/auto-classifier.git
synced 2026-07-22 07:40:29 +00:00
Edit view-manager.ts
This commit is contained in:
parent
8c59f55dda
commit
45cdadba67
1 changed files with 14 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { App, MarkdownView, Notice, Editor} from "obsidian";
|
||||
import { App, MarkdownView, Notice, Editor, getAllTags, TagCache} from "obsidian";
|
||||
|
||||
export class ViewManager {
|
||||
app: App;
|
||||
|
|
@ -36,6 +36,19 @@ export class ViewManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
async getTags(filterRegex?: string): Promise<string[] | null> {
|
||||
const tagsDict = this.app.metadataCache.getTags();
|
||||
let tags = Object.keys(tagsDict);
|
||||
if (!tags || tags.length == 0) return null;
|
||||
// remove #
|
||||
tags = tags.map((tag) => tag.replace(/^#/, ''));
|
||||
// filter
|
||||
if (filterRegex) {
|
||||
return tags.filter((tag) => RegExp(filterRegex).test(tag));
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
async insertAtFrontMatter(key: string, value: string, overwrite = false): Promise<void> {
|
||||
const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue