Fixing history rendering of expressions
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ad5001 2022-10-20 16:44:11 +02:00
parent 3cd4ad6a20
commit 7e427e5bb9
Signed by: Ad5001
GPG key ID: 7251B1AF90B960F9
2 changed files with 6 additions and 3 deletions

View file

@ -42,7 +42,7 @@ class EditedProperty extends C.Action {
this.newValue = newValue
this.propertyType = Objects.types[targetType].properties()[targetProperty]
if(valueIsExpressionNeedingImport) {
if(this.propertyType == "Expression") {
if(typeof this.propertyType == 'object' && this.propertyType.type == "Expression") {
this.previousValue = new MathLib.Expression(this.previousValue);
this.newValue = new MathLib.Expression(this.newValue);
} else if(this.propertyType == "Domain") {
@ -98,6 +98,10 @@ class EditedProperty extends C.Action {
this.prevString = JSON.stringify(this.previousValue)
this.nextString = JSON.stringify(this.newValue)
break;
case "Expression":
this.prevString = this.previousValue == null ? "null" : this.previousValue.toString()
this.nextString = this.newValue == null ? "null" : this.newValue.toString()
break;
}
} else {
this.prevString = this.previousValue == null ? "null" : this.previousValue.toString()
@ -106,7 +110,7 @@ class EditedProperty extends C.Action {
// HTML
this.prevHTML = '<tt style="background: rgba(128,128,128,0.1);">&nbsp;'+this.prevString+'&nbsp;</tt>'
this.nextHTML = '<tt style="background: rgba(128,128,128,0.1);">&nbsp;'+this.nextString+'&nbsp;</tt>'
if(Latex.enabled && this.propertyType == "Expression") {
if(Latex.enabled && typeof this.propertyType == 'object' && this.propertyType.type == "Expression") {
this.prevHTML= this.renderLatexAsHtml(this.previousValue.latexMarkup)
this.nextHTML= this.renderLatexAsHtml(this.newValue.latexMarkup)
}

View file

@ -63,7 +63,6 @@ class Expression {
return this.cachedValue
}
C.currentVars = Object.assign({'x': x}, C.currentObjectsByName)
//console.log("Executing", this.expr, "with", JSON.stringify(C.currentVars))
return this.calc.evaluate(C.currentVars)
}