@tmagic/editor 1.1.0-beta.6 → 1.1.0-beta.9
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/style.css +4 -0
- package/dist/tmagic-editor.mjs +322 -320
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +321 -318
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +7 -7
- package/src/Editor.vue +8 -2
- package/src/components/Icon.vue +1 -1
- package/src/fields/UISelect.vue +0 -1
- package/src/index.ts +1 -1
- package/src/layouts/workspace/PageBar.vue +43 -161
- package/src/layouts/workspace/PageBarScrollContainer.vue +111 -0
- package/src/layouts/workspace/Stage.vue +6 -2
- package/src/layouts/workspace/ViewerMenu.vue +7 -10
- package/src/layouts/workspace/Workspace.vue +1 -1
- package/src/services/editor.ts +158 -106
- package/src/theme/component-list-panel.scss +5 -0
- package/src/type.ts +2 -1
- package/src/utils/editor.ts +17 -10
- package/src/utils/operator.ts +21 -122
- package/types/Editor.vue.d.ts +10 -1
- package/types/fields/UISelect.vue.d.ts +0 -4
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +48 -0
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +3 -3
- package/types/services/editor.d.ts +9 -17
- package/types/type.d.ts +2 -1
- package/types/utils/editor.d.ts +4 -1
- package/types/utils/operator.d.ts +3 -26
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
window.globalThis = window;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const _sfc_main$
|
|
40
|
+
const _sfc_main$n = vue.defineComponent({
|
|
41
41
|
name: "m-fields-vs-code",
|
|
42
42
|
props: ["model", "name", "config", "prop"],
|
|
43
43
|
emits: ["change"],
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
onSave: _ctx.save
|
|
73
73
|
}, null, 8, ["style", "init-values", "language", "onSave"]);
|
|
74
74
|
}
|
|
75
|
-
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
75
|
+
const Code = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$g]]);
|
|
76
76
|
|
|
77
|
-
const _sfc_main$
|
|
77
|
+
const _sfc_main$m = vue.defineComponent({
|
|
78
78
|
name: "m-fields-code-link",
|
|
79
79
|
props: {
|
|
80
80
|
config: {
|
|
@@ -139,13 +139,12 @@
|
|
|
139
139
|
onChange: _ctx.changeHandler
|
|
140
140
|
}, null, 8, ["config", "model", "onChange"]);
|
|
141
141
|
}
|
|
142
|
-
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
142
|
+
const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
|
|
143
143
|
|
|
144
144
|
const _hoisted_1$d = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
|
|
145
|
-
const _sfc_main$
|
|
145
|
+
const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
|
|
146
146
|
__name: "UISelect",
|
|
147
147
|
props: {
|
|
148
|
-
labelWidth: null,
|
|
149
148
|
config: null,
|
|
150
149
|
model: null,
|
|
151
150
|
prop: null,
|
|
@@ -269,7 +268,7 @@
|
|
|
269
268
|
}
|
|
270
269
|
return value;
|
|
271
270
|
};
|
|
272
|
-
const _sfc_main$
|
|
271
|
+
const _sfc_main$k = vue.defineComponent({
|
|
273
272
|
name: "magic-code-editor",
|
|
274
273
|
props: {
|
|
275
274
|
initValues: {
|
|
@@ -384,7 +383,7 @@
|
|
|
384
383
|
function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
|
|
385
384
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
|
|
386
385
|
}
|
|
387
|
-
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
386
|
+
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
|
|
388
387
|
|
|
389
388
|
let $TMAGIC_EDITOR = {};
|
|
390
389
|
const setConfig = (option) => {
|
|
@@ -762,10 +761,10 @@
|
|
|
762
761
|
top: 0,
|
|
763
762
|
left: 0
|
|
764
763
|
});
|
|
765
|
-
const getMiddleTop = (
|
|
766
|
-
let height = style
|
|
767
|
-
if (!stage || typeof style
|
|
768
|
-
return style
|
|
764
|
+
const getMiddleTop = (node, parentNode, stage) => {
|
|
765
|
+
let height = node.style?.height || 0;
|
|
766
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
767
|
+
return node.style?.top;
|
|
769
768
|
if (!utils.isNumber(height)) {
|
|
770
769
|
height = 0;
|
|
771
770
|
}
|
|
@@ -776,12 +775,11 @@
|
|
|
776
775
|
}
|
|
777
776
|
return (parentHeight - height) / 2;
|
|
778
777
|
};
|
|
779
|
-
const getInitPositionStyle = (style = {}, layout
|
|
778
|
+
const getInitPositionStyle = (style = {}, layout) => {
|
|
780
779
|
if (layout === Layout.ABSOLUTE) {
|
|
781
780
|
return {
|
|
782
781
|
...style,
|
|
783
|
-
position: "absolute"
|
|
784
|
-
top: getMiddleTop(style, parentNode, stage)
|
|
782
|
+
position: "absolute"
|
|
785
783
|
};
|
|
786
784
|
}
|
|
787
785
|
if (layout === Layout.RELATIVE) {
|
|
@@ -873,6 +871,16 @@
|
|
|
873
871
|
}
|
|
874
872
|
return config.style.left;
|
|
875
873
|
};
|
|
874
|
+
const fixNodePosition = (config, parent, stage) => {
|
|
875
|
+
if (config.style?.position !== "absolute") {
|
|
876
|
+
return config.style;
|
|
877
|
+
}
|
|
878
|
+
return {
|
|
879
|
+
...config.style || {},
|
|
880
|
+
top: getMiddleTop(config, parent, stage),
|
|
881
|
+
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
882
|
+
};
|
|
883
|
+
};
|
|
876
884
|
|
|
877
885
|
class Props extends BaseService {
|
|
878
886
|
state = vue.reactive({
|
|
@@ -1029,36 +1037,6 @@
|
|
|
1029
1037
|
}));
|
|
1030
1038
|
return pasteConfigs;
|
|
1031
1039
|
};
|
|
1032
|
-
const beforeAdd = async (addNode, parent) => {
|
|
1033
|
-
const { type, inputEvent, ...config } = addNode;
|
|
1034
|
-
const curNode = editorService.get("node");
|
|
1035
|
-
let parentNode;
|
|
1036
|
-
const isPage2 = type === schema.NodeType.PAGE;
|
|
1037
|
-
if (isPage2) {
|
|
1038
|
-
parentNode = editorService.get("root");
|
|
1039
|
-
} else if (parent && typeof parent !== "function") {
|
|
1040
|
-
parentNode = parent;
|
|
1041
|
-
} else if (curNode.items) {
|
|
1042
|
-
parentNode = curNode;
|
|
1043
|
-
} else {
|
|
1044
|
-
parentNode = editorService.getParentById(curNode.id, false);
|
|
1045
|
-
}
|
|
1046
|
-
if (!parentNode)
|
|
1047
|
-
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1048
|
-
const layout = await editorService.getLayout(vue.toRaw(parentNode), addNode);
|
|
1049
|
-
const newNode = { ...vue.toRaw(await propsService.getPropsValue(type, config)) };
|
|
1050
|
-
newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, editorService.get("stage"));
|
|
1051
|
-
if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
|
|
1052
|
-
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1053
|
-
}
|
|
1054
|
-
parentNode?.items?.push(newNode);
|
|
1055
|
-
return {
|
|
1056
|
-
parentNode,
|
|
1057
|
-
newNode,
|
|
1058
|
-
layout,
|
|
1059
|
-
isPage: isPage2
|
|
1060
|
-
};
|
|
1061
|
-
};
|
|
1062
1040
|
const getPositionInContainer = (position = {}, id) => {
|
|
1063
1041
|
let { left = 0, top = 0 } = position;
|
|
1064
1042
|
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
@@ -1070,55 +1048,17 @@
|
|
|
1070
1048
|
top
|
|
1071
1049
|
};
|
|
1072
1050
|
};
|
|
1073
|
-
const
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
newNode.style.left = fixedLeft;
|
|
1081
|
-
await stage?.update({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(root) });
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
};
|
|
1085
|
-
const beforeRemove = async (node) => {
|
|
1086
|
-
if (!node?.id)
|
|
1087
|
-
return;
|
|
1088
|
-
const stage = editorService.get("stage");
|
|
1089
|
-
const root = editorService.get("root");
|
|
1090
|
-
if (!root)
|
|
1091
|
-
throw new Error("\u6CA1\u6709root");
|
|
1092
|
-
const { parent, node: curNode } = editorService.getNodeInfo(node.id, false);
|
|
1093
|
-
if (!parent || !curNode)
|
|
1094
|
-
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1095
|
-
const index = getNodeIndex(curNode, parent);
|
|
1096
|
-
if (typeof index !== "number" || index === -1)
|
|
1097
|
-
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1098
|
-
parent.items?.splice(index, 1);
|
|
1099
|
-
stage?.remove({ id: node.id, root: lodashEs.cloneDeep(root) });
|
|
1100
|
-
if (node.type === schema.NodeType.PAGE) {
|
|
1101
|
-
editorService.state.pageLength -= 1;
|
|
1102
|
-
if (root.items[0]) {
|
|
1103
|
-
await editorService.select(root.items[0]);
|
|
1104
|
-
stage?.select(root.items[0].id);
|
|
1105
|
-
} else {
|
|
1106
|
-
editorService.set("node", null);
|
|
1107
|
-
editorService.set("nodes", []);
|
|
1108
|
-
editorService.set("parent", null);
|
|
1109
|
-
editorService.set("page", null);
|
|
1110
|
-
editorService.set("stage", null);
|
|
1111
|
-
editorService.set("highlightNode", null);
|
|
1112
|
-
editorService.resetModifiedNodeId();
|
|
1113
|
-
historyService.reset();
|
|
1114
|
-
editorService.emit("remove", node);
|
|
1115
|
-
return;
|
|
1116
|
-
}
|
|
1051
|
+
const getAddParent = (addNode) => {
|
|
1052
|
+
const curNode = editorService.get("node");
|
|
1053
|
+
let parentNode;
|
|
1054
|
+
if (!Array.isArray(addNode) && utils.isPage(addNode)) {
|
|
1055
|
+
parentNode = editorService.get("root");
|
|
1056
|
+
} else if (curNode.items) {
|
|
1057
|
+
parentNode = curNode;
|
|
1117
1058
|
} else {
|
|
1118
|
-
|
|
1119
|
-
stage?.select(parent.id);
|
|
1059
|
+
parentNode = editorService.getParentById(curNode.id, false);
|
|
1120
1060
|
}
|
|
1121
|
-
return
|
|
1061
|
+
return parentNode;
|
|
1122
1062
|
};
|
|
1123
1063
|
|
|
1124
1064
|
class Editor$1 extends BaseService {
|
|
@@ -1138,12 +1078,16 @@
|
|
|
1138
1078
|
super([
|
|
1139
1079
|
"getLayout",
|
|
1140
1080
|
"select",
|
|
1081
|
+
"doAdd",
|
|
1141
1082
|
"add",
|
|
1083
|
+
"doRemove",
|
|
1142
1084
|
"remove",
|
|
1085
|
+
"doUpdate",
|
|
1143
1086
|
"update",
|
|
1144
1087
|
"sort",
|
|
1145
1088
|
"copy",
|
|
1146
1089
|
"paste",
|
|
1090
|
+
"duAlignCenter",
|
|
1147
1091
|
"alignCenter",
|
|
1148
1092
|
"moveLayer",
|
|
1149
1093
|
"moveToContainer",
|
|
@@ -1272,62 +1216,94 @@
|
|
|
1272
1216
|
});
|
|
1273
1217
|
this.set("nodes", nodes);
|
|
1274
1218
|
}
|
|
1275
|
-
async
|
|
1219
|
+
async doAdd(node, parent) {
|
|
1220
|
+
const root = this.get("root");
|
|
1221
|
+
const curNode = this.get("node");
|
|
1276
1222
|
const stage = this.get("stage");
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
this.
|
|
1287
|
-
return
|
|
1223
|
+
if ((parent?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
|
|
1224
|
+
throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
|
|
1225
|
+
}
|
|
1226
|
+
const layout = await this.getLayout(vue.toRaw(parent), node);
|
|
1227
|
+
node.style = getInitPositionStyle(node.style, layout);
|
|
1228
|
+
await stage?.add({ config: lodashEs.cloneDeep(node), parent: lodashEs.cloneDeep(parent), root: lodashEs.cloneDeep(root) });
|
|
1229
|
+
node.style = fixNodePosition(node, parent, stage);
|
|
1230
|
+
await stage?.update({ config: lodashEs.cloneDeep(node), root: lodashEs.cloneDeep(root) });
|
|
1231
|
+
parent?.items?.push(node);
|
|
1232
|
+
this.addModifiedNodeId(node.id);
|
|
1233
|
+
return node;
|
|
1288
1234
|
}
|
|
1289
1235
|
async add(addNode, parent) {
|
|
1290
1236
|
const stage = this.get("stage");
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
if (!
|
|
1296
|
-
|
|
1237
|
+
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(addNode);
|
|
1238
|
+
if (!parentNode)
|
|
1239
|
+
throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
|
|
1240
|
+
const addNodes = [];
|
|
1241
|
+
if (!Array.isArray(addNode)) {
|
|
1242
|
+
const { type, inputEvent, ...config } = addNode;
|
|
1243
|
+
if (!type)
|
|
1244
|
+
throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
|
|
1245
|
+
addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
|
|
1246
|
+
} else {
|
|
1247
|
+
addNodes.push(...addNode);
|
|
1297
1248
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1249
|
+
const newNodes = await Promise.all(addNodes.map((node) => this.doAdd(node, parentNode)));
|
|
1250
|
+
if (newNodes.length > 1) {
|
|
1251
|
+
const newNodeIds = newNodes.map((node) => node.id);
|
|
1252
|
+
stage?.multiSelect(newNodeIds);
|
|
1253
|
+
await this.multiSelect(newNodeIds);
|
|
1300
1254
|
} else {
|
|
1301
|
-
|
|
1255
|
+
await this.select(newNodes[0]);
|
|
1256
|
+
if (utils.isPage(newNodes[0])) {
|
|
1257
|
+
this.state.pageLength += 1;
|
|
1258
|
+
} else {
|
|
1259
|
+
stage?.select(newNodes[0].id);
|
|
1260
|
+
}
|
|
1302
1261
|
}
|
|
1303
|
-
this.
|
|
1304
|
-
|
|
1262
|
+
this.pushHistoryState();
|
|
1263
|
+
this.emit("add", newNodes);
|
|
1264
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1305
1265
|
}
|
|
1306
|
-
async
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1266
|
+
async doRemove(node) {
|
|
1267
|
+
const root = this.get("root");
|
|
1268
|
+
if (!root)
|
|
1269
|
+
throw new Error("\u6CA1\u6709root");
|
|
1270
|
+
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
1271
|
+
if (!parent || !curNode)
|
|
1272
|
+
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1273
|
+
const index = getNodeIndex(curNode, parent);
|
|
1274
|
+
if (typeof index !== "number" || index === -1)
|
|
1275
|
+
throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
|
|
1276
|
+
parent.items?.splice(index, 1);
|
|
1277
|
+
const stage = this.get("stage");
|
|
1278
|
+
stage?.remove({ id: node.id, root: this.get("root") });
|
|
1279
|
+
if (node.type === schema.NodeType.PAGE) {
|
|
1280
|
+
this.state.pageLength -= 1;
|
|
1281
|
+
if (root.items[0]) {
|
|
1282
|
+
await this.select(root.items[0]);
|
|
1283
|
+
stage?.select(root.items[0].id);
|
|
1284
|
+
} else {
|
|
1285
|
+
this.set("node", null);
|
|
1286
|
+
this.set("parent", null);
|
|
1287
|
+
this.set("page", null);
|
|
1288
|
+
this.set("stage", null);
|
|
1289
|
+
this.set("highlightNode", null);
|
|
1290
|
+
this.resetModifiedNodeId();
|
|
1291
|
+
historyService.reset();
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
} else {
|
|
1295
|
+
await this.select(parent);
|
|
1296
|
+
stage?.select(parent.id);
|
|
1310
1297
|
}
|
|
1311
|
-
|
|
1312
|
-
const removeParent = await beforeRemove(node);
|
|
1313
|
-
if (!removeParent)
|
|
1314
|
-
return node;
|
|
1315
|
-
this.addModifiedNodeId(removeParent.id);
|
|
1316
|
-
this.pushHistoryState();
|
|
1317
|
-
this.emit("remove", node);
|
|
1318
|
-
return node;
|
|
1298
|
+
this.addModifiedNodeId(parent.id);
|
|
1319
1299
|
}
|
|
1320
|
-
async
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
}));
|
|
1324
|
-
const nodeIds = nodes.map((node) => node.id);
|
|
1325
|
-
this.addModifiedNodeId(nodeIds.join("-"));
|
|
1300
|
+
async remove(nodeOrNodeList) {
|
|
1301
|
+
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1302
|
+
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1326
1303
|
this.pushHistoryState();
|
|
1327
|
-
this.emit("
|
|
1328
|
-
return nodes;
|
|
1304
|
+
this.emit("remove");
|
|
1329
1305
|
}
|
|
1330
|
-
async
|
|
1306
|
+
async doUpdate(config) {
|
|
1331
1307
|
if (!config?.id)
|
|
1332
1308
|
throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
|
|
1333
1309
|
const info = this.getNodeInfo(config.id, false);
|
|
@@ -1368,10 +1344,15 @@
|
|
|
1368
1344
|
this.set("page", newConfig);
|
|
1369
1345
|
}
|
|
1370
1346
|
this.addModifiedNodeId(newConfig.id);
|
|
1371
|
-
this.pushHistoryState();
|
|
1372
|
-
this.emit("update", newConfig);
|
|
1373
1347
|
return newConfig;
|
|
1374
1348
|
}
|
|
1349
|
+
async update(config) {
|
|
1350
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1351
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1352
|
+
this.pushHistoryState();
|
|
1353
|
+
this.emit("update", newNodes);
|
|
1354
|
+
return newNodes.length > 1 ? newNodes[0] : newNodes;
|
|
1355
|
+
}
|
|
1375
1356
|
async sort(id1, id2) {
|
|
1376
1357
|
const node = this.get("node");
|
|
1377
1358
|
const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
|
|
@@ -1393,20 +1374,22 @@
|
|
|
1393
1374
|
}
|
|
1394
1375
|
async paste(position = {}) {
|
|
1395
1376
|
const config = await storageService.getItem(COPY_STORAGE_KEY);
|
|
1396
|
-
if (!config)
|
|
1377
|
+
if (!Array.isArray(config))
|
|
1397
1378
|
return;
|
|
1398
1379
|
const pasteConfigs = await beforePaste(position, config);
|
|
1399
|
-
return
|
|
1380
|
+
return this.add(pasteConfigs);
|
|
1400
1381
|
}
|
|
1401
|
-
async
|
|
1402
|
-
const parent = this.
|
|
1403
|
-
|
|
1404
|
-
|
|
1382
|
+
async doAlignCenter(config) {
|
|
1383
|
+
const parent = this.getParentById(config.id);
|
|
1384
|
+
if (!parent)
|
|
1385
|
+
throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
|
|
1386
|
+
const node = lodashEs.cloneDeep(vue.toRaw(config));
|
|
1387
|
+
const layout = await this.getLayout(parent, node);
|
|
1405
1388
|
if (layout === Layout.RELATIVE) {
|
|
1406
|
-
return;
|
|
1389
|
+
return config;
|
|
1407
1390
|
}
|
|
1408
1391
|
if (!node.style)
|
|
1409
|
-
return;
|
|
1392
|
+
return config;
|
|
1410
1393
|
const stage = this.get("stage");
|
|
1411
1394
|
const doc = stage?.renderer.contentWindow?.document;
|
|
1412
1395
|
if (doc) {
|
|
@@ -1418,14 +1401,15 @@
|
|
|
1418
1401
|
} else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
|
|
1419
1402
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
1420
1403
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
this.
|
|
1428
|
-
|
|
1404
|
+
return node;
|
|
1405
|
+
}
|
|
1406
|
+
async alignCenter(config) {
|
|
1407
|
+
const nodes = Array.isArray(config) ? config : [config];
|
|
1408
|
+
const stage = this.get("stage");
|
|
1409
|
+
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1410
|
+
const newNode = await this.update(newNodes);
|
|
1411
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
1412
|
+
return newNode;
|
|
1429
1413
|
}
|
|
1430
1414
|
async moveLayer(offset) {
|
|
1431
1415
|
const parent = this.get("parent");
|
|
@@ -1459,7 +1443,7 @@
|
|
|
1459
1443
|
return srcValue;
|
|
1460
1444
|
}
|
|
1461
1445
|
});
|
|
1462
|
-
newConfig.style = getInitPositionStyle(newConfig.style, layout
|
|
1446
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1463
1447
|
target.items.push(newConfig);
|
|
1464
1448
|
await stage.select(targetId);
|
|
1465
1449
|
await stage.update({ config: lodashEs.cloneDeep(target), root });
|
|
@@ -1485,7 +1469,7 @@
|
|
|
1485
1469
|
const node = vue.toRaw(this.get("node"));
|
|
1486
1470
|
if (!node || utils.isPage(node))
|
|
1487
1471
|
return;
|
|
1488
|
-
const { style, id } = node;
|
|
1472
|
+
const { style, id, type } = node;
|
|
1489
1473
|
if (!style || style.position !== "absolute")
|
|
1490
1474
|
return;
|
|
1491
1475
|
if (top && !utils.isNumber(style.top))
|
|
@@ -1494,6 +1478,7 @@
|
|
|
1494
1478
|
return;
|
|
1495
1479
|
this.update({
|
|
1496
1480
|
id,
|
|
1481
|
+
type,
|
|
1497
1482
|
style: {
|
|
1498
1483
|
...style,
|
|
1499
1484
|
left: Number(style.left) + left,
|
|
@@ -1852,7 +1837,7 @@
|
|
|
1852
1837
|
}
|
|
1853
1838
|
};
|
|
1854
1839
|
|
|
1855
|
-
const _sfc_main$
|
|
1840
|
+
const _sfc_main$j = vue.defineComponent({
|
|
1856
1841
|
components: { Plus: iconsVue.Plus },
|
|
1857
1842
|
setup() {
|
|
1858
1843
|
const services = vue.inject("services");
|
|
@@ -1872,7 +1857,7 @@
|
|
|
1872
1857
|
|
|
1873
1858
|
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
1874
1859
|
const _hoisted_2$4 = { class: "m-editor-empty-content" };
|
|
1875
|
-
const _hoisted_3$
|
|
1860
|
+
const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
1876
1861
|
function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1877
1862
|
const _component_plus = vue.resolveComponent("plus");
|
|
1878
1863
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
@@ -1890,14 +1875,14 @@
|
|
|
1890
1875
|
_: 1
|
|
1891
1876
|
})
|
|
1892
1877
|
]),
|
|
1893
|
-
_hoisted_3$
|
|
1878
|
+
_hoisted_3$1
|
|
1894
1879
|
])
|
|
1895
1880
|
])
|
|
1896
1881
|
]);
|
|
1897
1882
|
}
|
|
1898
|
-
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1883
|
+
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
|
|
1899
1884
|
|
|
1900
|
-
const _sfc_main$
|
|
1885
|
+
const _sfc_main$i = vue.defineComponent({
|
|
1901
1886
|
name: "m-editor-resize",
|
|
1902
1887
|
props: {
|
|
1903
1888
|
type: {
|
|
@@ -1949,9 +1934,9 @@
|
|
|
1949
1934
|
vue.renderSlot(_ctx.$slots, "default")
|
|
1950
1935
|
], 512);
|
|
1951
1936
|
}
|
|
1952
|
-
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1937
|
+
const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
|
|
1953
1938
|
|
|
1954
|
-
const _sfc_main$
|
|
1939
|
+
const _sfc_main$h = vue.defineComponent({
|
|
1955
1940
|
components: {
|
|
1956
1941
|
AddPageBox,
|
|
1957
1942
|
Resizer
|
|
@@ -2032,9 +2017,9 @@
|
|
|
2032
2017
|
]))
|
|
2033
2018
|
]);
|
|
2034
2019
|
}
|
|
2035
|
-
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2020
|
+
const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
|
|
2036
2021
|
|
|
2037
|
-
const _sfc_main$
|
|
2022
|
+
const _sfc_main$g = vue.defineComponent({
|
|
2038
2023
|
name: "m-icon",
|
|
2039
2024
|
components: { Edit: iconsVue.Edit },
|
|
2040
2025
|
props: {
|
|
@@ -2058,10 +2043,12 @@
|
|
|
2058
2043
|
vue.createVNode(_component_edit)
|
|
2059
2044
|
]),
|
|
2060
2045
|
_: 1
|
|
2061
|
-
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2046
|
+
})) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
|
|
2047
|
+
default: vue.withCtx(() => [
|
|
2048
|
+
vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
|
|
2049
|
+
]),
|
|
2050
|
+
_: 1
|
|
2051
|
+
})) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
2065
2052
|
key: 2,
|
|
2066
2053
|
class: vue.normalizeClass(_ctx.icon)
|
|
2067
2054
|
}, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
|
|
@@ -2071,7 +2058,7 @@
|
|
|
2071
2058
|
_: 1
|
|
2072
2059
|
}));
|
|
2073
2060
|
}
|
|
2074
|
-
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2061
|
+
const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
|
|
2075
2062
|
|
|
2076
2063
|
const _hoisted_1$7 = {
|
|
2077
2064
|
key: 1,
|
|
@@ -2081,8 +2068,8 @@
|
|
|
2081
2068
|
class: "menu-item-text",
|
|
2082
2069
|
style: { "margin": "0 5px" }
|
|
2083
2070
|
};
|
|
2084
|
-
const _hoisted_3
|
|
2085
|
-
const _sfc_main$
|
|
2071
|
+
const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2072
|
+
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2086
2073
|
__name: "ToolButton",
|
|
2087
2074
|
props: {
|
|
2088
2075
|
data: {
|
|
@@ -2325,7 +2312,7 @@
|
|
|
2325
2312
|
})) : vue.createCommentVNode("", true)
|
|
2326
2313
|
]),
|
|
2327
2314
|
default: vue.withCtx(() => [
|
|
2328
|
-
vue.createElementVNode("span", _hoisted_3
|
|
2315
|
+
vue.createElementVNode("span", _hoisted_3, [
|
|
2329
2316
|
vue.createTextVNode(vue.toDisplayString(vue.unref(item).text), 1),
|
|
2330
2317
|
vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
|
|
2331
2318
|
default: vue.withCtx(() => [
|
|
@@ -2342,9 +2329,9 @@
|
|
|
2342
2329
|
}
|
|
2343
2330
|
});
|
|
2344
2331
|
|
|
2345
|
-
const _sfc_main$
|
|
2332
|
+
const _sfc_main$e = vue.defineComponent({
|
|
2346
2333
|
name: "nav-menu",
|
|
2347
|
-
components: { ToolButton: _sfc_main$
|
|
2334
|
+
components: { ToolButton: _sfc_main$f },
|
|
2348
2335
|
props: {
|
|
2349
2336
|
data: {
|
|
2350
2337
|
type: Object,
|
|
@@ -2385,9 +2372,9 @@
|
|
|
2385
2372
|
}), 128))
|
|
2386
2373
|
], 4);
|
|
2387
2374
|
}
|
|
2388
|
-
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2375
|
+
const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
|
|
2389
2376
|
|
|
2390
|
-
const _sfc_main$
|
|
2377
|
+
const _sfc_main$d = vue.defineComponent({
|
|
2391
2378
|
name: "m-editor-props-panel",
|
|
2392
2379
|
emits: ["mounted"],
|
|
2393
2380
|
setup(props, { emit }) {
|
|
@@ -2451,9 +2438,9 @@
|
|
|
2451
2438
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
|
|
2452
2439
|
]);
|
|
2453
2440
|
}
|
|
2454
|
-
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2441
|
+
const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
|
|
2455
2442
|
|
|
2456
|
-
const _sfc_main$
|
|
2443
|
+
const _sfc_main$c = vue.defineComponent({
|
|
2457
2444
|
name: "ui-component-panel",
|
|
2458
2445
|
components: { MIcon },
|
|
2459
2446
|
setup() {
|
|
@@ -2594,9 +2581,9 @@
|
|
|
2594
2581
|
_: 3
|
|
2595
2582
|
});
|
|
2596
2583
|
}
|
|
2597
|
-
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2584
|
+
const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
2598
2585
|
|
|
2599
|
-
const _sfc_main$
|
|
2586
|
+
const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
|
|
2600
2587
|
__name: "ContentMenu",
|
|
2601
2588
|
props: {
|
|
2602
2589
|
menuData: { default: () => [] },
|
|
@@ -2685,7 +2672,7 @@
|
|
|
2685
2672
|
}, [
|
|
2686
2673
|
vue.createElementVNode("div", null, [
|
|
2687
2674
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
|
|
2688
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
2675
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$f, {
|
|
2689
2676
|
"event-type": "mouseup",
|
|
2690
2677
|
data: item,
|
|
2691
2678
|
key: index,
|
|
@@ -2709,8 +2696,8 @@
|
|
|
2709
2696
|
}
|
|
2710
2697
|
});
|
|
2711
2698
|
|
|
2712
|
-
const _sfc_main$
|
|
2713
|
-
components: { ContentMenu: _sfc_main$
|
|
2699
|
+
const _sfc_main$a = vue.defineComponent({
|
|
2700
|
+
components: { ContentMenu: _sfc_main$b },
|
|
2714
2701
|
setup() {
|
|
2715
2702
|
const services = vue.inject("services");
|
|
2716
2703
|
const menu = vue.ref();
|
|
@@ -2801,7 +2788,7 @@
|
|
|
2801
2788
|
style: { "overflow": "initial" }
|
|
2802
2789
|
}, null, 8, ["menu-data"]);
|
|
2803
2790
|
}
|
|
2804
|
-
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
2791
|
+
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
|
|
2805
2792
|
|
|
2806
2793
|
const throttleTime = 150;
|
|
2807
2794
|
const select = async (data, editorService) => {
|
|
@@ -2901,7 +2888,7 @@
|
|
|
2901
2888
|
tree.value?.filter(val);
|
|
2902
2889
|
}
|
|
2903
2890
|
});
|
|
2904
|
-
const _sfc_main$
|
|
2891
|
+
const _sfc_main$9 = vue.defineComponent({
|
|
2905
2892
|
name: "magic-editor-layer-panel",
|
|
2906
2893
|
components: { LayerMenu },
|
|
2907
2894
|
setup() {
|
|
@@ -3012,9 +2999,9 @@
|
|
|
3012
2999
|
_: 3
|
|
3013
3000
|
});
|
|
3014
3001
|
}
|
|
3015
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3002
|
+
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
|
|
3016
3003
|
|
|
3017
|
-
const _sfc_main$
|
|
3004
|
+
const _sfc_main$8 = vue.defineComponent({
|
|
3018
3005
|
components: { MIcon },
|
|
3019
3006
|
props: {
|
|
3020
3007
|
data: {
|
|
@@ -3102,9 +3089,9 @@
|
|
|
3102
3089
|
_: 3
|
|
3103
3090
|
}, 8, ["name"])) : vue.createCommentVNode("", true);
|
|
3104
3091
|
}
|
|
3105
|
-
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3092
|
+
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
|
|
3106
3093
|
|
|
3107
|
-
const _sfc_main$
|
|
3094
|
+
const _sfc_main$7 = vue.defineComponent({
|
|
3108
3095
|
components: { TabPane },
|
|
3109
3096
|
name: "m-sidebar",
|
|
3110
3097
|
props: {
|
|
@@ -3159,89 +3146,69 @@
|
|
|
3159
3146
|
_: 3
|
|
3160
3147
|
}, 8, ["modelValue"])) : vue.createCommentVNode("", true);
|
|
3161
3148
|
}
|
|
3162
|
-
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3149
|
+
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
|
|
3163
3150
|
|
|
3164
|
-
const
|
|
3165
|
-
|
|
3166
|
-
ref: "pageBar"
|
|
3167
|
-
};
|
|
3168
|
-
const _hoisted_2 = ["onClick"];
|
|
3169
|
-
const _hoisted_3 = { class: "m-editor-page-bar-title" };
|
|
3170
|
-
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3171
|
-
__name: "PageBar",
|
|
3151
|
+
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
3152
|
+
__name: "PageBarScrollContainer",
|
|
3172
3153
|
setup(__props) {
|
|
3173
|
-
const
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
}
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
}
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
}
|
|
3201
|
-
} else if (type === "right") {
|
|
3202
|
-
translateLeft -= 100;
|
|
3203
|
-
if (-translateLeft > maxScrollLeft) {
|
|
3204
|
-
translateLeft = -maxScrollLeft;
|
|
3205
|
-
}
|
|
3206
|
-
} else if (type === "start") {
|
|
3154
|
+
const services = vue.inject("services");
|
|
3155
|
+
const editorService = services?.editorService;
|
|
3156
|
+
const pageBar = vue.ref();
|
|
3157
|
+
const itemsContainer = vue.ref();
|
|
3158
|
+
const pageBarWidth = vue.ref(0);
|
|
3159
|
+
const canScroll = vue.ref(false);
|
|
3160
|
+
const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
|
|
3161
|
+
let translateLeft = 0;
|
|
3162
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3163
|
+
for (const { contentRect } of entries) {
|
|
3164
|
+
const { width } = contentRect;
|
|
3165
|
+
pageBarWidth.value = width || 0;
|
|
3166
|
+
setCanScroll();
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
3169
|
+
const setCanScroll = () => {
|
|
3170
|
+
if (itemsContainer.value) {
|
|
3171
|
+
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
|
3172
|
+
}
|
|
3173
|
+
};
|
|
3174
|
+
const scroll = (type) => {
|
|
3175
|
+
if (!itemsContainer.value)
|
|
3176
|
+
return;
|
|
3177
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
3178
|
+
if (type === "left") {
|
|
3179
|
+
translateLeft += 100;
|
|
3180
|
+
if (translateLeft > 0) {
|
|
3207
3181
|
translateLeft = 0;
|
|
3208
|
-
}
|
|
3182
|
+
}
|
|
3183
|
+
} else if (type === "right") {
|
|
3184
|
+
translateLeft -= 100;
|
|
3185
|
+
if (-translateLeft > maxScrollLeft) {
|
|
3209
3186
|
translateLeft = -maxScrollLeft;
|
|
3210
3187
|
}
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
}
|
|
3216
|
-
|
|
3217
|
-
resizeObserver.disconnect();
|
|
3218
|
-
});
|
|
3219
|
-
vue.watch(() => root2.value?.items.length, (length = 0, preLength = 0) => {
|
|
3220
|
-
setTimeout(() => {
|
|
3221
|
-
setCanScroll();
|
|
3222
|
-
if (length < preLength) {
|
|
3223
|
-
scroll("start");
|
|
3224
|
-
} else {
|
|
3225
|
-
scroll("end");
|
|
3226
|
-
}
|
|
3227
|
-
});
|
|
3228
|
-
});
|
|
3229
|
-
return {
|
|
3230
|
-
pageBar,
|
|
3231
|
-
itemsContainer,
|
|
3232
|
-
canScroll,
|
|
3233
|
-
itemsContainerWidth,
|
|
3234
|
-
scroll
|
|
3235
|
-
};
|
|
3188
|
+
} else if (type === "start") {
|
|
3189
|
+
translateLeft = 0;
|
|
3190
|
+
} else if (type === "end") {
|
|
3191
|
+
translateLeft = -maxScrollLeft;
|
|
3192
|
+
}
|
|
3193
|
+
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
3236
3194
|
};
|
|
3237
|
-
|
|
3238
|
-
|
|
3195
|
+
vue.onMounted(() => {
|
|
3196
|
+
pageBar.value && resizeObserver.observe(pageBar.value);
|
|
3197
|
+
});
|
|
3198
|
+
vue.onUnmounted(() => {
|
|
3199
|
+
resizeObserver.disconnect();
|
|
3200
|
+
});
|
|
3239
3201
|
const root = vue.computed(() => editorService?.get("root"));
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3202
|
+
vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
|
|
3203
|
+
setTimeout(() => {
|
|
3204
|
+
setCanScroll();
|
|
3205
|
+
if (length < preLength) {
|
|
3206
|
+
scroll("start");
|
|
3207
|
+
} else {
|
|
3208
|
+
scroll("end");
|
|
3209
|
+
}
|
|
3210
|
+
});
|
|
3211
|
+
});
|
|
3245
3212
|
const addPage = () => {
|
|
3246
3213
|
if (!editorService)
|
|
3247
3214
|
return;
|
|
@@ -3251,21 +3218,13 @@
|
|
|
3251
3218
|
};
|
|
3252
3219
|
editorService.add(pageConfig);
|
|
3253
3220
|
};
|
|
3254
|
-
const copy = (node) => {
|
|
3255
|
-
node && editorService?.copy(node);
|
|
3256
|
-
editorService?.paste({
|
|
3257
|
-
left: 0,
|
|
3258
|
-
top: 0
|
|
3259
|
-
});
|
|
3260
|
-
};
|
|
3261
|
-
const remove = (node) => {
|
|
3262
|
-
editorService?.remove(node);
|
|
3263
|
-
};
|
|
3264
3221
|
return (_ctx, _cache) => {
|
|
3265
3222
|
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3223
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3224
|
+
class: "m-editor-page-bar",
|
|
3225
|
+
ref_key: "pageBar",
|
|
3226
|
+
ref: pageBar
|
|
3227
|
+
}, [
|
|
3269
3228
|
vue.createElementVNode("div", {
|
|
3270
3229
|
id: "m-editor-page-bar-add-icon",
|
|
3271
3230
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
@@ -3278,10 +3237,10 @@
|
|
|
3278
3237
|
_: 1
|
|
3279
3238
|
})
|
|
3280
3239
|
]),
|
|
3281
|
-
|
|
3240
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3282
3241
|
key: 0,
|
|
3283
3242
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3284
|
-
onClick: _cache[0] || (_cache[0] = ($event) =>
|
|
3243
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3285
3244
|
}, [
|
|
3286
3245
|
vue.createVNode(_component_el_icon, null, {
|
|
3287
3246
|
default: vue.withCtx(() => [
|
|
@@ -3293,16 +3252,64 @@
|
|
|
3293
3252
|
vue.unref(root) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3294
3253
|
key: 1,
|
|
3295
3254
|
class: "m-editor-page-bar-items",
|
|
3296
|
-
|
|
3297
|
-
|
|
3255
|
+
ref_key: "itemsContainer",
|
|
3256
|
+
ref: itemsContainer,
|
|
3257
|
+
style: vue.normalizeStyle(`width: ${vue.unref(itemsContainerWidth)}px`)
|
|
3298
3258
|
}, [
|
|
3299
|
-
|
|
3259
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
3260
|
+
], 4)) : vue.createCommentVNode("", true),
|
|
3261
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
3262
|
+
key: 2,
|
|
3263
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3264
|
+
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3265
|
+
}, [
|
|
3266
|
+
vue.createVNode(_component_el_icon, null, {
|
|
3267
|
+
default: vue.withCtx(() => [
|
|
3268
|
+
vue.createVNode(vue.unref(iconsVue.ArrowRightBold))
|
|
3269
|
+
]),
|
|
3270
|
+
_: 1
|
|
3271
|
+
})
|
|
3272
|
+
])) : vue.createCommentVNode("", true)
|
|
3273
|
+
], 512);
|
|
3274
|
+
};
|
|
3275
|
+
}
|
|
3276
|
+
});
|
|
3277
|
+
|
|
3278
|
+
const _hoisted_1$2 = ["onClick"];
|
|
3279
|
+
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
3280
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3281
|
+
__name: "PageBar",
|
|
3282
|
+
setup(__props) {
|
|
3283
|
+
const services = vue.inject("services");
|
|
3284
|
+
const editorService = services?.editorService;
|
|
3285
|
+
const root = vue.computed(() => editorService?.get("root"));
|
|
3286
|
+
const page = vue.computed(() => editorService?.get("page"));
|
|
3287
|
+
const switchPage = (page2) => {
|
|
3288
|
+
editorService?.select(page2);
|
|
3289
|
+
};
|
|
3290
|
+
const copy = (node) => {
|
|
3291
|
+
node && editorService?.copy(node);
|
|
3292
|
+
editorService?.paste({
|
|
3293
|
+
left: 0,
|
|
3294
|
+
top: 0
|
|
3295
|
+
});
|
|
3296
|
+
};
|
|
3297
|
+
const remove = (node) => {
|
|
3298
|
+
editorService?.remove(node);
|
|
3299
|
+
};
|
|
3300
|
+
return (_ctx, _cache) => {
|
|
3301
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
3302
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
3303
|
+
const _component_el_popover = vue.resolveComponent("el-popover");
|
|
3304
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$6, null, {
|
|
3305
|
+
default: vue.withCtx(() => [
|
|
3306
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
|
|
3300
3307
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
3301
|
-
key: item.key,
|
|
3302
3308
|
class: vue.normalizeClass(["m-editor-page-bar-item", { active: vue.unref(page)?.id === item.id }]),
|
|
3309
|
+
key: item.key,
|
|
3303
3310
|
onClick: ($event) => switchPage(item)
|
|
3304
3311
|
}, [
|
|
3305
|
-
vue.createElementVNode("div",
|
|
3312
|
+
vue.createElementVNode("div", _hoisted_2, [
|
|
3306
3313
|
vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3307
3314
|
vue.createVNode(_component_el_tooltip, {
|
|
3308
3315
|
effect: "dark",
|
|
@@ -3333,7 +3340,7 @@
|
|
|
3333
3340
|
default: vue.withCtx(() => [
|
|
3334
3341
|
vue.createElementVNode("div", null, [
|
|
3335
3342
|
vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3336
|
-
vue.createVNode(_sfc_main$
|
|
3343
|
+
vue.createVNode(_sfc_main$f, {
|
|
3337
3344
|
data: {
|
|
3338
3345
|
type: "button",
|
|
3339
3346
|
text: "\u590D\u5236",
|
|
@@ -3341,7 +3348,7 @@
|
|
|
3341
3348
|
handler: () => copy(item)
|
|
3342
3349
|
}
|
|
3343
3350
|
}, null, 8, ["data"]),
|
|
3344
|
-
vue.createVNode(_sfc_main$
|
|
3351
|
+
vue.createVNode(_sfc_main$f, {
|
|
3345
3352
|
data: {
|
|
3346
3353
|
type: "button",
|
|
3347
3354
|
text: "\u5220\u9664",
|
|
@@ -3354,22 +3361,11 @@
|
|
|
3354
3361
|
]),
|
|
3355
3362
|
_: 2
|
|
3356
3363
|
}, 1024)
|
|
3357
|
-
], 10,
|
|
3364
|
+
], 10, _hoisted_1$2);
|
|
3358
3365
|
}), 128))
|
|
3359
|
-
]
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3363
|
-
onClick: _cache[1] || (_cache[1] = ($event) => vue.unref(scrollState).scroll("right"))
|
|
3364
|
-
}, [
|
|
3365
|
-
vue.createVNode(_component_el_icon, null, {
|
|
3366
|
-
default: vue.withCtx(() => [
|
|
3367
|
-
vue.createVNode(vue.unref(iconsVue.ArrowRightBold))
|
|
3368
|
-
]),
|
|
3369
|
-
_: 1
|
|
3370
|
-
})
|
|
3371
|
-
])) : vue.createCommentVNode("", true)
|
|
3372
|
-
], 512);
|
|
3366
|
+
]),
|
|
3367
|
+
_: 3
|
|
3368
|
+
});
|
|
3373
3369
|
};
|
|
3374
3370
|
}
|
|
3375
3371
|
});
|
|
@@ -3615,11 +3611,11 @@
|
|
|
3615
3611
|
{
|
|
3616
3612
|
type: "button",
|
|
3617
3613
|
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
3618
|
-
display: () => canCenter.value
|
|
3614
|
+
display: () => canCenter.value,
|
|
3619
3615
|
handler: () => {
|
|
3620
|
-
if (!
|
|
3616
|
+
if (!nodes.value)
|
|
3621
3617
|
return;
|
|
3622
|
-
editorService?.alignCenter(
|
|
3618
|
+
editorService?.alignCenter(nodes.value);
|
|
3623
3619
|
}
|
|
3624
3620
|
},
|
|
3625
3621
|
{
|
|
@@ -3715,10 +3711,6 @@
|
|
|
3715
3711
|
},
|
|
3716
3712
|
...stageContentMenu
|
|
3717
3713
|
]);
|
|
3718
|
-
vue.onMounted(async () => {
|
|
3719
|
-
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3720
|
-
canPaste.value = data !== "undefined" && !!data;
|
|
3721
|
-
});
|
|
3722
3714
|
vue.watch(parent, async () => {
|
|
3723
3715
|
if (!parent.value || !editorService)
|
|
3724
3716
|
return canCenter.value = false;
|
|
@@ -3727,12 +3719,14 @@
|
|
|
3727
3719
|
const isTypeConform = nodes.value?.every((selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
|
|
3728
3720
|
canCenter.value = isLayoutConform && !!isTypeConform;
|
|
3729
3721
|
}, { immediate: true });
|
|
3730
|
-
const show = (e) => {
|
|
3722
|
+
const show = async (e) => {
|
|
3731
3723
|
menu.value?.show(e);
|
|
3724
|
+
const data = await storageService.getItem(COPY_STORAGE_KEY);
|
|
3725
|
+
canPaste.value = data !== "undefined" && !!data;
|
|
3732
3726
|
};
|
|
3733
3727
|
expose({ show });
|
|
3734
3728
|
return (_ctx, _cache) => {
|
|
3735
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3729
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$b, {
|
|
3736
3730
|
"menu-data": menuData,
|
|
3737
3731
|
ref_key: "menu",
|
|
3738
3732
|
ref: menu
|
|
@@ -3774,6 +3768,7 @@
|
|
|
3774
3768
|
isContainer: stageOptions.isContainer,
|
|
3775
3769
|
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
3776
3770
|
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
3771
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
3777
3772
|
canSelect: (el, event, stop) => {
|
|
3778
3773
|
const elCanSelect = stageOptions.canSelect(el);
|
|
3779
3774
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
@@ -3802,10 +3797,12 @@
|
|
|
3802
3797
|
});
|
|
3803
3798
|
stage?.on("update", (ev) => {
|
|
3804
3799
|
if (ev.parentEl) {
|
|
3805
|
-
|
|
3800
|
+
for (const data of ev.data) {
|
|
3801
|
+
services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
3802
|
+
}
|
|
3806
3803
|
return;
|
|
3807
3804
|
}
|
|
3808
|
-
services?.editorService.update({ id:
|
|
3805
|
+
services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
3809
3806
|
});
|
|
3810
3807
|
stage?.on("sort", (ev) => {
|
|
3811
3808
|
services?.editorService.sort(ev.src, ev.dist);
|
|
@@ -3976,7 +3973,7 @@
|
|
|
3976
3973
|
nodes.value && services?.editorService.copy(nodes.value);
|
|
3977
3974
|
}).keydown([ctrl, "v"], (e) => {
|
|
3978
3975
|
e.inputEvent.preventDefault();
|
|
3979
|
-
nodes.value && services?.editorService.paste();
|
|
3976
|
+
nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
|
|
3980
3977
|
}).keydown([ctrl, "x"], (e) => {
|
|
3981
3978
|
e.inputEvent.preventDefault();
|
|
3982
3979
|
if (!nodes.value || utils.isPage(nodes.value[0]))
|
|
@@ -4280,6 +4277,10 @@
|
|
|
4280
4277
|
type: Number,
|
|
4281
4278
|
default: 800
|
|
4282
4279
|
},
|
|
4280
|
+
containerHighlightType: {
|
|
4281
|
+
type: String,
|
|
4282
|
+
default: StageCore.ContainerHighlightType.DEFAULT
|
|
4283
|
+
},
|
|
4283
4284
|
stageRect: {
|
|
4284
4285
|
type: [String, Object]
|
|
4285
4286
|
},
|
|
@@ -4350,7 +4351,8 @@
|
|
|
4350
4351
|
updateDragEl: props.updateDragEl,
|
|
4351
4352
|
isContainer: props.isContainer,
|
|
4352
4353
|
containerHighlightClassName: props.containerHighlightClassName,
|
|
4353
|
-
containerHighlightDuration: props.containerHighlightDuration
|
|
4354
|
+
containerHighlightDuration: props.containerHighlightDuration,
|
|
4355
|
+
containerHighlightType: props.containerHighlightType
|
|
4354
4356
|
}));
|
|
4355
4357
|
return services;
|
|
4356
4358
|
}
|
|
@@ -4427,7 +4429,7 @@
|
|
|
4427
4429
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4428
4430
|
setConfig(option);
|
|
4429
4431
|
app.component(Editor.name, Editor);
|
|
4430
|
-
app.component(
|
|
4432
|
+
app.component("m-fields-ui-select", _sfc_main$l);
|
|
4431
4433
|
app.component(CodeLink.name, CodeLink);
|
|
4432
4434
|
app.component(Code.name, Code);
|
|
4433
4435
|
app.component(CodeEditor.name, CodeEditor);
|
|
@@ -4446,7 +4448,7 @@
|
|
|
4446
4448
|
exports.PropsPanel = PropsPanel;
|
|
4447
4449
|
exports.TMagicCodeEditor = CodeEditor;
|
|
4448
4450
|
exports.TMagicEditor = Editor;
|
|
4449
|
-
exports.ToolButton = _sfc_main$
|
|
4451
|
+
exports.ToolButton = _sfc_main$f;
|
|
4450
4452
|
exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
|
|
4451
4453
|
exports.change2Fixed = change2Fixed;
|
|
4452
4454
|
exports.debug = debug;
|
|
@@ -4456,6 +4458,7 @@
|
|
|
4456
4458
|
exports.eventsService = eventsService;
|
|
4457
4459
|
exports.fillConfig = fillConfig;
|
|
4458
4460
|
exports.fixNodeLeft = fixNodeLeft;
|
|
4461
|
+
exports.fixNodePosition = fixNodePosition;
|
|
4459
4462
|
exports.generatePageName = generatePageName;
|
|
4460
4463
|
exports.generatePageNameByApp = generatePageNameByApp;
|
|
4461
4464
|
exports.getConfig = getConfig;
|