mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 18:03:37 +02:00
Added a preview for latex rendered unit and symbol to parameters
This commit is contained in:
parent
9a7e47863b
commit
34053f6591
2 changed files with 23 additions and 2 deletions
21
assets/controllers/pages/latex_preview_controller.js
Normal file
21
assets/controllers/pages/latex_preview_controller.js
Normal 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));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue