generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.ts
45 lines (36 loc) · 1.12 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
45
import { Plugin } from "obsidian";
import { DefaultSettings, EmotionPickerSettings } from "src/settings/PluginSettings";
import { addSmileIcon } from "src/SmileIcon";
import { EmotionPickerModal } from "./src/Modal";
import { EmotionPickerSettingsTab } from "src/settings/SettingsTab";
export default class EmotionPickerPlugin extends Plugin {
settings: EmotionPickerSettings;
async onload() {
// add new icon for ribbon item
addSmileIcon();
this.addRibbonIcon("smile", "Emotions Picker", (evt: MouseEvent) => {
new EmotionPickerModal(this.app, this).open();
});
this.addCommand({
id: "Open",
name: "Open",
callback: () => {
new EmotionPickerModal(this.app, this).open();
},
});
await this.loadSettings();
this.addSettingTab(new EmotionPickerSettingsTab(this.app, this));
}
onunload() {}
async loadSettings() {
this.settings = Object.assign(
{},
new DefaultSettings(),
await this.loadData()
);
}
async saveSettings() {
console.log("saving settings with emotions:", this.settings.emotions);
await this.saveData(this.settings);
}
}