generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
43 lines (40 loc) · 1.33 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
import { Notice, Plugin } from "obsidian";
import { getAPI } from "obsidian-dataview";
import { getFileFields, printHello } from "src/utils";
import { ExampleModal } from "modals/user-input";
export default class obsidianAntimonkey extends Plugin {
async onload() {
this.addRibbonIcon("arrow-up-circle", "Add +1 to a field", async () => {
const { update, getPropertyValue } =
this.app.plugins.plugins["metaedit"].api;
const currentFile = app.workspace.getActiveFile();
let currentValue = await getPropertyValue("inline", currentFile);
await update(
"inline",
Number.parseInt(currentValue) + 1,
currentFile
);
});
this.addRibbonIcon(
"arrow-down-circle",
"Subtract -1 from a field",
async () => {
const { autoprop } = this.app.plugins.plugins["metaedit"].api;
let result = await autoprop("inline");
console.log(result);
}
);
this.addRibbonIcon(
"dice",
"Invoke default modal",
async () => {
const { update, getPropertyValue } = this.app.plugins.plugins["metaedit"].api;
const currentFile = app.workspace.getActiveFile();
const currentValue = await getPropertyValue("inline", currentFile);
new ExampleModal(this.app, async (result) => {
await update("inline", Number.parseInt(result) + Number.parseInt(currentValue), currentFile);
}).open();
}
)
}
}