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