Refactoring

This commit is contained in:
barsdeveloper
2022-04-02 21:16:17 +02:00
parent 6ffdcbccab
commit 7d72015bb5
13 changed files with 115 additions and 62 deletions

View File

@@ -24,20 +24,20 @@ export default class PinTemplate extends ITemplate {
render(pin) {
if (pin.isInput()) {
return html`
<span class="ueb-pin-icon">
<div class="ueb-pin-icon">
${this.renderIcon(pin)}
</span>
<span class="ueb-pin-content">
</div>
<div class="ueb-pin-content">
<span class="ueb-pin-name">${sanitizeText(pin.getPinDisplayName())}</span>
${this.renderInput(pin)}
</span>
</div>
`
} else {
return html`
<span class="ueb-pin-name">${sanitizeText(pin.getPinDisplayName())}</span>
<span class="ueb-pin-icon">
<div class="ueb-pin-name">${sanitizeText(pin.getPinDisplayName())}</div>
<div class="ueb-pin-icon">
${this.renderIcon(pin)}
</span>
</div>
`
}
}
@@ -71,7 +71,7 @@ export default class PinTemplate extends ITemplate {
pin.dataset.advancedView = "true"
}
pin.clickableElement = pin
window.customElements.whenDefined("ueb-node").then(pin.nodeElement = pin.closest("ueb-node"))
window.customElements.whenDefined("ueb-node").then(_ => pin.nodeElement = pin.closest("ueb-node"))
pin.getLinks().forEach(pinReference => {
const targetPin = pin.blueprint.getPin(pinReference)
if (targetPin) {

View File

@@ -16,14 +16,16 @@ export default class StringPinTemplate extends PinTemplate {
* @param {PinElement} pin
*/
renderInput(pin) {
const stopEventPropagation = "e => stopPropagation()"
return html`
<span class="ueb-pin-input">
<span class="ueb-pin-input-content" role="textbox" contenteditable="true"
<div class="ueb-pin-input">
<div class="ueb-pin-input-content" role="textbox" contenteditable="true"
onfocus="this.closest('ueb-blueprint')?.dispatchEditTextEvent(true)"
onfocusout="this.closest('ueb-blueprint')?.dispatchEditTextEvent(false)"
></span>
</span>
onfocusout="
this.closest('ueb-blueprint')?.dispatchEditTextEvent(false)
document.getSelection().removeAllRanges()
"
></div>
</div>
`
}
}