Added a preview for latex rendered unit and symbol to parameters

This commit is contained in:
Jan Böhmer 2022-09-05 17:20:36 +02:00
parent 9a7e47863b
commit 34053f6591
2 changed files with 23 additions and 2 deletions

View file

@ -0,0 +1,21 @@
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));
}
}