@tmagic/editor 1.3.6 → 1.3.8

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 (82) hide show
  1. package/LICENSE +5432 -0
  2. package/dist/style.css +34 -11
  3. package/dist/tmagic-editor.js +1360 -957
  4. package/dist/tmagic-editor.js.map +1 -1
  5. package/dist/tmagic-editor.umd.cjs +1382 -977
  6. package/dist/tmagic-editor.umd.cjs.map +1 -1
  7. package/package.json +17 -17
  8. package/src/Editor.vue +15 -7
  9. package/src/components/CodeBlockEditor.vue +2 -2
  10. package/src/components/ContentMenu.vue +5 -5
  11. package/src/components/ScrollBar.vue +2 -2
  12. package/src/components/ScrollViewer.vue +2 -2
  13. package/src/components/SplitView.vue +2 -2
  14. package/src/components/Tree.vue +1 -1
  15. package/src/components/TreeNode.vue +3 -3
  16. package/src/editorProps.ts +14 -4
  17. package/src/fields/PageFragmentSelect.vue +63 -0
  18. package/src/hooks/use-getso.ts +2 -2
  19. package/src/hooks/use-stage.ts +18 -1
  20. package/src/index.ts +3 -0
  21. package/src/initService.ts +15 -5
  22. package/src/layouts/AddPageBox.vue +16 -4
  23. package/src/layouts/CodeEditor.vue +2 -2
  24. package/src/layouts/Framework.vue +19 -3
  25. package/src/layouts/PropsPanel.vue +9 -7
  26. package/src/layouts/page-bar/AddButton.vue +48 -0
  27. package/src/layouts/page-bar/PageBar.vue +158 -0
  28. package/src/layouts/{workspace → page-bar}/PageBarScrollContainer.vue +61 -35
  29. package/src/layouts/page-bar/SwitchTypeButton.vue +45 -0
  30. package/src/layouts/sidebar/Sidebar.vue +2 -0
  31. package/src/layouts/sidebar/layer/LayerMenu.vue +39 -27
  32. package/src/layouts/sidebar/layer/LayerPanel.vue +7 -1
  33. package/src/layouts/sidebar/layer/use-click.ts +5 -3
  34. package/src/layouts/sidebar/layer/use-keybinding.ts +8 -8
  35. package/src/layouts/sidebar/layer/use-node-status.ts +3 -3
  36. package/src/layouts/workspace/Workspace.vue +6 -7
  37. package/src/layouts/workspace/viewer/NodeListMenu.vue +2 -2
  38. package/src/layouts/workspace/viewer/Stage.vue +12 -5
  39. package/src/layouts/workspace/viewer/ViewerMenu.vue +93 -80
  40. package/src/services/dataSource.ts +17 -0
  41. package/src/services/dep.ts +4 -0
  42. package/src/services/editor.ts +66 -35
  43. package/src/services/history.ts +6 -2
  44. package/src/services/keybinding.ts +48 -13
  45. package/src/theme/code-block.scss +0 -16
  46. package/src/theme/page-bar.scss +18 -1
  47. package/src/theme/page-fragment-select.scss +14 -0
  48. package/src/theme/theme.scss +1 -0
  49. package/src/theme/tree.scss +6 -0
  50. package/src/type.ts +23 -7
  51. package/src/utils/content-menu.ts +2 -2
  52. package/src/utils/editor.ts +22 -15
  53. package/src/utils/operator.ts +4 -4
  54. package/types/components/ToolButton.vue.d.ts +2 -2
  55. package/types/editorProps.d.ts +11 -2
  56. package/types/fields/PageFragmentSelect.vue.d.ts +31 -0
  57. package/types/index.d.ts +1 -0
  58. package/types/layouts/AddPageBox.vue.d.ts +14 -1
  59. package/types/layouts/Framework.vue.d.ts +14 -1
  60. package/types/layouts/PropsPanel.vue.d.ts +19 -10
  61. package/types/layouts/page-bar/AddButton.vue.d.ts +16 -0
  62. package/types/layouts/page-bar/PageBar.vue.d.ts +28 -0
  63. package/types/layouts/page-bar/PageBarScrollContainer.vue.d.ts +24 -0
  64. package/types/layouts/page-bar/SwitchTypeButton.vue.d.ts +20 -0
  65. package/types/layouts/sidebar/Sidebar.vue.d.ts +2 -0
  66. package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +22 -3
  67. package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +2 -0
  68. package/types/layouts/sidebar/layer/use-click.d.ts +25 -3
  69. package/types/layouts/sidebar/layer/use-keybinding.d.ts +1 -1
  70. package/types/layouts/workspace/Workspace.vue.d.ts +2 -0
  71. package/types/layouts/workspace/viewer/Stage.vue.d.ts +2 -0
  72. package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +8 -0
  73. package/types/services/dataSource.d.ts +2 -0
  74. package/types/services/dep.d.ts +1 -0
  75. package/types/services/editor.d.ts +3 -2
  76. package/types/services/history.d.ts +3 -2
  77. package/types/services/keybinding.d.ts +21 -1
  78. package/types/type.d.ts +26 -12
  79. package/types/utils/editor.d.ts +9 -7
  80. package/src/layouts/workspace/PageBar.vue +0 -87
  81. package/types/layouts/workspace/PageBar.vue.d.ts +0 -15
  82. package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +0 -9
@@ -1,13 +1,13 @@
1
- import { defineComponent, ref, watch, onMounted, onUnmounted, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, Fragment, resolveDynamicComponent, createTextVNode, createCommentVNode, toRaw, nextTick, mergeProps, toDisplayString, renderList, createStaticVNode, watchEffect, withModifiers, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, withDirectives, vShow, provide, Transition, toHandlers, onBeforeUnmount, mergeDefaults } from 'vue';
2
- import { FullScreen, Edit, View, Coin, Delete, Plus, Close, ArrowDown, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, ArrowRight, CopyDocument, DocumentCopy, Files, Hide, Goods, List, EditPen, Top, Bottom, ArrowLeftBold, ArrowRightBold, CaretBottom } from '@element-plus/icons-vue';
1
+ import { defineComponent, ref, watch, onMounted, onBeforeUnmount, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, Fragment, resolveDynamicComponent, createTextVNode, createCommentVNode, toRaw, nextTick, mergeProps, toDisplayString, renderList, createStaticVNode, watchEffect, withModifiers, renderSlot, normalizeProps, resolveDirective, withDirectives, createSlots, markRaw, getCurrentInstance, vShow, provide, Transition, toHandlers, mergeDefaults } from 'vue';
2
+ import { FullScreen, Edit, View, Coin, Delete, Plus, Close, ArrowDown, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, ArrowRight, CopyDocument, Files, Hide, Goods, List, EditPen, Top, Bottom } from '@element-plus/icons-vue';
3
3
  import { throttle, isEmpty, cloneDeep, mergeWith, get, set, isObject, uniq, map, has, pick, keys } from 'lodash-es';
4
4
  import * as monaco from 'monaco-editor';
5
5
  import serialize from 'serialize-javascript';
6
- import { TMagicButton, TMagicCard, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox, TMagicIcon, getConfig as getConfig$1, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
6
+ import { TMagicButton, TMagicCard, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox, TMagicIcon, getConfig as getConfig$1, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
7
7
  import { HookType, NodeType, ActionType } from '@tmagic/schema';
8
8
  import { MFormBox, MFormDrawer, MForm, createValues, MSelect } from '@tmagic/form';
9
9
  import { MagicTable } from '@tmagic/table';
10
- import { guid, isPop, getNodePath, isNumber, isPage, toLine, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, convertToNumber, getNodes } from '@tmagic/utils';
10
+ import { guid, isPage, isPageFragment, isPop, getNodePath, isNumber, toLine, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, convertToNumber, getNodes } from '@tmagic/utils';
11
11
  import Gesto from 'gesto';
12
12
  import Moveable from 'moveable';
13
13
  import { Watcher, DepTargetType, createRelatedCompTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
@@ -23,10 +23,10 @@ const setConfig = (option) => {
23
23
  };
24
24
  const getConfig = (key) => $TMAGIC_EDITOR[key];
25
25
 
26
- const _hoisted_1$s = {
26
+ const _hoisted_1$t = {
27
27
  class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
28
28
  };
29
- const _sfc_main$Q = /* @__PURE__ */ defineComponent({
29
+ const _sfc_main$T = /* @__PURE__ */ defineComponent({
30
30
  ...{
31
31
  name: "MEditorCodeEditor"
32
32
  },
@@ -152,7 +152,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
152
152
  loading.value = true;
153
153
  init();
154
154
  });
155
- onUnmounted(() => {
155
+ onBeforeUnmount(() => {
156
156
  resizeObserver.disconnect();
157
157
  });
158
158
  const fullScreen = ref(false);
@@ -184,7 +184,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
184
184
  }
185
185
  });
186
186
  return (_ctx, _cache) => {
187
- return openBlock(), createElementBlock("div", _hoisted_1$s, [
187
+ return openBlock(), createElementBlock("div", _hoisted_1$t, [
188
188
  (openBlock(), createBlock(Teleport, {
189
189
  to: "body",
190
190
  disabled: !fullScreen.value
@@ -212,7 +212,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
212
212
  }
213
213
  });
214
214
 
215
- const _sfc_main$P = /* @__PURE__ */ defineComponent({
215
+ const _sfc_main$S = /* @__PURE__ */ defineComponent({
216
216
  ...{
217
217
  name: "MEditorCode"
218
218
  },
@@ -237,7 +237,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
237
237
  emit("change", v);
238
238
  };
239
239
  return (_ctx, _cache) => {
240
- return openBlock(), createBlock(_sfc_main$Q, {
240
+ return openBlock(), createBlock(_sfc_main$T, {
241
241
  height: _ctx.config.height,
242
242
  "init-values": _ctx.model[_ctx.name],
243
243
  language: _ctx.config.language,
@@ -252,7 +252,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
252
252
  }
253
253
  });
254
254
 
255
- const _sfc_main$O = /* @__PURE__ */ defineComponent({
255
+ const _sfc_main$R = /* @__PURE__ */ defineComponent({
256
256
  ...{
257
257
  name: "MEditorCodeLink"
258
258
  },
@@ -332,7 +332,7 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
332
332
  }
333
333
  });
334
334
 
335
- const _sfc_main$N = /* @__PURE__ */ defineComponent({
335
+ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
336
336
  ...{
337
337
  name: "MEditorCodeSelect"
338
338
  },
@@ -405,11 +405,11 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
405
405
  }
406
406
  });
407
407
 
408
- const _hoisted_1$r = { style: { "display": "flex", "margin-bottom": "10px" } };
409
- const _hoisted_2$j = { style: { "flex": "1" } };
410
- const _hoisted_3$7 = { style: { "flex": "1" } };
411
- const _hoisted_4$5 = { class: "dialog-footer" };
412
- const _sfc_main$M = /* @__PURE__ */ defineComponent({
408
+ const _hoisted_1$s = { style: { "display": "flex", "margin-bottom": "10px" } };
409
+ const _hoisted_2$k = { style: { "flex": "1" } };
410
+ const _hoisted_3$8 = { style: { "flex": "1" } };
411
+ const _hoisted_4$7 = { class: "dialog-footer" };
412
+ const _sfc_main$P = /* @__PURE__ */ defineComponent({
413
413
  ...{
414
414
  name: "MEditorCodeBlockEditor"
415
415
  },
@@ -432,7 +432,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
432
432
  height.value = globalThis.innerHeight;
433
433
  };
434
434
  globalThis.addEventListener("resize", windowReizehandler);
435
- onUnmounted(() => {
435
+ onBeforeUnmount(() => {
436
436
  globalThis.removeEventListener("resize", windowReizehandler);
437
437
  });
438
438
  const magicVsEditor = ref();
@@ -630,7 +630,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
630
630
  fullscreen: ""
631
631
  }, {
632
632
  footer: withCtx(() => [
633
- createElementVNode("span", _hoisted_4$5, [
633
+ createElementVNode("span", _hoisted_4$7, [
634
634
  createVNode(unref(TMagicButton), {
635
635
  size: "small",
636
636
  onClick: _cache[1] || (_cache[1] = ($event) => difVisible.value = false)
@@ -653,8 +653,8 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
653
653
  ])
654
654
  ]),
655
655
  default: withCtx(() => [
656
- createElementVNode("div", _hoisted_1$r, [
657
- createElementVNode("div", _hoisted_2$j, [
656
+ createElementVNode("div", _hoisted_1$s, [
657
+ createElementVNode("div", _hoisted_2$k, [
658
658
  createVNode(unref(TMagicTag), {
659
659
  size: "small",
660
660
  type: "info"
@@ -665,7 +665,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
665
665
  _: 1
666
666
  })
667
667
  ]),
668
- createElementVNode("div", _hoisted_3$7, [
668
+ createElementVNode("div", _hoisted_3$8, [
669
669
  createVNode(unref(TMagicTag), {
670
670
  size: "small",
671
671
  type: "success"
@@ -677,7 +677,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
677
677
  })
678
678
  ])
679
679
  ]),
680
- difVisible.value ? (openBlock(), createBlock(_sfc_main$Q, {
680
+ difVisible.value ? (openBlock(), createBlock(_sfc_main$T, {
681
681
  key: 0,
682
682
  ref_key: "magicVsEditor",
683
683
  ref: magicVsEditor,
@@ -1133,6 +1133,22 @@ class DataSource extends BaseService {
1133
1133
  events: {},
1134
1134
  methods: {}
1135
1135
  });
1136
+ constructor() {
1137
+ super([
1138
+ { name: "getFormConfig", isAsync: false },
1139
+ { name: "setFormConfig", isAsync: false },
1140
+ { name: "getFormValue", isAsync: false },
1141
+ { name: "setFormValue", isAsync: false },
1142
+ { name: "getFormEvent", isAsync: false },
1143
+ { name: "setFormEvent", isAsync: false },
1144
+ { name: "getFormMethod", isAsync: false },
1145
+ { name: "setFormMethod", isAsync: false },
1146
+ { name: "add", isAsync: false },
1147
+ { name: "update", isAsync: false },
1148
+ { name: "remove", isAsync: false },
1149
+ { name: "createId", isAsync: false }
1150
+ ]);
1151
+ }
1136
1152
  set(name, value) {
1137
1153
  this.state[name] = value;
1138
1154
  }
@@ -1608,25 +1624,33 @@ var DragType = /* @__PURE__ */ ((DragType2) => {
1608
1624
  const UI_SELECT_MODE_EVENT_NAME = "ui-select";
1609
1625
 
1610
1626
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
1611
- const getPageList = (app) => {
1612
- if (app.items && Array.isArray(app.items)) {
1613
- return app.items.filter((item) => item.type === NodeType.PAGE);
1614
- }
1615
- return [];
1627
+ const getPageList = (root) => {
1628
+ if (!root)
1629
+ return [];
1630
+ if (!Array.isArray(root.items))
1631
+ return [];
1632
+ return root.items.filter((item) => isPage(item));
1633
+ };
1634
+ const getPageFragmentList = (root) => {
1635
+ if (!root)
1636
+ return [];
1637
+ if (!Array.isArray(root.items))
1638
+ return [];
1639
+ return root.items.filter((item) => isPageFragment(item));
1616
1640
  };
1617
1641
  const getPageNameList = (pages) => pages.map((page) => page.name || "index");
1618
- const generatePageName = (pageNameList) => {
1642
+ const generatePageName = (pageNameList, type) => {
1619
1643
  let pageLength = pageNameList.length;
1620
1644
  if (!pageLength)
1621
- return "index";
1622
- let pageName = `page_${pageLength}`;
1645
+ return `${type}_index`;
1646
+ let pageName = `${type}_${pageLength}`;
1623
1647
  while (pageNameList.includes(pageName)) {
1624
1648
  pageLength += 1;
1625
- pageName = `page_${pageLength}`;
1649
+ pageName = `${type}_${pageLength}`;
1626
1650
  }
1627
1651
  return pageName;
1628
1652
  };
1629
- const generatePageNameByApp = (app) => generatePageName(getPageNameList(getPageList(app)));
1653
+ const generatePageNameByApp = (app, type) => generatePageName(getPageNameList(type === "page" ? getPageList(app) : getPageFragmentList(app)), type);
1630
1654
  const isFixed = (node) => node.style?.position === "fixed";
1631
1655
  const getNodeIndex = (id, parent) => {
1632
1656
  const items = parent?.items || [];
@@ -1668,7 +1692,7 @@ const getInitPositionStyle = (style = {}, layout) => {
1668
1692
  }
1669
1693
  return style;
1670
1694
  };
1671
- const setChilrenLayout = (node, layout) => {
1695
+ const setChildrenLayout = (node, layout) => {
1672
1696
  node.items?.forEach((child) => {
1673
1697
  setLayout(child, layout);
1674
1698
  });
@@ -1810,6 +1834,9 @@ class Dep extends BaseService {
1810
1834
  clear(nodes) {
1811
1835
  return this.watcher.clear(nodes);
1812
1836
  }
1837
+ clearByType(type, nodes) {
1838
+ return this.watcher.clearByType(type, nodes);
1839
+ }
1813
1840
  hasTarget(id, type = DepTargetType.DEFAULT) {
1814
1841
  return this.watcher.hasTarget(id, type);
1815
1842
  }
@@ -1880,6 +1907,9 @@ class History extends BaseService {
1880
1907
  }
1881
1908
  reset() {
1882
1909
  this.state.pageSteps = {};
1910
+ this.resetPage();
1911
+ }
1912
+ resetPage() {
1883
1913
  this.state.pageId = void 0;
1884
1914
  this.state.canRedo = false;
1885
1915
  this.state.canUndo = false;
@@ -2269,9 +2299,12 @@ class Editor extends BaseService {
2269
2299
  node: null,
2270
2300
  nodes: [],
2271
2301
  stage: null,
2302
+ stageLoading: true,
2272
2303
  highlightNode: null,
2273
2304
  modifiedNodeIds: /* @__PURE__ */ new Map(),
2274
- pageLength: 0
2305
+ pageLength: 0,
2306
+ pageFragmentLength: 0,
2307
+ disabledMultiSelect: false
2275
2308
  });
2276
2309
  isHistoryStateChange = false;
2277
2310
  constructor() {
@@ -2305,7 +2338,7 @@ class Editor extends BaseService {
2305
2338
  }
2306
2339
  /**
2307
2340
  * 设置当前指点节点配置
2308
- * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength'
2341
+ * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength' | 'pageFragmentLength
2309
2342
  * @param value MNode
2310
2343
  */
2311
2344
  set(name, value) {
@@ -2318,17 +2351,22 @@ class Editor extends BaseService {
2318
2351
  if (Array.isArray(value)) {
2319
2352
  throw new Error("root 不能为数组");
2320
2353
  }
2321
- if (value && isObject(value) && !(value instanceof StageCore) && !(value instanceof Map)) {
2322
- this.state.pageLength = value.items?.length || 0;
2354
+ if (value && isObject(value)) {
2355
+ const app = value;
2356
+ this.state.pageLength = getPageList(app).length || 0;
2357
+ this.state.pageFragmentLength = getPageFragmentList(app).length || 0;
2358
+ this.state.stageLoading = this.state.pageLength !== 0;
2323
2359
  } else {
2324
2360
  this.state.pageLength = 0;
2361
+ this.state.pageFragmentLength = 0;
2362
+ this.state.stageLoading = false;
2325
2363
  }
2326
2364
  this.emit("root-change", value, preValue);
2327
2365
  }
2328
2366
  }
2329
2367
  /**
2330
2368
  * 获取当前指点节点配置
2331
- * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength'
2369
+ * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength' | 'pageFragmentLength'
2332
2370
  * @returns MNode
2333
2371
  */
2334
2372
  get(name) {
@@ -2363,7 +2401,7 @@ class Editor extends BaseService {
2363
2401
  info.node = path[path.length - 1];
2364
2402
  info.parent = path[path.length - 2];
2365
2403
  path.forEach((item) => {
2366
- if (item.type === NodeType.PAGE) {
2404
+ if (isPage(item) || isPageFragment(item)) {
2367
2405
  info.page = item;
2368
2406
  return;
2369
2407
  }
@@ -2487,6 +2525,16 @@ class Editor extends BaseService {
2487
2525
  });
2488
2526
  this.set("nodes", nodes);
2489
2527
  }
2528
+ selectRoot() {
2529
+ const root = this.get("root");
2530
+ if (!root)
2531
+ return;
2532
+ this.set("nodes", [root]);
2533
+ this.set("parent", null);
2534
+ this.set("page", null);
2535
+ this.set("stage", null);
2536
+ this.set("highlightNode", null);
2537
+ }
2490
2538
  async doAdd(node, parent) {
2491
2539
  const root = this.get("root");
2492
2540
  if (!root)
@@ -2495,10 +2543,10 @@ class Editor extends BaseService {
2495
2543
  const stage = this.get("stage");
2496
2544
  if (!curNode)
2497
2545
  throw new Error("当前选中节点为空");
2498
- if ((parent.type === NodeType.ROOT || curNode?.type === NodeType.ROOT) && node.type !== NodeType.PAGE) {
2546
+ if ((parent.type === NodeType.ROOT || curNode?.type === NodeType.ROOT) && !(isPage(node) || isPageFragment(node))) {
2499
2547
  throw new Error("app下不能添加组件");
2500
2548
  }
2501
- if (parent.id !== curNode.id && node.type !== NodeType.PAGE) {
2549
+ if (parent.id !== curNode.id && !(isPage(node) || isPageFragment(node))) {
2502
2550
  const index = parent.items.indexOf(curNode);
2503
2551
  parent.items?.splice(index + 1, 0, node);
2504
2552
  } else {
@@ -2540,7 +2588,7 @@ class Editor extends BaseService {
2540
2588
  const newNodes = await Promise.all(
2541
2589
  addNodes.map((node) => {
2542
2590
  const root = this.get("root");
2543
- if (isPage(node) && root) {
2591
+ if ((isPage(node) || isPageFragment(node)) && root) {
2544
2592
  return this.doAdd(node, root);
2545
2593
  }
2546
2594
  const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
@@ -2557,11 +2605,13 @@ class Editor extends BaseService {
2557
2605
  await this.select(newNodes[0]);
2558
2606
  if (isPage(newNodes[0])) {
2559
2607
  this.state.pageLength += 1;
2608
+ } else if (isPageFragment(newNodes[0])) {
2609
+ this.state.pageFragmentLength += 1;
2560
2610
  } else {
2561
2611
  stage?.select(newNodes[0].id);
2562
2612
  }
2563
2613
  }
2564
- if (!isPage(newNodes[0])) {
2614
+ if (!(isPage(newNodes[0]) || isPageFragment(newNodes[0]))) {
2565
2615
  this.pushHistoryState();
2566
2616
  }
2567
2617
  this.emit("add", newNodes);
@@ -2571,7 +2621,7 @@ class Editor extends BaseService {
2571
2621
  const root = this.get("root");
2572
2622
  if (!root)
2573
2623
  throw new Error("root不能为空");
2574
- const { parent, node: curNode } = this.getNodeInfo(node.id);
2624
+ const { parent, node: curNode } = this.getNodeInfo(node.id, false);
2575
2625
  if (!parent || !curNode)
2576
2626
  throw new Error("找不要删除的节点");
2577
2627
  const index = getNodeIndex(curNode.id, parent);
@@ -2580,26 +2630,31 @@ class Editor extends BaseService {
2580
2630
  parent.items?.splice(index, 1);
2581
2631
  const stage = this.get("stage");
2582
2632
  stage?.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
2583
- if (node.type === NodeType.PAGE) {
2584
- this.state.pageLength -= 1;
2585
- if (root.items[0]) {
2586
- await this.select(root.items[0]);
2587
- stage?.select(root.items[0].id);
2633
+ const selectDefault = async (pages) => {
2634
+ if (pages[0]) {
2635
+ await this.select(pages[0]);
2636
+ stage?.select(pages[0].id);
2588
2637
  } else {
2589
- this.set("nodes", [root]);
2590
- this.set("parent", null);
2591
- this.set("page", null);
2592
- this.set("stage", null);
2593
- this.set("highlightNode", null);
2594
- this.resetModifiedNodeId();
2595
- historyService.reset();
2596
- return;
2638
+ this.selectRoot();
2639
+ historyService.resetPage();
2597
2640
  }
2641
+ };
2642
+ const rootItems = root.items || [];
2643
+ if (isPage(node)) {
2644
+ this.state.pageLength -= 1;
2645
+ await selectDefault(getPageList(root));
2646
+ } else if (isPageFragment(node)) {
2647
+ this.state.pageFragmentLength -= 1;
2648
+ await selectDefault(getPageFragmentList(root));
2598
2649
  } else {
2599
2650
  await this.select(parent);
2600
2651
  stage?.select(parent.id);
2652
+ this.addModifiedNodeId(parent.id);
2653
+ }
2654
+ if (!rootItems.length) {
2655
+ this.resetModifiedNodeId();
2656
+ historyService.reset();
2601
2657
  }
2602
- this.addModifiedNodeId(parent.id);
2603
2658
  }
2604
2659
  /**
2605
2660
  * 删除组件
@@ -2608,7 +2663,7 @@ class Editor extends BaseService {
2608
2663
  async remove(nodeOrNodeList) {
2609
2664
  const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
2610
2665
  await Promise.all(nodes.map((node) => this.doRemove(node)));
2611
- if (!isPage(nodes[0])) {
2666
+ if (!(isPage(nodes[0]) || isPageFragment(nodes[0]))) {
2612
2667
  this.pushHistoryState();
2613
2668
  }
2614
2669
  this.emit("remove", nodes);
@@ -2648,7 +2703,7 @@ class Editor extends BaseService {
2648
2703
  const newLayout = await this.getLayout(newConfig);
2649
2704
  const layout = await this.getLayout(node);
2650
2705
  if (Array.isArray(newConfig.items) && newLayout !== layout) {
2651
- newConfig = setChilrenLayout(newConfig, newLayout);
2706
+ newConfig = setChildrenLayout(newConfig, newLayout);
2652
2707
  }
2653
2708
  parentNodeItems[index] = newConfig;
2654
2709
  const nodes = this.get("nodes");
@@ -2660,7 +2715,7 @@ class Editor extends BaseService {
2660
2715
  parentId: parent.id,
2661
2716
  root: cloneDeep(root)
2662
2717
  });
2663
- if (newConfig.type === NodeType.PAGE) {
2718
+ if (isPage(newConfig) || isPageFragment(newConfig)) {
2664
2719
  this.set("page", newConfig);
2665
2720
  }
2666
2721
  this.addModifiedNodeId(newConfig.id);
@@ -2728,7 +2783,7 @@ class Editor extends BaseService {
2728
2783
  */
2729
2784
  copyWithRelated(config) {
2730
2785
  const copyNodes = Array.isArray(config) ? config : [config];
2731
- depService.getTarget(DepTargetType.RELATED_COMP_WHEN_COPY, DepTargetType.RELATED_COMP_WHEN_COPY)?.removeDep();
2786
+ depService.clearByType(DepTargetType.RELATED_COMP_WHEN_COPY);
2732
2787
  depService.collect(copyNodes, true, DepTargetType.RELATED_COMP_WHEN_COPY);
2733
2788
  const customTarget = depService.getTarget(
2734
2789
  DepTargetType.RELATED_COMP_WHEN_COPY,
@@ -3109,8 +3164,8 @@ const beforePaste = async (position, config) => {
3109
3164
  };
3110
3165
  }
3111
3166
  const root = editorService.get("root");
3112
- if (isPage(pasteConfig) && root) {
3113
- pasteConfig.name = generatePageNameByApp(root);
3167
+ if ((isPage(pasteConfig) || isPageFragment(pasteConfig)) && root) {
3168
+ pasteConfig.name = generatePageNameByApp(root, isPage(pasteConfig) ? NodeType.PAGE : NodeType.PAGE_FRAGMENT);
3114
3169
  }
3115
3170
  return pasteConfig;
3116
3171
  })
@@ -3148,7 +3203,7 @@ const getDefaultConfig = async (addNode, parentNode) => {
3148
3203
  return newNode;
3149
3204
  };
3150
3205
 
3151
- const _sfc_main$L = /* @__PURE__ */ defineComponent({
3206
+ const _sfc_main$O = /* @__PURE__ */ defineComponent({
3152
3207
  ...{
3153
3208
  name: "MEditorCodeParams"
3154
3209
  },
@@ -3198,8 +3253,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
3198
3253
  }
3199
3254
  });
3200
3255
 
3201
- const _hoisted_1$q = ["src"];
3202
- const _sfc_main$K = /* @__PURE__ */ defineComponent({
3256
+ const _hoisted_1$r = ["src"];
3257
+ const _sfc_main$N = /* @__PURE__ */ defineComponent({
3203
3258
  ...{
3204
3259
  name: "MEditorIcon"
3205
3260
  },
@@ -3223,7 +3278,7 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
3223
3278
  class: "magic-editor-icon"
3224
3279
  }, {
3225
3280
  default: withCtx(() => [
3226
- createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$q)
3281
+ createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$r)
3227
3282
  ]),
3228
3283
  _: 1
3229
3284
  })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
@@ -3301,9 +3356,9 @@ const useCodeBlockEdit = (codeBlockService) => {
3301
3356
  };
3302
3357
  };
3303
3358
 
3304
- const _hoisted_1$p = { class: "m-fields-code-select-col" };
3305
- const _hoisted_2$i = { class: "code-select-container" };
3306
- const _sfc_main$J = /* @__PURE__ */ defineComponent({
3359
+ const _hoisted_1$q = { class: "m-fields-code-select-col" };
3360
+ const _hoisted_2$j = { class: "code-select-container" };
3361
+ const _sfc_main$M = /* @__PURE__ */ defineComponent({
3307
3362
  ...{
3308
3363
  name: "MEditorCodeSelectCol"
3309
3364
  },
@@ -3376,8 +3431,8 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
3376
3431
  const { codeBlockEditor, codeConfig, editCode, submitCodeBlockHandler } = useCodeBlockEdit(services?.codeBlockService);
3377
3432
  return (_ctx, _cache) => {
3378
3433
  const _component_m_form_container = resolveComponent("m-form-container");
3379
- return openBlock(), createElementBlock("div", _hoisted_1$p, [
3380
- createElementVNode("div", _hoisted_2$i, [
3434
+ return openBlock(), createElementBlock("div", _hoisted_1$q, [
3435
+ createElementVNode("div", _hoisted_2$j, [
3381
3436
  createVNode(_component_m_form_container, {
3382
3437
  class: "select",
3383
3438
  config: selectConfig,
@@ -3385,14 +3440,14 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
3385
3440
  size: _ctx.size,
3386
3441
  onChange: onParamsChangeHandler
3387
3442
  }, null, 8, ["model", "size"]),
3388
- _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$K, {
3443
+ _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$N, {
3389
3444
  key: 0,
3390
3445
  class: "icon",
3391
3446
  icon: !_ctx.disabled ? unref(Edit) : unref(View),
3392
3447
  onClick: _cache[0] || (_cache[0] = ($event) => unref(editCode)(_ctx.model[_ctx.name]))
3393
3448
  }, null, 8, ["icon"])) : createCommentVNode("", true)
3394
3449
  ]),
3395
- paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$L, {
3450
+ paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$O, {
3396
3451
  key: 0,
3397
3452
  name: "params",
3398
3453
  model: _ctx.model,
@@ -3400,7 +3455,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
3400
3455
  "params-config": paramsConfig.value,
3401
3456
  onChange: onParamsChangeHandler
3402
3457
  }, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true),
3403
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$M, {
3458
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$P, {
3404
3459
  key: 1,
3405
3460
  ref_key: "codeBlockEditor",
3406
3461
  ref: codeBlockEditor,
@@ -3413,9 +3468,9 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
3413
3468
  }
3414
3469
  });
3415
3470
 
3416
- const _hoisted_1$o = { class: "m-editor-data-source-fields" };
3417
- const _hoisted_2$h = { class: "m-editor-data-source-fields-footer" };
3418
- const _sfc_main$I = /* @__PURE__ */ defineComponent({
3471
+ const _hoisted_1$p = { class: "m-editor-data-source-fields" };
3472
+ const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
3473
+ const _sfc_main$L = /* @__PURE__ */ defineComponent({
3419
3474
  ...{
3420
3475
  name: "MEditorDataSourceFields"
3421
3476
  },
@@ -3650,12 +3705,12 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
3650
3705
  }
3651
3706
  };
3652
3707
  return (_ctx, _cache) => {
3653
- return openBlock(), createElementBlock("div", _hoisted_1$o, [
3708
+ return openBlock(), createElementBlock("div", _hoisted_1$p, [
3654
3709
  createVNode(unref(MagicTable), {
3655
3710
  data: _ctx.model[_ctx.name],
3656
3711
  columns: fieldColumns
3657
3712
  }, null, 8, ["data"]),
3658
- createElementVNode("div", _hoisted_2$h, [
3713
+ createElementVNode("div", _hoisted_2$i, [
3659
3714
  createVNode(unref(TMagicButton), {
3660
3715
  size: "small",
3661
3716
  disabled: _ctx.disabled,
@@ -3707,7 +3762,7 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
3707
3762
  }
3708
3763
  });
3709
3764
 
3710
- const _sfc_main$H = /* @__PURE__ */ defineComponent({
3765
+ const _sfc_main$K = /* @__PURE__ */ defineComponent({
3711
3766
  __name: "DataSourceFieldSelect",
3712
3767
  props: {
3713
3768
  config: {},
@@ -3762,10 +3817,10 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
3762
3817
  }
3763
3818
  });
3764
3819
 
3765
- const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
3766
- const _hoisted_2$g = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
3767
- const _hoisted_3$6 = { class: "el-input__inner" };
3768
- const _sfc_main$G = /* @__PURE__ */ defineComponent({
3820
+ const _hoisted_1$o = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
3821
+ const _hoisted_2$h = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
3822
+ const _hoisted_3$7 = { class: "el-input__inner" };
3823
+ const _sfc_main$J = /* @__PURE__ */ defineComponent({
3769
3824
  ...{
3770
3825
  name: "MEditorDataSourceInput"
3771
3826
  },
@@ -3955,12 +4010,12 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
3955
4010
  }
3956
4011
  ), {
3957
4012
  suffix: withCtx(() => [
3958
- createVNode(_sfc_main$K, { icon: unref(Coin) }, null, 8, ["icon"])
4013
+ createVNode(_sfc_main$N, { icon: unref(Coin) }, null, 8, ["icon"])
3959
4014
  ]),
3960
4015
  default: withCtx(({ item }) => [
3961
- createElementVNode("div", _hoisted_1$n, [
4016
+ createElementVNode("div", _hoisted_1$o, [
3962
4017
  createElementVNode("div", null, toDisplayString(item.text), 1),
3963
- createElementVNode("span", _hoisted_2$g, toDisplayString(item.value), 1)
4018
+ createElementVNode("span", _hoisted_2$h, toDisplayString(item.value), 1)
3964
4019
  ])
3965
4020
  ]),
3966
4021
  _: 1
@@ -3972,7 +4027,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
3972
4027
  createElementVNode("div", {
3973
4028
  class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
3974
4029
  }, [
3975
- createElementVNode("div", _hoisted_3$6, [
4030
+ createElementVNode("div", _hoisted_3$7, [
3976
4031
  (openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
3977
4032
  return openBlock(), createElementBlock(Fragment, null, [
3978
4033
  item.type === "text" ? (openBlock(), createElementBlock("span", {
@@ -3990,7 +4045,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
3990
4045
  }, 1032, ["size"])) : createCommentVNode("", true)
3991
4046
  ], 64);
3992
4047
  }), 256)),
3993
- createVNode(_sfc_main$K, {
4048
+ createVNode(_sfc_main$N, {
3994
4049
  class: "tmagic-data-source-input-icon",
3995
4050
  icon: unref(Coin)
3996
4051
  }, null, 8, ["icon"])
@@ -4073,9 +4128,9 @@ const useDataSourceMethod = () => {
4073
4128
  };
4074
4129
  };
4075
4130
 
4076
- const _hoisted_1$m = { class: "m-editor-data-source-methods" };
4077
- const _hoisted_2$f = { class: "m-editor-data-source-methods-footer" };
4078
- const _sfc_main$F = /* @__PURE__ */ defineComponent({
4131
+ const _hoisted_1$n = { class: "m-editor-data-source-methods" };
4132
+ const _hoisted_2$g = { class: "m-editor-data-source-methods-footer" };
4133
+ const _sfc_main$I = /* @__PURE__ */ defineComponent({
4079
4134
  ...{
4080
4135
  name: "MEditorDataSourceMethods"
4081
4136
  },
@@ -4145,12 +4200,12 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
4145
4200
  emit("change", props.model[props.name]);
4146
4201
  };
4147
4202
  return (_ctx, _cache) => {
4148
- return openBlock(), createElementBlock("div", _hoisted_1$m, [
4203
+ return openBlock(), createElementBlock("div", _hoisted_1$n, [
4149
4204
  createVNode(unref(MagicTable), {
4150
4205
  data: _ctx.model[_ctx.name],
4151
4206
  columns: methodColumns
4152
4207
  }, null, 8, ["data"]),
4153
- createElementVNode("div", _hoisted_2$f, [
4208
+ createElementVNode("div", _hoisted_2$g, [
4154
4209
  createVNode(unref(TMagicButton), {
4155
4210
  size: "small",
4156
4211
  type: "primary",
@@ -4164,7 +4219,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
4164
4219
  _: 1
4165
4220
  }, 8, ["disabled"])
4166
4221
  ]),
4167
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$M, {
4222
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$P, {
4168
4223
  key: 0,
4169
4224
  ref_key: "codeBlockEditor",
4170
4225
  ref: codeBlockEditor,
@@ -4179,9 +4234,9 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
4179
4234
  }
4180
4235
  });
4181
4236
 
4182
- const _hoisted_1$l = { class: "m-fields-data-source-method-select" };
4183
- const _hoisted_2$e = { class: "data-source-method-select-container" };
4184
- const _sfc_main$E = /* @__PURE__ */ defineComponent({
4237
+ const _hoisted_1$m = { class: "m-fields-data-source-method-select" };
4238
+ const _hoisted_2$f = { class: "data-source-method-select-container" };
4239
+ const _sfc_main$H = /* @__PURE__ */ defineComponent({
4185
4240
  ...{
4186
4241
  name: "MEditorDataSourceMethodSelect"
4187
4242
  },
@@ -4264,22 +4319,22 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
4264
4319
  };
4265
4320
  return (_ctx, _cache) => {
4266
4321
  const _component_m_form_container = resolveComponent("m-form-container");
4267
- return openBlock(), createElementBlock("div", _hoisted_1$l, [
4268
- createElementVNode("div", _hoisted_2$e, [
4322
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
4323
+ createElementVNode("div", _hoisted_2$f, [
4269
4324
  createVNode(_component_m_form_container, {
4270
4325
  class: "select",
4271
4326
  config: cascaderConfig.value,
4272
4327
  model: _ctx.model,
4273
4328
  onChange: onChangeHandler
4274
4329
  }, null, 8, ["config", "model"]),
4275
- _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$K, {
4330
+ _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$N, {
4276
4331
  key: 0,
4277
4332
  class: "icon",
4278
4333
  icon: !_ctx.disabled ? unref(Edit) : unref(View),
4279
4334
  onClick: editCodeHandler
4280
4335
  }, null, 8, ["icon"])) : createCommentVNode("", true)
4281
4336
  ]),
4282
- paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$L, {
4337
+ paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$O, {
4283
4338
  key: 0,
4284
4339
  name: "params",
4285
4340
  model: _ctx.model,
@@ -4288,7 +4343,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
4288
4343
  "params-config": paramsConfig.value,
4289
4344
  onChange: onChangeHandler
4290
4345
  }, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true),
4291
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$M, {
4346
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$P, {
4292
4347
  key: 1,
4293
4348
  ref_key: "codeBlockEditor",
4294
4349
  ref: codeBlockEditor,
@@ -4301,9 +4356,9 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
4301
4356
  }
4302
4357
  });
4303
4358
 
4304
- const _hoisted_1$k = { class: "m-editor-data-source-fields" };
4305
- const _hoisted_2$d = { class: "m-editor-data-source-fields-footer" };
4306
- const _sfc_main$D = /* @__PURE__ */ defineComponent({
4359
+ const _hoisted_1$l = { class: "m-editor-data-source-fields" };
4360
+ const _hoisted_2$e = { class: "m-editor-data-source-fields-footer" };
4361
+ const _sfc_main$G = /* @__PURE__ */ defineComponent({
4307
4362
  ...{
4308
4363
  name: "MEditorDataSourceMocks"
4309
4364
  },
@@ -4390,7 +4445,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4390
4445
  const columns = [
4391
4446
  {
4392
4447
  type: "expand",
4393
- component: _sfc_main$Q,
4448
+ component: _sfc_main$T,
4394
4449
  props: (row) => ({
4395
4450
  initValues: row.data,
4396
4451
  language: "json",
@@ -4499,12 +4554,12 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4499
4554
  });
4500
4555
  };
4501
4556
  return (_ctx, _cache) => {
4502
- return openBlock(), createElementBlock("div", _hoisted_1$k, [
4557
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
4503
4558
  createVNode(unref(MagicTable), {
4504
4559
  data: _ctx.model[_ctx.name],
4505
4560
  columns
4506
4561
  }, null, 8, ["data"]),
4507
- createElementVNode("div", _hoisted_2$d, [
4562
+ createElementVNode("div", _hoisted_2$e, [
4508
4563
  createVNode(unref(TMagicButton), {
4509
4564
  size: "small",
4510
4565
  type: "primary",
@@ -4535,7 +4590,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4535
4590
  }
4536
4591
  });
4537
4592
 
4538
- const _sfc_main$C = /* @__PURE__ */ defineComponent({
4593
+ const _sfc_main$F = /* @__PURE__ */ defineComponent({
4539
4594
  ...{
4540
4595
  name: "MEditorDataSourceSelect"
4541
4596
  },
@@ -4592,12 +4647,12 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
4592
4647
  }
4593
4648
  });
4594
4649
 
4595
- const _hoisted_1$j = { class: "m-fields-event-select" };
4596
- const _hoisted_2$c = {
4650
+ const _hoisted_1$k = { class: "m-fields-event-select" };
4651
+ const _hoisted_2$d = {
4597
4652
  key: 1,
4598
4653
  class: "fullWidth"
4599
4654
  };
4600
- const _sfc_main$B = /* @__PURE__ */ defineComponent({
4655
+ const _sfc_main$E = /* @__PURE__ */ defineComponent({
4601
4656
  ...{
4602
4657
  name: "MEditorEventSelect"
4603
4658
  },
@@ -4800,7 +4855,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
4800
4855
  const _component_m_form_table = resolveComponent("m-form-table");
4801
4856
  const _component_m_form_container = resolveComponent("m-form-container");
4802
4857
  const _component_m_form_panel = resolveComponent("m-form-panel");
4803
- return openBlock(), createElementBlock("div", _hoisted_1$j, [
4858
+ return openBlock(), createElementBlock("div", _hoisted_1$k, [
4804
4859
  isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
4805
4860
  key: 0,
4806
4861
  ref: "eventForm",
@@ -4810,7 +4865,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
4810
4865
  model: _ctx.model,
4811
4866
  config: tableConfig.value,
4812
4867
  onChange: onChangeHandler
4813
- }, null, 8, ["size", "disabled", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$c, [
4868
+ }, null, 8, ["size", "disabled", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$d, [
4814
4869
  createVNode(unref(TMagicButton), {
4815
4870
  class: "create-button",
4816
4871
  type: "primary",
@@ -4860,32 +4915,32 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
4860
4915
  }
4861
4916
  });
4862
4917
 
4863
- const _hoisted_1$i = {
4918
+ const _hoisted_1$j = {
4864
4919
  viewBox: "0 0 32 32",
4865
4920
  version: "1.1",
4866
4921
  xmlns: "http://www.w3.org/2000/svg",
4867
4922
  "xmlns:xlink": "http://www.w3.org/1999/xlink"
4868
4923
  };
4869
- const _hoisted_2$b = /* @__PURE__ */ createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2);
4870
- const _hoisted_4$4 = [
4871
- _hoisted_2$b
4924
+ const _hoisted_2$c = /* @__PURE__ */ createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2);
4925
+ const _hoisted_4$6 = [
4926
+ _hoisted_2$c
4872
4927
  ];
4873
- const _sfc_main$A = /* @__PURE__ */ defineComponent({
4928
+ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4874
4929
  ...{
4875
4930
  name: "MEditorCodeIcon"
4876
4931
  },
4877
4932
  __name: "CodeIcon",
4878
4933
  setup(__props) {
4879
4934
  return (_ctx, _cache) => {
4880
- return openBlock(), createElementBlock("svg", _hoisted_1$i, _hoisted_4$4);
4935
+ return openBlock(), createElementBlock("svg", _hoisted_1$j, _hoisted_4$6);
4881
4936
  };
4882
4937
  }
4883
4938
  });
4884
4939
 
4885
- const _hoisted_1$h = { class: "m-fields-key-value" };
4886
- const _hoisted_2$a = { key: 0 };
4887
- const _hoisted_3$5 = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
4888
- const _sfc_main$z = /* @__PURE__ */ defineComponent({
4940
+ const _hoisted_1$i = { class: "m-fields-key-value" };
4941
+ const _hoisted_2$b = { key: 0 };
4942
+ const _hoisted_3$6 = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
4943
+ const _sfc_main$C = /* @__PURE__ */ defineComponent({
4889
4944
  ...{
4890
4945
  name: "MEditorKeyValue"
4891
4946
  },
@@ -4943,8 +4998,8 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
4943
4998
  emit("change", v);
4944
4999
  };
4945
5000
  return (_ctx, _cache) => {
4946
- return openBlock(), createElementBlock("div", _hoisted_1$h, [
4947
- !showCode.value ? (openBlock(), createElementBlock("div", _hoisted_2$a, [
5001
+ return openBlock(), createElementBlock("div", _hoisted_1$i, [
5002
+ !showCode.value ? (openBlock(), createElementBlock("div", _hoisted_2$b, [
4948
5003
  (openBlock(true), createElementBlock(Fragment, null, renderList(records.value, (item, index) => {
4949
5004
  return openBlock(), createElementBlock("div", {
4950
5005
  class: "m-fields-key-value-item",
@@ -4958,7 +5013,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
4958
5013
  size: _ctx.size,
4959
5014
  onChange: keyChangeHandler
4960
5015
  }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "size"]),
4961
- _hoisted_3$5,
5016
+ _hoisted_3$6,
4962
5017
  createVNode(unref(TMagicInput), {
4963
5018
  placeholder: "value",
4964
5019
  modelValue: records.value[index][1],
@@ -4993,7 +5048,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
4993
5048
  _: 1
4994
5049
  }, 8, ["size", "disabled", "icon"])
4995
5050
  ])) : createCommentVNode("", true),
4996
- _ctx.config.advanced && showCode.value ? (openBlock(), createBlock(_sfc_main$Q, {
5051
+ _ctx.config.advanced && showCode.value ? (openBlock(), createBlock(_sfc_main$T, {
4997
5052
  key: 1,
4998
5053
  height: "200px",
4999
5054
  "init-values": _ctx.model[_ctx.name],
@@ -5009,7 +5064,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
5009
5064
  size: "default",
5010
5065
  disabled: _ctx.disabled,
5011
5066
  text: "",
5012
- icon: _sfc_main$A,
5067
+ icon: _sfc_main$D,
5013
5068
  onClick: _cache[0] || (_cache[0] = ($event) => showCode.value = !showCode.value)
5014
5069
  }, null, 8, ["disabled"])) : createCommentVNode("", true)
5015
5070
  ]);
@@ -5017,12 +5072,81 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
5017
5072
  }
5018
5073
  });
5019
5074
 
5075
+ const _hoisted_1$h = { class: "m-fields-page-fragment-select" };
5076
+ const _hoisted_2$a = { class: "page-fragment-select-container" };
5077
+ const _sfc_main$B = /* @__PURE__ */ defineComponent({
5078
+ ...{
5079
+ name: "MEditorPageFragmentSelect"
5080
+ },
5081
+ __name: "PageFragmentSelect",
5082
+ props: {
5083
+ config: {},
5084
+ model: {},
5085
+ initValues: {},
5086
+ values: {},
5087
+ name: {},
5088
+ prop: {},
5089
+ disabled: { type: Boolean, default: false },
5090
+ size: {},
5091
+ lastValues: {}
5092
+ },
5093
+ emits: ["change"],
5094
+ setup(__props, { emit: __emit }) {
5095
+ const services = inject("services");
5096
+ const emit = __emit;
5097
+ const props = __props;
5098
+ const pageList = computed(
5099
+ () => services?.editorService.get("root")?.items.filter((item) => item.type === NodeType.PAGE_FRAGMENT)
5100
+ );
5101
+ const selectConfig = {
5102
+ type: "select",
5103
+ name: props.name,
5104
+ options: () => {
5105
+ if (pageList.value) {
5106
+ return pageList.value.map((item) => ({
5107
+ text: `${item.devconfig?.tabName || item.title || item.name}(${item.id})`,
5108
+ label: `${item.devconfig?.tabName || item.title || item.name}(${item.id})`,
5109
+ value: item.id
5110
+ }));
5111
+ }
5112
+ return [];
5113
+ }
5114
+ };
5115
+ const changeHandler = async () => {
5116
+ emit("change", props.model[props.name]);
5117
+ };
5118
+ const editPageFragment = (id) => {
5119
+ services?.editorService.select(id);
5120
+ };
5121
+ return (_ctx, _cache) => {
5122
+ const _component_m_form_container = resolveComponent("m-form-container");
5123
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
5124
+ createElementVNode("div", _hoisted_2$a, [
5125
+ createVNode(_component_m_form_container, {
5126
+ class: "select",
5127
+ config: selectConfig,
5128
+ model: _ctx.model,
5129
+ size: _ctx.size,
5130
+ onChange: changeHandler
5131
+ }, null, 8, ["model", "size"]),
5132
+ _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$N, {
5133
+ key: 0,
5134
+ class: "icon",
5135
+ icon: unref(Edit),
5136
+ onClick: _cache[0] || (_cache[0] = ($event) => editPageFragment(_ctx.model[_ctx.name]))
5137
+ }, null, 8, ["icon"])) : createCommentVNode("", true)
5138
+ ])
5139
+ ]);
5140
+ };
5141
+ }
5142
+ });
5143
+
5020
5144
  const _hoisted_1$g = {
5021
5145
  key: 1,
5022
5146
  class: "m-fields-ui-select",
5023
5147
  style: { "display": "flex" }
5024
5148
  };
5025
- const _sfc_main$y = /* @__PURE__ */ defineComponent({
5149
+ const _sfc_main$A = /* @__PURE__ */ defineComponent({
5026
5150
  ...{
5027
5151
  name: "MEditorUISelect"
5028
5152
  },
@@ -5198,7 +5322,7 @@ const useGetSo = (target, emit) => {
5198
5322
  isDraging.value = false;
5199
5323
  });
5200
5324
  });
5201
- onUnmounted(() => {
5325
+ onBeforeUnmount(() => {
5202
5326
  getso?.unset();
5203
5327
  isDraging.value = false;
5204
5328
  });
@@ -5207,7 +5331,7 @@ const useGetSo = (target, emit) => {
5207
5331
  };
5208
5332
  };
5209
5333
 
5210
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
5334
+ const _sfc_main$z = /* @__PURE__ */ defineComponent({
5211
5335
  ...{
5212
5336
  name: "MEditorResizer"
5213
5337
  },
@@ -5229,7 +5353,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
5229
5353
  }
5230
5354
  });
5231
5355
 
5232
- const _sfc_main$w = /* @__PURE__ */ defineComponent({
5356
+ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5233
5357
  ...{
5234
5358
  name: "MEditorLayout"
5235
5359
  },
@@ -5296,7 +5420,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
5296
5420
  resizerObserver.observe(el.value);
5297
5421
  }
5298
5422
  });
5299
- onUnmounted(() => {
5423
+ onBeforeUnmount(() => {
5300
5424
  resizerObserver.disconnect();
5301
5425
  });
5302
5426
  const center = ref(0);
@@ -5356,7 +5480,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
5356
5480
  }, [
5357
5481
  renderSlot(_ctx.$slots, "left")
5358
5482
  ], 6),
5359
- createVNode(_sfc_main$x, { onChange: changeLeft })
5483
+ createVNode(_sfc_main$z, { onChange: changeLeft })
5360
5484
  ], 64)) : createCommentVNode("", true),
5361
5485
  createElementVNode("div", {
5362
5486
  class: normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
@@ -5365,7 +5489,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
5365
5489
  renderSlot(_ctx.$slots, "center")
5366
5490
  ], 6),
5367
5491
  hasRight.value && _ctx.$slots.right ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
5368
- createVNode(_sfc_main$x, { onChange: changeRight }),
5492
+ createVNode(_sfc_main$z, { onChange: changeRight }),
5369
5493
  createElementVNode("div", {
5370
5494
  class: normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
5371
5495
  style: normalizeStyle(`width: ${_ctx.right}px`)
@@ -5378,345 +5502,751 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
5378
5502
  }
5379
5503
  });
5380
5504
 
5381
- const _hoisted_1$f = { class: "m-editor-empty-panel" };
5382
- const _hoisted_2$9 = { class: "m-editor-empty-content" };
5383
- const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
5384
- const _sfc_main$v = /* @__PURE__ */ defineComponent({
5505
+ const _hoisted_1$f = {
5506
+ key: 1,
5507
+ class: "menu-item-text"
5508
+ };
5509
+ const _hoisted_2$9 = { class: "el-dropdown-link menubar-menu-button" };
5510
+ const _sfc_main$x = /* @__PURE__ */ defineComponent({
5385
5511
  ...{
5386
- name: "MEditorAddPageBox"
5512
+ name: "MEditorToolButton"
5513
+ },
5514
+ __name: "ToolButton",
5515
+ props: {
5516
+ data: { default: () => ({
5517
+ type: "text",
5518
+ display: false
5519
+ }) },
5520
+ eventType: { default: "click" }
5387
5521
  },
5388
- __name: "AddPageBox",
5389
5522
  setup(__props) {
5523
+ const props = __props;
5390
5524
  const services = inject("services");
5391
- const clickHandler = () => {
5392
- const { editorService } = services || {};
5393
- if (!editorService)
5525
+ const disabled = computed(() => {
5526
+ if (typeof props.data === "string")
5527
+ return false;
5528
+ if (props.data.type === "component")
5529
+ return false;
5530
+ if (typeof props.data.disabled === "function") {
5531
+ return props.data.disabled(services);
5532
+ }
5533
+ return props.data.disabled;
5534
+ });
5535
+ const display = computed(() => {
5536
+ if (!props.data)
5537
+ return false;
5538
+ if (typeof props.data === "string")
5539
+ return true;
5540
+ if (typeof props.data.display === "function") {
5541
+ return props.data.display(services);
5542
+ }
5543
+ return props.data.display ?? true;
5544
+ });
5545
+ const buttonHandler = (item, event) => {
5546
+ if (disabled.value)
5394
5547
  return;
5395
- const root = toRaw(editorService.get("root"));
5396
- if (!root)
5397
- throw new Error("root 不能为空");
5398
- editorService.add({
5399
- type: NodeType.PAGE,
5400
- name: generatePageNameByApp(root)
5401
- });
5548
+ if (typeof item.handler === "function" && services) {
5549
+ item.handler?.(services, event);
5550
+ }
5402
5551
  };
5403
- return (_ctx, _cache) => {
5404
- return openBlock(), createElementBlock("div", _hoisted_1$f, [
5405
- createElementVNode("div", _hoisted_2$9, [
5406
- createElementVNode("div", {
5407
- class: "m-editor-empty-button",
5408
- onClick: clickHandler
5409
- }, [
5410
- createElementVNode("div", null, [
5411
- createVNode(_sfc_main$K, { icon: unref(Plus) }, null, 8, ["icon"])
5412
- ]),
5413
- _hoisted_3$4
5414
- ])
5415
- ])
5416
- ]);
5552
+ const dropdownHandler = (command) => {
5553
+ if (command.item.handler) {
5554
+ command.item.handler(services);
5555
+ }
5417
5556
  };
5418
- }
5419
- });
5420
-
5421
- const DEFAULT_LEFT_COLUMN_WIDTH = 310;
5422
- const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
5423
- const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
5424
- const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
5425
- const _sfc_main$u = /* @__PURE__ */ defineComponent({
5426
- ...{
5427
- name: "MEditorFramework"
5428
- },
5429
- __name: "Framework",
5430
- setup(__props) {
5431
- const codeOptions = inject("codeOptions", {});
5432
- const { editorService, uiService } = inject("services") || {};
5433
- const content = ref();
5434
- const splitView = ref();
5435
- const root = computed(() => editorService?.get("root"));
5436
- const pageLength = computed(() => editorService?.get("pageLength") || 0);
5437
- const showSrc = computed(() => uiService?.get("showSrc"));
5438
- const getLeftColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
5439
- const leftColumnWidthCacheData = getLeftColumnWidthCacheData();
5440
- const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
5441
- const columnWidth = ref({
5442
- left: leftColumnWidthCacheData,
5443
- center: 0,
5444
- right: RightColumnWidthCacheData
5445
- });
5446
- watch(
5447
- [pageLength, splitView],
5448
- () => {
5449
- splitView.value?.updateWidth();
5450
- },
5451
- {
5452
- immediate: true
5557
+ const clickHandler = (item, event) => {
5558
+ if (props.eventType !== "click")
5559
+ return;
5560
+ if (item.type === "button") {
5561
+ buttonHandler(item, event);
5453
5562
  }
5454
- );
5455
- watch(
5456
- () => columnWidth.value.right,
5457
- (right) => {
5458
- if (typeof right === "undefined")
5459
- return;
5460
- globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
5563
+ };
5564
+ const mousedownHandler = (item, event) => {
5565
+ if (props.eventType !== "mousedown")
5566
+ return;
5567
+ if (item.type === "button") {
5568
+ buttonHandler(item, event);
5461
5569
  }
5462
- );
5463
- watch(
5464
- () => columnWidth.value.left,
5465
- (left) => {
5466
- globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
5467
- }
5468
- );
5469
- watch(
5470
- () => uiService?.get("hideSlideBar"),
5471
- (hideSlideBar) => {
5472
- columnWidth.value.left = hideSlideBar ? 0 : getLeftColumnWidthCacheData();
5473
- }
5474
- );
5475
- const columnWidthChange = (columnW) => {
5476
- columnWidth.value.left = columnW.left;
5477
- columnWidth.value.center = columnW.center;
5478
- columnWidth.value.right = columnW.right;
5479
- uiService?.set("columnWidth", columnW);
5480
5570
  };
5481
- const saveCode = (value) => {
5482
- try {
5483
- const parseDSL = getConfig("parseDSL");
5484
- editorService?.set("root", parseDSL(value));
5485
- } catch (e) {
5486
- console.error(e);
5571
+ const mouseupHandler = (item, event) => {
5572
+ if (props.eventType !== "mouseup")
5573
+ return;
5574
+ if (item.type === "button") {
5575
+ buttonHandler(item, event);
5487
5576
  }
5488
5577
  };
5489
5578
  return (_ctx, _cache) => {
5490
- return openBlock(), createElementBlock("div", {
5491
- class: "m-editor",
5492
- ref_key: "content",
5493
- ref: content,
5494
- style: { "min-width": "180px" }
5579
+ return display.value ? (openBlock(), createElementBlock("div", {
5580
+ key: 0,
5581
+ class: normalizeClass(["menu-item", `${_ctx.data.type} ${_ctx.data.className || ""}`]),
5582
+ onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(_ctx.data, $event)),
5583
+ onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(_ctx.data, $event)),
5584
+ onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(_ctx.data, $event))
5495
5585
  }, [
5496
- renderSlot(_ctx.$slots, "header"),
5497
- renderSlot(_ctx.$slots, "nav"),
5498
- renderSlot(_ctx.$slots, "content-before"),
5499
- showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
5500
- createVNode(_sfc_main$Q, {
5501
- class: "m-editor-content",
5502
- "init-values": root.value,
5503
- options: unref(codeOptions),
5504
- onSave: saveCode
5505
- }, null, 8, ["init-values", "options"])
5506
- ]) : (openBlock(), createBlock(_sfc_main$w, {
5507
- key: 1,
5508
- ref_key: "splitView",
5509
- ref: splitView,
5510
- class: "m-editor-content",
5511
- "left-class": "m-editor-framework-left",
5512
- "center-class": "m-editor-framework-center",
5513
- "right-class": "m-editor-framework-right",
5514
- left: columnWidth.value.left,
5515
- "onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
5516
- right: columnWidth.value.right,
5517
- "onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
5518
- "min-left": 65,
5519
- "min-right": 20,
5520
- "min-center": 100,
5521
- onChange: columnWidthChange
5522
- }, createSlots({
5523
- left: withCtx(() => [
5524
- renderSlot(_ctx.$slots, "sidebar")
5525
- ]),
5526
- center: withCtx(() => [
5527
- pageLength.value > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
5528
- createVNode(_sfc_main$v)
5529
- ])
5586
+ _ctx.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
5587
+ key: 0,
5588
+ direction: _ctx.data.direction || "vertical"
5589
+ }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$f, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
5590
+ _ctx.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
5591
+ key: 0,
5592
+ effect: "dark",
5593
+ placement: "bottom-start",
5594
+ content: _ctx.data.tooltip
5595
+ }, {
5596
+ default: withCtx(() => [
5597
+ createVNode(unref(TMagicButton), {
5598
+ size: "small",
5599
+ text: "",
5600
+ disabled: disabled.value
5601
+ }, {
5602
+ default: withCtx(() => [
5603
+ _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$N, {
5604
+ key: 0,
5605
+ icon: _ctx.data.icon
5606
+ }, null, 8, ["icon"])) : createCommentVNode("", true),
5607
+ createElementVNode("span", null, toDisplayString(_ctx.data.text), 1)
5608
+ ]),
5609
+ _: 1
5610
+ }, 8, ["disabled"])
5611
+ ]),
5612
+ _: 1
5613
+ }, 8, ["content"])) : (openBlock(), createBlock(unref(TMagicButton), {
5614
+ key: 1,
5615
+ size: "small",
5616
+ text: "",
5617
+ disabled: disabled.value,
5618
+ title: _ctx.data.text
5619
+ }, {
5620
+ default: withCtx(() => [
5621
+ _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$N, {
5622
+ key: 0,
5623
+ icon: _ctx.data.icon
5624
+ }, null, 8, ["icon"])) : createCommentVNode("", true),
5625
+ createElementVNode("span", null, toDisplayString(_ctx.data.text), 1)
5626
+ ]),
5627
+ _: 1
5628
+ }, 8, ["disabled", "title"]))
5629
+ ], 64)) : _ctx.data.type === "dropdown" ? (openBlock(), createBlock(unref(TMagicDropdown), {
5630
+ key: 3,
5631
+ trigger: "click",
5632
+ disabled: disabled.value,
5633
+ onCommand: dropdownHandler
5634
+ }, {
5635
+ dropdown: withCtx(() => [
5636
+ _ctx.data.items && _ctx.data.items.length ? (openBlock(), createBlock(unref(TMagicDropdownMenu), { key: 0 }, {
5637
+ default: withCtx(() => [
5638
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.items, (subItem, index) => {
5639
+ return openBlock(), createBlock(unref(TMagicDropdownItem), {
5640
+ key: index,
5641
+ command: { data: _ctx.data, subItem }
5642
+ }, {
5643
+ default: withCtx(() => [
5644
+ createTextVNode(toDisplayString(subItem.text), 1)
5645
+ ]),
5646
+ _: 2
5647
+ }, 1032, ["command"]);
5648
+ }), 128))
5649
+ ]),
5650
+ _: 1
5651
+ })) : createCommentVNode("", true)
5530
5652
  ]),
5531
- _: 2
5532
- }, [
5533
- pageLength.value > 0 ? {
5534
- name: "right",
5535
- fn: withCtx(() => [
5536
- createVNode(unref(TMagicScrollbar), null, {
5653
+ default: withCtx(() => [
5654
+ createElementVNode("span", _hoisted_2$9, [
5655
+ createTextVNode(toDisplayString(_ctx.data.text), 1),
5656
+ createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
5537
5657
  default: withCtx(() => [
5538
- renderSlot(_ctx.$slots, "props-panel")
5658
+ createVNode(unref(ArrowDown))
5539
5659
  ]),
5540
- _: 3
5660
+ _: 1
5541
5661
  })
5542
- ]),
5543
- key: "0"
5544
- } : void 0
5545
- ]), 1032, ["left", "right"])),
5546
- renderSlot(_ctx.$slots, "content-after"),
5547
- renderSlot(_ctx.$slots, "footer")
5548
- ], 512);
5662
+ ])
5663
+ ]),
5664
+ _: 1
5665
+ }, 8, ["disabled"])) : _ctx.data.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.data.component), normalizeProps(mergeProps({ key: 4 }, _ctx.data.props || {})), null, 16)) : createCommentVNode("", true)
5666
+ ], 34)) : createCommentVNode("", true);
5549
5667
  };
5550
5668
  }
5551
5669
  });
5552
5670
 
5553
5671
  const _hoisted_1$e = {
5554
5672
  key: 1,
5555
- class: "menu-item-text"
5673
+ style: { "width": "21px" }
5556
5674
  };
5557
- const _hoisted_2$8 = { class: "el-dropdown-link menubar-menu-button" };
5558
- const _sfc_main$t = /* @__PURE__ */ defineComponent({
5675
+ const _sfc_main$w = /* @__PURE__ */ defineComponent({
5559
5676
  ...{
5560
- name: "MEditorToolButton"
5677
+ name: "MEditorPageBarAddButton"
5561
5678
  },
5562
- __name: "ToolButton",
5679
+ __name: "AddButton",
5563
5680
  props: {
5564
- data: { default: () => ({
5565
- type: "text",
5566
- display: false
5567
- }) },
5568
- eventType: { default: "click" }
5681
+ type: {}
5569
5682
  },
5570
5683
  setup(__props) {
5571
5684
  const props = __props;
5572
5685
  const services = inject("services");
5573
- const disabled = computed(() => {
5574
- if (typeof props.data === "string")
5575
- return false;
5576
- if (props.data.type === "component")
5577
- return false;
5578
- if (typeof props.data.disabled === "function") {
5579
- return props.data.disabled(services);
5580
- }
5581
- return props.data.disabled;
5686
+ const uiService = services?.uiService;
5687
+ const editorService = services?.editorService;
5688
+ const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
5689
+ const addPage = () => {
5690
+ if (!editorService)
5691
+ return;
5692
+ const root = toRaw(editorService.get("root"));
5693
+ if (!root)
5694
+ throw new Error("root 不能为空");
5695
+ const pageConfig = {
5696
+ type: props.type,
5697
+ name: generatePageNameByApp(root, props.type),
5698
+ items: []
5699
+ };
5700
+ editorService.add(pageConfig);
5701
+ };
5702
+ return (_ctx, _cache) => {
5703
+ return showAddPageButton.value ? (openBlock(), createElementBlock("div", {
5704
+ key: 0,
5705
+ id: "m-editor-page-bar-add-icon",
5706
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5707
+ onClick: addPage
5708
+ }, [
5709
+ createVNode(_sfc_main$N, { icon: unref(Plus) }, null, 8, ["icon"])
5710
+ ])) : (openBlock(), createElementBlock("div", _hoisted_1$e));
5711
+ };
5712
+ }
5713
+ });
5714
+
5715
+ const _sfc_main$v = /* @__PURE__ */ defineComponent({
5716
+ ...{
5717
+ name: "MEditorPageBarScrollContainer"
5718
+ },
5719
+ __name: "PageBarScrollContainer",
5720
+ props: {
5721
+ type: {}
5722
+ },
5723
+ setup(__props) {
5724
+ const props = __props;
5725
+ const services = inject("services");
5726
+ const editorService = services?.editorService;
5727
+ const uiService = services?.uiService;
5728
+ const itemsContainer = ref();
5729
+ const canScroll = ref(false);
5730
+ const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
5731
+ const itemsContainerWidth = ref(0);
5732
+ const setCanScroll = () => {
5733
+ itemsContainerWidth.value = (pageBar.value?.clientWidth || 0) - 37 * 2 - (showAddPageButton.value ? 37 : 21);
5734
+ nextTick(() => {
5735
+ if (itemsContainer.value) {
5736
+ canScroll.value = itemsContainer.value.scrollWidth - itemsContainerWidth.value > 1;
5737
+ }
5738
+ });
5739
+ };
5740
+ const resizeObserver = new ResizeObserver(() => {
5741
+ setCanScroll();
5582
5742
  });
5583
- const display = computed(() => {
5584
- if (!props.data)
5585
- return false;
5586
- if (typeof props.data === "string")
5587
- return true;
5588
- if (typeof props.data.display === "function") {
5589
- return props.data.display(services);
5590
- }
5591
- return props.data.display ?? true;
5743
+ const pageBar = ref();
5744
+ onMounted(() => {
5745
+ pageBar.value && resizeObserver.observe(pageBar.value);
5592
5746
  });
5593
- const buttonHandler = (item, event) => {
5594
- if (disabled.value)
5747
+ onBeforeUnmount(() => {
5748
+ resizeObserver.disconnect();
5749
+ });
5750
+ let translateLeft = 0;
5751
+ const scroll = (type) => {
5752
+ if (!itemsContainer.value)
5595
5753
  return;
5596
- if (typeof item.handler === "function" && services) {
5597
- item.handler?.(services, event);
5754
+ const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
5755
+ if (type === "left") {
5756
+ translateLeft += 100;
5757
+ if (translateLeft > 0) {
5758
+ translateLeft = 0;
5759
+ }
5760
+ } else if (type === "right") {
5761
+ translateLeft -= 100;
5762
+ if (-translateLeft > maxScrollLeft) {
5763
+ translateLeft = -maxScrollLeft;
5764
+ }
5765
+ } else if (type === "start") {
5766
+ translateLeft = 0;
5767
+ } else if (type === "end") {
5768
+ translateLeft = -maxScrollLeft;
5598
5769
  }
5770
+ itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
5599
5771
  };
5600
- const dropdownHandler = (command) => {
5601
- if (command.item.handler) {
5602
- command.item.handler(services);
5772
+ const pageLength = computed(() => editorService?.get("pageLength") || 0);
5773
+ const pageFragmentLength = computed(() => editorService?.get("pageFragmentLength") || 0);
5774
+ const crateWatchLength = (length) => watch(
5775
+ length,
5776
+ (length2 = 0, preLength = 0) => {
5777
+ setTimeout(() => {
5778
+ setCanScroll();
5779
+ if (length2 < preLength) {
5780
+ scroll("start");
5781
+ } else {
5782
+ scroll("end");
5783
+ }
5784
+ });
5785
+ },
5786
+ {
5787
+ immediate: true
5788
+ }
5789
+ );
5790
+ let unWatchPageLength;
5791
+ let unWatchPageFragmentLength;
5792
+ watch(
5793
+ () => props.type,
5794
+ (type) => {
5795
+ if (type === NodeType.PAGE) {
5796
+ unWatchPageFragmentLength?.();
5797
+ unWatchPageFragmentLength = null;
5798
+ unWatchPageLength = crateWatchLength(pageLength);
5799
+ } else {
5800
+ unWatchPageLength?.();
5801
+ unWatchPageLength = null;
5802
+ unWatchPageFragmentLength = crateWatchLength(pageFragmentLength);
5803
+ }
5804
+ },
5805
+ {
5806
+ immediate: true
5603
5807
  }
5808
+ );
5809
+ return (_ctx, _cache) => {
5810
+ return openBlock(), createElementBlock("div", {
5811
+ class: "m-editor-page-bar",
5812
+ ref_key: "pageBar",
5813
+ ref: pageBar
5814
+ }, [
5815
+ renderSlot(_ctx.$slots, "prepend"),
5816
+ canScroll.value ? (openBlock(), createElementBlock("div", {
5817
+ key: 0,
5818
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5819
+ onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
5820
+ }, [
5821
+ createVNode(_sfc_main$N, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
5822
+ ])) : createCommentVNode("", true),
5823
+ _ctx.type === unref(NodeType).PAGE && pageLength.value || _ctx.type === unref(NodeType).PAGE_FRAGMENT && pageFragmentLength.value ? (openBlock(), createElementBlock("div", {
5824
+ key: 1,
5825
+ class: "m-editor-page-bar-items",
5826
+ ref_key: "itemsContainer",
5827
+ ref: itemsContainer,
5828
+ style: normalizeStyle(`width: ${itemsContainerWidth.value}px`)
5829
+ }, [
5830
+ renderSlot(_ctx.$slots, "default")
5831
+ ], 4)) : createCommentVNode("", true),
5832
+ canScroll.value ? (openBlock(), createElementBlock("div", {
5833
+ key: 2,
5834
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5835
+ onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
5836
+ }, [
5837
+ createVNode(_sfc_main$N, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
5838
+ ])) : createCommentVNode("", true)
5839
+ ], 512);
5604
5840
  };
5605
- const clickHandler = (item, event) => {
5606
- if (props.eventType !== "click")
5607
- return;
5608
- if (item.type === "button") {
5609
- buttonHandler(item, event);
5841
+ }
5842
+ });
5843
+
5844
+ const _sfc_main$u = /* @__PURE__ */ defineComponent({
5845
+ ...{
5846
+ name: "MEditorPageBarSwitchTypeButton"
5847
+ },
5848
+ __name: "SwitchTypeButton",
5849
+ props: {
5850
+ modelValue: {}
5851
+ },
5852
+ emits: ["update:modelValue"],
5853
+ setup(__props, { emit: __emit }) {
5854
+ const data = [
5855
+ {
5856
+ type: NodeType.PAGE,
5857
+ text: "页面"
5858
+ },
5859
+ {
5860
+ type: NodeType.PAGE_FRAGMENT,
5861
+ text: "页面片"
5610
5862
  }
5863
+ ];
5864
+ const emit = __emit;
5865
+ const clickHandler = (value) => {
5866
+ emit("update:modelValue", value);
5611
5867
  };
5612
- const mousedownHandler = (item, event) => {
5613
- if (props.eventType !== "mousedown")
5868
+ return (_ctx, _cache) => {
5869
+ return openBlock(), createElementBlock(Fragment, null, renderList(data, (item) => {
5870
+ return createVNode(unref(TMagicButton), {
5871
+ class: normalizeClass(["m-editor-page-bar-switch-type-button", { active: _ctx.modelValue === item.type }]),
5872
+ size: "small",
5873
+ key: item.type,
5874
+ text: "",
5875
+ type: _ctx.modelValue === item.type ? "primary" : "",
5876
+ onClick: ($event) => clickHandler(item.type)
5877
+ }, {
5878
+ default: withCtx(() => [
5879
+ createTextVNode(toDisplayString(item.text), 1)
5880
+ ]),
5881
+ _: 2
5882
+ }, 1032, ["class", "type", "onClick"]);
5883
+ }), 64);
5884
+ };
5885
+ }
5886
+ });
5887
+
5888
+ const _hoisted_1$d = { class: "m-editor-page-bar-tabs" };
5889
+ const _hoisted_2$8 = ["onClick"];
5890
+ const _hoisted_3$5 = { class: "m-editor-page-bar-title" };
5891
+ const _hoisted_4$5 = ["title"];
5892
+ const _sfc_main$t = /* @__PURE__ */ defineComponent({
5893
+ ...{
5894
+ name: "MEditorPageBar"
5895
+ },
5896
+ __name: "PageBar",
5897
+ props: {
5898
+ disabledPageFragment: { type: Boolean }
5899
+ },
5900
+ setup(__props) {
5901
+ const active = ref(NodeType.PAGE);
5902
+ const services = inject("services");
5903
+ const editorService = services?.editorService;
5904
+ const root = computed(() => editorService?.get("root"));
5905
+ const page = computed(() => editorService?.get("page"));
5906
+ const pageList = computed(() => getPageList(root.value));
5907
+ const pageFragmentList = computed(() => getPageFragmentList(root.value));
5908
+ const list = computed(() => active.value === NodeType.PAGE ? pageList.value : pageFragmentList.value);
5909
+ const activePage = ref("");
5910
+ const activePageFragment = ref("");
5911
+ watch(
5912
+ page,
5913
+ (page2) => {
5914
+ if (!page2) {
5915
+ if (active.value === NodeType.PAGE) {
5916
+ activePage.value = "";
5917
+ }
5918
+ if (active.value === NodeType.PAGE_FRAGMENT) {
5919
+ activePageFragment.value = "";
5920
+ }
5921
+ return;
5922
+ }
5923
+ if (isPage(page2)) {
5924
+ activePage.value = page2?.id;
5925
+ if (active.value !== NodeType.PAGE) {
5926
+ active.value = NodeType.PAGE;
5927
+ }
5928
+ } else if (isPageFragment(page2)) {
5929
+ activePageFragment.value = page2?.id;
5930
+ if (active.value !== NodeType.PAGE_FRAGMENT) {
5931
+ active.value = NodeType.PAGE_FRAGMENT;
5932
+ }
5933
+ }
5934
+ },
5935
+ {
5936
+ immediate: true
5937
+ }
5938
+ );
5939
+ watch(active, (active2) => {
5940
+ if (active2 === NodeType.PAGE) {
5941
+ if (!activePage.value) {
5942
+ editorService?.selectRoot();
5943
+ return;
5944
+ }
5945
+ switchPage(activePage.value);
5614
5946
  return;
5615
- if (item.type === "button") {
5616
- buttonHandler(item, event);
5617
5947
  }
5948
+ if (active2 === NodeType.PAGE_FRAGMENT) {
5949
+ if (!activePageFragment.value) {
5950
+ editorService?.selectRoot();
5951
+ return;
5952
+ }
5953
+ switchPage(activePageFragment.value);
5954
+ }
5955
+ });
5956
+ const switchPage = (id) => {
5957
+ editorService?.select(id);
5618
5958
  };
5619
- const mouseupHandler = (item, event) => {
5620
- if (props.eventType !== "mouseup")
5959
+ const copy = (node) => {
5960
+ node && editorService?.copy(node);
5961
+ editorService?.paste({
5962
+ left: 0,
5963
+ top: 0
5964
+ });
5965
+ };
5966
+ const remove = (node) => {
5967
+ editorService?.remove(node);
5968
+ };
5969
+ return (_ctx, _cache) => {
5970
+ return openBlock(), createElementBlock("div", _hoisted_1$d, [
5971
+ !_ctx.disabledPageFragment ? (openBlock(), createBlock(_sfc_main$u, {
5972
+ key: 0,
5973
+ modelValue: active.value,
5974
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => active.value = $event)
5975
+ }, null, 8, ["modelValue"])) : createCommentVNode("", true),
5976
+ createVNode(_sfc_main$v, { type: active.value }, {
5977
+ prepend: withCtx(() => [
5978
+ createVNode(_sfc_main$w, { type: active.value }, null, 8, ["type"])
5979
+ ]),
5980
+ default: withCtx(() => [
5981
+ (openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (item) => {
5982
+ return openBlock(), createElementBlock("div", {
5983
+ class: normalizeClass(["m-editor-page-bar-item", { active: page.value?.id === item.id }]),
5984
+ key: item.id,
5985
+ onClick: ($event) => switchPage(item.id)
5986
+ }, [
5987
+ createElementVNode("div", _hoisted_3$5, [
5988
+ renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
5989
+ createElementVNode("span", {
5990
+ title: item.name
5991
+ }, toDisplayString(item.name || item.id), 9, _hoisted_4$5)
5992
+ ])
5993
+ ]),
5994
+ createVNode(unref(TMagicPopover), {
5995
+ "popper-class": "page-bar-popover",
5996
+ placement: "top",
5997
+ width: 160,
5998
+ trigger: "hover"
5999
+ }, {
6000
+ reference: withCtx(() => [
6001
+ createVNode(unref(TMagicIcon), { class: "m-editor-page-bar-menu-icon" }, {
6002
+ default: withCtx(() => [
6003
+ createVNode(unref(CaretBottom))
6004
+ ]),
6005
+ _: 1
6006
+ })
6007
+ ]),
6008
+ default: withCtx(() => [
6009
+ createElementVNode("div", null, [
6010
+ renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
6011
+ createVNode(_sfc_main$x, {
6012
+ data: {
6013
+ type: "button",
6014
+ text: "复制",
6015
+ icon: unref(DocumentCopy),
6016
+ handler: () => copy(item)
6017
+ }
6018
+ }, null, 8, ["data"]),
6019
+ createVNode(_sfc_main$x, {
6020
+ data: {
6021
+ type: "button",
6022
+ text: "删除",
6023
+ icon: unref(Delete),
6024
+ handler: () => remove(item)
6025
+ }
6026
+ }, null, 8, ["data"])
6027
+ ])
6028
+ ])
6029
+ ]),
6030
+ _: 2
6031
+ }, 1024)
6032
+ ], 10, _hoisted_2$8);
6033
+ }), 128))
6034
+ ]),
6035
+ _: 3
6036
+ }, 8, ["type"])
6037
+ ]);
6038
+ };
6039
+ }
6040
+ });
6041
+
6042
+ const _hoisted_1$c = { class: "m-editor-empty-panel" };
6043
+ const _hoisted_2$7 = { class: "m-editor-empty-content" };
6044
+ const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
6045
+ const _hoisted_4$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面片", -1);
6046
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6047
+ ...{
6048
+ name: "MEditorAddPageBox"
6049
+ },
6050
+ __name: "AddPageBox",
6051
+ props: {
6052
+ disabledPageFragment: { type: Boolean }
6053
+ },
6054
+ setup(__props) {
6055
+ const services = inject("services");
6056
+ const clickHandler = (type) => {
6057
+ const { editorService } = services || {};
6058
+ if (!editorService)
5621
6059
  return;
5622
- if (item.type === "button") {
5623
- buttonHandler(item, event);
6060
+ const root = toRaw(editorService.get("root"));
6061
+ if (!root)
6062
+ throw new Error("root 不能为空");
6063
+ editorService.add({
6064
+ type,
6065
+ name: generatePageNameByApp(root, type),
6066
+ items: []
6067
+ });
6068
+ };
6069
+ return (_ctx, _cache) => {
6070
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
6071
+ createElementVNode("div", _hoisted_2$7, [
6072
+ createElementVNode("div", {
6073
+ class: "m-editor-empty-button",
6074
+ onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(NodeType).PAGE))
6075
+ }, [
6076
+ createElementVNode("div", null, [
6077
+ createVNode(_sfc_main$N, { icon: unref(Plus) }, null, 8, ["icon"])
6078
+ ]),
6079
+ _hoisted_3$4
6080
+ ]),
6081
+ !_ctx.disabledPageFragment ? (openBlock(), createElementBlock("div", {
6082
+ key: 0,
6083
+ class: "m-editor-empty-button",
6084
+ onClick: _cache[1] || (_cache[1] = ($event) => clickHandler(unref(NodeType).PAGE_FRAGMENT))
6085
+ }, [
6086
+ createElementVNode("div", null, [
6087
+ createVNode(_sfc_main$N, { icon: unref(Plus) }, null, 8, ["icon"])
6088
+ ]),
6089
+ _hoisted_4$4
6090
+ ])) : createCommentVNode("", true)
6091
+ ])
6092
+ ]);
6093
+ };
6094
+ }
6095
+ });
6096
+
6097
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
6098
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
6099
+ const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
6100
+ const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
6101
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6102
+ ...{
6103
+ name: "MEditorFramework"
6104
+ },
6105
+ __name: "Framework",
6106
+ props: {
6107
+ disabledPageFragment: { type: Boolean }
6108
+ },
6109
+ setup(__props) {
6110
+ const codeOptions = inject("codeOptions", {});
6111
+ const { editorService, uiService } = inject("services") || {};
6112
+ const content = ref();
6113
+ const splitView = ref();
6114
+ const root = computed(() => editorService?.get("root"));
6115
+ const page = computed(() => editorService?.get("page"));
6116
+ const pageLength = computed(() => editorService?.get("pageLength") || 0);
6117
+ const stageLoading = computed(() => editorService?.get("stageLoading") || false);
6118
+ const showSrc = computed(() => uiService?.get("showSrc"));
6119
+ const getLeftColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
6120
+ const leftColumnWidthCacheData = getLeftColumnWidthCacheData();
6121
+ const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
6122
+ const columnWidth = ref({
6123
+ left: leftColumnWidthCacheData,
6124
+ center: 0,
6125
+ right: RightColumnWidthCacheData
6126
+ });
6127
+ watch(
6128
+ [pageLength, splitView],
6129
+ () => {
6130
+ splitView.value?.updateWidth();
6131
+ },
6132
+ {
6133
+ immediate: true
6134
+ }
6135
+ );
6136
+ watch(
6137
+ () => columnWidth.value.right,
6138
+ (right) => {
6139
+ if (typeof right === "undefined")
6140
+ return;
6141
+ globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
6142
+ }
6143
+ );
6144
+ watch(
6145
+ () => columnWidth.value.left,
6146
+ (left) => {
6147
+ globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
6148
+ }
6149
+ );
6150
+ watch(
6151
+ () => uiService?.get("hideSlideBar"),
6152
+ (hideSlideBar) => {
6153
+ columnWidth.value.left = hideSlideBar ? 0 : getLeftColumnWidthCacheData();
6154
+ }
6155
+ );
6156
+ const columnWidthChange = (columnW) => {
6157
+ columnWidth.value.left = columnW.left;
6158
+ columnWidth.value.center = columnW.center;
6159
+ columnWidth.value.right = columnW.right;
6160
+ uiService?.set("columnWidth", columnW);
6161
+ };
6162
+ const saveCode = (value) => {
6163
+ try {
6164
+ const parseDSL = getConfig("parseDSL");
6165
+ editorService?.set("root", parseDSL(value));
6166
+ } catch (e) {
6167
+ console.error(e);
5624
6168
  }
5625
6169
  };
5626
6170
  return (_ctx, _cache) => {
5627
- return display.value ? (openBlock(), createElementBlock("div", {
5628
- key: 0,
5629
- class: normalizeClass(["menu-item", `${_ctx.data.type} ${_ctx.data.className || ""}`]),
5630
- onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(_ctx.data, $event)),
5631
- onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(_ctx.data, $event)),
5632
- onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(_ctx.data, $event))
6171
+ const _directive_loading = resolveDirective("loading");
6172
+ return openBlock(), createElementBlock("div", {
6173
+ class: "m-editor",
6174
+ ref_key: "content",
6175
+ ref: content,
6176
+ style: { "min-width": "180px" }
5633
6177
  }, [
5634
- _ctx.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
5635
- key: 0,
5636
- direction: _ctx.data.direction || "vertical"
5637
- }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$e, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
5638
- _ctx.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
5639
- key: 0,
5640
- effect: "dark",
5641
- placement: "bottom-start",
5642
- content: _ctx.data.tooltip
5643
- }, {
5644
- default: withCtx(() => [
5645
- createVNode(unref(TMagicButton), {
5646
- size: "small",
5647
- text: "",
5648
- disabled: disabled.value
5649
- }, {
5650
- default: withCtx(() => [
5651
- _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$K, {
5652
- key: 0,
5653
- icon: _ctx.data.icon
5654
- }, null, 8, ["icon"])) : createCommentVNode("", true),
5655
- createElementVNode("span", null, toDisplayString(_ctx.data.text), 1)
5656
- ]),
5657
- _: 1
5658
- }, 8, ["disabled"])
5659
- ]),
5660
- _: 1
5661
- }, 8, ["content"])) : (openBlock(), createBlock(unref(TMagicButton), {
5662
- key: 1,
5663
- size: "small",
5664
- text: "",
5665
- disabled: disabled.value,
5666
- title: _ctx.data.text
5667
- }, {
5668
- default: withCtx(() => [
5669
- _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$K, {
5670
- key: 0,
5671
- icon: _ctx.data.icon
5672
- }, null, 8, ["icon"])) : createCommentVNode("", true),
5673
- createElementVNode("span", null, toDisplayString(_ctx.data.text), 1)
6178
+ renderSlot(_ctx.$slots, "header"),
6179
+ renderSlot(_ctx.$slots, "nav"),
6180
+ renderSlot(_ctx.$slots, "content-before"),
6181
+ showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
6182
+ createVNode(_sfc_main$T, {
6183
+ class: "m-editor-content",
6184
+ "init-values": root.value,
6185
+ options: unref(codeOptions),
6186
+ onSave: saveCode
6187
+ }, null, 8, ["init-values", "options"])
6188
+ ]) : withDirectives((openBlock(), createBlock(_sfc_main$y, {
6189
+ key: 1,
6190
+ "element-loading-text": "Runtime 加载中...",
6191
+ ref_key: "splitView",
6192
+ ref: splitView,
6193
+ class: "m-editor-content",
6194
+ "left-class": "m-editor-framework-left",
6195
+ "center-class": "m-editor-framework-center",
6196
+ "right-class": "m-editor-framework-right",
6197
+ left: columnWidth.value.left,
6198
+ "onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
6199
+ right: columnWidth.value.right,
6200
+ "onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
6201
+ "min-left": 65,
6202
+ "min-right": 20,
6203
+ "min-center": 100,
6204
+ onChange: columnWidthChange
6205
+ }, createSlots({
6206
+ left: withCtx(() => [
6207
+ renderSlot(_ctx.$slots, "sidebar")
6208
+ ]),
6209
+ center: withCtx(() => [
6210
+ page.value ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
6211
+ createVNode(_sfc_main$s, { "disabled-page-fragment": _ctx.disabledPageFragment }, null, 8, ["disabled-page-fragment"])
5674
6212
  ]),
5675
- _: 1
5676
- }, 8, ["disabled", "title"]))
5677
- ], 64)) : _ctx.data.type === "dropdown" ? (openBlock(), createBlock(unref(TMagicDropdown), {
5678
- key: 3,
5679
- trigger: "click",
5680
- disabled: disabled.value,
5681
- onCommand: dropdownHandler
5682
- }, {
5683
- dropdown: withCtx(() => [
5684
- _ctx.data.items && _ctx.data.items.length ? (openBlock(), createBlock(unref(TMagicDropdownMenu), { key: 0 }, {
5685
- default: withCtx(() => [
5686
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.items, (subItem, index) => {
5687
- return openBlock(), createBlock(unref(TMagicDropdownItem), {
5688
- key: index,
5689
- command: { data: _ctx.data, subItem }
5690
- }, {
5691
- default: withCtx(() => [
5692
- createTextVNode(toDisplayString(subItem.text), 1)
5693
- ]),
5694
- _: 2
5695
- }, 1032, ["command"]);
5696
- }), 128))
5697
- ]),
5698
- _: 1
5699
- })) : createCommentVNode("", true)
6213
+ renderSlot(_ctx.$slots, "page-bar", {}, () => [
6214
+ createVNode(_sfc_main$t, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
6215
+ "page-bar-title": withCtx(({ page: page2 }) => [
6216
+ renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
6217
+ ]),
6218
+ "page-bar-popover": withCtx(({ page: page2 }) => [
6219
+ renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
6220
+ ]),
6221
+ _: 3
6222
+ }, 8, ["disabled-page-fragment"])
6223
+ ])
5700
6224
  ]),
5701
- default: withCtx(() => [
5702
- createElementVNode("span", _hoisted_2$8, [
5703
- createTextVNode(toDisplayString(_ctx.data.text), 1),
5704
- createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
6225
+ _: 2
6226
+ }, [
6227
+ page.value ? {
6228
+ name: "right",
6229
+ fn: withCtx(() => [
6230
+ createVNode(unref(TMagicScrollbar), null, {
5705
6231
  default: withCtx(() => [
5706
- createVNode(unref(ArrowDown))
6232
+ renderSlot(_ctx.$slots, "props-panel")
5707
6233
  ]),
5708
- _: 1
6234
+ _: 3
5709
6235
  })
5710
- ])
5711
- ]),
5712
- _: 1
5713
- }, 8, ["disabled"])) : _ctx.data.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.data.component), normalizeProps(mergeProps({ key: 4 }, _ctx.data.props || {})), null, 16)) : createCommentVNode("", true)
5714
- ], 34)) : createCommentVNode("", true);
6236
+ ]),
6237
+ key: "0"
6238
+ } : void 0
6239
+ ]), 1032, ["left", "right"])), [
6240
+ [_directive_loading, stageLoading.value]
6241
+ ]),
6242
+ renderSlot(_ctx.$slots, "content-after"),
6243
+ renderSlot(_ctx.$slots, "footer")
6244
+ ], 512);
5715
6245
  };
5716
6246
  }
5717
6247
  });
5718
6248
 
5719
- const _sfc_main$s = /* @__PURE__ */ defineComponent({
6249
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
5720
6250
  ...{
5721
6251
  name: "MEditorNavMenu"
5722
6252
  },
@@ -5878,7 +6408,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
5878
6408
  style: normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
5879
6409
  }, [
5880
6410
  (openBlock(true), createElementBlock(Fragment, null, renderList(buttons.value[key], (item, index) => {
5881
- return openBlock(), createBlock(_sfc_main$t, {
6411
+ return openBlock(), createBlock(_sfc_main$x, {
5882
6412
  data: item,
5883
6413
  key: index
5884
6414
  }, null, 8, ["data"]);
@@ -5890,8 +6420,8 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
5890
6420
  }
5891
6421
  });
5892
6422
 
5893
- const _hoisted_1$d = { class: "m-editor-props-panel" };
5894
- const _sfc_main$r = /* @__PURE__ */ defineComponent({
6423
+ const _hoisted_1$b = { class: "m-editor-props-panel" };
6424
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
5895
6425
  ...{
5896
6426
  name: "MEditorPropsPanel"
5897
6427
  },
@@ -5899,7 +6429,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
5899
6429
  props: {
5900
6430
  extendState: { type: Function }
5901
6431
  },
5902
- emits: ["mounted"],
6432
+ emits: ["mounted", "submit-error", "form-error"],
5903
6433
  setup(__props, { expose: __expose, emit: __emit }) {
5904
6434
  const emit = __emit;
5905
6435
  const internalInstance = getCurrentInstance();
@@ -5925,7 +6455,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
5925
6455
  onMounted(() => {
5926
6456
  emit("mounted", internalInstance);
5927
6457
  });
5928
- onUnmounted(() => {
6458
+ onBeforeUnmount(() => {
5929
6459
  services?.propsService.off("props-configs-change", init);
5930
6460
  });
5931
6461
  watchEffect(() => {
@@ -5938,14 +6468,15 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
5938
6468
  const values2 = await configForm.value?.submitForm();
5939
6469
  services?.editorService.update(values2);
5940
6470
  } catch (e) {
5941
- console.error(e);
5942
- tMagicMessage.closeAll();
5943
- tMagicMessage.error(e.message);
6471
+ emit("submit-error", e);
5944
6472
  }
5945
6473
  };
6474
+ const errorHandler = (e) => {
6475
+ emit("form-error", e);
6476
+ };
5946
6477
  __expose({ configForm, submit });
5947
6478
  return (_ctx, _cache) => {
5948
- return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$d, [
6479
+ return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$b, [
5949
6480
  renderSlot(_ctx.$slots, "props-panel-header"),
5950
6481
  createVNode(unref(MForm), {
5951
6482
  ref_key: "configForm",
@@ -5956,7 +6487,8 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
5956
6487
  "init-values": values.value,
5957
6488
  config: curFormConfig.value,
5958
6489
  "extend-state": _ctx.extendState,
5959
- onChange: submit
6490
+ onChange: submit,
6491
+ onError: errorHandler
5960
6492
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"])
5961
6493
  ], 512)), [
5962
6494
  [vShow, nodes.value.length === 1]
@@ -6096,7 +6628,7 @@ const useFloatBox = (slideKeys) => {
6096
6628
  };
6097
6629
  };
6098
6630
 
6099
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
6631
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
6100
6632
  ...{
6101
6633
  name: "MEditorSearchInput"
6102
6634
  },
@@ -6147,14 +6679,14 @@ const updateStatus = (nodeStatusMap, id, status) => {
6147
6679
  });
6148
6680
  };
6149
6681
 
6150
- const _hoisted_1$c = ["draggable", "data-node-id", "data-is-container"];
6151
- const _hoisted_2$7 = { class: "tree-node-label" };
6682
+ const _hoisted_1$a = ["draggable", "data-node-id", "data-is-container"];
6683
+ const _hoisted_2$6 = { class: "tree-node-label" };
6152
6684
  const _hoisted_3$3 = { class: "tree-node-tool" };
6153
6685
  const _hoisted_4$3 = {
6154
6686
  key: 0,
6155
6687
  class: "m-editor-tree-node-children"
6156
6688
  };
6157
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
6689
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6158
6690
  ...{
6159
6691
  name: "MEditorTreeNode"
6160
6692
  },
@@ -6180,7 +6712,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6180
6712
  const selected = computed(() => nodeStatus.value.selected);
6181
6713
  const visible = computed(() => nodeStatus.value.visible);
6182
6714
  const draggable = computed(() => nodeStatus.value.draggable);
6183
- const hasChilren = computed(() => props.data.items?.some((item) => props.nodeStatusMap.get(item.id)?.visible));
6715
+ const hasChildren = computed(() => props.data.items?.some((item) => props.nodeStatusMap.get(item.id)?.visible));
6184
6716
  const handleDragStart = (event) => {
6185
6717
  treeEmit?.("node-dragstart", event, props.data);
6186
6718
  };
@@ -6221,9 +6753,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6221
6753
  onContextmenu: nodeContentmenuHandler,
6222
6754
  onMouseenter: mouseenterHandler
6223
6755
  }, [
6224
- createVNode(_sfc_main$K, {
6756
+ createVNode(_sfc_main$N, {
6225
6757
  class: "expand-icon",
6226
- style: normalizeStyle(hasChilren.value ? "" : "color: transparent; cursor: default"),
6758
+ style: normalizeStyle(hasChildren.value ? "" : "color: transparent; cursor: default"),
6227
6759
  icon: expanded.value ? unref(ArrowDown) : unref(ArrowRight),
6228
6760
  onClick: expandHandler
6229
6761
  }, null, 8, ["style", "icon"]),
@@ -6232,7 +6764,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6232
6764
  onClick: nodeClickHandler
6233
6765
  }, [
6234
6766
  renderSlot(_ctx.$slots, "tree-node-content", { data: _ctx.data }, () => [
6235
- createElementVNode("div", _hoisted_2$7, [
6767
+ createElementVNode("div", _hoisted_2$6, [
6236
6768
  renderSlot(_ctx.$slots, "tree-node-label", { data: _ctx.data }, () => [
6237
6769
  createTextVNode(toDisplayString(`${_ctx.data.name} (${_ctx.data.id})`), 1)
6238
6770
  ])
@@ -6243,7 +6775,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6243
6775
  ])
6244
6776
  ])
6245
6777
  ], 38),
6246
- hasChilren.value && expanded.value ? (openBlock(), createElementBlock("div", _hoisted_4$3, [
6778
+ hasChildren.value && expanded.value ? (openBlock(), createElementBlock("div", _hoisted_4$3, [
6247
6779
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.items, (item) => {
6248
6780
  return openBlock(), createBlock(_component_TreeNode, {
6249
6781
  key: item.id,
@@ -6264,15 +6796,18 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6264
6796
  }, 1032, ["data", "node-status-map", "indent"]);
6265
6797
  }), 128))
6266
6798
  ])) : createCommentVNode("", true)
6267
- ], 40, _hoisted_1$c)), [
6799
+ ], 40, _hoisted_1$a)), [
6268
6800
  [vShow, visible.value]
6269
6801
  ]);
6270
6802
  };
6271
6803
  }
6272
6804
  });
6273
6805
 
6274
- const _hoisted_1$b = { key: 1 };
6275
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
6806
+ const _hoisted_1$9 = {
6807
+ key: 1,
6808
+ class: "m-editor-tree-empty"
6809
+ };
6810
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
6276
6811
  ...{
6277
6812
  name: "MEditorTree"
6278
6813
  },
@@ -6296,7 +6831,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
6296
6831
  onDragover: handleDragOver
6297
6832
  }, [
6298
6833
  _ctx.data?.length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.data, (item) => {
6299
- return openBlock(), createBlock(_sfc_main$p, {
6834
+ return openBlock(), createBlock(_sfc_main$n, {
6300
6835
  key: item.id,
6301
6836
  data: item,
6302
6837
  indent: _ctx.indent,
@@ -6313,7 +6848,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
6313
6848
  ]),
6314
6849
  _: 2
6315
6850
  }, 1032, ["data", "indent", "node-status-map"]);
6316
- }), 128)) : (openBlock(), createElementBlock("div", _hoisted_1$b, [
6851
+ }), 128)) : (openBlock(), createElementBlock("div", _hoisted_1$9, [
6317
6852
  createElementVNode("p", null, toDisplayString(_ctx.emptyText), 1)
6318
6853
  ]))
6319
6854
  ], 32);
@@ -6393,7 +6928,7 @@ const useNodeStatus$1 = (nodeData) => {
6393
6928
  };
6394
6929
  };
6395
6930
 
6396
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
6931
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
6397
6932
  ...{
6398
6933
  name: "MEditorCodeBlockList"
6399
6934
  },
@@ -6475,7 +7010,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6475
7010
  filter: filterTextChangeHandler
6476
7011
  });
6477
7012
  return (_ctx, _cache) => {
6478
- return openBlock(), createBlock(_sfc_main$o, {
7013
+ return openBlock(), createBlock(_sfc_main$m, {
6479
7014
  data: codeList.value,
6480
7015
  "node-status-map": unref(nodeStatusMap),
6481
7016
  onNodeClick: clickHandler
@@ -6497,7 +7032,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6497
7032
  placement: "bottom"
6498
7033
  }, {
6499
7034
  default: withCtx(() => [
6500
- createVNode(_sfc_main$K, {
7035
+ createVNode(_sfc_main$N, {
6501
7036
  icon: editable.value ? unref(Edit) : unref(View),
6502
7037
  class: "edit-icon",
6503
7038
  onClick: withModifiers(($event) => editCode(`${data.key}`), ["stop"])
@@ -6512,7 +7047,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6512
7047
  placement: "bottom"
6513
7048
  }, {
6514
7049
  default: withCtx(() => [
6515
- createVNode(_sfc_main$K, {
7050
+ createVNode(_sfc_main$N, {
6516
7051
  icon: unref(Close),
6517
7052
  class: "edit-icon",
6518
7053
  onClick: withModifiers(($event) => deleteCode(`${data.key}`), ["stop"])
@@ -6531,8 +7066,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
6531
7066
  }
6532
7067
  });
6533
7068
 
6534
- const _hoisted_1$a = { class: "search-wrapper" };
6535
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
7069
+ const _hoisted_1$8 = { class: "search-wrapper" };
7070
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
6536
7071
  ...{
6537
7072
  name: "MEditorCodeBlockListPanel"
6538
7073
  },
@@ -6554,8 +7089,8 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
6554
7089
  createVNode(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-layer-panel" }, {
6555
7090
  default: withCtx(() => [
6556
7091
  renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
6557
- createElementVNode("div", _hoisted_1$a, [
6558
- createVNode(_sfc_main$q, { onSearch: filterTextChangeHandler }),
7092
+ createElementVNode("div", _hoisted_1$8, [
7093
+ createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
6559
7094
  editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
6560
7095
  key: 0,
6561
7096
  class: "create-code-button",
@@ -6571,7 +7106,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
6571
7106
  renderSlot(_ctx.$slots, "code-block-panel-search")
6572
7107
  ])
6573
7108
  ]),
6574
- createVNode(_sfc_main$n, {
7109
+ createVNode(_sfc_main$l, {
6575
7110
  ref_key: "codeBlockList",
6576
7111
  ref: codeBlockList,
6577
7112
  "custom-error": _ctx.customError,
@@ -6589,7 +7124,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
6589
7124
  ]),
6590
7125
  _: 3
6591
7126
  }),
6592
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$M, {
7127
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$P, {
6593
7128
  key: 0,
6594
7129
  ref_key: "codeBlockEditor",
6595
7130
  ref: codeBlockEditor,
@@ -6603,7 +7138,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
6603
7138
  }
6604
7139
  });
6605
7140
 
6606
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
7141
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
6607
7142
  ...{
6608
7143
  name: "MEditorDataSourceConfigPanel"
6609
7144
  },
@@ -6659,7 +7194,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
6659
7194
  }
6660
7195
  });
6661
7196
 
6662
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
7197
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
6663
7198
  ...{
6664
7199
  name: "MEditorDataSourceList"
6665
7200
  },
@@ -6748,7 +7283,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
6748
7283
  filter: filterTextChangeHandler
6749
7284
  });
6750
7285
  return (_ctx, _cache) => {
6751
- return openBlock(), createBlock(_sfc_main$o, {
7286
+ return openBlock(), createBlock(_sfc_main$m, {
6752
7287
  data: list.value,
6753
7288
  "node-status-map": unref(nodeStatusMap),
6754
7289
  onNodeClick: clickHandler
@@ -6770,7 +7305,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
6770
7305
  placement: "bottom"
6771
7306
  }, {
6772
7307
  default: withCtx(() => [
6773
- createVNode(_sfc_main$K, {
7308
+ createVNode(_sfc_main$N, {
6774
7309
  icon: editable.value ? unref(Edit) : unref(View),
6775
7310
  class: "edit-icon",
6776
7311
  onClick: withModifiers(($event) => editHandler(`${data.key}`), ["stop"])
@@ -6785,7 +7320,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
6785
7320
  placement: "bottom"
6786
7321
  }, {
6787
7322
  default: withCtx(() => [
6788
- createVNode(_sfc_main$K, {
7323
+ createVNode(_sfc_main$N, {
6789
7324
  icon: unref(Close),
6790
7325
  class: "edit-icon",
6791
7326
  onClick: withModifiers(($event) => removeHandler(`${data.key}`), ["stop"])
@@ -6801,9 +7336,9 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
6801
7336
  }
6802
7337
  });
6803
7338
 
6804
- const _hoisted_1$9 = { class: "search-wrapper" };
6805
- const _hoisted_2$6 = { class: "data-source-list-panel-add-menu" };
6806
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
7339
+ const _hoisted_1$7 = { class: "search-wrapper" };
7340
+ const _hoisted_2$5 = { class: "data-source-list-panel-add-menu" };
7341
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
6807
7342
  ...{
6808
7343
  name: "MEditorDataSourceListPanel"
6809
7344
  },
@@ -6867,8 +7402,8 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
6867
7402
  return openBlock(), createElementBlock(Fragment, null, [
6868
7403
  createVNode(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-layer-panel" }, {
6869
7404
  default: withCtx(() => [
6870
- createElementVNode("div", _hoisted_1$9, [
6871
- createVNode(_sfc_main$q, { onSearch: filterTextChangeHandler }),
7405
+ createElementVNode("div", _hoisted_1$7, [
7406
+ createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
6872
7407
  editable.value ? (openBlock(), createBlock(unref(TMagicPopover), {
6873
7408
  key: 0,
6874
7409
  placement: "right"
@@ -6885,9 +7420,9 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
6885
7420
  })
6886
7421
  ]),
6887
7422
  default: withCtx(() => [
6888
- createElementVNode("div", _hoisted_2$6, [
7423
+ createElementVNode("div", _hoisted_2$5, [
6889
7424
  (openBlock(true), createElementBlock(Fragment, null, renderList(datasourceTypeList.value, (item, index) => {
6890
- return openBlock(), createBlock(_sfc_main$t, {
7425
+ return openBlock(), createBlock(_sfc_main$x, {
6891
7426
  data: {
6892
7427
  type: "button",
6893
7428
  text: item.text,
@@ -6903,14 +7438,14 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
6903
7438
  _: 1
6904
7439
  })) : createCommentVNode("", true)
6905
7440
  ]),
6906
- createVNode(_sfc_main$k, {
7441
+ createVNode(_sfc_main$i, {
6907
7442
  onEdit: editHandler,
6908
7443
  onRemove: removeHandler
6909
7444
  })
6910
7445
  ]),
6911
7446
  _: 1
6912
7447
  }),
6913
- createVNode(_sfc_main$l, {
7448
+ createVNode(_sfc_main$j, {
6914
7449
  ref_key: "editDialog",
6915
7450
  ref: editDialog,
6916
7451
  disabled: !editable.value,
@@ -6924,7 +7459,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
6924
7459
  }
6925
7460
  });
6926
7461
 
6927
- const _sfc_main$i = /* @__PURE__ */ defineComponent({
7462
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
6928
7463
  ...{
6929
7464
  name: "MEditorContentMenu"
6930
7465
  },
@@ -6965,7 +7500,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
6965
7500
  return;
6966
7501
  hide();
6967
7502
  };
6968
- const outsideClickhideHandler = (e) => {
7503
+ const outsideClickHideHandler = (e) => {
6969
7504
  if (!props.autoHide)
6970
7505
  return;
6971
7506
  const target = e.target;
@@ -7026,12 +7561,12 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7026
7561
  onMounted(() => {
7027
7562
  if (props.isSubMenu)
7028
7563
  return;
7029
- globalThis.addEventListener("mousedown", outsideClickhideHandler, true);
7564
+ globalThis.addEventListener("mousedown", outsideClickHideHandler, true);
7030
7565
  });
7031
- onUnmounted(() => {
7566
+ onBeforeUnmount(() => {
7032
7567
  if (props.isSubMenu)
7033
7568
  return;
7034
- globalThis.removeEventListener("mousedown", outsideClickhideHandler, true);
7569
+ globalThis.removeEventListener("mousedown", outsideClickHideHandler, true);
7035
7570
  });
7036
7571
  __expose({
7037
7572
  menu,
@@ -7055,7 +7590,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7055
7590
  renderSlot(_ctx.$slots, "title"),
7056
7591
  createElementVNode("div", null, [
7057
7592
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
7058
- return openBlock(), createBlock(_sfc_main$t, {
7593
+ return openBlock(), createBlock(_sfc_main$x, {
7059
7594
  "event-type": "mouseup",
7060
7595
  ref_for: true,
7061
7596
  ref_key: "buttons",
@@ -7090,7 +7625,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7090
7625
  }
7091
7626
  });
7092
7627
 
7093
- const _hoisted_1$8 = {
7628
+ const _hoisted_1$6 = {
7094
7629
  width: "1em",
7095
7630
  height: "1em",
7096
7631
  viewBox: "0 0 16 16",
@@ -7098,7 +7633,7 @@ const _hoisted_1$8 = {
7098
7633
  fill: "currentColor",
7099
7634
  xmlns: "http://www.w3.org/2000/svg"
7100
7635
  };
7101
- const _hoisted_2$5 = /* @__PURE__ */ createElementVNode("path", {
7636
+ const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("path", {
7102
7637
  "fill-rule": "evenodd",
7103
7638
  d: "M9.828 4H2.19a1 1 0 0 0-.996 1.09l.637 7a1 1 0 0 0 .995.91H9v1H2.826a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31L.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181L15.546 8H14.54l.265-2.91A1 1 0 0 0 13.81 4H9.828zm-2.95-1.707L7.587 3H2.19c-.24 0-.47.042-.684.12L1.5 2.98a1 1 0 0 1 1-.98h3.672a1 1 0 0 1 .707.293z"
7104
7639
  }, null, -1);
@@ -7107,17 +7642,17 @@ const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("path", {
7107
7642
  d: "M11 11.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5z"
7108
7643
  }, null, -1);
7109
7644
  const _hoisted_4$2 = [
7110
- _hoisted_2$5,
7645
+ _hoisted_2$4,
7111
7646
  _hoisted_3$2
7112
7647
  ];
7113
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
7648
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
7114
7649
  ...{
7115
7650
  name: "MEditorFolderMinusIcon"
7116
7651
  },
7117
7652
  __name: "FolderMinusIcon",
7118
7653
  setup(__props) {
7119
7654
  return (_ctx, _cache) => {
7120
- return openBlock(), createElementBlock("svg", _hoisted_1$8, _hoisted_4$2);
7655
+ return openBlock(), createElementBlock("svg", _hoisted_1$6, _hoisted_4$2);
7121
7656
  };
7122
7657
  }
7123
7658
  });
@@ -7128,7 +7663,7 @@ const useDeleteMenu = () => ({
7128
7663
  icon: Delete,
7129
7664
  display: (services) => {
7130
7665
  const node = services?.editorService?.get("node");
7131
- return node?.type !== NodeType.ROOT && !isPage(node);
7666
+ return node?.type !== NodeType.ROOT && !isPage(node) && !isPageFragment(node);
7132
7667
  },
7133
7668
  handler: (services) => {
7134
7669
  const nodes = services?.editorService?.get("nodes");
@@ -7195,13 +7730,14 @@ const useMoveToMenu = (services) => {
7195
7730
  };
7196
7731
  };
7197
7732
 
7198
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
7733
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7199
7734
  ...{
7200
7735
  name: "MEditorLayerMenu"
7201
7736
  },
7202
7737
  __name: "LayerMenu",
7203
7738
  props: {
7204
- layerContentMenu: {}
7739
+ layerContentMenu: { default: () => [] },
7740
+ customContentMenu: { type: Function, default: (menus) => menus }
7205
7741
  },
7206
7742
  emits: ["collapse-all"],
7207
7743
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -7255,29 +7791,34 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7255
7791
  }
7256
7792
  return [];
7257
7793
  });
7258
- const menuData = computed(() => [
7259
- {
7260
- type: "button",
7261
- text: "全部折叠",
7262
- icon: _sfc_main$h,
7263
- display: () => isPage(node.value),
7264
- handler: () => {
7265
- emit("collapse-all");
7266
- }
7267
- },
7268
- {
7269
- type: "button",
7270
- text: "新增",
7271
- icon: markRaw(Plus),
7272
- display: () => node.value?.items && nodes.value?.length === 1,
7273
- items: getSubMenuData.value
7274
- },
7275
- useCopyMenu(),
7276
- usePasteMenu(),
7277
- useDeleteMenu(),
7278
- useMoveToMenu(services),
7279
- ...props.layerContentMenu
7280
- ]);
7794
+ const menuData = computed(
7795
+ () => props.customContentMenu(
7796
+ [
7797
+ {
7798
+ type: "button",
7799
+ text: "全部折叠",
7800
+ icon: _sfc_main$f,
7801
+ display: () => isPage(node.value) || isPageFragment(node.value),
7802
+ handler: () => {
7803
+ emit("collapse-all");
7804
+ }
7805
+ },
7806
+ {
7807
+ type: "button",
7808
+ text: "新增",
7809
+ icon: markRaw(Plus),
7810
+ display: () => node.value?.items && nodes.value?.length === 1,
7811
+ items: getSubMenuData.value
7812
+ },
7813
+ useCopyMenu(),
7814
+ usePasteMenu(),
7815
+ useDeleteMenu(),
7816
+ useMoveToMenu(services),
7817
+ ...props.layerContentMenu
7818
+ ],
7819
+ "layer"
7820
+ )
7821
+ );
7281
7822
  const show = (e) => {
7282
7823
  menu.value?.show(e);
7283
7824
  };
@@ -7285,7 +7826,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7285
7826
  show
7286
7827
  });
7287
7828
  return (_ctx, _cache) => {
7288
- return openBlock(), createBlock(_sfc_main$i, {
7829
+ return openBlock(), createBlock(_sfc_main$g, {
7289
7830
  "menu-data": menuData.value,
7290
7831
  ref_key: "menu",
7291
7832
  ref: menu,
@@ -7295,7 +7836,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7295
7836
  }
7296
7837
  });
7297
7838
 
7298
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
7839
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
7299
7840
  __name: "LayerNodeTool",
7300
7841
  props: {
7301
7842
  data: {}
@@ -7314,12 +7855,12 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
7314
7855
  };
7315
7856
  return (_ctx, _cache) => {
7316
7857
  return _ctx.data.type !== "page" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
7317
- _ctx.data.visible === false ? (openBlock(), createBlock(_sfc_main$K, {
7858
+ _ctx.data.visible === false ? (openBlock(), createBlock(_sfc_main$N, {
7318
7859
  key: 0,
7319
7860
  icon: unref(Hide),
7320
7861
  onClick: _cache[0] || (_cache[0] = withModifiers(($event) => setNodeVisible(true), ["stop"])),
7321
7862
  title: "点击显示"
7322
- }, null, 8, ["icon"])) : (openBlock(), createBlock(_sfc_main$K, {
7863
+ }, null, 8, ["icon"])) : (openBlock(), createBlock(_sfc_main$N, {
7323
7864
  key: 1,
7324
7865
  icon: unref(View),
7325
7866
  onClick: _cache[1] || (_cache[1] = withModifiers(($event) => setNodeVisible(false), ["stop"])),
@@ -7332,11 +7873,12 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
7332
7873
  });
7333
7874
 
7334
7875
  const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
7876
+ const isMultiSelect = computed(() => isCtrlKeyDown.value && !services?.editorService.get("disabledMultiSelect"));
7335
7877
  const select = async (data) => {
7336
7878
  if (!data.id) {
7337
7879
  throw new Error("没有id");
7338
7880
  }
7339
- if (isCtrlKeyDown.value) {
7881
+ if (isMultiSelect.value) {
7340
7882
  multiSelect(data);
7341
7883
  } else {
7342
7884
  await services?.editorService.select(data);
@@ -7375,7 +7917,7 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
7375
7917
  document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: data }));
7376
7918
  return;
7377
7919
  }
7378
- if (data.items && data.items.length > 0 && !isCtrlKeyDown.value) {
7920
+ if (data.items && data.items.length > 0 && !isMultiSelect.value) {
7379
7921
  updateStatus(nodeStatusMap.value, data.id, {
7380
7922
  expand: true
7381
7923
  });
@@ -7645,21 +8187,21 @@ const keybindingConfig = [
7645
8187
  }
7646
8188
  ];
7647
8189
 
7648
- const useKeybinding = (services, contianer) => {
8190
+ const useKeybinding = (services, container) => {
7649
8191
  const keybindingService = services?.keybindingService;
7650
8192
  const isCtrlKeyDown = ref(false);
7651
8193
  const windowBlurHandler = () => {
7652
8194
  isCtrlKeyDown.value = false;
7653
8195
  };
7654
- keybindingService?.registeCommand("layer-panel-global-keyup", () => {
8196
+ keybindingService?.registerCommand("layer-panel-global-keyup", () => {
7655
8197
  isCtrlKeyDown.value = false;
7656
8198
  });
7657
- keybindingService?.registeCommand("layer-panel-global-keydwon", () => {
8199
+ keybindingService?.registerCommand("layer-panel-global-keydown", () => {
7658
8200
  isCtrlKeyDown.value = true;
7659
8201
  });
7660
- keybindingService?.registe([
8202
+ keybindingService?.register([
7661
8203
  {
7662
- command: "layer-panel-global-keydwon",
8204
+ command: "layer-panel-global-keydown",
7663
8205
  keybinding: "ctrl",
7664
8206
  when: [["global", "keydown"]]
7665
8207
  },
@@ -7670,12 +8212,12 @@ const useKeybinding = (services, contianer) => {
7670
8212
  }
7671
8213
  ]);
7672
8214
  watchEffect(() => {
7673
- if (contianer.value) {
8215
+ if (container.value) {
7674
8216
  globalThis.addEventListener("blur", windowBlurHandler);
7675
- keybindingService?.registeEl(KeyBindingContainerKey.LAYER_PANEL, contianer.value.$el);
8217
+ keybindingService?.registerEl(KeyBindingContainerKey.LAYER_PANEL, container.value.$el);
7676
8218
  } else {
7677
8219
  globalThis.removeEventListener("blur", windowBlurHandler);
7678
- keybindingService?.unregisteEl(KeyBindingContainerKey.LAYER_PANEL);
8220
+ keybindingService?.unregisterEl(KeyBindingContainerKey.LAYER_PANEL);
7679
8221
  }
7680
8222
  });
7681
8223
  return {
@@ -7683,7 +8225,7 @@ const useKeybinding = (services, contianer) => {
7683
8225
  };
7684
8226
  };
7685
8227
 
7686
- const createPageNodeStatus = (page, initalLayerNodeStatus) => {
8228
+ const createPageNodeStatus = (page, initialLayerNodeStatus) => {
7687
8229
  const map = /* @__PURE__ */ new Map();
7688
8230
  map.set(page.id, {
7689
8231
  visible: true,
@@ -7695,7 +8237,7 @@ const createPageNodeStatus = (page, initalLayerNodeStatus) => {
7695
8237
  (node) => traverseNode(node, (node2) => {
7696
8238
  map.set(
7697
8239
  node2.id,
7698
- initalLayerNodeStatus?.get(node2.id) || {
8240
+ initialLayerNodeStatus?.get(node2.id) || {
7699
8241
  visible: true,
7700
8242
  expand: false,
7701
8243
  selected: false,
@@ -7770,13 +8312,14 @@ const useNodeStatus = (services) => {
7770
8312
  };
7771
8313
  };
7772
8314
 
7773
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
8315
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
7774
8316
  ...{
7775
8317
  name: "MEditorLayerPanel"
7776
8318
  },
7777
8319
  __name: "LayerPanel",
7778
8320
  props: {
7779
- layerContentMenu: {}
8321
+ layerContentMenu: {},
8322
+ customContentMenu: { type: Function }
7780
8323
  },
7781
8324
  setup(__props) {
7782
8325
  const services = inject("services");
@@ -7818,8 +8361,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7818
8361
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-layer-panel" }, {
7819
8362
  default: withCtx(() => [
7820
8363
  renderSlot(_ctx.$slots, "layer-panel-header"),
7821
- createVNode(_sfc_main$q, { onSearch: unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
7822
- page.value && unref(nodeStatusMap) ? (openBlock(), createBlock(_sfc_main$o, {
8364
+ createVNode(_sfc_main$o, { onSearch: unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
8365
+ page.value && unref(nodeStatusMap) ? (openBlock(), createBlock(_sfc_main$m, {
7823
8366
  key: 0,
7824
8367
  tabindex: "-1",
7825
8368
  ref_key: "tree",
@@ -7839,7 +8382,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7839
8382
  ]),
7840
8383
  "tree-node-tool": withCtx(({ data: nodeData2 }) => [
7841
8384
  renderSlot(_ctx.$slots, "layer-node-tool", { data: nodeData2 }, () => [
7842
- createVNode(_sfc_main$f, { data: nodeData2 }, null, 8, ["data"])
8385
+ createVNode(_sfc_main$d, { data: nodeData2 }, null, 8, ["data"])
7843
8386
  ])
7844
8387
  ]),
7845
8388
  "tree-node-label": withCtx(({ data: nodeData2 }) => [
@@ -7848,12 +8391,13 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7848
8391
  _: 3
7849
8392
  }, 8, ["data", "node-status-map", "onNodeDragover", "onNodeDragstart", "onNodeDragleave", "onNodeDragend", "onNodeContextmenu", "onNodeMouseenter", "onNodeClick"])) : createCommentVNode("", true),
7850
8393
  (openBlock(), createBlock(Teleport, { to: "body" }, [
7851
- createVNode(_sfc_main$g, {
8394
+ createVNode(_sfc_main$e, {
7852
8395
  ref_key: "menu",
7853
8396
  ref: menu,
7854
8397
  "layer-content-menu": _ctx.layerContentMenu,
8398
+ "custom-content-menu": _ctx.customContentMenu,
7855
8399
  onCollapseAll: collapseAllHandler
7856
- }, null, 8, ["layer-content-menu"])
8400
+ }, null, 8, ["layer-content-menu", "custom-content-menu"])
7857
8401
  ]))
7858
8402
  ]),
7859
8403
  _: 3
@@ -7862,9 +8406,9 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
7862
8406
  }
7863
8407
  });
7864
8408
 
7865
- const _hoisted_1$7 = ["onClick", "onDragstart"];
7866
- const _hoisted_2$4 = ["title"];
7867
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
8409
+ const _hoisted_1$5 = ["onClick", "onDragstart"];
8410
+ const _hoisted_2$3 = ["title"];
8411
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
7868
8412
  ...{
7869
8413
  name: "MEditorComponentListPanel"
7870
8414
  },
@@ -7944,7 +8488,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
7944
8488
  "model-value": collapseValue.value
7945
8489
  }, {
7946
8490
  default: withCtx(() => [
7947
- createVNode(_sfc_main$q, { onSearch: filterTextChangeHandler }),
8491
+ createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
7948
8492
  (openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
7949
8493
  return openBlock(), createElementBlock(Fragment, null, [
7950
8494
  group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
@@ -7952,7 +8496,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
7952
8496
  name: `${index}`
7953
8497
  }, {
7954
8498
  title: withCtx(() => [
7955
- createVNode(_sfc_main$K, { icon: unref(Grid) }, null, 8, ["icon"]),
8499
+ createVNode(_sfc_main$N, { icon: unref(Grid) }, null, 8, ["icon"]),
7956
8500
  createTextVNode(toDisplayString(group.title), 1)
7957
8501
  ]),
7958
8502
  default: withCtx(() => [
@@ -7973,7 +8517,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
7973
8517
  content: item.desc
7974
8518
  }, {
7975
8519
  default: withCtx(() => [
7976
- createVNode(_sfc_main$K, {
8520
+ createVNode(_sfc_main$N, {
7977
8521
  icon: item.icon
7978
8522
  }, null, 8, ["icon"])
7979
8523
  ]),
@@ -7981,9 +8525,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
7981
8525
  }, 1032, ["disabled", "content"]),
7982
8526
  createElementVNode("span", {
7983
8527
  title: item.text
7984
- }, toDisplayString(item.text), 9, _hoisted_2$4)
8528
+ }, toDisplayString(item.text), 9, _hoisted_2$3)
7985
8529
  ])
7986
- ], 40, _hoisted_1$7);
8530
+ ], 40, _hoisted_1$5);
7987
8531
  }), 128))
7988
8532
  ]),
7989
8533
  _: 2
@@ -8000,11 +8544,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
8000
8544
  }
8001
8545
  });
8002
8546
 
8003
- const _hoisted_1$6 = {
8547
+ const _hoisted_1$4 = {
8004
8548
  key: 0,
8005
8549
  class: "m-editor-sidebar"
8006
8550
  };
8007
- const _hoisted_2$3 = { class: "m-editor-sidebar-header" };
8551
+ const _hoisted_2$2 = { class: "m-editor-sidebar-header" };
8008
8552
  const _hoisted_3$1 = ["onClick", "onDragend"];
8009
8553
  const _hoisted_4$1 = {
8010
8554
  key: 1,
@@ -8013,14 +8557,15 @@ const _hoisted_4$1 = {
8013
8557
  const _hoisted_5$1 = { class: "m-editor-float-box-list" };
8014
8558
  const _hoisted_6 = ["onClick"];
8015
8559
  const _hoisted_7 = { class: "m-editor-float-box-body" };
8016
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
8560
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8017
8561
  ...{
8018
8562
  name: "MEditorSidebar"
8019
8563
  },
8020
8564
  __name: "Sidebar",
8021
8565
  props: {
8022
8566
  data: { default: () => ({ type: "tabs", status: "组件", items: ["component-list", "layer", "code-block", "data-source"] }) },
8023
- layerContentMenu: {}
8567
+ layerContentMenu: {},
8568
+ customContentMenu: {}
8024
8569
  },
8025
8570
  setup(__props, { expose: __expose }) {
8026
8571
  const props = __props;
@@ -8033,7 +8578,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8033
8578
  type: "component",
8034
8579
  icon: Goods,
8035
8580
  text: "组件",
8036
- component: _sfc_main$d,
8581
+ component: _sfc_main$b,
8037
8582
  slots: {}
8038
8583
  },
8039
8584
  layer: {
@@ -8042,9 +8587,10 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8042
8587
  icon: List,
8043
8588
  text: "已选组件",
8044
8589
  props: {
8045
- layerContentMenu: props.layerContentMenu
8590
+ layerContentMenu: props.layerContentMenu,
8591
+ customContentMenu: props.customContentMenu
8046
8592
  },
8047
- component: _sfc_main$e,
8593
+ component: _sfc_main$c,
8048
8594
  slots: {}
8049
8595
  },
8050
8596
  "code-block": {
@@ -8052,7 +8598,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8052
8598
  type: "component",
8053
8599
  icon: EditPen,
8054
8600
  text: "代码编辑",
8055
- component: _sfc_main$m,
8601
+ component: _sfc_main$k,
8056
8602
  slots: {},
8057
8603
  boxComponentConfig: {
8058
8604
  props: {
@@ -8065,7 +8611,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8065
8611
  type: "component",
8066
8612
  icon: Coin,
8067
8613
  text: "数据源",
8068
- component: _sfc_main$j,
8614
+ component: _sfc_main$h,
8069
8615
  slots: {},
8070
8616
  boxComponentConfig: {
8071
8617
  props: {
@@ -8108,8 +8654,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8108
8654
  });
8109
8655
  return (_ctx, _cache) => {
8110
8656
  return openBlock(), createElementBlock(Fragment, null, [
8111
- _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
8112
- createElementVNode("div", _hoisted_2$3, [
8657
+ _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
8658
+ createElementVNode("div", _hoisted_2$2, [
8113
8659
  (openBlock(true), createElementBlock(Fragment, null, renderList(sideBarItems.value, (config, index) => {
8114
8660
  return withDirectives((openBlock(), createElementBlock("div", {
8115
8661
  class: normalizeClass(["m-editor-sidebar-header-item", { "is-active": activeTabName.value === config.text }]),
@@ -8120,7 +8666,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8120
8666
  (...args) => unref(dragstartHandler) && unref(dragstartHandler)(...args)),
8121
8667
  onDragend: ($event) => unref(dragendHandler)(config.$key, $event)
8122
8668
  }, [
8123
- config.icon ? (openBlock(), createBlock(_sfc_main$K, {
8669
+ config.icon ? (openBlock(), createBlock(_sfc_main$N, {
8124
8670
  key: 0,
8125
8671
  icon: config.icon
8126
8672
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -8256,7 +8802,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
8256
8802
  onClick: ($event) => unref(showFloatBox)(config.$key)
8257
8803
  }, [
8258
8804
  createElementVNode("div", null, toDisplayString(config.text), 1),
8259
- createVNode(_sfc_main$K, {
8805
+ createVNode(_sfc_main$N, {
8260
8806
  class: "m-editor-float-box-close",
8261
8807
  icon: unref(Close),
8262
8808
  onClick: withModifiers(($event) => unref(closeFloatBox)(config.$key), ["stop"])
@@ -8404,7 +8950,7 @@ class ScrollViewer extends EventEmitter {
8404
8950
  };
8405
8951
  }
8406
8952
 
8407
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
8953
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8408
8954
  ...{
8409
8955
  name: "MEditorScrollBar"
8410
8956
  },
@@ -8443,7 +8989,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
8443
8989
  });
8444
8990
  bar.value?.addEventListener("wheel", wheelHandler, false);
8445
8991
  });
8446
- onUnmounted(() => {
8992
+ onBeforeUnmount(() => {
8447
8993
  if (gesto)
8448
8994
  gesto.off();
8449
8995
  bar.value?.removeEventListener("wheel", wheelHandler, false);
@@ -8492,7 +9038,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
8492
9038
  }
8493
9039
  });
8494
9040
 
8495
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
9041
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8496
9042
  ...{
8497
9043
  name: "MEditorScrollViewer"
8498
9044
  },
@@ -8539,7 +9085,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8539
9085
  scrollHeight.value = data.scrollHeight;
8540
9086
  });
8541
9087
  });
8542
- onUnmounted(() => {
9088
+ onBeforeUnmount(() => {
8543
9089
  scrollViewer.destroy();
8544
9090
  });
8545
9091
  watch(
@@ -8578,14 +9124,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
8578
9124
  }, [
8579
9125
  renderSlot(_ctx.$slots, "default")
8580
9126
  ], 4),
8581
- scrollHeight.value > _ctx.wrapHeight ? (openBlock(), createBlock(_sfc_main$b, {
9127
+ scrollHeight.value > _ctx.wrapHeight ? (openBlock(), createBlock(_sfc_main$9, {
8582
9128
  key: 0,
8583
9129
  "scroll-size": scrollHeight.value,
8584
9130
  size: _ctx.wrapHeight,
8585
9131
  pos: vOffset.value,
8586
9132
  onScroll: vScrollHandler
8587
9133
  }, null, 8, ["scroll-size", "size", "pos"])) : createCommentVNode("", true),
8588
- scrollWidth.value > _ctx.wrapWidth ? (openBlock(), createBlock(_sfc_main$b, {
9134
+ scrollWidth.value > _ctx.wrapWidth ? (openBlock(), createBlock(_sfc_main$9, {
8589
9135
  key: 1,
8590
9136
  "is-horizontal": true,
8591
9137
  "scroll-size": scrollWidth.value,
@@ -8728,12 +9274,27 @@ const useStage = (stageOptions) => {
8728
9274
  return elCanSelect;
8729
9275
  },
8730
9276
  moveableOptions: stageOptions.moveableOptions,
8731
- updateDragEl: stageOptions.updateDragEl
9277
+ updateDragEl: stageOptions.updateDragEl,
9278
+ guidesOptions: stageOptions.guidesOptions,
9279
+ disabledMultiSelect: stageOptions.disabledMultiSelect
8732
9280
  });
9281
+ watch(
9282
+ () => editorService.get("disabledMultiSelect"),
9283
+ (disabledMultiSelect) => {
9284
+ if (disabledMultiSelect) {
9285
+ stage.disableMultiSelect();
9286
+ } else {
9287
+ stage.enableMultiSelect();
9288
+ }
9289
+ }
9290
+ );
8733
9291
  stage.mask.setGuides([
8734
9292
  getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
8735
9293
  getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
8736
9294
  ]);
9295
+ stage.on("page-el-update", () => {
9296
+ editorService.set("stageLoading", false);
9297
+ });
8737
9298
  stage.on("select", (el) => {
8738
9299
  if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
8739
9300
  return;
@@ -8784,8 +9345,8 @@ const useStage = (stageOptions) => {
8784
9345
  return stage;
8785
9346
  };
8786
9347
 
8787
- const _hoisted_1$5 = { class: "m-editor-float-box-body" };
8788
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
9348
+ const _hoisted_1$3 = { class: "m-editor-float-box-body" };
9349
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
8789
9350
  __name: "FloatingBox",
8790
9351
  props: {
8791
9352
  visible: { type: Boolean, default: false },
@@ -8885,7 +9446,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8885
9446
  }, null, 8, ["icon"])
8886
9447
  ])
8887
9448
  ], 512),
8888
- createElementVNode("div", _hoisted_1$5, [
9449
+ createElementVNode("div", _hoisted_1$3, [
8889
9450
  renderSlot(_ctx.$slots, "body")
8890
9451
  ])
8891
9452
  ], 4)
@@ -8894,7 +9455,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
8894
9455
  }
8895
9456
  });
8896
9457
 
8897
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
9458
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8898
9459
  __name: "NodeListMenu",
8899
9460
  setup(__props) {
8900
9461
  const services = inject("services");
@@ -8915,13 +9476,13 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8915
9476
  (stage2) => {
8916
9477
  if (!stage2)
8917
9478
  return;
9479
+ nextTick(() => unWatch());
8918
9480
  stage2.on("select", (el, event) => {
8919
9481
  const els = stage2.renderer.getElementsFromPoint(event) || [];
8920
9482
  const ids = els.map((el2) => el2.id).filter((id) => Boolean(id));
8921
9483
  buttonVisible.value = ids.length > 3;
8922
9484
  filterTextChangeHandler(ids);
8923
9485
  });
8924
- unWatch();
8925
9486
  },
8926
9487
  {
8927
9488
  immediate: true
@@ -8976,7 +9537,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8976
9537
  ]),
8977
9538
  _: 1
8978
9539
  })) : createCommentVNode("", true),
8979
- page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$9, {
9540
+ page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$7, {
8980
9541
  key: 1,
8981
9542
  ref_key: "box",
8982
9543
  ref: box,
@@ -8986,7 +9547,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
8986
9547
  position: menuPosition.value
8987
9548
  }, {
8988
9549
  body: withCtx(() => [
8989
- createVNode(_sfc_main$o, {
9550
+ createVNode(_sfc_main$m, {
8990
9551
  class: "m-editor-node-list-menu magic-editor-layer-tree",
8991
9552
  data: nodeData.value,
8992
9553
  "node-status-map": unref(nodeStatusMap),
@@ -9000,12 +9561,12 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
9000
9561
  }
9001
9562
  });
9002
9563
 
9003
- const _hoisted_1$4 = {
9564
+ const _hoisted_1$2 = {
9004
9565
  viewBox: "0 0 24 24",
9005
9566
  fill: "none",
9006
9567
  xmlns: "http://www.w3.org/2000/svg"
9007
9568
  };
9008
- const _hoisted_2$2 = /* @__PURE__ */ createElementVNode("path", {
9569
+ const _hoisted_2$1 = /* @__PURE__ */ createElementVNode("path", {
9009
9570
  "fill-rule": "evenodd",
9010
9571
  "clip-rule": "evenodd",
9011
9572
  d: "M2 4H21V6H2V4Z",
@@ -9027,119 +9588,125 @@ const _hoisted_4 = /* @__PURE__ */ createElementVNode("path", {
9027
9588
  "fill-opacity": "0.9"
9028
9589
  }, null, -1);
9029
9590
  const _hoisted_5 = [
9030
- _hoisted_2$2,
9591
+ _hoisted_2$1,
9031
9592
  _hoisted_3,
9032
9593
  _hoisted_4
9033
9594
  ];
9034
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
9595
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
9035
9596
  ...{
9036
9597
  name: "MEditorCenterIcon"
9037
9598
  },
9038
9599
  __name: "CenterIcon",
9039
9600
  setup(__props) {
9040
9601
  return (_ctx, _cache) => {
9041
- return openBlock(), createElementBlock("svg", _hoisted_1$4, _hoisted_5);
9602
+ return openBlock(), createElementBlock("svg", _hoisted_1$2, _hoisted_5);
9042
9603
  };
9043
9604
  }
9044
9605
  });
9045
9606
 
9046
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
9607
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9047
9608
  ...{
9048
9609
  name: "MEditorViewerMenu"
9049
9610
  },
9050
9611
  __name: "ViewerMenu",
9051
9612
  props: {
9052
9613
  isMultiSelect: { type: Boolean, default: false },
9053
- stageContentMenu: {}
9614
+ stageContentMenu: { default: () => [] },
9615
+ customContentMenu: { type: Function, default: (menus) => menus }
9054
9616
  },
9055
9617
  setup(__props, { expose: __expose }) {
9056
9618
  const props = __props;
9057
- const services = inject("services");
9058
- const editorService = services?.editorService;
9059
- const menu = ref();
9060
- const canCenter = ref(false);
9061
- const node = computed(() => editorService?.get("node"));
9062
- const nodes = computed(() => editorService?.get("nodes"));
9063
- const parent = computed(() => editorService?.get("parent"));
9064
- const menuData = computed(() => [
9065
- {
9066
- type: "button",
9067
- text: "水平居中",
9068
- icon: markRaw(_sfc_main$7),
9069
- display: () => canCenter.value,
9070
- handler: () => {
9071
- if (!nodes.value)
9072
- return;
9073
- editorService?.alignCenter(nodes.value);
9074
- }
9075
- },
9076
- useCopyMenu(),
9077
- usePasteMenu(menu),
9078
- {
9079
- type: "divider",
9080
- direction: "horizontal",
9081
- display: () => {
9082
- if (!node.value)
9083
- return false;
9084
- return !isPage(node.value);
9085
- }
9086
- },
9087
- {
9088
- type: "button",
9089
- text: "上移一层",
9090
- icon: markRaw(Top),
9091
- display: () => !isPage(node.value) && !props.isMultiSelect,
9092
- handler: () => {
9093
- editorService?.moveLayer(1);
9094
- }
9095
- },
9096
- {
9097
- type: "button",
9098
- text: "下移一层",
9099
- icon: markRaw(Bottom),
9100
- display: () => !isPage(node.value) && !props.isMultiSelect,
9101
- handler: () => {
9102
- editorService?.moveLayer(-1);
9103
- }
9104
- },
9105
- {
9106
- type: "button",
9107
- text: "置顶",
9108
- icon: markRaw(Top),
9109
- display: () => !isPage(node.value) && !props.isMultiSelect,
9110
- handler: () => {
9111
- editorService?.moveLayer(LayerOffset.TOP);
9112
- }
9113
- },
9114
- {
9115
- type: "button",
9116
- text: "置底",
9117
- icon: markRaw(Bottom),
9118
- display: () => !isPage(node.value) && !props.isMultiSelect,
9119
- handler: () => {
9120
- editorService?.moveLayer(LayerOffset.BOTTOM);
9121
- }
9122
- },
9123
- useMoveToMenu(services),
9124
- {
9125
- type: "divider",
9126
- direction: "horizontal",
9127
- display: () => !isPage(node.value) && !props.isMultiSelect
9128
- },
9129
- useDeleteMenu(),
9130
- {
9131
- type: "divider",
9132
- direction: "horizontal"
9133
- },
9134
- {
9135
- type: "button",
9136
- text: "清空参考线",
9137
- handler: () => {
9138
- editorService?.get("stage")?.clearGuides();
9139
- }
9140
- },
9141
- ...props.stageContentMenu
9142
- ]);
9619
+ const services = inject("services");
9620
+ const editorService = services?.editorService;
9621
+ const menu = ref();
9622
+ const canCenter = ref(false);
9623
+ const node = computed(() => editorService?.get("node"));
9624
+ const nodes = computed(() => editorService?.get("nodes"));
9625
+ const parent = computed(() => editorService?.get("parent"));
9626
+ const menuData = computed(
9627
+ () => props.customContentMenu(
9628
+ [
9629
+ {
9630
+ type: "button",
9631
+ text: "水平居中",
9632
+ icon: markRaw(_sfc_main$5),
9633
+ display: () => canCenter.value,
9634
+ handler: () => {
9635
+ if (!nodes.value)
9636
+ return;
9637
+ editorService?.alignCenter(nodes.value);
9638
+ }
9639
+ },
9640
+ useCopyMenu(),
9641
+ usePasteMenu(menu),
9642
+ {
9643
+ type: "divider",
9644
+ direction: "horizontal",
9645
+ display: () => {
9646
+ if (!node.value)
9647
+ return false;
9648
+ return !isPage(node.value) && !isPageFragment(node.value);
9649
+ }
9650
+ },
9651
+ {
9652
+ type: "button",
9653
+ text: "上移一层",
9654
+ icon: markRaw(Top),
9655
+ display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect,
9656
+ handler: () => {
9657
+ editorService?.moveLayer(1);
9658
+ }
9659
+ },
9660
+ {
9661
+ type: "button",
9662
+ text: "下移一层",
9663
+ icon: markRaw(Bottom),
9664
+ display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect,
9665
+ handler: () => {
9666
+ editorService?.moveLayer(-1);
9667
+ }
9668
+ },
9669
+ {
9670
+ type: "button",
9671
+ text: "置顶",
9672
+ icon: markRaw(Top),
9673
+ display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect,
9674
+ handler: () => {
9675
+ editorService?.moveLayer(LayerOffset.TOP);
9676
+ }
9677
+ },
9678
+ {
9679
+ type: "button",
9680
+ text: "置底",
9681
+ icon: markRaw(Bottom),
9682
+ display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect,
9683
+ handler: () => {
9684
+ editorService?.moveLayer(LayerOffset.BOTTOM);
9685
+ }
9686
+ },
9687
+ useMoveToMenu(services),
9688
+ {
9689
+ type: "divider",
9690
+ direction: "horizontal",
9691
+ display: () => !isPage(node.value) && !isPageFragment(node.value) && !props.isMultiSelect
9692
+ },
9693
+ useDeleteMenu(),
9694
+ {
9695
+ type: "divider",
9696
+ direction: "horizontal"
9697
+ },
9698
+ {
9699
+ type: "button",
9700
+ text: "清空参考线",
9701
+ handler: () => {
9702
+ editorService?.get("stage")?.clearGuides();
9703
+ }
9704
+ },
9705
+ ...props.stageContentMenu
9706
+ ],
9707
+ "viewer"
9708
+ )
9709
+ );
9143
9710
  watch(
9144
9711
  parent,
9145
9712
  async () => {
@@ -9159,7 +9726,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
9159
9726
  };
9160
9727
  __expose({ show });
9161
9728
  return (_ctx, _cache) => {
9162
- return openBlock(), createBlock(_sfc_main$i, {
9729
+ return openBlock(), createBlock(_sfc_main$g, {
9163
9730
  "menu-data": menuData.value,
9164
9731
  ref_key: "menu",
9165
9732
  ref: menu
@@ -9168,13 +9735,14 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
9168
9735
  }
9169
9736
  });
9170
9737
 
9171
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
9738
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
9172
9739
  ...{
9173
9740
  name: "MEditorStage"
9174
9741
  },
9175
9742
  __name: "Stage",
9176
9743
  props: {
9177
- stageContentMenu: {}
9744
+ stageContentMenu: {},
9745
+ customContentMenu: { type: Function }
9178
9746
  },
9179
9747
  setup(__props) {
9180
9748
  let stage = null;
@@ -9223,6 +9791,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
9223
9791
  });
9224
9792
  watch(page, (page2) => {
9225
9793
  if (runtime && page2) {
9794
+ services?.editorService.set("stageLoading", true);
9226
9795
  runtime.updatePageId?.(page2.id);
9227
9796
  nextTick(() => {
9228
9797
  stage?.select(page2.id);
@@ -9246,14 +9815,14 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
9246
9815
  onMounted(() => {
9247
9816
  if (stageWrap.value?.container) {
9248
9817
  resizeObserver.observe(stageWrap.value.container);
9249
- services?.keybindingService.registeEl(KeyBindingContainerKey.STAGE, stageWrap.value.container);
9818
+ services?.keybindingService.registerEl(KeyBindingContainerKey.STAGE, stageWrap.value.container);
9250
9819
  }
9251
9820
  });
9252
- onUnmounted(() => {
9821
+ onBeforeUnmount(() => {
9253
9822
  stage?.destroy();
9254
9823
  resizeObserver.disconnect();
9255
9824
  services?.editorService.set("stage", null);
9256
- services?.keybindingService.unregisteEl("stage");
9825
+ services?.keybindingService.unregisterEl("stage");
9257
9826
  services?.editorService.off("root-change", rootChangeHandler);
9258
9827
  });
9259
9828
  const parseDSL = getConfig("parseDSL");
@@ -9316,7 +9885,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
9316
9885
  }
9317
9886
  };
9318
9887
  return (_ctx, _cache) => {
9319
- return openBlock(), createBlock(_sfc_main$a, {
9888
+ return openBlock(), createBlock(_sfc_main$8, {
9320
9889
  class: "m-editor-stage",
9321
9890
  ref_key: "stageWrap",
9322
9891
  ref: stageWrap,
@@ -9342,14 +9911,15 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
9342
9911
  onDrop: dropHandler,
9343
9912
  onDragover: dragoverHandler
9344
9913
  }, null, 36),
9345
- createVNode(_sfc_main$8),
9914
+ createVNode(_sfc_main$6),
9346
9915
  (openBlock(), createBlock(Teleport, { to: "body" }, [
9347
- createVNode(_sfc_main$6, {
9916
+ createVNode(_sfc_main$4, {
9348
9917
  ref_key: "menu",
9349
9918
  ref: menu,
9350
9919
  "is-multi-select": isMultiSelect.value,
9351
- "stage-content-menu": _ctx.stageContentMenu
9352
- }, null, 8, ["is-multi-select", "stage-content-menu"])
9920
+ "stage-content-menu": _ctx.stageContentMenu,
9921
+ "custom-content-menu": _ctx.customContentMenu
9922
+ }, null, 8, ["is-multi-select", "stage-content-menu", "custom-content-menu"])
9353
9923
  ]))
9354
9924
  ]),
9355
9925
  _: 1
@@ -9358,12 +9928,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
9358
9928
  }
9359
9929
  });
9360
9930
 
9361
- const _hoisted_1$3 = {
9931
+ const _hoisted_1$1 = {
9362
9932
  key: 0,
9363
9933
  class: "m-editor-breadcrumb"
9364
9934
  };
9365
- const _hoisted_2$1 = { key: 0 };
9366
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9935
+ const _hoisted_2 = { key: 0 };
9936
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
9367
9937
  ...{
9368
9938
  name: "MEditorBreadcrumb"
9369
9939
  },
@@ -9380,7 +9950,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9380
9950
  editorService?.get("stage")?.select(node2.id);
9381
9951
  };
9382
9952
  return (_ctx, _cache) => {
9383
- return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
9953
+ return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
9384
9954
  (openBlock(true), createElementBlock(Fragment, null, renderList(path.value, (item, index) => {
9385
9955
  return openBlock(), createElementBlock(Fragment, {
9386
9956
  key: item.id
@@ -9395,7 +9965,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9395
9965
  ]),
9396
9966
  _: 2
9397
9967
  }, 1032, ["disabled", "onClick"]),
9398
- index < path.value.length - 1 ? (openBlock(), createElementBlock("span", _hoisted_2$1, "/")) : createCommentVNode("", true)
9968
+ index < path.value.length - 1 ? (openBlock(), createElementBlock("span", _hoisted_2, "/")) : createCommentVNode("", true)
9399
9969
  ], 64);
9400
9970
  }), 128))
9401
9971
  ])) : createCommentVNode("", true);
@@ -9403,223 +9973,6 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
9403
9973
  }
9404
9974
  });
9405
9975
 
9406
- const _hoisted_1$2 = {
9407
- key: 1,
9408
- style: { "width": "21px" }
9409
- };
9410
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
9411
- ...{
9412
- name: "MEditorPageBarScrollContainer"
9413
- },
9414
- __name: "PageBarScrollContainer",
9415
- setup(__props) {
9416
- const services = inject("services");
9417
- const editorService = services?.editorService;
9418
- const uiService = services?.uiService;
9419
- const itemsContainer = ref();
9420
- const canScroll = ref(false);
9421
- const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
9422
- const itemsContainerWidth = ref(0);
9423
- const setCanScroll = () => {
9424
- itemsContainerWidth.value = (pageBar.value?.clientWidth || 0) - 37 * 2 - (showAddPageButton.value ? 37 : 21);
9425
- nextTick(() => {
9426
- if (itemsContainer.value) {
9427
- canScroll.value = itemsContainer.value.scrollWidth - itemsContainerWidth.value > 1;
9428
- }
9429
- });
9430
- };
9431
- const resizeObserver = new ResizeObserver(() => {
9432
- setCanScroll();
9433
- });
9434
- const pageBar = ref();
9435
- onMounted(() => {
9436
- pageBar.value && resizeObserver.observe(pageBar.value);
9437
- });
9438
- onUnmounted(() => {
9439
- resizeObserver.disconnect();
9440
- });
9441
- let translateLeft = 0;
9442
- const scroll = (type) => {
9443
- if (!itemsContainer.value)
9444
- return;
9445
- const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
9446
- if (type === "left") {
9447
- translateLeft += 100;
9448
- if (translateLeft > 0) {
9449
- translateLeft = 0;
9450
- }
9451
- } else if (type === "right") {
9452
- translateLeft -= 100;
9453
- if (-translateLeft > maxScrollLeft) {
9454
- translateLeft = -maxScrollLeft;
9455
- }
9456
- } else if (type === "start") {
9457
- translateLeft = 0;
9458
- } else if (type === "end") {
9459
- translateLeft = -maxScrollLeft;
9460
- }
9461
- itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
9462
- };
9463
- const pageLength = computed(() => editorService?.get("pageLength"));
9464
- watch(pageLength, (length = 0, preLength = 0) => {
9465
- setTimeout(() => {
9466
- setCanScroll();
9467
- if (length < preLength) {
9468
- scroll("start");
9469
- } else {
9470
- scroll("end");
9471
- }
9472
- });
9473
- });
9474
- const addPage = () => {
9475
- if (!editorService)
9476
- return;
9477
- const root = toRaw(editorService.get("root"));
9478
- if (!root)
9479
- throw new Error("root 不能为空");
9480
- const pageConfig = {
9481
- type: NodeType.PAGE,
9482
- name: generatePageNameByApp(root)
9483
- };
9484
- editorService.add(pageConfig);
9485
- };
9486
- return (_ctx, _cache) => {
9487
- return openBlock(), createElementBlock("div", {
9488
- class: "m-editor-page-bar",
9489
- ref_key: "pageBar",
9490
- ref: pageBar
9491
- }, [
9492
- showAddPageButton.value ? (openBlock(), createElementBlock("div", {
9493
- key: 0,
9494
- id: "m-editor-page-bar-add-icon",
9495
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
9496
- onClick: addPage
9497
- }, [
9498
- createVNode(_sfc_main$K, { icon: unref(Plus) }, null, 8, ["icon"])
9499
- ])) : (openBlock(), createElementBlock("div", _hoisted_1$2)),
9500
- canScroll.value ? (openBlock(), createElementBlock("div", {
9501
- key: 2,
9502
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
9503
- onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
9504
- }, [
9505
- createVNode(_sfc_main$K, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
9506
- ])) : createCommentVNode("", true),
9507
- pageLength.value ? (openBlock(), createElementBlock("div", {
9508
- key: 3,
9509
- class: "m-editor-page-bar-items",
9510
- ref_key: "itemsContainer",
9511
- ref: itemsContainer,
9512
- style: normalizeStyle(`width: ${itemsContainerWidth.value}px`)
9513
- }, [
9514
- renderSlot(_ctx.$slots, "default")
9515
- ], 4)) : createCommentVNode("", true),
9516
- canScroll.value ? (openBlock(), createElementBlock("div", {
9517
- key: 4,
9518
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
9519
- onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
9520
- }, [
9521
- createVNode(_sfc_main$K, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
9522
- ])) : createCommentVNode("", true)
9523
- ], 512);
9524
- };
9525
- }
9526
- });
9527
-
9528
- const _hoisted_1$1 = ["onClick"];
9529
- const _hoisted_2 = { class: "m-editor-page-bar-title" };
9530
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
9531
- ...{
9532
- name: "MEditorPageBar"
9533
- },
9534
- __name: "PageBar",
9535
- setup(__props) {
9536
- const services = inject("services");
9537
- const editorService = services?.editorService;
9538
- const root = computed(() => editorService?.get("root"));
9539
- const page = computed(() => editorService?.get("page"));
9540
- const switchPage = (page2) => {
9541
- editorService?.select(page2);
9542
- };
9543
- const copy = (node) => {
9544
- node && editorService?.copy(node);
9545
- editorService?.paste({
9546
- left: 0,
9547
- top: 0
9548
- });
9549
- };
9550
- const remove = (node) => {
9551
- editorService?.remove(node);
9552
- };
9553
- return (_ctx, _cache) => {
9554
- return openBlock(), createBlock(_sfc_main$3, null, {
9555
- default: withCtx(() => [
9556
- (openBlock(true), createElementBlock(Fragment, null, renderList(root.value && root.value.items || [], (item) => {
9557
- return openBlock(), createElementBlock("div", {
9558
- class: normalizeClass(["m-editor-page-bar-item", { active: page.value?.id === item.id }]),
9559
- key: item.key,
9560
- onClick: ($event) => switchPage(item)
9561
- }, [
9562
- createElementVNode("div", _hoisted_2, [
9563
- renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
9564
- createVNode(unref(TMagicTooltip), {
9565
- effect: "dark",
9566
- placement: "top-start",
9567
- content: item.name
9568
- }, {
9569
- default: withCtx(() => [
9570
- createElementVNode("span", null, toDisplayString(item.name || item.id), 1)
9571
- ]),
9572
- _: 2
9573
- }, 1032, ["content"])
9574
- ])
9575
- ]),
9576
- createVNode(unref(TMagicPopover), {
9577
- "popper-class": "page-bar-popover",
9578
- placement: "top",
9579
- width: 160,
9580
- trigger: "hover"
9581
- }, {
9582
- reference: withCtx(() => [
9583
- createVNode(unref(TMagicIcon), { class: "m-editor-page-bar-menu-icon" }, {
9584
- default: withCtx(() => [
9585
- createVNode(unref(CaretBottom))
9586
- ]),
9587
- _: 1
9588
- })
9589
- ]),
9590
- default: withCtx(() => [
9591
- createElementVNode("div", null, [
9592
- renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
9593
- createVNode(_sfc_main$t, {
9594
- data: {
9595
- type: "button",
9596
- text: "复制",
9597
- icon: unref(DocumentCopy),
9598
- handler: () => copy(item)
9599
- }
9600
- }, null, 8, ["data"]),
9601
- createVNode(_sfc_main$t, {
9602
- data: {
9603
- type: "button",
9604
- text: "删除",
9605
- icon: unref(Delete),
9606
- handler: () => remove(item)
9607
- }
9608
- }, null, 8, ["data"])
9609
- ])
9610
- ])
9611
- ]),
9612
- _: 2
9613
- }, 1024)
9614
- ], 10, _hoisted_1$1);
9615
- }), 128))
9616
- ]),
9617
- _: 3
9618
- });
9619
- };
9620
- }
9621
- });
9622
-
9623
9976
  const _hoisted_1 = { class: "m-editor-workspace" };
9624
9977
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9625
9978
  ...{
@@ -9627,30 +9980,23 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
9627
9980
  },
9628
9981
  __name: "Workspace",
9629
9982
  props: {
9630
- stageContentMenu: {}
9983
+ stageContentMenu: {},
9984
+ customContentMenu: { type: Function }
9631
9985
  },
9632
9986
  setup(__props) {
9633
9987
  const services = inject("services");
9634
9988
  const page = computed(() => services?.editorService.get("page"));
9635
9989
  return (_ctx, _cache) => {
9636
9990
  return openBlock(), createElementBlock("div", _hoisted_1, [
9637
- createVNode(_sfc_main$4),
9991
+ createVNode(_sfc_main$2),
9638
9992
  renderSlot(_ctx.$slots, "stage", {}, () => [
9639
- page.value ? (openBlock(), createBlock(_sfc_main$5, {
9993
+ page.value ? (openBlock(), createBlock(_sfc_main$3, {
9640
9994
  key: 0,
9641
- "stage-content-menu": _ctx.stageContentMenu
9642
- }, null, 8, ["stage-content-menu"])) : createCommentVNode("", true)
9995
+ "stage-content-menu": _ctx.stageContentMenu,
9996
+ "custom-content-menu": _ctx.customContentMenu
9997
+ }, null, 8, ["stage-content-menu", "custom-content-menu"])) : createCommentVNode("", true)
9643
9998
  ]),
9644
- renderSlot(_ctx.$slots, "workspace-content"),
9645
- createVNode(_sfc_main$2, null, {
9646
- "page-bar-title": withCtx(({ page: page2 }) => [
9647
- renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
9648
- ]),
9649
- "page-bar-popover": withCtx(({ page: page2 }) => [
9650
- renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
9651
- ]),
9652
- _: 3
9653
- })
9999
+ renderSlot(_ctx.$slots, "workspace-content")
9654
10000
  ]);
9655
10001
  };
9656
10002
  }
@@ -9934,7 +10280,7 @@ class Keybinding extends BaseService {
9934
10280
  commands = {
9935
10281
  [KeyBindingCommand.DELETE_NODE]: () => {
9936
10282
  const nodes = editorService.get("nodes");
9937
- if (!nodes || isPage(nodes[0]))
10283
+ if (!nodes || isPage(nodes[0]) || isPageFragment(nodes[0]))
9938
10284
  return;
9939
10285
  editorService.remove(nodes);
9940
10286
  },
@@ -9944,7 +10290,7 @@ class Keybinding extends BaseService {
9944
10290
  },
9945
10291
  [KeyBindingCommand.CUT_NODE]: () => {
9946
10292
  const nodes = editorService.get("nodes");
9947
- if (!nodes || isPage(nodes[0]))
10293
+ if (!nodes || isPage(nodes[0]) || isPageFragment(nodes[0]))
9948
10294
  return;
9949
10295
  editorService.copy(nodes);
9950
10296
  editorService.remove(nodes);
@@ -9999,13 +10345,25 @@ class Keybinding extends BaseService {
9999
10345
  editorService.selectNextNode();
10000
10346
  }
10001
10347
  };
10002
- registeCommand(command, handler) {
10348
+ registerCommand(command, handler) {
10003
10349
  this.commands[command] = handler;
10004
10350
  }
10005
- unregisteCommand(command) {
10351
+ /**
10352
+ * @deprecated
10353
+ */
10354
+ registeCommand(command, handler) {
10355
+ this.registerCommand(command, handler);
10356
+ }
10357
+ unregisterCommand(command) {
10006
10358
  delete this.commands[command];
10007
10359
  }
10008
- registeEl(name, el) {
10360
+ /**
10361
+ * @deprecated
10362
+ */
10363
+ unregisteCommand(command) {
10364
+ this.unregisterCommand(command);
10365
+ }
10366
+ registerEl(name, el) {
10009
10367
  if (name !== "global" && !el) {
10010
10368
  throw new Error("只有name为global可以不传el");
10011
10369
  }
@@ -10013,23 +10371,41 @@ class Keybinding extends BaseService {
10013
10371
  this.controllers.set(name, keycon);
10014
10372
  this.bind(name);
10015
10373
  }
10016
- unregisteEl(name) {
10374
+ /**
10375
+ * @deprecated
10376
+ */
10377
+ registeEl(name, el) {
10378
+ this.registerEl(name, el);
10379
+ }
10380
+ unregisterEl(name) {
10017
10381
  this.controllers.get(name)?.destroy();
10018
10382
  this.controllers.delete(name);
10019
10383
  this.bindingList.forEach((item) => {
10020
- item.binded = false;
10384
+ item.bound = false;
10021
10385
  });
10022
10386
  }
10023
- registe(maps) {
10387
+ /**
10388
+ * @deprecated
10389
+ */
10390
+ unregisteEl(name) {
10391
+ this.unregisterEl(name);
10392
+ }
10393
+ register(maps) {
10024
10394
  for (const keybindingItem of maps) {
10025
10395
  const { command, keybinding, when } = keybindingItem;
10026
10396
  for (const [type = "", eventType = "keydown"] of when) {
10027
- const cacheItem = { type, command, keybinding, eventType, binded: false };
10397
+ const cacheItem = { type, command, keybinding, eventType, bound: false };
10028
10398
  this.bindingList.push(cacheItem);
10029
10399
  }
10030
10400
  }
10031
10401
  this.bind();
10032
10402
  }
10403
+ /**
10404
+ * @deprecated
10405
+ */
10406
+ registe(map) {
10407
+ this.register(map);
10408
+ }
10033
10409
  reset() {
10034
10410
  this.controllers.forEach((keycon) => {
10035
10411
  keycon.destroy();
@@ -10042,11 +10418,11 @@ class Keybinding extends BaseService {
10042
10418
  }
10043
10419
  bind(name) {
10044
10420
  for (const item of this.bindingList) {
10045
- const { type, eventType, command, keybinding, binded } = item;
10421
+ const { type, eventType, command, keybinding, bound } = item;
10046
10422
  if (name && name !== type) {
10047
10423
  continue;
10048
10424
  }
10049
- if (binded) {
10425
+ if (bound) {
10050
10426
  continue;
10051
10427
  }
10052
10428
  const keycon = this.controllers.get(type);
@@ -10064,7 +10440,7 @@ class Keybinding extends BaseService {
10064
10440
  keycon[eventType](handler);
10065
10441
  }
10066
10442
  });
10067
- item.binded = true;
10443
+ item.bound = true;
10068
10444
  }
10069
10445
  }
10070
10446
  getKeyconKeys(keybinding = "") {
@@ -10094,7 +10470,9 @@ const defaultEditorProps = {
10094
10470
  containerHighlightDuration: 800,
10095
10471
  containerHighlightType: ContainerHighlightType.DEFAULT,
10096
10472
  codeOptions: () => ({}),
10097
- renderType: RenderType.IFRAME
10473
+ renderType: RenderType.IFRAME,
10474
+ disabledMultiSelect: false,
10475
+ disabledPageFragment: false
10098
10476
  };
10099
10477
 
10100
10478
  const initServiceState = (props, {
@@ -10117,6 +10495,15 @@ const initServiceState = (props, {
10117
10495
  immediate: true
10118
10496
  }
10119
10497
  );
10498
+ watch(
10499
+ () => props.disabledMultiSelect,
10500
+ (disabledMultiSelect) => {
10501
+ editorService.set("disabledMultiSelect", disabledMultiSelect || false);
10502
+ },
10503
+ {
10504
+ immediate: true
10505
+ }
10506
+ );
10120
10507
  watch(
10121
10508
  () => props.componentGroupList,
10122
10509
  (componentGroupList) => componentGroupList && componentListService.setList(componentGroupList),
@@ -10217,7 +10604,7 @@ const initServiceState = (props, {
10217
10604
  immediate: true
10218
10605
  }
10219
10606
  );
10220
- onUnmounted(() => {
10607
+ onBeforeUnmount(() => {
10221
10608
  editorService.resetState();
10222
10609
  historyService.resetState();
10223
10610
  propsService.resetState();
@@ -10401,7 +10788,7 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
10401
10788
  if (props.collectorOptions && !depService.hasTarget(DepTargetType.RELATED_COMP_WHEN_COPY)) {
10402
10789
  depService.addTarget(createRelatedCompTarget(props.collectorOptions));
10403
10790
  }
10404
- onUnmounted(() => {
10791
+ onBeforeUnmount(() => {
10405
10792
  depService.off("add-target", targetAddHandler);
10406
10793
  depService.off("remove-target", targetRemoveHandler);
10407
10794
  depService.off("dep-update", depUpdateHandler);
@@ -10454,9 +10841,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10454
10841
  updateDragEl: { type: Function },
10455
10842
  disabledDragStart: { type: Boolean },
10456
10843
  extendFormState: { type: Function },
10457
- collectorOptions: {}
10844
+ collectorOptions: {},
10845
+ guidesOptions: {},
10846
+ disabledMultiSelect: { type: Boolean },
10847
+ disabledPageFragment: { type: Boolean },
10848
+ customContentMenu: { type: Function }
10458
10849
  }, defaultEditorProps),
10459
- emits: ["props-panel-mounted", "update:modelValue"],
10850
+ emits: ["props-panel-mounted", "update:modelValue", "props-form-error", "props-submit-error"],
10460
10851
  setup(__props, { expose: __expose, emit: __emit }) {
10461
10852
  const emit = __emit;
10462
10853
  const props = __props;
@@ -10475,8 +10866,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10475
10866
  };
10476
10867
  initServiceEvents(props, emit, services);
10477
10868
  initServiceState(props, services);
10478
- keybindingService.registe(keybindingConfig);
10479
- keybindingService.registeEl("global");
10869
+ keybindingService.register(keybindingConfig);
10870
+ keybindingService.registerEl("global");
10480
10871
  provide("services", services);
10481
10872
  provide("codeOptions", props.codeOptions);
10482
10873
  provide(
@@ -10493,18 +10884,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10493
10884
  containerHighlightDuration: props.containerHighlightDuration,
10494
10885
  containerHighlightType: props.containerHighlightType,
10495
10886
  disabledDragStart: props.disabledDragStart,
10496
- renderType: props.renderType
10887
+ renderType: props.renderType,
10888
+ guidesOptions: props.guidesOptions,
10889
+ disabledMultiSelect: props.disabledMultiSelect
10497
10890
  })
10498
10891
  );
10499
10892
  __expose(services);
10500
10893
  return (_ctx, _cache) => {
10501
- return openBlock(), createBlock(_sfc_main$u, null, {
10894
+ return openBlock(), createBlock(_sfc_main$r, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
10502
10895
  header: withCtx(() => [
10503
10896
  renderSlot(_ctx.$slots, "header")
10504
10897
  ]),
10505
10898
  nav: withCtx(() => [
10506
10899
  renderSlot(_ctx.$slots, "nav", { editorService: unref(editorService) }, () => [
10507
- createVNode(_sfc_main$s, { data: _ctx.menu }, null, 8, ["data"])
10900
+ createVNode(_sfc_main$q, { data: _ctx.menu }, null, 8, ["data"])
10508
10901
  ])
10509
10902
  ]),
10510
10903
  "content-before": withCtx(() => [
@@ -10515,9 +10908,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10515
10908
  ]),
10516
10909
  sidebar: withCtx(() => [
10517
10910
  renderSlot(_ctx.$slots, "sidebar", { editorService: unref(editorService) }, () => [
10518
- createVNode(_sfc_main$c, {
10911
+ createVNode(_sfc_main$a, {
10519
10912
  data: _ctx.sidebar,
10520
- "layer-content-menu": _ctx.layerContentMenu
10913
+ "layer-content-menu": _ctx.layerContentMenu,
10914
+ "custom-content-menu": _ctx.customContentMenu
10521
10915
  }, {
10522
10916
  "layer-panel-header": withCtx(() => [
10523
10917
  renderSlot(_ctx.$slots, "layer-panel-header")
@@ -10550,33 +10944,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10550
10944
  renderSlot(_ctx.$slots, "data-source-panel-tool", { data })
10551
10945
  ]),
10552
10946
  _: 3
10553
- }, 8, ["data", "layer-content-menu"])
10947
+ }, 8, ["data", "layer-content-menu", "custom-content-menu"])
10554
10948
  ])
10555
10949
  ]),
10556
10950
  workspace: withCtx(() => [
10557
10951
  renderSlot(_ctx.$slots, "workspace", { editorService: unref(editorService) }, () => [
10558
- createVNode(_sfc_main$1, { "stage-content-menu": _ctx.stageContentMenu }, {
10952
+ createVNode(_sfc_main$1, {
10953
+ "stage-content-menu": _ctx.stageContentMenu,
10954
+ "custom-content-menu": _ctx.customContentMenu
10955
+ }, {
10559
10956
  stage: withCtx(() => [
10560
10957
  renderSlot(_ctx.$slots, "stage")
10561
10958
  ]),
10562
10959
  "workspace-content": withCtx(() => [
10563
10960
  renderSlot(_ctx.$slots, "workspace-content", { editorService: unref(editorService) })
10564
10961
  ]),
10565
- "page-bar-title": withCtx(({ page }) => [
10566
- renderSlot(_ctx.$slots, "page-bar-title", { page })
10567
- ]),
10568
- "page-bar-popover": withCtx(({ page }) => [
10569
- renderSlot(_ctx.$slots, "page-bar-popover", { page })
10570
- ]),
10571
10962
  _: 3
10572
- }, 8, ["stage-content-menu"])
10963
+ }, 8, ["stage-content-menu", "custom-content-menu"])
10573
10964
  ])
10574
10965
  ]),
10575
10966
  "props-panel": withCtx(() => [
10576
10967
  renderSlot(_ctx.$slots, "props-panel", {}, () => [
10577
- createVNode(_sfc_main$r, {
10968
+ createVNode(_sfc_main$p, {
10578
10969
  "extend-state": _ctx.extendFormState,
10579
- onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
10970
+ onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance)),
10971
+ onFormError: _cache[1] || (_cache[1] = (e) => _ctx.$emit("props-form-error", e)),
10972
+ onSubmitError: _cache[2] || (_cache[2] = (e) => _ctx.$emit("props-submit-error", e))
10580
10973
  }, {
10581
10974
  "props-panel-header": withCtx(() => [
10582
10975
  renderSlot(_ctx.$slots, "props-panel-header")
@@ -10594,8 +10987,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10594
10987
  footer: withCtx(() => [
10595
10988
  renderSlot(_ctx.$slots, "footer")
10596
10989
  ]),
10990
+ "page-bar": withCtx(() => [
10991
+ renderSlot(_ctx.$slots, "page-bar")
10992
+ ]),
10993
+ "page-bar-title": withCtx(({ page }) => [
10994
+ renderSlot(_ctx.$slots, "page-bar-title", { page })
10995
+ ]),
10996
+ "page-bar-popover": withCtx(({ page }) => [
10997
+ renderSlot(_ctx.$slots, "page-bar-popover", { page })
10998
+ ]),
10597
10999
  _: 3
10598
- });
11000
+ }, 8, ["disabled-page-fragment"]);
10599
11001
  };
10600
11002
  }
10601
11003
  });
@@ -10610,23 +11012,24 @@ const index = {
10610
11012
  app.config.globalProperties.$TMAGIC_EDITOR = option;
10611
11013
  setConfig(option);
10612
11014
  app.component(_sfc_main.name, _sfc_main);
10613
- app.component("m-fields-ui-select", _sfc_main$y);
10614
- app.component("m-fields-code-link", _sfc_main$O);
10615
- app.component("m-fields-vs-code", _sfc_main$P);
10616
- app.component("magic-code-editor", _sfc_main$Q);
10617
- app.component("m-fields-code-select", _sfc_main$N);
10618
- app.component("m-fields-code-select-col", _sfc_main$J);
10619
- app.component("m-fields-event-select", _sfc_main$B);
10620
- app.component("m-fields-data-source-fields", _sfc_main$I);
10621
- app.component("m-fields-data-source-mocks", _sfc_main$D);
10622
- app.component("m-fields-key-value", _sfc_main$z);
10623
- app.component("m-fields-data-source-input", _sfc_main$G);
10624
- app.component("m-fields-data-source-select", _sfc_main$C);
10625
- app.component("m-fields-data-source-methods", _sfc_main$F);
10626
- app.component("m-fields-data-source-method-select", _sfc_main$E);
10627
- app.component("m-fields-data-source-field-select", _sfc_main$H);
11015
+ app.component("m-fields-ui-select", _sfc_main$A);
11016
+ app.component("m-fields-code-link", _sfc_main$R);
11017
+ app.component("m-fields-vs-code", _sfc_main$S);
11018
+ app.component("magic-code-editor", _sfc_main$T);
11019
+ app.component("m-fields-code-select", _sfc_main$Q);
11020
+ app.component("m-fields-code-select-col", _sfc_main$M);
11021
+ app.component("m-fields-event-select", _sfc_main$E);
11022
+ app.component("m-fields-data-source-fields", _sfc_main$L);
11023
+ app.component("m-fields-data-source-mocks", _sfc_main$G);
11024
+ app.component("m-fields-key-value", _sfc_main$C);
11025
+ app.component("m-fields-data-source-input", _sfc_main$J);
11026
+ app.component("m-fields-data-source-select", _sfc_main$F);
11027
+ app.component("m-fields-data-source-methods", _sfc_main$I);
11028
+ app.component("m-fields-data-source-method-select", _sfc_main$H);
11029
+ app.component("m-fields-data-source-field-select", _sfc_main$K);
11030
+ app.component("m-fields-page-fragment-select", _sfc_main$B);
10628
11031
  }
10629
11032
  };
10630
11033
 
10631
- export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$M as CodeBlockEditor, _sfc_main$n as CodeBlockList, _sfc_main$m as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$N as CodeSelect, _sfc_main$J as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$i as ContentMenu, _sfc_main$H as DataSourceFieldSelect, _sfc_main$I as DataSourceFields, _sfc_main$G as DataSourceInput, _sfc_main$E as DataSourceMethodSelect, _sfc_main$F as DataSourceMethods, _sfc_main$D as DataSourceMocks, _sfc_main$C as DataSourceSelect, DragType, _sfc_main$B as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$K as Icon, KeyBindingCommand, _sfc_main$z as KeyValue, Keys, LayerOffset, _sfc_main$e as LayerPanel, Layout, _sfc_main$w as LayoutContainer, _sfc_main$r as PropsPanel, _sfc_main$x as Resizer, _sfc_main$w as SplitView, _sfc_main$Q as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$t as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChilrenLayout, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useFloatBox, useStage, warn };
11034
+ export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$P as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$M as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$K as DataSourceFieldSelect, _sfc_main$L as DataSourceFields, _sfc_main$J as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$N as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, _sfc_main$y as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useFloatBox, useStage, warn };
10632
11035
  //# sourceMappingURL=tmagic-editor.js.map