mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 09:41:57 +00:00
feat: getSuitableInsertion 支持 node 参数,checkNestingDown 将 target 转换为 Node
This commit is contained in:
parent
fe412a2621
commit
542586421f
@ -13,7 +13,7 @@ import {
|
||||
FieldConfig,
|
||||
} from '@ali/lowcode-types';
|
||||
import { computed } from '@ali/lowcode-editor-core';
|
||||
import { Node, ParentalNode } from './document';
|
||||
import { isNode, Node, ParentalNode } from './document';
|
||||
import { Designer } from './designer';
|
||||
import { intlNode } from './locale';
|
||||
import { IconContainer } from './icons/container';
|
||||
@ -264,6 +264,9 @@ export class ComponentMeta {
|
||||
checkNestingDown(my: Node, target: Node | NodeSchema) {
|
||||
// 检查父子关系,直接约束型,在画布中拖拽直接掠过目标容器
|
||||
if (this.childWhitelist) {
|
||||
if (!isNode(target)) {
|
||||
target = new Node(my.document, target);
|
||||
}
|
||||
return this.childWhitelist(target, my);
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -9,6 +9,7 @@ import {
|
||||
CompositeObject,
|
||||
PropsList,
|
||||
isNodeSchema,
|
||||
NodeSchema,
|
||||
} from '@ali/lowcode-types';
|
||||
import { Project } from '../project';
|
||||
import { Node, DocumentModel, insertChildren, isRootNode, ParentalNode, TransformStage } from '../document';
|
||||
@ -294,7 +295,7 @@ export class Designer {
|
||||
/**
|
||||
* 获得合适的插入位置
|
||||
*/
|
||||
getSuitableInsertion(): { target: ParentalNode; index?: number } | null {
|
||||
getSuitableInsertion(insertNode?: Node | NodeSchema): { target: ParentalNode; index?: number } | null {
|
||||
const activedDoc = this.project.currentDocument;
|
||||
if (!activedDoc) {
|
||||
return null;
|
||||
@ -306,7 +307,7 @@ export class Designer {
|
||||
target = activedDoc.rootNode;
|
||||
} else {
|
||||
const node = nodes[0];
|
||||
if (isRootNode(node)) {
|
||||
if (isRootNode(node) || node.componentMeta.isContainer) {
|
||||
target = node;
|
||||
} else {
|
||||
// FIXME!!, parent maybe null
|
||||
@ -314,6 +315,11 @@ export class Designer {
|
||||
index = node.index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (target && insertNode && !target.componentMeta.checkNestingDown(target, insertNode)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { target, index };
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user