generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
44 lines (34 loc) · 1.3 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Plugin, TFile } from "obsidian";
import P from "src/util/P";
import { settingTab, DEFAULT_SETTINGS, clusterPluginSettings } from "./src/settings/settings";
export default class clusterPlugin extends Plugin {
settings: clusterPluginSettings;
async onload() {
console.log("loading Cluster plugin");
const file = this.app.workspace.getActiveFile() as TFile;
await this.loadSettings();
this.addSettingTab(new settingTab(this.app, this));
file ? await P.buttonsLine(this.app, file, this.settings) : null;
P.addEvents(this)
P.addRibbonIcon(this);
setTimeout(() => P.newNavTreeStart(this), 500)
P.fileMenu(this, P.SimpleFocus);
P.addCommands(this);
P.unsorted.unsortedFiles(this.app);
await P.cardStyleFunction(this.settings);//card style for lorens theme
}
async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
}
async saveSettings() {
await this.saveData(this.settings);
}
async onunload() {
//FIX if there more than one file in workspace you need to remove the buttons line from them all
// Remove Buttons line
const file = this.app.workspace.getActiveFile() as TFile;
await P.buttonsLine(this.app, file, this.settings, true);
P.unsorted.unSortedObserver(this.app, false);
console.log("unloading Cluster plugin");
}
}