mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 02:34:45 +08:00
Names refactoring
This commit is contained in:
@@ -123,6 +123,10 @@ export default class BlueprintTemplate extends ITemplate {
|
||||
}
|
||||
}
|
||||
|
||||
getComments() {
|
||||
return this.element.querySelectorAll(`ueb-node[data-type="${Configuration.nodeType.comment}"]`)
|
||||
}
|
||||
|
||||
/** @param {PinReferenceEntity} pinReference */
|
||||
getPin(pinReference) {
|
||||
return /** @type {PinElement} */(this.element.querySelector(
|
||||
|
||||
@@ -48,8 +48,7 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
|
||||
setSizeX(value) {
|
||||
value = Math.round(value)
|
||||
if (value >= Configuration.gridSet * Configuration.gridSize) {
|
||||
this.element.sizeX = value
|
||||
this.element.entity.setNodeWidth(this.element.sizeX)
|
||||
this.element.setNodeWidth(value)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -59,8 +58,7 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
|
||||
setSizeY(value) {
|
||||
value = Math.round(value)
|
||||
if (value >= 3 * Configuration.gridSize) {
|
||||
this.element.sizeY = Math.max(value, 3 * Configuration.gridSize)
|
||||
this.element.entity.setNodeHeight(this.element.sizeY)
|
||||
this.element.setNodeHeight(value)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -77,7 +77,7 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
|
||||
/** @param {String[]?} values */
|
||||
setInputs(values = [], updateDefaultValue = true) {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error
|
||||
this.#inputContentElements.forEach(this.constructor.singleLineInput
|
||||
? (elem, i) => elem.innerText = values[i]
|
||||
: (elem, i) => elem.innerText = values[i].replaceAll("\n", "")
|
||||
@@ -85,7 +85,7 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
if (updateDefaultValue) {
|
||||
this.setDefaultValue(values.map(v => IInputPinTemplate.stringFromInputToUE(v)), values)
|
||||
}
|
||||
this.element.addNextUpdatedCallbacks(() => this.element.nodeElement.dispatchReflowEvent())
|
||||
this.element.addNextUpdatedCallbacks(() => this.element.nodeElement.acknowledgeReflow())
|
||||
}
|
||||
|
||||
setDefaultValue(values = [], rawValues = values) {
|
||||
|
||||
@@ -130,13 +130,13 @@ export default class IResizeableTemplate extends NodeTemplate {
|
||||
|
||||
/** @param {Number} value */
|
||||
setSizeX(value) {
|
||||
this.element.sizeX = value
|
||||
this.element.setNodeWidth(value)
|
||||
return true
|
||||
}
|
||||
|
||||
/** @param {Number} value */
|
||||
setSizeY(value) {
|
||||
this.element.sizeY = value
|
||||
this.element.setNodeHeight(value)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import ITemplate from "./ITemplate"
|
||||
export default class InputTemplate extends ITemplate {
|
||||
|
||||
#focusHandler = () => {
|
||||
this.element.blueprint.dispatchEditTextEvent(true)
|
||||
this.element.blueprint.acknowledgeEditText(true)
|
||||
if (this.element.selectOnFocus) {
|
||||
getSelection().selectAllChildren(this.element)
|
||||
}
|
||||
}
|
||||
#focusoutHandler = () => {
|
||||
this.element.blueprint.dispatchEditTextEvent(false)
|
||||
this.element.blueprint.acknowledgeEditText(false)
|
||||
document.getSelection()?.removeAllRanges() // Deselect eventually selected text inside the input
|
||||
}
|
||||
#inputSingleLineHandler =
|
||||
|
||||
@@ -34,7 +34,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
|
||||
toggleAdvancedDisplayHandler = () => {
|
||||
this.element.toggleShowAdvancedPinDisplay()
|
||||
this.element.addNextUpdatedCallbacks(() => this.element.dispatchReflowEvent(), true)
|
||||
this.element.addNextUpdatedCallbacks(() => this.element.acknowledgeReflow(), true)
|
||||
}
|
||||
|
||||
/** @param {NodeElement} element */
|
||||
@@ -130,7 +130,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
firstUpdated(changedProperties) {
|
||||
super.firstUpdated(changedProperties)
|
||||
this.setupPins()
|
||||
Promise.all(this.element.getPinElements().map(n => n.updateComplete)).then(() => this.element.dispatchReflowEvent())
|
||||
Promise.all(this.element.getPinElements().map(n => n.updateComplete)).then(() => this.element.acknowledgeReflow())
|
||||
}
|
||||
|
||||
setupPins() {
|
||||
|
||||
@@ -72,7 +72,7 @@ export default class PinTemplate extends ITemplate {
|
||||
if (this.element.isInput() && changedProperties.has("isLinked")) {
|
||||
// When connected, an input may drop its input fields which means the node has to reflow
|
||||
const node = this.element.nodeElement
|
||||
node.addNextUpdatedCallbacks(() => node.dispatchReflowEvent())
|
||||
node.addNextUpdatedCallbacks(() => node.acknowledgeReflow())
|
||||
node.requestUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user