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

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
@@ -1177,8 +1177,9 @@ class BuilderDataManager {
1177
1177
  var overIndex = sortUids.findIndex(item => item === dragOverNodeUid);
1178
1178
  sortIndex = dragStatus === "top" ? overIndex : overIndex + 1; // 排序修正
1179
1179
 
1180
- sortNodeIds.splice(sortIndex, 0, nodeData.id);
1181
- sortUids.splice(sortIndex, 0, (_dragEdge$child = dragEdge === null || dragEdge === void 0 ? void 0 : dragEdge.child) !== null && _dragEdge$child !== void 0 ? _dragEdge$child : null);
1180
+ sortNodeIds.splice(sortIndex, 0, nodeData.id); // 如果是新增的情况下, 没有edge, 则取dragNodeUid(新创建的uid)
1181
+
1182
+ sortUids.splice(sortIndex, 0, (_dragEdge$child = dragEdge === null || dragEdge === void 0 ? void 0 : dragEdge.child) !== null && _dragEdge$child !== void 0 ? _dragEdge$child : dragNodeUid);
1182
1183
  }
1183
1184
 
1184
1185
  return {
@@ -1193,26 +1194,40 @@ class BuilderDataManager {
1193
1194
 
1194
1195
  workbenchNodeAdd(detail) {
1195
1196
  var {
1196
- rootId,
1197
- nodes
1197
+ nodes,
1198
+ edges,
1199
+ rootId
1198
1200
  } = this.data;
1199
1201
  var {
1200
1202
  nodeData,
1201
- dragOverNodeInstanceId,
1202
- dragStatus
1203
+ dragOverInstanceId,
1204
+ parentInstanceId,
1205
+ dragStatus,
1206
+ mountPoint
1203
1207
  } = detail;
1204
1208
 
1205
1209
  if (nodeData.instanceId) ; else {
1206
- var _nodes$find;
1207
-
1208
1210
  // insert
1209
1211
  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;
1212
+ var overNode = nodes.find(item => item.instanceId === dragOverInstanceId);
1213
+ var dragOverNodeUid = overNode.$$uid;
1214
+ var realDragStatus = dragStatus;
1215
+
1216
+ if (dragOverNodeUid === rootId) {
1217
+ realDragStatus = "inside";
1218
+ } else {
1219
+ var overEdge = edges.find(item => item.child === dragOverNodeUid);
1220
+ var overParentNode = nodes.find(item => dragStatus === "inside" ? item.$$uid === overEdge.child : item.$$uid === overEdge.parent);
1221
+
1222
+ if (overParentNode.instanceId !== parentInstanceId) {
1223
+ // 如果instanceId不相同, 说明父元素被修改, dragStatus强制等于inside, uid也需要切换成实际父元素的uid
1224
+ realDragStatus = "inside";
1225
+ dragOverNodeUid = nodes.find(item => item.instanceId === parentInstanceId).$$uid;
1226
+ }
1227
+ }
1228
+
1213
1229
  var {
1214
1230
  parentUid,
1215
- mountPoint,
1216
1231
  sortIndex,
1217
1232
  sortUids: nodeUids,
1218
1233
  sortNodeIds: nodeIds
@@ -1222,9 +1237,9 @@ class BuilderDataManager {
1222
1237
  },
1223
1238
  dragNodeUid: newNodeUid,
1224
1239
  dragOverNodeUid,
1225
- dragStatus
1240
+ dragStatus: realDragStatus
1226
1241
  });
1227
- nodeData.parent = nodes.find(item => item.$$uid === parentUid).instanceId;
1242
+ nodeData.parent = parentInstanceId;
1228
1243
  nodeData.mountPoint = mountPoint;
1229
1244
 
1230
1245
  if (nodeData.bricks) {