@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.
@@ -1,9 +1,9 @@
1
1
  import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createVNode, unref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, markRaw, renderList, normalizeProps, mergeProps, getCurrentInstance, Teleport, nextTick, toHandlers, createSlots, provide } from 'vue';
2
2
  import serialize from 'serialize-javascript';
3
- import { Delete, Close, Plus, Edit, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, ArrowDown, Files, DocumentCopy, Coin, ArrowLeftBold, CaretBottom, ArrowRightBold, Top, Bottom } from '@element-plus/icons-vue';
3
+ import { Delete, Close, Plus, Edit, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, ArrowDown, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
4
4
  import { throttle, cloneDeep, mergeWith, isEmpty, uniq } from 'lodash-es';
5
5
  import * as monaco from 'monaco-editor';
6
- import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS } from '@tmagic/stage';
6
+ import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
7
7
  import { NodeType } from '@tmagic/schema';
8
8
  import { isPop, getNodePath, isNumber, isPage, toLine, removeClassNameByClassName } from '@tmagic/utils';
9
9
  import { EventEmitter } from 'events';
@@ -19,7 +19,7 @@ if (typeof globalThis === "undefined") {
19
19
  window.globalThis = window;
20
20
  }
21
21
 
22
- const _sfc_main$m = defineComponent({
22
+ const _sfc_main$n = defineComponent({
23
23
  name: "m-fields-vs-code",
24
24
  props: ["model", "name", "config", "prop"],
25
25
  emits: ["change"],
@@ -54,9 +54,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
54
54
  onSave: _ctx.save
55
55
  }, null, 8, ["style", "init-values", "language", "onSave"]);
56
56
  }
57
- const Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$g]]);
57
+ const Code = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$g]]);
58
58
 
59
- const _sfc_main$l = defineComponent({
59
+ const _sfc_main$m = defineComponent({
60
60
  name: "m-fields-code-link",
61
61
  props: {
62
62
  config: {
@@ -121,13 +121,12 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
121
121
  onChange: _ctx.changeHandler
122
122
  }, null, 8, ["config", "model", "onChange"]);
123
123
  }
124
- const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$f]]);
124
+ const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
125
125
 
126
126
  const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
127
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
127
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
128
128
  __name: "UISelect",
129
129
  props: {
130
- labelWidth: null,
131
130
  config: null,
132
131
  model: null,
133
132
  prop: null,
@@ -251,7 +250,7 @@ const toString = (v, language) => {
251
250
  }
252
251
  return value;
253
252
  };
254
- const _sfc_main$j = defineComponent({
253
+ const _sfc_main$k = defineComponent({
255
254
  name: "magic-code-editor",
256
255
  props: {
257
256
  initValues: {
@@ -366,7 +365,7 @@ const _hoisted_1$c = {
366
365
  function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
367
366
  return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
368
367
  }
369
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$e]]);
368
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
370
369
 
371
370
  let $TMAGIC_EDITOR = {};
372
371
  const setConfig = (option) => {
@@ -744,10 +743,10 @@ const getRelativeStyle = (style = {}) => ({
744
743
  top: 0,
745
744
  left: 0
746
745
  });
747
- const getMiddleTop = (style = {}, parentNode, stage) => {
748
- let height = style.height || 0;
749
- if (!stage || typeof style.top !== "undefined" || !parentNode.style)
750
- return style.top;
746
+ const getMiddleTop = (node, parentNode, stage) => {
747
+ let height = node.style?.height || 0;
748
+ if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
749
+ return node.style?.top;
751
750
  if (!isNumber(height)) {
752
751
  height = 0;
753
752
  }
@@ -758,12 +757,11 @@ const getMiddleTop = (style = {}, parentNode, stage) => {
758
757
  }
759
758
  return (parentHeight - height) / 2;
760
759
  };
761
- const getInitPositionStyle = (style = {}, layout, parentNode, stage) => {
760
+ const getInitPositionStyle = (style = {}, layout) => {
762
761
  if (layout === Layout.ABSOLUTE) {
763
762
  return {
764
763
  ...style,
765
- position: "absolute",
766
- top: getMiddleTop(style, parentNode, stage)
764
+ position: "absolute"
767
765
  };
768
766
  }
769
767
  if (layout === Layout.RELATIVE) {
@@ -855,6 +853,16 @@ const fixNodeLeft = (config, parent, doc) => {
855
853
  }
856
854
  return config.style.left;
857
855
  };
856
+ const fixNodePosition = (config, parent, stage) => {
857
+ if (config.style?.position !== "absolute") {
858
+ return config.style;
859
+ }
860
+ return {
861
+ ...config.style || {},
862
+ top: getMiddleTop(config, parent, stage),
863
+ left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
864
+ };
865
+ };
858
866
 
859
867
  class Props extends BaseService {
860
868
  state = reactive({
@@ -1011,36 +1019,6 @@ const beforePaste = async (position, config) => {
1011
1019
  }));
1012
1020
  return pasteConfigs;
1013
1021
  };
1014
- const beforeAdd = async (addNode, parent) => {
1015
- const { type, inputEvent, ...config } = addNode;
1016
- const curNode = editorService.get("node");
1017
- let parentNode;
1018
- const isPage2 = type === NodeType.PAGE;
1019
- if (isPage2) {
1020
- parentNode = editorService.get("root");
1021
- } else if (parent && typeof parent !== "function") {
1022
- parentNode = parent;
1023
- } else if (curNode.items) {
1024
- parentNode = curNode;
1025
- } else {
1026
- parentNode = editorService.getParentById(curNode.id, false);
1027
- }
1028
- if (!parentNode)
1029
- throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1030
- const layout = await editorService.getLayout(toRaw(parentNode), addNode);
1031
- const newNode = { ...toRaw(await propsService.getPropsValue(type, config)) };
1032
- newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, editorService.get("stage"));
1033
- if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
1034
- throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
1035
- }
1036
- parentNode?.items?.push(newNode);
1037
- return {
1038
- parentNode,
1039
- newNode,
1040
- layout,
1041
- isPage: isPage2
1042
- };
1043
- };
1044
1022
  const getPositionInContainer = (position = {}, id) => {
1045
1023
  let { left = 0, top = 0 } = position;
1046
1024
  const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
@@ -1052,55 +1030,17 @@ const getPositionInContainer = (position = {}, id) => {
1052
1030
  top
1053
1031
  };
1054
1032
  };
1055
- const notifyAddToStage = async (parentNode, newNode, layout) => {
1056
- const stage = editorService.get("stage");
1057
- const root = editorService.get("root");
1058
- await stage?.add({ config: cloneDeep(newNode), parent: cloneDeep(parentNode), root: cloneDeep(root) });
1059
- if (layout === Layout.ABSOLUTE) {
1060
- const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
1061
- if (typeof fixedLeft !== "undefined" && newNode.style) {
1062
- newNode.style.left = fixedLeft;
1063
- await stage?.update({ config: cloneDeep(newNode), root: cloneDeep(root) });
1064
- }
1065
- }
1066
- };
1067
- const beforeRemove = async (node) => {
1068
- if (!node?.id)
1069
- return;
1070
- const stage = editorService.get("stage");
1071
- const root = editorService.get("root");
1072
- if (!root)
1073
- throw new Error("\u6CA1\u6709root");
1074
- const { parent, node: curNode } = editorService.getNodeInfo(node.id, false);
1075
- if (!parent || !curNode)
1076
- throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1077
- const index = getNodeIndex(curNode, parent);
1078
- if (typeof index !== "number" || index === -1)
1079
- throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1080
- parent.items?.splice(index, 1);
1081
- stage?.remove({ id: node.id, root: cloneDeep(root) });
1082
- if (node.type === NodeType.PAGE) {
1083
- editorService.state.pageLength -= 1;
1084
- if (root.items[0]) {
1085
- await editorService.select(root.items[0]);
1086
- stage?.select(root.items[0].id);
1087
- } else {
1088
- editorService.set("node", null);
1089
- editorService.set("nodes", []);
1090
- editorService.set("parent", null);
1091
- editorService.set("page", null);
1092
- editorService.set("stage", null);
1093
- editorService.set("highlightNode", null);
1094
- editorService.resetModifiedNodeId();
1095
- historyService.reset();
1096
- editorService.emit("remove", node);
1097
- return;
1098
- }
1033
+ const getAddParent = (addNode) => {
1034
+ const curNode = editorService.get("node");
1035
+ let parentNode;
1036
+ if (!Array.isArray(addNode) && isPage(addNode)) {
1037
+ parentNode = editorService.get("root");
1038
+ } else if (curNode.items) {
1039
+ parentNode = curNode;
1099
1040
  } else {
1100
- await editorService.select(parent);
1101
- stage?.select(parent.id);
1041
+ parentNode = editorService.getParentById(curNode.id, false);
1102
1042
  }
1103
- return parent;
1043
+ return parentNode;
1104
1044
  };
1105
1045
 
1106
1046
  class Editor$1 extends BaseService {
@@ -1120,12 +1060,16 @@ class Editor$1 extends BaseService {
1120
1060
  super([
1121
1061
  "getLayout",
1122
1062
  "select",
1063
+ "doAdd",
1123
1064
  "add",
1065
+ "doRemove",
1124
1066
  "remove",
1067
+ "doUpdate",
1125
1068
  "update",
1126
1069
  "sort",
1127
1070
  "copy",
1128
1071
  "paste",
1072
+ "duAlignCenter",
1129
1073
  "alignCenter",
1130
1074
  "moveLayer",
1131
1075
  "moveToContainer",
@@ -1254,62 +1198,94 @@ class Editor$1 extends BaseService {
1254
1198
  });
1255
1199
  this.set("nodes", nodes);
1256
1200
  }
1257
- async multiAdd(configs) {
1201
+ async doAdd(node, parent) {
1202
+ const root = this.get("root");
1203
+ const curNode = this.get("node");
1258
1204
  const stage = this.get("stage");
1259
- const newNodes = await Promise.all(configs.map(async (configItem) => {
1260
- const { parentNode, newNode, layout } = await beforeAdd(configItem);
1261
- await notifyAddToStage(parentNode, newNode, layout);
1262
- return newNode;
1263
- }));
1264
- const newNodeIds = newNodes.map((node) => node.id);
1265
- this.addModifiedNodeId(newNodeIds.join("-"));
1266
- this.pushHistoryState();
1267
- stage?.multiSelect(newNodeIds);
1268
- this.emit("multiAdd", newNodes);
1269
- return newNodes;
1205
+ if ((parent?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && node.type !== NodeType.PAGE) {
1206
+ throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
1207
+ }
1208
+ const layout = await this.getLayout(toRaw(parent), node);
1209
+ node.style = getInitPositionStyle(node.style, layout);
1210
+ await stage?.add({ config: cloneDeep(node), parent: cloneDeep(parent), root: cloneDeep(root) });
1211
+ node.style = fixNodePosition(node, parent, stage);
1212
+ await stage?.update({ config: cloneDeep(node), root: cloneDeep(root) });
1213
+ parent?.items?.push(node);
1214
+ this.addModifiedNodeId(node.id);
1215
+ return node;
1270
1216
  }
1271
1217
  async add(addNode, parent) {
1272
1218
  const stage = this.get("stage");
1273
- const { parentNode, newNode, layout, isPage: isPage2 } = await beforeAdd(addNode, parent);
1274
- await notifyAddToStage(parentNode, newNode, layout);
1275
- await this.select(newNode);
1276
- this.addModifiedNodeId(newNode.id);
1277
- if (!isPage2) {
1278
- this.pushHistoryState();
1219
+ const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(addNode);
1220
+ if (!parentNode)
1221
+ throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1222
+ const addNodes = [];
1223
+ if (!Array.isArray(addNode)) {
1224
+ const { type, inputEvent, ...config } = addNode;
1225
+ if (!type)
1226
+ throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
1227
+ addNodes.push({ ...toRaw(await propsService.getPropsValue(type, config)) });
1228
+ } else {
1229
+ addNodes.push(...addNode);
1279
1230
  }
1280
- if (isPage2) {
1281
- this.state.pageLength += 1;
1231
+ const newNodes = await Promise.all(addNodes.map((node) => this.doAdd(node, parentNode)));
1232
+ if (newNodes.length > 1) {
1233
+ const newNodeIds = newNodes.map((node) => node.id);
1234
+ stage?.multiSelect(newNodeIds);
1235
+ await this.multiSelect(newNodeIds);
1282
1236
  } else {
1283
- stage?.select(newNode.id);
1237
+ await this.select(newNodes[0]);
1238
+ if (isPage(newNodes[0])) {
1239
+ this.state.pageLength += 1;
1240
+ } else {
1241
+ stage?.select(newNodes[0].id);
1242
+ }
1284
1243
  }
1285
- this.emit("add", newNode);
1286
- return newNode;
1244
+ this.pushHistoryState();
1245
+ this.emit("add", newNodes);
1246
+ return newNodes.length > 1 ? newNodes[0] : newNodes;
1287
1247
  }
1288
- async remove(nodeOrNodeList) {
1289
- if (Array.isArray(nodeOrNodeList)) {
1290
- const nodes = nodeOrNodeList;
1291
- return this.multiRemove(nodes);
1248
+ async doRemove(node) {
1249
+ const root = this.get("root");
1250
+ if (!root)
1251
+ throw new Error("\u6CA1\u6709root");
1252
+ const { parent, node: curNode } = this.getNodeInfo(node.id);
1253
+ if (!parent || !curNode)
1254
+ throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1255
+ const index = getNodeIndex(curNode, parent);
1256
+ if (typeof index !== "number" || index === -1)
1257
+ throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1258
+ parent.items?.splice(index, 1);
1259
+ const stage = this.get("stage");
1260
+ stage?.remove({ id: node.id, root: this.get("root") });
1261
+ if (node.type === NodeType.PAGE) {
1262
+ this.state.pageLength -= 1;
1263
+ if (root.items[0]) {
1264
+ await this.select(root.items[0]);
1265
+ stage?.select(root.items[0].id);
1266
+ } else {
1267
+ this.set("node", null);
1268
+ this.set("parent", null);
1269
+ this.set("page", null);
1270
+ this.set("stage", null);
1271
+ this.set("highlightNode", null);
1272
+ this.resetModifiedNodeId();
1273
+ historyService.reset();
1274
+ return;
1275
+ }
1276
+ } else {
1277
+ await this.select(parent);
1278
+ stage?.select(parent.id);
1292
1279
  }
1293
- const node = nodeOrNodeList;
1294
- const removeParent = await beforeRemove(node);
1295
- if (!removeParent)
1296
- return node;
1297
- this.addModifiedNodeId(removeParent.id);
1298
- this.pushHistoryState();
1299
- this.emit("remove", node);
1300
- return node;
1280
+ this.addModifiedNodeId(parent.id);
1301
1281
  }
1302
- async multiRemove(nodes) {
1303
- await Promise.all(nodes.map(async (removeNode) => {
1304
- await beforeRemove(removeNode);
1305
- }));
1306
- const nodeIds = nodes.map((node) => node.id);
1307
- this.addModifiedNodeId(nodeIds.join("-"));
1282
+ async remove(nodeOrNodeList) {
1283
+ const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
1284
+ await Promise.all(nodes.map((node) => this.doRemove(node)));
1308
1285
  this.pushHistoryState();
1309
- this.emit("multiRemove", nodes);
1310
- return nodes;
1286
+ this.emit("remove");
1311
1287
  }
1312
- async update(config) {
1288
+ async doUpdate(config) {
1313
1289
  if (!config?.id)
1314
1290
  throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
1315
1291
  const info = this.getNodeInfo(config.id, false);
@@ -1350,10 +1326,15 @@ class Editor$1 extends BaseService {
1350
1326
  this.set("page", newConfig);
1351
1327
  }
1352
1328
  this.addModifiedNodeId(newConfig.id);
1353
- this.pushHistoryState();
1354
- this.emit("update", newConfig);
1355
1329
  return newConfig;
1356
1330
  }
1331
+ async update(config) {
1332
+ const nodes = Array.isArray(config) ? config : [config];
1333
+ const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
1334
+ this.pushHistoryState();
1335
+ this.emit("update", newNodes);
1336
+ return newNodes.length > 1 ? newNodes[0] : newNodes;
1337
+ }
1357
1338
  async sort(id1, id2) {
1358
1339
  const node = this.get("node");
1359
1340
  const parent = cloneDeep(toRaw(this.get("parent")));
@@ -1375,20 +1356,22 @@ class Editor$1 extends BaseService {
1375
1356
  }
1376
1357
  async paste(position = {}) {
1377
1358
  const config = await storageService.getItem(COPY_STORAGE_KEY);
1378
- if (!config)
1359
+ if (!Array.isArray(config))
1379
1360
  return;
1380
1361
  const pasteConfigs = await beforePaste(position, config);
1381
- return await this.multiAdd(pasteConfigs);
1362
+ return this.add(pasteConfigs);
1382
1363
  }
1383
- async alignCenter(config) {
1384
- const parent = this.get("parent");
1385
- const node = this.get("node");
1386
- const layout = await this.getLayout(toRaw(parent), toRaw(node));
1364
+ async doAlignCenter(config) {
1365
+ const parent = this.getParentById(config.id);
1366
+ if (!parent)
1367
+ throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
1368
+ const node = cloneDeep(toRaw(config));
1369
+ const layout = await this.getLayout(parent, node);
1387
1370
  if (layout === Layout.RELATIVE) {
1388
- return;
1371
+ return config;
1389
1372
  }
1390
1373
  if (!node.style)
1391
- return;
1374
+ return config;
1392
1375
  const stage = this.get("stage");
1393
1376
  const doc = stage?.renderer.contentWindow?.document;
1394
1377
  if (doc) {
@@ -1400,14 +1383,15 @@ class Editor$1 extends BaseService {
1400
1383
  } else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
1401
1384
  node.style.left = (parent.style.width - node.style.width) / 2;
1402
1385
  }
1403
- await this.update(node);
1404
- this.get("stage")?.update({
1405
- config: cloneDeep(toRaw(node)),
1406
- root: cloneDeep(this.get("root"))
1407
- });
1408
- this.addModifiedNodeId(config.id);
1409
- this.pushHistoryState();
1410
- return config;
1386
+ return node;
1387
+ }
1388
+ async alignCenter(config) {
1389
+ const nodes = Array.isArray(config) ? config : [config];
1390
+ const stage = this.get("stage");
1391
+ const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
1392
+ const newNode = await this.update(newNodes);
1393
+ await stage?.multiSelect(newNodes.map((node) => node.id));
1394
+ return newNode;
1411
1395
  }
1412
1396
  async moveLayer(offset) {
1413
1397
  const parent = this.get("parent");
@@ -1441,7 +1425,7 @@ class Editor$1 extends BaseService {
1441
1425
  return srcValue;
1442
1426
  }
1443
1427
  });
1444
- newConfig.style = getInitPositionStyle(newConfig.style, layout, target, stage);
1428
+ newConfig.style = getInitPositionStyle(newConfig.style, layout);
1445
1429
  target.items.push(newConfig);
1446
1430
  await stage.select(targetId);
1447
1431
  await stage.update({ config: cloneDeep(target), root });
@@ -1467,7 +1451,7 @@ class Editor$1 extends BaseService {
1467
1451
  const node = toRaw(this.get("node"));
1468
1452
  if (!node || isPage(node))
1469
1453
  return;
1470
- const { style, id } = node;
1454
+ const { style, id, type } = node;
1471
1455
  if (!style || style.position !== "absolute")
1472
1456
  return;
1473
1457
  if (top && !isNumber(style.top))
@@ -1476,6 +1460,7 @@ class Editor$1 extends BaseService {
1476
1460
  return;
1477
1461
  this.update({
1478
1462
  id,
1463
+ type,
1479
1464
  style: {
1480
1465
  ...style,
1481
1466
  left: Number(style.left) + left,
@@ -1834,7 +1819,7 @@ const error = (...args) => {
1834
1819
  }
1835
1820
  };
1836
1821
 
1837
- const _sfc_main$i = defineComponent({
1822
+ const _sfc_main$j = defineComponent({
1838
1823
  components: { Plus },
1839
1824
  setup() {
1840
1825
  const services = inject("services");
@@ -1854,7 +1839,7 @@ const _sfc_main$i = defineComponent({
1854
1839
 
1855
1840
  const _hoisted_1$b = { class: "m-editor-empty-panel" };
1856
1841
  const _hoisted_2$4 = { class: "m-editor-empty-content" };
1857
- const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1842
+ const _hoisted_3$1 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1858
1843
  function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1859
1844
  const _component_plus = resolveComponent("plus");
1860
1845
  const _component_el_icon = resolveComponent("el-icon");
@@ -1872,14 +1857,14 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1872
1857
  _: 1
1873
1858
  })
1874
1859
  ]),
1875
- _hoisted_3$2
1860
+ _hoisted_3$1
1876
1861
  ])
1877
1862
  ])
1878
1863
  ]);
1879
1864
  }
1880
- const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$d]]);
1865
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
1881
1866
 
1882
- const _sfc_main$h = defineComponent({
1867
+ const _sfc_main$i = defineComponent({
1883
1868
  name: "m-editor-resize",
1884
1869
  props: {
1885
1870
  type: {
@@ -1931,9 +1916,9 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1931
1916
  renderSlot(_ctx.$slots, "default")
1932
1917
  ], 512);
1933
1918
  }
1934
- const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$c]]);
1919
+ const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
1935
1920
 
1936
- const _sfc_main$g = defineComponent({
1921
+ const _sfc_main$h = defineComponent({
1937
1922
  components: {
1938
1923
  AddPageBox,
1939
1924
  Resizer
@@ -2014,9 +1999,9 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2014
1999
  ]))
2015
2000
  ]);
2016
2001
  }
2017
- const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$b]]);
2002
+ const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
2018
2003
 
2019
- const _sfc_main$f = defineComponent({
2004
+ const _sfc_main$g = defineComponent({
2020
2005
  name: "m-icon",
2021
2006
  components: { Edit },
2022
2007
  props: {
@@ -2040,10 +2025,12 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2040
2025
  createVNode(_component_edit)
2041
2026
  ]),
2042
2027
  _: 1
2043
- })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createElementBlock("img", {
2044
- key: 1,
2045
- src: _ctx.icon
2046
- }, null, 8, _hoisted_1$8)) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
2028
+ })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
2029
+ default: withCtx(() => [
2030
+ createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
2031
+ ]),
2032
+ _: 1
2033
+ })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
2047
2034
  key: 2,
2048
2035
  class: normalizeClass(_ctx.icon)
2049
2036
  }, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
@@ -2053,7 +2040,7 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2053
2040
  _: 1
2054
2041
  }));
2055
2042
  }
2056
- const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$a]]);
2043
+ const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
2057
2044
 
2058
2045
  const _hoisted_1$7 = {
2059
2046
  key: 1,
@@ -2063,8 +2050,8 @@ const _hoisted_2$2 = {
2063
2050
  class: "menu-item-text",
2064
2051
  style: { "margin": "0 5px" }
2065
2052
  };
2066
- const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
2067
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
2053
+ const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
2054
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2068
2055
  __name: "ToolButton",
2069
2056
  props: {
2070
2057
  data: {
@@ -2307,7 +2294,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
2307
2294
  })) : createCommentVNode("", true)
2308
2295
  ]),
2309
2296
  default: withCtx(() => [
2310
- createElementVNode("span", _hoisted_3$1, [
2297
+ createElementVNode("span", _hoisted_3, [
2311
2298
  createTextVNode(toDisplayString(unref(item).text), 1),
2312
2299
  createVNode(_component_el_icon, { class: "el-icon--right" }, {
2313
2300
  default: withCtx(() => [
@@ -2324,9 +2311,9 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
2324
2311
  }
2325
2312
  });
2326
2313
 
2327
- const _sfc_main$d = defineComponent({
2314
+ const _sfc_main$e = defineComponent({
2328
2315
  name: "nav-menu",
2329
- components: { ToolButton: _sfc_main$e },
2316
+ components: { ToolButton: _sfc_main$f },
2330
2317
  props: {
2331
2318
  data: {
2332
2319
  type: Object,
@@ -2367,9 +2354,9 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2367
2354
  }), 128))
2368
2355
  ], 4);
2369
2356
  }
2370
- const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$9]]);
2357
+ const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
2371
2358
 
2372
- const _sfc_main$c = defineComponent({
2359
+ const _sfc_main$d = defineComponent({
2373
2360
  name: "m-editor-props-panel",
2374
2361
  emits: ["mounted"],
2375
2362
  setup(props, { emit }) {
@@ -2433,9 +2420,9 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2433
2420
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
2434
2421
  ]);
2435
2422
  }
2436
- const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$8]]);
2423
+ const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
2437
2424
 
2438
- const _sfc_main$b = defineComponent({
2425
+ const _sfc_main$c = defineComponent({
2439
2426
  name: "ui-component-panel",
2440
2427
  components: { MIcon },
2441
2428
  setup() {
@@ -2576,9 +2563,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2576
2563
  _: 3
2577
2564
  });
2578
2565
  }
2579
- const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$7]]);
2566
+ const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
2580
2567
 
2581
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
2568
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2582
2569
  __name: "ContentMenu",
2583
2570
  props: {
2584
2571
  menuData: { default: () => [] },
@@ -2667,7 +2654,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2667
2654
  }, [
2668
2655
  createElementVNode("div", null, [
2669
2656
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
2670
- return openBlock(), createBlock(_sfc_main$e, {
2657
+ return openBlock(), createBlock(_sfc_main$f, {
2671
2658
  "event-type": "mouseup",
2672
2659
  data: item,
2673
2660
  key: index,
@@ -2691,8 +2678,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2691
2678
  }
2692
2679
  });
2693
2680
 
2694
- const _sfc_main$9 = defineComponent({
2695
- components: { ContentMenu: _sfc_main$a },
2681
+ const _sfc_main$a = defineComponent({
2682
+ components: { ContentMenu: _sfc_main$b },
2696
2683
  setup() {
2697
2684
  const services = inject("services");
2698
2685
  const menu = ref();
@@ -2783,7 +2770,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2783
2770
  style: { "overflow": "initial" }
2784
2771
  }, null, 8, ["menu-data"]);
2785
2772
  }
2786
- const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$6]]);
2773
+ const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
2787
2774
 
2788
2775
  const throttleTime = 150;
2789
2776
  const select = async (data, editorService) => {
@@ -2883,7 +2870,7 @@ const useFilter = (tree) => ({
2883
2870
  tree.value?.filter(val);
2884
2871
  }
2885
2872
  });
2886
- const _sfc_main$8 = defineComponent({
2873
+ const _sfc_main$9 = defineComponent({
2887
2874
  name: "magic-editor-layer-panel",
2888
2875
  components: { LayerMenu },
2889
2876
  setup() {
@@ -2994,9 +2981,9 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2994
2981
  _: 3
2995
2982
  });
2996
2983
  }
2997
- const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$5]]);
2984
+ const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
2998
2985
 
2999
- const _sfc_main$7 = defineComponent({
2986
+ const _sfc_main$8 = defineComponent({
3000
2987
  components: { MIcon },
3001
2988
  props: {
3002
2989
  data: {
@@ -3084,9 +3071,9 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3084
3071
  _: 3
3085
3072
  }, 8, ["name"])) : createCommentVNode("", true);
3086
3073
  }
3087
- const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$4]]);
3074
+ const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
3088
3075
 
3089
- const _sfc_main$6 = defineComponent({
3076
+ const _sfc_main$7 = defineComponent({
3090
3077
  components: { TabPane },
3091
3078
  name: "m-sidebar",
3092
3079
  props: {
@@ -3141,89 +3128,69 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3141
3128
  _: 3
3142
3129
  }, 8, ["modelValue"])) : createCommentVNode("", true);
3143
3130
  }
3144
- const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$3]]);
3131
+ const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
3145
3132
 
3146
- const _hoisted_1$2 = {
3147
- class: "m-editor-page-bar",
3148
- ref: "pageBar"
3149
- };
3150
- const _hoisted_2 = ["onClick"];
3151
- const _hoisted_3 = { class: "m-editor-page-bar-title" };
3152
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3153
- __name: "PageBar",
3133
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3134
+ __name: "PageBarScrollContainer",
3154
3135
  setup(__props) {
3155
- const useScroll = (root2) => {
3156
- const pageBar = ref();
3157
- const itemsContainer = ref();
3158
- const pageBarWidth = ref(0);
3159
- const canScroll = ref(false);
3160
- const itemsContainerWidth = 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) {
3181
- translateLeft = 0;
3182
- }
3183
- } else if (type === "right") {
3184
- translateLeft -= 100;
3185
- if (-translateLeft > maxScrollLeft) {
3186
- translateLeft = -maxScrollLeft;
3187
- }
3188
- } else if (type === "start") {
3136
+ const services = inject("services");
3137
+ const editorService = services?.editorService;
3138
+ const pageBar = ref();
3139
+ const itemsContainer = ref();
3140
+ const pageBarWidth = ref(0);
3141
+ const canScroll = ref(false);
3142
+ const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
3143
+ let translateLeft = 0;
3144
+ const resizeObserver = new ResizeObserver((entries) => {
3145
+ for (const { contentRect } of entries) {
3146
+ const { width } = contentRect;
3147
+ pageBarWidth.value = width || 0;
3148
+ setCanScroll();
3149
+ }
3150
+ });
3151
+ const setCanScroll = () => {
3152
+ if (itemsContainer.value) {
3153
+ canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
3154
+ }
3155
+ };
3156
+ const scroll = (type) => {
3157
+ if (!itemsContainer.value)
3158
+ return;
3159
+ const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
3160
+ if (type === "left") {
3161
+ translateLeft += 100;
3162
+ if (translateLeft > 0) {
3189
3163
  translateLeft = 0;
3190
- } else if (type === "end") {
3164
+ }
3165
+ } else if (type === "right") {
3166
+ translateLeft -= 100;
3167
+ if (-translateLeft > maxScrollLeft) {
3191
3168
  translateLeft = -maxScrollLeft;
3192
3169
  }
3193
- itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
3194
- };
3195
- onMounted(() => {
3196
- pageBar.value && resizeObserver.observe(pageBar.value);
3197
- });
3198
- onUnmounted(() => {
3199
- resizeObserver.disconnect();
3200
- });
3201
- watch(() => root2.value?.items.length, (length = 0, preLength = 0) => {
3202
- setTimeout(() => {
3203
- setCanScroll();
3204
- if (length < preLength) {
3205
- scroll("start");
3206
- } else {
3207
- scroll("end");
3208
- }
3209
- });
3210
- });
3211
- return {
3212
- pageBar,
3213
- itemsContainer,
3214
- canScroll,
3215
- itemsContainerWidth,
3216
- scroll
3217
- };
3170
+ } else if (type === "start") {
3171
+ translateLeft = 0;
3172
+ } else if (type === "end") {
3173
+ translateLeft = -maxScrollLeft;
3174
+ }
3175
+ itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
3218
3176
  };
3219
- const services = inject("services");
3220
- const editorService = services?.editorService;
3177
+ onMounted(() => {
3178
+ pageBar.value && resizeObserver.observe(pageBar.value);
3179
+ });
3180
+ onUnmounted(() => {
3181
+ resizeObserver.disconnect();
3182
+ });
3221
3183
  const root = computed(() => editorService?.get("root"));
3222
- const scrollState = useScroll(root);
3223
- const page = computed(() => editorService?.get("page"));
3224
- const switchPage = (page2) => {
3225
- editorService?.select(page2);
3226
- };
3184
+ watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
3185
+ setTimeout(() => {
3186
+ setCanScroll();
3187
+ if (length < preLength) {
3188
+ scroll("start");
3189
+ } else {
3190
+ scroll("end");
3191
+ }
3192
+ });
3193
+ });
3227
3194
  const addPage = () => {
3228
3195
  if (!editorService)
3229
3196
  return;
@@ -3233,21 +3200,13 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3233
3200
  };
3234
3201
  editorService.add(pageConfig);
3235
3202
  };
3236
- const copy = (node) => {
3237
- node && editorService?.copy(node);
3238
- editorService?.paste({
3239
- left: 0,
3240
- top: 0
3241
- });
3242
- };
3243
- const remove = (node) => {
3244
- editorService?.remove(node);
3245
- };
3246
3203
  return (_ctx, _cache) => {
3247
3204
  const _component_el_icon = resolveComponent("el-icon");
3248
- const _component_el_tooltip = resolveComponent("el-tooltip");
3249
- const _component_el_popover = resolveComponent("el-popover");
3250
- return openBlock(), createElementBlock("div", _hoisted_1$2, [
3205
+ return openBlock(), createElementBlock("div", {
3206
+ class: "m-editor-page-bar",
3207
+ ref_key: "pageBar",
3208
+ ref: pageBar
3209
+ }, [
3251
3210
  createElementVNode("div", {
3252
3211
  id: "m-editor-page-bar-add-icon",
3253
3212
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
@@ -3260,10 +3219,10 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3260
3219
  _: 1
3261
3220
  })
3262
3221
  ]),
3263
- unref(scrollState).canScroll ? (openBlock(), createElementBlock("div", {
3222
+ canScroll.value ? (openBlock(), createElementBlock("div", {
3264
3223
  key: 0,
3265
3224
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3266
- onClick: _cache[0] || (_cache[0] = ($event) => unref(scrollState).scroll("left"))
3225
+ onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
3267
3226
  }, [
3268
3227
  createVNode(_component_el_icon, null, {
3269
3228
  default: withCtx(() => [
@@ -3275,16 +3234,64 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3275
3234
  unref(root) ? (openBlock(), createElementBlock("div", {
3276
3235
  key: 1,
3277
3236
  class: "m-editor-page-bar-items",
3278
- ref: "itemsContainer",
3279
- style: normalizeStyle(`width: ${unref(scrollState).itemsContainerWidth}px`)
3237
+ ref_key: "itemsContainer",
3238
+ ref: itemsContainer,
3239
+ style: normalizeStyle(`width: ${unref(itemsContainerWidth)}px`)
3280
3240
  }, [
3281
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(root).items, (item) => {
3241
+ renderSlot(_ctx.$slots, "default")
3242
+ ], 4)) : createCommentVNode("", true),
3243
+ canScroll.value ? (openBlock(), createElementBlock("div", {
3244
+ key: 2,
3245
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3246
+ onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
3247
+ }, [
3248
+ createVNode(_component_el_icon, null, {
3249
+ default: withCtx(() => [
3250
+ createVNode(unref(ArrowRightBold))
3251
+ ]),
3252
+ _: 1
3253
+ })
3254
+ ])) : createCommentVNode("", true)
3255
+ ], 512);
3256
+ };
3257
+ }
3258
+ });
3259
+
3260
+ const _hoisted_1$2 = ["onClick"];
3261
+ const _hoisted_2 = { class: "m-editor-page-bar-title" };
3262
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3263
+ __name: "PageBar",
3264
+ setup(__props) {
3265
+ const services = inject("services");
3266
+ const editorService = services?.editorService;
3267
+ const root = computed(() => editorService?.get("root"));
3268
+ const page = computed(() => editorService?.get("page"));
3269
+ const switchPage = (page2) => {
3270
+ editorService?.select(page2);
3271
+ };
3272
+ const copy = (node) => {
3273
+ node && editorService?.copy(node);
3274
+ editorService?.paste({
3275
+ left: 0,
3276
+ top: 0
3277
+ });
3278
+ };
3279
+ const remove = (node) => {
3280
+ editorService?.remove(node);
3281
+ };
3282
+ return (_ctx, _cache) => {
3283
+ const _component_el_tooltip = resolveComponent("el-tooltip");
3284
+ const _component_el_icon = resolveComponent("el-icon");
3285
+ const _component_el_popover = resolveComponent("el-popover");
3286
+ return openBlock(), createBlock(_sfc_main$6, null, {
3287
+ default: withCtx(() => [
3288
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
3282
3289
  return openBlock(), createElementBlock("div", {
3283
- key: item.key,
3284
3290
  class: normalizeClass(["m-editor-page-bar-item", { active: unref(page)?.id === item.id }]),
3291
+ key: item.key,
3285
3292
  onClick: ($event) => switchPage(item)
3286
3293
  }, [
3287
- createElementVNode("div", _hoisted_3, [
3294
+ createElementVNode("div", _hoisted_2, [
3288
3295
  renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3289
3296
  createVNode(_component_el_tooltip, {
3290
3297
  effect: "dark",
@@ -3315,7 +3322,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3315
3322
  default: withCtx(() => [
3316
3323
  createElementVNode("div", null, [
3317
3324
  renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3318
- createVNode(_sfc_main$e, {
3325
+ createVNode(_sfc_main$f, {
3319
3326
  data: {
3320
3327
  type: "button",
3321
3328
  text: "\u590D\u5236",
@@ -3323,7 +3330,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3323
3330
  handler: () => copy(item)
3324
3331
  }
3325
3332
  }, null, 8, ["data"]),
3326
- createVNode(_sfc_main$e, {
3333
+ createVNode(_sfc_main$f, {
3327
3334
  data: {
3328
3335
  type: "button",
3329
3336
  text: "\u5220\u9664",
@@ -3336,22 +3343,11 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3336
3343
  ]),
3337
3344
  _: 2
3338
3345
  }, 1024)
3339
- ], 10, _hoisted_2);
3346
+ ], 10, _hoisted_1$2);
3340
3347
  }), 128))
3341
- ], 4)) : createCommentVNode("", true),
3342
- unref(scrollState).canScroll ? (openBlock(), createElementBlock("div", {
3343
- key: 2,
3344
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3345
- onClick: _cache[1] || (_cache[1] = ($event) => unref(scrollState).scroll("right"))
3346
- }, [
3347
- createVNode(_component_el_icon, null, {
3348
- default: withCtx(() => [
3349
- createVNode(unref(ArrowRightBold))
3350
- ]),
3351
- _: 1
3352
- })
3353
- ])) : createCommentVNode("", true)
3354
- ], 512);
3348
+ ]),
3349
+ _: 3
3350
+ });
3355
3351
  };
3356
3352
  }
3357
3353
  });
@@ -3597,11 +3593,11 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3597
3593
  {
3598
3594
  type: "button",
3599
3595
  text: "\u6C34\u5E73\u5C45\u4E2D",
3600
- display: () => canCenter.value && !props.isMultiSelect,
3596
+ display: () => canCenter.value,
3601
3597
  handler: () => {
3602
- if (!node.value)
3598
+ if (!nodes.value)
3603
3599
  return;
3604
- editorService?.alignCenter(node.value);
3600
+ editorService?.alignCenter(nodes.value);
3605
3601
  }
3606
3602
  },
3607
3603
  {
@@ -3697,10 +3693,6 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3697
3693
  },
3698
3694
  ...stageContentMenu
3699
3695
  ]);
3700
- onMounted(async () => {
3701
- const data = await storageService.getItem(COPY_STORAGE_KEY);
3702
- canPaste.value = data !== "undefined" && !!data;
3703
- });
3704
3696
  watch(parent, async () => {
3705
3697
  if (!parent.value || !editorService)
3706
3698
  return canCenter.value = false;
@@ -3709,12 +3701,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3709
3701
  const isTypeConform = nodes.value?.every((selectedNode) => ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
3710
3702
  canCenter.value = isLayoutConform && !!isTypeConform;
3711
3703
  }, { immediate: true });
3712
- const show = (e) => {
3704
+ const show = async (e) => {
3713
3705
  menu.value?.show(e);
3706
+ const data = await storageService.getItem(COPY_STORAGE_KEY);
3707
+ canPaste.value = data !== "undefined" && !!data;
3714
3708
  };
3715
3709
  expose({ show });
3716
3710
  return (_ctx, _cache) => {
3717
- return openBlock(), createBlock(_sfc_main$a, {
3711
+ return openBlock(), createBlock(_sfc_main$b, {
3718
3712
  "menu-data": menuData,
3719
3713
  ref_key: "menu",
3720
3714
  ref: menu
@@ -3756,6 +3750,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3756
3750
  isContainer: stageOptions.isContainer,
3757
3751
  containerHighlightClassName: stageOptions.containerHighlightClassName,
3758
3752
  containerHighlightDuration: stageOptions.containerHighlightDuration,
3753
+ containerHighlightType: stageOptions.containerHighlightType,
3759
3754
  canSelect: (el, event, stop) => {
3760
3755
  const elCanSelect = stageOptions.canSelect(el);
3761
3756
  if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
@@ -3784,10 +3779,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3784
3779
  });
3785
3780
  stage?.on("update", (ev) => {
3786
3781
  if (ev.parentEl) {
3787
- services?.editorService.moveToContainer({ id: ev.el.id, style: ev.style }, ev.parentEl.id);
3782
+ for (const data of ev.data) {
3783
+ services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
3784
+ }
3788
3785
  return;
3789
3786
  }
3790
- services?.editorService.update({ id: ev.el.id, style: ev.style });
3787
+ services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
3791
3788
  });
3792
3789
  stage?.on("sort", (ev) => {
3793
3790
  services?.editorService.sort(ev.src, ev.dist);
@@ -3958,7 +3955,7 @@ const _sfc_main$1 = defineComponent({
3958
3955
  nodes.value && services?.editorService.copy(nodes.value);
3959
3956
  }).keydown([ctrl, "v"], (e) => {
3960
3957
  e.inputEvent.preventDefault();
3961
- nodes.value && services?.editorService.paste();
3958
+ nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
3962
3959
  }).keydown([ctrl, "x"], (e) => {
3963
3960
  e.inputEvent.preventDefault();
3964
3961
  if (!nodes.value || isPage(nodes.value[0]))
@@ -4262,6 +4259,10 @@ const _sfc_main = defineComponent({
4262
4259
  type: Number,
4263
4260
  default: 800
4264
4261
  },
4262
+ containerHighlightType: {
4263
+ type: String,
4264
+ default: ContainerHighlightType.DEFAULT
4265
+ },
4265
4266
  stageRect: {
4266
4267
  type: [String, Object]
4267
4268
  },
@@ -4332,7 +4333,8 @@ const _sfc_main = defineComponent({
4332
4333
  updateDragEl: props.updateDragEl,
4333
4334
  isContainer: props.isContainer,
4334
4335
  containerHighlightClassName: props.containerHighlightClassName,
4335
- containerHighlightDuration: props.containerHighlightDuration
4336
+ containerHighlightDuration: props.containerHighlightDuration,
4337
+ containerHighlightType: props.containerHighlightType
4336
4338
  }));
4337
4339
  return services;
4338
4340
  }
@@ -4409,12 +4411,12 @@ const index = {
4409
4411
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4410
4412
  setConfig(option);
4411
4413
  app.component(Editor.name, Editor);
4412
- app.component(_sfc_main$k.name, _sfc_main$k);
4414
+ app.component("m-fields-ui-select", _sfc_main$l);
4413
4415
  app.component(CodeLink.name, CodeLink);
4414
4416
  app.component(Code.name, Code);
4415
4417
  app.component(CodeEditor.name, CodeEditor);
4416
4418
  }
4417
4419
  };
4418
4420
 
4419
- export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$e as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, warn };
4421
+ export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$f as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, warn };
4420
4422
  //# sourceMappingURL=tmagic-editor.mjs.map