@next-core/editor-bricks-helper 0.42.26 → 0.44.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,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.44.0](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.43.1...@next-core/editor-bricks-helper@0.44.0) (2022-08-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * support updateNode update edges ([0db8809](https://github.com/easyops-cn/next-core/commit/0db880952e8a92bc0dee4453fdd3422a740c23af))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.43.1](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.43.0...@next-core/editor-bricks-helper@0.43.1) (2022-08-03)
18
+
19
+ **Note:** Version bump only for package @next-core/editor-bricks-helper
20
+
21
+
22
+
23
+
24
+
25
+ # [0.43.0](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.42.26...@next-core/editor-bricks-helper@0.43.0) (2022-08-01)
26
+
27
+
28
+ ### Features
29
+
30
+ * support local source change builderData ([1245f36](https://github.com/easyops-cn/next-core/commit/1245f3622f274e7b2cdbfcd24cb3463cb50f1238))
31
+
32
+
33
+
34
+
35
+
6
36
  ## [0.42.26](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.42.25...@next-core/editor-bricks-helper@0.42.26) (2022-07-25)
7
37
 
8
38
  **Note:** Version bump only for package @next-core/editor-bricks-helper
@@ -724,6 +724,7 @@
724
724
  BuilderInternalEventType["NODE_MOVE"] = "builder.node.move";
725
725
  BuilderInternalEventType["NODE_REORDER"] = "builder.node.reorder";
726
726
  BuilderInternalEventType["NODE_CLICK"] = "builder.node.click";
727
+ BuilderInternalEventType["NODE_UPDATE"] = "builder.node.update";
727
728
  BuilderInternalEventType["SNIPPET_APPLY"] = "builder.snippet.apply";
728
729
  BuilderInternalEventType["CONTEXT_MENU_CHANGE"] = "builder.contextMenu.change";
729
730
  BuilderInternalEventType["DATA_CHANGE"] = "builder.data.change";
@@ -859,7 +860,9 @@
859
860
  var rootNode = nodes.find(node => node.$$uid === rootId);
860
861
  var rootNodeIsCustomTemplate = rootNode.type === "custom-template";
861
862
  this.relatedNodesBasedOnEventsMap = getRelatedNodesBasedOnEvents(nodes, rootNodeIsCustomTemplate);
862
- this.eventTarget.dispatchEvent(new CustomEvent(BuilderInternalEventType.DATA_CHANGE));
863
+ this.eventTarget.dispatchEvent(new CustomEvent(BuilderInternalEventType.DATA_CHANGE, {
864
+ detail: this.data
865
+ }));
863
866
  }
864
867
 
865
868
  runAddNodeAction(detail) {
@@ -908,6 +911,41 @@
908
911
  this.runAddNodeAction(detail);
909
912
  }
910
913
 
914
+ updateNode(instanceId, detail) {
915
+ var {
916
+ rootId,
917
+ nodes,
918
+ edges,
919
+ wrapperNode
920
+ } = this.data;
921
+ var updateNode = nodes.find(item => item.instanceId === instanceId);
922
+ var newNodes = nodes.map(item => {
923
+ if (item.instanceId === instanceId) {
924
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, item), detail);
925
+ }
926
+
927
+ return item;
928
+ });
929
+ var newEdges = detail.mountPoint === undefined || detail.mountPoint === null ? edges : edges.map(item => {
930
+ if (item.child === updateNode.$$uid) {
931
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
932
+ mountPoint: detail.mountPoint
933
+ });
934
+ }
935
+
936
+ return item;
937
+ });
938
+ this.data = {
939
+ rootId,
940
+ nodes: newNodes,
941
+ edges: newEdges,
942
+ wrapperNode
943
+ };
944
+ this.eventTarget.dispatchEvent(new CustomEvent(BuilderInternalEventType.NODE_UPDATE, {
945
+ detail: this.data
946
+ }));
947
+ }
948
+
911
949
  redirectMountPoint(detail) {
912
950
  var {
913
951
  rootId,
@@ -1203,14 +1241,14 @@
1203
1241
  var {
1204
1242
  nodeData,
1205
1243
  dragOverInstanceId,
1206
- parentInstanceId,
1207
1244
  dragStatus,
1208
1245
  mountPoint
1209
1246
  } = detail;
1210
1247
 
1211
- if (nodeData.instanceId) ; else {
1248
+ if (nodeData.instanceId && !nodeData.instanceId.startsWith("mock")) ; else {
1212
1249
  // insert
1213
- var newNodeUid = getUniqueNodeId();
1250
+ var parentInstanceId = detail.parent || detail.parentInstanceId;
1251
+ var newNodeUid = nodeData.$$uid || getUniqueNodeId();
1214
1252
  var overNode = nodes.find(item => item.instanceId === dragOverInstanceId);
1215
1253
  var dragOverNodeUid = overNode.$$uid;
1216
1254
  var realDragStatus = dragStatus;
@@ -1243,6 +1281,7 @@
1243
1281
  });
1244
1282
  nodeData.parent = parentInstanceId;
1245
1283
  nodeData.mountPoint = mountPoint;
1284
+ nodeData.sort = sortIndex;
1246
1285
 
1247
1286
  if (nodeData.bricks) {
1248
1287
  // snippet
@@ -1486,6 +1525,13 @@
1486
1525
  };
1487
1526
  }
1488
1527
 
1528
+ onNodeUpdate(fn) {
1529
+ this.eventTarget.addEventListener(BuilderInternalEventType.NODE_UPDATE, fn);
1530
+ return () => {
1531
+ this.eventTarget.removeEventListener(BuilderInternalEventType.NODE_UPDATE, fn);
1532
+ };
1533
+ }
1534
+
1489
1535
  onContextMenuChange(fn) {
1490
1536
  this.eventTarget.addEventListener(BuilderInternalEventType.CONTEXT_MENU_CHANGE, fn);
1491
1537
  return () => {