Merge branch 'fix/drop-object-is-data' into 'release/0.9.7'

Fix/drop object is data



See merge request !940210
This commit is contained in:
力皓 2020-08-19 12:17:18 +08:00
commit 649394e8ce
4 changed files with 41 additions and 4 deletions

View File

@ -874,9 +874,10 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
return canMove;
});
if (!operationalNodes || operationalNodes.length === 0) {
if (nodes && (!operationalNodes || operationalNodes.length === 0)) {
return;
}
this.sensing = true;
this.scroller.scrolling(e);
const dropContainer = this.getDropContainer(e);
@ -886,7 +887,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
!dropContainer ||
canDropIn === false ||
// too dirty
(typeof canDropIn === 'function' && !canDropIn(operationalNodes[0]))
(nodes && typeof canDropIn === 'function' && !canDropIn(operationalNodes[0]))
) {
return null;
}
@ -918,7 +919,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
event: e,
};
if (dragObject.type === 'node' && operationalNodes[0]?.getPrototype()?.isModal()) {
if (dragObject.type === 'node' && nodes && operationalNodes[0]?.getPrototype()?.isModal()) {
return this.designer.createLocation({
target: this.document.rootNode,
detail: {

View File

@ -8,6 +8,7 @@ import {
IEditor,
CompositeObject,
PropsList,
isNodeSchema,
} from '@ali/lowcode-types';
import { Project } from '../project';
import { Node, DocumentModel, insertChildren, isRootNode, ParentalNode, TransformStage } from '../document';
@ -111,10 +112,14 @@ export class Designer {
if (isLocationChildrenDetail(loc.detail) && loc.detail.valid !== false) {
let nodes: Node[] | undefined;
if (isDragNodeObject(dragObject)) {
nodes = insertChildren(loc.target, dragObject.nodes, loc.detail.index, copy);
nodes = insertChildren(loc.target, [...dragObject.nodes], loc.detail.index, copy);
} else if (isDragNodeDataObject(dragObject)) {
// process nodeData
const nodeData = Array.isArray(dragObject.data) ? dragObject.data : [dragObject.data];
const isNotNodeSchema = nodeData.find(item => !isNodeSchema(item));
if (isNotNodeSchema) {
return;
}
nodes = insertChildren(loc.target, nodeData, loc.detail.index);
}
if (nodes) {

View File

@ -149,4 +149,29 @@ export class DropLocation {
event,
});
}
/**
* @deprecated
* vision
*/
getContainer() {
return this.target;
}
/**
* @deprecated
* vision
*/
getInsertion() {
if (!this.detail) {
return null;
}
if (this.detail.type === 'Children') {
if (this.detail.index <= 0) {
return null;
}
return this.target.children.get(this.detail.index - 1);
}
return (this.detail as any)?.near?.node;
}
}

View File

@ -734,6 +734,12 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return this.componentName;
}
/**
* @deprecated
*/
insert(node: Node, ref?: Node, useMutator = true) {
this.insertAfter(node, ref, useMutator);
}
insertBefore(node: Node, ref?: Node, useMutator = true) {
this.children?.insert(node, ref ? ref.index : null, useMutator);
}