diff --git a/packages/designer/src/document/node/node-children.ts b/packages/designer/src/document/node/node-children.ts index 0dc6264f7..80f91b430 100644 --- a/packages/designer/src/document/node/node-children.ts +++ b/packages/designer/src/document/node/node-children.ts @@ -244,7 +244,7 @@ export class NodeChildren { return this.children.some((child, index) => fn(child, index)); } - filter(fn: (item: Node, index: number) => item is Node) { + filter(fn: (item: Node, index: number) => any) { return this.children.filter(fn); } diff --git a/packages/designer/src/document/node/node.ts b/packages/designer/src/document/node/node.ts index cc336e044..f34426092 100644 --- a/packages/designer/src/document/node/node.ts +++ b/packages/designer/src/document/node/node.ts @@ -793,11 +793,39 @@ export class Node { * @deprecated */ getSuitablePlace(node: Node, ref: any): any { - // TODO: - if (this.isRoot()) { + if (this.isRoot() && this.children) { + const dropElement = this.children.filter((c: Node) => { + if (!c.isContainer()) { + return false; + } + const canDropIn = c.componentMeta?.prototype?.options?.canDropIn; + if (typeof canDropIn === 'function') { + return canDropIn(node); + } else if (typeof canDropIn === 'boolean'){ + return canDropIn; + } + return true; + })[0]; + if (dropElement) { + return { container: dropElement, ref }; + } return { container: this, ref }; } - return { container: this.parent, ref: this }; + + const canDropIn = this.componentMeta?.prototype?.options?.canDropIn; + if (this.isContainer()) { + if (canDropIn === undefined || + (typeof canDropIn === 'boolean' && canDropIn) || + (typeof canDropIn === 'function' && canDropIn(node))){ + return { container: this, ref }; + } + } + + if (this.parent) { + return this.parent.getSuitablePlace(node, ref); + } + + return null; } /** * @deprecated diff --git a/packages/rax-simulator-renderer/package.json b/packages/rax-simulator-renderer/package.json index 047ee61a3..55525ae90 100644 --- a/packages/rax-simulator-renderer/package.json +++ b/packages/rax-simulator-renderer/package.json @@ -51,5 +51,5 @@ "ts-node/register" ] }, - "homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@0.8.35/build/index.html" + "homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@0.8.36/build/index.html" }