mirror of
https://github.com/wassname/template.git
synced 2026-08-15 12:54:58 +08:00
Project reorganization, add editorconfig and linter
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import katex from "katex";
|
||||
import { Mutating } from "../mixins/mutating.js"
|
||||
import { Template } from "../mixins/template.js"
|
||||
import katexCSS from "../../node_modules/katex/dist/katex.min.css"
|
||||
|
||||
const T = Template("d-math", `
|
||||
<style>
|
||||
|
||||
d-math[block] {
|
||||
display: block;
|
||||
}
|
||||
|
||||
${katexCSS}
|
||||
|
||||
</style>
|
||||
|
||||
<span id="katex-container"></span>
|
||||
`);
|
||||
|
||||
export class DMath extends Mutating(T(HTMLElement)) {
|
||||
|
||||
renderContent() {
|
||||
const options = { displayMode: this.hasAttribute("block") };
|
||||
const container = this.root.querySelector("#katex-container");
|
||||
katex.render(this.textContent, container, options);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user