Latex rendering for property edition history action!
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Ad5001 2022-10-19 17:29:35 +02:00
parent c5851e6d95
commit e98be96b0d
Signed by: Ad5001
GPG key ID: 7251B1AF90B960F9

View file

@ -19,6 +19,7 @@
.pragma library .pragma library
.import "../objects.js" as Objects .import "../objects.js" as Objects
.import "../math/latex.js" as Latex
.import "../mathlib.js" as MathLib .import "../mathlib.js" as MathLib
.import "../objs/common.js" as Common .import "../objs/common.js" as Common
.import "common.js" as C .import "common.js" as C
@ -77,30 +78,37 @@ class EditedProperty extends C.Action {
} }
setReadableValues() { setReadableValues() {
this.prev = ""; this.prevString = "";
this.next = ""; this.nextString = "";
if(this.propertyType instanceof Object) { if(this.propertyType instanceof Object) {
switch(this.propertyType.type) { switch(this.propertyType.type) {
case "Enum": case "Enum":
this.prev = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.previousValue)] this.prevString = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.previousValue)]
this.next = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.newValue)] this.nextString = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.newValue)]
break; break;
case "ObjectType": case "ObjectType":
this.prev = this.previousValue == null ? "null" : this.previousValue.name this.prevString = this.previousValue == null ? "null" : this.previousValue.name
this.next = this.newValue == null ? "null" : this.newValue.name this.nextString = this.newValue == null ? "null" : this.newValue.name
break; break;
case "List": case "List":
this.prev = this.previousValue.join(",") this.prevString = this.previousValue.join(",")
this.next = this.newValue.name.join(",") this.nextString = this.newValue.name.join(",")
break; break;
case "Dict": case "Dict":
this.prev = JSON.stringify(this.previousValue) this.prevString = JSON.stringify(this.previousValue)
this.next = JSON.stringify(this.newValue) this.nextString = JSON.stringify(this.newValue)
break; break;
} }
} else { } else {
this.prev = this.previousValue == null ? "null" : this.previousValue.toString() this.prevString = this.previousValue == null ? "null" : this.previousValue.toString()
this.next = this.newValue == null ? "null" : this.newValue.toString() this.nextString = this.newValue == null ? "null" : this.newValue.toString()
}
// 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") {
this.prevHTML= this.renderLatexAsHtml(this.previousValue.latexMarkup)
this.nextHTML= this.renderLatexAsHtml(this.newValue.latexMarkup)
} }
} }
@ -108,16 +116,14 @@ class EditedProperty extends C.Action {
return qsTr('%1 of %2 %3 changed from "%4" to "%5".') return qsTr('%1 of %2 %3 changed from "%4" to "%5".')
.arg(this.targetPropertyReadable) .arg(this.targetPropertyReadable)
.arg(Objects.types[this.targetType].displayType()) .arg(Objects.types[this.targetType].displayType())
.arg(this.targetName).arg(this.prev).arg(this.next) .arg(this.targetName).arg(this.prevString).arg(this.nextString)
} }
getHTMLString() { getHTMLString() {
return qsTr('%1 of %2 changed from %3 to %4.') return qsTr('%1 of %2 changed from %3 to %4.')
.arg(this.targetPropertyReadable) .arg(this.targetPropertyReadable)
.arg('<b style="font-size: 15px;">&nbsp;' + this.targetName + '&nbsp;</b>') .arg('<b style="font-size: 15px;">&nbsp;' + this.targetName + '&nbsp;</b>')
.arg('<tt style="background: rgba(128,128,128,0.1);">&nbsp;'+this.prev+'&nbsp;</tt>') .arg(this.prevHTML)
.arg('<tt style="background: rgba(128,128,128,0.1);">&nbsp;'+this.next+'&nbsp;</tt>') .arg(this.nextHTML)
// .arg('<b style="font-size: 15px;">' + Objects.types[this.targetType].displayType())
} }
} }