@next-core/editor-bricks-helper 0.41.1 → 0.42.2
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 +107 -73
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +103 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/types/interfaces.d.ts +6 -2
- 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.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)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **BuilderDataManager:** add node redirect parent error ([ac3e0cc](https://github.com/easyops-cn/next-core/commit/ac3e0cc2ab4115062eb057fce803de23bbd77cbf))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [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)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @next-core/editor-bricks-helper
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [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)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* **BuilderDataManager:** support preview snippet apply ([ef506d4](https://github.com/easyops-cn/next-core/commit/ef506d4ae83946665e1a30a125948ff5504ba4aa))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
## [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)
|
|
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) {
|
|
@@ -1138,25 +1195,40 @@
|
|
|
1138
1195
|
|
|
1139
1196
|
workbenchNodeAdd(detail) {
|
|
1140
1197
|
var {
|
|
1141
|
-
|
|
1142
|
-
|
|
1198
|
+
nodes,
|
|
1199
|
+
edges,
|
|
1200
|
+
rootId
|
|
1143
1201
|
} = this.data;
|
|
1144
1202
|
var {
|
|
1145
1203
|
nodeData,
|
|
1146
|
-
|
|
1147
|
-
|
|
1204
|
+
dragOverInstanceId,
|
|
1205
|
+
parentInstanceId,
|
|
1206
|
+
dragStatus,
|
|
1207
|
+
mountPoint
|
|
1148
1208
|
} = detail;
|
|
1149
1209
|
|
|
1150
1210
|
if (nodeData.instanceId) ; else {
|
|
1151
|
-
var _nodes$find;
|
|
1152
|
-
|
|
1153
1211
|
// insert
|
|
1154
1212
|
var newNodeUid = getUniqueNodeId();
|
|
1155
|
-
var
|
|
1156
|
-
var dragOverNodeUid =
|
|
1213
|
+
var overNode = nodes.find(item => item.instanceId === dragOverInstanceId);
|
|
1214
|
+
var dragOverNodeUid = overNode.$$uid;
|
|
1215
|
+
var realDragStatus = dragStatus;
|
|
1216
|
+
|
|
1217
|
+
if (dragOverNodeUid === rootId) {
|
|
1218
|
+
realDragStatus = "inside";
|
|
1219
|
+
} else {
|
|
1220
|
+
var overEdge = edges.find(item => item.child === dragOverNodeUid);
|
|
1221
|
+
var overParentNode = nodes.find(item => dragStatus === "inside" ? item.$$uid === overEdge.child : item.$$uid === overEdge.parent);
|
|
1222
|
+
|
|
1223
|
+
if (overParentNode.instanceId !== parentInstanceId) {
|
|
1224
|
+
// 如果instanceId不相同, 说明父元素被修改, dragStatus强制等于inside, uid也需要切换成实际父元素的uid
|
|
1225
|
+
realDragStatus = "inside";
|
|
1226
|
+
dragOverNodeUid = nodes.find(item => item.instanceId === parentInstanceId).$$uid;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1157
1230
|
var {
|
|
1158
1231
|
parentUid,
|
|
1159
|
-
mountPoint,
|
|
1160
1232
|
sortIndex,
|
|
1161
1233
|
sortUids: nodeUids,
|
|
1162
1234
|
sortNodeIds: nodeIds
|
|
@@ -1166,10 +1238,29 @@
|
|
|
1166
1238
|
},
|
|
1167
1239
|
dragNodeUid: newNodeUid,
|
|
1168
1240
|
dragOverNodeUid,
|
|
1169
|
-
dragStatus
|
|
1241
|
+
dragStatus: realDragStatus
|
|
1170
1242
|
});
|
|
1171
|
-
nodeData.parent =
|
|
1243
|
+
nodeData.parent = parentInstanceId;
|
|
1172
1244
|
nodeData.mountPoint = mountPoint;
|
|
1245
|
+
|
|
1246
|
+
if (nodeData.bricks) {
|
|
1247
|
+
// snippet
|
|
1248
|
+
this.snippetApply({
|
|
1249
|
+
parentUid,
|
|
1250
|
+
nodeDetails: nodeData.bricks.map(brickConf => getSnippetNodeDetail({
|
|
1251
|
+
parent: parentInstanceId,
|
|
1252
|
+
parentUid: parentUid,
|
|
1253
|
+
mountPoint: mountPoint,
|
|
1254
|
+
nodeUid: newNodeUid,
|
|
1255
|
+
brickConf: brickConf,
|
|
1256
|
+
isPortalCanvas: false
|
|
1257
|
+
})),
|
|
1258
|
+
nodeIds,
|
|
1259
|
+
nodeUids
|
|
1260
|
+
});
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1173
1264
|
this.runAddNodeAction({
|
|
1174
1265
|
nodeUid: newNodeUid,
|
|
1175
1266
|
parentUid,
|
|
@@ -2350,63 +2441,6 @@
|
|
|
2350
2441
|
};
|
|
2351
2442
|
}
|
|
2352
2443
|
|
|
2353
|
-
var jsonFieldsInBrick = ["properties", "events", "lifeCycle", "params", "if", "transform"];
|
|
2354
|
-
var yamlFieldsInBrick = ["permissionsPreCheck", "transformFrom"];
|
|
2355
|
-
var ignoredFieldsInBrick = ["brick", "template", "portal", "slots", "id", "children", "instanceId"];
|
|
2356
|
-
// The reverse operation of *normalize*.
|
|
2357
|
-
// https://github.com/easyops-cn/next-basics/blob/5a6710d567821bcb4a0c71e22d55212193d8b0cb/bricks/next-builder/src/shared/storyboard/buildStoryboard.ts#L394
|
|
2358
|
-
function reverseNormalize(brickConf, ctx) {
|
|
2359
|
-
return Object.fromEntries(Object.entries(brickConf).map(_ref => {
|
|
2360
|
-
var [key, value] = _ref;
|
|
2361
|
-
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];
|
|
2362
|
-
}).filter(Boolean).concat(Object.entries(ctx.nodeData), [["brick", ctx.nodeData.type === "template" ? brickConf.template : brickConf.brick], ["portal", ctx.isPortalCanvas || brickConf.portal]]));
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
|
-
function getSnippetNodeDetail(_ref) {
|
|
2366
|
-
var {
|
|
2367
|
-
parent,
|
|
2368
|
-
parentUid,
|
|
2369
|
-
mountPoint,
|
|
2370
|
-
nodeUid,
|
|
2371
|
-
brickConf,
|
|
2372
|
-
isPortalCanvas,
|
|
2373
|
-
sort
|
|
2374
|
-
} = _ref;
|
|
2375
|
-
var type = brickConf.template ? "template" : brickConf.bg ? "provider" : "brick";
|
|
2376
|
-
return {
|
|
2377
|
-
nodeUid,
|
|
2378
|
-
parentUid,
|
|
2379
|
-
nodeData: reverseNormalize(brickConf, {
|
|
2380
|
-
isPortalCanvas,
|
|
2381
|
-
nodeData: {
|
|
2382
|
-
type,
|
|
2383
|
-
parent,
|
|
2384
|
-
mountPoint,
|
|
2385
|
-
sort
|
|
2386
|
-
}
|
|
2387
|
-
}),
|
|
2388
|
-
children: brickConf.slots ? Object.entries(brickConf.slots).flatMap(_ref2 => {
|
|
2389
|
-
var [mountPoint, slotConf] = _ref2;
|
|
2390
|
-
return slotConf.bricks.map(childBrickConf => ({
|
|
2391
|
-
childBrickConf,
|
|
2392
|
-
mountPoint
|
|
2393
|
-
}));
|
|
2394
|
-
}).map((_ref3, index) => {
|
|
2395
|
-
var {
|
|
2396
|
-
childBrickConf,
|
|
2397
|
-
mountPoint
|
|
2398
|
-
} = _ref3;
|
|
2399
|
-
return getSnippetNodeDetail({
|
|
2400
|
-
parentUid: nodeUid,
|
|
2401
|
-
mountPoint,
|
|
2402
|
-
nodeUid: getUniqueNodeId(),
|
|
2403
|
-
brickConf: childBrickConf,
|
|
2404
|
-
sort: index
|
|
2405
|
-
});
|
|
2406
|
-
}) : []
|
|
2407
|
-
};
|
|
2408
|
-
}
|
|
2409
|
-
|
|
2410
2444
|
function processDrop(_ref) {
|
|
2411
2445
|
var {
|
|
2412
2446
|
manager,
|