This commit is contained in:
Johanna Stuber 2021-01-31 00:16:42 +01:00
commit e6becf6b04
5 changed files with 30 additions and 16 deletions

View File

@ -9,12 +9,27 @@ declare let window: {
};
export abstract class MathjaxAdapter extends LitElement {
protected execTypeset(shadowRoot: ShadowRoot | null) {
private execTypeset(shadowRoot: ShadowRoot | null) {
if (window.MathJax !== undefined) {
window.MathJax.typesetShadow(shadowRoot, () => this.calculateSteps());
}
}
protected requestTypeset() {
this.updateComplete.then(() => {
if (window.MathJax === undefined || !window.MathJax.isInitialized) {
window.addEventListener('mathjax-initialized', () => this.execTypeset(this.shadowRoot));
} else {
this.execTypeset(this.shadowRoot);
}
});
}
connectedCallback() {
super.connectedCallback();
this.requestTypeset();
}
render(): TemplateResult {
return html`<mjx-doc id="mjx-document"><mjx-head></mjx-head><mjx-body>
<div id="tc-content"></div>
@ -26,13 +41,13 @@ export abstract class MathjaxAdapter extends LitElement {
protected calculateSteps(): void {
}
connectedCallback() {
super.connectedCallback();
if (window.MathJax === undefined || !window.MathJax.isInitialized) {
window.addEventListener('mathjax-initialized', () => this.execTypeset(this.shadowRoot));
} else {
this.execTypeset(this.shadowRoot);
}
}
// connectedCallback() {
// super.connectedCallback();
// if (window.MathJax === undefined || !window.MathJax.isInitialized) {
// window.addEventListener('mathjax-initialized', () => this.execTypeset(this.shadowRoot));
// } else {
// this.execTypeset(this.shadowRoot);
// }
// }
}

View File

@ -20,8 +20,7 @@ class MathjaxUnification extends MathjaxAdapter {
protected showStep(n: number): void {
this.content = this.latex[n];
this.updateComplete.then(() => this.execTypeset(this.shadowRoot));
this.requestTypeset();
}
public setTex(tex: String): void {

View File

@ -1,7 +1,5 @@
package edu.kit.typicalc.view.main;
import java.util.HashMap;
import com.vaadin.flow.component.applayout.DrawerToggle;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.dialog.Dialog;
@ -12,6 +10,8 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import edu.kit.typicalc.view.content.infocontent.StartPageView;
import edu.kit.typicalc.view.main.MainView.MainViewListener;
import java.util.HashMap;
/**
* Contains all the components constantly shown in the upper part of the webage.
*/
@ -43,7 +43,7 @@ public class UpperBar extends HorizontalLayout {
this.presenter = presenter;
this.viewTitle = new H1(getTranslation("root.typicalc"));
viewTitle.addClickListener(event -> this.getUI().get().navigate(StartPageView.class));
viewTitle.addClickListener(event -> this.getUI().ifPresent(ui -> ui.navigate(StartPageView.class)));
viewTitle.setId(VIEW_TITLE_ID);
this.inputBar = new InputBar(this::typeInfer);
inputBar.setId(INPUT_BAR_ID);

View File

@ -12,7 +12,7 @@ root.absRule=Abs-Regel
abs-rule=\
\\begin{prooftree}\
\\AxiomC{$\\Gamma=\\vdash t_1 : \\tau_1 \\rightarrow \\tau_2$}\
\\AxiomC{$\\Gamma \\vdash t_1 : \\tau_1 \\rightarrow \\tau_2$}\
\
\\AxiomC{$\\Gamma \\vdash t_2 : \\tau_1$}\
\

View File

@ -8,7 +8,7 @@ root.typeInfer=Type
abs-rule=\
\\begin{prooftree}\n\
\\AxiomC{$\\Gamma=\\vdash t_1 : \\tau_1 \\rightarrow \\tau_2$}\n\
\\AxiomC{$\\Gamma \\vdash t_1 : \\tau_1 \\rightarrow \\tau_2$}\n\
\\AxiomC{$\\Gamma \\vdash t_2 : \\tau_1$}\n\
\n\
\\LeftLabel{APP}\n\