@next-core/editor-bricks-helper 0.42.26 → 0.43.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.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)
7
+
8
+
9
+ ### Features
10
+
11
+ * support local source change builderData ([1245f36](https://github.com/easyops-cn/next-core/commit/1245f3622f274e7b2cdbfcd24cb3463cb50f1238))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [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
18
 
8
19
  **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,31 @@
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 newNodes = nodes.map(item => {
922
+ if (item.instanceId === instanceId) {
923
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, item), detail);
924
+ }
925
+
926
+ return item;
927
+ });
928
+ this.data = {
929
+ rootId,
930
+ nodes: newNodes,
931
+ edges,
932
+ wrapperNode
933
+ };
934
+ this.eventTarget.dispatchEvent(new CustomEvent(BuilderInternalEventType.NODE_UPDATE, {
935
+ detail: this.data
936
+ }));
937
+ }
938
+
911
939
  redirectMountPoint(detail) {
912
940
  var {
913
941
  rootId,
@@ -1203,14 +1231,14 @@
1203
1231
  var {
1204
1232
  nodeData,
1205
1233
  dragOverInstanceId,
1206
- parentInstanceId,
1207
1234
  dragStatus,
1208
1235
  mountPoint
1209
1236
  } = detail;
1210
1237
 
1211
- if (nodeData.instanceId) ; else {
1238
+ if (nodeData.instanceId && !nodeData.instanceId.startsWith("mock")) ; else {
1212
1239
  // insert
1213
- var newNodeUid = getUniqueNodeId();
1240
+ var parentInstanceId = detail.parent || detail.parentInstanceId;
1241
+ var newNodeUid = nodeData.$$uid || getUniqueNodeId();
1214
1242
  var overNode = nodes.find(item => item.instanceId === dragOverInstanceId);
1215
1243
  var dragOverNodeUid = overNode.$$uid;
1216
1244
  var realDragStatus = dragStatus;
@@ -1243,6 +1271,7 @@
1243
1271
  });
1244
1272
  nodeData.parent = parentInstanceId;
1245
1273
  nodeData.mountPoint = mountPoint;
1274
+ nodeData.sort = sortIndex;
1246
1275
 
1247
1276
  if (nodeData.bricks) {
1248
1277
  // snippet
@@ -1486,6 +1515,13 @@
1486
1515
  };
1487
1516
  }
1488
1517
 
1518
+ onNodeUpdate(fn) {
1519
+ this.eventTarget.addEventListener(BuilderInternalEventType.NODE_UPDATE, fn);
1520
+ return () => {
1521
+ this.eventTarget.removeEventListener(BuilderInternalEventType.NODE_UPDATE, fn);
1522
+ };
1523
+ }
1524
+
1489
1525
  onContextMenuChange(fn) {
1490
1526
  this.eventTarget.addEventListener(BuilderInternalEventType.CONTEXT_MENU_CHANGE, fn);
1491
1527
  return () => {