mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-12 17:08:14 +00:00
fix: 拖拽时要解除与原来节点的关系
This commit is contained in:
parent
2bcd87741e
commit
7a6bf2cdb4
@ -106,6 +106,13 @@ export class NodeChildren {
|
||||
});
|
||||
}
|
||||
|
||||
unlinkChild(node: Node) {
|
||||
const i = this.children.indexOf(node);
|
||||
if (i < 0) {
|
||||
return false;
|
||||
}
|
||||
this.children.splice(i, 1);
|
||||
}
|
||||
/**
|
||||
* 删除一个节点
|
||||
*/
|
||||
|
||||
@ -261,6 +261,15 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
return;
|
||||
}
|
||||
|
||||
// 解除老的父子关系,但不需要真的删除节点
|
||||
if (this._parent) {
|
||||
if (this.isSlot()) {
|
||||
this._parent.unlinkSlot(this);
|
||||
} else {
|
||||
this._parent.children.unlinkChild(this);
|
||||
}
|
||||
}
|
||||
// 建立新的父子关系
|
||||
this._parent = parent;
|
||||
if (parent) {
|
||||
this.document.removeWillPurge(this);
|
||||
@ -640,6 +649,14 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
return comparePosition(this, otherNode);
|
||||
}
|
||||
|
||||
unlinkSlot(slotNode: Node) {
|
||||
const i = this._slots.indexOf(slotNode);
|
||||
if (i < 0) {
|
||||
return false;
|
||||
}
|
||||
this._slots.splice(i, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个Slot节点
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user