Last active
April 18, 2021 16:06
-
-
Save schemar/58b79e87d4858b837b0095b46dea273f to your computer and use it in GitHub Desktop.
Test Plugin with MarkdowRenderChild in CodeBlock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MarkdownRenderChild, Plugin } from 'obsidian'; | |
export default class Test extends Plugin { | |
async onload() { | |
console.log('loading plugin "test"'); | |
this.registerMarkdownCodeBlockProcessor('testlang', async (_src, el, ctx) => { | |
ctx.addChild(new TestRenderChild(el)); | |
}); | |
} | |
onunload() { | |
console.log('unloading plugin "test"'); | |
} | |
} | |
class TestRenderChild extends MarkdownRenderChild { | |
private readonly container: HTMLElement; | |
constructor(element: HTMLElement) { | |
super(); | |
this.container = element; | |
} | |
onload() { | |
console.log('load test'); | |
const div = this.container.createEl('div'); | |
div.innerHTML = 'test'; | |
} | |
onunload() { | |
console.log('unload test'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment