mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-02 23:37:04 +00:00
feat: support subtreeModified
This commit is contained in:
parent
40d8260afb
commit
7eeb51cd33
@ -79,6 +79,10 @@ export class NodeChildren {
|
|||||||
return this.size > 0;
|
return this.size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed length() {
|
||||||
|
return this.children.length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除一个节点
|
* 删除一个节点
|
||||||
*/
|
*/
|
||||||
@ -94,6 +98,7 @@ export class NodeChildren {
|
|||||||
deleted.purge();
|
deleted.purge();
|
||||||
}
|
}
|
||||||
this.emitter.emit('change');
|
this.emitter.emit('change');
|
||||||
|
this.reportModified(node, this.owner, {type: 'remove', removeIndex: i, removeNode: node});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,4 +295,17 @@ export class NodeChildren {
|
|||||||
// 保证向前兼容性
|
// 保证向前兼容性
|
||||||
return "Array";
|
return "Array";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private reportModified(node: Node, owner: Node, options = {}) {
|
||||||
|
if (!node) { return; }
|
||||||
|
if (node.isRoot()) { return; }
|
||||||
|
const callbacks = owner.componentMeta.getMetadata().experimental?.callbacks;
|
||||||
|
if (callbacks?.onSubtreeModified) {
|
||||||
|
callbacks?.onSubtreeModified.call(node, owner, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (owner.parent && !owner.parent.isRoot()) {
|
||||||
|
this.reportModified(node, owner.parent, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -631,6 +631,14 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
this._slots.push(slotNode);
|
this._slots.push(slotNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除一个节点
|
||||||
|
* @param node
|
||||||
|
*/
|
||||||
|
removeChild(node: Node) {
|
||||||
|
this.children?.delete(node);
|
||||||
|
}
|
||||||
|
|
||||||
private purged = false;
|
private purged = false;
|
||||||
/**
|
/**
|
||||||
* 是否已销毁
|
* 是否已销毁
|
||||||
|
|||||||
@ -749,10 +749,7 @@ export function upgradeMetadata(oldConfig: OldPrototypeConfig) {
|
|||||||
callbacks.onNodeRemove = didDropOut;
|
callbacks.onNodeRemove = didDropOut;
|
||||||
}
|
}
|
||||||
if (subtreeModified) {
|
if (subtreeModified) {
|
||||||
callbacks.onSubtreeModified = (...args: any[]) => {
|
callbacks.onSubtreeModified = subtreeModified;
|
||||||
// FIXME! args not correct
|
|
||||||
subtreeModified.apply(args[0], args as any);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if (onResize) {
|
if (onResize) {
|
||||||
callbacks.onResize = (e: any, currentNode: any) => {
|
callbacks.onResize = (e: any, currentNode: any) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user