generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.ts
32 lines (21 loc) · 955 Bytes
/
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
import {MarkdownPostProcessor, Plugin} from 'obsidian';
import {Parser} from 'src/parser';
import {Renderer} from 'src/render';
// Remember to rename these classes and interfaces!
export default class MyPlugin extends Plugin {
postprocessors: Map<string, MarkdownPostProcessor> = new Map();
async onload() {
this.registerMarkdownCodeBlockProcessor("gantt", (source, element, context) => {
const parser = new Parser();
parser.Parse(source);
const renderer = new Renderer(parser.ganttInfo);
renderer.width = element.ownerDocument.getElementsByClassName("view-content")[0].clientWidth*0.95;
const graph = renderer.Render();
element.appendChild(graph);
});
// When registering intervals, this function will automatically clear the interval when the plugin is disabled.
this.registerInterval(window.setInterval(() => console.log('setInterval'), 5 * 60 * 1000));
}
onunload() {
}
}