generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
82 lines (61 loc) · 2.3 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
import { App, MarkdownPostProcessor, MarkdownPostProcessorContext, MarkdownPreviewRenderer, MarkdownRenderer, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
import { smartypants } from 'smartypants';
// interface MyPluginSettings {
// mode: number;
// }
// const DEFAULT_SETTINGS: MyPluginSettings = {
// mode: 2
// }
export default class SmartypantsPlugin extends Plugin {
// settings: MyPluginSettings;
static postprocessor: MarkdownPostProcessor = (el: HTMLElement, ctx: MarkdownPostProcessorContext) => {
// console.log("postprocessor is called")
// console.log(el)
const source = el.innerHTML
let educated = smartypants(source, 2) // @TODO use MyPluginSettings here
// console.log("educated version:")
// console.log(educated)
// el.appendChild(educated)
el.innerHTML = educated
// blockToReplace.innerHTML = educated
}
async onload() {
console.log('Loading Smartypants plugin');
// await this.loadSettings();
// this.addSettingTab(new SampleSettingTab(this.app, this));
MarkdownPreviewRenderer.registerPostProcessor(SmartypantsPlugin.postprocessor)
}
async onunload() {
console.log('Unloading smartypants plugin');
MarkdownPreviewRenderer.unregisterPostProcessor(SmartypantsPlugin.postprocessor)
}
// async loadSettings() {
// this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
// }
// async saveSettings() {
// await this.saveData(this.settings);
// }
}
// class SampleSettingTab extends PluginSettingTab {
// plugin: MyPlugin;
// constructor(app: App, plugin: MyPlugin) {
// super(app, plugin);
// this.plugin = plugin;
// }
// display(): void {
// let {containerEl} = this;
// containerEl.empty();
// containerEl.createEl('h2', {text: 'Settings for my awesome plugin.'});
// new Setting(containerEl)
// .setName('Setting #1')
// .setDesc('It\'s a secret')
// .addText(text => text
// .setPlaceholder('Enter your secret')
// .setValue('')
// .onChange(async (value) => {
// console.log('Secret: ' + value);
// this.plugin.settings.mode = value;
// await this.plugin.saveSettings();
// }));
// }
// }