From 6a85c43468cf2db93e1c9fea000b388af1e6a6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E7=86=A0?= Date: Thu, 13 Aug 2020 12:07:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=A1=E7=89=87=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E7=94=A8=E6=8B=96=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/src/builtin-simulator/host.ts | 23 +++++++++++++++---- packages/designer/src/component-meta.ts | 6 ++--- packages/plugin-outline-pane/src/main.ts | 18 ++++++++++++--- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index 045a5bae5..5259a31f4 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -839,22 +839,35 @@ export class BuiltinSimulatorHost implements ISimulatorHost { + const onMoveHook = node.componentMeta?.getMetadata()?.experimental?.callbacks?.onMoveHook; + const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook() : true; + + return canMove; + }); + + if (!operationalNodes || operationalNodes.length === 0) { + return; + } this.sensing = true; this.scroller.scrolling(e); const dropContainer = this.getDropContainer(e); - const canDropIn = dropContainer.container?.componentMeta?.prototype?.options?.canDropIn; + const canDropIn = dropContainer?.container?.componentMeta?.prototype?.options?.canDropIn; + if ( !dropContainer || canDropIn === false || // too dirty - (typeof canDropIn === 'function' && - !canDropIn(e.dragObject.nodes[0])) + (typeof canDropIn === 'function' && !canDropIn(operationalNodes[0])) ) { return null; } @@ -886,7 +899,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost { + const onMoveHook = node.componentMeta?.getMetadata()?.experimental?.callbacks?.onMoveHook; + const canMove = onMoveHook && typeof onMoveHook === 'function' ? onMoveHook() : true; + + return canMove; + }); + + if (!operationalNodes || operationalNodes.length === 0) { + return; + } + const document = tree.document; const designer = document.designer; - const { globalY, dragObject } = e; const pos = getPosFromEvent(e, this._shell); const irect = this.getInsertionRect(); const originLoc = document.dropLocation; - if (e.dragObject.type === 'node' && e.dragObject.nodes[0].getPrototype().isModal()) { + if (dragObject.type === 'node' && operationalNodes[0].getPrototype().isModal()) { return designer.createLocation({ target: document.rootNode, detail: { @@ -195,7 +207,7 @@ export class OutlineMain implements ISensor, ITreeBoard, IScrollable { let focusSlots = pos.focusSlots; let { node } = treeNode; if (isDragNodeObject(dragObject)) { - const nodes = dragObject.nodes; + const nodes = operationalNodes; let i = nodes.length; let p: any = node; while (i-- > 0) {