@tmagic/editor 1.0.0-beta.13 → 1.0.0-beta.14

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.
Files changed (91) hide show
  1. package/coverage/clover.xml +646 -550
  2. package/coverage/coverage-final.json +19 -18
  3. package/coverage/lcov-report/index.html +55 -55
  4. package/coverage/lcov-report/src/Editor.vue.html +1 -1
  5. package/coverage/lcov-report/{layouts/sidebar/LayerMenu.vue.html → src/components/ContentMenu.vue.html} +137 -95
  6. package/coverage/lcov-report/src/components/Icon.vue.html +5 -5
  7. package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
  8. package/coverage/lcov-report/src/components/ToolButton.vue.html +180 -63
  9. package/coverage/lcov-report/src/components/index.html +34 -19
  10. package/coverage/lcov-report/src/index.html +1 -1
  11. package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
  12. package/coverage/lcov-report/src/layouts/Framework.vue.html +13 -13
  13. package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
  14. package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +1 -1
  15. package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
  16. package/coverage/lcov-report/src/layouts/index.html +15 -15
  17. package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +78 -12
  18. package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +149 -92
  19. package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +43 -121
  20. package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +1 -1
  21. package/coverage/lcov-report/src/layouts/sidebar/index.html +40 -40
  22. package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +99 -12
  23. package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +86 -95
  24. package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +208 -97
  25. package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +3 -3
  26. package/coverage/lcov-report/src/layouts/workspace/index.html +35 -35
  27. package/coverage/lcov-report/src/services/BaseService.ts.html +11 -11
  28. package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
  29. package/coverage/lcov-report/src/services/editor.ts.html +102 -9
  30. package/coverage/lcov-report/src/services/events.ts.html +1 -1
  31. package/coverage/lcov-report/src/services/history.ts.html +29 -8
  32. package/coverage/lcov-report/src/services/index.html +25 -25
  33. package/coverage/lcov-report/src/services/props.ts.html +4 -7
  34. package/coverage/lcov-report/src/services/ui.ts.html +1 -1
  35. package/coverage/lcov-report/src/type.ts.html +8 -14
  36. package/coverage/lcov-report/src/utils/compose.ts.html +4 -4
  37. package/coverage/lcov-report/src/utils/config.ts.html +1 -1
  38. package/coverage/lcov-report/src/utils/editor.ts.html +2 -2
  39. package/coverage/lcov-report/src/utils/index.html +1 -1
  40. package/coverage/lcov-report/src/utils/index.ts.html +1 -1
  41. package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
  42. package/coverage/lcov-report/src/utils/props.ts.html +59 -2
  43. package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
  44. package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
  45. package/coverage/lcov.info +1623 -1354
  46. package/dist/style.css +39 -18
  47. package/dist/tmagic-editor.es.js +598 -412
  48. package/dist/tmagic-editor.es.js.map +1 -1
  49. package/dist/tmagic-editor.umd.js +595 -408
  50. package/dist/tmagic-editor.umd.js.map +1 -1
  51. package/dist/types/src/Editor.vue.d.ts +1 -1
  52. package/dist/types/src/components/ToolButton.vue.d.ts +12 -1
  53. package/dist/types/src/index.d.ts +1 -0
  54. package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -0
  55. package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +2 -0
  56. package/dist/types/src/services/history.d.ts +1 -0
  57. package/dist/types/src/services/props.d.ts +2 -2
  58. package/dist/types/src/type.d.ts +6 -8
  59. package/dist/types/src/utils/polyfills.d.ts +0 -0
  60. package/package.json +8 -7
  61. package/src/components/ContentMenu.vue +107 -0
  62. package/src/components/ToolButton.vue +66 -27
  63. package/src/index.ts +2 -0
  64. package/src/layouts/Framework.vue +6 -6
  65. package/src/layouts/sidebar/ComponentListPanel.vue +23 -1
  66. package/src/layouts/sidebar/LayerMenu.vue +91 -72
  67. package/src/layouts/sidebar/LayerPanel.vue +23 -49
  68. package/src/layouts/workspace/PageBar.vue +35 -6
  69. package/src/layouts/workspace/Stage.vue +41 -44
  70. package/src/layouts/workspace/ViewerMenu.vue +104 -67
  71. package/src/layouts/workspace/Workspace.vue +2 -2
  72. package/src/services/editor.ts +32 -1
  73. package/src/services/history.ts +7 -0
  74. package/src/services/props.ts +2 -3
  75. package/src/theme/common/var.scss +1 -0
  76. package/src/theme/component-list-panel.scss +2 -0
  77. package/src/theme/content-menu.scss +33 -26
  78. package/src/theme/layer-panel.scss +1 -1
  79. package/src/theme/page-bar.scss +22 -1
  80. package/src/type.ts +6 -8
  81. package/src/utils/editor.ts +1 -1
  82. package/src/utils/polyfills.ts +22 -0
  83. package/src/utils/props.ts +19 -0
  84. package/coverage/lcov-report/Icon.vue.html +0 -172
  85. package/coverage/lcov-report/ToolButton.vue.html +0 -655
  86. package/coverage/lcov-report/layouts/sidebar/index.html +0 -116
  87. package/coverage/lcov-report/utils/index.html +0 -116
  88. package/coverage/lcov-report/utils/undo-redo.ts.html +0 -313
  89. package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -980
  90. package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -188
  91. package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
@@ -29,6 +29,10 @@
29
29
  var KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
30
30
  var StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
31
31
 
32
+ if (typeof window.global === "undefined") {
33
+ window.global = window;
34
+ }
35
+
32
36
  var _export_sfc = (sfc, props) => {
33
37
  const target = sfc.__vccOpts || sfc;
34
38
  for (const [key, val] of props) {
@@ -37,7 +41,7 @@
37
41
  return target;
38
42
  };
39
43
 
40
- const _sfc_main$k = vue.defineComponent({
44
+ const _sfc_main$l = vue.defineComponent({
41
45
  name: "m-fields-vs-code",
42
46
  props: ["model", "name", "config", "prop"],
43
47
  emits: ["change"],
@@ -54,7 +58,7 @@
54
58
  };
55
59
  }
56
60
  });
57
- function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
61
+ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
58
62
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
59
63
  return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
60
64
  style: vue.normalizeStyle(`height: ${_ctx.height}`),
@@ -63,9 +67,9 @@
63
67
  onSave: _ctx.save
64
68
  }, null, 8, ["style", "init-values", "language", "onSave"]);
65
69
  }
66
- var Code = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
70
+ var Code = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
67
71
 
68
- const _sfc_main$j = vue.defineComponent({
72
+ const _sfc_main$k = vue.defineComponent({
69
73
  name: "m-fields-code-link",
70
74
  props: {
71
75
  config: {
@@ -120,7 +124,7 @@
120
124
  };
121
125
  }
122
126
  });
123
- function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
127
+ function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
124
128
  const _component_m_fields_link = vue.resolveComponent("m-fields-link");
125
129
  return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
126
130
  config: _ctx.formConfig,
@@ -129,11 +133,11 @@
129
133
  onChange: _ctx.changeHandler
130
134
  }, null, 8, ["config", "model", "onChange"]);
131
135
  }
132
- var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
136
+ var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
133
137
 
134
138
  var UISelect_vue_vue_type_style_index_0_lang = '';
135
139
 
136
- const _sfc_main$i = vue.defineComponent({
140
+ const _sfc_main$j = vue.defineComponent({
137
141
  name: "m-fields-ui-select",
138
142
  props: {
139
143
  labelWidth: String,
@@ -195,25 +199,25 @@
195
199
  };
196
200
  }
197
201
  });
198
- const _hoisted_1$e = /* @__PURE__ */ vue.createElementVNode("i", {
202
+ const _hoisted_1$c = /* @__PURE__ */ vue.createElementVNode("i", {
199
203
  class: "el-icon-delete",
200
204
  style: { "color": "rgb(221, 75, 57)" }
201
205
  }, "\u53D6\u6D88", -1);
202
- const _hoisted_2$7 = [
203
- _hoisted_1$e
206
+ const _hoisted_2$5 = [
207
+ _hoisted_1$c
204
208
  ];
205
- const _hoisted_3$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
206
- function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
209
+ const _hoisted_3$3 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
210
+ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
207
211
  return _ctx.uiSelectMode ? (vue.openBlock(), vue.createElementBlock("div", {
208
212
  key: 0,
209
213
  class: "m-fields-ui-select",
210
214
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
211
- }, _hoisted_2$7)) : (vue.openBlock(), vue.createElementBlock("div", {
215
+ }, _hoisted_2$5)) : (vue.openBlock(), vue.createElementBlock("div", {
212
216
  key: 1,
213
217
  class: "m-fields-ui-select",
214
218
  onClick: _cache[2] || (_cache[2] = (...args) => _ctx.startSelect && _ctx.startSelect(...args))
215
219
  }, [
216
- _hoisted_3$5,
220
+ _hoisted_3$3,
217
221
  vue.createElementVNode("span", null, vue.toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1),
218
222
  _ctx.val ? (vue.openBlock(), vue.createElementBlock("i", {
219
223
  key: 0,
@@ -222,7 +226,7 @@
222
226
  })) : vue.createCommentVNode("", true)
223
227
  ]));
224
228
  }
225
- var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
229
+ var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
226
230
 
227
231
  const toString = (v, language) => {
228
232
  let value = "";
@@ -239,7 +243,7 @@
239
243
  }
240
244
  return value;
241
245
  };
242
- const _sfc_main$h = vue.defineComponent({
246
+ const _sfc_main$i = vue.defineComponent({
243
247
  name: "magic-code-editor",
244
248
  props: {
245
249
  initValues: {
@@ -344,14 +348,14 @@
344
348
  };
345
349
  }
346
350
  });
347
- const _hoisted_1$d = {
351
+ const _hoisted_1$b = {
348
352
  ref: "codeEditor",
349
353
  class: "magic-code-editor"
350
354
  };
351
- function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
352
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, null, 512);
355
+ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
356
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, null, 512);
353
357
  }
354
- var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
358
+ var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
355
359
 
356
360
  let $TMAGIC_EDITOR = {};
357
361
  const setConfig = (option) => {
@@ -532,6 +536,12 @@
532
536
  });
533
537
  this.on("change", this.setCanUndoRedo);
534
538
  }
539
+ reset() {
540
+ this.state.pageSteps = {};
541
+ this.state.pageId = void 0;
542
+ this.state.canRedo = false;
543
+ this.state.canUndo = false;
544
+ }
535
545
  changePage(page) {
536
546
  if (!page)
537
547
  return;
@@ -637,8 +647,7 @@
637
647
  }
638
648
  return lodashEs.cloneDeep({
639
649
  ...getDefaultPropsValue(type),
640
- ...defaultValue,
641
- ...this.state.propsValueMap[type] || {}
650
+ ...lodashEs.mergeWith(this.state.propsValueMap[type] || {}, defaultValue)
642
651
  });
643
652
  }
644
653
  }
@@ -725,7 +734,7 @@
725
734
  const setTop2Middle = (node, parentNode, stage) => {
726
735
  const style = node.style || {};
727
736
  const height = style.height || 0;
728
- if (!stage || style.top || !parentNode.style || !utils.isNumber(height))
737
+ if (!stage || typeof style.top !== "undefined" || !parentNode.style || !utils.isNumber(height))
729
738
  return style;
730
739
  const { height: parentHeight } = parentNode.style;
731
740
  if (utils.isPage(parentNode)) {
@@ -835,6 +844,7 @@
835
844
  "paste",
836
845
  "alignCenter",
837
846
  "moveLayer",
847
+ "move",
838
848
  "undo",
839
849
  "redo",
840
850
  "highlight"
@@ -847,12 +857,14 @@
847
857
  node: null,
848
858
  stage: null,
849
859
  highlightNode: null,
850
- modifiedNodeIds: /* @__PURE__ */ new Map()
860
+ modifiedNodeIds: /* @__PURE__ */ new Map(),
861
+ pageLength: 0
851
862
  });
852
863
  }
853
864
  set(name, value) {
854
865
  this.state[name] = value;
855
866
  if (name === "root") {
867
+ this.state.pageLength = value?.items?.length || 0;
856
868
  this.emit("root-change", value);
857
869
  }
858
870
  }
@@ -912,6 +924,7 @@
912
924
  } else {
913
925
  historyService.empty();
914
926
  }
927
+ this.emit("select", node);
915
928
  return node;
916
929
  }
917
930
  async selectNextNode() {
@@ -947,7 +960,8 @@
947
960
  const { type, ...config2 } = addNode;
948
961
  const curNode = this.get("node");
949
962
  let parentNode;
950
- if (type === schema.NodeType.PAGE) {
963
+ const isPage2 = type === schema.NodeType.PAGE;
964
+ if (isPage2) {
951
965
  parentNode = this.get("root");
952
966
  } else if (parent && typeof parent !== "function") {
953
967
  parentNode = parent;
@@ -972,6 +986,10 @@
972
986
  this.pushHistoryState();
973
987
  }
974
988
  stage?.select(newNode.id);
989
+ if (isPage2) {
990
+ this.state.pageLength += 1;
991
+ }
992
+ this.emit("add", newNode);
975
993
  return newNode;
976
994
  }
977
995
  async remove(node) {
@@ -990,9 +1008,20 @@
990
1008
  const stage = this.get("stage");
991
1009
  stage?.remove({ id: node.id, root: this.get("root") });
992
1010
  if (node.type === schema.NodeType.PAGE) {
1011
+ this.state.pageLength -= 1;
993
1012
  if (root.items[0]) {
994
1013
  await this.select(root.items[0]);
995
1014
  stage?.select(root.items[0].id);
1015
+ } else {
1016
+ this.set("node", null);
1017
+ this.set("parent", null);
1018
+ this.set("page", null);
1019
+ this.set("stage", null);
1020
+ this.set("highlightNode", null);
1021
+ this.resetModifiedNodeId();
1022
+ historyService.reset();
1023
+ this.emit("remove", node);
1024
+ return node;
996
1025
  }
997
1026
  } else {
998
1027
  await this.select(parent);
@@ -1000,6 +1029,7 @@
1000
1029
  }
1001
1030
  this.addModifiedNodeId(parent.id);
1002
1031
  this.pushHistoryState();
1032
+ this.emit("remove", node);
1003
1033
  return node;
1004
1034
  }
1005
1035
  async update(config2) {
@@ -1043,6 +1073,7 @@
1043
1073
  }
1044
1074
  this.addModifiedNodeId(newConfig.id);
1045
1075
  this.pushHistoryState();
1076
+ this.emit("update", newConfig);
1046
1077
  return newConfig;
1047
1078
  }
1048
1079
  async sort(id1, id2) {
@@ -1372,6 +1403,25 @@
1372
1403
  defaultValue: "100% 100%"
1373
1404
  }
1374
1405
  ]
1406
+ },
1407
+ {
1408
+ type: "fieldset",
1409
+ legend: "\u5B57\u4F53",
1410
+ items: [
1411
+ {
1412
+ name: "color",
1413
+ text: "\u989C\u8272",
1414
+ type: "colorPicker"
1415
+ },
1416
+ {
1417
+ name: "fontSize",
1418
+ text: "\u5927\u5C0F"
1419
+ },
1420
+ {
1421
+ name: "fontWeight",
1422
+ text: "\u7C97\u7EC6"
1423
+ }
1424
+ ]
1375
1425
  }
1376
1426
  ]
1377
1427
  }
@@ -1439,7 +1489,7 @@
1439
1489
  name: type
1440
1490
  });
1441
1491
 
1442
- const _sfc_main$g = vue.defineComponent({
1492
+ const _sfc_main$h = vue.defineComponent({
1443
1493
  components: { Plus: icons.Plus },
1444
1494
  setup() {
1445
1495
  const services = vue.inject("services");
@@ -1456,14 +1506,14 @@
1456
1506
  };
1457
1507
  }
1458
1508
  });
1459
- const _hoisted_1$c = { class: "m-editor-empty-panel" };
1460
- const _hoisted_2$6 = { class: "m-editor-empty-content" };
1461
- const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1462
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1509
+ const _hoisted_1$a = { class: "m-editor-empty-panel" };
1510
+ const _hoisted_2$4 = { class: "m-editor-empty-content" };
1511
+ const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1512
+ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1463
1513
  const _component_plus = vue.resolveComponent("plus");
1464
1514
  const _component_el_icon = vue.resolveComponent("el-icon");
1465
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
1466
- vue.createElementVNode("div", _hoisted_2$6, [
1515
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
1516
+ vue.createElementVNode("div", _hoisted_2$4, [
1467
1517
  vue.createElementVNode("div", {
1468
1518
  class: "m-editor-empty-button",
1469
1519
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
@@ -1476,12 +1526,12 @@
1476
1526
  _: 1
1477
1527
  })
1478
1528
  ]),
1479
- _hoisted_3$4
1529
+ _hoisted_3$2
1480
1530
  ])
1481
1531
  ])
1482
1532
  ]);
1483
1533
  }
1484
- var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
1534
+ var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
1485
1535
 
1486
1536
  /*
1487
1537
  Copyright (c) 2018 Daybrush
@@ -2692,7 +2742,7 @@
2692
2742
 
2693
2743
  var Gesto$1 = Gesto;
2694
2744
 
2695
- const _sfc_main$f = vue.defineComponent({
2745
+ const _sfc_main$g = vue.defineComponent({
2696
2746
  name: "m-editor-resize",
2697
2747
  props: {
2698
2748
  type: {
@@ -2734,33 +2784,33 @@
2734
2784
  };
2735
2785
  }
2736
2786
  });
2737
- const _hoisted_1$b = {
2787
+ const _hoisted_1$9 = {
2738
2788
  ref: "target",
2739
2789
  class: "m-editor-resizer"
2740
2790
  };
2741
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2742
- return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$b, [
2791
+ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2792
+ return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$9, [
2743
2793
  vue.renderSlot(_ctx.$slots, "default")
2744
2794
  ], 512);
2745
2795
  }
2746
- var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
2796
+ var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
2747
2797
 
2748
- const _sfc_main$e = vue.defineComponent({
2798
+ const _sfc_main$f = vue.defineComponent({
2749
2799
  components: {
2750
2800
  AddPageBox,
2751
2801
  Resizer
2752
2802
  },
2753
2803
  setup() {
2754
- const services = vue.inject("services");
2755
- const root = vue.computed(() => services?.editorService.get("root"));
2804
+ const { editorService, uiService } = vue.inject("services") || {};
2805
+ const root = vue.computed(() => editorService?.get("root"));
2756
2806
  return {
2757
2807
  root,
2758
- pageLength: vue.computed(() => root.value?.items?.length || 0),
2759
- showSrc: vue.computed(() => services?.uiService.get("showSrc")),
2760
- columnWidth: vue.computed(() => services?.uiService.get("columnWidth")),
2808
+ pageLength: vue.computed(() => editorService?.get("pageLength") || 0),
2809
+ showSrc: vue.computed(() => uiService?.get("showSrc")),
2810
+ columnWidth: vue.computed(() => uiService?.get("columnWidth")),
2761
2811
  saveCode(value) {
2762
2812
  try {
2763
- services?.editorService.set("root", eval(value));
2813
+ editorService?.set("root", eval(value));
2764
2814
  } catch (e) {
2765
2815
  console.error(e);
2766
2816
  }
@@ -2768,24 +2818,24 @@
2768
2818
  };
2769
2819
  }
2770
2820
  });
2771
- const _hoisted_1$a = { class: "m-editor" };
2772
- const _hoisted_2$5 = {
2821
+ const _hoisted_1$8 = { class: "m-editor" };
2822
+ const _hoisted_2$3 = {
2773
2823
  key: 1,
2774
2824
  class: "m-editor-content"
2775
2825
  };
2776
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2826
+ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2777
2827
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
2778
2828
  const _component_resizer = vue.resolveComponent("resizer");
2779
2829
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
2780
2830
  const _component_add_page_box = vue.resolveComponent("add-page-box");
2781
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
2831
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2782
2832
  vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2783
2833
  _ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
2784
2834
  key: 0,
2785
2835
  class: "m-editor-content",
2786
2836
  "init-values": _ctx.root,
2787
2837
  onSave: _ctx.saveCode
2788
- }, null, 8, ["init-values", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$5, [
2838
+ }, null, 8, ["init-values", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
2789
2839
  vue.createElementVNode("div", {
2790
2840
  class: "m-editor-framework-left",
2791
2841
  style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
@@ -2818,9 +2868,9 @@
2818
2868
  ]))
2819
2869
  ]);
2820
2870
  }
2821
- var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
2871
+ var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
2822
2872
 
2823
- const _sfc_main$d = vue.defineComponent({
2873
+ const _sfc_main$e = vue.defineComponent({
2824
2874
  name: "m-icon",
2825
2875
  components: { Edit: icons.Edit },
2826
2876
  props: {
@@ -2834,8 +2884,8 @@
2834
2884
  };
2835
2885
  }
2836
2886
  });
2837
- const _hoisted_1$9 = ["src"];
2838
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2887
+ const _hoisted_1$7 = ["src"];
2888
+ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2839
2889
  const _component_edit = vue.resolveComponent("edit");
2840
2890
  const _component_el_icon = vue.resolveComponent("el-icon");
2841
2891
  return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
@@ -2846,7 +2896,7 @@
2846
2896
  })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
2847
2897
  key: 1,
2848
2898
  src: _ctx.icon
2849
- }, null, 8, _hoisted_1$9)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2899
+ }, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2850
2900
  key: 2,
2851
2901
  class: vue.normalizeClass(_ctx.icon)
2852
2902
  }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
@@ -2856,9 +2906,9 @@
2856
2906
  _: 1
2857
2907
  }));
2858
2908
  }
2859
- var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
2909
+ var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
2860
2910
 
2861
- const _sfc_main$c = vue.defineComponent({
2911
+ const _sfc_main$d = vue.defineComponent({
2862
2912
  components: { MIcon, ArrowDown: icons.ArrowDown },
2863
2913
  props: {
2864
2914
  data: {
@@ -2868,6 +2918,10 @@
2868
2918
  type: "text",
2869
2919
  display: false
2870
2920
  })
2921
+ },
2922
+ eventType: {
2923
+ type: String,
2924
+ default: "click"
2871
2925
  }
2872
2926
  },
2873
2927
  setup(props) {
@@ -2894,7 +2948,7 @@
2894
2948
  case "delete":
2895
2949
  return {
2896
2950
  type: "button",
2897
- icon: icons.Delete,
2951
+ icon: vue.markRaw(icons.Delete),
2898
2952
  tooltip: "\u522A\u9664",
2899
2953
  disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
2900
2954
  handler: () => services?.editorService.remove(services?.editorService.get("node"))
@@ -2902,7 +2956,7 @@
2902
2956
  case "undo":
2903
2957
  return {
2904
2958
  type: "button",
2905
- icon: icons.Back,
2959
+ icon: vue.markRaw(icons.Back),
2906
2960
  tooltip: "\u540E\u9000",
2907
2961
  disabled: () => !services?.historyService.state.canUndo,
2908
2962
  handler: () => services?.editorService.undo()
@@ -2910,7 +2964,7 @@
2910
2964
  case "redo":
2911
2965
  return {
2912
2966
  type: "button",
2913
- icon: icons.Right,
2967
+ icon: vue.markRaw(icons.Right),
2914
2968
  tooltip: "\u524D\u8FDB",
2915
2969
  disabled: () => !services?.historyService.state.canRedo,
2916
2970
  handler: () => services?.editorService.redo()
@@ -2918,28 +2972,28 @@
2918
2972
  case "zoom-in":
2919
2973
  return {
2920
2974
  type: "button",
2921
- icon: icons.ZoomIn,
2975
+ icon: vue.markRaw(icons.ZoomIn),
2922
2976
  tooltip: "\u653E\u5927",
2923
2977
  handler: zoomInHandler
2924
2978
  };
2925
2979
  case "zoom-out":
2926
2980
  return {
2927
2981
  type: "button",
2928
- icon: icons.ZoomOut,
2982
+ icon: vue.markRaw(icons.ZoomOut),
2929
2983
  tooltip: "\u7E2E\u5C0F",
2930
2984
  handler: zoomOutHandler
2931
2985
  };
2932
2986
  case "rule":
2933
2987
  return {
2934
2988
  type: "button",
2935
- icon: icons.ScaleToOriginal,
2989
+ icon: vue.markRaw(icons.ScaleToOriginal),
2936
2990
  tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2937
2991
  handler: () => uiService?.set("showRule", !showRule.value)
2938
2992
  };
2939
2993
  case "guides":
2940
2994
  return {
2941
2995
  type: "button",
2942
- icon: icons.Grid,
2996
+ icon: vue.markRaw(icons.Grid),
2943
2997
  tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2944
2998
  handler: () => uiService?.set("showGuides", !showGuides.value)
2945
2999
  };
@@ -2960,9 +3014,16 @@
2960
3014
  }
2961
3015
  return item.value.disabled;
2962
3016
  });
3017
+ const buttonHandler = (item2, event) => {
3018
+ if (disabled.value)
3019
+ return;
3020
+ if (typeof item2.handler === "function" && services) {
3021
+ item2.handler?.(services, event);
3022
+ }
3023
+ };
2963
3024
  return {
2964
- ZoomIn: icons.ZoomIn,
2965
- ZoomOut: icons.ZoomOut,
3025
+ ZoomIn: vue.markRaw(icons.ZoomIn),
3026
+ ZoomOut: vue.markRaw(icons.ZoomOut),
2966
3027
  item,
2967
3028
  zoom,
2968
3029
  disabled,
@@ -2983,31 +3044,42 @@
2983
3044
  command.item.handler(services);
2984
3045
  }
2985
3046
  },
2986
- buttonHandler(item2) {
2987
- if (disabled.value)
3047
+ clickHandler(item2, event) {
3048
+ if (props.eventType !== "click")
3049
+ return;
3050
+ if (item2.type === "button") {
3051
+ buttonHandler(item2, event);
3052
+ }
3053
+ },
3054
+ mousedownHandler(item2, event) {
3055
+ if (props.eventType !== "mousedown")
2988
3056
  return;
2989
- if (typeof item2.handler === "function") {
2990
- item2.handler?.(services);
3057
+ if (item2.type === "button") {
3058
+ buttonHandler(item2, event);
3059
+ }
3060
+ },
3061
+ mouseupHandler(item2, event) {
3062
+ if (props.eventType !== "mouseup")
3063
+ return;
3064
+ if (item2.type === "button") {
3065
+ buttonHandler(item2, event);
2991
3066
  }
2992
3067
  }
2993
3068
  };
2994
3069
  }
2995
3070
  });
2996
- const _hoisted_1$8 = {
2997
- key: 0,
2998
- class: "menu-item"
2999
- };
3000
- const _hoisted_2$4 = {
3071
+ const _hoisted_1$6 = {
3001
3072
  key: 1,
3002
3073
  class: "menu-item-text"
3003
3074
  };
3004
- const _hoisted_3$3 = {
3075
+ const _hoisted_2$2 = {
3005
3076
  class: "menu-item-text",
3006
3077
  style: { "margin": "0 5px" }
3007
3078
  };
3008
- const _hoisted_4$2 = { class: "el-dropdown-link menubar-menu-button" };
3009
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
3079
+ const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
3080
+ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
3010
3081
  const _component_el_divider = vue.resolveComponent("el-divider");
3082
+ const _component_tool_button = vue.resolveComponent("tool-button", true);
3011
3083
  const _component_m_icon = vue.resolveComponent("m-icon");
3012
3084
  const _component_el_button = vue.resolveComponent("el-button");
3013
3085
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -3016,60 +3088,66 @@
3016
3088
  const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
3017
3089
  const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
3018
3090
  const _component_el_dropdown = vue.resolveComponent("el-dropdown");
3019
- return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
3091
+ return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", {
3092
+ key: 0,
3093
+ class: vue.normalizeClass(["menu-item", _ctx.item.type]),
3094
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
3095
+ onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
3096
+ onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
3097
+ }, [
3020
3098
  _ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
3021
3099
  key: 0,
3022
- direction: "vertical"
3023
- })) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$4, vue.toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
3024
- vue.createVNode(_component_el_button, {
3025
- size: "small",
3026
- type: "text"
3100
+ direction: _ctx.item.direction || "vertical"
3101
+ }, null, 8, ["direction"])) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, vue.toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
3102
+ vue.createVNode(_component_tool_button, {
3103
+ data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
3104
+ "event-type": _ctx.eventType
3105
+ }, null, 8, ["data", "event-type"]),
3106
+ vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
3107
+ vue.createVNode(_component_tool_button, {
3108
+ data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
3109
+ "event-type": _ctx.eventType
3110
+ }, null, 8, ["data", "event-type"])
3111
+ ], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
3112
+ _ctx.item.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
3113
+ key: 0,
3114
+ effect: "dark",
3115
+ placement: "bottom-start",
3116
+ content: _ctx.item.tooltip
3027
3117
  }, {
3028
3118
  default: vue.withCtx(() => [
3029
- vue.createVNode(_component_m_icon, {
3030
- icon: _ctx.ZoomIn,
3031
- onClick: _ctx.zoomInHandler
3032
- }, null, 8, ["icon", "onClick"])
3119
+ vue.createVNode(_component_el_button, {
3120
+ size: "small",
3121
+ type: "text",
3122
+ disabled: _ctx.disabled
3123
+ }, {
3124
+ default: vue.withCtx(() => [
3125
+ _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
3126
+ key: 0,
3127
+ icon: _ctx.item.icon
3128
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
3129
+ vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
3130
+ ]),
3131
+ _: 1
3132
+ }, 8, ["disabled"])
3033
3133
  ]),
3034
3134
  _: 1
3035
- }),
3036
- vue.createElementVNode("span", _hoisted_3$3, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
3037
- vue.createVNode(_component_el_button, {
3135
+ }, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
3136
+ key: 1,
3038
3137
  size: "small",
3039
- type: "text"
3138
+ type: "text",
3139
+ disabled: _ctx.disabled
3040
3140
  }, {
3041
3141
  default: vue.withCtx(() => [
3042
- vue.createVNode(_component_m_icon, {
3043
- icon: _ctx.ZoomOut,
3044
- onClick: _ctx.zoomOutHandler
3045
- }, null, 8, ["icon", "onClick"])
3142
+ _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
3143
+ key: 0,
3144
+ icon: _ctx.item.icon
3145
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
3146
+ vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
3046
3147
  ]),
3047
3148
  _: 1
3048
- })
3049
- ], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
3050
- key: 3,
3051
- effect: "dark",
3052
- placement: "bottom-start",
3053
- content: _ctx.item.tooltip || _ctx.item.text
3054
- }, {
3055
- default: vue.withCtx(() => [
3056
- vue.createVNode(_component_el_button, {
3057
- size: "small",
3058
- type: "text",
3059
- disabled: _ctx.disabled,
3060
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.buttonHandler(_ctx.item))
3061
- }, {
3062
- default: vue.withCtx(() => [
3063
- vue.createVNode(_component_m_icon, {
3064
- icon: _ctx.item.icon
3065
- }, null, 8, ["icon"]),
3066
- vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
3067
- ]),
3068
- _: 1
3069
- }, 8, ["disabled"])
3070
- ]),
3071
- _: 1
3072
- }, 8, ["content"])) : _ctx.item.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
3149
+ }, 8, ["disabled"]))
3150
+ ], 64)) : _ctx.item.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
3073
3151
  key: 4,
3074
3152
  trigger: "click",
3075
3153
  disabled: _ctx.disabled,
@@ -3094,7 +3172,7 @@
3094
3172
  })) : vue.createCommentVNode("", true)
3095
3173
  ]),
3096
3174
  default: vue.withCtx(() => [
3097
- vue.createElementVNode("span", _hoisted_4$2, [
3175
+ vue.createElementVNode("span", _hoisted_3$1, [
3098
3176
  vue.createTextVNode(vue.toDisplayString(_ctx.item.text), 1),
3099
3177
  vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
3100
3178
  default: vue.withCtx(() => [
@@ -3106,11 +3184,11 @@
3106
3184
  ]),
3107
3185
  _: 1
3108
3186
  }, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.item.component), vue.normalizeProps(vue.mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : vue.createCommentVNode("", true)
3109
- ])) : vue.createCommentVNode("", true);
3187
+ ], 34)) : vue.createCommentVNode("", true);
3110
3188
  }
3111
- var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
3189
+ var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
3112
3190
 
3113
- const _sfc_main$b = vue.defineComponent({
3191
+ const _sfc_main$c = vue.defineComponent({
3114
3192
  name: "nav-menu",
3115
3193
  components: { ToolButton },
3116
3194
  props: {
@@ -3130,7 +3208,7 @@
3130
3208
  };
3131
3209
  }
3132
3210
  });
3133
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
3211
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
3134
3212
  const _component_tool_button = vue.resolveComponent("tool-button");
3135
3213
  return vue.openBlock(), vue.createElementBlock("div", {
3136
3214
  class: "m-editor-nav-menu",
@@ -3152,9 +3230,9 @@
3152
3230
  }), 128))
3153
3231
  ], 4);
3154
3232
  }
3155
- var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
3233
+ var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
3156
3234
 
3157
- const _sfc_main$a = vue.defineComponent({
3235
+ const _sfc_main$b = vue.defineComponent({
3158
3236
  name: "m-editor-props-panel",
3159
3237
  emits: ["mounted"],
3160
3238
  setup(props, { emit }) {
@@ -3200,7 +3278,7 @@
3200
3278
  };
3201
3279
  }
3202
3280
  });
3203
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
3281
+ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
3204
3282
  const _component_m_form = vue.resolveComponent("m-form");
3205
3283
  return vue.openBlock(), vue.createBlock(_component_m_form, {
3206
3284
  class: "m-editor-props-panel",
@@ -3212,9 +3290,9 @@
3212
3290
  onChange: _ctx.submit
3213
3291
  }, null, 8, ["init-values", "config", "onChange"]);
3214
3292
  }
3215
- var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
3293
+ var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
3216
3294
 
3217
- const _sfc_main$9 = vue.defineComponent({
3295
+ const _sfc_main$a = vue.defineComponent({
3218
3296
  name: "ui-component-panel",
3219
3297
  components: { MIcon },
3220
3298
  setup() {
@@ -3235,13 +3313,23 @@
3235
3313
  type,
3236
3314
  ...data
3237
3315
  });
3316
+ },
3317
+ dragstartHandler({ text, type, data = {} }, e) {
3318
+ if (e.dataTransfer) {
3319
+ e.dataTransfer.effectAllowed = "move";
3320
+ e.dataTransfer.setData("data", serialize__default["default"]({
3321
+ name: text,
3322
+ type,
3323
+ ...data
3324
+ }).replace(/"(\w+)":\s/g, "$1: "));
3325
+ }
3238
3326
  }
3239
3327
  };
3240
3328
  }
3241
3329
  });
3242
- const _hoisted_1$7 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3243
- const _hoisted_2$3 = ["onClick"];
3244
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
3330
+ const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3331
+ const _hoisted_2$1 = ["onClick", "onDragstart"];
3332
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
3245
3333
  const _component_el_input = vue.resolveComponent("el-input");
3246
3334
  const _component_m_icon = vue.resolveComponent("m-icon");
3247
3335
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -3271,15 +3359,17 @@
3271
3359
  name: index
3272
3360
  }, {
3273
3361
  title: vue.withCtx(() => [
3274
- _hoisted_1$7,
3362
+ _hoisted_1$5,
3275
3363
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
3276
3364
  ]),
3277
3365
  default: vue.withCtx(() => [
3278
3366
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.items, (item) => {
3279
3367
  return vue.openBlock(), vue.createElementBlock("div", {
3280
3368
  class: "component-item",
3369
+ draggable: "true",
3281
3370
  key: item.type,
3282
- onClick: ($event) => _ctx.appendComponent(item)
3371
+ onClick: ($event) => _ctx.appendComponent(item),
3372
+ onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
3283
3373
  }, [
3284
3374
  vue.createVNode(_component_m_icon, {
3285
3375
  icon: item.icon
@@ -3294,7 +3384,7 @@
3294
3384
  ]),
3295
3385
  _: 2
3296
3386
  }, 1032, ["content"])
3297
- ], 8, _hoisted_2$3);
3387
+ ], 40, _hoisted_2$1);
3298
3388
  }), 128))
3299
3389
  ]),
3300
3390
  _: 2
@@ -3308,98 +3398,194 @@
3308
3398
  _: 1
3309
3399
  });
3310
3400
  }
3311
- var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
3401
+ var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
3402
+
3403
+ const _sfc_main$9 = vue.defineComponent({
3404
+ components: { ToolButton },
3405
+ props: {
3406
+ menuData: {
3407
+ type: Array,
3408
+ default: () => []
3409
+ }
3410
+ },
3411
+ setup() {
3412
+ const menu = vue.ref();
3413
+ const subMenu = vue.ref();
3414
+ const visible = vue.ref(false);
3415
+ const subMenuData = vue.ref([]);
3416
+ const menuStyle = vue.ref({
3417
+ left: "0",
3418
+ top: "0"
3419
+ });
3420
+ const hide = () => {
3421
+ visible.value = false;
3422
+ };
3423
+ vue.onMounted(() => {
3424
+ globalThis.addEventListener("mousedown", (e) => {
3425
+ if (!visible.value || e.target && menu.value?.contains(e.target)) {
3426
+ return;
3427
+ }
3428
+ hide();
3429
+ }, true);
3430
+ });
3431
+ return {
3432
+ menu,
3433
+ subMenu,
3434
+ visible,
3435
+ menuStyle,
3436
+ subMenuData,
3437
+ hide,
3438
+ show(e) {
3439
+ visible.value = true;
3440
+ vue.nextTick(() => {
3441
+ const menuHeight = menu.value?.clientHeight || 0;
3442
+ let top = e.clientY;
3443
+ if (menuHeight + e.clientY > document.body.clientHeight) {
3444
+ top = document.body.clientHeight - menuHeight;
3445
+ }
3446
+ menuStyle.value = {
3447
+ top: `${top}px`,
3448
+ left: `${e.clientX}px`
3449
+ };
3450
+ });
3451
+ },
3452
+ showSubMenu(item) {
3453
+ const menuItem = item;
3454
+ if (typeof item !== "object" || !menuItem.items?.length) {
3455
+ return;
3456
+ }
3457
+ subMenuData.value = menuItem.items;
3458
+ if (menu.value) {
3459
+ subMenu.value.show({
3460
+ clientX: menu.value.offsetLeft + menu.value.clientWidth,
3461
+ clientY: menu.value.offsetTop
3462
+ });
3463
+ }
3464
+ }
3465
+ };
3466
+ }
3467
+ });
3468
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
3469
+ const _component_tool_button = vue.resolveComponent("tool-button");
3470
+ const _component_content_menu = vue.resolveComponent("content-menu", true);
3471
+ return _ctx.menuData.length ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
3472
+ key: 0,
3473
+ class: "magic-editor-content-menu",
3474
+ ref: "menu",
3475
+ style: vue.normalizeStyle(_ctx.menuStyle)
3476
+ }, [
3477
+ vue.createElementVNode("div", null, [
3478
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
3479
+ return vue.openBlock(), vue.createBlock(_component_tool_button, {
3480
+ "event-type": "mouseup",
3481
+ data: item,
3482
+ key: index,
3483
+ onMouseup: _ctx.hide,
3484
+ onMouseenter: ($event) => _ctx.showSubMenu(item)
3485
+ }, null, 8, ["data", "onMouseup", "onMouseenter"]);
3486
+ }), 128))
3487
+ ]),
3488
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3489
+ vue.createVNode(_component_content_menu, {
3490
+ class: "sub-menu",
3491
+ ref: "subMenu",
3492
+ "menu-data": _ctx.subMenuData
3493
+ }, null, 8, ["menu-data"])
3494
+ ]))
3495
+ ], 4)), [
3496
+ [vue.vShow, _ctx.visible]
3497
+ ]) : vue.createCommentVNode("", true);
3498
+ }
3499
+ var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
3312
3500
 
3313
3501
  const _sfc_main$8 = vue.defineComponent({
3314
- name: "magic-editor-content-menu",
3502
+ components: { ContentMenu },
3315
3503
  setup() {
3316
3504
  const services = vue.inject("services");
3317
- const subVisible = vue.ref(false);
3505
+ const menu = vue.ref();
3318
3506
  const node = vue.computed(() => services?.editorService.get("node"));
3319
- return {
3320
- subVisible,
3321
- node,
3322
- componentGroupList: vue.computed(() => services?.componentListService.getList()),
3323
- append(config) {
3507
+ const isRoot = vue.computed(() => node.value?.type === schema.NodeType.ROOT);
3508
+ const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
3509
+ const componentList = vue.computed(() => services?.componentListService.getList() || []);
3510
+ const createMenuItems = (group) => group.items.map((component) => ({
3511
+ text: component.text,
3512
+ type: "button",
3513
+ icon: component.icon,
3514
+ handler: () => {
3324
3515
  services?.editorService.add({
3325
- name: config.text,
3326
- type: config.type,
3327
- ...config.data || {}
3516
+ name: component.text,
3517
+ type: component.type,
3518
+ ...component.data || {}
3328
3519
  });
3329
- },
3330
- remove() {
3331
- node.value && services?.editorService.remove(node.value);
3332
- },
3333
- copy(node2) {
3334
- node2 && services?.editorService.copy(node2);
3335
- },
3336
- setSubVisitable(v) {
3337
- subVisible.value = v;
3520
+ }
3521
+ }));
3522
+ const getSubMenuData = vue.computed(() => {
3523
+ if (node.value?.type === "tabs") {
3524
+ return [
3525
+ {
3526
+ text: "\u6807\u7B7E\u9875",
3527
+ type: "button",
3528
+ icon: icons.Files,
3529
+ handler: () => {
3530
+ services?.editorService.add({
3531
+ type: "tab-pane"
3532
+ });
3533
+ }
3534
+ }
3535
+ ];
3536
+ }
3537
+ if (node.value?.items) {
3538
+ return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
3539
+ {
3540
+ type: "divider",
3541
+ direction: "horizontal"
3542
+ }
3543
+ ] : []), []) || [];
3544
+ }
3545
+ return [];
3546
+ });
3547
+ return {
3548
+ menu,
3549
+ menuData: vue.computed(() => [
3550
+ {
3551
+ type: "button",
3552
+ text: "\u65B0\u589E",
3553
+ icon: vue.markRaw(icons.Plus),
3554
+ display: () => node.value?.items,
3555
+ items: getSubMenuData.value
3556
+ },
3557
+ {
3558
+ type: "button",
3559
+ text: "\u590D\u5236",
3560
+ icon: vue.markRaw(icons.DocumentCopy),
3561
+ display: () => !isRoot.value,
3562
+ handler: () => {
3563
+ node.value && services?.editorService.copy(node.value);
3564
+ }
3565
+ },
3566
+ {
3567
+ type: "button",
3568
+ text: "\u5220\u9664",
3569
+ icon: vue.markRaw(icons.Delete),
3570
+ display: () => !isRoot.value && !isPage.value,
3571
+ handler: () => {
3572
+ node.value && services?.editorService.remove(node.value);
3573
+ }
3574
+ }
3575
+ ]),
3576
+ show(e) {
3577
+ menu.value?.show(e);
3338
3578
  }
3339
3579
  };
3340
3580
  }
3341
3581
  });
3342
- const _hoisted_1$6 = {
3343
- key: 0,
3344
- class: "magic-editor-content-menu"
3345
- };
3346
- const _hoisted_2$2 = ["onClick"];
3347
- const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3348
3582
  function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
3349
- const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
3350
- return _ctx.node ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
3351
- _ctx.node.items ? (vue.openBlock(), vue.createElementBlock("div", {
3352
- key: 0,
3353
- class: "magic-editor-content-menu-item",
3354
- onMouseenter: _cache[0] || (_cache[0] = ($event) => _ctx.setSubVisitable(true)),
3355
- onMouseleave: _cache[1] || (_cache[1] = ($event) => _ctx.setSubVisitable(false))
3356
- }, " \u65B0\u589E ", 32)) : vue.createCommentVNode("", true),
3357
- _ctx.node.type !== "app" ? (vue.openBlock(), vue.createElementBlock("div", {
3358
- key: 1,
3359
- class: "magic-editor-content-menu-item",
3360
- onClick: _cache[2] || (_cache[2] = () => _ctx.copy(_ctx.node))
3361
- }, "\u590D\u5236")) : vue.createCommentVNode("", true),
3362
- _ctx.node.type !== "app" && _ctx.node.type !== "page" ? (vue.openBlock(), vue.createElementBlock("div", {
3363
- key: 2,
3364
- class: "magic-editor-content-menu-item",
3365
- onClick: _cache[3] || (_cache[3] = () => _ctx.remove())
3366
- }, " \u5220\u9664 ")) : vue.createCommentVNode("", true),
3367
- vue.withDirectives(vue.createElementVNode("div", {
3368
- class: "subMenu",
3369
- onMouseenter: _cache[5] || (_cache[5] = ($event) => _ctx.setSubVisitable(true)),
3370
- onMouseleave: _cache[6] || (_cache[6] = ($event) => _ctx.setSubVisitable(false))
3371
- }, [
3372
- vue.createVNode(_component_el_scrollbar, null, {
3373
- default: vue.withCtx(() => [
3374
- _ctx.node.type === "tabs" ? (vue.openBlock(), vue.createElementBlock("div", {
3375
- key: 0,
3376
- class: "magic-editor-content-menu-item",
3377
- onClick: _cache[4] || (_cache[4] = () => _ctx.append({
3378
- type: "tab-pane"
3379
- }))
3380
- }, " \u6807\u7B7E ")) : _ctx.node.items ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(_ctx.componentGroupList, (list) => {
3381
- return vue.openBlock(), vue.createElementBlock("div", {
3382
- key: list.title
3383
- }, [
3384
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.items, (item) => {
3385
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
3386
- item ? (vue.openBlock(), vue.createElementBlock("div", {
3387
- class: "magic-editor-content-menu-item",
3388
- key: item.type,
3389
- onClick: () => _ctx.append(item)
3390
- }, vue.toDisplayString(item.text), 9, _hoisted_2$2)) : vue.createCommentVNode("", true)
3391
- ], 64);
3392
- }), 256)),
3393
- _hoisted_3$2
3394
- ]);
3395
- }), 128)) : vue.createCommentVNode("", true)
3396
- ]),
3397
- _: 1
3398
- })
3399
- ], 544), [
3400
- [vue.vShow, _ctx.subVisible]
3401
- ])
3402
- ])) : vue.createCommentVNode("", true);
3583
+ const _component_content_menu = vue.resolveComponent("content-menu");
3584
+ return vue.openBlock(), vue.createBlock(_component_content_menu, {
3585
+ "menu-data": _ctx.menuData,
3586
+ ref: "menu",
3587
+ style: { "overflow": "initial" }
3588
+ }, null, 8, ["menu-data"]);
3403
3589
  }
3404
3590
  var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
3405
3591
 
@@ -3493,56 +3679,37 @@
3493
3679
  tree.value?.filter(val);
3494
3680
  }
3495
3681
  });
3496
- const useContentMenu = (editorService) => {
3497
- const menuStyle = vue.ref({
3498
- position: "absolute",
3499
- left: "0",
3500
- top: "0",
3501
- display: "none"
3502
- });
3503
- vue.onMounted(() => {
3504
- document.addEventListener("click", () => {
3505
- menuStyle.value.display = "none";
3506
- }, true);
3507
- });
3508
- return {
3509
- menuStyle,
3510
- contextmenu(event, data) {
3511
- const bodyHeight = globalThis.document.body.clientHeight;
3512
- const left = `${event.clientX + 20}px`;
3513
- let top = `${event.clientY - 10}px`;
3514
- if (event.clientY + 300 > bodyHeight) {
3515
- top = `${bodyHeight - 300}px`;
3516
- }
3517
- menuStyle.value.left = left;
3518
- menuStyle.value.top = top;
3519
- menuStyle.value.display = "";
3520
- select(data, editorService);
3521
- }
3522
- };
3523
- };
3524
3682
  const _sfc_main$7 = vue.defineComponent({
3525
3683
  name: "magic-editor-layer-panel",
3526
3684
  components: { LayerMenu },
3527
3685
  setup() {
3528
3686
  const services = vue.inject("services");
3529
3687
  const tree = vue.ref();
3688
+ const menu = vue.ref();
3530
3689
  const clicked = vue.ref(false);
3531
3690
  const editorService = services?.editorService;
3532
3691
  const highlightHandler = lodashEs.throttle((data) => {
3533
3692
  highlight(data, editorService);
3534
3693
  }, throttleTime);
3535
- const toogleClickFlag = () => {
3694
+ const toggleClickFlag = () => {
3536
3695
  clicked.value = !clicked.value;
3537
3696
  };
3538
3697
  const statusData = useStatus(tree, editorService);
3539
3698
  const canHighlight = vue.computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
3699
+ editorService?.on("remove", () => {
3700
+ setTimeout(() => {
3701
+ tree.value?.getNode(editorService.get("node").id)?.updateChildren();
3702
+ }, 0);
3703
+ });
3540
3704
  return {
3541
3705
  tree,
3706
+ menu,
3542
3707
  ...statusData,
3543
3708
  ...useDrop(tree, editorService),
3544
3709
  ...useFilter(tree),
3545
- ...useContentMenu(editorService),
3710
+ highlightHandler,
3711
+ toggleClickFlag,
3712
+ canHighlight,
3546
3713
  clickHandler(data) {
3547
3714
  if (services?.uiService.get("uiSelectMode")) {
3548
3715
  document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
@@ -3551,13 +3718,15 @@
3551
3718
  tree.value?.setCurrentKey(data.id);
3552
3719
  select(data, editorService);
3553
3720
  },
3554
- highlightHandler,
3555
- toogleClickFlag,
3556
- canHighlight
3721
+ async contextmenu(event, data) {
3722
+ event.preventDefault();
3723
+ await select(data, editorService);
3724
+ menu.value?.show(event);
3725
+ }
3557
3726
  };
3558
3727
  }
3559
3728
  });
3560
- const _hoisted_1$5 = ["id", "onMouseenter"];
3729
+ const _hoisted_1$4 = ["id", "onMouseenter"];
3561
3730
  function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3562
3731
  const _component_el_input = vue.resolveComponent("el-input");
3563
3732
  const _component_el_tree = vue.resolveComponent("el-tree");
@@ -3598,8 +3767,8 @@
3598
3767
  vue.createElementVNode("div", {
3599
3768
  id: data.id,
3600
3769
  class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
3601
- onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
3602
- onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
3770
+ onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
3771
+ onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
3603
3772
  onMouseenter: ($event) => _ctx.highlightHandler(data)
3604
3773
  }, [
3605
3774
  vue.renderSlot(_ctx.$slots, "layer-node-content", {
@@ -3608,14 +3777,12 @@
3608
3777
  }, () => [
3609
3778
  vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
3610
3779
  ])
3611
- ], 42, _hoisted_1$5)
3780
+ ], 42, _hoisted_1$4)
3612
3781
  ]),
3613
3782
  _: 3
3614
3783
  }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
3615
3784
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3616
- vue.createVNode(_component_layer_menu, {
3617
- style: vue.normalizeStyle(_ctx.menuStyle)
3618
- }, null, 8, ["style"])
3785
+ vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
3619
3786
  ]))
3620
3787
  ]),
3621
3788
  _: 3
@@ -3667,7 +3834,7 @@
3667
3834
  };
3668
3835
  }
3669
3836
  });
3670
- const _hoisted_1$4 = {
3837
+ const _hoisted_1$3 = {
3671
3838
  key: 1,
3672
3839
  class: "magic-editor-tab-panel-title"
3673
3840
  };
@@ -3695,7 +3862,7 @@
3695
3862
  key: 0,
3696
3863
  icon: item.icon
3697
3864
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
3698
- item.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, vue.toDisplayString(item.text), 1)) : vue.createCommentVNode("", true)
3865
+ item.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, vue.toDisplayString(item.text), 1)) : vue.createCommentVNode("", true)
3699
3866
  ])
3700
3867
  ]),
3701
3868
  default: vue.withCtx(() => [
@@ -3785,12 +3952,14 @@
3785
3952
  };
3786
3953
  };
3787
3954
  const _sfc_main$5 = vue.defineComponent({
3788
- components: { ArrowLeftBold: icons.ArrowLeftBold, ArrowRightBold: icons.ArrowRightBold, CaretBottom: icons.CaretBottom, Plus: icons.Plus },
3955
+ components: { ArrowLeftBold: icons.ArrowLeftBold, ArrowRightBold: icons.ArrowRightBold, CaretBottom: icons.CaretBottom, Plus: icons.Plus, ToolButton },
3789
3956
  setup() {
3790
3957
  const services = vue.inject("services");
3791
3958
  const editorService = services?.editorService;
3792
3959
  const root = vue.computed(() => editorService?.get("root"));
3793
3960
  return {
3961
+ Delete: vue.markRaw(icons.Delete),
3962
+ DocumentCopy: vue.markRaw(icons.DocumentCopy),
3794
3963
  ...useScroll(root),
3795
3964
  root,
3796
3965
  page: vue.computed(() => editorService?.get("page")),
@@ -3819,23 +3988,22 @@
3819
3988
  };
3820
3989
  }
3821
3990
  });
3822
- const _hoisted_1$3 = {
3991
+ const _hoisted_1$2 = {
3823
3992
  class: "m-editor-page-bar",
3824
3993
  ref: "pageBar"
3825
3994
  };
3826
- const _hoisted_2$1 = ["onClick"];
3827
- const _hoisted_3$1 = { class: "m-editor-page-bar-title" };
3828
- const _hoisted_4$1 = ["onClick"];
3829
- const _hoisted_5 = ["onClick"];
3995
+ const _hoisted_2 = ["onClick"];
3996
+ const _hoisted_3 = { class: "m-editor-page-bar-title" };
3830
3997
  function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3831
3998
  const _component_plus = vue.resolveComponent("plus");
3832
3999
  const _component_el_icon = vue.resolveComponent("el-icon");
3833
4000
  const _component_arrow_left_bold = vue.resolveComponent("arrow-left-bold");
3834
4001
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
4002
+ const _component_tool_button = vue.resolveComponent("tool-button");
3835
4003
  const _component_caret_bottom = vue.resolveComponent("caret-bottom");
3836
4004
  const _component_el_popover = vue.resolveComponent("el-popover");
3837
4005
  const _component_arrow_right_bold = vue.resolveComponent("arrow-right-bold");
3838
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
4006
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
3839
4007
  vue.createElementVNode("div", {
3840
4008
  id: "m-editor-page-bar-add-icon",
3841
4009
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
@@ -3872,7 +4040,7 @@
3872
4040
  class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
3873
4041
  onClick: ($event) => _ctx.switchPage(item)
3874
4042
  }, [
3875
- vue.createElementVNode("div", _hoisted_3$1, [
4043
+ vue.createElementVNode("div", _hoisted_3, [
3876
4044
  vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3877
4045
  vue.createVNode(_component_el_tooltip, {
3878
4046
  effect: "dark",
@@ -3887,6 +4055,7 @@
3887
4055
  ])
3888
4056
  ]),
3889
4057
  vue.createVNode(_component_el_popover, {
4058
+ "popper-class": "page-bar-popover",
3890
4059
  placement: "top",
3891
4060
  width: 160,
3892
4061
  trigger: "hover"
@@ -3902,20 +4071,28 @@
3902
4071
  default: vue.withCtx(() => [
3903
4072
  vue.createElementVNode("div", null, [
3904
4073
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3905
- vue.createElementVNode("div", {
3906
- class: "magic-editor-content-menu-item",
3907
- onClick: () => _ctx.copy(item)
3908
- }, "\u590D\u5236", 8, _hoisted_4$1),
3909
- vue.createElementVNode("div", {
3910
- class: "magic-editor-content-menu-item",
3911
- onClick: () => _ctx.remove(item)
3912
- }, "\u5220\u9664", 8, _hoisted_5)
4074
+ vue.createVNode(_component_tool_button, {
4075
+ data: {
4076
+ type: "button",
4077
+ text: "\u590D\u5236",
4078
+ icon: _ctx.DocumentCopy,
4079
+ handler: () => _ctx.copy(item)
4080
+ }
4081
+ }, null, 8, ["data"]),
4082
+ vue.createVNode(_component_tool_button, {
4083
+ data: {
4084
+ type: "button",
4085
+ text: "\u5220\u9664",
4086
+ icon: _ctx.Delete,
4087
+ handler: () => _ctx.remove(item)
4088
+ }
4089
+ }, null, 8, ["data"])
3913
4090
  ])
3914
4091
  ])
3915
4092
  ]),
3916
4093
  _: 2
3917
4094
  }, 1024)
3918
- ], 10, _hoisted_2$1);
4095
+ ], 10, _hoisted_2);
3919
4096
  }), 128))
3920
4097
  ], 4)) : vue.createCommentVNode("", true),
3921
4098
  _ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
@@ -4135,12 +4312,12 @@
4135
4312
  };
4136
4313
  }
4137
4314
  });
4138
- const _hoisted_1$2 = {
4315
+ const _hoisted_1$1 = {
4139
4316
  class: "m-editor-scroll-viewer-container",
4140
4317
  ref: "container"
4141
4318
  };
4142
4319
  function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
4143
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
4320
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
4144
4321
  vue.createElementVNode("div", {
4145
4322
  ref: "el",
4146
4323
  style: vue.normalizeStyle(_ctx.style)
@@ -4152,7 +4329,7 @@
4152
4329
  var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
4153
4330
 
4154
4331
  const _sfc_main$3 = vue.defineComponent({
4155
- name: "magic-editor-ui-viewer-menu",
4332
+ components: { ContentMenu },
4156
4333
  setup() {
4157
4334
  const services = vue.inject("services");
4158
4335
  const editorService = services?.editorService;
@@ -4161,6 +4338,7 @@
4161
4338
  const canCenter = vue.ref(false);
4162
4339
  const node = vue.computed(() => editorService?.get("node"));
4163
4340
  const parent = vue.computed(() => editorService?.get("parent"));
4341
+ const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
4164
4342
  vue.onMounted(() => {
4165
4343
  const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
4166
4344
  canPaste.value = data !== "undefined" && !!data;
@@ -4173,133 +4351,114 @@
4173
4351
  }, { immediate: true });
4174
4352
  return {
4175
4353
  menu,
4176
- canPaste,
4177
- canDelete: vue.computed(() => node.value?.type !== schema.NodeType.PAGE),
4178
- canMoveZPos: vue.computed(() => node.value?.type !== schema.NodeType.PAGE),
4179
- canCenter,
4180
- center() {
4181
- node.value && editorService?.alignCenter(node.value);
4182
- },
4183
- copy() {
4184
- node.value && editorService?.copy(node.value);
4185
- canPaste.value = true;
4186
- },
4187
- paste() {
4188
- const top = menu.value?.offsetTop || 0;
4189
- const left = menu.value?.offsetLeft || 0;
4190
- editorService?.paste({ left, top });
4191
- },
4192
- remove() {
4193
- node.value && editorService?.remove(node.value);
4194
- },
4195
- top() {
4196
- editorService?.moveLayer(LayerOffset.TOP);
4197
- },
4198
- bottom() {
4199
- editorService?.moveLayer(LayerOffset.BOTTOM);
4200
- },
4201
- topItem() {
4202
- editorService?.moveLayer(1);
4203
- },
4204
- bottomItem() {
4205
- editorService?.moveLayer(-1);
4206
- },
4207
- clearGuides() {
4208
- editorService?.get("stage").clearGuides();
4354
+ menuData: vue.reactive([
4355
+ {
4356
+ type: "button",
4357
+ text: "\u6C34\u5E73\u5C45\u4E2D",
4358
+ display: () => canCenter.value,
4359
+ handler: () => {
4360
+ node.value && editorService?.alignCenter(node.value);
4361
+ }
4362
+ },
4363
+ {
4364
+ type: "button",
4365
+ text: "\u590D\u5236",
4366
+ icon: vue.markRaw(icons.DocumentCopy),
4367
+ handler: () => {
4368
+ node.value && editorService?.copy(node.value);
4369
+ canPaste.value = true;
4370
+ }
4371
+ },
4372
+ {
4373
+ type: "button",
4374
+ text: "\u7C98\u8D34",
4375
+ display: () => canPaste.value,
4376
+ handler: () => {
4377
+ const top = menu.value?.$el.offsetTop || 0;
4378
+ const left = menu.value?.$el.offsetLeft || 0;
4379
+ editorService?.paste({ left, top });
4380
+ }
4381
+ },
4382
+ {
4383
+ type: "divider",
4384
+ direction: "horizontal",
4385
+ display: () => !isPage.value
4386
+ },
4387
+ {
4388
+ type: "button",
4389
+ text: "\u4E0A\u79FB\u4E00\u5C42",
4390
+ icon: vue.markRaw(icons.Top),
4391
+ display: () => !isPage.value,
4392
+ handler: () => {
4393
+ editorService?.moveLayer(1);
4394
+ }
4395
+ },
4396
+ {
4397
+ type: "button",
4398
+ text: "\u4E0B\u79FB\u4E00\u5C42",
4399
+ icon: vue.markRaw(icons.Bottom),
4400
+ display: () => !isPage.value,
4401
+ handler: () => {
4402
+ editorService?.moveLayer(-1);
4403
+ }
4404
+ },
4405
+ {
4406
+ type: "button",
4407
+ text: "\u7F6E\u9876",
4408
+ display: () => !isPage.value,
4409
+ handler: () => {
4410
+ editorService?.moveLayer(LayerOffset.TOP);
4411
+ }
4412
+ },
4413
+ {
4414
+ type: "button",
4415
+ text: "\u7F6E\u5E95",
4416
+ display: () => !isPage.value,
4417
+ handler: () => {
4418
+ editorService?.moveLayer(LayerOffset.BOTTOM);
4419
+ }
4420
+ },
4421
+ {
4422
+ type: "divider",
4423
+ direction: "horizontal",
4424
+ display: () => !isPage.value
4425
+ },
4426
+ {
4427
+ type: "button",
4428
+ text: "\u5220\u9664",
4429
+ icon: icons.Delete,
4430
+ display: () => !isPage.value,
4431
+ handler: () => {
4432
+ node.value && editorService?.remove(node.value);
4433
+ }
4434
+ },
4435
+ {
4436
+ type: "divider",
4437
+ direction: "horizontal"
4438
+ },
4439
+ {
4440
+ type: "button",
4441
+ text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
4442
+ handler: () => {
4443
+ editorService?.get("stage").clearGuides();
4444
+ }
4445
+ }
4446
+ ]),
4447
+ show(e) {
4448
+ menu.value?.show(e);
4209
4449
  }
4210
4450
  };
4211
4451
  }
4212
4452
  });
4213
- const _hoisted_1$1 = {
4214
- class: "magic-editor-content-menu",
4215
- ref: "menu"
4216
- };
4217
- const _hoisted_2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
4218
- const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
4219
- const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
4220
4453
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
4221
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
4222
- vue.createElementVNode("div", null, [
4223
- _ctx.canCenter ? (vue.openBlock(), vue.createElementBlock("div", {
4224
- key: 0,
4225
- class: "magic-editor-content-menu-item",
4226
- onClick: _cache[0] || (_cache[0] = () => _ctx.center())
4227
- }, "\u6C34\u5E73\u5C45\u4E2D")) : vue.createCommentVNode("", true),
4228
- vue.createElementVNode("div", {
4229
- class: "magic-editor-content-menu-item",
4230
- onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
4231
- }, "\u590D\u5236"),
4232
- _ctx.canPaste ? (vue.openBlock(), vue.createElementBlock("div", {
4233
- key: 1,
4234
- class: "magic-editor-content-menu-item",
4235
- onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
4236
- }, "\u7C98\u8D34")) : vue.createCommentVNode("", true),
4237
- _ctx.canMoveZPos ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
4238
- _hoisted_2,
4239
- vue.createElementVNode("div", {
4240
- class: "magic-editor-content-menu-item",
4241
- onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
4242
- }, "\u4E0A\u79FB\u4E00\u5C42"),
4243
- vue.createElementVNode("div", {
4244
- class: "magic-editor-content-menu-item",
4245
- onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
4246
- }, "\u4E0B\u79FB\u4E00\u5C42"),
4247
- vue.createElementVNode("div", {
4248
- class: "magic-editor-content-menu-item",
4249
- onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
4250
- }, "\u7F6E\u9876"),
4251
- vue.createElementVNode("div", {
4252
- class: "magic-editor-content-menu-item",
4253
- onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
4254
- }, "\u7F6E\u5E95")
4255
- ], 64)) : vue.createCommentVNode("", true),
4256
- _ctx.canDelete ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
4257
- _hoisted_3,
4258
- vue.createElementVNode("div", {
4259
- class: "magic-editor-content-menu-item",
4260
- onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
4261
- }, "\u5220\u9664")
4262
- ], 64)) : vue.createCommentVNode("", true),
4263
- _hoisted_4,
4264
- vue.createElementVNode("div", {
4265
- class: "magic-editor-content-menu-item",
4266
- onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
4267
- }, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
4268
- ])
4269
- ], 512);
4454
+ const _component_content_menu = vue.resolveComponent("content-menu");
4455
+ return vue.openBlock(), vue.createBlock(_component_content_menu, {
4456
+ "menu-data": _ctx.menuData,
4457
+ ref: "menu"
4458
+ }, null, 8, ["menu-data"]);
4270
4459
  }
4271
4460
  var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
4272
4461
 
4273
- const useMenu = () => {
4274
- const menu = vue.ref();
4275
- const menuStyle = vue.ref({
4276
- display: "none",
4277
- left: "0",
4278
- top: "0"
4279
- });
4280
- vue.onMounted(() => {
4281
- document.addEventListener("click", () => {
4282
- menuStyle.value.display = "none";
4283
- }, true);
4284
- });
4285
- return {
4286
- menu,
4287
- menuStyle,
4288
- contextmenuHandler(e) {
4289
- e.preventDefault();
4290
- const menuHeight = menu.value?.$el.clientHeight;
4291
- let top = e.clientY;
4292
- if (menuHeight + e.clientY > document.body.clientHeight) {
4293
- top = document.body.clientHeight - menuHeight;
4294
- }
4295
- menuStyle.value = {
4296
- display: "block",
4297
- top: `${top}px`,
4298
- left: `${e.clientX}px`
4299
- };
4300
- }
4301
- };
4302
- };
4303
4462
  const _sfc_main$2 = vue.defineComponent({
4304
4463
  name: "magic-stage",
4305
4464
  components: {
@@ -4326,11 +4485,12 @@
4326
4485
  const services = vue.inject("services");
4327
4486
  const stageWrap = vue.ref();
4328
4487
  const stageContainer = vue.ref();
4488
+ const menu = vue.ref();
4329
4489
  const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
4330
4490
  const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
4331
4491
  const root = vue.computed(() => services?.editorService.get("root"));
4332
4492
  const page = vue.computed(() => services?.editorService.get("page"));
4333
- const zoom = vue.computed(() => services?.uiService.get("zoom"));
4493
+ const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
4334
4494
  const node = vue.computed(() => services?.editorService.get("node"));
4335
4495
  let stage = null;
4336
4496
  let runtime = null;
@@ -4412,9 +4572,36 @@
4412
4572
  return {
4413
4573
  stageWrap,
4414
4574
  stageContainer,
4575
+ menu,
4415
4576
  stageRect,
4416
4577
  zoom,
4417
- ...useMenu()
4578
+ contextmenuHandler(e2) {
4579
+ e2.preventDefault();
4580
+ menu.value?.show(e2);
4581
+ },
4582
+ dragoverHandler(e2) {
4583
+ e2.preventDefault();
4584
+ if (e2.dataTransfer) {
4585
+ e2.dataTransfer.dropEffect = "move";
4586
+ }
4587
+ },
4588
+ async dropHandler(e) {
4589
+ e.preventDefault();
4590
+ if (e.dataTransfer && page.value && stageContainer.value && stage) {
4591
+ const config = eval(`(${e.dataTransfer.getData("data")})`);
4592
+ const layout = await services?.editorService.getLayout(page.value);
4593
+ const containerRect = stageContainer.value.getBoundingClientRect();
4594
+ const { scrollTop, scrollLeft } = stage.mask;
4595
+ if (layout === Layout.ABSOLUTE) {
4596
+ config.style = {
4597
+ position: "absolute",
4598
+ top: e.clientY - containerRect.top + scrollTop,
4599
+ left: e.clientX - containerRect.left + scrollLeft
4600
+ };
4601
+ }
4602
+ services?.editorService.add(config, page.value);
4603
+ }
4604
+ }
4418
4605
  };
4419
4606
  }
4420
4607
  });
@@ -4432,14 +4619,13 @@
4432
4619
  vue.createElementVNode("div", {
4433
4620
  class: "m-editor-stage-container",
4434
4621
  ref: "stageContainer",
4622
+ style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
4435
4623
  onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
4436
- style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`)
4624
+ onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
4625
+ onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
4437
4626
  }, null, 36),
4438
4627
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
4439
- vue.createVNode(_component_viewer_menu, {
4440
- ref: "menu",
4441
- style: vue.normalizeStyle(_ctx.menuStyle)
4442
- }, null, 8, ["style"])
4628
+ vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
4443
4629
  ]))
4444
4630
  ]),
4445
4631
  _: 1
@@ -4486,10 +4672,10 @@
4486
4672
  }).keydown([ctrl, "c"], (e) => {
4487
4673
  e.inputEvent.preventDefault();
4488
4674
  node.value && services?.editorService.copy(node.value);
4489
- }).keyup([ctrl, "v"], (e) => {
4675
+ }).keydown([ctrl, "v"], (e) => {
4490
4676
  e.inputEvent.preventDefault();
4491
4677
  node.value && services?.editorService.paste();
4492
- }).keyup([ctrl, "x"], (e) => {
4678
+ }).keydown([ctrl, "x"], (e) => {
4493
4679
  e.inputEvent.preventDefault();
4494
4680
  if (!node.value || utils.isPage(node.value))
4495
4681
  return;
@@ -4879,6 +5065,7 @@
4879
5065
  exports.PropsPanel = PropsPanel;
4880
5066
  exports.TMagicCodeEditor = CodeEditor;
4881
5067
  exports.TMagicEditor = Editor;
5068
+ exports.ToolButton = ToolButton;
4882
5069
  exports.change2Fixed = change2Fixed;
4883
5070
  exports.debug = debug;
4884
5071
  exports["default"] = index;