Fix type highlighting when switching language

This commit is contained in:
Arne Keller 2021-10-07 11:03:39 +02:00
parent 980b2d838d
commit ed9cb6a3fa

View File

@ -392,13 +392,7 @@ class MathjaxProofTree extends MathjaxAdapter {
this.hoverStyles.id = "typicalc-hover-styles"; this.hoverStyles.id = "typicalc-hover-styles";
root.querySelector("mjx-head")!.appendChild(this.hoverStyles); root.querySelector("mjx-head")!.appendChild(this.hoverStyles);
} }
const unificationEl = root.host.parentElement!.parentElement!.querySelector("tc-unification")!; this.setupUnificationStyles();
this.hoverStylesUnification = unificationEl.shadowRoot!.querySelector("#typicalc-hover-styles");
if (!this.hoverStylesUnification) {
this.hoverStylesUnification = document.createElement('style');
this.hoverStylesUnification.id = "typicalc-hover-styles";
unificationEl.shadowRoot!.querySelector("mjx-head")!.appendChild(this.hoverStylesUnification);
}
// set the size of the rendered SVG to the size of the container element // set the size of the rendered SVG to the size of the container element
if (!root.querySelector("#style-fixes")) { if (!root.querySelector("#style-fixes")) {
const style = document.createElement('style'); const style = document.createElement('style');
@ -449,6 +443,7 @@ class MathjaxProofTree extends MathjaxAdapter {
const typeClass = typeTarget.classList[1]; const typeClass = typeTarget.classList[1];
const css = "." + typeClass + " { color: red; }"; const css = "." + typeClass + " { color: red; }";
this.hoverStyles!.innerHTML = css; this.hoverStyles!.innerHTML = css;
this.setupUnificationStyles();
this.hoverStylesUnification!.innerHTML = css; this.hoverStylesUnification!.innerHTML = css;
} else if (isLabel) { } else if (isLabel) {
let stepTarget = typeTarget; let stepTarget = typeTarget;
@ -558,6 +553,17 @@ class MathjaxProofTree extends MathjaxAdapter {
this.$server!.setStepCount(this.steps.length); this.$server!.setStepCount(this.steps.length);
} }
// creates the mirrored style document in the unification element
private setupUnificationStyles() {
const unificationEl = this.shadowRoot!.host.parentElement!.parentElement!.querySelector("tc-unification")!;
this.hoverStylesUnification = unificationEl.shadowRoot!.querySelector("#typicalc-hover-styles");
if (!this.hoverStylesUnification) {
this.hoverStylesUnification = document.createElement('style');
this.hoverStylesUnification.id = "typicalc-hover-styles";
unificationEl.shadowRoot!.querySelector("mjx-head")!.appendChild(this.hoverStylesUnification);
}
}
private destroyTooltip() { private destroyTooltip() {
const svg = this.shadowRoot!.querySelector<SVGElement>("svg"); const svg = this.shadowRoot!.querySelector<SVGElement>("svg");
if (!svg) { if (!svg) {