@next-core/editor-bricks-helper 0.40.1 → 0.42.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 +30 -0
- package/dist/index.bundle.js +201 -85
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +197 -81
- package/dist/index.esm.js.map +1 -1
- package/dist/types/interfaces.d.ts +12 -0
- package/dist/types/internal/BuilderDataManager.d.ts +3 -1
- package/package.json +3 -3
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **BuilderDataManager:** support preview snippet apply ([ef506d4](https://github.com/easyops-cn/next-core/commit/ef506d4ae83946665e1a30a125948ff5504ba4aa))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.41.1](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.41.0...@next-core/editor-bricks-helper@0.41.1) (2022-06-10)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @next-core/editor-bricks-helper
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [0.41.0](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.40.1...@next-core/editor-bricks-helper@0.41.0) (2022-06-10)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* **BuilderDataManager:** support preview addNode ([b5b0ee7](https://github.com/easyops-cn/next-core/commit/b5b0ee7e55466486a6d31656ec384d0114111ce7))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
## [0.40.1](https://github.com/easyops-cn/next-core/compare/@next-core/editor-bricks-helper@0.40.0...@next-core/editor-bricks-helper@0.40.1) (2022-06-06)
|
|
7
37
|
|
|
8
38
|
**Note:** Version bump only for package @next-core/editor-bricks-helper
|
package/dist/index.bundle.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/defineProperty'), require('lodash'), require('@next-core/brick-utils'), require('@babel/runtime/helpers/objectWithoutProperties'), require('react-dnd'), require('@babel/runtime/helpers/asyncToGenerator'), require('@next-core/brick-kit'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/defineProperty', 'lodash', '@next-core/brick-utils', '@babel/runtime/helpers/objectWithoutProperties', 'react-dnd', '@babel/runtime/helpers/asyncToGenerator', '@next-core/brick-kit', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.EditorBricksHelper = {}, global.React, global._objectSpread, global._defineProperty, global.lodash, global.brickUtils, global._objectWithoutProperties, global.reactDnd, global._asyncToGenerator, global.brickKit, global.
|
|
5
|
-
})(this, (function (exports, React, _objectSpread, _defineProperty, lodash, brickUtils, _objectWithoutProperties, reactDnd, _asyncToGenerator, brickKit,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/defineProperty'), require('lodash'), require('@next-core/brick-utils'), require('js-yaml'), require('@babel/runtime/helpers/objectWithoutProperties'), require('react-dnd'), require('@babel/runtime/helpers/asyncToGenerator'), require('@next-core/brick-kit'), require('@babel/runtime/helpers/decorate'), require('react-dom'), require('react-dnd-html5-backend')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/defineProperty', 'lodash', '@next-core/brick-utils', 'js-yaml', '@babel/runtime/helpers/objectWithoutProperties', 'react-dnd', '@babel/runtime/helpers/asyncToGenerator', '@next-core/brick-kit', '@babel/runtime/helpers/decorate', 'react-dom', 'react-dnd-html5-backend'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.EditorBricksHelper = {}, global.React, global._objectSpread, global._defineProperty, global.lodash, global.brickUtils, global.yaml, global._objectWithoutProperties, global.reactDnd, global._asyncToGenerator, global.brickKit, global._decorate, global.ReactDOM, global.reactDndHtml5Backend));
|
|
5
|
+
})(this, (function (exports, React, _objectSpread, _defineProperty, lodash, brickUtils, yaml, _objectWithoutProperties, reactDnd, _asyncToGenerator, brickKit, _decorate, ReactDOM, reactDndHtml5Backend) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
11
11
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
12
|
+
var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
|
|
12
13
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
13
14
|
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
14
|
-
var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
|
|
15
15
|
var _decorate__default = /*#__PURE__*/_interopDefaultLegacy(_decorate);
|
|
16
16
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
17
17
|
|
|
@@ -660,6 +660,63 @@
|
|
|
660
660
|
return nodes.find(node => node.$$uid === parentUid).$$isExpandableTemplate;
|
|
661
661
|
}
|
|
662
662
|
|
|
663
|
+
var jsonFieldsInBrick = ["properties", "events", "lifeCycle", "params", "if", "transform"];
|
|
664
|
+
var yamlFieldsInBrick = ["permissionsPreCheck", "transformFrom"];
|
|
665
|
+
var ignoredFieldsInBrick = ["brick", "template", "portal", "slots", "id", "children", "instanceId"];
|
|
666
|
+
// The reverse operation of *normalize*.
|
|
667
|
+
// https://github.com/easyops-cn/next-basics/blob/5a6710d567821bcb4a0c71e22d55212193d8b0cb/bricks/next-builder/src/shared/storyboard/buildStoryboard.ts#L394
|
|
668
|
+
function reverseNormalize(brickConf, ctx) {
|
|
669
|
+
return Object.fromEntries(Object.entries(brickConf).map(_ref => {
|
|
670
|
+
var [key, value] = _ref;
|
|
671
|
+
return value === undefined || ignoredFieldsInBrick.includes(key) ? undefined : jsonFieldsInBrick.includes(key) ? [key, JSON.stringify(value)] : yamlFieldsInBrick.includes(key) ? [key, yaml__default["default"].safeDump(value)] : [key, value];
|
|
672
|
+
}).filter(Boolean).concat(Object.entries(ctx.nodeData), [["brick", ctx.nodeData.type === "template" ? brickConf.template : brickConf.brick], ["portal", ctx.isPortalCanvas || brickConf.portal]]));
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function getSnippetNodeDetail(_ref) {
|
|
676
|
+
var {
|
|
677
|
+
parent,
|
|
678
|
+
parentUid,
|
|
679
|
+
mountPoint,
|
|
680
|
+
nodeUid,
|
|
681
|
+
brickConf,
|
|
682
|
+
isPortalCanvas,
|
|
683
|
+
sort
|
|
684
|
+
} = _ref;
|
|
685
|
+
var type = brickConf.template ? "template" : brickConf.bg ? "provider" : "brick";
|
|
686
|
+
return {
|
|
687
|
+
nodeUid,
|
|
688
|
+
parentUid,
|
|
689
|
+
nodeData: reverseNormalize(brickConf, {
|
|
690
|
+
isPortalCanvas,
|
|
691
|
+
nodeData: {
|
|
692
|
+
type,
|
|
693
|
+
parent,
|
|
694
|
+
mountPoint,
|
|
695
|
+
sort
|
|
696
|
+
}
|
|
697
|
+
}),
|
|
698
|
+
children: brickConf.slots ? Object.entries(brickConf.slots).flatMap(_ref2 => {
|
|
699
|
+
var [mountPoint, slotConf] = _ref2;
|
|
700
|
+
return slotConf.bricks.map(childBrickConf => ({
|
|
701
|
+
childBrickConf,
|
|
702
|
+
mountPoint
|
|
703
|
+
}));
|
|
704
|
+
}).map((_ref3, index) => {
|
|
705
|
+
var {
|
|
706
|
+
childBrickConf,
|
|
707
|
+
mountPoint
|
|
708
|
+
} = _ref3;
|
|
709
|
+
return getSnippetNodeDetail({
|
|
710
|
+
parentUid: nodeUid,
|
|
711
|
+
mountPoint,
|
|
712
|
+
nodeUid: getUniqueNodeId(),
|
|
713
|
+
brickConf: childBrickConf,
|
|
714
|
+
sort: index
|
|
715
|
+
});
|
|
716
|
+
}) : []
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
|
|
663
720
|
var BuilderInternalEventType;
|
|
664
721
|
|
|
665
722
|
(function (BuilderInternalEventType) {
|
|
@@ -816,7 +873,8 @@
|
|
|
816
873
|
nodeUid,
|
|
817
874
|
parentUid,
|
|
818
875
|
nodeUids,
|
|
819
|
-
nodeData
|
|
876
|
+
nodeData,
|
|
877
|
+
sort
|
|
820
878
|
} = detail;
|
|
821
879
|
var {
|
|
822
880
|
nodes: addNodes,
|
|
@@ -827,7 +885,7 @@
|
|
|
827
885
|
parent: parentUid,
|
|
828
886
|
child: nodeUid,
|
|
829
887
|
mountPoint: nodeData.mountPoint,
|
|
830
|
-
sort: undefined,
|
|
888
|
+
sort: sort !== null && sort !== void 0 ? sort : undefined,
|
|
831
889
|
$$isTemplateDelegated: isParentExpandableTemplate(nodes, parentUid)
|
|
832
890
|
}).concat(addEdges);
|
|
833
891
|
var newData = {
|
|
@@ -1065,30 +1123,35 @@
|
|
|
1065
1123
|
this.reorder(parentUid, orderedEdges);
|
|
1066
1124
|
}
|
|
1067
1125
|
|
|
1068
|
-
|
|
1069
|
-
var
|
|
1070
|
-
|
|
1071
|
-
nodes,
|
|
1072
|
-
edges,
|
|
1073
|
-
wrapperNode
|
|
1074
|
-
} = this.data;
|
|
1126
|
+
getDragInfo(_ref3) {
|
|
1127
|
+
var _dragEdge$mountPoint;
|
|
1128
|
+
|
|
1075
1129
|
var {
|
|
1130
|
+
nodeData,
|
|
1076
1131
|
dragNodeUid,
|
|
1077
1132
|
dragOverNodeUid,
|
|
1078
|
-
dragParentNodeUid,
|
|
1079
1133
|
dragStatus
|
|
1080
|
-
} =
|
|
1134
|
+
} = _ref3;
|
|
1135
|
+
var {
|
|
1136
|
+
rootId,
|
|
1137
|
+
nodes,
|
|
1138
|
+
edges
|
|
1139
|
+
} = this.data;
|
|
1081
1140
|
var isDragRoot = dragOverNodeUid === rootId;
|
|
1082
|
-
|
|
1083
|
-
|
|
1141
|
+
/*
|
|
1142
|
+
* 如果没有id, 则为新增状态, 没有edge, 否则为移动状态
|
|
1143
|
+
*/
|
|
1144
|
+
|
|
1145
|
+
var isAdd = nodeData.id;
|
|
1146
|
+
var dragEdge = !isAdd ? edges.find(item => item.child === dragNodeUid) : null;
|
|
1084
1147
|
var dragOverEdge = edges.find(item => item.child === dragOverNodeUid);
|
|
1085
1148
|
/**
|
|
1086
1149
|
* 如果是根节点, 则mountPoint强制等于 bricks
|
|
1087
|
-
* 如果是属于拖动进某个节点中, 则使用原mountPoint
|
|
1150
|
+
* 如果是属于拖动进某个节点中, 则使用原mountPoint(新增节点为content)
|
|
1088
1151
|
* 其他情况, 使用被拖拽节点的mountPoint
|
|
1089
1152
|
*/
|
|
1090
1153
|
|
|
1091
|
-
var mountPoint = isDragRoot ? "bricks" : dragStatus === "inside" ? dragEdge.mountPoint : dragOverEdge.mountPoint;
|
|
1154
|
+
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;
|
|
1092
1155
|
var parentEdge = edges.find(item => item.child === dragOverNodeUid);
|
|
1093
1156
|
/**
|
|
1094
1157
|
* 如果是根节点, parentUid强制等于rootId
|
|
@@ -1111,31 +1174,141 @@
|
|
|
1111
1174
|
|
|
1112
1175
|
sortNodeIds.push(nodeData.id);
|
|
1113
1176
|
} else if (dragStatus === "top" || dragStatus === "bottom") {
|
|
1114
|
-
var _dragEdge
|
|
1177
|
+
var _dragEdge$child;
|
|
1115
1178
|
|
|
1116
1179
|
var overIndex = sortUids.findIndex(item => item === dragOverNodeUid);
|
|
1117
1180
|
sortIndex = dragStatus === "top" ? overIndex : overIndex + 1; // 排序修正
|
|
1118
1181
|
|
|
1119
1182
|
sortNodeIds.splice(sortIndex, 0, nodeData.id);
|
|
1120
|
-
sortUids.splice(sortIndex, 0, _dragEdge.child);
|
|
1183
|
+
sortUids.splice(sortIndex, 0, (_dragEdge$child = dragEdge === null || dragEdge === void 0 ? void 0 : dragEdge.child) !== null && _dragEdge$child !== void 0 ? _dragEdge$child : null);
|
|
1121
1184
|
}
|
|
1122
1185
|
|
|
1186
|
+
return {
|
|
1187
|
+
parentUid,
|
|
1188
|
+
mountPoint,
|
|
1189
|
+
sortIndex,
|
|
1190
|
+
parnetNodeData,
|
|
1191
|
+
sortUids,
|
|
1192
|
+
sortNodeIds
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
workbenchNodeAdd(detail) {
|
|
1197
|
+
var {
|
|
1198
|
+
rootId,
|
|
1199
|
+
nodes
|
|
1200
|
+
} = this.data;
|
|
1201
|
+
var {
|
|
1202
|
+
nodeData,
|
|
1203
|
+
dragOverNodeInstanceId,
|
|
1204
|
+
dragStatus
|
|
1205
|
+
} = detail;
|
|
1206
|
+
|
|
1207
|
+
if (nodeData.instanceId) ; else {
|
|
1208
|
+
var _nodes$find;
|
|
1209
|
+
|
|
1210
|
+
// insert
|
|
1211
|
+
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;
|
|
1215
|
+
var {
|
|
1216
|
+
parentUid,
|
|
1217
|
+
mountPoint,
|
|
1218
|
+
sortIndex,
|
|
1219
|
+
sortUids: nodeUids,
|
|
1220
|
+
sortNodeIds: nodeIds
|
|
1221
|
+
} = this.getDragInfo({
|
|
1222
|
+
nodeData: {
|
|
1223
|
+
id: null
|
|
1224
|
+
},
|
|
1225
|
+
dragNodeUid: newNodeUid,
|
|
1226
|
+
dragOverNodeUid,
|
|
1227
|
+
dragStatus
|
|
1228
|
+
});
|
|
1229
|
+
nodeData.parent = nodes.find(item => item.$$uid === parentUid).instanceId;
|
|
1230
|
+
nodeData.mountPoint = mountPoint;
|
|
1231
|
+
|
|
1232
|
+
if (nodeData.bricks) {
|
|
1233
|
+
// snippet
|
|
1234
|
+
this.snippetApply({
|
|
1235
|
+
parentUid,
|
|
1236
|
+
nodeDetails: nodeData.bricks.map(brickConf => getSnippetNodeDetail({
|
|
1237
|
+
parent: parentInstanceId,
|
|
1238
|
+
parentUid: parentUid,
|
|
1239
|
+
mountPoint: mountPoint,
|
|
1240
|
+
nodeUid: newNodeUid,
|
|
1241
|
+
brickConf: brickConf,
|
|
1242
|
+
isPortalCanvas: false
|
|
1243
|
+
})),
|
|
1244
|
+
nodeIds,
|
|
1245
|
+
nodeUids
|
|
1246
|
+
});
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
this.runAddNodeAction({
|
|
1251
|
+
nodeUid: newNodeUid,
|
|
1252
|
+
parentUid,
|
|
1253
|
+
nodeUids,
|
|
1254
|
+
nodeIds,
|
|
1255
|
+
nodeData,
|
|
1256
|
+
sort: sortIndex
|
|
1257
|
+
});
|
|
1258
|
+
this.eventTarget.dispatchEvent(new CustomEvent(BuilderInternalEventType.NODE_ADD, {
|
|
1259
|
+
detail: {
|
|
1260
|
+
nodeUid: newNodeUid,
|
|
1261
|
+
parentUid,
|
|
1262
|
+
nodeUids,
|
|
1263
|
+
nodeIds,
|
|
1264
|
+
nodeData
|
|
1265
|
+
}
|
|
1266
|
+
}));
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
workbenchTreeNodeMove(detail) {
|
|
1271
|
+
var {
|
|
1272
|
+
rootId,
|
|
1273
|
+
nodes,
|
|
1274
|
+
edges,
|
|
1275
|
+
wrapperNode
|
|
1276
|
+
} = this.data;
|
|
1277
|
+
var {
|
|
1278
|
+
dragNodeUid,
|
|
1279
|
+
dragOverNodeUid,
|
|
1280
|
+
dragStatus
|
|
1281
|
+
} = detail;
|
|
1282
|
+
var nodeData = nodes.find(item => item.$$uid === dragNodeUid);
|
|
1283
|
+
var {
|
|
1284
|
+
parentUid,
|
|
1285
|
+
parnetNodeData,
|
|
1286
|
+
mountPoint,
|
|
1287
|
+
sortIndex,
|
|
1288
|
+
sortUids: nodeUids,
|
|
1289
|
+
sortNodeIds: nodeIds
|
|
1290
|
+
} = this.getDragInfo({
|
|
1291
|
+
nodeData,
|
|
1292
|
+
dragNodeUid,
|
|
1293
|
+
dragOverNodeUid,
|
|
1294
|
+
dragStatus
|
|
1295
|
+
});
|
|
1123
1296
|
var newData = {
|
|
1124
1297
|
rootId,
|
|
1125
1298
|
nodes,
|
|
1126
1299
|
edges: edges.filter(edge => edge.child !== dragNodeUid).concat({
|
|
1127
|
-
parent:
|
|
1300
|
+
parent: parentUid,
|
|
1128
1301
|
child: dragNodeUid,
|
|
1129
1302
|
mountPoint: mountPoint,
|
|
1130
1303
|
sort: sortIndex,
|
|
1131
|
-
$$isTemplateDelegated: isParentExpandableTemplate(nodes,
|
|
1304
|
+
$$isTemplateDelegated: isParentExpandableTemplate(nodes, parentUid)
|
|
1132
1305
|
}),
|
|
1133
1306
|
wrapperNode
|
|
1134
1307
|
};
|
|
1135
1308
|
this.data = _objectSpread__default["default"](_objectSpread__default["default"]({}, newData), {}, {
|
|
1136
1309
|
edges: reorderBuilderEdges(newData, {
|
|
1137
1310
|
parentUid,
|
|
1138
|
-
nodeUids
|
|
1311
|
+
nodeUids
|
|
1139
1312
|
})
|
|
1140
1313
|
});
|
|
1141
1314
|
this.triggerDataChange();
|
|
@@ -1143,7 +1316,7 @@
|
|
|
1143
1316
|
detail: {
|
|
1144
1317
|
nodeUid: dragNodeUid,
|
|
1145
1318
|
nodeInstanceId: nodeData.instanceId,
|
|
1146
|
-
nodeIds
|
|
1319
|
+
nodeIds,
|
|
1147
1320
|
nodeData: {
|
|
1148
1321
|
parent: parnetNodeData.instanceId,
|
|
1149
1322
|
mountPoint: mountPoint
|
|
@@ -1156,10 +1329,10 @@
|
|
|
1156
1329
|
*/
|
|
1157
1330
|
|
|
1158
1331
|
|
|
1159
|
-
moveMountPoint(
|
|
1332
|
+
moveMountPoint(_ref4, mountPoint, direction) {
|
|
1160
1333
|
var {
|
|
1161
1334
|
$$uid: parentUid
|
|
1162
|
-
} =
|
|
1335
|
+
} = _ref4;
|
|
1163
1336
|
var {
|
|
1164
1337
|
relatedEdges,
|
|
1165
1338
|
mountPoints
|
|
@@ -2254,63 +2427,6 @@
|
|
|
2254
2427
|
};
|
|
2255
2428
|
}
|
|
2256
2429
|
|
|
2257
|
-
var jsonFieldsInBrick = ["properties", "events", "lifeCycle", "params", "if", "transform"];
|
|
2258
|
-
var yamlFieldsInBrick = ["permissionsPreCheck", "transformFrom"];
|
|
2259
|
-
var ignoredFieldsInBrick = ["brick", "template", "portal", "slots", "id", "children", "instanceId"];
|
|
2260
|
-
// The reverse operation of *normalize*.
|
|
2261
|
-
// https://github.com/easyops-cn/next-basics/blob/5a6710d567821bcb4a0c71e22d55212193d8b0cb/bricks/next-builder/src/shared/storyboard/buildStoryboard.ts#L394
|
|
2262
|
-
function reverseNormalize(brickConf, ctx) {
|
|
2263
|
-
return Object.fromEntries(Object.entries(brickConf).map(_ref => {
|
|
2264
|
-
var [key, value] = _ref;
|
|
2265
|
-
return value === undefined || ignoredFieldsInBrick.includes(key) ? undefined : jsonFieldsInBrick.includes(key) ? [key, JSON.stringify(value)] : yamlFieldsInBrick.includes(key) ? [key, yaml__default["default"].safeDump(value)] : [key, value];
|
|
2266
|
-
}).filter(Boolean).concat(Object.entries(ctx.nodeData), [["brick", ctx.nodeData.type === "template" ? brickConf.template : brickConf.brick], ["portal", ctx.isPortalCanvas || brickConf.portal]]));
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
function getSnippetNodeDetail(_ref) {
|
|
2270
|
-
var {
|
|
2271
|
-
parent,
|
|
2272
|
-
parentUid,
|
|
2273
|
-
mountPoint,
|
|
2274
|
-
nodeUid,
|
|
2275
|
-
brickConf,
|
|
2276
|
-
isPortalCanvas,
|
|
2277
|
-
sort
|
|
2278
|
-
} = _ref;
|
|
2279
|
-
var type = brickConf.template ? "template" : brickConf.bg ? "provider" : "brick";
|
|
2280
|
-
return {
|
|
2281
|
-
nodeUid,
|
|
2282
|
-
parentUid,
|
|
2283
|
-
nodeData: reverseNormalize(brickConf, {
|
|
2284
|
-
isPortalCanvas,
|
|
2285
|
-
nodeData: {
|
|
2286
|
-
type,
|
|
2287
|
-
parent,
|
|
2288
|
-
mountPoint,
|
|
2289
|
-
sort
|
|
2290
|
-
}
|
|
2291
|
-
}),
|
|
2292
|
-
children: brickConf.slots ? Object.entries(brickConf.slots).flatMap(_ref2 => {
|
|
2293
|
-
var [mountPoint, slotConf] = _ref2;
|
|
2294
|
-
return slotConf.bricks.map(childBrickConf => ({
|
|
2295
|
-
childBrickConf,
|
|
2296
|
-
mountPoint
|
|
2297
|
-
}));
|
|
2298
|
-
}).map((_ref3, index) => {
|
|
2299
|
-
var {
|
|
2300
|
-
childBrickConf,
|
|
2301
|
-
mountPoint
|
|
2302
|
-
} = _ref3;
|
|
2303
|
-
return getSnippetNodeDetail({
|
|
2304
|
-
parentUid: nodeUid,
|
|
2305
|
-
mountPoint,
|
|
2306
|
-
nodeUid: getUniqueNodeId(),
|
|
2307
|
-
brickConf: childBrickConf,
|
|
2308
|
-
sort: index
|
|
2309
|
-
});
|
|
2310
|
-
}) : []
|
|
2311
|
-
};
|
|
2312
|
-
}
|
|
2313
|
-
|
|
2314
2430
|
function processDrop(_ref) {
|
|
2315
2431
|
var {
|
|
2316
2432
|
manager,
|