mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
21 lines
505 B
JavaScript
21 lines
505 B
JavaScript
|
import {Controller} from "@hotwired/stimulus";
|
||
|
import katex from "katex";
|
||
|
import "katex/dist/katex.css";
|
||
|
|
||
|
/* stimulusFetch: 'lazy' */
|
||
|
export default class extends Controller {
|
||
|
static targets = ["input", "preview"];
|
||
|
|
||
|
updatePreview()
|
||
|
{
|
||
|
katex.render(this.inputTarget.value, this.previewTarget, {
|
||
|
throwOnError: false,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
connect()
|
||
|
{
|
||
|
this.updatePreview();
|
||
|
this.inputTarget.addEventListener('input', this.updatePreview.bind(this));
|
||
|
}
|
||
|
}
|