From da875763264a5ea72e98d259f6dd79827b6dd631 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Mon, 29 Nov 2021 15:49:55 +0100 Subject: [PATCH] Fix issue #31 --- frontend/src/mathjax-proof-tree.ts | 7 ++++--- .../content/typeinferencecontent/MathjaxProofTree.java | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/mathjax-proof-tree.ts b/frontend/src/mathjax-proof-tree.ts index 8c64f7a..bca80a0 100644 --- a/frontend/src/mathjax-proof-tree.ts +++ b/frontend/src/mathjax-proof-tree.ts @@ -79,10 +79,11 @@ class MathjaxProofTree extends MathjaxAdapter { console.time('stepCalculation'); const svg = this.shadowRoot!.querySelector("svg")!; - let root = this.shadowRoot!.querySelector("#typicalc-prooftree")! as SVGElement; + let root = this.shadowRoot!.querySelector("#typicalc-prooftree") as SVGElement || this.shadowRoot!.querySelector("semantics") as SVGElement; while (!root.getAttribute("semantics")) { root = root.parentNode! as SVGElement; } + root.id = "typicalc-prooftree"; // first, enumerate all of the steps // and assign IDs let stepIdx = 0; @@ -140,8 +141,8 @@ class MathjaxProofTree extends MathjaxAdapter { svg.viewBox.baseVal.width = Math.min(50000, svg.viewBox.baseVal.width); svg.viewBox.baseVal.width = Math.max(20000, svg.viewBox.baseVal.width); // center on first visible element - const finalConclusion = svg - .querySelector("#typicalc-prooftree > g[semantics='bspr_inferenceRule:down']")! + const finalConclusion = root + .querySelector("g[semantics='bspr_inferenceRule:down']")! .children[1]! as SVGGraphicsElement; const conclusionBBox = finalConclusion.getBBox(); const mainGroupElement = svg.children[1]! as SVGGraphicsElement; diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxProofTree.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxProofTree.java index eba1380..8c6ca81 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxProofTree.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxProofTree.java @@ -36,7 +36,7 @@ public class MathjaxProofTree extends LitTemplate implements MathjaxAdapter { */ public MathjaxProofTree(String latex, List extraData) { // step definitions used for tooltips - content.add("\\[\\cssId{typicalc-prooftree}{" + latex + "}" + String latexCode = "\\[\\cssId{typicalc-prooftree}{" + latex + "}" + "\\class{typicalc-definition}{" + "\\cssId{typicalc-definition-abs}{" + getTranslation("root.absLatex") @@ -72,7 +72,8 @@ public class MathjaxProofTree extends LitTemplate implements MathjaxAdapter { + getTranslation("root.letLatex") + "}" + "}" - + "\\]"); + + "\\]"; + content.add(latexCode); getElement().callJsFunction("requestTypeset", new Gson().toJson(extraData)); }