-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
42 lines (36 loc) · 1003 Bytes
/
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
import {
App,
normalizePath,
Plugin,
FileManager,
TFile,
TFolder,
} from "obsidian";
import { SETTINGS } from "./settings";
import { FileWriter, PopclipSettingsTab } from "src/modules";
export default class PopclipPlugin extends Plugin {
settings: Settings;
async onload() {
await this.loadSettings();
this.addSettingTab(new PopclipSettingsTab(this.app, this));
this.registerObsidianProtocolHandler(SETTINGS.action, async (ev) => {
if (ev?.heading) {
if (ev?.heading === SETTINGS.actionHeading) {
new FileWriter(this.app, this).writeToFile(JSON.parse(ev.data));
}
} else if (!this.settings.usePopclipHeading) {
new FileWriter(this.app, this).writeToFile(JSON.parse(ev.data));
}
});
}
onunload() {
// this.app.workspace.detachLeavesOfType(VIEW_TYPE_EXAMPLE);
}
async loadSettings() {
this.settings = Object.assign({}, SETTINGS, await this.loadData());
}
async saveSettings() {
await this.saveData(this.settings);
}
async activateView() { }
}