mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 21:20:28 +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;
|
||||
}
|
||||
|
||||
@computed length() {
|
||||
return this.children.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个节点
|
||||
*/
|
||||
@ -94,6 +98,7 @@ export class NodeChildren {
|
||||
deleted.purge();
|
||||
}
|
||||
this.emitter.emit('change');
|
||||
this.reportModified(node, this.owner, {type: 'remove', removeIndex: i, removeNode: node});
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -290,4 +295,17 @@ export class NodeChildren {
|
||||
// 保证向前兼容性
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个节点
|
||||
* @param node
|
||||
*/
|
||||
removeChild(node: Node) {
|
||||
this.children?.delete(node);
|
||||
}
|
||||
|
||||
private purged = false;
|
||||
/**
|
||||
* 是否已销毁
|
||||
|
||||
@ -749,10 +749,7 @@ export function upgradeMetadata(oldConfig: OldPrototypeConfig) {
|
||||
callbacks.onNodeRemove = didDropOut;
|
||||
}
|
||||
if (subtreeModified) {
|
||||
callbacks.onSubtreeModified = (...args: any[]) => {
|
||||
// FIXME! args not correct
|
||||
subtreeModified.apply(args[0], args as any);
|
||||
};
|
||||
callbacks.onSubtreeModified = subtreeModified;
|
||||
}
|
||||
if (onResize) {
|
||||
callbacks.onResize = (e: any, currentNode: any) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user