generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.ts
90 lines (79 loc) · 3.01 KB
/
settings.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { App, PluginSettingTab, Setting } from 'obsidian';
import type KoiPlugin from "main";
export interface KoiPluginSettings {
koiApiUrl: string;
koiApiKey: string;
koiApiSubscriberId: string;
koiSyncDirectoryPath: string;
templatePath: string;
initialized: boolean;
}
export const DEFAULT_SETTINGS: KoiPluginSettings = {
koiApiUrl: "",
koiApiKey: "",
koiApiSubscriberId: "",
koiSyncDirectoryPath: "telescope",
templatePath: "telescope-template.md",
initialized: false
}
export class KoiSettingTab extends PluginSettingTab {
plugin: KoiPlugin;
constructor(app: App, plugin: KoiPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const {containerEl} = this;
containerEl.empty();
new Setting(containerEl)
.setName('KOI API URL')
.setDesc('URL of the KOI API this plugin will communicate with')
.addText(text => text
.setPlaceholder('https://...')
.setValue(this.plugin.settings.koiApiUrl)
.onChange(async (value) => {
this.plugin.settings.koiApiUrl = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('KOI API Key')
.setDesc('Key for accessing KOI API')
.addText(text => text
.setPlaceholder('')
.setValue(this.plugin.settings.koiApiKey)
.onChange(async (value) => {
this.plugin.settings.koiApiKey = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('KOI API Subscriber ID')
.setDesc('Subscriber ID for receiving RID events (set automatically)')
.addText(text => text
.setPlaceholder('')
.setValue(this.plugin.settings.koiApiSubscriberId
))
.setDisabled(true);
new Setting(containerEl)
.setName('KOI Sync Directory Path')
.setDesc('Directory used to store RID objects synced through KOI')
.addText(text => text
.setPlaceholder('koi')
.setValue(this.plugin.settings.koiSyncDirectoryPath)
.onChange(async (value) => {
this.plugin.settings.koiSyncDirectoryPath = value;
await this.plugin.saveSettings();
})
)
new Setting(containerEl)
.setName('Template file location')
.setDesc('Will be used to generate documents imported from KOI')
.addText(text => text
.setPlaceholder('')
.setValue(this.plugin.settings.templatePath)
.onChange(async (value) => {
this.plugin.settings.templatePath = value;
await this.plugin.fileFormatter.compileTemplate();
await this.plugin.saveSettings();
}));
}
}