-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
59 lines (50 loc) · 1.63 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
import { Editor, MarkdownView, Plugin } from 'obsidian';
import { blogModal } from 'src/blogModal';
import { docsModal } from 'src/docsModal';
import { createBlogFrontMatter, createDocsFrontMatter, createMinutesFrontMatter } from 'src/createFrontMatter';
import { minutesModal } from 'src/minutesModal';
interface PluginSettings {
mySetting: string;
}
const DEFAULT_SETTINGS: PluginSettings = {
mySetting: 'default'
}
export default class Clerk extends Plugin {
settings: PluginSettings;
async onload() {
await this.loadSettings();
this.addCommand({
id: 'open-blog-modal',
name: 'Create a new blog post',
editorCallback: (editor: Editor, view: MarkdownView) => {
new blogModal(this.app, (result) => {
editor.replaceSelection(createBlogFrontMatter(result.title, result.tags, result.author));
}).open();
}
});
this.addCommand({
id: 'open-docs-modal',
name: 'Create a docs page',
editorCallback: (editor: Editor, view: MarkdownView) => {
new docsModal(this.app, (result) => {
editor.replaceSelection(createDocsFrontMatter(result.title, result.tags));
}).open();
}
});
this.addCommand({
id: 'open-meetings-modal',
name: 'Create meeting minutes',
editorCallback: (editor: Editor, view: MarkdownView) => {
new minutesModal(this.app, (result) => {
editor.replaceSelection(createMinutesFrontMatter(result.title, result.attending, result.chair, result.meetingGroup, result.meetingAuthor));
}).open();
}
});
}
async loadSettings() {
this.settings = { ...DEFAULT_SETTINGS, ...await this.loadData()};
}
async saveSettings() {
await this.saveData(this.settings);
}
}