-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettings.ts
66 lines (60 loc) · 1.96 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
import LinkExploderPlugin from './main';
import { App, PluginSettingTab, Setting } from 'obsidian';
export class LinkExploderPluginSettings {
newFileLocation: Location = Location.VaultFolder;
customFileLocation = '';
}
export enum Location {
VaultFolder,
SameFolder,
SpecifiedFolder,
}
export class LinkExploderPluginSettingTab extends PluginSettingTab {
plugin: LinkExploderPlugin;
constructor(app: App, plugin: LinkExploderPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const { containerEl } = this;
containerEl.empty();
containerEl.createEl('h2', { text: 'Link Exploder Settings' });
new Setting(containerEl)
.setName('Default location for new canvas files')
.addDropdown((dropDown) => {
dropDown
.addOption(Location[Location.VaultFolder], 'Vault folder')
.addOption(
Location[Location.SameFolder],
'Same folder as current file'
)
.addOption(
Location[Location.SpecifiedFolder],
'In the folder specified below'
)
.setValue(
Location[this.plugin.settings.newFileLocation] ||
Location[Location.VaultFolder]
)
.onChange(async (value) => {
this.plugin.settings.newFileLocation =
Location[value as keyof typeof Location];
await this.plugin.saveSettings();
this.display();
});
});
if (this.plugin.settings.newFileLocation == Location.SpecifiedFolder) {
new Setting(containerEl)
.setName('Folder to create new canvas files in')
.addText((text) => {
text
.setPlaceholder('Example: folder 1/folder 2')
.setValue(this.plugin.settings.customFileLocation)
.onChange(async (value) => {
this.plugin.settings.customFileLocation = value;
await this.plugin.saveSettings();
});
});
}
}
}