@tmagic/editor 1.1.0-beta.9 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/style.css +53 -4
  2. package/dist/tmagic-editor.mjs +1134 -928
  3. package/dist/tmagic-editor.mjs.map +1 -1
  4. package/dist/tmagic-editor.umd.js +1138 -929
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/package.json +10 -10
  7. package/src/Editor.vue +28 -8
  8. package/src/components/ContentMenu.vue +4 -4
  9. package/src/components/Icon.vue +11 -23
  10. package/src/components/ScrollBar.vue +147 -0
  11. package/src/components/ScrollViewer.vue +89 -44
  12. package/src/components/ToolButton.vue +40 -138
  13. package/src/fields/UISelect.vue +2 -2
  14. package/src/index.ts +2 -2
  15. package/src/layouts/NavMenu.vue +156 -23
  16. package/src/layouts/PropsPanel.vue +49 -51
  17. package/src/layouts/sidebar/ComponentListPanel.vue +78 -90
  18. package/src/layouts/sidebar/LayerMenu.vue +3 -3
  19. package/src/layouts/sidebar/LayerPanel.vue +39 -8
  20. package/src/layouts/sidebar/Sidebar.vue +4 -0
  21. package/src/layouts/sidebar/TabPane.vue +12 -0
  22. package/src/layouts/workspace/PageBar.vue +2 -2
  23. package/src/layouts/workspace/PageBarScrollContainer.vue +13 -3
  24. package/src/layouts/workspace/Stage.vue +10 -92
  25. package/src/layouts/workspace/ViewerMenu.vue +3 -3
  26. package/src/layouts/workspace/Workspace.vue +133 -138
  27. package/src/services/componentList.ts +5 -0
  28. package/src/services/editor.ts +57 -20
  29. package/src/services/events.ts +8 -2
  30. package/src/services/props.ts +31 -52
  31. package/src/services/storage.ts +4 -0
  32. package/src/services/ui.ts +33 -30
  33. package/src/theme/component-list-panel.scss +0 -5
  34. package/src/theme/content-menu.scss +4 -0
  35. package/src/theme/icon.scss +6 -0
  36. package/src/theme/index.scss +1 -0
  37. package/src/theme/nav-menu.scss +6 -0
  38. package/src/type.ts +28 -10
  39. package/src/utils/index.ts +1 -0
  40. package/src/utils/operator.ts +3 -3
  41. package/src/utils/props.ts +0 -3
  42. package/src/utils/scroll-viewer.ts +90 -158
  43. package/src/utils/stage.ts +91 -0
  44. package/types/Editor.vue.d.ts +7 -7
  45. package/types/components/ContentMenu.vue.d.ts +8 -8
  46. package/types/components/Icon.vue.d.ts +62 -12
  47. package/types/components/ScrollBar.vue.d.ts +83 -0
  48. package/types/components/ScrollViewer.vue.d.ts +131 -19
  49. package/types/components/ToolButton.vue.d.ts +56 -59
  50. package/types/index.d.ts +2 -1
  51. package/types/layouts/NavMenu.vue.d.ts +92 -23
  52. package/types/layouts/PropsPanel.vue.d.ts +25 -208
  53. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +50 -12
  54. package/types/layouts/sidebar/LayerMenu.vue.d.ts +7 -7
  55. package/types/layouts/sidebar/LayerPanel.vue.d.ts +17 -15
  56. package/types/layouts/workspace/Workspace.vue.d.ts +54 -4
  57. package/types/services/componentList.d.ts +1 -0
  58. package/types/services/editor.d.ts +1 -0
  59. package/types/services/events.d.ts +1 -0
  60. package/types/services/props.d.ts +41 -9
  61. package/types/services/storage.d.ts +1 -0
  62. package/types/services/ui.d.ts +4 -1
  63. package/types/type.d.ts +25 -10
  64. package/types/utils/index.d.ts +1 -0
  65. package/types/utils/operator.d.ts +1 -1
  66. package/types/utils/props.d.ts +0 -1
  67. package/types/utils/scroll-viewer.d.ts +16 -18
  68. package/types/utils/stage.d.ts +3 -0
  69. package/src/utils/polyfills.ts +0 -8
  70. package/types/utils/polyfills.d.ts +0 -0
@@ -1,6 +1,6 @@
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';
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, renderList, normalizeProps, mergeProps, markRaw, 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, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
3
+ import { Delete, Close, Plus, Edit, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, 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
6
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
@@ -12,14 +12,7 @@ import Gesto from 'gesto';
12
12
  import { ElMessage } from 'element-plus';
13
13
  import KeyController from 'keycon';
14
14
 
15
- if (typeof global === "undefined") {
16
- window.global = window;
17
- }
18
- if (typeof globalThis === "undefined") {
19
- window.globalThis = window;
20
- }
21
-
22
- const _sfc_main$n = defineComponent({
15
+ const _sfc_main$o = defineComponent({
23
16
  name: "m-fields-vs-code",
24
17
  props: ["model", "name", "config", "prop"],
25
18
  emits: ["change"],
@@ -45,7 +38,7 @@ const _export_sfc = (sfc, props) => {
45
38
  return target;
46
39
  };
47
40
 
48
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
41
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
49
42
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
50
43
  return openBlock(), createBlock(_component_magic_code_editor, {
51
44
  style: normalizeStyle(`height: ${_ctx.height}`),
@@ -54,9 +47,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
54
47
  onSave: _ctx.save
55
48
  }, null, 8, ["style", "init-values", "language", "onSave"]);
56
49
  }
57
- const Code = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$g]]);
50
+ const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$a]]);
58
51
 
59
- const _sfc_main$m = defineComponent({
52
+ const _sfc_main$n = defineComponent({
60
53
  name: "m-fields-code-link",
61
54
  props: {
62
55
  config: {
@@ -112,7 +105,7 @@ const _sfc_main$m = defineComponent({
112
105
  }
113
106
  });
114
107
 
115
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
108
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
116
109
  const _component_m_fields_link = resolveComponent("m-fields-link");
117
110
  return openBlock(), createBlock(_component_m_fields_link, {
118
111
  config: _ctx.formConfig,
@@ -121,10 +114,10 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
121
114
  onChange: _ctx.changeHandler
122
115
  }, null, 8, ["config", "model", "onChange"]);
123
116
  }
124
- const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
117
+ const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$9]]);
125
118
 
126
- const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
127
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
119
+ const _hoisted_1$c = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
120
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
128
121
  __name: "UISelect",
129
122
  props: {
130
123
  config: null,
@@ -189,7 +182,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
189
182
  style: { "padding": "0" }
190
183
  }, {
191
184
  default: withCtx(() => [
192
- _hoisted_1$d
185
+ _hoisted_1$c
193
186
  ]),
194
187
  _: 1
195
188
  }, 8, ["icon"])
@@ -199,19 +192,21 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
199
192
  onClick: startSelect,
200
193
  style: { "display": "flex" }
201
194
  }, [
202
- createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
195
+ unref(val) ? (openBlock(), createBlock(_component_el_tooltip, {
196
+ key: 0,
197
+ content: "\u6E05\u9664"
198
+ }, {
203
199
  default: withCtx(() => [
204
- unref(val) ? (openBlock(), createBlock(_component_el_button, {
205
- key: 0,
200
+ createVNode(_component_el_button, {
206
201
  style: { "padding": "0" },
207
202
  type: "danger",
208
203
  icon: unref(Close),
209
204
  text: "",
210
205
  onClick: withModifiers(deleteHandler, ["stop"])
211
- }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
206
+ }, null, 8, ["icon", "onClick"])
212
207
  ]),
213
208
  _: 1
214
- }),
209
+ })) : createCommentVNode("", true),
215
210
  createVNode(_component_el_tooltip, {
216
211
  content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
217
212
  }, {
@@ -250,7 +245,7 @@ const toString = (v, language) => {
250
245
  }
251
246
  return value;
252
247
  };
253
- const _sfc_main$k = defineComponent({
248
+ const _sfc_main$l = defineComponent({
254
249
  name: "magic-code-editor",
255
250
  props: {
256
251
  initValues: {
@@ -358,14 +353,14 @@ const _sfc_main$k = defineComponent({
358
353
  }
359
354
  });
360
355
 
361
- const _hoisted_1$c = {
356
+ const _hoisted_1$b = {
362
357
  ref: "codeEditor",
363
358
  class: "magic-code-editor"
364
359
  };
365
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
366
- return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
360
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
361
+ return openBlock(), createElementBlock("div", _hoisted_1$b, null, 512);
367
362
  }
368
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
363
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$8]]);
369
364
 
370
365
  let $TMAGIC_EDITOR = {};
371
366
  const setConfig = (option) => {
@@ -673,6 +668,9 @@ class WebStorage extends BaseService {
673
668
  }
674
669
  storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
675
670
  }
671
+ destroy() {
672
+ this.removeAllListeners();
673
+ }
676
674
  getValueAndProtocol(value) {
677
675
  let protocol2 = "";
678
676
  if (value === null) {
@@ -693,6 +691,12 @@ class WebStorage extends BaseService {
693
691
  }
694
692
  const storageService = new WebStorage();
695
693
 
694
+ var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
695
+ ColumnLayout2["LEFT"] = "left";
696
+ ColumnLayout2["CENTER"] = "center";
697
+ ColumnLayout2["RIGHT"] = "right";
698
+ return ColumnLayout2;
699
+ })(ColumnLayout || {});
696
700
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
697
701
  LayerOffset2["TOP"] = "top";
698
702
  LayerOffset2["BOTTOM"] = "bottom";
@@ -877,6 +881,7 @@ class Props extends BaseService {
877
881
  "getPropsValue",
878
882
  "createId",
879
883
  "setNewItemId",
884
+ "fillConfig",
880
885
  "getDefaultPropsValue"
881
886
  ]);
882
887
  }
@@ -886,14 +891,17 @@ class Props extends BaseService {
886
891
  });
887
892
  this.emit("props-configs-change");
888
893
  }
889
- setPropsConfig(type, config) {
890
- this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
894
+ async fillConfig(config) {
895
+ return fillConfig(config);
896
+ }
897
+ async setPropsConfig(type, config) {
898
+ this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
891
899
  }
892
900
  async getPropsConfig(type) {
893
901
  if (type === "area") {
894
902
  return await this.getPropsConfig("button");
895
903
  }
896
- return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
904
+ return cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
897
905
  }
898
906
  setPropsValues(values) {
899
907
  Object.keys(values).forEach((type) => {
@@ -927,25 +935,14 @@ class Props extends BaseService {
927
935
  ...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
928
936
  };
929
937
  }
930
- guid(digit = 8) {
931
- return "x".repeat(digit).replace(/[xy]/g, (c) => {
932
- const r = Math.random() * 16 | 0;
933
- const v = c == "x" ? r : r & 3 | 8;
934
- return v.toString(16);
935
- });
936
- }
937
938
  async createId(type) {
938
939
  return `${type}_${this.guid()}`;
939
940
  }
940
- async setNewItemId(config, parent) {
941
- const oldId = config.id;
941
+ async setNewItemId(config) {
942
942
  config.id = await this.createId(config.type || "component");
943
- if (isPop(config) && parent?.type === NodeType.PAGE) {
944
- updatePopId(oldId, config.id, parent);
945
- }
946
943
  if (config.items && Array.isArray(config.items)) {
947
944
  for (const item of config.items) {
948
- await this.setNewItemId(item, config);
945
+ await this.setNewItemId(item);
949
946
  }
950
947
  }
951
948
  return config;
@@ -963,22 +960,19 @@ class Props extends BaseService {
963
960
  name: type
964
961
  };
965
962
  }
963
+ destroy() {
964
+ this.state.propsConfigMap = {};
965
+ this.state.propsValueMap = {};
966
+ this.removeAllListeners();
967
+ }
968
+ guid(digit = 8) {
969
+ return "x".repeat(digit).replace(/[xy]/g, (c) => {
970
+ const r = Math.random() * 16 | 0;
971
+ const v = c === "x" ? r : r & 3 | 8;
972
+ return v.toString(16);
973
+ });
974
+ }
966
975
  }
967
- const updatePopId = (oldId, popId, pageConfig) => {
968
- pageConfig.items?.forEach((config) => {
969
- if (config.pop === oldId) {
970
- config.pop = popId;
971
- return;
972
- }
973
- if (config.popId === oldId) {
974
- config.popId = popId;
975
- return;
976
- }
977
- if (Array.isArray(config.items)) {
978
- updatePopId(oldId, popId, config);
979
- }
980
- });
981
- };
982
976
  const propsService = new Props();
983
977
 
984
978
  const beforePaste = async (position, config) => {
@@ -998,7 +992,7 @@ const beforePaste = async (position, config) => {
998
992
  if (pastePosition.top && configItem.style?.top) {
999
993
  pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
1000
994
  }
1001
- const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
995
+ const pasteConfig = await propsService.setNewItemId(configItem);
1002
996
  if (pasteConfig.style) {
1003
997
  const { left, top } = pasteConfig.style;
1004
998
  if (typeof left === "number" || !!left && !isNaN(Number(left))) {
@@ -1030,10 +1024,10 @@ const getPositionInContainer = (position = {}, id) => {
1030
1024
  top
1031
1025
  };
1032
1026
  };
1033
- const getAddParent = (addNode) => {
1027
+ const getAddParent = (node) => {
1034
1028
  const curNode = editorService.get("node");
1035
1029
  let parentNode;
1036
- if (!Array.isArray(addNode) && isPage(addNode)) {
1030
+ if (isPage(node)) {
1037
1031
  parentNode = editorService.get("root");
1038
1032
  } else if (curNode.items) {
1039
1033
  parentNode = curNode;
@@ -1069,6 +1063,7 @@ class Editor$1 extends BaseService {
1069
1063
  "sort",
1070
1064
  "copy",
1071
1065
  "paste",
1066
+ "doPaste",
1072
1067
  "duAlignCenter",
1073
1068
  "alignCenter",
1074
1069
  "moveLayer",
@@ -1205,20 +1200,27 @@ class Editor$1 extends BaseService {
1205
1200
  if ((parent?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && node.type !== NodeType.PAGE) {
1206
1201
  throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
1207
1202
  }
1203
+ if (parent.id !== curNode.id) {
1204
+ const index = parent.items.indexOf(curNode);
1205
+ parent?.items?.splice(index + 1, 0, node);
1206
+ } else {
1207
+ parent?.items?.push(node);
1208
+ }
1208
1209
  const layout = await this.getLayout(toRaw(parent), node);
1209
1210
  node.style = getInitPositionStyle(node.style, layout);
1210
- await stage?.add({ config: cloneDeep(node), parent: cloneDeep(parent), root: cloneDeep(root) });
1211
+ await stage?.add({
1212
+ config: cloneDeep(node),
1213
+ parent: cloneDeep(parent),
1214
+ parentId: parent.id,
1215
+ root: cloneDeep(root)
1216
+ });
1211
1217
  node.style = fixNodePosition(node, parent, stage);
1212
- await stage?.update({ config: cloneDeep(node), root: cloneDeep(root) });
1213
- parent?.items?.push(node);
1218
+ await stage?.update({ config: cloneDeep(node), parentId: parent.id, root: cloneDeep(root) });
1214
1219
  this.addModifiedNodeId(node.id);
1215
1220
  return node;
1216
1221
  }
1217
1222
  async add(addNode, parent) {
1218
1223
  const stage = this.get("stage");
1219
- const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(addNode);
1220
- if (!parentNode)
1221
- throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1222
1224
  const addNodes = [];
1223
1225
  if (!Array.isArray(addNode)) {
1224
1226
  const { type, inputEvent, ...config } = addNode;
@@ -1228,7 +1230,12 @@ class Editor$1 extends BaseService {
1228
1230
  } else {
1229
1231
  addNodes.push(...addNode);
1230
1232
  }
1231
- const newNodes = await Promise.all(addNodes.map((node) => this.doAdd(node, parentNode)));
1233
+ const newNodes = await Promise.all(addNodes.map((node) => {
1234
+ const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
1235
+ if (!parentNode)
1236
+ throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1237
+ return this.doAdd(node, parentNode);
1238
+ }));
1232
1239
  if (newNodes.length > 1) {
1233
1240
  const newNodeIds = newNodes.map((node) => node.id);
1234
1241
  stage?.multiSelect(newNodeIds);
@@ -1243,7 +1250,7 @@ class Editor$1 extends BaseService {
1243
1250
  }
1244
1251
  this.pushHistoryState();
1245
1252
  this.emit("add", newNodes);
1246
- return newNodes.length > 1 ? newNodes[0] : newNodes;
1253
+ return Array.isArray(addNode) ? newNodes : newNodes[0];
1247
1254
  }
1248
1255
  async doRemove(node) {
1249
1256
  const root = this.get("root");
@@ -1257,14 +1264,14 @@ class Editor$1 extends BaseService {
1257
1264
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1258
1265
  parent.items?.splice(index, 1);
1259
1266
  const stage = this.get("stage");
1260
- stage?.remove({ id: node.id, root: this.get("root") });
1267
+ stage?.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
1261
1268
  if (node.type === NodeType.PAGE) {
1262
1269
  this.state.pageLength -= 1;
1263
1270
  if (root.items[0]) {
1264
1271
  await this.select(root.items[0]);
1265
1272
  stage?.select(root.items[0].id);
1266
1273
  } else {
1267
- this.set("node", null);
1274
+ this.set("nodes", [root]);
1268
1275
  this.set("parent", null);
1269
1276
  this.set("page", null);
1270
1277
  this.set("stage", null);
@@ -1283,7 +1290,7 @@ class Editor$1 extends BaseService {
1283
1290
  const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
1284
1291
  await Promise.all(nodes.map((node) => this.doRemove(node)));
1285
1292
  this.pushHistoryState();
1286
- this.emit("remove");
1293
+ this.emit("remove", nodes);
1287
1294
  }
1288
1295
  async doUpdate(config) {
1289
1296
  if (!config?.id)
@@ -1321,7 +1328,11 @@ class Editor$1 extends BaseService {
1321
1328
  const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
1322
1329
  nodes.splice(targetIndex, 1, newConfig);
1323
1330
  this.set("nodes", nodes);
1324
- this.get("stage")?.update({ config: cloneDeep(newConfig), root: cloneDeep(this.get("root")) });
1331
+ this.get("stage")?.update({
1332
+ config: cloneDeep(newConfig),
1333
+ parentId: parent.id,
1334
+ root: cloneDeep(this.get("root"))
1335
+ });
1325
1336
  if (newConfig.type === NodeType.PAGE) {
1326
1337
  this.set("page", newConfig);
1327
1338
  }
@@ -1333,7 +1344,7 @@ class Editor$1 extends BaseService {
1333
1344
  const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
1334
1345
  this.pushHistoryState();
1335
1346
  this.emit("update", newNodes);
1336
- return newNodes.length > 1 ? newNodes[0] : newNodes;
1347
+ return Array.isArray(config) ? newNodes : newNodes[0];
1337
1348
  }
1338
1349
  async sort(id1, id2) {
1339
1350
  const node = this.get("node");
@@ -1345,7 +1356,11 @@ class Editor$1 extends BaseService {
1345
1356
  parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
1346
1357
  await this.update(parent);
1347
1358
  await this.select(node);
1348
- this.get("stage")?.update({ config: cloneDeep(node), root: cloneDeep(this.get("root")) });
1359
+ this.get("stage")?.update({
1360
+ config: cloneDeep(node),
1361
+ parentId: parent.id,
1362
+ root: cloneDeep(this.get("root"))
1363
+ });
1349
1364
  this.addModifiedNodeId(parent.id);
1350
1365
  this.pushHistoryState();
1351
1366
  }
@@ -1358,9 +1373,13 @@ class Editor$1 extends BaseService {
1358
1373
  const config = await storageService.getItem(COPY_STORAGE_KEY);
1359
1374
  if (!Array.isArray(config))
1360
1375
  return;
1361
- const pasteConfigs = await beforePaste(position, config);
1376
+ const pasteConfigs = await this.doPaste(config, position);
1362
1377
  return this.add(pasteConfigs);
1363
1378
  }
1379
+ async doPaste(config, position = {}) {
1380
+ const pasteConfigs = await beforePaste(position, cloneDeep(config));
1381
+ return pasteConfigs;
1382
+ }
1364
1383
  async doAlignCenter(config) {
1365
1384
  const parent = this.getParentById(config.id);
1366
1385
  if (!parent)
@@ -1405,10 +1424,14 @@ class Editor$1 extends BaseService {
1405
1424
  } else {
1406
1425
  brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
1407
1426
  }
1427
+ const grandparent = this.getParentById(parent.id);
1408
1428
  this.get("stage")?.update({
1409
1429
  config: cloneDeep(toRaw(parent)),
1430
+ parentId: grandparent?.id,
1410
1431
  root: cloneDeep(this.get("root"))
1411
1432
  });
1433
+ this.addModifiedNodeId(parent.id);
1434
+ this.pushHistoryState();
1412
1435
  }
1413
1436
  async moveToContainer(config, targetId) {
1414
1437
  const { node, parent } = this.getNodeInfo(config.id, false);
@@ -1418,7 +1441,7 @@ class Editor$1 extends BaseService {
1418
1441
  const root = cloneDeep(this.get("root"));
1419
1442
  const index = getNodeIndex(node, parent);
1420
1443
  parent.items?.splice(index, 1);
1421
- await stage.remove({ id: node.id, root });
1444
+ await stage.remove({ id: node.id, parentId: parent.id, root });
1422
1445
  const layout = await this.getLayout(target);
1423
1446
  const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
1424
1447
  if (Array.isArray(srcValue)) {
@@ -1428,7 +1451,8 @@ class Editor$1 extends BaseService {
1428
1451
  newConfig.style = getInitPositionStyle(newConfig.style, layout);
1429
1452
  target.items.push(newConfig);
1430
1453
  await stage.select(targetId);
1431
- await stage.update({ config: cloneDeep(target), root });
1454
+ const targetParent = this.getParentById(target.id);
1455
+ await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root });
1432
1456
  await this.select(newConfig);
1433
1457
  stage.select(newConfig.id);
1434
1458
  this.addModifiedNodeId(target.id);
@@ -1475,6 +1499,10 @@ class Editor$1 extends BaseService {
1475
1499
  this.set("nodes", []);
1476
1500
  this.set("page", null);
1477
1501
  this.set("parent", null);
1502
+ this.set("stage", null);
1503
+ this.set("highlightNode", null);
1504
+ this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
1505
+ this.set("pageLength", /* @__PURE__ */ new Map());
1478
1506
  }
1479
1507
  resetModifiedNodeId() {
1480
1508
  this.get("modifiedNodeIds").clear();
@@ -1544,8 +1572,8 @@ class Editor$1 extends BaseService {
1544
1572
  }
1545
1573
  const editorService = new Editor$1();
1546
1574
 
1547
- const eventMap = reactive({});
1548
- const methodMap = reactive({});
1575
+ let eventMap = reactive({});
1576
+ let methodMap = reactive({});
1549
1577
  class Events extends BaseService {
1550
1578
  constructor() {
1551
1579
  super([]);
@@ -1585,6 +1613,11 @@ class Events extends BaseService {
1585
1613
  getMethod(type) {
1586
1614
  return cloneDeep(methodMap[type] || DEFAULT_METHODS);
1587
1615
  }
1616
+ destroy() {
1617
+ eventMap = reactive({});
1618
+ methodMap = reactive({});
1619
+ this.removeAllListeners();
1620
+ }
1588
1621
  }
1589
1622
  const eventsService = new Events();
1590
1623
 
@@ -1791,7 +1824,6 @@ const fillConfig = (config = []) => [
1791
1824
  ]
1792
1825
  }
1793
1826
  ];
1794
- const DEFAULT_CONFIG = fillConfig([]);
1795
1827
 
1796
1828
  const log = (...args) => {
1797
1829
  if (process.env.NODE_ENV === "development") {
@@ -1819,7 +1851,195 @@ const error = (...args) => {
1819
1851
  }
1820
1852
  };
1821
1853
 
1822
- const _sfc_main$j = defineComponent({
1854
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
1855
+ const MIN_LEFT_COLUMN_WIDTH = 45;
1856
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
1857
+ const MIN_RIGHT_COLUMN_WIDTH = 1;
1858
+ const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
1859
+ const defaultColumnWidth = {
1860
+ left: DEFAULT_LEFT_COLUMN_WIDTH,
1861
+ center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
1862
+ right: DEFAULT_RIGHT_COLUMN_WIDTH
1863
+ };
1864
+ const state = reactive({
1865
+ uiSelectMode: false,
1866
+ showSrc: false,
1867
+ zoom: 1,
1868
+ stageContainerRect: {
1869
+ width: 0,
1870
+ height: 0
1871
+ },
1872
+ stageRect: {
1873
+ width: 375,
1874
+ height: 817
1875
+ },
1876
+ columnWidth: defaultColumnWidth,
1877
+ showGuides: true,
1878
+ showRule: true,
1879
+ propsPanelSize: "small",
1880
+ showAddPageButton: true
1881
+ });
1882
+ class Ui extends BaseService {
1883
+ constructor() {
1884
+ super([]);
1885
+ globalThis.addEventListener("resize", () => {
1886
+ this.setColumnWidth({
1887
+ center: "auto"
1888
+ });
1889
+ });
1890
+ }
1891
+ set(name, value) {
1892
+ const mask = editorService.get("stage")?.mask;
1893
+ if (name === "columnWidth") {
1894
+ this.setColumnWidth(value);
1895
+ return;
1896
+ }
1897
+ if (name === "stageRect") {
1898
+ this.setStageRect(value);
1899
+ return;
1900
+ }
1901
+ if (name === "showGuides") {
1902
+ mask?.showGuides(value);
1903
+ }
1904
+ if (name === "showRule") {
1905
+ mask?.showRule(value);
1906
+ }
1907
+ state[name] = value;
1908
+ }
1909
+ get(name) {
1910
+ return state[name];
1911
+ }
1912
+ initColumnWidth() {
1913
+ const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
1914
+ if (columnWidthCacheData) {
1915
+ try {
1916
+ const columnWidthCache = JSON.parse(columnWidthCacheData);
1917
+ this.setColumnWidth(columnWidthCache);
1918
+ } catch (e) {
1919
+ console.error(e);
1920
+ }
1921
+ }
1922
+ }
1923
+ zoom(zoom) {
1924
+ this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
1925
+ if (this.get("zoom") < 0.1)
1926
+ this.set("zoom", 0.1);
1927
+ }
1928
+ calcZoom() {
1929
+ const { stageRect, stageContainerRect } = state;
1930
+ const { height, width } = stageContainerRect;
1931
+ if (!width || !height)
1932
+ return 1;
1933
+ const stageWidth = stageRect.width + 30;
1934
+ const stageHeight = stageRect.height + 30;
1935
+ if (width > stageWidth && height > stageHeight) {
1936
+ return 1;
1937
+ }
1938
+ return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
1939
+ }
1940
+ destroy() {
1941
+ this.removeAllListeners();
1942
+ }
1943
+ setColumnWidth({ left, center, right }) {
1944
+ const columnWidth = {
1945
+ ...toRaw(this.get("columnWidth"))
1946
+ };
1947
+ if (left) {
1948
+ columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
1949
+ }
1950
+ if (right) {
1951
+ columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
1952
+ }
1953
+ if (!center || center === "auto") {
1954
+ const bodyWidth = globalThis.document.body.clientWidth;
1955
+ columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
1956
+ if (columnWidth.center <= 0) {
1957
+ columnWidth.left = defaultColumnWidth.left;
1958
+ columnWidth.center = defaultColumnWidth.center;
1959
+ columnWidth.right = defaultColumnWidth.right;
1960
+ }
1961
+ } else {
1962
+ columnWidth.center = center;
1963
+ }
1964
+ globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
1965
+ state.columnWidth = columnWidth;
1966
+ }
1967
+ setStageRect(value) {
1968
+ state.stageRect = {
1969
+ ...state.stageRect,
1970
+ ...value
1971
+ };
1972
+ state.zoom = this.calcZoom();
1973
+ }
1974
+ }
1975
+ const uiService = new Ui();
1976
+
1977
+ const root = computed(() => editorService.get("root"));
1978
+ const page = computed(() => editorService.get("page"));
1979
+ const zoom = computed(() => uiService.get("zoom") || 1);
1980
+ const uiSelectMode = computed(() => uiService.get("uiSelectMode"));
1981
+ const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
1982
+ const useStage = (stageOptions) => {
1983
+ const stage = new StageCore({
1984
+ render: stageOptions.render,
1985
+ runtimeUrl: stageOptions.runtimeUrl,
1986
+ zoom: zoom.value,
1987
+ autoScrollIntoView: stageOptions.autoScrollIntoView,
1988
+ isContainer: stageOptions.isContainer,
1989
+ containerHighlightClassName: stageOptions.containerHighlightClassName,
1990
+ containerHighlightDuration: stageOptions.containerHighlightDuration,
1991
+ containerHighlightType: stageOptions.containerHighlightType,
1992
+ canSelect: (el, event, stop) => {
1993
+ const elCanSelect = stageOptions.canSelect(el);
1994
+ if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
1995
+ document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
1996
+ return stop();
1997
+ }
1998
+ return elCanSelect;
1999
+ },
2000
+ moveableOptions: stageOptions.moveableOptions,
2001
+ updateDragEl: stageOptions.updateDragEl
2002
+ });
2003
+ stage.mask.setGuides([
2004
+ getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
2005
+ getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
2006
+ ]);
2007
+ stage.on("select", (el) => {
2008
+ editorService.select(el.id);
2009
+ });
2010
+ stage.on("highlight", (el) => {
2011
+ editorService.highlight(el.id);
2012
+ });
2013
+ stage.on("multiSelect", (els) => {
2014
+ editorService.multiSelect(els.map((el) => el.id));
2015
+ });
2016
+ stage.on("update", (ev) => {
2017
+ if (ev.parentEl) {
2018
+ for (const data of ev.data) {
2019
+ editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
2020
+ }
2021
+ return;
2022
+ }
2023
+ editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
2024
+ });
2025
+ stage.on("sort", (ev) => {
2026
+ editorService.sort(ev.src, ev.dist);
2027
+ });
2028
+ stage.on("changeGuides", (e) => {
2029
+ uiService.set("showGuides", true);
2030
+ if (!root.value || !page.value)
2031
+ return;
2032
+ const storageKey = getGuideLineKey(e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
2033
+ if (e.guides.length) {
2034
+ globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
2035
+ } else {
2036
+ globalThis.localStorage.removeItem(storageKey);
2037
+ }
2038
+ });
2039
+ return stage;
2040
+ };
2041
+
2042
+ const _sfc_main$k = defineComponent({
1823
2043
  components: { Plus },
1824
2044
  setup() {
1825
2045
  const services = inject("services");
@@ -1837,13 +2057,13 @@ const _sfc_main$j = defineComponent({
1837
2057
  }
1838
2058
  });
1839
2059
 
1840
- const _hoisted_1$b = { class: "m-editor-empty-panel" };
2060
+ const _hoisted_1$a = { class: "m-editor-empty-panel" };
1841
2061
  const _hoisted_2$4 = { class: "m-editor-empty-content" };
1842
- const _hoisted_3$1 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1843
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2062
+ const _hoisted_3 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2063
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
1844
2064
  const _component_plus = resolveComponent("plus");
1845
2065
  const _component_el_icon = resolveComponent("el-icon");
1846
- return openBlock(), createElementBlock("div", _hoisted_1$b, [
2066
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
1847
2067
  createElementVNode("div", _hoisted_2$4, [
1848
2068
  createElementVNode("div", {
1849
2069
  class: "m-editor-empty-button",
@@ -1857,14 +2077,14 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1857
2077
  _: 1
1858
2078
  })
1859
2079
  ]),
1860
- _hoisted_3$1
2080
+ _hoisted_3
1861
2081
  ])
1862
2082
  ])
1863
2083
  ]);
1864
2084
  }
1865
- const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
2085
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$7]]);
1866
2086
 
1867
- const _sfc_main$i = defineComponent({
2087
+ const _sfc_main$j = defineComponent({
1868
2088
  name: "m-editor-resize",
1869
2089
  props: {
1870
2090
  type: {
@@ -1907,18 +2127,18 @@ const _sfc_main$i = defineComponent({
1907
2127
  }
1908
2128
  });
1909
2129
 
1910
- const _hoisted_1$a = {
2130
+ const _hoisted_1$9 = {
1911
2131
  ref: "target",
1912
2132
  class: "m-editor-resizer"
1913
2133
  };
1914
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1915
- return openBlock(), createElementBlock("span", _hoisted_1$a, [
2134
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2135
+ return openBlock(), createElementBlock("span", _hoisted_1$9, [
1916
2136
  renderSlot(_ctx.$slots, "default")
1917
2137
  ], 512);
1918
2138
  }
1919
- const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
2139
+ const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$6]]);
1920
2140
 
1921
- const _sfc_main$h = defineComponent({
2141
+ const _sfc_main$i = defineComponent({
1922
2142
  components: {
1923
2143
  AddPageBox,
1924
2144
  Resizer
@@ -1948,17 +2168,17 @@ const _sfc_main$h = defineComponent({
1948
2168
  }
1949
2169
  });
1950
2170
 
1951
- const _hoisted_1$9 = { class: "m-editor" };
2171
+ const _hoisted_1$8 = { class: "m-editor" };
1952
2172
  const _hoisted_2$3 = {
1953
2173
  key: 1,
1954
2174
  class: "m-editor-content"
1955
2175
  };
1956
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2176
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
1957
2177
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
1958
2178
  const _component_resizer = resolveComponent("resizer");
1959
2179
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
1960
2180
  const _component_add_page_box = resolveComponent("add-page-box");
1961
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
2181
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
1962
2182
  renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
1963
2183
  _ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
1964
2184
  key: 0,
@@ -1999,211 +2219,121 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
1999
2219
  ]))
2000
2220
  ]);
2001
2221
  }
2002
- const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
2222
+ const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$5]]);
2003
2223
 
2004
- const _sfc_main$g = defineComponent({
2005
- name: "m-icon",
2006
- components: { Edit },
2224
+ const _hoisted_1$7 = ["src"];
2225
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
2226
+ __name: "Icon",
2007
2227
  props: {
2008
- icon: {
2009
- type: [String, Object]
2010
- }
2228
+ icon: null
2011
2229
  },
2012
- setup() {
2013
- return {
2014
- toRaw
2230
+ setup(__props) {
2231
+ return (_ctx, _cache) => {
2232
+ const _component_el_icon = resolveComponent("el-icon");
2233
+ return !__props.icon ? (openBlock(), createBlock(_component_el_icon, {
2234
+ key: 0,
2235
+ class: "magic-editor-icon"
2236
+ }, {
2237
+ default: withCtx(() => [
2238
+ createVNode(unref(Edit))
2239
+ ]),
2240
+ _: 1
2241
+ })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, {
2242
+ key: 1,
2243
+ class: "magic-editor-icon"
2244
+ }, {
2245
+ default: withCtx(() => [
2246
+ createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$7)
2247
+ ]),
2248
+ _: 1
2249
+ })) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
2250
+ key: 2,
2251
+ class: normalizeClass(["magic-editor-icon", __props.icon])
2252
+ }, null, 2)) : (openBlock(), createBlock(_component_el_icon, {
2253
+ key: 3,
2254
+ class: "magic-editor-icon"
2255
+ }, {
2256
+ default: withCtx(() => [
2257
+ (openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
2258
+ ]),
2259
+ _: 1
2260
+ }));
2015
2261
  };
2016
2262
  }
2017
2263
  });
2018
2264
 
2019
- const _hoisted_1$8 = ["src"];
2020
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2021
- const _component_edit = resolveComponent("edit");
2022
- const _component_el_icon = resolveComponent("el-icon");
2023
- return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
2024
- default: withCtx(() => [
2025
- createVNode(_component_edit)
2026
- ]),
2027
- _: 1
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", {
2034
- key: 2,
2035
- class: normalizeClass(_ctx.icon)
2036
- }, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
2037
- default: withCtx(() => [
2038
- (openBlock(), createBlock(resolveDynamicComponent(_ctx.toRaw(_ctx.icon))))
2039
- ]),
2040
- _: 1
2041
- }));
2042
- }
2043
- const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
2044
-
2045
- const _hoisted_1$7 = {
2265
+ const _hoisted_1$6 = {
2046
2266
  key: 1,
2047
2267
  class: "menu-item-text"
2048
2268
  };
2049
- const _hoisted_2$2 = {
2050
- class: "menu-item-text",
2051
- style: { "margin": "0 5px" }
2052
- };
2053
- const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
2054
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
2269
+ const _hoisted_2$2 = { class: "el-dropdown-link menubar-menu-button" };
2270
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2055
2271
  __name: "ToolButton",
2056
2272
  props: {
2057
- data: {
2058
- type: [Object, String],
2059
- require: true,
2060
- default: () => ({
2061
- type: "text",
2062
- display: false
2063
- })
2064
- },
2065
- eventType: {
2066
- type: String,
2067
- default: "click"
2068
- }
2273
+ data: { default: () => ({
2274
+ type: "text",
2275
+ display: false
2276
+ }) },
2277
+ eventType: { default: "click" }
2069
2278
  },
2070
2279
  setup(__props) {
2071
2280
  const props = __props;
2072
2281
  const services = inject("services");
2073
- const uiService = services?.uiService;
2074
- const zoom = computed(() => uiService?.get("zoom") ?? 1);
2075
- const showGuides = computed(() => uiService?.get("showGuides") ?? true);
2076
- const showRule = computed(() => uiService?.get("showRule") ?? true);
2077
- const zoomInHandler = () => uiService?.zoom(0.1);
2078
- const zoomOutHandler = () => uiService?.zoom(-0.1);
2079
- const item = computed(() => {
2080
- if (typeof props.data !== "string") {
2081
- return props.data;
2082
- }
2083
- switch (props.data) {
2084
- case "/":
2085
- return {
2086
- type: "divider"
2087
- };
2088
- case "zoom":
2089
- return {
2090
- type: "zoom"
2091
- };
2092
- case "delete":
2093
- return {
2094
- type: "button",
2095
- icon: markRaw(Delete),
2096
- tooltip: "\u522A\u9664",
2097
- disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
2098
- handler: () => services?.editorService.remove(services?.editorService.get("node"))
2099
- };
2100
- case "undo":
2101
- return {
2102
- type: "button",
2103
- icon: markRaw(Back),
2104
- tooltip: "\u540E\u9000",
2105
- disabled: () => !services?.historyService.state.canUndo,
2106
- handler: () => services?.editorService.undo()
2107
- };
2108
- case "redo":
2109
- return {
2110
- type: "button",
2111
- icon: markRaw(Right),
2112
- tooltip: "\u524D\u8FDB",
2113
- disabled: () => !services?.historyService.state.canRedo,
2114
- handler: () => services?.editorService.redo()
2115
- };
2116
- case "zoom-in":
2117
- return {
2118
- type: "button",
2119
- icon: markRaw(ZoomIn),
2120
- tooltip: "\u653E\u5927",
2121
- handler: zoomInHandler
2122
- };
2123
- case "zoom-out":
2124
- return {
2125
- type: "button",
2126
- icon: markRaw(ZoomOut),
2127
- tooltip: "\u7E2E\u5C0F",
2128
- handler: zoomOutHandler
2129
- };
2130
- case "rule":
2131
- return {
2132
- type: "button",
2133
- icon: markRaw(ScaleToOriginal),
2134
- tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2135
- handler: () => uiService?.set("showRule", !showRule.value)
2136
- };
2137
- case "guides":
2138
- return {
2139
- type: "button",
2140
- icon: markRaw(Grid),
2141
- tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2142
- handler: () => uiService?.set("showGuides", !showGuides.value)
2143
- };
2144
- default:
2145
- return {
2146
- type: "text",
2147
- text: props.data
2148
- };
2282
+ const disabled = computed(() => {
2283
+ if (typeof props.data === "string")
2284
+ return false;
2285
+ if (props.data.type === "component")
2286
+ return false;
2287
+ if (typeof props.data.disabled === "function") {
2288
+ return props.data.disabled(services);
2149
2289
  }
2290
+ return props.data.disabled;
2150
2291
  });
2151
- const disabled = computed(() => {
2152
- if (typeof item.value === "string")
2153
- return false;
2154
- if (item.value.type === "component")
2292
+ const display = computed(() => {
2293
+ if (!props.data)
2155
2294
  return false;
2156
- if (typeof item.value.disabled === "function") {
2157
- return item.value.disabled(services);
2295
+ if (typeof props.data === "string")
2296
+ return true;
2297
+ if (typeof props.data.display === "function") {
2298
+ return props.data.display(services);
2158
2299
  }
2159
- return item.value.disabled;
2300
+ return props.data.display ?? true;
2160
2301
  });
2161
- const buttonHandler = (item2, event) => {
2302
+ const buttonHandler = (item, event) => {
2162
2303
  if (disabled.value)
2163
2304
  return;
2164
- if (typeof item2.handler === "function" && services) {
2165
- item2.handler?.(services, event);
2305
+ if (typeof item.handler === "function" && services) {
2306
+ item.handler?.(services, event);
2166
2307
  }
2167
2308
  };
2168
- const display = computed(() => {
2169
- if (!item.value)
2170
- return false;
2171
- if (typeof item.value === "string")
2172
- return true;
2173
- if (typeof item.value.display === "function") {
2174
- return item.value.display(services);
2175
- }
2176
- return item.value.display ?? true;
2177
- });
2178
2309
  const dropdownHandler = (command) => {
2179
2310
  if (command.item.handler) {
2180
2311
  command.item.handler(services);
2181
2312
  }
2182
2313
  };
2183
- const clickHandler = (item2, event) => {
2314
+ const clickHandler = (item, event) => {
2184
2315
  if (props.eventType !== "click")
2185
2316
  return;
2186
- if (item2.type === "button") {
2187
- buttonHandler(item2, event);
2317
+ if (item.type === "button") {
2318
+ buttonHandler(item, event);
2188
2319
  }
2189
2320
  };
2190
- const mousedownHandler = (item2, event) => {
2321
+ const mousedownHandler = (item, event) => {
2191
2322
  if (props.eventType !== "mousedown")
2192
2323
  return;
2193
- if (item2.type === "button") {
2194
- buttonHandler(item2, event);
2324
+ if (item.type === "button") {
2325
+ buttonHandler(item, event);
2195
2326
  }
2196
2327
  };
2197
- const mouseupHandler = (item2, event) => {
2328
+ const mouseupHandler = (item, event) => {
2198
2329
  if (props.eventType !== "mouseup")
2199
2330
  return;
2200
- if (item2.type === "button") {
2201
- buttonHandler(item2, event);
2331
+ if (item.type === "button") {
2332
+ buttonHandler(item, event);
2202
2333
  }
2203
2334
  };
2204
2335
  return (_ctx, _cache) => {
2205
2336
  const _component_el_divider = resolveComponent("el-divider");
2206
- const _component_tool_button = resolveComponent("tool-button", true);
2207
2337
  const _component_el_button = resolveComponent("el-button");
2208
2338
  const _component_el_tooltip = resolveComponent("el-tooltip");
2209
2339
  const _component_el_icon = resolveComponent("el-icon");
@@ -2212,30 +2342,20 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2212
2342
  const _component_el_dropdown = resolveComponent("el-dropdown");
2213
2343
  return unref(display) ? (openBlock(), createElementBlock("div", {
2214
2344
  key: 0,
2215
- class: normalizeClass(["menu-item", unref(item).type]),
2216
- onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(item), $event)),
2217
- onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(unref(item), $event)),
2218
- onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(unref(item), $event))
2345
+ class: normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
2346
+ onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(__props.data, $event)),
2347
+ onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
2348
+ onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
2219
2349
  }, [
2220
- unref(item).type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2350
+ __props.data.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2221
2351
  key: 0,
2222
- direction: unref(item).direction || "vertical"
2223
- }, null, 8, ["direction"])) : unref(item).type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$7, toDisplayString(unref(item).text), 1)) : unref(item).type === "zoom" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2224
- createVNode(_component_tool_button, {
2225
- data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2226
- "event-type": __props.eventType
2227
- }, null, 8, ["data", "event-type"]),
2228
- createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
2229
- createVNode(_component_tool_button, {
2230
- data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
2231
- "event-type": __props.eventType
2232
- }, null, 8, ["data", "event-type"])
2233
- ], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
2234
- unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
2352
+ direction: __props.data.direction || "vertical"
2353
+ }, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$6, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2354
+ __props.data.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
2235
2355
  key: 0,
2236
2356
  effect: "dark",
2237
2357
  placement: "bottom-start",
2238
- content: unref(item).tooltip
2358
+ content: __props.data.tooltip
2239
2359
  }, {
2240
2360
  default: withCtx(() => [
2241
2361
  createVNode(_component_el_button, {
@@ -2244,11 +2364,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2244
2364
  disabled: unref(disabled)
2245
2365
  }, {
2246
2366
  default: withCtx(() => [
2247
- unref(item).icon ? (openBlock(), createBlock(MIcon, {
2367
+ __props.data.icon ? (openBlock(), createBlock(_sfc_main$h, {
2248
2368
  key: 0,
2249
- icon: unref(item).icon
2369
+ icon: __props.data.icon
2250
2370
  }, null, 8, ["icon"])) : createCommentVNode("", true),
2251
- createElementVNode("span", null, toDisplayString(unref(item).text), 1)
2371
+ createElementVNode("span", null, toDisplayString(__props.data.text), 1)
2252
2372
  ]),
2253
2373
  _: 1
2254
2374
  }, 8, ["disabled"])
@@ -2261,27 +2381,27 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2261
2381
  disabled: unref(disabled)
2262
2382
  }, {
2263
2383
  default: withCtx(() => [
2264
- unref(item).icon ? (openBlock(), createBlock(MIcon, {
2384
+ __props.data.icon ? (openBlock(), createBlock(_sfc_main$h, {
2265
2385
  key: 0,
2266
- icon: unref(item).icon
2386
+ icon: __props.data.icon
2267
2387
  }, null, 8, ["icon"])) : createCommentVNode("", true),
2268
- createElementVNode("span", null, toDisplayString(unref(item).text), 1)
2388
+ createElementVNode("span", null, toDisplayString(__props.data.text), 1)
2269
2389
  ]),
2270
2390
  _: 1
2271
2391
  }, 8, ["disabled"]))
2272
- ], 64)) : unref(item).type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
2273
- key: 4,
2392
+ ], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
2393
+ key: 3,
2274
2394
  trigger: "click",
2275
2395
  disabled: unref(disabled),
2276
2396
  onCommand: dropdownHandler
2277
2397
  }, {
2278
2398
  dropdown: withCtx(() => [
2279
- unref(item).items && unref(item).items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
2399
+ __props.data.items && __props.data.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
2280
2400
  default: withCtx(() => [
2281
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(item).items, (subItem, index) => {
2401
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data.items, (subItem, index) => {
2282
2402
  return openBlock(), createBlock(_component_el_dropdown_item, {
2283
2403
  key: index,
2284
- command: { item: unref(item), subItem }
2404
+ command: { data: __props.data, subItem }
2285
2405
  }, {
2286
2406
  default: withCtx(() => [
2287
2407
  createTextVNode(toDisplayString(subItem.text), 1)
@@ -2294,8 +2414,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2294
2414
  })) : createCommentVNode("", true)
2295
2415
  ]),
2296
2416
  default: withCtx(() => [
2297
- createElementVNode("span", _hoisted_3, [
2298
- createTextVNode(toDisplayString(unref(item).text), 1),
2417
+ createElementVNode("span", _hoisted_2$2, [
2418
+ createTextVNode(toDisplayString(__props.data.text), 1),
2299
2419
  createVNode(_component_el_icon, { class: "el-icon--right" }, {
2300
2420
  default: withCtx(() => [
2301
2421
  createVNode(unref(ArrowDown))
@@ -2305,67 +2425,187 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2305
2425
  ])
2306
2426
  ]),
2307
2427
  _: 1
2308
- }, 8, ["disabled"])) : unref(item).type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(unref(item).component), normalizeProps(mergeProps({ key: 5 }, unref(item).props || {})), null, 16)) : createCommentVNode("", true)
2428
+ }, 8, ["disabled"])) : __props.data.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(__props.data.component), normalizeProps(mergeProps({ key: 4 }, __props.data.props || {})), null, 16)) : createCommentVNode("", true)
2309
2429
  ], 34)) : createCommentVNode("", true);
2310
2430
  };
2311
2431
  }
2312
2432
  });
2313
2433
 
2314
- const _sfc_main$e = defineComponent({
2315
- name: "nav-menu",
2316
- components: { ToolButton: _sfc_main$f },
2434
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2435
+ __name: "NavMenu",
2317
2436
  props: {
2318
- data: {
2319
- type: Object,
2320
- default: () => ({})
2321
- },
2322
- height: {
2323
- type: Number
2324
- }
2437
+ data: { default: () => ({}) },
2438
+ height: { default: 35 }
2325
2439
  },
2326
- setup(props) {
2440
+ setup(__props) {
2441
+ const props = __props;
2327
2442
  const services = inject("services");
2328
- return {
2329
- keys: computed(() => Object.keys(props.data)),
2330
- columnWidth: computed(() => services?.uiService.get("columnWidth"))
2443
+ const uiService = services?.uiService;
2444
+ const columnWidth = computed(() => services?.uiService.get("columnWidth"));
2445
+ const keys = Object.values(ColumnLayout);
2446
+ const showGuides = computed(() => uiService?.get("showGuides") ?? true);
2447
+ const showRule = computed(() => uiService?.get("showRule") ?? true);
2448
+ const zoom = computed(() => uiService?.get("zoom") ?? 1);
2449
+ const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
2450
+ const ctrl = isMac ? "Command" : "Ctrl";
2451
+ const getConfig = (item) => {
2452
+ if (typeof item !== "string") {
2453
+ return [item];
2454
+ }
2455
+ const config = [];
2456
+ switch (item) {
2457
+ case "/":
2458
+ config.push({
2459
+ type: "divider",
2460
+ className: "divider"
2461
+ });
2462
+ break;
2463
+ case "zoom":
2464
+ config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
2465
+ break;
2466
+ case "delete":
2467
+ config.push({
2468
+ type: "button",
2469
+ className: "delete",
2470
+ icon: markRaw(Delete),
2471
+ tooltip: `\u522A\u9664(Delete)`,
2472
+ disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
2473
+ handler: () => services?.editorService.remove(services?.editorService.get("node"))
2474
+ });
2475
+ break;
2476
+ case "undo":
2477
+ config.push({
2478
+ type: "button",
2479
+ className: "undo",
2480
+ icon: markRaw(Back),
2481
+ tooltip: `\u540E\u9000(${ctrl}+z)`,
2482
+ disabled: () => !services?.historyService.state.canUndo,
2483
+ handler: () => services?.editorService.undo()
2484
+ });
2485
+ break;
2486
+ case "redo":
2487
+ config.push({
2488
+ type: "button",
2489
+ className: "redo",
2490
+ icon: markRaw(Right),
2491
+ tooltip: `\u524D\u8FDB(${ctrl}+Shift+z)`,
2492
+ disabled: () => !services?.historyService.state.canRedo,
2493
+ handler: () => services?.editorService.redo()
2494
+ });
2495
+ break;
2496
+ case "zoom-in":
2497
+ config.push({
2498
+ type: "button",
2499
+ className: "zoom-in",
2500
+ icon: markRaw(ZoomIn),
2501
+ tooltip: `\u653E\u5927(${ctrl}+=)`,
2502
+ handler: () => uiService?.zoom(0.1)
2503
+ });
2504
+ break;
2505
+ case "zoom-out":
2506
+ config.push({
2507
+ type: "button",
2508
+ className: "zoom-out",
2509
+ icon: markRaw(ZoomOut),
2510
+ tooltip: `\u7E2E\u5C0F(${ctrl}+-)`,
2511
+ handler: () => uiService?.zoom(-0.1)
2512
+ });
2513
+ break;
2514
+ case "scale-to-original":
2515
+ config.push({
2516
+ type: "button",
2517
+ className: "scale-to-original",
2518
+ icon: markRaw(ScaleToOriginal),
2519
+ tooltip: `\u7F29\u653E\u5230\u5B9E\u9645\u5927\u5C0F(${ctrl}+1)`,
2520
+ handler: () => uiService?.set("zoom", 1)
2521
+ });
2522
+ break;
2523
+ case "scale-to-fit":
2524
+ config.push({
2525
+ type: "button",
2526
+ className: "scale-to-fit",
2527
+ icon: markRaw(FullScreen),
2528
+ tooltip: `\u7F29\u653E\u4EE5\u9002\u5E94(${ctrl}+0)`,
2529
+ handler: () => uiService?.set("zoom", uiService.calcZoom())
2530
+ });
2531
+ break;
2532
+ case "rule":
2533
+ config.push({
2534
+ type: "button",
2535
+ className: "rule",
2536
+ icon: markRaw(Memo),
2537
+ tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2538
+ handler: () => uiService?.set("showRule", !showRule.value)
2539
+ });
2540
+ break;
2541
+ case "guides":
2542
+ config.push({
2543
+ type: "button",
2544
+ className: "guides",
2545
+ icon: markRaw(Grid),
2546
+ tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2547
+ handler: () => uiService?.set("showGuides", !showGuides.value)
2548
+ });
2549
+ break;
2550
+ default:
2551
+ config.push({
2552
+ type: "text",
2553
+ text: item
2554
+ });
2555
+ }
2556
+ return config;
2331
2557
  };
2332
- }
2333
- });
2334
-
2335
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2336
- const _component_tool_button = resolveComponent("tool-button");
2337
- return openBlock(), createElementBlock("div", {
2338
- class: "m-editor-nav-menu",
2339
- style: normalizeStyle({ height: `${_ctx.height}px` })
2340
- }, [
2341
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.keys, (key) => {
2558
+ const buttons = computed(() => {
2559
+ const data = {
2560
+ [ColumnLayout.LEFT]: [],
2561
+ [ColumnLayout.CENTER]: [],
2562
+ [ColumnLayout.RIGHT]: []
2563
+ };
2564
+ keys.forEach((key) => {
2565
+ const items = props.data[key] || [];
2566
+ items.forEach((item) => {
2567
+ data[key].push(...getConfig(item));
2568
+ });
2569
+ });
2570
+ return data;
2571
+ });
2572
+ return (_ctx, _cache) => {
2342
2573
  return openBlock(), createElementBlock("div", {
2343
- class: normalizeClass(`menu-${key}`),
2344
- key,
2345
- style: normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
2574
+ class: "m-editor-nav-menu",
2575
+ style: normalizeStyle({ height: `${__props.height}px` })
2346
2576
  }, [
2347
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data[key], (item, index) => {
2348
- return openBlock(), createBlock(_component_tool_button, {
2349
- data: item,
2350
- key: index
2351
- }, null, 8, ["data"]);
2577
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(keys), (key) => {
2578
+ return openBlock(), createElementBlock("div", {
2579
+ class: normalizeClass(`menu-${key}`),
2580
+ key,
2581
+ style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
2582
+ }, [
2583
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
2584
+ return openBlock(), createBlock(_sfc_main$g, {
2585
+ data: item,
2586
+ key: index
2587
+ }, null, 8, ["data"]);
2588
+ }), 128))
2589
+ ], 6);
2352
2590
  }), 128))
2353
- ], 6);
2354
- }), 128))
2355
- ], 4);
2356
- }
2357
- const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
2591
+ ], 4);
2592
+ };
2593
+ }
2594
+ });
2358
2595
 
2359
- const _sfc_main$d = defineComponent({
2360
- name: "m-editor-props-panel",
2596
+ const _hoisted_1$5 = { class: "`m-editor-props-panel" };
2597
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
2598
+ __name: "PropsPanel",
2361
2599
  emits: ["mounted"],
2362
- setup(props, { emit }) {
2600
+ setup(__props, { expose, emit }) {
2363
2601
  const internalInstance = getCurrentInstance();
2364
2602
  const values = ref({});
2365
2603
  const configForm = ref();
2366
2604
  const curFormConfig = ref([]);
2367
2605
  const services = inject("services");
2368
2606
  const node = computed(() => services?.editorService.get("node"));
2607
+ const propsPanelSize = computed(() => services?.uiService.get("propsPanelSize") || "small");
2608
+ const stage = computed(() => services?.editorService.get("stage"));
2369
2609
  const init = async () => {
2370
2610
  if (!node.value) {
2371
2611
  curFormConfig.value = [];
@@ -2380,52 +2620,51 @@ const _sfc_main$d = defineComponent({
2380
2620
  onMounted(() => {
2381
2621
  emit("mounted", internalInstance);
2382
2622
  });
2383
- return {
2384
- values,
2385
- configForm,
2386
- curFormConfig,
2387
- propsPanelSize: computed(() => services?.uiService.get("propsPanelSize") || "small"),
2388
- async submit() {
2389
- try {
2390
- const values2 = await configForm.value?.submitForm();
2391
- services?.editorService.update(values2);
2392
- } catch (e) {
2393
- console.error(e);
2394
- ElMessage.closeAll();
2395
- ElMessage.error({
2396
- duration: 1e4,
2397
- showClose: true,
2398
- message: e.message,
2399
- dangerouslyUseHTMLString: true
2400
- });
2401
- }
2623
+ watchEffect(() => {
2624
+ if (configForm.value && stage.value) {
2625
+ configForm.value.formState.stage = stage.value;
2626
+ }
2627
+ });
2628
+ const submit = async () => {
2629
+ try {
2630
+ const values2 = await configForm.value?.submitForm();
2631
+ services?.editorService.update(values2);
2632
+ } catch (e) {
2633
+ console.error(e);
2634
+ ElMessage.closeAll();
2635
+ ElMessage.error({
2636
+ duration: 1e4,
2637
+ showClose: true,
2638
+ message: e.message,
2639
+ dangerouslyUseHTMLString: true
2640
+ });
2402
2641
  }
2403
2642
  };
2643
+ expose({ submit });
2644
+ return (_ctx, _cache) => {
2645
+ const _component_m_form = resolveComponent("m-form");
2646
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [
2647
+ renderSlot(_ctx.$slots, "props-panel-header"),
2648
+ createVNode(_component_m_form, {
2649
+ ref_key: "configForm",
2650
+ ref: configForm,
2651
+ class: normalizeClass(`m-editor-props-panel ${unref(propsPanelSize)}`),
2652
+ "popper-class": `m-editor-props-panel-popper ${unref(propsPanelSize)}`,
2653
+ size: unref(propsPanelSize),
2654
+ "init-values": values.value,
2655
+ config: curFormConfig.value,
2656
+ onChange: submit
2657
+ }, null, 8, ["class", "popper-class", "size", "init-values", "config"])
2658
+ ]);
2659
+ };
2404
2660
  }
2405
2661
  });
2406
2662
 
2407
- const _hoisted_1$6 = { class: "`m-editor-props-panel" };
2408
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2409
- const _component_m_form = resolveComponent("m-form");
2410
- return openBlock(), createElementBlock("div", _hoisted_1$6, [
2411
- renderSlot(_ctx.$slots, "props-panel-header"),
2412
- createVNode(_component_m_form, {
2413
- class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
2414
- "popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
2415
- ref: "configForm",
2416
- size: _ctx.propsPanelSize,
2417
- "init-values": _ctx.values,
2418
- config: _ctx.curFormConfig,
2419
- onChange: _ctx.submit
2420
- }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
2421
- ]);
2422
- }
2423
- const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
2424
-
2425
- const _sfc_main$c = defineComponent({
2426
- name: "ui-component-panel",
2427
- components: { MIcon },
2428
- setup() {
2663
+ const _hoisted_1$4 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2664
+ const _hoisted_2$1 = ["onClick", "onDragstart"];
2665
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2666
+ __name: "ComponentListPanel",
2667
+ setup(__props) {
2429
2668
  const searchText = ref("");
2430
2669
  const services = inject("services");
2431
2670
  const stageOptions = inject("stageOptions");
@@ -2438,134 +2677,126 @@ const _sfc_main$c = defineComponent({
2438
2677
  let timeout;
2439
2678
  let clientX;
2440
2679
  let clientY;
2441
- return {
2442
- searchText,
2443
- collapseValue,
2444
- list,
2445
- appendComponent({ text, type, data = {} }) {
2446
- services?.editorService.add({
2680
+ const appendComponent = ({ text, type, data = {} }) => {
2681
+ services?.editorService.add({
2682
+ name: text,
2683
+ type,
2684
+ ...data
2685
+ });
2686
+ };
2687
+ const dragstartHandler = ({ text, type, data = {} }, e) => {
2688
+ if (e.dataTransfer) {
2689
+ e.dataTransfer.effectAllowed = "move";
2690
+ e.dataTransfer.setData("data", serialize({
2447
2691
  name: text,
2448
2692
  type,
2449
2693
  ...data
2450
- });
2451
- },
2452
- dragstartHandler({ text, type, data = {} }, e) {
2453
- if (e.dataTransfer) {
2454
- e.dataTransfer.effectAllowed = "move";
2455
- e.dataTransfer.setData("data", serialize({
2456
- name: text,
2457
- type,
2458
- ...data
2459
- }).replace(/"(\w+)":\s/g, "$1: "));
2460
- }
2461
- },
2462
- dragendHandler() {
2694
+ }).replace(/"(\w+)":\s/g, "$1: "));
2695
+ }
2696
+ };
2697
+ const dragendHandler = () => {
2698
+ if (timeout) {
2699
+ globalThis.clearTimeout(timeout);
2700
+ timeout = void 0;
2701
+ }
2702
+ const doc = stage.value?.renderer.contentWindow?.document;
2703
+ if (doc && stageOptions) {
2704
+ removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
2705
+ }
2706
+ clientX = 0;
2707
+ clientY = 0;
2708
+ };
2709
+ const dragHandler = (e) => {
2710
+ if (e.clientX !== clientX || e.clientY !== clientY) {
2711
+ clientX = e.clientX;
2712
+ clientY = e.clientY;
2463
2713
  if (timeout) {
2464
2714
  globalThis.clearTimeout(timeout);
2465
2715
  timeout = void 0;
2466
2716
  }
2467
- const doc = stage.value?.renderer.contentWindow?.document;
2468
- if (doc && stageOptions) {
2469
- removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
2470
- }
2471
- clientX = 0;
2472
- clientY = 0;
2473
- },
2474
- dragHandler(e) {
2475
- if (e.clientX !== clientX || e.clientY !== clientY) {
2476
- clientX = e.clientX;
2477
- clientY = e.clientY;
2478
- if (timeout) {
2479
- globalThis.clearTimeout(timeout);
2480
- timeout = void 0;
2481
- }
2482
- return;
2483
- }
2484
- if (timeout || !stage.value)
2485
- return;
2486
- timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
2717
+ return;
2487
2718
  }
2719
+ if (timeout || !stage.value)
2720
+ return;
2721
+ timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
2488
2722
  };
2489
- }
2490
- });
2491
-
2492
- const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2493
- const _hoisted_2$1 = ["onClick", "onDragstart"];
2494
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2495
- const _component_el_input = resolveComponent("el-input");
2496
- const _component_m_icon = resolveComponent("m-icon");
2497
- const _component_el_tooltip = resolveComponent("el-tooltip");
2498
- const _component_el_collapse_item = resolveComponent("el-collapse-item");
2499
- const _component_el_collapse = resolveComponent("el-collapse");
2500
- const _component_el_scrollbar = resolveComponent("el-scrollbar");
2501
- return openBlock(), createBlock(_component_el_scrollbar, null, {
2502
- default: withCtx(() => [
2503
- renderSlot(_ctx.$slots, "component-list-panel-header"),
2504
- createVNode(_component_el_collapse, {
2505
- class: "ui-component-panel",
2506
- "model-value": _ctx.collapseValue
2507
- }, {
2723
+ return (_ctx, _cache) => {
2724
+ const _component_el_input = resolveComponent("el-input");
2725
+ const _component_el_tooltip = resolveComponent("el-tooltip");
2726
+ const _component_el_collapse_item = resolveComponent("el-collapse-item");
2727
+ const _component_el_collapse = resolveComponent("el-collapse");
2728
+ const _component_el_scrollbar = resolveComponent("el-scrollbar");
2729
+ return openBlock(), createBlock(_component_el_scrollbar, null, {
2508
2730
  default: withCtx(() => [
2509
- createVNode(_component_el_input, {
2510
- "prefix-icon": "el-icon-search",
2511
- placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
2512
- class: "search-input",
2513
- size: "small",
2514
- clearable: "",
2515
- modelValue: _ctx.searchText,
2516
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.searchText = $event)
2517
- }, null, 8, ["modelValue"]),
2518
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (group, index) => {
2519
- return openBlock(), createElementBlock(Fragment, null, [
2520
- group.items && group.items.length ? (openBlock(), createBlock(_component_el_collapse_item, {
2521
- key: index,
2522
- name: index
2523
- }, {
2524
- title: withCtx(() => [
2525
- _hoisted_1$5,
2526
- createTextVNode(toDisplayString(group.title), 1)
2527
- ]),
2528
- default: withCtx(() => [
2529
- (openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
2530
- return openBlock(), createElementBlock("div", {
2531
- class: "component-item",
2532
- draggable: "true",
2533
- key: item.type,
2534
- onClick: ($event) => _ctx.appendComponent(item),
2535
- onDragstart: ($event) => _ctx.dragstartHandler(item, $event),
2536
- onDragend: _cache[1] || (_cache[1] = (...args) => _ctx.dragendHandler && _ctx.dragendHandler(...args)),
2537
- onDrag: _cache[2] || (_cache[2] = (...args) => _ctx.dragHandler && _ctx.dragHandler(...args))
2538
- }, [
2539
- createVNode(_component_m_icon, {
2540
- icon: item.icon
2541
- }, null, 8, ["icon"]),
2542
- createVNode(_component_el_tooltip, {
2543
- effect: "dark",
2544
- placement: "bottom",
2545
- content: item.text
2546
- }, {
2547
- default: withCtx(() => [
2548
- createElementVNode("span", null, toDisplayString(item.text), 1)
2549
- ]),
2550
- _: 2
2551
- }, 1032, ["content"])
2552
- ], 40, _hoisted_2$1);
2553
- }), 128))
2554
- ]),
2555
- _: 2
2556
- }, 1032, ["name"])) : createCommentVNode("", true)
2557
- ], 64);
2558
- }), 256))
2731
+ renderSlot(_ctx.$slots, "component-list-panel-header"),
2732
+ createVNode(_component_el_collapse, {
2733
+ class: "ui-component-panel",
2734
+ "model-value": unref(collapseValue)
2735
+ }, {
2736
+ default: withCtx(() => [
2737
+ createVNode(_component_el_input, {
2738
+ "prefix-icon": "el-icon-search",
2739
+ placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
2740
+ class: "search-input",
2741
+ size: "small",
2742
+ clearable: "",
2743
+ modelValue: searchText.value,
2744
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
2745
+ }, null, 8, ["modelValue"]),
2746
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (group, index) => {
2747
+ return openBlock(), createElementBlock(Fragment, null, [
2748
+ group.items && group.items.length ? (openBlock(), createBlock(_component_el_collapse_item, {
2749
+ key: index,
2750
+ name: index
2751
+ }, {
2752
+ title: withCtx(() => [
2753
+ _hoisted_1$4,
2754
+ createTextVNode(toDisplayString(group.title), 1)
2755
+ ]),
2756
+ default: withCtx(() => [
2757
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
2758
+ return openBlock(), createElementBlock("div", {
2759
+ class: "component-item",
2760
+ draggable: "true",
2761
+ key: item.type,
2762
+ onClick: ($event) => appendComponent(item),
2763
+ onDragstart: ($event) => dragstartHandler(item, $event),
2764
+ onDragend: dragendHandler,
2765
+ onDrag: dragHandler
2766
+ }, [
2767
+ renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
2768
+ createVNode(_sfc_main$h, {
2769
+ icon: item.icon
2770
+ }, null, 8, ["icon"]),
2771
+ createVNode(_component_el_tooltip, {
2772
+ effect: "dark",
2773
+ placement: "bottom",
2774
+ content: item.text
2775
+ }, {
2776
+ default: withCtx(() => [
2777
+ createElementVNode("span", null, toDisplayString(item.text), 1)
2778
+ ]),
2779
+ _: 2
2780
+ }, 1032, ["content"])
2781
+ ])
2782
+ ], 40, _hoisted_2$1);
2783
+ }), 128))
2784
+ ]),
2785
+ _: 2
2786
+ }, 1032, ["name"])) : createCommentVNode("", true)
2787
+ ], 64);
2788
+ }), 256))
2789
+ ]),
2790
+ _: 3
2791
+ }, 8, ["model-value"])
2559
2792
  ]),
2560
- _: 1
2561
- }, 8, ["model-value"])
2562
- ]),
2563
- _: 3
2564
- });
2565
- }
2566
- const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
2793
+ _: 3
2794
+ });
2795
+ };
2796
+ }
2797
+ });
2567
2798
 
2568
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
2799
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
2569
2800
  __name: "ContentMenu",
2570
2801
  props: {
2571
2802
  menuData: { default: () => [] },
@@ -2654,7 +2885,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2654
2885
  }, [
2655
2886
  createElementVNode("div", null, [
2656
2887
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
2657
- return openBlock(), createBlock(_sfc_main$f, {
2888
+ return openBlock(), createBlock(_sfc_main$g, {
2658
2889
  "event-type": "mouseup",
2659
2890
  data: item,
2660
2891
  key: index,
@@ -2678,8 +2909,8 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2678
2909
  }
2679
2910
  });
2680
2911
 
2681
- const _sfc_main$a = defineComponent({
2682
- components: { ContentMenu: _sfc_main$b },
2912
+ const _sfc_main$b = defineComponent({
2913
+ components: { ContentMenu: _sfc_main$c },
2683
2914
  setup() {
2684
2915
  const services = inject("services");
2685
2916
  const menu = ref();
@@ -2762,7 +2993,7 @@ const _sfc_main$a = defineComponent({
2762
2993
  }
2763
2994
  });
2764
2995
 
2765
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2996
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
2766
2997
  const _component_content_menu = resolveComponent("content-menu");
2767
2998
  return openBlock(), createBlock(_component_content_menu, {
2768
2999
  "menu-data": _ctx.menuData,
@@ -2770,7 +3001,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2770
3001
  style: { "overflow": "initial" }
2771
3002
  }, null, 8, ["menu-data"]);
2772
3003
  }
2773
- const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
3004
+ const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
2774
3005
 
2775
3006
  const throttleTime = 150;
2776
3007
  const select = async (data, editorService) => {
@@ -2821,20 +3052,38 @@ const useDrop = (tree, editorService) => ({
2821
3052
  }
2822
3053
  });
2823
3054
  const useStatus = (tree, editorService) => {
2824
- const highlightNode = ref();
2825
3055
  const node = ref();
2826
3056
  const page = computed(() => editorService?.get("page"));
3057
+ const expandedKeys = /* @__PURE__ */ new Map();
3058
+ const expandNodes = () => {
3059
+ expandedKeys.forEach((key) => {
3060
+ if (!tree.value)
3061
+ return;
3062
+ tree.value.getNode(key)?.expand();
3063
+ });
3064
+ };
2827
3065
  watchEffect(() => {
2828
3066
  if (!tree.value)
2829
3067
  return;
2830
- node.value = editorService?.get("node");
2831
- node.value && tree.value.setCurrentKey(node.value.id, true);
2832
- const parent = editorService?.get("parent");
3068
+ if (!editorService)
3069
+ return;
3070
+ node.value = editorService.get("node");
3071
+ if (!node.value)
3072
+ return;
3073
+ tree.value.setCurrentKey(node.value.id, true);
3074
+ const parent = editorService.get("parent");
2833
3075
  if (!parent?.id)
2834
3076
  return;
2835
3077
  const treeNode = tree.value.getNode(parent.id);
2836
3078
  treeNode?.updateChildren();
2837
- highlightNode.value = editorService?.get("highlightNode");
3079
+ setTimeout(() => {
3080
+ tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
3081
+ if (node2.expanded && node2.data.items) {
3082
+ expandedKeys.set(id, id);
3083
+ }
3084
+ });
3085
+ expandNodes();
3086
+ });
2838
3087
  });
2839
3088
  return {
2840
3089
  values: computed(() => page.value ? [page.value] : []),
@@ -2847,9 +3096,18 @@ const useStatus = (tree, editorService) => {
2847
3096
  }
2848
3097
  resolve([]);
2849
3098
  },
2850
- highlightNode,
3099
+ highlightNode: computed(() => editorService?.get("highlightNode")),
2851
3100
  clickNode: node,
2852
- expandedKeys: computed(() => node.value ? [node.value.id] : [])
3101
+ expandedKeys: computed(() => node.value ? [node.value.id] : []),
3102
+ handleCollapse: (data) => {
3103
+ expandedKeys.delete(data.id);
3104
+ },
3105
+ handleExpand: (data) => {
3106
+ const parent = editorService?.getParentById(data.id);
3107
+ if (!parent?.id)
3108
+ return;
3109
+ expandedKeys.set(parent.id, parent.id);
3110
+ }
2853
3111
  };
2854
3112
  };
2855
3113
  const useFilter = (tree) => ({
@@ -2870,7 +3128,7 @@ const useFilter = (tree) => ({
2870
3128
  tree.value?.filter(val);
2871
3129
  }
2872
3130
  });
2873
- const _sfc_main$9 = defineComponent({
3131
+ const _sfc_main$a = defineComponent({
2874
3132
  name: "magic-editor-layer-panel",
2875
3133
  components: { LayerMenu },
2876
3134
  setup() {
@@ -2918,8 +3176,8 @@ const _sfc_main$9 = defineComponent({
2918
3176
  }
2919
3177
  });
2920
3178
 
2921
- const _hoisted_1$4 = ["id", "onMouseenter"];
2922
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3179
+ const _hoisted_1$3 = ["id", "onMouseenter"];
3180
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
2923
3181
  const _component_el_input = resolveComponent("el-input");
2924
3182
  const _component_el_tree = resolveComponent("el-tree");
2925
3183
  const _component_layer_menu = resolveComponent("layer-menu");
@@ -2940,6 +3198,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2940
3198
  key: 0,
2941
3199
  ref: "tree",
2942
3200
  "node-key": "id",
3201
+ "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
2943
3202
  draggable: "",
2944
3203
  "default-expanded-keys": _ctx.expandedKeys,
2945
3204
  load: _ctx.loadItems,
@@ -2954,7 +3213,8 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2954
3213
  onNodeClick: _ctx.clickHandler,
2955
3214
  onNodeContextmenu: _ctx.contextmenu,
2956
3215
  onNodeDragEnd: _ctx.handleDragEnd,
2957
- "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
3216
+ onNodeCollapse: _ctx.handleCollapse,
3217
+ onNodeExpand: _ctx.handleExpand
2958
3218
  }, {
2959
3219
  default: withCtx(({ node, data }) => [
2960
3220
  createElementVNode("div", {
@@ -2970,10 +3230,10 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2970
3230
  }, () => [
2971
3231
  createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
2972
3232
  ])
2973
- ], 42, _hoisted_1$4)
3233
+ ], 42, _hoisted_1$3)
2974
3234
  ]),
2975
3235
  _: 3
2976
- }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
3236
+ }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
2977
3237
  (openBlock(), createBlock(Teleport, { to: "body" }, [
2978
3238
  createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
2979
3239
  ]))
@@ -2981,10 +3241,10 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2981
3241
  _: 3
2982
3242
  });
2983
3243
  }
2984
- const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
3244
+ const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
2985
3245
 
2986
- const _sfc_main$8 = defineComponent({
2987
- components: { MIcon },
3246
+ const _sfc_main$9 = defineComponent({
3247
+ components: { MIcon: _sfc_main$h },
2988
3248
  props: {
2989
3249
  data: {
2990
3250
  type: [Object, String]
@@ -3002,7 +3262,7 @@ const _sfc_main$8 = defineComponent({
3002
3262
  type: "component",
3003
3263
  icon: Coin,
3004
3264
  text: "\u7EC4\u4EF6",
3005
- component: ComponentListPanel,
3265
+ component: _sfc_main$d,
3006
3266
  slots: {}
3007
3267
  };
3008
3268
  case "layer":
@@ -3021,11 +3281,11 @@ const _sfc_main$8 = defineComponent({
3021
3281
  }
3022
3282
  });
3023
3283
 
3024
- const _hoisted_1$3 = {
3284
+ const _hoisted_1$2 = {
3025
3285
  key: 1,
3026
3286
  class: "magic-editor-tab-panel-title"
3027
3287
  };
3028
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3288
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3029
3289
  const _component_m_icon = resolveComponent("m-icon");
3030
3290
  const _component_el_tab_pane = resolveComponent("el-tab-pane");
3031
3291
  return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
@@ -3040,7 +3300,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3040
3300
  key: 0,
3041
3301
  icon: _ctx.config.icon
3042
3302
  }, null, 8, ["icon"])) : createCommentVNode("", true),
3043
- _ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
3303
+ _ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$2, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
3044
3304
  ]))
3045
3305
  ]),
3046
3306
  default: withCtx(() => [
@@ -3051,6 +3311,18 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3051
3311
  _ctx.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : _ctx.config.slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
3052
3312
  ])
3053
3313
  } : void 0,
3314
+ _ctx.data === "component-list" || _ctx.config.slots?.componentListItem ? {
3315
+ name: "component-list-item",
3316
+ fn: withCtx(({ component }) => [
3317
+ _ctx.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
3318
+ key: 0,
3319
+ component
3320
+ }) : _ctx.config.slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.componentListItem), {
3321
+ key: 1,
3322
+ component
3323
+ }, null, 8, ["component"])) : createCommentVNode("", true)
3324
+ ])
3325
+ } : void 0,
3054
3326
  _ctx.data === "layer" || _ctx.config.slots?.layerPanelHeader ? {
3055
3327
  name: "layer-panel-header",
3056
3328
  fn: withCtx(() => [
@@ -3071,9 +3343,9 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3071
3343
  _: 3
3072
3344
  }, 8, ["name"])) : createCommentVNode("", true);
3073
3345
  }
3074
- const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
3346
+ const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
3075
3347
 
3076
- const _sfc_main$7 = defineComponent({
3348
+ const _sfc_main$8 = defineComponent({
3077
3349
  components: { TabPane },
3078
3350
  name: "m-sidebar",
3079
3351
  props: {
@@ -3093,7 +3365,7 @@ const _sfc_main$7 = defineComponent({
3093
3365
  }
3094
3366
  });
3095
3367
 
3096
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3368
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3097
3369
  const _component_tab_pane = resolveComponent("tab-pane");
3098
3370
  const _component_el_tabs = resolveComponent("el-tabs");
3099
3371
  return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
@@ -3121,6 +3393,12 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3121
3393
  fn: withCtx(() => [
3122
3394
  renderSlot(_ctx.$slots, "component-list-panel-header")
3123
3395
  ])
3396
+ } : void 0,
3397
+ item === "component-list" ? {
3398
+ name: "component-list-item",
3399
+ fn: withCtx(({ component }) => [
3400
+ renderSlot(_ctx.$slots, "component-list-item", { component })
3401
+ ])
3124
3402
  } : void 0
3125
3403
  ]), 1032, ["data"]);
3126
3404
  }), 128))
@@ -3128,18 +3406,24 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3128
3406
  _: 3
3129
3407
  }, 8, ["modelValue"])) : createCommentVNode("", true);
3130
3408
  }
3131
- const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
3409
+ const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
3132
3410
 
3133
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3411
+ const _hoisted_1$1 = {
3412
+ key: 1,
3413
+ style: { "width": "21px" }
3414
+ };
3415
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3134
3416
  __name: "PageBarScrollContainer",
3135
3417
  setup(__props) {
3136
3418
  const services = inject("services");
3137
3419
  const editorService = services?.editorService;
3420
+ const uiService = services?.uiService;
3138
3421
  const pageBar = ref();
3139
3422
  const itemsContainer = ref();
3140
3423
  const pageBarWidth = ref(0);
3141
3424
  const canScroll = ref(false);
3142
- const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
3425
+ const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
3426
+ const itemsContainerWidth = computed(() => pageBarWidth.value - 35 * 2 - (showAddPageButton.value ? 35 : 21));
3143
3427
  let translateLeft = 0;
3144
3428
  const resizeObserver = new ResizeObserver((entries) => {
3145
3429
  for (const { contentRect } of entries) {
@@ -3150,7 +3434,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3150
3434
  });
3151
3435
  const setCanScroll = () => {
3152
3436
  if (itemsContainer.value) {
3153
- canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
3437
+ canScroll.value = itemsContainer.value.scrollWidth > itemsContainerWidth.value;
3154
3438
  }
3155
3439
  };
3156
3440
  const scroll = (type) => {
@@ -3207,7 +3491,8 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3207
3491
  ref_key: "pageBar",
3208
3492
  ref: pageBar
3209
3493
  }, [
3210
- createElementVNode("div", {
3494
+ unref(showAddPageButton) ? (openBlock(), createElementBlock("div", {
3495
+ key: 0,
3211
3496
  id: "m-editor-page-bar-add-icon",
3212
3497
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3213
3498
  onClick: addPage
@@ -3218,9 +3503,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3218
3503
  ]),
3219
3504
  _: 1
3220
3505
  })
3221
- ]),
3506
+ ])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
3222
3507
  canScroll.value ? (openBlock(), createElementBlock("div", {
3223
- key: 0,
3508
+ key: 2,
3224
3509
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3225
3510
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
3226
3511
  }, [
@@ -3232,7 +3517,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3232
3517
  })
3233
3518
  ])) : createCommentVNode("", true),
3234
3519
  unref(root) ? (openBlock(), createElementBlock("div", {
3235
- key: 1,
3520
+ key: 3,
3236
3521
  class: "m-editor-page-bar-items",
3237
3522
  ref_key: "itemsContainer",
3238
3523
  ref: itemsContainer,
@@ -3241,7 +3526,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3241
3526
  renderSlot(_ctx.$slots, "default")
3242
3527
  ], 4)) : createCommentVNode("", true),
3243
3528
  canScroll.value ? (openBlock(), createElementBlock("div", {
3244
- key: 2,
3529
+ key: 4,
3245
3530
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3246
3531
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
3247
3532
  }, [
@@ -3257,9 +3542,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3257
3542
  }
3258
3543
  });
3259
3544
 
3260
- const _hoisted_1$2 = ["onClick"];
3545
+ const _hoisted_1 = ["onClick"];
3261
3546
  const _hoisted_2 = { class: "m-editor-page-bar-title" };
3262
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3547
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3263
3548
  __name: "PageBar",
3264
3549
  setup(__props) {
3265
3550
  const services = inject("services");
@@ -3283,7 +3568,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3283
3568
  const _component_el_tooltip = resolveComponent("el-tooltip");
3284
3569
  const _component_el_icon = resolveComponent("el-icon");
3285
3570
  const _component_el_popover = resolveComponent("el-popover");
3286
- return openBlock(), createBlock(_sfc_main$6, null, {
3571
+ return openBlock(), createBlock(_sfc_main$7, null, {
3287
3572
  default: withCtx(() => [
3288
3573
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
3289
3574
  return openBlock(), createElementBlock("div", {
@@ -3299,7 +3584,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3299
3584
  content: item.name
3300
3585
  }, {
3301
3586
  default: withCtx(() => [
3302
- createElementVNode("span", null, toDisplayString(item.name), 1)
3587
+ createElementVNode("span", null, toDisplayString(item.name || item.id), 1)
3303
3588
  ]),
3304
3589
  _: 2
3305
3590
  }, 1032, ["content"])
@@ -3322,7 +3607,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3322
3607
  default: withCtx(() => [
3323
3608
  createElementVNode("div", null, [
3324
3609
  renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3325
- createVNode(_sfc_main$f, {
3610
+ createVNode(_sfc_main$g, {
3326
3611
  data: {
3327
3612
  type: "button",
3328
3613
  text: "\u590D\u5236",
@@ -3330,7 +3615,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3330
3615
  handler: () => copy(item)
3331
3616
  }
3332
3617
  }, null, 8, ["data"]),
3333
- createVNode(_sfc_main$f, {
3618
+ createVNode(_sfc_main$g, {
3334
3619
  data: {
3335
3620
  type: "button",
3336
3621
  text: "\u5220\u9664",
@@ -3343,7 +3628,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3343
3628
  ]),
3344
3629
  _: 2
3345
3630
  }, 1024)
3346
- ], 10, _hoisted_1$2);
3631
+ ], 10, _hoisted_1);
3347
3632
  }), 128))
3348
3633
  ]),
3349
3634
  _: 3
@@ -3352,190 +3637,245 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3352
3637
  }
3353
3638
  });
3354
3639
 
3355
- class ScrollViewer$1 {
3356
- enter = false;
3357
- targetEnter = false;
3358
- keydown = false;
3640
+ class ScrollViewer extends EventEmitter {
3359
3641
  container;
3360
3642
  target;
3361
3643
  zoom = 1;
3362
3644
  scrollLeft = 0;
3363
3645
  scrollTop = 0;
3364
- x = 0;
3365
- y = 0;
3366
- resizeObserver = new ResizeObserver((entries) => {
3367
- for (const { contentRect } of entries) {
3368
- const { width, height } = contentRect;
3369
- const targetRect = this.target.getBoundingClientRect();
3370
- const targetWidth = targetRect.width * this.zoom;
3371
- const targetMarginTop = Number(this.target.style.marginTop) || 0;
3372
- const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3373
- if (targetWidth < width) {
3374
- this.target._left = 0;
3375
- }
3376
- if (targetHeight < height) {
3377
- this.target._top = 0;
3378
- }
3379
- this.scroll();
3380
- }
3646
+ scrollHeight = 0;
3647
+ scrollWidth = 0;
3648
+ width = 0;
3649
+ height = 0;
3650
+ translateXCorrectionValue = 0;
3651
+ translateYCorrectionValue = 0;
3652
+ resizeObserver = new ResizeObserver(() => {
3653
+ this.setSize();
3654
+ this.setScrollSize();
3381
3655
  });
3382
3656
  constructor(options) {
3657
+ super();
3383
3658
  this.container = options.container;
3384
3659
  this.target = options.target;
3385
3660
  this.zoom = options.zoom;
3386
- globalThis.addEventListener("keydown", this.keydownHandler);
3387
- globalThis.addEventListener("keyup", this.keyupHandler);
3388
- this.container.addEventListener("mouseenter", this.mouseEnterHandler);
3389
- this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
3390
- this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
3391
- this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
3392
- this.container.addEventListener("wheel", this.wheelHandler);
3661
+ this.container.addEventListener("wheel", this.wheelHandler, false);
3662
+ this.setSize();
3663
+ this.setScrollSize();
3393
3664
  this.resizeObserver.observe(this.container);
3394
3665
  }
3395
3666
  destroy() {
3396
3667
  this.resizeObserver.disconnect();
3397
- this.container.removeEventListener("mouseenter", this.mouseEnterHandler);
3398
- this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
3399
- this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
3400
- this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
3401
- globalThis.removeEventListener("keydown", this.keydownHandler);
3402
- globalThis.removeEventListener("keyup", this.keyupHandler);
3668
+ this.container.removeEventListener("wheel", this.wheelHandler, false);
3669
+ this.removeAllListeners();
3403
3670
  }
3404
3671
  setZoom(zoom) {
3405
3672
  this.zoom = zoom;
3673
+ this.setScrollSize();
3406
3674
  }
3407
- scroll() {
3408
- const scrollLeft = this.target._left;
3409
- const scrollTop = this.target._top;
3410
- this.target.style.transform = `translate(${scrollLeft}px, ${scrollTop}px)`;
3411
- }
3412
- removeHandler() {
3413
- this.target.style.cursor = "";
3414
- this.target.removeEventListener("mousedown", this.mousedownHandler);
3415
- document.removeEventListener("mousemove", this.mousemoveHandler);
3416
- document.removeEventListener("mouseup", this.mouseupHandler);
3675
+ scrollTo({ left, top }) {
3676
+ if (typeof left !== "undefined") {
3677
+ this.scrollLeft = left;
3678
+ }
3679
+ if (typeof top !== "undefined") {
3680
+ this.scrollTop = top;
3681
+ }
3682
+ const translateX = -this.scrollLeft + this.translateXCorrectionValue;
3683
+ const translateY = -this.scrollTop + this.translateYCorrectionValue;
3684
+ this.target.style.transform = `translate(${translateX}px, ${translateY}px)`;
3417
3685
  }
3418
3686
  wheelHandler = (event) => {
3419
- if (this.targetEnter)
3420
- return;
3421
3687
  const { deltaX, deltaY, currentTarget } = event;
3422
3688
  if (currentTarget !== this.container)
3423
3689
  return;
3424
- this.setScrollOffset(deltaX, deltaY);
3425
- this.scroll();
3426
- this.scrollLeft = this.target._left;
3427
- this.scrollTop = this.target._top;
3428
- };
3429
- mouseEnterHandler = () => {
3430
- this.enter = true;
3431
- };
3432
- mouseLeaveHandler = () => {
3433
- this.enter = false;
3434
- };
3435
- targetMouseEnterHandler = () => {
3436
- this.targetEnter = true;
3437
- };
3438
- targetMouseLeaveHandler = () => {
3439
- this.targetEnter = false;
3440
- };
3441
- mousedownHandler = (event) => {
3442
- if (!this.keydown)
3443
- return;
3444
- event.stopImmediatePropagation();
3445
- event.stopPropagation();
3446
- this.target.style.cursor = "grabbing";
3447
- this.x = event.clientX;
3448
- this.y = event.clientY;
3449
- document.addEventListener("mousemove", this.mousemoveHandler);
3450
- document.addEventListener("mouseup", this.mouseupHandler);
3451
- };
3452
- mouseupHandler = () => {
3453
- this.x = 0;
3454
- this.y = 0;
3455
- this.scrollLeft = this.target._left;
3456
- this.scrollTop = this.target._top;
3457
- this.removeHandler();
3458
- };
3459
- mousemoveHandler = (event) => {
3460
- event.stopImmediatePropagation();
3461
- event.stopPropagation();
3462
- const deltaX = event.clientX - this.x;
3463
- const deltaY = event.clientY - this.y;
3464
- this.setScrollOffset(deltaX, deltaY);
3465
- this.scroll();
3466
- };
3467
- keydownHandler = (event) => {
3468
- if (event.code === Keys.ESCAPE && this.enter) {
3469
- event.preventDefault();
3470
- event.stopImmediatePropagation();
3471
- event.stopPropagation();
3690
+ let top;
3691
+ if (this.scrollHeight > this.height) {
3692
+ top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
3472
3693
  }
3473
- if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3474
- return;
3694
+ let left;
3695
+ if (this.scrollWidth > this.width) {
3696
+ left = this.scrollLeft + this.getPos(deltaX, this.scrollLeft, this.scrollWidth, this.width);
3475
3697
  }
3476
- this.keydown = true;
3477
- this.target.style.cursor = "grab";
3478
- this.container.addEventListener("mousedown", this.mousedownHandler);
3698
+ this.scrollTo({ left, top });
3699
+ this.emit("scroll", {
3700
+ scrollLeft: this.scrollLeft,
3701
+ scrollTop: this.scrollTop,
3702
+ scrollHeight: this.scrollHeight,
3703
+ scrollWidth: this.scrollWidth
3704
+ });
3479
3705
  };
3480
- keyupHandler = (event) => {
3481
- if (event.code !== Keys.ESCAPE || !this.keydown) {
3482
- return;
3706
+ getPos(delta, scrollPos, scrollSize, size) {
3707
+ let pos = 0;
3708
+ if (delta < 0) {
3709
+ if (scrollPos > 0) {
3710
+ pos = Math.max(delta, -scrollPos);
3711
+ }
3712
+ } else {
3713
+ const leftPos = scrollSize - size - scrollPos;
3714
+ if (leftPos > 0) {
3715
+ pos = Math.min(delta, leftPos);
3716
+ }
3717
+ }
3718
+ return pos;
3719
+ }
3720
+ setScrollSize = () => {
3721
+ const targetRect = this.target.getBoundingClientRect();
3722
+ this.scrollWidth = targetRect.width * this.zoom + 100;
3723
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3724
+ this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + 100;
3725
+ let left;
3726
+ let top;
3727
+ if (this.scrollWidth < this.width) {
3728
+ left = 0;
3729
+ this.translateXCorrectionValue = 0;
3730
+ } else {
3731
+ this.translateXCorrectionValue = (this.scrollWidth - this.width) / 2;
3732
+ }
3733
+ if (this.scrollHeight < this.height) {
3734
+ top = 0;
3735
+ this.translateYCorrectionValue = 0;
3736
+ } else {
3737
+ this.translateYCorrectionValue = (this.scrollHeight - this.height) / 2;
3483
3738
  }
3484
- event.preventDefault();
3485
- event.stopImmediatePropagation();
3486
- event.stopPropagation();
3487
- this.keydown = false;
3488
- event.preventDefault();
3489
- this.removeHandler();
3739
+ this.scrollTo({
3740
+ left,
3741
+ top
3742
+ });
3743
+ this.emit("scroll", {
3744
+ scrollLeft: this.scrollLeft,
3745
+ scrollTop: this.scrollTop,
3746
+ scrollHeight: this.scrollHeight,
3747
+ scrollWidth: this.scrollWidth
3748
+ });
3490
3749
  };
3491
- setScrollOffset(deltaX, deltaY) {
3750
+ setSize = () => {
3492
3751
  const { width, height } = this.container.getBoundingClientRect();
3493
- const targetRect = this.target.getBoundingClientRect();
3494
- const targetWidth = targetRect.width * this.zoom;
3495
- const targetHeight = targetRect.height * this.zoom;
3496
- let y = 0;
3497
- if (targetHeight > height) {
3498
- if (deltaY > 0) {
3499
- y = this.scrollTop + Math.min(targetHeight - height - this.scrollTop, deltaY);
3500
- } else {
3501
- y = this.scrollTop + Math.max(-(targetHeight - height + this.scrollTop), deltaY);
3752
+ this.width = width;
3753
+ this.height = height;
3754
+ };
3755
+ }
3756
+
3757
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3758
+ __name: "ScrollBar",
3759
+ props: {
3760
+ size: null,
3761
+ scrollSize: null,
3762
+ isHorizontal: { type: Boolean },
3763
+ pos: null
3764
+ },
3765
+ emits: ["scroll"],
3766
+ setup(__props, { emit }) {
3767
+ const props = __props;
3768
+ const bar = ref();
3769
+ const thumb = ref();
3770
+ const thumbSize = computed(() => props.size * (props.size / props.scrollSize));
3771
+ const thumbPos = computed(() => props.pos / props.scrollSize * props.size);
3772
+ const thumbStyle = computed(() => ({
3773
+ [props.isHorizontal ? "width" : "height"]: `${thumbSize.value}px`,
3774
+ transform: `translate${props.isHorizontal ? "X" : "Y"}(${thumbPos.value}px)`
3775
+ }));
3776
+ let gesto;
3777
+ onMounted(() => {
3778
+ if (!thumb.value)
3779
+ return;
3780
+ const thumbEl = thumb.value;
3781
+ gesto = new Gesto(thumbEl, {
3782
+ container: window
3783
+ });
3784
+ gesto.on("dragStart", (e) => {
3785
+ e.inputEvent.stopPropagation();
3786
+ e.inputEvent.preventDefault();
3787
+ }).on("drag", (e) => {
3788
+ scrollBy(getDelta(e));
3789
+ });
3790
+ bar.value?.addEventListener("wheel", wheelHandler, false);
3791
+ });
3792
+ onUnmounted(() => {
3793
+ if (gesto)
3794
+ gesto.off();
3795
+ bar.value?.removeEventListener("wheel", wheelHandler, false);
3796
+ });
3797
+ const wheelHandler = (e) => {
3798
+ const delta = props.isHorizontal ? e.deltaX : e.deltaY;
3799
+ if (delta) {
3800
+ e.preventDefault();
3502
3801
  }
3503
- }
3504
- let x = 0;
3505
- if (targetWidth > width) {
3506
- if (deltaX > 0) {
3507
- x = this.scrollLeft + Math.min(targetWidth - width - this.scrollLeft, deltaX);
3802
+ scrollBy(delta);
3803
+ };
3804
+ const getDelta = (e) => {
3805
+ const ratio = (props.isHorizontal ? e.deltaX : e.deltaY) / props.size;
3806
+ return props.scrollSize * ratio;
3807
+ };
3808
+ const scrollBy = (delta) => {
3809
+ if (delta < 0) {
3810
+ if (props.pos <= 0) {
3811
+ emit("scroll", 0);
3812
+ } else {
3813
+ emit("scroll", -Math.min(-delta, props.pos));
3814
+ }
3508
3815
  } else {
3509
- x = this.scrollLeft + Math.max(-(targetWidth - width + this.scrollLeft), deltaX);
3816
+ const leftPos = props.size - (thumbSize.value + thumbPos.value);
3817
+ if (leftPos <= 0) {
3818
+ emit("scroll", 0);
3819
+ } else {
3820
+ emit("scroll", Math.min(delta, leftPos));
3821
+ }
3510
3822
  }
3511
- }
3512
- this.target._left = x;
3513
- this.target._top = y;
3823
+ };
3824
+ return (_ctx, _cache) => {
3825
+ return openBlock(), createElementBlock("div", {
3826
+ ref_key: "bar",
3827
+ ref: bar,
3828
+ class: normalizeClass(["m-editor-scroll-bar", __props.isHorizontal ? "horizontal" : "vertical"])
3829
+ }, [
3830
+ createElementVNode("div", {
3831
+ ref_key: "thumb",
3832
+ ref: thumb,
3833
+ class: "m-editor-scroll-bar-thumb",
3834
+ style: normalizeStyle(unref(thumbStyle))
3835
+ }, null, 4)
3836
+ ], 2);
3837
+ };
3514
3838
  }
3515
- }
3839
+ });
3516
3840
 
3517
- const _sfc_main$4 = defineComponent({
3518
- name: "m-editor-scroll-viewer",
3841
+ const ScrollBar_vue_vue_type_style_index_0_lang = '';
3842
+
3843
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3844
+ __name: "ScrollViewer",
3519
3845
  props: {
3520
- width: Number,
3521
- height: Number,
3522
- zoom: {
3523
- type: Number,
3524
- default: 1
3525
- }
3846
+ width: { default: 0 },
3847
+ height: { default: 0 },
3848
+ wrapWidth: { default: 0 },
3849
+ wrapHeight: { default: 0 },
3850
+ zoom: { default: 1 }
3526
3851
  },
3527
- setup(props) {
3852
+ setup(__props, { expose }) {
3853
+ const props = __props;
3528
3854
  const container = ref();
3529
3855
  const el = ref();
3856
+ const style = computed(() => `
3857
+ width: ${props.width}px;
3858
+ height: ${props.height}px;
3859
+ position: absolute;
3860
+ margin-top: 30px;
3861
+ `);
3862
+ const scrollWidth = ref(0);
3863
+ const scrollHeight = ref(0);
3530
3864
  let scrollViewer;
3531
3865
  onMounted(() => {
3532
3866
  if (!container.value || !el.value)
3533
3867
  return;
3534
- scrollViewer = new ScrollViewer$1({
3868
+ scrollViewer = new ScrollViewer({
3535
3869
  container: container.value,
3536
3870
  target: el.value,
3537
3871
  zoom: props.zoom
3538
3872
  });
3873
+ scrollViewer.on("scroll", (data) => {
3874
+ hOffset.value = data.scrollLeft;
3875
+ vOffset.value = data.scrollTop;
3876
+ scrollWidth.value = data.scrollWidth;
3877
+ scrollHeight.value = data.scrollHeight;
3878
+ });
3539
3879
  });
3540
3880
  onUnmounted(() => {
3541
3881
  scrollViewer.destroy();
@@ -3543,35 +3883,56 @@ const _sfc_main$4 = defineComponent({
3543
3883
  watch(() => props.zoom, () => {
3544
3884
  scrollViewer.setZoom(props.zoom);
3545
3885
  });
3546
- return {
3547
- container,
3548
- el,
3549
- style: computed(() => `
3550
- width: ${props.width}px;
3551
- height: ${props.height}px;
3552
- position: absolute;
3553
- margin-top: 30px;
3554
- `)
3886
+ const vOffset = ref(0);
3887
+ const vScrollHandler = (delta) => {
3888
+ vOffset.value += delta;
3889
+ scrollViewer.scrollTo({
3890
+ top: vOffset.value
3891
+ });
3892
+ };
3893
+ const hOffset = ref(0);
3894
+ const hScrollHandler = (delta) => {
3895
+ hOffset.value += delta;
3896
+ scrollViewer.scrollTo({
3897
+ left: hOffset.value
3898
+ });
3899
+ };
3900
+ expose({
3901
+ container
3902
+ });
3903
+ return (_ctx, _cache) => {
3904
+ return openBlock(), createElementBlock("div", {
3905
+ class: "m-editor-scroll-viewer-container",
3906
+ ref_key: "container",
3907
+ ref: container
3908
+ }, [
3909
+ createElementVNode("div", {
3910
+ ref_key: "el",
3911
+ ref: el,
3912
+ style: normalizeStyle(unref(style))
3913
+ }, [
3914
+ renderSlot(_ctx.$slots, "default")
3915
+ ], 4),
3916
+ scrollHeight.value > __props.wrapHeight ? (openBlock(), createBlock(_sfc_main$5, {
3917
+ key: 0,
3918
+ "scroll-size": scrollHeight.value,
3919
+ size: __props.wrapHeight,
3920
+ pos: vOffset.value,
3921
+ onScroll: vScrollHandler
3922
+ }, null, 8, ["scroll-size", "size", "pos"])) : createCommentVNode("", true),
3923
+ scrollWidth.value > __props.wrapWidth ? (openBlock(), createBlock(_sfc_main$5, {
3924
+ key: 1,
3925
+ "is-horizontal": true,
3926
+ "scroll-size": scrollWidth.value,
3927
+ pos: hOffset.value,
3928
+ size: __props.wrapWidth,
3929
+ onScroll: hScrollHandler
3930
+ }, null, 8, ["scroll-size", "pos", "size"])) : createCommentVNode("", true)
3931
+ ], 512);
3555
3932
  };
3556
3933
  }
3557
3934
  });
3558
3935
 
3559
- const _hoisted_1$1 = {
3560
- class: "m-editor-scroll-viewer-container",
3561
- ref: "container"
3562
- };
3563
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3564
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
3565
- createElementVNode("div", {
3566
- ref: "el",
3567
- style: normalizeStyle(_ctx.style)
3568
- }, [
3569
- renderSlot(_ctx.$slots, "default")
3570
- ], 4)
3571
- ], 512);
3572
- }
3573
- const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
3574
-
3575
3936
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3576
3937
  __name: "ViewerMenu",
3577
3938
  props: {
@@ -3708,7 +4069,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3708
4069
  };
3709
4070
  expose({ show });
3710
4071
  return (_ctx, _cache) => {
3711
- return openBlock(), createBlock(_sfc_main$b, {
4072
+ return openBlock(), createBlock(_sfc_main$c, {
3712
4073
  "menu-data": menuData,
3713
4074
  ref_key: "menu",
3714
4075
  ref: menu
@@ -3729,12 +4090,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3729
4090
  const menu = ref();
3730
4091
  const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
3731
4092
  const stageRect = computed(() => services?.uiService.get("stageRect"));
3732
- const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
4093
+ const stageContainerRect = computed(() => services?.uiService.get("stageContainerRect"));
3733
4094
  const root = computed(() => services?.editorService.get("root"));
3734
4095
  const page = computed(() => services?.editorService.get("page"));
3735
4096
  const zoom = computed(() => services?.uiService.get("zoom") || 1);
3736
4097
  const node = computed(() => services?.editorService.get("node"));
3737
- const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
3738
4098
  watchEffect(() => {
3739
4099
  if (stage)
3740
4100
  return;
@@ -3742,64 +4102,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3742
4102
  return;
3743
4103
  if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
3744
4104
  return;
3745
- stage = new StageCore({
3746
- render: stageOptions.render,
3747
- runtimeUrl: stageOptions.runtimeUrl,
3748
- zoom: zoom.value,
3749
- autoScrollIntoView: stageOptions.autoScrollIntoView,
3750
- isContainer: stageOptions.isContainer,
3751
- containerHighlightClassName: stageOptions.containerHighlightClassName,
3752
- containerHighlightDuration: stageOptions.containerHighlightDuration,
3753
- containerHighlightType: stageOptions.containerHighlightType,
3754
- canSelect: (el, event, stop) => {
3755
- const elCanSelect = stageOptions.canSelect(el);
3756
- if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
3757
- document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
3758
- return stop();
3759
- }
3760
- return elCanSelect;
3761
- },
3762
- moveableOptions: stageOptions.moveableOptions,
3763
- updateDragEl: stageOptions.updateDragEl
3764
- });
4105
+ stage = useStage(stageOptions);
3765
4106
  services?.editorService.set("stage", markRaw(stage));
3766
4107
  stage?.mount(stageContainer.value);
3767
- stage.mask.setGuides([
3768
- getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
3769
- getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
3770
- ]);
3771
- stage?.on("select", (el) => {
3772
- services?.editorService.select(el.id);
3773
- });
3774
- stage?.on("highlight", (el) => {
3775
- services?.editorService.highlight(el.id);
3776
- });
3777
- stage?.on("multiSelect", (els) => {
3778
- services?.editorService.multiSelect(els.map((el) => el.id));
3779
- });
3780
- stage?.on("update", (ev) => {
3781
- if (ev.parentEl) {
3782
- for (const data of ev.data) {
3783
- services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
3784
- }
3785
- return;
3786
- }
3787
- services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
3788
- });
3789
- stage?.on("sort", (ev) => {
3790
- services?.editorService.sort(ev.src, ev.dist);
3791
- });
3792
- stage?.on("changeGuides", (e2) => {
3793
- services?.uiService.set("showGuides", true);
3794
- if (!root.value || !page.value)
3795
- return;
3796
- const storageKey = getGuideLineKey(e2.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
3797
- if (e2.guides.length) {
3798
- globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
3799
- } else {
3800
- globalThis.localStorage.removeItem(storageKey);
3801
- }
3802
- });
3803
4108
  if (!node.value?.id)
3804
4109
  return;
3805
4110
  stage?.on("runtime-ready", (rt) => {
@@ -3877,20 +4182,22 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3877
4182
  config.style = {
3878
4183
  ...style,
3879
4184
  position,
3880
- top,
3881
- left
4185
+ top: top / zoom.value,
4186
+ left: left / zoom.value
3882
4187
  };
3883
4188
  config.inputEvent = e;
3884
4189
  services?.editorService.add(config, parent);
3885
4190
  }
3886
4191
  };
3887
4192
  return (_ctx, _cache) => {
3888
- return openBlock(), createBlock(ScrollViewer, {
4193
+ return openBlock(), createBlock(_sfc_main$4, {
3889
4194
  class: "m-editor-stage",
3890
4195
  ref_key: "stageWrap",
3891
4196
  ref: stageWrap,
3892
4197
  width: unref(stageRect)?.width,
3893
4198
  height: unref(stageRect)?.height,
4199
+ "wrap-width": unref(stageContainerRect)?.width,
4200
+ "wrap-height": unref(stageContainerRect)?.height,
3894
4201
  zoom: unref(zoom)
3895
4202
  }, {
3896
4203
  default: withCtx(() => [
@@ -3898,7 +4205,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3898
4205
  class: "m-editor-stage-container",
3899
4206
  ref_key: "stageContainer",
3900
4207
  ref: stageContainer,
3901
- style: normalizeStyle(`transform: scale(${unref(zoom)})`),
4208
+ style: normalizeStyle(`transform: scale(${unref(zoom)});`),
3902
4209
  onContextmenu: contextmenuHandler,
3903
4210
  onDrop: dropHandler,
3904
4211
  onDragover: dragoverHandler
@@ -3912,28 +4219,25 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3912
4219
  ]))
3913
4220
  ]),
3914
4221
  _: 1
3915
- }, 8, ["width", "height", "zoom"]);
4222
+ }, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
3916
4223
  };
3917
4224
  }
3918
4225
  });
3919
4226
 
3920
- const _sfc_main$1 = defineComponent({
3921
- name: "m-editor-workspace",
3922
- components: {
3923
- PageBar: _sfc_main$5,
3924
- MagicStage: _sfc_main$2
3925
- },
3926
- setup() {
4227
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
4228
+ __name: "Workspace",
4229
+ setup(__props) {
3927
4230
  const services = inject("services");
3928
4231
  const workspace = ref();
3929
4232
  const nodes = computed(() => services?.editorService.get("nodes"));
3930
- let keycon;
4233
+ const page = computed(() => services?.editorService.get("page"));
3931
4234
  const mouseenterHandler = () => {
3932
4235
  workspace.value?.focus();
3933
4236
  };
3934
4237
  const mouseleaveHandler = () => {
3935
4238
  workspace.value?.blur();
3936
4239
  };
4240
+ let keycon;
3937
4241
  onMounted(() => {
3938
4242
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3939
4243
  workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
@@ -4010,6 +4314,12 @@ const _sfc_main$1 = defineComponent({
4010
4314
  }).keydown([ctrl, "numpad-"], (e) => {
4011
4315
  e.inputEvent.preventDefault();
4012
4316
  services?.uiService.zoom(-0.1);
4317
+ }).keydown([ctrl, "0"], (e) => {
4318
+ e.inputEvent.preventDefault();
4319
+ services?.uiService.set("zoom", services.uiService.calcZoom());
4320
+ }).keydown([ctrl, "1"], (e) => {
4321
+ e.inputEvent.preventDefault();
4322
+ services?.uiService.set("zoom", 1);
4013
4323
  });
4014
4324
  });
4015
4325
  onUnmounted(() => {
@@ -4017,39 +4327,33 @@ const _sfc_main$1 = defineComponent({
4017
4327
  workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
4018
4328
  keycon.destroy();
4019
4329
  });
4020
- return {
4021
- workspace,
4022
- page: computed(() => services?.editorService.get("page"))
4330
+ return (_ctx, _cache) => {
4331
+ return openBlock(), createElementBlock("div", {
4332
+ class: "m-editor-workspace",
4333
+ tabindex: "1",
4334
+ ref_key: "workspace",
4335
+ ref: workspace
4336
+ }, [
4337
+ renderSlot(_ctx.$slots, "stage", {}, () => [
4338
+ (openBlock(), createBlock(_sfc_main$2, {
4339
+ key: unref(page)?.id
4340
+ }))
4341
+ ]),
4342
+ renderSlot(_ctx.$slots, "workspace-content"),
4343
+ createVNode(_sfc_main$6, null, {
4344
+ "page-bar-title": withCtx(({ page: page2 }) => [
4345
+ renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
4346
+ ]),
4347
+ "page-bar-popover": withCtx(({ page: page2 }) => [
4348
+ renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
4349
+ ]),
4350
+ _: 3
4351
+ })
4352
+ ], 512);
4023
4353
  };
4024
4354
  }
4025
4355
  });
4026
4356
 
4027
- const _hoisted_1 = {
4028
- class: "m-editor-workspace",
4029
- tabindex: "1",
4030
- ref: "workspace"
4031
- };
4032
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4033
- const _component_magic_stage = resolveComponent("magic-stage");
4034
- const _component_page_bar = resolveComponent("page-bar");
4035
- return openBlock(), createElementBlock("div", _hoisted_1, [
4036
- (openBlock(), createBlock(_component_magic_stage, {
4037
- key: _ctx.page?.id
4038
- })),
4039
- renderSlot(_ctx.$slots, "workspace-content"),
4040
- createVNode(_component_page_bar, null, {
4041
- "page-bar-title": withCtx(({ page }) => [
4042
- renderSlot(_ctx.$slots, "page-bar-title", { page })
4043
- ]),
4044
- "page-bar-popover": withCtx(({ page }) => [
4045
- renderSlot(_ctx.$slots, "page-bar-popover", { page })
4046
- ]),
4047
- _: 3
4048
- })
4049
- ], 512);
4050
- }
4051
- const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4052
-
4053
4357
  class ComponentList extends BaseService {
4054
4358
  state = reactive({
4055
4359
  list: []
@@ -4063,136 +4367,20 @@ class ComponentList extends BaseService {
4063
4367
  getList() {
4064
4368
  return this.state.list;
4065
4369
  }
4066
- }
4067
- const componentListService = new ComponentList();
4068
-
4069
- const DEFAULT_LEFT_COLUMN_WIDTH = 310;
4070
- const MIN_LEFT_COLUMN_WIDTH = 45;
4071
- const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
4072
- const MIN_RIGHT_COLUMN_WIDTH = 1;
4073
- const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
4074
- const defaultColumnWidth = {
4075
- left: DEFAULT_LEFT_COLUMN_WIDTH,
4076
- center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
4077
- right: DEFAULT_RIGHT_COLUMN_WIDTH
4078
- };
4079
- const state = reactive({
4080
- uiSelectMode: false,
4081
- showSrc: false,
4082
- zoom: 1,
4083
- stageContainerRect: {
4084
- width: 0,
4085
- height: 0
4086
- },
4087
- stageRect: {
4088
- width: 375,
4089
- height: 817
4090
- },
4091
- columnWidth: defaultColumnWidth,
4092
- showGuides: true,
4093
- showRule: true,
4094
- propsPanelSize: "small"
4095
- });
4096
- class Ui extends BaseService {
4097
- constructor() {
4098
- super([]);
4099
- globalThis.addEventListener("resize", () => {
4100
- this.setColumnWidth({
4101
- center: "auto"
4102
- });
4103
- });
4104
- const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
4105
- if (columnWidthCacheData) {
4106
- try {
4107
- const columnWidthCache = JSON.parse(columnWidthCacheData);
4108
- this.setColumnWidth(columnWidthCache);
4109
- } catch (e) {
4110
- console.error(e);
4111
- }
4112
- }
4113
- }
4114
- set(name, value) {
4115
- const mask = editorService.get("stage")?.mask;
4116
- if (name === "columnWidth") {
4117
- this.setColumnWidth(value);
4118
- return;
4119
- }
4120
- if (name === "stageRect") {
4121
- this.setStageRect(value);
4122
- return;
4123
- }
4124
- if (name === "showGuides") {
4125
- mask?.showGuides(value);
4126
- }
4127
- if (name === "showRule") {
4128
- mask?.showRule(value);
4129
- }
4130
- state[name] = value;
4131
- if (name === "stageContainerRect") {
4132
- state.zoom = this.calcZoom();
4133
- }
4134
- }
4135
- get(name) {
4136
- return state[name];
4137
- }
4138
- zoom(zoom) {
4139
- this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
4140
- if (this.get("zoom") < 0.1)
4141
- this.set("zoom", 0.1);
4142
- }
4143
- setColumnWidth({ left, center, right }) {
4144
- const columnWidth = {
4145
- ...toRaw(this.get("columnWidth"))
4146
- };
4147
- if (left) {
4148
- columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
4149
- }
4150
- if (right) {
4151
- columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
4152
- }
4153
- if (!center || center === "auto") {
4154
- const bodyWidth = globalThis.document.body.clientWidth;
4155
- columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
4156
- if (columnWidth.center <= 0) {
4157
- columnWidth.left = defaultColumnWidth.left;
4158
- columnWidth.center = defaultColumnWidth.center;
4159
- columnWidth.right = defaultColumnWidth.right;
4160
- }
4161
- } else {
4162
- columnWidth.center = center;
4163
- }
4164
- globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
4165
- state.columnWidth = columnWidth;
4166
- }
4167
- setStageRect(value) {
4168
- state.stageRect = {
4169
- ...state.stageRect,
4170
- ...value
4171
- };
4172
- state.zoom = this.calcZoom();
4173
- }
4174
- calcZoom() {
4175
- const { stageRect, stageContainerRect } = state;
4176
- const { height, width } = stageContainerRect;
4177
- if (!width || !height)
4178
- return 1;
4179
- const stageWidth = stageRect.width + 30;
4180
- const stageHeight = stageRect.height + 30;
4181
- if (width > stageWidth && height > stageHeight) {
4182
- return 1;
4183
- }
4184
- return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
4370
+ destroy() {
4371
+ this.state.list = [];
4372
+ this.removeAllListeners();
4185
4373
  }
4186
4374
  }
4187
- const uiService = new Ui();
4375
+ const componentListService = new ComponentList();
4188
4376
 
4189
4377
  const _sfc_main = defineComponent({
4190
4378
  name: "m-editor",
4191
4379
  components: {
4192
- NavMenu,
4380
+ NavMenu: _sfc_main$f,
4193
4381
  Sidebar,
4194
- Workspace,
4195
- PropsPanel,
4382
+ Workspace: _sfc_main$1,
4383
+ PropsPanel: _sfc_main$e,
4196
4384
  Framework
4197
4385
  },
4198
4386
  props: {
@@ -4276,9 +4464,14 @@ const _sfc_main = defineComponent({
4276
4464
  },
4277
4465
  emits: ["props-panel-mounted", "update:modelValue"],
4278
4466
  setup(props, { emit }) {
4279
- editorService.on("root-change", () => {
4280
- const node = editorService.get("node") || props.defaultSelected;
4281
- node && editorService.select(node);
4467
+ editorService.on("root-change", (value) => {
4468
+ const node = editorService.get("node");
4469
+ const nodeId = node?.id || props.defaultSelected;
4470
+ if (nodeId && node !== value) {
4471
+ editorService.select(nodeId);
4472
+ } else {
4473
+ editorService.set("nodes", [value]);
4474
+ }
4282
4475
  emit("update:modelValue", toRaw(editorService.get("root")));
4283
4476
  });
4284
4477
  watch(() => props.modelValue, (modelValue) => editorService.set("root", modelValue), {
@@ -4311,7 +4504,15 @@ const _sfc_main = defineComponent({
4311
4504
  watch(() => props.stageRect, (stageRect) => stageRect && uiService.set("stageRect", stageRect), {
4312
4505
  immediate: true
4313
4506
  });
4314
- onUnmounted(() => editorService.destroy());
4507
+ uiService.initColumnWidth();
4508
+ onUnmounted(() => {
4509
+ editorService.destroy();
4510
+ historyService.destroy();
4511
+ propsService.destroy();
4512
+ uiService.destroy();
4513
+ componentListService.destroy();
4514
+ storageService.destroy();
4515
+ });
4315
4516
  const services = {
4316
4517
  componentListService,
4317
4518
  eventsService,
@@ -4361,6 +4562,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4361
4562
  "component-list-panel-header": withCtx(() => [
4362
4563
  renderSlot(_ctx.$slots, "component-list-panel-header")
4363
4564
  ]),
4565
+ "component-list-item": withCtx(({ component }) => [
4566
+ renderSlot(_ctx.$slots, "component-list-item", { component })
4567
+ ]),
4364
4568
  _: 3
4365
4569
  }, 8, ["data"])
4366
4570
  ])
@@ -4368,6 +4572,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4368
4572
  workspace: withCtx(() => [
4369
4573
  renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
4370
4574
  createVNode(_component_workspace, null, {
4575
+ stage: withCtx(() => [
4576
+ renderSlot(_ctx.$slots, "stage")
4577
+ ]),
4371
4578
  "workspace-content": withCtx(() => [
4372
4579
  renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
4373
4580
  ]),
@@ -4384,14 +4591,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4384
4591
  "props-panel": withCtx(() => [
4385
4592
  renderSlot(_ctx.$slots, "props-panel", {}, () => [
4386
4593
  createVNode(_component_props_panel, {
4387
- ref: "propsPanel",
4388
4594
  onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
4389
4595
  }, {
4390
4596
  "props-panel-header": withCtx(() => [
4391
4597
  renderSlot(_ctx.$slots, "props-panel-header")
4392
4598
  ]),
4393
4599
  _: 3
4394
- }, 512)
4600
+ })
4395
4601
  ])
4396
4602
  ]),
4397
4603
  empty: withCtx(() => [
@@ -4411,12 +4617,12 @@ const index = {
4411
4617
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4412
4618
  setConfig(option);
4413
4619
  app.component(Editor.name, Editor);
4414
- app.component("m-fields-ui-select", _sfc_main$l);
4620
+ app.component("m-fields-ui-select", _sfc_main$m);
4415
4621
  app.component(CodeLink.name, CodeLink);
4416
4622
  app.component(Code.name, Code);
4417
4623
  app.component(CodeEditor.name, CodeEditor);
4418
4624
  }
4419
4625
  };
4420
4626
 
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 };
4627
+ export { COPY_STORAGE_KEY, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$h as Icon, Keys, LayerOffset, LayerPanel, Layout, _sfc_main$e as PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$g 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, useStage, warn };
4422
4628
  //# sourceMappingURL=tmagic-editor.mjs.map