mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-20 15:38:32 +00:00
fix: getSuitablePlace by kangwei to #35417409
This commit is contained in:
parent
98065b7a62
commit
a39010ae73
@ -956,26 +956,53 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
getSuitablePlace(node: Node, ref: any): any {
|
getSuitablePlace(node: Node, ref: any): any {
|
||||||
|
const focusNode = this.document.focusNode;
|
||||||
// 如果节点是模态框,插入到根节点下
|
// 如果节点是模态框,插入到根节点下
|
||||||
if (node?.componentMeta?.isModal) {
|
if (node?.componentMeta?.isModal) {
|
||||||
return { container: this.document.rootNode, ref };
|
return { container: focusNode, ref };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ref && this.contains(focusNode)) {
|
||||||
|
const rootCanDropIn = focusNode.componentMeta?.prototype?.options?.canDropIn;
|
||||||
|
if (
|
||||||
|
rootCanDropIn === undefined ||
|
||||||
|
rootCanDropIn === true ||
|
||||||
|
(typeof rootCanDropIn === 'function' && rootCanDropIn(node))
|
||||||
|
) {
|
||||||
|
return { container: focusNode };
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo: remove these dirty code (for legao tranditional scene)
|
||||||
if (this.isRoot() && this.children) {
|
if (this.isRoot() && this.children) {
|
||||||
const dropElement = this.children.filter((c: Node) => {
|
const rootCanDropIn = this.componentMeta?.prototype?.options?.canDropIn;
|
||||||
|
if (
|
||||||
|
rootCanDropIn === undefined ||
|
||||||
|
rootCanDropIn === true ||
|
||||||
|
(typeof rootCanDropIn === 'function' && rootCanDropIn(node))
|
||||||
|
) {
|
||||||
|
return { container: this, ref };
|
||||||
|
}
|
||||||
|
|
||||||
|
const dropElement = this.children.filter((c) => {
|
||||||
if (!c.isContainer()) {
|
if (!c.isContainer()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const canDropIn = c.componentMeta?.prototype?.options?.canDropIn;
|
const canDropIn = c.componentMeta?.prototype?.options?.canDropIn;
|
||||||
if (typeof canDropIn === 'function') {
|
if (
|
||||||
return canDropIn(node);
|
canDropIn === undefined ||
|
||||||
} else if (typeof canDropIn === 'boolean') {
|
canDropIn === true ||
|
||||||
return canDropIn;
|
(typeof canDropIn === 'function' && canDropIn(node))
|
||||||
}
|
) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
if (dropElement) {
|
if (dropElement) {
|
||||||
return { container: dropElement, ref };
|
return { container: dropElement };
|
||||||
}
|
}
|
||||||
const rootCanDropIn = this.componentMeta?.prototype?.options?.canDropIn;
|
const rootCanDropIn = this.componentMeta?.prototype?.options?.canDropIn;
|
||||||
if (
|
if (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user