-
Notifications
You must be signed in to change notification settings - Fork 6
/
mmsettings.ts
65 lines (55 loc) · 1.82 KB
/
mmsettings.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
import { PluginSettingTab, App, Setting } from 'obsidian';
import Metatemplates from './main'
export const DEFAULT_SETTINGS: MetatemplatesSettings = {
templateFolder: 'templates',
dateFormat: 'YYMMDD',
timeFormat: 'HHmm'
}
export interface MetatemplatesSettings {
templateFolder: string;
dateFormat: string;
timeFormat: string;
}
export class MetatemplatesSettingTab extends PluginSettingTab {
plugin: Metatemplates;
constructor(app: App, plugin: Metatemplates) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
let {containerEl} = this;
containerEl.empty();
containerEl.createEl('h2', {text: 'Metatemplates Settings'});
new Setting(containerEl)
.setName('Template folder location')
.setDesc('Files in this folder will be available as templates.')
.addText(text => text
.setPlaceholder('Example: folder1/folder2')
.setValue(this.plugin.settings.templateFolder)
.onChange(async (value: string) => {
this.plugin.settings.templateFolder = value;
await this.plugin.saveSettings();
this.plugin.reloadTemplates();
}));
new Setting(containerEl)
.setName('Date format')
.setDesc('<<date>> in the template file will be replaced with this value.')
.addText(text => text
.setPlaceholder('Example: YY.MM.DD')
.setValue(this.plugin.settings.dateFormat)
.onChange(async (value: string) => {
this.plugin.settings.dateFormat = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Time format')
.setDesc('<<time>> in the template file will be replaced with this value.')
.addText(text => text
.setPlaceholder('Example: HH:mm.ss')
.setValue(this.plugin.settings.timeFormat)
.onChange(async (value: string) => {
this.plugin.settings.timeFormat = value;
await this.plugin.saveSettings();
}));
}
}