@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/CHANGELOG.md CHANGED
@@ -3,6 +3,36 @@
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.3](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.42.2...@next-core/editor-bricks-helper@0.42.3) (2022-06-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **BuilderDataManage:** sortUid incorrect after add node ([b7d2c1b](https://github.com/easyops-cn/next-core/commit/b7d2c1ba615f8242f46261218c3dbb7b36db2441))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.42.2](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.42.1...@next-core/editor-bricks-helper@0.42.2) (2022-06-16)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **BuilderDataManager:** add node redirect parent error ([ac3e0cc](https://github.com/easyops-cn/next-core/commit/ac3e0cc2ab4115062eb057fce803de23bbd77cbf))
23
+
24
+
25
+
26
+
27
+
28
+ ## [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)
29
+
30
+ **Note:** Version bump only for package @next-core/editor-bricks-helper
31
+
32
+
33
+
34
+
35
+
6
36
  # [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
37
 
8
38
 
@@ -1179,8 +1179,9 @@
1179
1179
  var overIndex = sortUids.findIndex(item => item === dragOverNodeUid);
1180
1180
  sortIndex = dragStatus === "top" ? overIndex : overIndex + 1; // 排序修正
1181
1181
 
1182
- sortNodeIds.splice(sortIndex, 0, nodeData.id);
1183
- sortUids.splice(sortIndex, 0, (_dragEdge$child = dragEdge === null || dragEdge === void 0 ? void 0 : dragEdge.child) !== null && _dragEdge$child !== void 0 ? _dragEdge$child : null);
1182
+ sortNodeIds.splice(sortIndex, 0, nodeData.id); // 如果是新增的情况下, 没有edge, 则取dragNodeUid(新创建的uid)
1183
+
1184
+ sortUids.splice(sortIndex, 0, (_dragEdge$child = dragEdge === null || dragEdge === void 0 ? void 0 : dragEdge.child) !== null && _dragEdge$child !== void 0 ? _dragEdge$child : dragNodeUid);
1184
1185
  }
1185
1186
 
1186
1187
  return {
@@ -1195,26 +1196,40 @@
1195
1196
 
1196
1197
  workbenchNodeAdd(detail) {
1197
1198
  var {
1198
- rootId,
1199
- nodes
1199
+ nodes,
1200
+ edges,
1201
+ rootId
1200
1202
  } = this.data;
1201
1203
  var {
1202
1204
  nodeData,
1203
- dragOverNodeInstanceId,
1204
- dragStatus
1205
+ dragOverInstanceId,
1206
+ parentInstanceId,
1207
+ dragStatus,
1208
+ mountPoint
1205
1209
  } = detail;
1206
1210
 
1207
1211
  if (nodeData.instanceId) ; else {
1208
- var _nodes$find;
1209
-
1210
1212
  // insert
1211
1213
  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;
1214
+ var overNode = nodes.find(item => item.instanceId === dragOverInstanceId);
1215
+ var dragOverNodeUid = overNode.$$uid;
1216
+ var realDragStatus = dragStatus;
1217
+
1218
+ if (dragOverNodeUid === rootId) {
1219
+ realDragStatus = "inside";
1220
+ } else {
1221
+ var overEdge = edges.find(item => item.child === dragOverNodeUid);
1222
+ var overParentNode = nodes.find(item => dragStatus === "inside" ? item.$$uid === overEdge.child : item.$$uid === overEdge.parent);
1223
+
1224
+ if (overParentNode.instanceId !== parentInstanceId) {
1225
+ // 如果instanceId不相同, 说明父元素被修改, dragStatus强制等于inside, uid也需要切换成实际父元素的uid
1226
+ realDragStatus = "inside";
1227
+ dragOverNodeUid = nodes.find(item => item.instanceId === parentInstanceId).$$uid;
1228
+ }
1229
+ }
1230
+
1215
1231
  var {
1216
1232
  parentUid,
1217
- mountPoint,
1218
1233
  sortIndex,
1219
1234
  sortUids: nodeUids,
1220
1235
  sortNodeIds: nodeIds
@@ -1224,9 +1239,9 @@
1224
1239
  },
1225
1240
  dragNodeUid: newNodeUid,
1226
1241
  dragOverNodeUid,
1227
- dragStatus
1242
+ dragStatus: realDragStatus
1228
1243
  });
1229
- nodeData.parent = nodes.find(item => item.$$uid === parentUid).instanceId;
1244
+ nodeData.parent = parentInstanceId;
1230
1245
  nodeData.mountPoint = mountPoint;
1231
1246
 
1232
1247
  if (nodeData.bricks) {