mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 23:37:30 +08:00
Fix pasted nodes links
This commit is contained in:
23
dist/ueblueprint.js
vendored
23
dist/ueblueprint.js
vendored
@@ -3998,10 +3998,14 @@ class PinElement extends IElement {
|
|||||||
this.entity.DefaultValue = value;
|
this.entity.DefaultValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
sanitizeLinks() {
|
/** @param {IElement[]} nodesWhitelist */
|
||||||
|
sanitizeLinks(nodesWhitelist = []) {
|
||||||
this.entity.LinkedTo = this.getLinks().filter(pinReference => {
|
this.entity.LinkedTo = this.getLinks().filter(pinReference => {
|
||||||
let pin = this.blueprint.getPin(pinReference);
|
let pin = this.blueprint.getPin(pinReference);
|
||||||
if (pin) {
|
if (pin) {
|
||||||
|
if (nodesWhitelist.length && !nodesWhitelist.includes(pin.nodeElement)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
let link = this.blueprint.getLink(this, pin, true);
|
let link = this.blueprint.getLink(this, pin, true);
|
||||||
if (!link) {
|
if (!link) {
|
||||||
this.blueprint.addGraphElement(new LinkElement(this, pin));
|
this.blueprint.addGraphElement(new LinkElement(this, pin));
|
||||||
@@ -4186,6 +4190,8 @@ class NodeTemplate extends SelectableDraggableTemplate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @typedef {import("./IElement").default} IElement */
|
||||||
|
|
||||||
/** @extends {ISelectableDraggableElement<ObjectEntity, NodeTemplate>} */
|
/** @extends {ISelectableDraggableElement<ObjectEntity, NodeTemplate>} */
|
||||||
class NodeElement extends ISelectableDraggableElement {
|
class NodeElement extends ISelectableDraggableElement {
|
||||||
|
|
||||||
@@ -4279,8 +4285,9 @@ class NodeElement extends ISelectableDraggableElement {
|
|||||||
return this.entity.getDisplayName()
|
return this.entity.getDisplayName()
|
||||||
}
|
}
|
||||||
|
|
||||||
sanitizeLinks() {
|
/** @param {IElement[]} nodesWhitelist */
|
||||||
this.getPinElements().forEach(pin => pin.sanitizeLinks());
|
sanitizeLinks(nodesWhitelist = []) {
|
||||||
|
this.getPinElements().forEach(pin => pin.sanitizeLinks(nodesWhitelist));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {String} name */
|
/** @param {String} name */
|
||||||
@@ -5193,12 +5200,14 @@ class Blueprint extends IElement {
|
|||||||
|
|
||||||
/** @param {PinReferenceEntity} pinReference */
|
/** @param {PinReferenceEntity} pinReference */
|
||||||
getPin(pinReference) {
|
getPin(pinReference) {
|
||||||
let result = this.template.getPin(this, pinReference);
|
let result = this.template.getPin(pinReference);
|
||||||
if (result) {
|
if (result
|
||||||
|
// Make sure it wasn't renamed in the meantime
|
||||||
|
&& result.nodeElement.getNodeName() == pinReference.objectName) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
// Slower fallback
|
||||||
return [... this.nodes
|
return [... this.nodes
|
||||||
//.filter(n => !n.parentNode)
|
|
||||||
.find(n => pinReference.objectName.toString() == n.getNodeName())
|
.find(n => pinReference.objectName.toString() == n.getNodeName())
|
||||||
?.getPinElements() ?? []]
|
?.getPinElements() ?? []]
|
||||||
.find(p => pinReference.pinGuid.toString() == p.GetPinIdValue())
|
.find(p => pinReference.pinGuid.toString() == p.GetPinIdValue())
|
||||||
@@ -5269,7 +5278,7 @@ class Blueprint extends IElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
graphElements.filter(element => element instanceof NodeElement).forEach(
|
graphElements.filter(element => element instanceof NodeElement).forEach(
|
||||||
node => /** @type {NodeElement} */(node).sanitizeLinks()
|
node => /** @type {NodeElement} */(node).sanitizeLinks(graphElements)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
dist/ueblueprint.min.js
vendored
2
dist/ueblueprint.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -279,12 +279,14 @@ export default class Blueprint extends IElement {
|
|||||||
|
|
||||||
/** @param {PinReferenceEntity} pinReference */
|
/** @param {PinReferenceEntity} pinReference */
|
||||||
getPin(pinReference) {
|
getPin(pinReference) {
|
||||||
let result = this.template.getPin(this, pinReference)
|
let result = this.template.getPin(pinReference)
|
||||||
if (result) {
|
if (result
|
||||||
|
// Make sure it wasn't renamed in the meantime
|
||||||
|
&& result.nodeElement.getNodeName() == pinReference.objectName) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
// Slower fallback
|
||||||
return [... this.nodes
|
return [... this.nodes
|
||||||
//.filter(n => !n.parentNode)
|
|
||||||
.find(n => pinReference.objectName.toString() == n.getNodeName())
|
.find(n => pinReference.objectName.toString() == n.getNodeName())
|
||||||
?.getPinElements() ?? []]
|
?.getPinElements() ?? []]
|
||||||
.find(p => pinReference.pinGuid.toString() == p.GetPinIdValue())
|
.find(p => pinReference.pinGuid.toString() == p.GetPinIdValue())
|
||||||
@@ -357,7 +359,7 @@ export default class Blueprint extends IElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
graphElements.filter(element => element instanceof NodeElement).forEach(
|
graphElements.filter(element => element instanceof NodeElement).forEach(
|
||||||
node => /** @type {NodeElement} */(node).sanitizeLinks()
|
node => /** @type {NodeElement} */(node).sanitizeLinks(graphElements)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import PinReferenceEntity from "../entity/PinReferenceEntity"
|
|||||||
import SerializerFactory from "../serialization/SerializerFactory"
|
import SerializerFactory from "../serialization/SerializerFactory"
|
||||||
import Utility from "../Utility"
|
import Utility from "../Utility"
|
||||||
|
|
||||||
|
/** @typedef {import("./IElement").default} IElement */
|
||||||
|
|
||||||
/** @extends {ISelectableDraggableElement<ObjectEntity, NodeTemplate>} */
|
/** @extends {ISelectableDraggableElement<ObjectEntity, NodeTemplate>} */
|
||||||
export default class NodeElement extends ISelectableDraggableElement {
|
export default class NodeElement extends ISelectableDraggableElement {
|
||||||
|
|
||||||
@@ -102,8 +104,9 @@ export default class NodeElement extends ISelectableDraggableElement {
|
|||||||
return this.entity.getDisplayName()
|
return this.entity.getDisplayName()
|
||||||
}
|
}
|
||||||
|
|
||||||
sanitizeLinks() {
|
/** @param {IElement[]} nodesWhitelist */
|
||||||
this.getPinElements().forEach(pin => pin.sanitizeLinks())
|
sanitizeLinks(nodesWhitelist = []) {
|
||||||
|
this.getPinElements().forEach(pin => pin.sanitizeLinks(nodesWhitelist))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {String} name */
|
/** @param {String} name */
|
||||||
|
|||||||
@@ -192,10 +192,14 @@ export default class PinElement extends IElement {
|
|||||||
this.entity.DefaultValue = value
|
this.entity.DefaultValue = value
|
||||||
}
|
}
|
||||||
|
|
||||||
sanitizeLinks() {
|
/** @param {IElement[]} nodesWhitelist */
|
||||||
|
sanitizeLinks(nodesWhitelist = []) {
|
||||||
this.entity.LinkedTo = this.getLinks().filter(pinReference => {
|
this.entity.LinkedTo = this.getLinks().filter(pinReference => {
|
||||||
let pin = this.blueprint.getPin(pinReference)
|
let pin = this.blueprint.getPin(pinReference)
|
||||||
if (pin) {
|
if (pin) {
|
||||||
|
if (nodesWhitelist.length && !nodesWhitelist.includes(pin.nodeElement)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
let link = this.blueprint.getLink(this, pin, true)
|
let link = this.blueprint.getLink(this, pin, true)
|
||||||
if (!link) {
|
if (!link) {
|
||||||
this.blueprint.addGraphElement(new LinkElement(this, pin))
|
this.blueprint.addGraphElement(new LinkElement(this, pin))
|
||||||
|
|||||||
Reference in New Issue
Block a user