generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
88 lines (76 loc) · 2.27 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
85
86
87
88
import { Plugin, Editor, MarkdownView } from "obsidian";
import { RegisterModal } from "Modals/Register";
import { FrontmatterGeneratorModal } from "Modals/Frontmatter";
import { ChapterModal } from "Modals/Chapter";
import { addSymbol } from "helpers/inlist";
import { nestedQuote } from "helpers/quote";
const COMMAND_RegisterNote = "ノートを作る/開く";
const COMMAND_GenerateFrontmatter = "フロントマターを作る";
/*
icons
https://lucide.dev/icons/
https://docs.obsidian.md/Plugins/User+interface/Icons#Browse+available+icons
*/
export default class Yonda extends Plugin {
async onload() {
this.addRibbonIcon("book-plus", COMMAND_RegisterNote, () => {
new RegisterModal(this.app).open();
}).addClass("yonda-register-ribbon");
this.addRibbonIcon("badge-info", COMMAND_GenerateFrontmatter, () => {
new FrontmatterGeneratorModal(this.app).open();
}).addClass("yonda-generate-frontmatter-ribbon");
this.addCommand({
id: "yonda-open-register-modal",
name: COMMAND_RegisterNote,
checkCallback: (checking: boolean) => {
if (checking) {
return true;
}
new RegisterModal(this.app).open();
},
});
this.addCommand({
id: "yonda-generate-frontmatter",
name: COMMAND_GenerateFrontmatter,
checkCallback: (checking: boolean) => {
if (checking) {
return true;
}
new FrontmatterGeneratorModal(this.app).open();
},
});
this.addCommand({
id: "yonda-add-inline-quote",
name: "リスト内に引用",
icon: "quote",
editorCallback: (editor: Editor, view: MarkdownView) => {
addSymbol(">", editor, view);
},
});
this.addCommand({
id: "yonda-add-inline-bulb",
name: "リスト内に:bulb:",
icon: "lightbulb",
editorCallback: (editor: Editor, view: MarkdownView) => {
addSymbol(":bulb:", editor, view);
},
});
this.addCommand({
id: "yonda-add-inline-chapter-title",
name: "章見出しを追加",
icon: "bookmark-plus",
editorCallback: (editor: Editor, view: MarkdownView) => {
new ChapterModal(this.app, editor, view).open();
},
});
this.addCommand({
id: "yonda-add-nested-quote",
name: "ネストして引用",
icon: "text-quote",
editorCallback: (editor: Editor, view: MarkdownView) => {
nestedQuote(editor, view);
},
});
}
onunload() {}
}