@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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.42.1](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.42.0...@next-core/editor-bricks-helper@0.42.1) (2022-06-15)
7
+
8
+ **Note:** Version bump only for package @next-core/editor-bricks-helper
9
+
10
+
11
+
12
+
13
+
6
14
  # [0.42.0](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.41.1...@next-core/editor-bricks-helper@0.42.0) (2022-06-14)
7
15
 
8
16
 
@@ -1195,26 +1195,40 @@
1195
1195
 
1196
1196
  workbenchNodeAdd(detail) {
1197
1197
  var {
1198
- rootId,
1199
- nodes
1198
+ nodes,
1199
+ edges,
1200
+ rootId
1200
1201
  } = this.data;
1201
1202
  var {
1202
1203
  nodeData,
1203
- dragOverNodeInstanceId,
1204
- dragStatus
1204
+ dragOverInstanceId,
1205
+ parentInstanceId,
1206
+ dragStatus,
1207
+ mountPoint
1205
1208
  } = detail;
1206
1209
 
1207
1210
  if (nodeData.instanceId) ; else {
1208
- var _nodes$find;
1209
-
1210
1211
  // insert
1211
1212
  var newNodeUid = getUniqueNodeId();
1212
- var isRoot = dragOverNodeInstanceId === "#main-mount-point";
1213
- var parentInstanceId = isRoot ? nodes.find(item => item.$$uid === rootId).instanceId : dragOverNodeInstanceId;
1214
- var dragOverNodeUid = (_nodes$find = nodes.find(item => isRoot ? item.$$uid === rootId : item.instanceId === dragOverNodeInstanceId)) === null || _nodes$find === void 0 ? void 0 : _nodes$find.$$uid;
1213
+ var overNode = nodes.find(item => item.instanceId === dragOverInstanceId);
1214
+ var dragOverNodeUid = overNode.$$uid;
1215
+ var realDragStatus = dragStatus;
1216
+
1217
+ if (dragOverNodeUid === rootId) {
1218
+ realDragStatus = "inside";
1219
+ } else {
1220
+ var overEdge = edges.find(item => item.child === dragOverNodeUid);
1221
+ var overParentNode = nodes.find(item => item.$$uid === overEdge.parent);
1222
+
1223
+ if (overParentNode.instanceId !== parentInstanceId) {
1224
+ // 如果instanceId不相同, 说明父元素被修改, dragStatus强制等于inside, uid也需要切换成实际父元素的uid
1225
+ realDragStatus = "inside";
1226
+ dragOverNodeUid = nodes.find(item => item.instanceId === parentInstanceId).$$uid;
1227
+ }
1228
+ }
1229
+
1215
1230
  var {
1216
1231
  parentUid,
1217
- mountPoint,
1218
1232
  sortIndex,
1219
1233
  sortUids: nodeUids,
1220
1234
  sortNodeIds: nodeIds
@@ -1224,9 +1238,9 @@
1224
1238
  },
1225
1239
  dragNodeUid: newNodeUid,
1226
1240
  dragOverNodeUid,
1227
- dragStatus
1241
+ dragStatus: realDragStatus
1228
1242
  });
1229
- nodeData.parent = nodes.find(item => item.$$uid === parentUid).instanceId;
1243
+ nodeData.parent = parentInstanceId;
1230
1244
  nodeData.mountPoint = mountPoint;
1231
1245
 
1232
1246
  if (nodeData.bricks) {