mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-10 13:24:40 +08:00
* Still WIP * WIP * ArrayEntity parsing fixed * Fix format text entity * Tests for various entity classes and update entity class implementations * More tests and fixed * More entities fixed * Simple entities serialization fixed * Entities tests fixed * Remove serialization bits * Fix Function reference * CustomProperties creating fixed * WIP * Better typing for grammars * Decoding code fixes * Fixing still * Several fixes * rename toString to serialize * Several fixes * More fixes * Moving more stuff out of Utility * Several fixes * Fixing Linear color entity print * Serialization fixes * Fix serialization * Method to compute grammar * Renaming fix * Fix array grammar and equality check * Fix inlined keys * Fix type * Several serialization fixes * Fix undefined dereference * Several fixes * More fixes and cleanup * Fix keys quoting mechanism * Fix natural number assignment * Fix Int64 toString() * Fix quoted keys for inlined arrays * Fix PG pins * Fix several test cases * Types fixes * New pin default value empty * Fix non existing DefaultValue for variadic nodes * Smaller fixes for crashes * Fix link color when attached to knot * Linking test and more reliability operations for adding pins * Improve issue 18 test * More tests and fixes * Fix enum pin entity * Remove failing test
101 lines
3.0 KiB
JavaScript
101 lines
3.0 KiB
JavaScript
import { html } from "lit"
|
|
import Configuration from "../../Configuration.js"
|
|
import Utility from "../../Utility.js"
|
|
import IResizeableTemplate from "../IResizeableTemplate.js"
|
|
|
|
export default class CommentNodeTemplate extends IResizeableTemplate {
|
|
|
|
#selectableAreaHeight = 0
|
|
|
|
/** @param {NodeElement} element */
|
|
initialize(element) {
|
|
super.initialize(element)
|
|
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
|
|
}
|
|
|
|
/** @returns {HTMLElement} */
|
|
getDraggableElement() {
|
|
return this.element.querySelector(".ueb-node-top")
|
|
}
|
|
|
|
render() {
|
|
return html`
|
|
<div class="ueb-node-border">
|
|
<div class="ueb-node-wrapper">
|
|
<div class="ueb-node-top"
|
|
.innerText="${Utility.encodeHTMLWhitespace(this.element.entity.NodeComment?.toString())}">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`
|
|
}
|
|
|
|
/** @param {PropertyValues} changedProperties */
|
|
firstUpdated(changedProperties) {
|
|
super.firstUpdated(changedProperties)
|
|
const bounding = this.getDraggableElement().getBoundingClientRect()
|
|
this.#selectableAreaHeight = bounding.height
|
|
}
|
|
|
|
manageNodesBind() {
|
|
let nodes = this.blueprint.getNodes()
|
|
for (let node of nodes) {
|
|
if (
|
|
node.topBoundary() >= this.element.topBoundary()
|
|
&& node.rightBoundary() <= this.element.rightBoundary()
|
|
&& node.bottomBoundary() <= this.element.bottomBoundary()
|
|
&& node.leftBoundary() >= this.element.leftBoundary()
|
|
) {
|
|
node.bindToComment(this.element)
|
|
} else {
|
|
node.unbindFromComment(this.element)
|
|
}
|
|
}
|
|
}
|
|
|
|
/** @param {Number} value */
|
|
setSizeX(value) {
|
|
value = Math.round(value)
|
|
if (value >= 2 * Configuration.gridSize) {
|
|
this.element.setNodeWidth(value)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
/** @param {Number} value */
|
|
setSizeY(value) {
|
|
value = Math.round(value)
|
|
if (value >= 2 * Configuration.gridSize) {
|
|
this.element.setNodeHeight(value)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
endResize() {
|
|
this.manageNodesBind()
|
|
}
|
|
|
|
topBoundary(justSelectableArea = false) {
|
|
return this.element.locationY
|
|
}
|
|
|
|
rightBoundary(justSelectableArea = false) {
|
|
return this.element.locationX + this.element.sizeX
|
|
}
|
|
|
|
bottomBoundary(justSelectableArea = false) {
|
|
return justSelectableArea
|
|
? this.element.locationY + this.#selectableAreaHeight
|
|
: super.bottomBoundary()
|
|
}
|
|
|
|
leftBoundary(justSelectableArea = false) {
|
|
return this.element.locationX
|
|
}
|
|
}
|