Fix names and strings

This commit is contained in:
barsdeveloper
2022-05-03 22:12:22 +02:00
parent 2617e15691
commit 5f4b35427e
8 changed files with 34 additions and 35 deletions

View File

@@ -203,8 +203,7 @@ export default class Utility {
static formatStringName(value) {
return value
.trim()
.replaceAll(/\s+/g, " ") // Multiple spaces is just a single normal space
.replace(/^b/, "") // Remove leading b (for boolean values)
.replaceAll(/(?<=[a-z])(?=[A-Z])|_/g, " ") // Insert a space between
.replace(/(?<!\n)^(b|\n+|(?:\\r\\n)+|(?:\\n)+)/, "") // Remove leading b (for boolean values) or newlines
.replaceAll(/(?<=[a-z])(?=[A-Z])|_|\s+/g, " ") // Insert a space between a lowercase and uppercase letter, instead of an underscore or multiple spaces
}
}

View File

@@ -76,7 +76,7 @@ export default class PinElement extends IElement {
getPinDisplayName() {
if (this.entity.PinToolTip) {
const matchResult = this.entity.PinToolTip.match(/\s*(.+?(?=\\n)|.+\S)\s*/) // Match up until the first \n
return matchResult[1]
return Utility.formatStringName(matchResult[1])
}
return Utility.formatStringName(this.entity.PinName)
}

View File

@@ -72,7 +72,7 @@ export default class IInputPinTemplate extends PinTemplate {
* @param {PinElement} pin
*/
getInputs(pin) {
return this.#inputContentElements.map(element => Utility.encodeInputString(element.innerText))
return this.#inputContentElements.map(element => Utility.encodeInputString(element.textContent))
}
/**
@@ -80,8 +80,8 @@ export default class IInputPinTemplate extends PinTemplate {
* @param {String[]?} values
*/
setInputs(pin, values = []) {
pin.entity.DefaultValue = this.getInput(pin)
this.#inputContentElements.forEach((element, i) => element.innerText = Utility.decodeInputString(values[i]))
pin.entity.DefaultValue = this.getInput(pin)
}
/**