@next-core/editor-bricks-helper 0.46.28 → 0.47.0

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,17 @@
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.47.0](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.46.28...@next-core/editor-bricks-helper@0.47.0) (2022-09-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * **BuilderDataManage:** support workbenchNodeAdd get sortData ([ba91744](https://github.com/easyops-cn/next-core/commit/ba91744b512bde26788e0141cc602c592059d3bb))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.46.28](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.46.27...@next-core/editor-bricks-helper@0.46.28) (2022-09-05)
7
18
 
8
19
  **Note:** Version bump only for package @next-core/editor-bricks-helper
@@ -1172,8 +1172,6 @@
1172
1172
  }
1173
1173
 
1174
1174
  getDragInfo(_ref3) {
1175
- var _dragEdge$mountPoint;
1176
-
1177
1175
  var {
1178
1176
  nodeData,
1179
1177
  dragNodeUid,
@@ -1187,19 +1185,18 @@
1187
1185
  } = this.data;
1188
1186
  var isDragRoot = dragOverNodeUid === rootId;
1189
1187
  /*
1190
- * 如果没有id, 则为新增状态, 没有edge, 否则为移动状态
1188
+ * 如果找不到edge, 则为新增状态, 否则为移动状态
1191
1189
  */
1192
1190
 
1193
- var isAdd = nodeData.id;
1194
- var dragEdge = !isAdd ? edges.find(item => item.child === dragNodeUid) : null;
1191
+ var dragEdge = edges.find(item => item.child === dragNodeUid);
1195
1192
  var dragOverEdge = edges.find(item => item.child === dragOverNodeUid);
1196
1193
  /**
1197
1194
  * 如果是根节点, 则mountPoint强制等于 bricks
1198
- * 如果是属于拖动进某个节点中, 则使用原mountPoint(新增节点为content)
1195
+ * 如果是属于拖动进某个节点中, 默认使用 content
1199
1196
  * 其他情况, 使用被拖拽节点的mountPoint
1200
1197
  */
1201
1198
 
1202
- var mountPoint = isDragRoot ? "bricks" : dragStatus === "inside" ? (_dragEdge$mountPoint = dragEdge === null || dragEdge === void 0 ? void 0 : dragEdge.mountPoint) !== null && _dragEdge$mountPoint !== void 0 ? _dragEdge$mountPoint : "content" : dragOverEdge.mountPoint;
1199
+ var mountPoint = isDragRoot ? "bricks" : dragStatus === "inside" ? "content" : dragOverEdge.mountPoint;
1203
1200
  var parentEdge = edges.find(item => item.child === dragOverNodeUid);
1204
1201
  /**
1205
1202
  * 如果是根节点, parentUid强制等于rootId
@@ -1212,8 +1209,12 @@
1212
1209
 
1213
1210
  var siblingEdge = edges.filter(edge => edge.child !== dragNodeUid && edge.parent === parentUid);
1214
1211
  var sortUids = lodash.sortBy(siblingEdge, "sort").map(item => item.child);
1215
- var sortNodeIds = sortUids.map(item => {
1216
- return nodes.find(node => node.$$uid === item).id;
1212
+ var sortNodeIds = [];
1213
+ var sortNodeInstanceIds = [];
1214
+ sortUids.forEach(item => {
1215
+ var node = nodes.find(node => node.$$uid === item);
1216
+ sortNodeIds.push(node.id);
1217
+ sortNodeInstanceIds.push(node.instanceId);
1217
1218
  });
1218
1219
  var sortIndex;
1219
1220
 
@@ -1221,6 +1222,7 @@
1221
1222
  sortIndex = siblingEdge.length ? Math.max(...siblingEdge.map(item => item.sort)) + 1 : 0; // 插入默认插最后
1222
1223
 
1223
1224
  sortNodeIds.push(nodeData.id);
1225
+ sortNodeInstanceIds.push(nodeData.instanceId);
1224
1226
  } else if (dragStatus === "top" || dragStatus === "bottom") {
1225
1227
  var _dragEdge$child;
1226
1228
 
@@ -1230,6 +1232,7 @@
1230
1232
  sortNodeIds.splice(sortIndex, 0, nodeData.id); // 如果是新增的情况下, 没有edge, 则取dragNodeUid(新创建的uid)
1231
1233
 
1232
1234
  sortUids.splice(sortIndex, 0, (_dragEdge$child = dragEdge === null || dragEdge === void 0 ? void 0 : dragEdge.child) !== null && _dragEdge$child !== void 0 ? _dragEdge$child : dragNodeUid);
1235
+ sortNodeInstanceIds.splice(sortIndex, 0, nodeData.instanceId);
1233
1236
  }
1234
1237
 
1235
1238
  return {
@@ -1238,7 +1241,8 @@
1238
1241
  sortIndex,
1239
1242
  parnetNodeData,
1240
1243
  sortUids,
1241
- sortNodeIds
1244
+ sortNodeIds,
1245
+ sortNodeInstanceIds
1242
1246
  };
1243
1247
  }
1244
1248
 
@@ -1257,6 +1261,8 @@
1257
1261
  } = detail;
1258
1262
 
1259
1263
  if (nodeData.instanceId && !nodeData.instanceId.startsWith("mock")) ; else {
1264
+ var _nodeData$id, _nodeData$instanceId;
1265
+
1260
1266
  // insert
1261
1267
  var parentInstanceId = detail.parent || detail.parentInstanceId;
1262
1268
  var newNodeUid = nodeData.$$uid || getUniqueNodeId();
@@ -1281,10 +1287,12 @@
1281
1287
  parentUid,
1282
1288
  sortIndex,
1283
1289
  sortUids: nodeUids,
1284
- sortNodeIds: nodeIds
1290
+ sortNodeIds: nodeIds,
1291
+ sortNodeInstanceIds: nodeInstanceIds
1285
1292
  } = this.getDragInfo({
1286
1293
  nodeData: {
1287
- id: null
1294
+ id: (_nodeData$id = nodeData.id) !== null && _nodeData$id !== void 0 ? _nodeData$id : null,
1295
+ instanceId: (_nodeData$instanceId = nodeData.instanceId) !== null && _nodeData$instanceId !== void 0 ? _nodeData$instanceId : null
1288
1296
  },
1289
1297
  dragNodeUid: newNodeUid,
1290
1298
  dragOverNodeUid,
@@ -1325,11 +1333,18 @@
1325
1333
  nodeData,
1326
1334
  sort: sortIndex
1327
1335
  });
1336
+ var sortData = {
1337
+ nodeUids,
1338
+ nodeInstanceIds,
1339
+ nodeIds
1340
+ };
1341
+ detail.sortData = sortData;
1328
1342
  this.eventTarget.dispatchEvent(new CustomEvent(BuilderInternalEventType.NODE_ADD, {
1329
1343
  detail: {
1330
1344
  nodeUid: newNodeUid,
1331
1345
  parentUid,
1332
1346
  nodeUids,
1347
+ nodeInstanceIds,
1333
1348
  nodeIds,
1334
1349
  nodeData
1335
1350
  }