generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsettings.ts
108 lines (98 loc) · 2.63 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { App, PluginSettingTab, Setting } from "obsidian";
import type AtomizerPlugin from "./main";
/**
* Settings interface for the Atomizer plugin
*/
export interface AtomizerSettings {
apiKey: string;
outputFolder: string;
model: string;
enableAtomizedTag: boolean;
customTags: string;
}
/**
* Default settings for the Atomizer plugin
*/
export const DEFAULT_SETTINGS: AtomizerSettings = {
apiKey: "",
outputFolder: "atomic-notes",
model: "gpt-4o-mini",
enableAtomizedTag: true,
customTags: "",
};
/**
* Settings tab for the Atomizer plugin
*/
export class AtomizerSettingTab extends PluginSettingTab {
plugin: AtomizerPlugin;
constructor(app: App, plugin: AtomizerPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const { containerEl } = this;
containerEl.empty();
new Setting(containerEl)
.setName("OpenAI API key")
.setDesc("Enter your OpenAI API key")
.addText((text) =>
text
.setPlaceholder("sk-...")
.setValue(this.plugin.settings.apiKey)
.onChange(async (value) => {
this.plugin.settings.apiKey = value;
await this.plugin.saveSettings();
}),
);
new Setting(containerEl)
.setName("Model")
.setDesc("Choose the OpenAI model to use")
.addDropdown((dropdown) =>
dropdown
.addOption("gpt-4o-mini", "GPT-4o Mini")
.addOption("gpt-4o", "GPT-4o")
.setValue(this.plugin.settings.model)
.onChange(async (value) => {
this.plugin.settings.model = value;
await this.plugin.saveSettings();
}),
);
new Setting(containerEl)
.setName("Output folder")
.setDesc("Folder where atomic notes will be created")
.addText((text) =>
text
.setPlaceholder("atomic-notes")
.setValue(this.plugin.settings.outputFolder)
.onChange(async (value) => {
this.plugin.settings.outputFolder = value;
await this.plugin.saveSettings();
}),
);
new Setting(containerEl)
.setName('Enable "atomized" tag')
.setDesc('Automatically add the "atomized" tag to generated notes')
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.enableAtomizedTag)
.onChange(async (value) => {
this.plugin.settings.enableAtomizedTag = value;
await this.plugin.saveSettings();
}),
);
new Setting(containerEl)
.setName("Custom tags")
.setDesc(
"Additional tags to add to generated notes (comma-separated)",
)
.addText((text) =>
text
.setPlaceholder("tag1, tag2, tag3")
.setValue(this.plugin.settings.customTags)
.onChange(async (value) => {
this.plugin.settings.customTags = value;
await this.plugin.saveSettings();
}),
);
}
}