@next-core/editor-bricks-helper 0.42.0 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1193,26 +1193,40 @@ class BuilderDataManager {
1193
1193
 
1194
1194
  workbenchNodeAdd(detail) {
1195
1195
  var {
1196
- rootId,
1197
- nodes
1196
+ nodes,
1197
+ edges,
1198
+ rootId
1198
1199
  } = this.data;
1199
1200
  var {
1200
1201
  nodeData,
1201
- dragOverNodeInstanceId,
1202
- dragStatus
1202
+ dragOverInstanceId,
1203
+ parentInstanceId,
1204
+ dragStatus,
1205
+ mountPoint
1203
1206
  } = detail;
1204
1207
 
1205
1208
  if (nodeData.instanceId) ; else {
1206
- var _nodes$find;
1207
-
1208
1209
  // insert
1209
1210
  var newNodeUid = getUniqueNodeId();
1210
- var isRoot = dragOverNodeInstanceId === "#main-mount-point";
1211
- var parentInstanceId = isRoot ? nodes.find(item => item.$$uid === rootId).instanceId : dragOverNodeInstanceId;
1212
- var dragOverNodeUid = (_nodes$find = nodes.find(item => isRoot ? item.$$uid === rootId : item.instanceId === dragOverNodeInstanceId)) === null || _nodes$find === void 0 ? void 0 : _nodes$find.$$uid;
1211
+ var overNode = nodes.find(item => item.instanceId === dragOverInstanceId);
1212
+ var dragOverNodeUid = overNode.$$uid;
1213
+ var realDragStatus = dragStatus;
1214
+
1215
+ if (dragOverNodeUid === rootId) {
1216
+ realDragStatus = "inside";
1217
+ } else {
1218
+ var overEdge = edges.find(item => item.child === dragOverNodeUid);
1219
+ var overParentNode = nodes.find(item => item.$$uid === overEdge.parent);
1220
+
1221
+ if (overParentNode.instanceId !== parentInstanceId) {
1222
+ // 如果instanceId不相同, 说明父元素被修改, dragStatus强制等于inside, uid也需要切换成实际父元素的uid
1223
+ realDragStatus = "inside";
1224
+ dragOverNodeUid = nodes.find(item => item.instanceId === parentInstanceId).$$uid;
1225
+ }
1226
+ }
1227
+
1213
1228
  var {
1214
1229
  parentUid,
1215
- mountPoint,
1216
1230
  sortIndex,
1217
1231
  sortUids: nodeUids,
1218
1232
  sortNodeIds: nodeIds
@@ -1222,9 +1236,9 @@ class BuilderDataManager {
1222
1236
  },
1223
1237
  dragNodeUid: newNodeUid,
1224
1238
  dragOverNodeUid,
1225
- dragStatus
1239
+ dragStatus: realDragStatus
1226
1240
  });
1227
- nodeData.parent = nodes.find(item => item.$$uid === parentUid).instanceId;
1241
+ nodeData.parent = parentInstanceId;
1228
1242
  nodeData.mountPoint = mountPoint;
1229
1243
 
1230
1244
  if (nodeData.bricks) {