Some minor fixes and refactoring

This commit is contained in:
barsdeveloper
2025-01-31 00:22:11 +02:00
parent 1073691794
commit 0e2ecdf93e
26 changed files with 290 additions and 87 deletions

View File

@@ -13,7 +13,7 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
element.classList.add("ueb-node-style-comment", "ueb-node-resizeable")
element.sizeX = 25 * Configuration.gridSize
element.sizeY = 6 * Configuration.gridSize
super.initialize(element) // Keep it at the end because it calls this.getColor() where this.#color must be initialized
super.initialize(element) // Keep it at the end because it needs the color. this.#color must be initialized
}
/** @returns {HTMLElement} */

View File

@@ -35,6 +35,17 @@ export default class KnotNodeTemplate extends NodeTemplate {
this.element.classList.add("ueb-node-style-minimal")
}
/** @param {PropertyValues} changedProperties */
update(changedProperties) {
super.update(changedProperties)
if (!this.#inputPin.isLinked && !this.#outputPin.isLinked) {
this.#inputPin.entity.PinType.PinCategory.value = "wildcard"
this.#inputPin.updateColor()
this.#outputPin.entity.PinType.PinCategory.value = "wildcard"
this.#inputPin.updateColor()
}
}
render() {
return html`
<div class="ueb-node-border"></div>

View File

@@ -57,17 +57,13 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
super.initialize(element)
this.#subtitle = nodeSubtitle(element.entity)
this.element.classList.add(.../** @type {typeof NodeTemplate} */(this.constructor).nodeStyleClasses)
this.element.style.setProperty("--ueb-node-color", this.getColor().cssText)
this.element.style.setProperty("--ueb-node-color", this.element.entity.nodeColor().cssText)
this.pinInserter = this.element.entity.additionalPinInserter()
if (this.pinInserter) {
this.element.classList.add("ueb-node-is-variadic")
}
}
getColor() {
return this.element.entity.nodeColor()
}
render() {
return html`
<div class="ueb-node-border">

View File

@@ -21,6 +21,6 @@ export default class VariableAccessNodeTemplate extends VariableManagementNodeTe
setupPins() {
super.setupPins()
let outputPin = this.element.getPinElements().find(p => !p.entity.isHidden() && !p.entity.isExecution())
this.element.style.setProperty("--ueb-node-color", outputPin.getColor().cssText)
this.element.style.setProperty("--ueb-node-color", outputPin.entity.pinColor().cssText)
}
}

View File

@@ -32,7 +32,9 @@ export default class InputTemplate extends ITemplate {
super.initialize(element)
this.element.classList.add("ueb-pin-input-content")
this.element.setAttribute("role", "textbox")
this.element.contentEditable = "true"
if (this.element.contentEditable !== "false") {
this.element.contentEditable = "true"
}
}
/** @param {PropertyValues} changedProperties */

View File

@@ -1,5 +0,0 @@
import MinimalPinTemplate from "./MinimalPinTemplate.js"
export default class InternalPinTemplate extends MinimalPinTemplate {
}

View File

@@ -0,0 +1,19 @@
import { html } from "lit"
import PinTemplate from "./PinTemplate.js"
/** @extends PinTemplate<StringEntity> */
export default class ReadonlyNamePinTemplate extends PinTemplate {
setDefaultValue(values = [], rawValues = values) {
}
renderInput() {
return html`
<div class="ueb-pin-input-wrapper ueb-pin-input">
<ueb-input contenteditable="false" .singleLine="${true}" .selectOnFocus="${false}"
.innerText="${this.element.entity.PinName.toString()}">
</ueb-input>
</div>
`
}
}