-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.ts
84 lines (67 loc) · 2.18 KB
/
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
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
import { Plugin, App, PluginSettingTab, Setting } from 'obsidian';
import { ClipboardCommand } from 'src/command/clipboard-command';
import { CurrentFileCommand } from 'src/command/current-file-command';
import { DataviewCommand } from 'src/command/dataview-command';
import { PresentationCommand } from 'src/command/presentation-command';
import { SearchCommand } from 'src/command/search-command';
export default class FileCookerPlugin extends Plugin {
settings: FileCookerPluginSettings;
async onload() {
await this.loadSettings();
new CurrentFileCommand(this).regist();
new ClipboardCommand(this).regist();
new DataviewCommand(this).regist();
new SearchCommand(this).regist();
new PresentationCommand(this).regist();
// This adds a settings tab so the user can configure various aspects of the plugin
this.addSettingTab(new FileCookerSettingTab(this.app, this));
}
onunload() {
}
async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
}
async saveSettings() {
await this.saveData(this.settings);
}
}
const DEFAULT_SETTINGS: FileCookerPluginSettings = {
flomoAPI: '',
limit: '300'
}
interface FileCookerPluginSettings {
flomoAPI: string;
limit: string;
}
class FileCookerSettingTab extends PluginSettingTab {
plugin: FileCookerPlugin;
constructor(app: App, plugin: FileCookerPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const { containerEl } = this;
containerEl.empty();
containerEl.createEl('h2', { text: 'Settings for File Cooker!' });
new Setting(containerEl)
.setName('Limit')
.setDesc('config batch file limit')
.addText(text => text
.setPlaceholder('Enter batch file limit')
.setValue(this.plugin.settings.limit)
.onChange(async (value) => {
this.plugin.settings.limit = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('flomoAPI')
.setDesc('config flomo API to sync notes')
.addText(text => text
.setPlaceholder('Enter flomo API')
.setValue(this.plugin.settings.flomoAPI)
.onChange(async (value) => {
this.plugin.settings.flomoAPI = value;
await this.plugin.saveSettings();
}));
}
}