mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-18 21:38:14 +00:00
fix: getSuitablePlace
This commit is contained in:
parent
21fc26045a
commit
03e7c57639
@ -244,7 +244,7 @@ export class NodeChildren {
|
|||||||
return this.children.some((child, index) => fn(child, index));
|
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);
|
return this.children.filter(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -793,11 +793,39 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
getSuitablePlace(node: Node, ref: any): any {
|
getSuitablePlace(node: Node, ref: any): any {
|
||||||
// TODO:
|
if (this.isRoot() && this.children) {
|
||||||
if (this.isRoot()) {
|
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, 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
|
* @deprecated
|
||||||
|
|||||||
@ -51,5 +51,5 @@
|
|||||||
"ts-node/register"
|
"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"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user