@tmagic/editor 1.1.0-beta.11 → 1.1.0-beta.12
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/dist/tmagic-editor.mjs +41 -43
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +40 -43
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/Editor.vue +1 -0
- package/src/layouts/workspace/PageBar.vue +1 -1
- package/src/layouts/workspace/Workspace.vue +3 -1
- package/src/services/editor.ts +17 -6
- package/src/services/props.ts +26 -53
- package/src/utils/operator.ts +1 -1
- package/src/utils/props.ts +0 -3
- package/types/services/editor.d.ts +1 -0
- package/types/services/props.d.ts +40 -9
- package/types/utils/props.d.ts +0 -1
|
@@ -897,6 +897,7 @@
|
|
|
897
897
|
"getPropsValue",
|
|
898
898
|
"createId",
|
|
899
899
|
"setNewItemId",
|
|
900
|
+
"fillConfig",
|
|
900
901
|
"getDefaultPropsValue"
|
|
901
902
|
]);
|
|
902
903
|
}
|
|
@@ -906,14 +907,17 @@
|
|
|
906
907
|
});
|
|
907
908
|
this.emit("props-configs-change");
|
|
908
909
|
}
|
|
909
|
-
|
|
910
|
-
|
|
910
|
+
async fillConfig(config) {
|
|
911
|
+
return fillConfig(config);
|
|
912
|
+
}
|
|
913
|
+
async setPropsConfig(type, config) {
|
|
914
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
911
915
|
}
|
|
912
916
|
async getPropsConfig(type) {
|
|
913
917
|
if (type === "area") {
|
|
914
918
|
return await this.getPropsConfig("button");
|
|
915
919
|
}
|
|
916
|
-
return lodashEs.cloneDeep(this.state.propsConfigMap[type] ||
|
|
920
|
+
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
917
921
|
}
|
|
918
922
|
setPropsValues(values) {
|
|
919
923
|
Object.keys(values).forEach((type) => {
|
|
@@ -947,25 +951,14 @@
|
|
|
947
951
|
...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
948
952
|
};
|
|
949
953
|
}
|
|
950
|
-
guid(digit = 8) {
|
|
951
|
-
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
952
|
-
const r = Math.random() * 16 | 0;
|
|
953
|
-
const v = c == "x" ? r : r & 3 | 8;
|
|
954
|
-
return v.toString(16);
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
954
|
async createId(type) {
|
|
958
955
|
return `${type}_${this.guid()}`;
|
|
959
956
|
}
|
|
960
|
-
async setNewItemId(config
|
|
961
|
-
const oldId = config.id;
|
|
957
|
+
async setNewItemId(config) {
|
|
962
958
|
config.id = await this.createId(config.type || "component");
|
|
963
|
-
if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
|
|
964
|
-
updatePopId(oldId, config.id, parent);
|
|
965
|
-
}
|
|
966
959
|
if (config.items && Array.isArray(config.items)) {
|
|
967
960
|
for (const item of config.items) {
|
|
968
|
-
await this.setNewItemId(item
|
|
961
|
+
await this.setNewItemId(item);
|
|
969
962
|
}
|
|
970
963
|
}
|
|
971
964
|
return config;
|
|
@@ -983,22 +976,14 @@
|
|
|
983
976
|
name: type
|
|
984
977
|
};
|
|
985
978
|
}
|
|
979
|
+
guid(digit = 8) {
|
|
980
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
981
|
+
const r = Math.random() * 16 | 0;
|
|
982
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
983
|
+
return v.toString(16);
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
986
|
}
|
|
987
|
-
const updatePopId = (oldId, popId, pageConfig) => {
|
|
988
|
-
pageConfig.items?.forEach((config) => {
|
|
989
|
-
if (config.pop === oldId) {
|
|
990
|
-
config.pop = popId;
|
|
991
|
-
return;
|
|
992
|
-
}
|
|
993
|
-
if (config.popId === oldId) {
|
|
994
|
-
config.popId = popId;
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
if (Array.isArray(config.items)) {
|
|
998
|
-
updatePopId(oldId, popId, config);
|
|
999
|
-
}
|
|
1000
|
-
});
|
|
1001
|
-
};
|
|
1002
987
|
const propsService = new Props();
|
|
1003
988
|
|
|
1004
989
|
const beforePaste = async (position, config) => {
|
|
@@ -1018,7 +1003,7 @@
|
|
|
1018
1003
|
if (pastePosition.top && configItem.style?.top) {
|
|
1019
1004
|
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1020
1005
|
}
|
|
1021
|
-
const pasteConfig = await propsService.setNewItemId(configItem
|
|
1006
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
1022
1007
|
if (pasteConfig.style) {
|
|
1023
1008
|
const { left, top } = pasteConfig.style;
|
|
1024
1009
|
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
@@ -1089,6 +1074,7 @@
|
|
|
1089
1074
|
"sort",
|
|
1090
1075
|
"copy",
|
|
1091
1076
|
"paste",
|
|
1077
|
+
"doPaste",
|
|
1092
1078
|
"duAlignCenter",
|
|
1093
1079
|
"alignCenter",
|
|
1094
1080
|
"moveLayer",
|
|
@@ -1270,7 +1256,7 @@
|
|
|
1270
1256
|
}
|
|
1271
1257
|
this.pushHistoryState();
|
|
1272
1258
|
this.emit("add", newNodes);
|
|
1273
|
-
return
|
|
1259
|
+
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1274
1260
|
}
|
|
1275
1261
|
async doRemove(node) {
|
|
1276
1262
|
const root = this.get("root");
|
|
@@ -1364,7 +1350,7 @@
|
|
|
1364
1350
|
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1365
1351
|
this.pushHistoryState();
|
|
1366
1352
|
this.emit("update", newNodes);
|
|
1367
|
-
return
|
|
1353
|
+
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1368
1354
|
}
|
|
1369
1355
|
async sort(id1, id2) {
|
|
1370
1356
|
const node = this.get("node");
|
|
@@ -1393,9 +1379,13 @@
|
|
|
1393
1379
|
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1394
1380
|
if (!Array.isArray(config))
|
|
1395
1381
|
return;
|
|
1396
|
-
const pasteConfigs = await
|
|
1382
|
+
const pasteConfigs = await this.doPaste(config, position);
|
|
1397
1383
|
return this.add(pasteConfigs);
|
|
1398
1384
|
}
|
|
1385
|
+
async doPaste(config, position = {}) {
|
|
1386
|
+
const pasteConfigs = await beforePaste(position, lodashEs.cloneDeep(config));
|
|
1387
|
+
return pasteConfigs;
|
|
1388
|
+
}
|
|
1399
1389
|
async doAlignCenter(config) {
|
|
1400
1390
|
const parent = this.getParentById(config.id);
|
|
1401
1391
|
if (!parent)
|
|
@@ -1440,11 +1430,14 @@
|
|
|
1440
1430
|
} else {
|
|
1441
1431
|
brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
|
|
1442
1432
|
}
|
|
1433
|
+
const grandparent = this.getParentById(parent.id);
|
|
1443
1434
|
this.get("stage")?.update({
|
|
1444
1435
|
config: lodashEs.cloneDeep(vue.toRaw(parent)),
|
|
1445
|
-
parentId:
|
|
1436
|
+
parentId: grandparent?.id,
|
|
1446
1437
|
root: lodashEs.cloneDeep(this.get("root"))
|
|
1447
1438
|
});
|
|
1439
|
+
this.addModifiedNodeId(parent.id);
|
|
1440
|
+
this.pushHistoryState();
|
|
1448
1441
|
}
|
|
1449
1442
|
async moveToContainer(config, targetId) {
|
|
1450
1443
|
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
@@ -1464,7 +1457,8 @@
|
|
|
1464
1457
|
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1465
1458
|
target.items.push(newConfig);
|
|
1466
1459
|
await stage.select(targetId);
|
|
1467
|
-
|
|
1460
|
+
const targetParent = this.getParentById(target.id);
|
|
1461
|
+
await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root });
|
|
1468
1462
|
await this.select(newConfig);
|
|
1469
1463
|
stage.select(newConfig.id);
|
|
1470
1464
|
this.addModifiedNodeId(target.id);
|
|
@@ -1827,7 +1821,6 @@
|
|
|
1827
1821
|
]
|
|
1828
1822
|
}
|
|
1829
1823
|
];
|
|
1830
|
-
const DEFAULT_CONFIG = fillConfig([]);
|
|
1831
1824
|
|
|
1832
1825
|
const log = (...args) => {
|
|
1833
1826
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -3364,7 +3357,7 @@
|
|
|
3364
3357
|
content: item.name
|
|
3365
3358
|
}, {
|
|
3366
3359
|
default: vue.withCtx(() => [
|
|
3367
|
-
vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
|
|
3360
|
+
vue.createElementVNode("span", null, vue.toDisplayString(item.name || item.id), 1)
|
|
3368
3361
|
]),
|
|
3369
3362
|
_: 2
|
|
3370
3363
|
}, 1032, ["content"])
|
|
@@ -4098,9 +4091,11 @@
|
|
|
4098
4091
|
const _component_magic_stage = vue.resolveComponent("magic-stage");
|
|
4099
4092
|
const _component_page_bar = vue.resolveComponent("page-bar");
|
|
4100
4093
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4094
|
+
vue.renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
4095
|
+
(vue.openBlock(), vue.createBlock(_component_magic_stage, {
|
|
4096
|
+
key: _ctx.page?.id
|
|
4097
|
+
}))
|
|
4098
|
+
]),
|
|
4104
4099
|
vue.renderSlot(_ctx.$slots, "workspace-content"),
|
|
4105
4100
|
vue.createVNode(_component_page_bar, null, {
|
|
4106
4101
|
"page-bar-title": vue.withCtx(({ page }) => [
|
|
@@ -4433,6 +4428,9 @@
|
|
|
4433
4428
|
workspace: vue.withCtx(() => [
|
|
4434
4429
|
vue.renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
4435
4430
|
vue.createVNode(_component_workspace, null, {
|
|
4431
|
+
stage: vue.withCtx(() => [
|
|
4432
|
+
vue.renderSlot(_ctx.$slots, "stage")
|
|
4433
|
+
]),
|
|
4436
4434
|
"workspace-content": vue.withCtx(() => [
|
|
4437
4435
|
vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
4438
4436
|
]),
|
|
@@ -4485,7 +4483,6 @@
|
|
|
4485
4483
|
|
|
4486
4484
|
exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
|
|
4487
4485
|
exports.ComponentListPanel = ComponentListPanel;
|
|
4488
|
-
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
4489
4486
|
exports.Fixed2Other = Fixed2Other;
|
|
4490
4487
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
4491
4488
|
exports.Keys = Keys;
|