@tmagic/editor 1.1.0-beta.10 → 1.1.0-beta.13

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 (50) hide show
  1. package/dist/style.css +46 -0
  2. package/dist/tmagic-editor.mjs +862 -740
  3. package/dist/tmagic-editor.mjs.map +1 -1
  4. package/dist/tmagic-editor.umd.js +864 -739
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/package.json +10 -10
  7. package/src/Editor.vue +4 -3
  8. package/src/components/ContentMenu.vue +4 -4
  9. package/src/components/Icon.vue +6 -20
  10. package/src/components/ScrollBar.vue +147 -0
  11. package/src/components/ScrollViewer.vue +89 -44
  12. package/src/components/ToolButton.vue +40 -138
  13. package/src/fields/UISelect.vue +2 -2
  14. package/src/index.ts +2 -0
  15. package/src/layouts/NavMenu.vue +156 -23
  16. package/src/layouts/sidebar/LayerMenu.vue +3 -3
  17. package/src/layouts/sidebar/LayerPanel.vue +39 -8
  18. package/src/layouts/workspace/PageBar.vue +1 -1
  19. package/src/layouts/workspace/Stage.vue +8 -90
  20. package/src/layouts/workspace/ViewerMenu.vue +3 -3
  21. package/src/layouts/workspace/Workspace.vue +133 -138
  22. package/src/services/editor.ts +17 -6
  23. package/src/services/props.ts +26 -53
  24. package/src/services/ui.ts +16 -20
  25. package/src/theme/nav-menu.scss +6 -0
  26. package/src/type.ts +26 -10
  27. package/src/utils/index.ts +1 -0
  28. package/src/utils/operator.ts +1 -1
  29. package/src/utils/props.ts +0 -3
  30. package/src/utils/scroll-viewer.ts +90 -158
  31. package/src/utils/stage.ts +91 -0
  32. package/types/Editor.vue.d.ts +7 -7
  33. package/types/components/ContentMenu.vue.d.ts +8 -8
  34. package/types/components/Icon.vue.d.ts +62 -12
  35. package/types/components/ScrollBar.vue.d.ts +83 -0
  36. package/types/components/ScrollViewer.vue.d.ts +131 -19
  37. package/types/components/ToolButton.vue.d.ts +56 -59
  38. package/types/index.d.ts +2 -0
  39. package/types/layouts/NavMenu.vue.d.ts +92 -23
  40. package/types/layouts/sidebar/LayerMenu.vue.d.ts +7 -7
  41. package/types/layouts/sidebar/LayerPanel.vue.d.ts +17 -15
  42. package/types/layouts/workspace/Workspace.vue.d.ts +54 -4
  43. package/types/services/editor.d.ts +1 -0
  44. package/types/services/props.d.ts +40 -9
  45. package/types/services/ui.d.ts +1 -1
  46. package/types/type.d.ts +23 -10
  47. package/types/utils/index.d.ts +1 -0
  48. package/types/utils/props.d.ts +0 -1
  49. package/types/utils/scroll-viewer.d.ts +16 -18
  50. package/types/utils/stage.d.ts +3 -0
@@ -37,7 +37,7 @@
37
37
  window.globalThis = window;
38
38
  }
39
39
 
40
- const _sfc_main$n = vue.defineComponent({
40
+ const _sfc_main$o = vue.defineComponent({
41
41
  name: "m-fields-vs-code",
42
42
  props: ["model", "name", "config", "prop"],
43
43
  emits: ["change"],
@@ -63,7 +63,7 @@
63
63
  return target;
64
64
  };
65
65
 
66
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
66
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
67
67
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
68
68
  return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
69
69
  style: vue.normalizeStyle(`height: ${_ctx.height}`),
@@ -72,9 +72,9 @@
72
72
  onSave: _ctx.save
73
73
  }, null, 8, ["style", "init-values", "language", "onSave"]);
74
74
  }
75
- const Code = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$g]]);
75
+ const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$c]]);
76
76
 
77
- const _sfc_main$m = vue.defineComponent({
77
+ const _sfc_main$n = vue.defineComponent({
78
78
  name: "m-fields-code-link",
79
79
  props: {
80
80
  config: {
@@ -130,7 +130,7 @@
130
130
  }
131
131
  });
132
132
 
133
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
133
+ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
134
134
  const _component_m_fields_link = vue.resolveComponent("m-fields-link");
135
135
  return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
136
136
  config: _ctx.formConfig,
@@ -139,10 +139,10 @@
139
139
  onChange: _ctx.changeHandler
140
140
  }, null, 8, ["config", "model", "onChange"]);
141
141
  }
142
- const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
142
+ const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$b]]);
143
143
 
144
- const _hoisted_1$d = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
145
- const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
144
+ const _hoisted_1$b = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
145
+ const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
146
146
  __name: "UISelect",
147
147
  props: {
148
148
  config: null,
@@ -207,7 +207,7 @@
207
207
  style: { "padding": "0" }
208
208
  }, {
209
209
  default: vue.withCtx(() => [
210
- _hoisted_1$d
210
+ _hoisted_1$b
211
211
  ]),
212
212
  _: 1
213
213
  }, 8, ["icon"])
@@ -217,19 +217,21 @@
217
217
  onClick: startSelect,
218
218
  style: { "display": "flex" }
219
219
  }, [
220
- vue.createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
220
+ vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
221
+ key: 0,
222
+ content: "\u6E05\u9664"
223
+ }, {
221
224
  default: vue.withCtx(() => [
222
- vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_button, {
223
- key: 0,
225
+ vue.createVNode(_component_el_button, {
224
226
  style: { "padding": "0" },
225
227
  type: "danger",
226
228
  icon: vue.unref(iconsVue.Close),
227
229
  text: "",
228
230
  onClick: vue.withModifiers(deleteHandler, ["stop"])
229
- }, null, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true)
231
+ }, null, 8, ["icon", "onClick"])
230
232
  ]),
231
233
  _: 1
232
- }),
234
+ })) : vue.createCommentVNode("", true),
233
235
  vue.createVNode(_component_el_tooltip, {
234
236
  content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
235
237
  }, {
@@ -268,7 +270,7 @@
268
270
  }
269
271
  return value;
270
272
  };
271
- const _sfc_main$k = vue.defineComponent({
273
+ const _sfc_main$l = vue.defineComponent({
272
274
  name: "magic-code-editor",
273
275
  props: {
274
276
  initValues: {
@@ -376,14 +378,14 @@
376
378
  }
377
379
  });
378
380
 
379
- const _hoisted_1$c = {
381
+ const _hoisted_1$a = {
380
382
  ref: "codeEditor",
381
383
  class: "magic-code-editor"
382
384
  };
383
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
384
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
385
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
386
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, null, 512);
385
387
  }
386
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
388
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$a]]);
387
389
 
388
390
  let $TMAGIC_EDITOR = {};
389
391
  const setConfig = (option) => {
@@ -711,6 +713,12 @@
711
713
  }
712
714
  const storageService = new WebStorage();
713
715
 
716
+ var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
717
+ ColumnLayout2["LEFT"] = "left";
718
+ ColumnLayout2["CENTER"] = "center";
719
+ ColumnLayout2["RIGHT"] = "right";
720
+ return ColumnLayout2;
721
+ })(ColumnLayout || {});
714
722
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
715
723
  LayerOffset2["TOP"] = "top";
716
724
  LayerOffset2["BOTTOM"] = "bottom";
@@ -895,6 +903,7 @@
895
903
  "getPropsValue",
896
904
  "createId",
897
905
  "setNewItemId",
906
+ "fillConfig",
898
907
  "getDefaultPropsValue"
899
908
  ]);
900
909
  }
@@ -904,14 +913,17 @@
904
913
  });
905
914
  this.emit("props-configs-change");
906
915
  }
907
- setPropsConfig(type, config) {
908
- this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
916
+ async fillConfig(config) {
917
+ return fillConfig(config);
918
+ }
919
+ async setPropsConfig(type, config) {
920
+ this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
909
921
  }
910
922
  async getPropsConfig(type) {
911
923
  if (type === "area") {
912
924
  return await this.getPropsConfig("button");
913
925
  }
914
- return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
926
+ return lodashEs.cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
915
927
  }
916
928
  setPropsValues(values) {
917
929
  Object.keys(values).forEach((type) => {
@@ -945,25 +957,14 @@
945
957
  ...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
946
958
  };
947
959
  }
948
- guid(digit = 8) {
949
- return "x".repeat(digit).replace(/[xy]/g, (c) => {
950
- const r = Math.random() * 16 | 0;
951
- const v = c == "x" ? r : r & 3 | 8;
952
- return v.toString(16);
953
- });
954
- }
955
960
  async createId(type) {
956
961
  return `${type}_${this.guid()}`;
957
962
  }
958
- async setNewItemId(config, parent) {
959
- const oldId = config.id;
963
+ async setNewItemId(config) {
960
964
  config.id = await this.createId(config.type || "component");
961
- if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
962
- updatePopId(oldId, config.id, parent);
963
- }
964
965
  if (config.items && Array.isArray(config.items)) {
965
966
  for (const item of config.items) {
966
- await this.setNewItemId(item, config);
967
+ await this.setNewItemId(item);
967
968
  }
968
969
  }
969
970
  return config;
@@ -981,22 +982,14 @@
981
982
  name: type
982
983
  };
983
984
  }
985
+ guid(digit = 8) {
986
+ return "x".repeat(digit).replace(/[xy]/g, (c) => {
987
+ const r = Math.random() * 16 | 0;
988
+ const v = c === "x" ? r : r & 3 | 8;
989
+ return v.toString(16);
990
+ });
991
+ }
984
992
  }
985
- const updatePopId = (oldId, popId, pageConfig) => {
986
- pageConfig.items?.forEach((config) => {
987
- if (config.pop === oldId) {
988
- config.pop = popId;
989
- return;
990
- }
991
- if (config.popId === oldId) {
992
- config.popId = popId;
993
- return;
994
- }
995
- if (Array.isArray(config.items)) {
996
- updatePopId(oldId, popId, config);
997
- }
998
- });
999
- };
1000
993
  const propsService = new Props();
1001
994
 
1002
995
  const beforePaste = async (position, config) => {
@@ -1016,7 +1009,7 @@
1016
1009
  if (pastePosition.top && configItem.style?.top) {
1017
1010
  pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
1018
1011
  }
1019
- const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
1012
+ const pasteConfig = await propsService.setNewItemId(configItem);
1020
1013
  if (pasteConfig.style) {
1021
1014
  const { left, top } = pasteConfig.style;
1022
1015
  if (typeof left === "number" || !!left && !isNaN(Number(left))) {
@@ -1087,6 +1080,7 @@
1087
1080
  "sort",
1088
1081
  "copy",
1089
1082
  "paste",
1083
+ "doPaste",
1090
1084
  "duAlignCenter",
1091
1085
  "alignCenter",
1092
1086
  "moveLayer",
@@ -1268,7 +1262,7 @@
1268
1262
  }
1269
1263
  this.pushHistoryState();
1270
1264
  this.emit("add", newNodes);
1271
- return newNodes.length > 1 ? newNodes[0] : newNodes;
1265
+ return Array.isArray(addNode) ? newNodes : newNodes[0];
1272
1266
  }
1273
1267
  async doRemove(node) {
1274
1268
  const root = this.get("root");
@@ -1362,7 +1356,7 @@
1362
1356
  const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
1363
1357
  this.pushHistoryState();
1364
1358
  this.emit("update", newNodes);
1365
- return newNodes.length > 1 ? newNodes[0] : newNodes;
1359
+ return Array.isArray(config) ? newNodes : newNodes[0];
1366
1360
  }
1367
1361
  async sort(id1, id2) {
1368
1362
  const node = this.get("node");
@@ -1391,9 +1385,13 @@
1391
1385
  const config = await storageService.getItem(COPY_STORAGE_KEY);
1392
1386
  if (!Array.isArray(config))
1393
1387
  return;
1394
- const pasteConfigs = await beforePaste(position, config);
1388
+ const pasteConfigs = await this.doPaste(config, position);
1395
1389
  return this.add(pasteConfigs);
1396
1390
  }
1391
+ async doPaste(config, position = {}) {
1392
+ const pasteConfigs = await beforePaste(position, lodashEs.cloneDeep(config));
1393
+ return pasteConfigs;
1394
+ }
1397
1395
  async doAlignCenter(config) {
1398
1396
  const parent = this.getParentById(config.id);
1399
1397
  if (!parent)
@@ -1438,11 +1436,14 @@
1438
1436
  } else {
1439
1437
  brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
1440
1438
  }
1439
+ const grandparent = this.getParentById(parent.id);
1441
1440
  this.get("stage")?.update({
1442
1441
  config: lodashEs.cloneDeep(vue.toRaw(parent)),
1443
- parentId: parent.id,
1442
+ parentId: grandparent?.id,
1444
1443
  root: lodashEs.cloneDeep(this.get("root"))
1445
1444
  });
1445
+ this.addModifiedNodeId(parent.id);
1446
+ this.pushHistoryState();
1446
1447
  }
1447
1448
  async moveToContainer(config, targetId) {
1448
1449
  const { node, parent } = this.getNodeInfo(config.id, false);
@@ -1462,7 +1463,8 @@
1462
1463
  newConfig.style = getInitPositionStyle(newConfig.style, layout);
1463
1464
  target.items.push(newConfig);
1464
1465
  await stage.select(targetId);
1465
- await stage.update({ config: lodashEs.cloneDeep(target), parentId: parent.id, root });
1466
+ const targetParent = this.getParentById(target.id);
1467
+ await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root });
1466
1468
  await this.select(newConfig);
1467
1469
  stage.select(newConfig.id);
1468
1470
  this.addModifiedNodeId(target.id);
@@ -1825,7 +1827,6 @@
1825
1827
  ]
1826
1828
  }
1827
1829
  ];
1828
- const DEFAULT_CONFIG = fillConfig([]);
1829
1830
 
1830
1831
  const log = (...args) => {
1831
1832
  if (process.env.NODE_ENV === "development") {
@@ -1853,7 +1854,189 @@
1853
1854
  }
1854
1855
  };
1855
1856
 
1856
- const _sfc_main$j = vue.defineComponent({
1857
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
1858
+ const MIN_LEFT_COLUMN_WIDTH = 45;
1859
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
1860
+ const MIN_RIGHT_COLUMN_WIDTH = 1;
1861
+ const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
1862
+ const defaultColumnWidth = {
1863
+ left: DEFAULT_LEFT_COLUMN_WIDTH,
1864
+ center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
1865
+ right: DEFAULT_RIGHT_COLUMN_WIDTH
1866
+ };
1867
+ const state = vue.reactive({
1868
+ uiSelectMode: false,
1869
+ showSrc: false,
1870
+ zoom: 1,
1871
+ stageContainerRect: {
1872
+ width: 0,
1873
+ height: 0
1874
+ },
1875
+ stageRect: {
1876
+ width: 375,
1877
+ height: 817
1878
+ },
1879
+ columnWidth: defaultColumnWidth,
1880
+ showGuides: true,
1881
+ showRule: true,
1882
+ propsPanelSize: "small"
1883
+ });
1884
+ class Ui extends BaseService {
1885
+ constructor() {
1886
+ super([]);
1887
+ globalThis.addEventListener("resize", () => {
1888
+ this.setColumnWidth({
1889
+ center: "auto"
1890
+ });
1891
+ });
1892
+ const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
1893
+ if (columnWidthCacheData) {
1894
+ try {
1895
+ const columnWidthCache = JSON.parse(columnWidthCacheData);
1896
+ this.setColumnWidth(columnWidthCache);
1897
+ } catch (e) {
1898
+ console.error(e);
1899
+ }
1900
+ }
1901
+ }
1902
+ set(name, value) {
1903
+ const mask = editorService.get("stage")?.mask;
1904
+ if (name === "columnWidth") {
1905
+ this.setColumnWidth(value);
1906
+ return;
1907
+ }
1908
+ if (name === "stageRect") {
1909
+ this.setStageRect(value);
1910
+ return;
1911
+ }
1912
+ if (name === "showGuides") {
1913
+ mask?.showGuides(value);
1914
+ }
1915
+ if (name === "showRule") {
1916
+ mask?.showRule(value);
1917
+ }
1918
+ state[name] = value;
1919
+ }
1920
+ get(name) {
1921
+ return state[name];
1922
+ }
1923
+ zoom(zoom) {
1924
+ this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
1925
+ if (this.get("zoom") < 0.1)
1926
+ this.set("zoom", 0.1);
1927
+ }
1928
+ calcZoom() {
1929
+ const { stageRect, stageContainerRect } = state;
1930
+ const { height, width } = stageContainerRect;
1931
+ if (!width || !height)
1932
+ return 1;
1933
+ const stageWidth = stageRect.width + 30;
1934
+ const stageHeight = stageRect.height + 30;
1935
+ if (width > stageWidth && height > stageHeight) {
1936
+ return 1;
1937
+ }
1938
+ return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
1939
+ }
1940
+ setColumnWidth({ left, center, right }) {
1941
+ const columnWidth = {
1942
+ ...vue.toRaw(this.get("columnWidth"))
1943
+ };
1944
+ if (left) {
1945
+ columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
1946
+ }
1947
+ if (right) {
1948
+ columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
1949
+ }
1950
+ if (!center || center === "auto") {
1951
+ const bodyWidth = globalThis.document.body.clientWidth;
1952
+ columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
1953
+ if (columnWidth.center <= 0) {
1954
+ columnWidth.left = defaultColumnWidth.left;
1955
+ columnWidth.center = defaultColumnWidth.center;
1956
+ columnWidth.right = defaultColumnWidth.right;
1957
+ }
1958
+ } else {
1959
+ columnWidth.center = center;
1960
+ }
1961
+ globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
1962
+ state.columnWidth = columnWidth;
1963
+ }
1964
+ setStageRect(value) {
1965
+ state.stageRect = {
1966
+ ...state.stageRect,
1967
+ ...value
1968
+ };
1969
+ state.zoom = this.calcZoom();
1970
+ }
1971
+ }
1972
+ const uiService = new Ui();
1973
+
1974
+ const root = vue.computed(() => editorService.get("root"));
1975
+ const page = vue.computed(() => editorService.get("page"));
1976
+ const zoom = vue.computed(() => uiService.get("zoom") || 1);
1977
+ const uiSelectMode = vue.computed(() => uiService.get("uiSelectMode"));
1978
+ const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
1979
+ const useStage = (stageOptions) => {
1980
+ const stage = new StageCore__default.default({
1981
+ render: stageOptions.render,
1982
+ runtimeUrl: stageOptions.runtimeUrl,
1983
+ zoom: zoom.value,
1984
+ autoScrollIntoView: stageOptions.autoScrollIntoView,
1985
+ isContainer: stageOptions.isContainer,
1986
+ containerHighlightClassName: stageOptions.containerHighlightClassName,
1987
+ containerHighlightDuration: stageOptions.containerHighlightDuration,
1988
+ containerHighlightType: stageOptions.containerHighlightType,
1989
+ canSelect: (el, event, stop) => {
1990
+ const elCanSelect = stageOptions.canSelect(el);
1991
+ if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
1992
+ document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
1993
+ return stop();
1994
+ }
1995
+ return elCanSelect;
1996
+ },
1997
+ moveableOptions: stageOptions.moveableOptions,
1998
+ updateDragEl: stageOptions.updateDragEl
1999
+ });
2000
+ stage.mask.setGuides([
2001
+ getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
2002
+ getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
2003
+ ]);
2004
+ stage.on("select", (el) => {
2005
+ editorService.select(el.id);
2006
+ });
2007
+ stage.on("highlight", (el) => {
2008
+ editorService.highlight(el.id);
2009
+ });
2010
+ stage.on("multiSelect", (els) => {
2011
+ editorService.multiSelect(els.map((el) => el.id));
2012
+ });
2013
+ stage.on("update", (ev) => {
2014
+ if (ev.parentEl) {
2015
+ for (const data of ev.data) {
2016
+ editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
2017
+ }
2018
+ return;
2019
+ }
2020
+ editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
2021
+ });
2022
+ stage.on("sort", (ev) => {
2023
+ editorService.sort(ev.src, ev.dist);
2024
+ });
2025
+ stage.on("changeGuides", (e) => {
2026
+ uiService.set("showGuides", true);
2027
+ if (!root.value || !page.value)
2028
+ return;
2029
+ const storageKey = getGuideLineKey(e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
2030
+ if (e.guides.length) {
2031
+ globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
2032
+ } else {
2033
+ globalThis.localStorage.removeItem(storageKey);
2034
+ }
2035
+ });
2036
+ return stage;
2037
+ };
2038
+
2039
+ const _sfc_main$k = vue.defineComponent({
1857
2040
  components: { Plus: iconsVue.Plus },
1858
2041
  setup() {
1859
2042
  const services = vue.inject("services");
@@ -1871,13 +2054,13 @@
1871
2054
  }
1872
2055
  });
1873
2056
 
1874
- const _hoisted_1$b = { class: "m-editor-empty-panel" };
2057
+ const _hoisted_1$9 = { class: "m-editor-empty-panel" };
1875
2058
  const _hoisted_2$4 = { class: "m-editor-empty-content" };
1876
- const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1877
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2059
+ const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2060
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
1878
2061
  const _component_plus = vue.resolveComponent("plus");
1879
2062
  const _component_el_icon = vue.resolveComponent("el-icon");
1880
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
2063
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
1881
2064
  vue.createElementVNode("div", _hoisted_2$4, [
1882
2065
  vue.createElementVNode("div", {
1883
2066
  class: "m-editor-empty-button",
@@ -1891,14 +2074,14 @@
1891
2074
  _: 1
1892
2075
  })
1893
2076
  ]),
1894
- _hoisted_3$1
2077
+ _hoisted_3
1895
2078
  ])
1896
2079
  ])
1897
2080
  ]);
1898
2081
  }
1899
- const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
2082
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$9]]);
1900
2083
 
1901
- const _sfc_main$i = vue.defineComponent({
2084
+ const _sfc_main$j = vue.defineComponent({
1902
2085
  name: "m-editor-resize",
1903
2086
  props: {
1904
2087
  type: {
@@ -1941,18 +2124,18 @@
1941
2124
  }
1942
2125
  });
1943
2126
 
1944
- const _hoisted_1$a = {
2127
+ const _hoisted_1$8 = {
1945
2128
  ref: "target",
1946
2129
  class: "m-editor-resizer"
1947
2130
  };
1948
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1949
- return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
2131
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2132
+ return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$8, [
1950
2133
  vue.renderSlot(_ctx.$slots, "default")
1951
2134
  ], 512);
1952
2135
  }
1953
- const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
2136
+ const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$8]]);
1954
2137
 
1955
- const _sfc_main$h = vue.defineComponent({
2138
+ const _sfc_main$i = vue.defineComponent({
1956
2139
  components: {
1957
2140
  AddPageBox,
1958
2141
  Resizer
@@ -1982,17 +2165,17 @@
1982
2165
  }
1983
2166
  });
1984
2167
 
1985
- const _hoisted_1$9 = { class: "m-editor" };
2168
+ const _hoisted_1$7 = { class: "m-editor" };
1986
2169
  const _hoisted_2$3 = {
1987
2170
  key: 1,
1988
2171
  class: "m-editor-content"
1989
2172
  };
1990
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2173
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
1991
2174
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
1992
2175
  const _component_resizer = vue.resolveComponent("resizer");
1993
2176
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
1994
2177
  const _component_add_page_box = vue.resolveComponent("add-page-box");
1995
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
2178
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
1996
2179
  vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
1997
2180
  _ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
1998
2181
  key: 0,
@@ -2033,211 +2216,112 @@
2033
2216
  ]))
2034
2217
  ]);
2035
2218
  }
2036
- const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
2219
+ const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$7]]);
2037
2220
 
2038
- const _sfc_main$g = vue.defineComponent({
2039
- name: "m-icon",
2040
- components: { Edit: iconsVue.Edit },
2221
+ const _hoisted_1$6 = ["src"];
2222
+ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
2223
+ __name: "Icon",
2041
2224
  props: {
2042
- icon: {
2043
- type: [String, Object]
2044
- }
2225
+ icon: null
2045
2226
  },
2046
- setup() {
2047
- return {
2048
- toRaw: vue.toRaw
2227
+ setup(__props) {
2228
+ return (_ctx, _cache) => {
2229
+ const _component_el_icon = vue.resolveComponent("el-icon");
2230
+ return !__props.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
2231
+ default: vue.withCtx(() => [
2232
+ vue.createVNode(vue.unref(iconsVue.Edit))
2233
+ ]),
2234
+ _: 1
2235
+ })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
2236
+ default: vue.withCtx(() => [
2237
+ vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$6)
2238
+ ]),
2239
+ _: 1
2240
+ })) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2241
+ key: 2,
2242
+ class: vue.normalizeClass(__props.icon)
2243
+ }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
2244
+ default: vue.withCtx(() => [
2245
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(__props.icon))))
2246
+ ]),
2247
+ _: 1
2248
+ }));
2049
2249
  };
2050
2250
  }
2051
2251
  });
2052
2252
 
2053
- const _hoisted_1$8 = ["src"];
2054
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2055
- const _component_edit = vue.resolveComponent("edit");
2056
- const _component_el_icon = vue.resolveComponent("el-icon");
2057
- return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
2058
- default: vue.withCtx(() => [
2059
- vue.createVNode(_component_edit)
2060
- ]),
2061
- _: 1
2062
- })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
2063
- default: vue.withCtx(() => [
2064
- vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
2065
- ]),
2066
- _: 1
2067
- })) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2068
- key: 2,
2069
- class: vue.normalizeClass(_ctx.icon)
2070
- }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
2071
- default: vue.withCtx(() => [
2072
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.toRaw(_ctx.icon))))
2073
- ]),
2074
- _: 1
2075
- }));
2076
- }
2077
- const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
2078
-
2079
- const _hoisted_1$7 = {
2253
+ const _hoisted_1$5 = {
2080
2254
  key: 1,
2081
2255
  class: "menu-item-text"
2082
2256
  };
2083
- const _hoisted_2$2 = {
2084
- class: "menu-item-text",
2085
- style: { "margin": "0 5px" }
2086
- };
2087
- const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
2088
- const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
2257
+ const _hoisted_2$2 = { class: "el-dropdown-link menubar-menu-button" };
2258
+ const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
2089
2259
  __name: "ToolButton",
2090
2260
  props: {
2091
- data: {
2092
- type: [Object, String],
2093
- require: true,
2094
- default: () => ({
2095
- type: "text",
2096
- display: false
2097
- })
2098
- },
2099
- eventType: {
2100
- type: String,
2101
- default: "click"
2102
- }
2261
+ data: { default: () => ({
2262
+ type: "text",
2263
+ display: false
2264
+ }) },
2265
+ eventType: { default: "click" }
2103
2266
  },
2104
2267
  setup(__props) {
2105
2268
  const props = __props;
2106
2269
  const services = vue.inject("services");
2107
- const uiService = services?.uiService;
2108
- const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
2109
- const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
2110
- const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
2111
- const zoomInHandler = () => uiService?.zoom(0.1);
2112
- const zoomOutHandler = () => uiService?.zoom(-0.1);
2113
- const item = vue.computed(() => {
2114
- if (typeof props.data !== "string") {
2115
- return props.data;
2116
- }
2117
- switch (props.data) {
2118
- case "/":
2119
- return {
2120
- type: "divider"
2121
- };
2122
- case "zoom":
2123
- return {
2124
- type: "zoom"
2125
- };
2126
- case "delete":
2127
- return {
2128
- type: "button",
2129
- icon: vue.markRaw(iconsVue.Delete),
2130
- tooltip: "\u522A\u9664",
2131
- disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
2132
- handler: () => services?.editorService.remove(services?.editorService.get("node"))
2133
- };
2134
- case "undo":
2135
- return {
2136
- type: "button",
2137
- icon: vue.markRaw(iconsVue.Back),
2138
- tooltip: "\u540E\u9000",
2139
- disabled: () => !services?.historyService.state.canUndo,
2140
- handler: () => services?.editorService.undo()
2141
- };
2142
- case "redo":
2143
- return {
2144
- type: "button",
2145
- icon: vue.markRaw(iconsVue.Right),
2146
- tooltip: "\u524D\u8FDB",
2147
- disabled: () => !services?.historyService.state.canRedo,
2148
- handler: () => services?.editorService.redo()
2149
- };
2150
- case "zoom-in":
2151
- return {
2152
- type: "button",
2153
- icon: vue.markRaw(iconsVue.ZoomIn),
2154
- tooltip: "\u653E\u5927",
2155
- handler: zoomInHandler
2156
- };
2157
- case "zoom-out":
2158
- return {
2159
- type: "button",
2160
- icon: vue.markRaw(iconsVue.ZoomOut),
2161
- tooltip: "\u7E2E\u5C0F",
2162
- handler: zoomOutHandler
2163
- };
2164
- case "rule":
2165
- return {
2166
- type: "button",
2167
- icon: vue.markRaw(iconsVue.ScaleToOriginal),
2168
- tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2169
- handler: () => uiService?.set("showRule", !showRule.value)
2170
- };
2171
- case "guides":
2172
- return {
2173
- type: "button",
2174
- icon: vue.markRaw(iconsVue.Grid),
2175
- tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2176
- handler: () => uiService?.set("showGuides", !showGuides.value)
2177
- };
2178
- default:
2179
- return {
2180
- type: "text",
2181
- text: props.data
2182
- };
2270
+ const disabled = vue.computed(() => {
2271
+ if (typeof props.data === "string")
2272
+ return false;
2273
+ if (props.data.type === "component")
2274
+ return false;
2275
+ if (typeof props.data.disabled === "function") {
2276
+ return props.data.disabled(services);
2183
2277
  }
2278
+ return props.data.disabled;
2184
2279
  });
2185
- const disabled = vue.computed(() => {
2186
- if (typeof item.value === "string")
2187
- return false;
2188
- if (item.value.type === "component")
2280
+ const display = vue.computed(() => {
2281
+ if (!props.data)
2189
2282
  return false;
2190
- if (typeof item.value.disabled === "function") {
2191
- return item.value.disabled(services);
2283
+ if (typeof props.data === "string")
2284
+ return true;
2285
+ if (typeof props.data.display === "function") {
2286
+ return props.data.display(services);
2192
2287
  }
2193
- return item.value.disabled;
2288
+ return props.data.display ?? true;
2194
2289
  });
2195
- const buttonHandler = (item2, event) => {
2290
+ const buttonHandler = (item, event) => {
2196
2291
  if (disabled.value)
2197
2292
  return;
2198
- if (typeof item2.handler === "function" && services) {
2199
- item2.handler?.(services, event);
2293
+ if (typeof item.handler === "function" && services) {
2294
+ item.handler?.(services, event);
2200
2295
  }
2201
2296
  };
2202
- const display = vue.computed(() => {
2203
- if (!item.value)
2204
- return false;
2205
- if (typeof item.value === "string")
2206
- return true;
2207
- if (typeof item.value.display === "function") {
2208
- return item.value.display(services);
2209
- }
2210
- return item.value.display ?? true;
2211
- });
2212
2297
  const dropdownHandler = (command) => {
2213
2298
  if (command.item.handler) {
2214
2299
  command.item.handler(services);
2215
2300
  }
2216
2301
  };
2217
- const clickHandler = (item2, event) => {
2302
+ const clickHandler = (item, event) => {
2218
2303
  if (props.eventType !== "click")
2219
2304
  return;
2220
- if (item2.type === "button") {
2221
- buttonHandler(item2, event);
2305
+ if (item.type === "button") {
2306
+ buttonHandler(item, event);
2222
2307
  }
2223
2308
  };
2224
- const mousedownHandler = (item2, event) => {
2309
+ const mousedownHandler = (item, event) => {
2225
2310
  if (props.eventType !== "mousedown")
2226
2311
  return;
2227
- if (item2.type === "button") {
2228
- buttonHandler(item2, event);
2312
+ if (item.type === "button") {
2313
+ buttonHandler(item, event);
2229
2314
  }
2230
2315
  };
2231
- const mouseupHandler = (item2, event) => {
2316
+ const mouseupHandler = (item, event) => {
2232
2317
  if (props.eventType !== "mouseup")
2233
2318
  return;
2234
- if (item2.type === "button") {
2235
- buttonHandler(item2, event);
2319
+ if (item.type === "button") {
2320
+ buttonHandler(item, event);
2236
2321
  }
2237
2322
  };
2238
2323
  return (_ctx, _cache) => {
2239
2324
  const _component_el_divider = vue.resolveComponent("el-divider");
2240
- const _component_tool_button = vue.resolveComponent("tool-button", true);
2241
2325
  const _component_el_button = vue.resolveComponent("el-button");
2242
2326
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2243
2327
  const _component_el_icon = vue.resolveComponent("el-icon");
@@ -2246,30 +2330,20 @@
2246
2330
  const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2247
2331
  return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
2248
2332
  key: 0,
2249
- class: vue.normalizeClass(["menu-item", vue.unref(item).type]),
2250
- onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(vue.unref(item), $event)),
2251
- onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(vue.unref(item), $event)),
2252
- onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(vue.unref(item), $event))
2333
+ class: vue.normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
2334
+ onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(__props.data, $event)),
2335
+ onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
2336
+ onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
2253
2337
  }, [
2254
- vue.unref(item).type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2338
+ __props.data.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2255
2339
  key: 0,
2256
- direction: vue.unref(item).direction || "vertical"
2257
- }, null, 8, ["direction"])) : vue.unref(item).type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, vue.toDisplayString(vue.unref(item).text), 1)) : vue.unref(item).type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
2258
- vue.createVNode(_component_tool_button, {
2259
- data: { type: "button", icon: vue.unref(iconsVue.ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2260
- "event-type": __props.eventType
2261
- }, null, 8, ["data", "event-type"]),
2262
- vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${vue.unref(zoom) * 100}`, 10)) + "%", 1),
2263
- vue.createVNode(_component_tool_button, {
2264
- data: { type: "button", icon: vue.unref(iconsVue.ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
2265
- "event-type": __props.eventType
2266
- }, null, 8, ["data", "event-type"])
2267
- ], 64)) : vue.unref(item).type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
2268
- vue.unref(item).tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2340
+ direction: __props.data.direction || "vertical"
2341
+ }, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, vue.toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
2342
+ __props.data.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2269
2343
  key: 0,
2270
2344
  effect: "dark",
2271
2345
  placement: "bottom-start",
2272
- content: vue.unref(item).tooltip
2346
+ content: __props.data.tooltip
2273
2347
  }, {
2274
2348
  default: vue.withCtx(() => [
2275
2349
  vue.createVNode(_component_el_button, {
@@ -2278,11 +2352,11 @@
2278
2352
  disabled: vue.unref(disabled)
2279
2353
  }, {
2280
2354
  default: vue.withCtx(() => [
2281
- vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
2355
+ __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
2282
2356
  key: 0,
2283
- icon: vue.unref(item).icon
2357
+ icon: __props.data.icon
2284
2358
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2285
- vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
2359
+ vue.createElementVNode("span", null, vue.toDisplayString(__props.data.text), 1)
2286
2360
  ]),
2287
2361
  _: 1
2288
2362
  }, 8, ["disabled"])
@@ -2295,27 +2369,27 @@
2295
2369
  disabled: vue.unref(disabled)
2296
2370
  }, {
2297
2371
  default: vue.withCtx(() => [
2298
- vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
2372
+ __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
2299
2373
  key: 0,
2300
- icon: vue.unref(item).icon
2374
+ icon: __props.data.icon
2301
2375
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2302
- vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
2376
+ vue.createElementVNode("span", null, vue.toDisplayString(__props.data.text), 1)
2303
2377
  ]),
2304
2378
  _: 1
2305
2379
  }, 8, ["disabled"]))
2306
- ], 64)) : vue.unref(item).type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2307
- key: 4,
2380
+ ], 64)) : __props.data.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2381
+ key: 3,
2308
2382
  trigger: "click",
2309
2383
  disabled: vue.unref(disabled),
2310
2384
  onCommand: dropdownHandler
2311
2385
  }, {
2312
2386
  dropdown: vue.withCtx(() => [
2313
- vue.unref(item).items && vue.unref(item).items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
2387
+ __props.data.items && __props.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
2314
2388
  default: vue.withCtx(() => [
2315
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(item).items, (subItem, index) => {
2389
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.data.items, (subItem, index) => {
2316
2390
  return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
2317
2391
  key: index,
2318
- command: { item: vue.unref(item), subItem }
2392
+ command: { data: __props.data, subItem }
2319
2393
  }, {
2320
2394
  default: vue.withCtx(() => [
2321
2395
  vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
@@ -2328,8 +2402,8 @@
2328
2402
  })) : vue.createCommentVNode("", true)
2329
2403
  ]),
2330
2404
  default: vue.withCtx(() => [
2331
- vue.createElementVNode("span", _hoisted_3, [
2332
- vue.createTextVNode(vue.toDisplayString(vue.unref(item).text), 1),
2405
+ vue.createElementVNode("span", _hoisted_2$2, [
2406
+ vue.createTextVNode(vue.toDisplayString(__props.data.text), 1),
2333
2407
  vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
2334
2408
  default: vue.withCtx(() => [
2335
2409
  vue.createVNode(vue.unref(iconsVue.ArrowDown))
@@ -2339,58 +2413,175 @@
2339
2413
  ])
2340
2414
  ]),
2341
2415
  _: 1
2342
- }, 8, ["disabled"])) : vue.unref(item).type === "component" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(item).component), vue.normalizeProps(vue.mergeProps({ key: 5 }, vue.unref(item).props || {})), null, 16)) : vue.createCommentVNode("", true)
2416
+ }, 8, ["disabled"])) : __props.data.type === "component" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(__props.data.component), vue.normalizeProps(vue.mergeProps({ key: 4 }, __props.data.props || {})), null, 16)) : vue.createCommentVNode("", true)
2343
2417
  ], 34)) : vue.createCommentVNode("", true);
2344
2418
  };
2345
2419
  }
2346
2420
  });
2347
2421
 
2348
- const _sfc_main$e = vue.defineComponent({
2349
- name: "nav-menu",
2350
- components: { ToolButton: _sfc_main$f },
2422
+ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
2423
+ __name: "NavMenu",
2351
2424
  props: {
2352
- data: {
2353
- type: Object,
2354
- default: () => ({})
2355
- },
2356
- height: {
2357
- type: Number
2358
- }
2425
+ data: { default: () => ({}) },
2426
+ height: { default: 35 }
2359
2427
  },
2360
- setup(props) {
2428
+ setup(__props) {
2429
+ const props = __props;
2361
2430
  const services = vue.inject("services");
2362
- return {
2363
- keys: vue.computed(() => Object.keys(props.data)),
2364
- columnWidth: vue.computed(() => services?.uiService.get("columnWidth"))
2431
+ const uiService = services?.uiService;
2432
+ const columnWidth = vue.computed(() => services?.uiService.get("columnWidth"));
2433
+ const keys = Object.values(ColumnLayout);
2434
+ const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
2435
+ const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
2436
+ const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
2437
+ const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
2438
+ const ctrl = isMac ? "Command" : "Ctrl";
2439
+ const getConfig = (item) => {
2440
+ if (typeof item !== "string") {
2441
+ return [item];
2442
+ }
2443
+ const config = [];
2444
+ switch (item) {
2445
+ case "/":
2446
+ config.push({
2447
+ type: "divider",
2448
+ className: "divider"
2449
+ });
2450
+ break;
2451
+ case "zoom":
2452
+ config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
2453
+ break;
2454
+ case "delete":
2455
+ config.push({
2456
+ type: "button",
2457
+ className: "delete",
2458
+ icon: vue.markRaw(iconsVue.Delete),
2459
+ tooltip: `\u522A\u9664(Delete)`,
2460
+ disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
2461
+ handler: () => services?.editorService.remove(services?.editorService.get("node"))
2462
+ });
2463
+ break;
2464
+ case "undo":
2465
+ config.push({
2466
+ type: "button",
2467
+ className: "undo",
2468
+ icon: vue.markRaw(iconsVue.Back),
2469
+ tooltip: `\u540E\u9000(${ctrl}+z)`,
2470
+ disabled: () => !services?.historyService.state.canUndo,
2471
+ handler: () => services?.editorService.undo()
2472
+ });
2473
+ break;
2474
+ case "redo":
2475
+ config.push({
2476
+ type: "button",
2477
+ className: "redo",
2478
+ icon: vue.markRaw(iconsVue.Right),
2479
+ tooltip: `\u524D\u8FDB(${ctrl}+Shift+z)`,
2480
+ disabled: () => !services?.historyService.state.canRedo,
2481
+ handler: () => services?.editorService.redo()
2482
+ });
2483
+ break;
2484
+ case "zoom-in":
2485
+ config.push({
2486
+ type: "button",
2487
+ className: "zoom-in",
2488
+ icon: vue.markRaw(iconsVue.ZoomIn),
2489
+ tooltip: `\u653E\u5927(${ctrl}+=)`,
2490
+ handler: () => uiService?.zoom(0.1)
2491
+ });
2492
+ break;
2493
+ case "zoom-out":
2494
+ config.push({
2495
+ type: "button",
2496
+ className: "zoom-out",
2497
+ icon: vue.markRaw(iconsVue.ZoomOut),
2498
+ tooltip: `\u7E2E\u5C0F(${ctrl}+-)`,
2499
+ handler: () => uiService?.zoom(-0.1)
2500
+ });
2501
+ break;
2502
+ case "scale-to-original":
2503
+ config.push({
2504
+ type: "button",
2505
+ className: "scale-to-original",
2506
+ icon: vue.markRaw(iconsVue.ScaleToOriginal),
2507
+ tooltip: `\u7F29\u653E\u5230\u5B9E\u9645\u5927\u5C0F(${ctrl}+1)`,
2508
+ handler: () => uiService?.set("zoom", 1)
2509
+ });
2510
+ break;
2511
+ case "scale-to-fit":
2512
+ config.push({
2513
+ type: "button",
2514
+ className: "scale-to-fit",
2515
+ icon: vue.markRaw(iconsVue.FullScreen),
2516
+ tooltip: `\u7F29\u653E\u4EE5\u9002\u5E94(${ctrl}+0)`,
2517
+ handler: () => uiService?.set("zoom", uiService.calcZoom())
2518
+ });
2519
+ break;
2520
+ case "rule":
2521
+ config.push({
2522
+ type: "button",
2523
+ className: "rule",
2524
+ icon: vue.markRaw(iconsVue.Memo),
2525
+ tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2526
+ handler: () => uiService?.set("showRule", !showRule.value)
2527
+ });
2528
+ break;
2529
+ case "guides":
2530
+ config.push({
2531
+ type: "button",
2532
+ className: "guides",
2533
+ icon: vue.markRaw(iconsVue.Grid),
2534
+ tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2535
+ handler: () => uiService?.set("showGuides", !showGuides.value)
2536
+ });
2537
+ break;
2538
+ default:
2539
+ config.push({
2540
+ type: "text",
2541
+ text: item
2542
+ });
2543
+ }
2544
+ return config;
2365
2545
  };
2366
- }
2367
- });
2368
-
2369
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2370
- const _component_tool_button = vue.resolveComponent("tool-button");
2371
- return vue.openBlock(), vue.createElementBlock("div", {
2372
- class: "m-editor-nav-menu",
2373
- style: vue.normalizeStyle({ height: `${_ctx.height}px` })
2374
- }, [
2375
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.keys, (key) => {
2546
+ const buttons = vue.computed(() => {
2547
+ const data = {
2548
+ [ColumnLayout.LEFT]: [],
2549
+ [ColumnLayout.CENTER]: [],
2550
+ [ColumnLayout.RIGHT]: []
2551
+ };
2552
+ keys.forEach((key) => {
2553
+ const items = props.data[key] || [];
2554
+ items.forEach((item) => {
2555
+ data[key].push(...getConfig(item));
2556
+ });
2557
+ });
2558
+ return data;
2559
+ });
2560
+ return (_ctx, _cache) => {
2376
2561
  return vue.openBlock(), vue.createElementBlock("div", {
2377
- class: vue.normalizeClass(`menu-${key}`),
2378
- key,
2379
- style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
2562
+ class: "m-editor-nav-menu",
2563
+ style: vue.normalizeStyle({ height: `${__props.height}px` })
2380
2564
  }, [
2381
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data[key], (item, index) => {
2382
- return vue.openBlock(), vue.createBlock(_component_tool_button, {
2383
- data: item,
2384
- key: index
2385
- }, null, 8, ["data"]);
2565
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(keys), (key) => {
2566
+ return vue.openBlock(), vue.createElementBlock("div", {
2567
+ class: vue.normalizeClass(`menu-${key}`),
2568
+ key,
2569
+ style: vue.normalizeStyle(`width: ${vue.unref(columnWidth)?.[key]}px`)
2570
+ }, [
2571
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(buttons)[key], (item, index) => {
2572
+ return vue.openBlock(), vue.createBlock(_sfc_main$g, {
2573
+ data: item,
2574
+ key: index
2575
+ }, null, 8, ["data"]);
2576
+ }), 128))
2577
+ ], 6);
2386
2578
  }), 128))
2387
- ], 6);
2388
- }), 128))
2389
- ], 4);
2390
- }
2391
- const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
2579
+ ], 4);
2580
+ };
2581
+ }
2582
+ });
2392
2583
 
2393
- const _sfc_main$d = vue.defineComponent({
2584
+ const _sfc_main$e = vue.defineComponent({
2394
2585
  name: "m-editor-props-panel",
2395
2586
  emits: ["mounted"],
2396
2587
  setup(props, { emit }) {
@@ -2438,10 +2629,10 @@
2438
2629
  }
2439
2630
  });
2440
2631
 
2441
- const _hoisted_1$6 = { class: "`m-editor-props-panel" };
2442
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2632
+ const _hoisted_1$4 = { class: "`m-editor-props-panel" };
2633
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2443
2634
  const _component_m_form = vue.resolveComponent("m-form");
2444
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
2635
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
2445
2636
  vue.renderSlot(_ctx.$slots, "props-panel-header"),
2446
2637
  vue.createVNode(_component_m_form, {
2447
2638
  class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
@@ -2454,11 +2645,11 @@
2454
2645
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
2455
2646
  ]);
2456
2647
  }
2457
- const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
2648
+ const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$6]]);
2458
2649
 
2459
- const _sfc_main$c = vue.defineComponent({
2650
+ const _sfc_main$d = vue.defineComponent({
2460
2651
  name: "ui-component-panel",
2461
- components: { MIcon },
2652
+ components: { MIcon: _sfc_main$h },
2462
2653
  setup() {
2463
2654
  const searchText = vue.ref("");
2464
2655
  const services = vue.inject("services");
@@ -2523,9 +2714,9 @@
2523
2714
  }
2524
2715
  });
2525
2716
 
2526
- const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2717
+ const _hoisted_1$3 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2527
2718
  const _hoisted_2$1 = ["onClick", "onDragstart"];
2528
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2719
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2529
2720
  const _component_el_input = vue.resolveComponent("el-input");
2530
2721
  const _component_m_icon = vue.resolveComponent("m-icon");
2531
2722
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -2556,7 +2747,7 @@
2556
2747
  name: index
2557
2748
  }, {
2558
2749
  title: vue.withCtx(() => [
2559
- _hoisted_1$5,
2750
+ _hoisted_1$3,
2560
2751
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
2561
2752
  ]),
2562
2753
  default: vue.withCtx(() => [
@@ -2597,9 +2788,9 @@
2597
2788
  _: 3
2598
2789
  });
2599
2790
  }
2600
- const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
2791
+ const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$5]]);
2601
2792
 
2602
- const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
2793
+ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
2603
2794
  __name: "ContentMenu",
2604
2795
  props: {
2605
2796
  menuData: { default: () => [] },
@@ -2688,7 +2879,7 @@
2688
2879
  }, [
2689
2880
  vue.createElementVNode("div", null, [
2690
2881
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
2691
- return vue.openBlock(), vue.createBlock(_sfc_main$f, {
2882
+ return vue.openBlock(), vue.createBlock(_sfc_main$g, {
2692
2883
  "event-type": "mouseup",
2693
2884
  data: item,
2694
2885
  key: index,
@@ -2712,8 +2903,8 @@
2712
2903
  }
2713
2904
  });
2714
2905
 
2715
- const _sfc_main$a = vue.defineComponent({
2716
- components: { ContentMenu: _sfc_main$b },
2906
+ const _sfc_main$b = vue.defineComponent({
2907
+ components: { ContentMenu: _sfc_main$c },
2717
2908
  setup() {
2718
2909
  const services = vue.inject("services");
2719
2910
  const menu = vue.ref();
@@ -2796,7 +2987,7 @@
2796
2987
  }
2797
2988
  });
2798
2989
 
2799
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2990
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
2800
2991
  const _component_content_menu = vue.resolveComponent("content-menu");
2801
2992
  return vue.openBlock(), vue.createBlock(_component_content_menu, {
2802
2993
  "menu-data": _ctx.menuData,
@@ -2804,7 +2995,7 @@
2804
2995
  style: { "overflow": "initial" }
2805
2996
  }, null, 8, ["menu-data"]);
2806
2997
  }
2807
- const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
2998
+ const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
2808
2999
 
2809
3000
  const throttleTime = 150;
2810
3001
  const select = async (data, editorService) => {
@@ -2855,20 +3046,38 @@
2855
3046
  }
2856
3047
  });
2857
3048
  const useStatus = (tree, editorService) => {
2858
- const highlightNode = vue.ref();
2859
3049
  const node = vue.ref();
2860
3050
  const page = vue.computed(() => editorService?.get("page"));
3051
+ const expandedKeys = /* @__PURE__ */ new Map();
3052
+ const expandNodes = () => {
3053
+ expandedKeys.forEach((key) => {
3054
+ if (!tree.value)
3055
+ return;
3056
+ tree.value.getNode(key)?.expand();
3057
+ });
3058
+ };
2861
3059
  vue.watchEffect(() => {
2862
3060
  if (!tree.value)
2863
3061
  return;
2864
- node.value = editorService?.get("node");
2865
- node.value && tree.value.setCurrentKey(node.value.id, true);
2866
- const parent = editorService?.get("parent");
3062
+ if (!editorService)
3063
+ return;
3064
+ node.value = editorService.get("node");
3065
+ if (!node.value)
3066
+ return;
3067
+ tree.value.setCurrentKey(node.value.id, true);
3068
+ const parent = editorService.get("parent");
2867
3069
  if (!parent?.id)
2868
3070
  return;
2869
3071
  const treeNode = tree.value.getNode(parent.id);
2870
3072
  treeNode?.updateChildren();
2871
- highlightNode.value = editorService?.get("highlightNode");
3073
+ setTimeout(() => {
3074
+ tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
3075
+ if (node2.expanded && node2.data.items) {
3076
+ expandedKeys.set(id, id);
3077
+ }
3078
+ });
3079
+ expandNodes();
3080
+ });
2872
3081
  });
2873
3082
  return {
2874
3083
  values: vue.computed(() => page.value ? [page.value] : []),
@@ -2881,9 +3090,18 @@
2881
3090
  }
2882
3091
  resolve([]);
2883
3092
  },
2884
- highlightNode,
3093
+ highlightNode: vue.computed(() => editorService?.get("highlightNode")),
2885
3094
  clickNode: node,
2886
- expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
3095
+ expandedKeys: vue.computed(() => node.value ? [node.value.id] : []),
3096
+ handleCollapse: (data) => {
3097
+ expandedKeys.delete(data.id);
3098
+ },
3099
+ handleExpand: (data) => {
3100
+ const parent = editorService?.getParentById(data.id);
3101
+ if (!parent?.id)
3102
+ return;
3103
+ expandedKeys.set(parent.id, parent.id);
3104
+ }
2887
3105
  };
2888
3106
  };
2889
3107
  const useFilter = (tree) => ({
@@ -2904,7 +3122,7 @@
2904
3122
  tree.value?.filter(val);
2905
3123
  }
2906
3124
  });
2907
- const _sfc_main$9 = vue.defineComponent({
3125
+ const _sfc_main$a = vue.defineComponent({
2908
3126
  name: "magic-editor-layer-panel",
2909
3127
  components: { LayerMenu },
2910
3128
  setup() {
@@ -2952,8 +3170,8 @@
2952
3170
  }
2953
3171
  });
2954
3172
 
2955
- const _hoisted_1$4 = ["id", "onMouseenter"];
2956
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3173
+ const _hoisted_1$2 = ["id", "onMouseenter"];
3174
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
2957
3175
  const _component_el_input = vue.resolveComponent("el-input");
2958
3176
  const _component_el_tree = vue.resolveComponent("el-tree");
2959
3177
  const _component_layer_menu = vue.resolveComponent("layer-menu");
@@ -2974,6 +3192,7 @@
2974
3192
  key: 0,
2975
3193
  ref: "tree",
2976
3194
  "node-key": "id",
3195
+ "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
2977
3196
  draggable: "",
2978
3197
  "default-expanded-keys": _ctx.expandedKeys,
2979
3198
  load: _ctx.loadItems,
@@ -2988,7 +3207,8 @@
2988
3207
  onNodeClick: _ctx.clickHandler,
2989
3208
  onNodeContextmenu: _ctx.contextmenu,
2990
3209
  onNodeDragEnd: _ctx.handleDragEnd,
2991
- "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
3210
+ onNodeCollapse: _ctx.handleCollapse,
3211
+ onNodeExpand: _ctx.handleExpand
2992
3212
  }, {
2993
3213
  default: vue.withCtx(({ node, data }) => [
2994
3214
  vue.createElementVNode("div", {
@@ -3004,10 +3224,10 @@
3004
3224
  }, () => [
3005
3225
  vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
3006
3226
  ])
3007
- ], 42, _hoisted_1$4)
3227
+ ], 42, _hoisted_1$2)
3008
3228
  ]),
3009
3229
  _: 3
3010
- }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
3230
+ }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : vue.createCommentVNode("", true),
3011
3231
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3012
3232
  vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
3013
3233
  ]))
@@ -3015,10 +3235,10 @@
3015
3235
  _: 3
3016
3236
  });
3017
3237
  }
3018
- const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
3238
+ const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
3019
3239
 
3020
- const _sfc_main$8 = vue.defineComponent({
3021
- components: { MIcon },
3240
+ const _sfc_main$9 = vue.defineComponent({
3241
+ components: { MIcon: _sfc_main$h },
3022
3242
  props: {
3023
3243
  data: {
3024
3244
  type: [Object, String]
@@ -3055,11 +3275,11 @@
3055
3275
  }
3056
3276
  });
3057
3277
 
3058
- const _hoisted_1$3 = {
3278
+ const _hoisted_1$1 = {
3059
3279
  key: 1,
3060
3280
  class: "magic-editor-tab-panel-title"
3061
3281
  };
3062
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3282
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3063
3283
  const _component_m_icon = vue.resolveComponent("m-icon");
3064
3284
  const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
3065
3285
  return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
@@ -3074,7 +3294,7 @@
3074
3294
  key: 0,
3075
3295
  icon: _ctx.config.icon
3076
3296
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
3077
- _ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, vue.toDisplayString(_ctx.config.text), 1)) : vue.createCommentVNode("", true)
3297
+ _ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, vue.toDisplayString(_ctx.config.text), 1)) : vue.createCommentVNode("", true)
3078
3298
  ]))
3079
3299
  ]),
3080
3300
  default: vue.withCtx(() => [
@@ -3105,9 +3325,9 @@
3105
3325
  _: 3
3106
3326
  }, 8, ["name"])) : vue.createCommentVNode("", true);
3107
3327
  }
3108
- const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
3328
+ const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
3109
3329
 
3110
- const _sfc_main$7 = vue.defineComponent({
3330
+ const _sfc_main$8 = vue.defineComponent({
3111
3331
  components: { TabPane },
3112
3332
  name: "m-sidebar",
3113
3333
  props: {
@@ -3127,7 +3347,7 @@
3127
3347
  }
3128
3348
  });
3129
3349
 
3130
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3350
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3131
3351
  const _component_tab_pane = vue.resolveComponent("tab-pane");
3132
3352
  const _component_el_tabs = vue.resolveComponent("el-tabs");
3133
3353
  return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
@@ -3162,9 +3382,9 @@
3162
3382
  _: 3
3163
3383
  }, 8, ["modelValue"])) : vue.createCommentVNode("", true);
3164
3384
  }
3165
- const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
3385
+ const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
3166
3386
 
3167
- const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
3387
+ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
3168
3388
  __name: "PageBarScrollContainer",
3169
3389
  setup(__props) {
3170
3390
  const services = vue.inject("services");
@@ -3291,9 +3511,9 @@
3291
3511
  }
3292
3512
  });
3293
3513
 
3294
- const _hoisted_1$2 = ["onClick"];
3514
+ const _hoisted_1 = ["onClick"];
3295
3515
  const _hoisted_2 = { class: "m-editor-page-bar-title" };
3296
- const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
3516
+ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
3297
3517
  __name: "PageBar",
3298
3518
  setup(__props) {
3299
3519
  const services = vue.inject("services");
@@ -3317,7 +3537,7 @@
3317
3537
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
3318
3538
  const _component_el_icon = vue.resolveComponent("el-icon");
3319
3539
  const _component_el_popover = vue.resolveComponent("el-popover");
3320
- return vue.openBlock(), vue.createBlock(_sfc_main$6, null, {
3540
+ return vue.openBlock(), vue.createBlock(_sfc_main$7, null, {
3321
3541
  default: vue.withCtx(() => [
3322
3542
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
3323
3543
  return vue.openBlock(), vue.createElementBlock("div", {
@@ -3333,7 +3553,7 @@
3333
3553
  content: item.name
3334
3554
  }, {
3335
3555
  default: vue.withCtx(() => [
3336
- vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
3556
+ vue.createElementVNode("span", null, vue.toDisplayString(item.name || item.id), 1)
3337
3557
  ]),
3338
3558
  _: 2
3339
3559
  }, 1032, ["content"])
@@ -3356,7 +3576,7 @@
3356
3576
  default: vue.withCtx(() => [
3357
3577
  vue.createElementVNode("div", null, [
3358
3578
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3359
- vue.createVNode(_sfc_main$f, {
3579
+ vue.createVNode(_sfc_main$g, {
3360
3580
  data: {
3361
3581
  type: "button",
3362
3582
  text: "\u590D\u5236",
@@ -3364,7 +3584,7 @@
3364
3584
  handler: () => copy(item)
3365
3585
  }
3366
3586
  }, null, 8, ["data"]),
3367
- vue.createVNode(_sfc_main$f, {
3587
+ vue.createVNode(_sfc_main$g, {
3368
3588
  data: {
3369
3589
  type: "button",
3370
3590
  text: "\u5220\u9664",
@@ -3377,7 +3597,7 @@
3377
3597
  ]),
3378
3598
  _: 2
3379
3599
  }, 1024)
3380
- ], 10, _hoisted_1$2);
3600
+ ], 10, _hoisted_1);
3381
3601
  }), 128))
3382
3602
  ]),
3383
3603
  _: 3
@@ -3386,190 +3606,245 @@
3386
3606
  }
3387
3607
  });
3388
3608
 
3389
- class ScrollViewer$1 {
3390
- enter = false;
3391
- targetEnter = false;
3392
- keydown = false;
3609
+ class ScrollViewer extends events.EventEmitter {
3393
3610
  container;
3394
3611
  target;
3395
3612
  zoom = 1;
3396
3613
  scrollLeft = 0;
3397
3614
  scrollTop = 0;
3398
- x = 0;
3399
- y = 0;
3400
- resizeObserver = new ResizeObserver((entries) => {
3401
- for (const { contentRect } of entries) {
3402
- const { width, height } = contentRect;
3403
- const targetRect = this.target.getBoundingClientRect();
3404
- const targetWidth = targetRect.width * this.zoom;
3405
- const targetMarginTop = Number(this.target.style.marginTop) || 0;
3406
- const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3407
- if (targetWidth < width) {
3408
- this.target._left = 0;
3409
- }
3410
- if (targetHeight < height) {
3411
- this.target._top = 0;
3412
- }
3413
- this.scroll();
3414
- }
3615
+ scrollHeight = 0;
3616
+ scrollWidth = 0;
3617
+ width = 0;
3618
+ height = 0;
3619
+ translateXCorrectionValue = 0;
3620
+ translateYCorrectionValue = 0;
3621
+ resizeObserver = new ResizeObserver(() => {
3622
+ this.setSize();
3623
+ this.setScrollSize();
3415
3624
  });
3416
3625
  constructor(options) {
3626
+ super();
3417
3627
  this.container = options.container;
3418
3628
  this.target = options.target;
3419
3629
  this.zoom = options.zoom;
3420
- globalThis.addEventListener("keydown", this.keydownHandler);
3421
- globalThis.addEventListener("keyup", this.keyupHandler);
3422
- this.container.addEventListener("mouseenter", this.mouseEnterHandler);
3423
- this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
3424
- this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
3425
- this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
3426
- this.container.addEventListener("wheel", this.wheelHandler);
3630
+ this.container.addEventListener("wheel", this.wheelHandler, false);
3631
+ this.setSize();
3632
+ this.setScrollSize();
3427
3633
  this.resizeObserver.observe(this.container);
3428
3634
  }
3429
3635
  destroy() {
3430
3636
  this.resizeObserver.disconnect();
3431
- this.container.removeEventListener("mouseenter", this.mouseEnterHandler);
3432
- this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
3433
- this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
3434
- this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
3435
- globalThis.removeEventListener("keydown", this.keydownHandler);
3436
- globalThis.removeEventListener("keyup", this.keyupHandler);
3637
+ this.container.removeEventListener("wheel", this.wheelHandler, false);
3638
+ this.removeAllListeners();
3437
3639
  }
3438
3640
  setZoom(zoom) {
3439
3641
  this.zoom = zoom;
3642
+ this.setScrollSize();
3440
3643
  }
3441
- scroll() {
3442
- const scrollLeft = this.target._left;
3443
- const scrollTop = this.target._top;
3444
- this.target.style.transform = `translate(${scrollLeft}px, ${scrollTop}px)`;
3445
- }
3446
- removeHandler() {
3447
- this.target.style.cursor = "";
3448
- this.target.removeEventListener("mousedown", this.mousedownHandler);
3449
- document.removeEventListener("mousemove", this.mousemoveHandler);
3450
- document.removeEventListener("mouseup", this.mouseupHandler);
3644
+ scrollTo({ left, top }) {
3645
+ if (typeof left !== "undefined") {
3646
+ this.scrollLeft = left;
3647
+ }
3648
+ if (typeof top !== "undefined") {
3649
+ this.scrollTop = top;
3650
+ }
3651
+ const translateX = -this.scrollLeft + this.translateXCorrectionValue;
3652
+ const translateY = -this.scrollTop + this.translateYCorrectionValue;
3653
+ this.target.style.transform = `translate(${translateX}px, ${translateY}px)`;
3451
3654
  }
3452
3655
  wheelHandler = (event) => {
3453
- if (this.targetEnter)
3454
- return;
3455
3656
  const { deltaX, deltaY, currentTarget } = event;
3456
3657
  if (currentTarget !== this.container)
3457
3658
  return;
3458
- this.setScrollOffset(deltaX, deltaY);
3459
- this.scroll();
3460
- this.scrollLeft = this.target._left;
3461
- this.scrollTop = this.target._top;
3462
- };
3463
- mouseEnterHandler = () => {
3464
- this.enter = true;
3465
- };
3466
- mouseLeaveHandler = () => {
3467
- this.enter = false;
3468
- };
3469
- targetMouseEnterHandler = () => {
3470
- this.targetEnter = true;
3471
- };
3472
- targetMouseLeaveHandler = () => {
3473
- this.targetEnter = false;
3474
- };
3475
- mousedownHandler = (event) => {
3476
- if (!this.keydown)
3477
- return;
3478
- event.stopImmediatePropagation();
3479
- event.stopPropagation();
3480
- this.target.style.cursor = "grabbing";
3481
- this.x = event.clientX;
3482
- this.y = event.clientY;
3483
- document.addEventListener("mousemove", this.mousemoveHandler);
3484
- document.addEventListener("mouseup", this.mouseupHandler);
3485
- };
3486
- mouseupHandler = () => {
3487
- this.x = 0;
3488
- this.y = 0;
3489
- this.scrollLeft = this.target._left;
3490
- this.scrollTop = this.target._top;
3491
- this.removeHandler();
3492
- };
3493
- mousemoveHandler = (event) => {
3494
- event.stopImmediatePropagation();
3495
- event.stopPropagation();
3496
- const deltaX = event.clientX - this.x;
3497
- const deltaY = event.clientY - this.y;
3498
- this.setScrollOffset(deltaX, deltaY);
3499
- this.scroll();
3500
- };
3501
- keydownHandler = (event) => {
3502
- if (event.code === Keys.ESCAPE && this.enter) {
3503
- event.preventDefault();
3504
- event.stopImmediatePropagation();
3505
- event.stopPropagation();
3659
+ let top;
3660
+ if (this.scrollHeight > this.height) {
3661
+ top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
3506
3662
  }
3507
- if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3508
- return;
3663
+ let left;
3664
+ if (this.scrollWidth > this.width) {
3665
+ left = this.scrollLeft + this.getPos(deltaX, this.scrollLeft, this.scrollWidth, this.width);
3509
3666
  }
3510
- this.keydown = true;
3511
- this.target.style.cursor = "grab";
3512
- this.container.addEventListener("mousedown", this.mousedownHandler);
3667
+ this.scrollTo({ left, top });
3668
+ this.emit("scroll", {
3669
+ scrollLeft: this.scrollLeft,
3670
+ scrollTop: this.scrollTop,
3671
+ scrollHeight: this.scrollHeight,
3672
+ scrollWidth: this.scrollWidth
3673
+ });
3513
3674
  };
3514
- keyupHandler = (event) => {
3515
- if (event.code !== Keys.ESCAPE || !this.keydown) {
3516
- return;
3675
+ getPos(delta, scrollPos, scrollSize, size) {
3676
+ let pos = 0;
3677
+ if (delta < 0) {
3678
+ if (scrollPos > 0) {
3679
+ pos = Math.max(delta, -scrollPos);
3680
+ }
3681
+ } else {
3682
+ const leftPos = scrollSize - size - scrollPos;
3683
+ if (leftPos > 0) {
3684
+ pos = Math.min(delta, leftPos);
3685
+ }
3517
3686
  }
3518
- event.preventDefault();
3519
- event.stopImmediatePropagation();
3520
- event.stopPropagation();
3521
- this.keydown = false;
3522
- event.preventDefault();
3523
- this.removeHandler();
3687
+ return pos;
3688
+ }
3689
+ setScrollSize = () => {
3690
+ const targetRect = this.target.getBoundingClientRect();
3691
+ this.scrollWidth = targetRect.width * this.zoom + 100;
3692
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3693
+ this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + 100;
3694
+ let left;
3695
+ let top;
3696
+ if (this.scrollWidth < this.width) {
3697
+ left = 0;
3698
+ this.translateXCorrectionValue = 0;
3699
+ } else {
3700
+ this.translateXCorrectionValue = (this.scrollWidth - this.width) / 2;
3701
+ }
3702
+ if (this.scrollHeight < this.height) {
3703
+ top = 0;
3704
+ this.translateYCorrectionValue = 0;
3705
+ } else {
3706
+ this.translateYCorrectionValue = (this.scrollHeight - this.height) / 2;
3707
+ }
3708
+ this.scrollTo({
3709
+ left,
3710
+ top
3711
+ });
3712
+ this.emit("scroll", {
3713
+ scrollLeft: this.scrollLeft,
3714
+ scrollTop: this.scrollTop,
3715
+ scrollHeight: this.scrollHeight,
3716
+ scrollWidth: this.scrollWidth
3717
+ });
3524
3718
  };
3525
- setScrollOffset(deltaX, deltaY) {
3719
+ setSize = () => {
3526
3720
  const { width, height } = this.container.getBoundingClientRect();
3527
- const targetRect = this.target.getBoundingClientRect();
3528
- const targetWidth = targetRect.width * this.zoom;
3529
- const targetHeight = targetRect.height * this.zoom;
3530
- let y = 0;
3531
- if (targetHeight > height) {
3532
- if (deltaY > 0) {
3533
- y = this.scrollTop + Math.min(targetHeight - height - this.scrollTop, deltaY);
3534
- } else {
3535
- y = this.scrollTop + Math.max(-(targetHeight - height + this.scrollTop), deltaY);
3721
+ this.width = width;
3722
+ this.height = height;
3723
+ };
3724
+ }
3725
+
3726
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
3727
+ __name: "ScrollBar",
3728
+ props: {
3729
+ size: null,
3730
+ scrollSize: null,
3731
+ isHorizontal: { type: Boolean },
3732
+ pos: null
3733
+ },
3734
+ emits: ["scroll"],
3735
+ setup(__props, { emit }) {
3736
+ const props = __props;
3737
+ const bar = vue.ref();
3738
+ const thumb = vue.ref();
3739
+ const thumbSize = vue.computed(() => props.size * (props.size / props.scrollSize));
3740
+ const thumbPos = vue.computed(() => props.pos / props.scrollSize * props.size);
3741
+ const thumbStyle = vue.computed(() => ({
3742
+ [props.isHorizontal ? "width" : "height"]: `${thumbSize.value}px`,
3743
+ transform: `translate${props.isHorizontal ? "X" : "Y"}(${thumbPos.value}px)`
3744
+ }));
3745
+ let gesto;
3746
+ vue.onMounted(() => {
3747
+ if (!thumb.value)
3748
+ return;
3749
+ const thumbEl = thumb.value;
3750
+ gesto = new Gesto__default.default(thumbEl, {
3751
+ container: window
3752
+ });
3753
+ gesto.on("dragStart", (e) => {
3754
+ e.inputEvent.stopPropagation();
3755
+ e.inputEvent.preventDefault();
3756
+ }).on("drag", (e) => {
3757
+ scrollBy(getDelta(e));
3758
+ });
3759
+ bar.value?.addEventListener("wheel", wheelHandler, false);
3760
+ });
3761
+ vue.onUnmounted(() => {
3762
+ if (gesto)
3763
+ gesto.off();
3764
+ bar.value?.removeEventListener("wheel", wheelHandler, false);
3765
+ });
3766
+ const wheelHandler = (e) => {
3767
+ const delta = props.isHorizontal ? e.deltaX : e.deltaY;
3768
+ if (delta) {
3769
+ e.preventDefault();
3536
3770
  }
3537
- }
3538
- let x = 0;
3539
- if (targetWidth > width) {
3540
- if (deltaX > 0) {
3541
- x = this.scrollLeft + Math.min(targetWidth - width - this.scrollLeft, deltaX);
3771
+ scrollBy(delta);
3772
+ };
3773
+ const getDelta = (e) => {
3774
+ const ratio = (props.isHorizontal ? e.deltaX : e.deltaY) / props.size;
3775
+ return props.scrollSize * ratio;
3776
+ };
3777
+ const scrollBy = (delta) => {
3778
+ if (delta < 0) {
3779
+ if (props.pos <= 0) {
3780
+ emit("scroll", 0);
3781
+ } else {
3782
+ emit("scroll", -Math.min(-delta, props.pos));
3783
+ }
3542
3784
  } else {
3543
- x = this.scrollLeft + Math.max(-(targetWidth - width + this.scrollLeft), deltaX);
3785
+ const leftPos = props.size - (thumbSize.value + thumbPos.value);
3786
+ if (leftPos <= 0) {
3787
+ emit("scroll", 0);
3788
+ } else {
3789
+ emit("scroll", Math.min(delta, leftPos));
3790
+ }
3544
3791
  }
3545
- }
3546
- this.target._left = x;
3547
- this.target._top = y;
3792
+ };
3793
+ return (_ctx, _cache) => {
3794
+ return vue.openBlock(), vue.createElementBlock("div", {
3795
+ ref_key: "bar",
3796
+ ref: bar,
3797
+ class: vue.normalizeClass(["m-editor-scroll-bar", __props.isHorizontal ? "horizontal" : "vertical"])
3798
+ }, [
3799
+ vue.createElementVNode("div", {
3800
+ ref_key: "thumb",
3801
+ ref: thumb,
3802
+ class: "m-editor-scroll-bar-thumb",
3803
+ style: vue.normalizeStyle(vue.unref(thumbStyle))
3804
+ }, null, 4)
3805
+ ], 2);
3806
+ };
3548
3807
  }
3549
- }
3808
+ });
3809
+
3810
+ const ScrollBar_vue_vue_type_style_index_0_lang = '';
3550
3811
 
3551
- const _sfc_main$4 = vue.defineComponent({
3552
- name: "m-editor-scroll-viewer",
3812
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
3813
+ __name: "ScrollViewer",
3553
3814
  props: {
3554
- width: Number,
3555
- height: Number,
3556
- zoom: {
3557
- type: Number,
3558
- default: 1
3559
- }
3815
+ width: { default: 0 },
3816
+ height: { default: 0 },
3817
+ wrapWidth: { default: 0 },
3818
+ wrapHeight: { default: 0 },
3819
+ zoom: { default: 1 }
3560
3820
  },
3561
- setup(props) {
3821
+ setup(__props, { expose }) {
3822
+ const props = __props;
3562
3823
  const container = vue.ref();
3563
3824
  const el = vue.ref();
3825
+ const style = vue.computed(() => `
3826
+ width: ${props.width}px;
3827
+ height: ${props.height}px;
3828
+ position: absolute;
3829
+ margin-top: 30px;
3830
+ `);
3831
+ const scrollWidth = vue.ref(0);
3832
+ const scrollHeight = vue.ref(0);
3564
3833
  let scrollViewer;
3565
3834
  vue.onMounted(() => {
3566
3835
  if (!container.value || !el.value)
3567
3836
  return;
3568
- scrollViewer = new ScrollViewer$1({
3837
+ scrollViewer = new ScrollViewer({
3569
3838
  container: container.value,
3570
3839
  target: el.value,
3571
3840
  zoom: props.zoom
3572
3841
  });
3842
+ scrollViewer.on("scroll", (data) => {
3843
+ hOffset.value = data.scrollLeft;
3844
+ vOffset.value = data.scrollTop;
3845
+ scrollWidth.value = data.scrollWidth;
3846
+ scrollHeight.value = data.scrollHeight;
3847
+ });
3573
3848
  });
3574
3849
  vue.onUnmounted(() => {
3575
3850
  scrollViewer.destroy();
@@ -3577,35 +3852,56 @@
3577
3852
  vue.watch(() => props.zoom, () => {
3578
3853
  scrollViewer.setZoom(props.zoom);
3579
3854
  });
3580
- return {
3581
- container,
3582
- el,
3583
- style: vue.computed(() => `
3584
- width: ${props.width}px;
3585
- height: ${props.height}px;
3586
- position: absolute;
3587
- margin-top: 30px;
3588
- `)
3855
+ const vOffset = vue.ref(0);
3856
+ const vScrollHandler = (delta) => {
3857
+ vOffset.value += delta;
3858
+ scrollViewer.scrollTo({
3859
+ top: vOffset.value
3860
+ });
3861
+ };
3862
+ const hOffset = vue.ref(0);
3863
+ const hScrollHandler = (delta) => {
3864
+ hOffset.value += delta;
3865
+ scrollViewer.scrollTo({
3866
+ left: hOffset.value
3867
+ });
3868
+ };
3869
+ expose({
3870
+ container
3871
+ });
3872
+ return (_ctx, _cache) => {
3873
+ return vue.openBlock(), vue.createElementBlock("div", {
3874
+ class: "m-editor-scroll-viewer-container",
3875
+ ref_key: "container",
3876
+ ref: container
3877
+ }, [
3878
+ vue.createElementVNode("div", {
3879
+ ref_key: "el",
3880
+ ref: el,
3881
+ style: vue.normalizeStyle(vue.unref(style))
3882
+ }, [
3883
+ vue.renderSlot(_ctx.$slots, "default")
3884
+ ], 4),
3885
+ scrollHeight.value > __props.wrapHeight ? (vue.openBlock(), vue.createBlock(_sfc_main$5, {
3886
+ key: 0,
3887
+ "scroll-size": scrollHeight.value,
3888
+ size: __props.wrapHeight,
3889
+ pos: vOffset.value,
3890
+ onScroll: vScrollHandler
3891
+ }, null, 8, ["scroll-size", "size", "pos"])) : vue.createCommentVNode("", true),
3892
+ scrollWidth.value > __props.wrapWidth ? (vue.openBlock(), vue.createBlock(_sfc_main$5, {
3893
+ key: 1,
3894
+ "is-horizontal": true,
3895
+ "scroll-size": scrollWidth.value,
3896
+ pos: hOffset.value,
3897
+ size: __props.wrapWidth,
3898
+ onScroll: hScrollHandler
3899
+ }, null, 8, ["scroll-size", "pos", "size"])) : vue.createCommentVNode("", true)
3900
+ ], 512);
3589
3901
  };
3590
3902
  }
3591
3903
  });
3592
3904
 
3593
- const _hoisted_1$1 = {
3594
- class: "m-editor-scroll-viewer-container",
3595
- ref: "container"
3596
- };
3597
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3598
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
3599
- vue.createElementVNode("div", {
3600
- ref: "el",
3601
- style: vue.normalizeStyle(_ctx.style)
3602
- }, [
3603
- vue.renderSlot(_ctx.$slots, "default")
3604
- ], 4)
3605
- ], 512);
3606
- }
3607
- const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
3608
-
3609
3905
  const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
3610
3906
  __name: "ViewerMenu",
3611
3907
  props: {
@@ -3742,7 +4038,7 @@
3742
4038
  };
3743
4039
  expose({ show });
3744
4040
  return (_ctx, _cache) => {
3745
- return vue.openBlock(), vue.createBlock(_sfc_main$b, {
4041
+ return vue.openBlock(), vue.createBlock(_sfc_main$c, {
3746
4042
  "menu-data": menuData,
3747
4043
  ref_key: "menu",
3748
4044
  ref: menu
@@ -3763,12 +4059,11 @@
3763
4059
  const menu = vue.ref();
3764
4060
  const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
3765
4061
  const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
3766
- const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
4062
+ const stageContainerRect = vue.computed(() => services?.uiService.get("stageContainerRect"));
3767
4063
  const root = vue.computed(() => services?.editorService.get("root"));
3768
4064
  const page = vue.computed(() => services?.editorService.get("page"));
3769
4065
  const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
3770
4066
  const node = vue.computed(() => services?.editorService.get("node"));
3771
- const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
3772
4067
  vue.watchEffect(() => {
3773
4068
  if (stage)
3774
4069
  return;
@@ -3776,64 +4071,9 @@
3776
4071
  return;
3777
4072
  if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
3778
4073
  return;
3779
- stage = new StageCore__default.default({
3780
- render: stageOptions.render,
3781
- runtimeUrl: stageOptions.runtimeUrl,
3782
- zoom: zoom.value,
3783
- autoScrollIntoView: stageOptions.autoScrollIntoView,
3784
- isContainer: stageOptions.isContainer,
3785
- containerHighlightClassName: stageOptions.containerHighlightClassName,
3786
- containerHighlightDuration: stageOptions.containerHighlightDuration,
3787
- containerHighlightType: stageOptions.containerHighlightType,
3788
- canSelect: (el, event, stop) => {
3789
- const elCanSelect = stageOptions.canSelect(el);
3790
- if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
3791
- document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
3792
- return stop();
3793
- }
3794
- return elCanSelect;
3795
- },
3796
- moveableOptions: stageOptions.moveableOptions,
3797
- updateDragEl: stageOptions.updateDragEl
3798
- });
4074
+ stage = useStage(stageOptions);
3799
4075
  services?.editorService.set("stage", vue.markRaw(stage));
3800
4076
  stage?.mount(stageContainer.value);
3801
- stage.mask.setGuides([
3802
- getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
3803
- getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
3804
- ]);
3805
- stage?.on("select", (el) => {
3806
- services?.editorService.select(el.id);
3807
- });
3808
- stage?.on("highlight", (el) => {
3809
- services?.editorService.highlight(el.id);
3810
- });
3811
- stage?.on("multiSelect", (els) => {
3812
- services?.editorService.multiSelect(els.map((el) => el.id));
3813
- });
3814
- stage?.on("update", (ev) => {
3815
- if (ev.parentEl) {
3816
- for (const data of ev.data) {
3817
- services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
3818
- }
3819
- return;
3820
- }
3821
- services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
3822
- });
3823
- stage?.on("sort", (ev) => {
3824
- services?.editorService.sort(ev.src, ev.dist);
3825
- });
3826
- stage?.on("changeGuides", (e2) => {
3827
- services?.uiService.set("showGuides", true);
3828
- if (!root.value || !page.value)
3829
- return;
3830
- const storageKey = getGuideLineKey(e2.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
3831
- if (e2.guides.length) {
3832
- globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
3833
- } else {
3834
- globalThis.localStorage.removeItem(storageKey);
3835
- }
3836
- });
3837
4077
  if (!node.value?.id)
3838
4078
  return;
3839
4079
  stage?.on("runtime-ready", (rt) => {
@@ -3919,12 +4159,14 @@
3919
4159
  }
3920
4160
  };
3921
4161
  return (_ctx, _cache) => {
3922
- return vue.openBlock(), vue.createBlock(ScrollViewer, {
4162
+ return vue.openBlock(), vue.createBlock(_sfc_main$4, {
3923
4163
  class: "m-editor-stage",
3924
4164
  ref_key: "stageWrap",
3925
4165
  ref: stageWrap,
3926
4166
  width: vue.unref(stageRect)?.width,
3927
4167
  height: vue.unref(stageRect)?.height,
4168
+ "wrap-width": vue.unref(stageContainerRect)?.width,
4169
+ "wrap-height": vue.unref(stageContainerRect)?.height,
3928
4170
  zoom: vue.unref(zoom)
3929
4171
  }, {
3930
4172
  default: vue.withCtx(() => [
@@ -3932,7 +4174,7 @@
3932
4174
  class: "m-editor-stage-container",
3933
4175
  ref_key: "stageContainer",
3934
4176
  ref: stageContainer,
3935
- style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})`),
4177
+ style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)});`),
3936
4178
  onContextmenu: contextmenuHandler,
3937
4179
  onDrop: dropHandler,
3938
4180
  onDragover: dragoverHandler
@@ -3946,28 +4188,25 @@
3946
4188
  ]))
3947
4189
  ]),
3948
4190
  _: 1
3949
- }, 8, ["width", "height", "zoom"]);
4191
+ }, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
3950
4192
  };
3951
4193
  }
3952
4194
  });
3953
4195
 
3954
- const _sfc_main$1 = vue.defineComponent({
3955
- name: "m-editor-workspace",
3956
- components: {
3957
- PageBar: _sfc_main$5,
3958
- MagicStage: _sfc_main$2
3959
- },
3960
- setup() {
4196
+ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
4197
+ __name: "Workspace",
4198
+ setup(__props) {
3961
4199
  const services = vue.inject("services");
3962
4200
  const workspace = vue.ref();
3963
4201
  const nodes = vue.computed(() => services?.editorService.get("nodes"));
3964
- let keycon;
4202
+ const page = vue.computed(() => services?.editorService.get("page"));
3965
4203
  const mouseenterHandler = () => {
3966
4204
  workspace.value?.focus();
3967
4205
  };
3968
4206
  const mouseleaveHandler = () => {
3969
4207
  workspace.value?.blur();
3970
4208
  };
4209
+ let keycon;
3971
4210
  vue.onMounted(() => {
3972
4211
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3973
4212
  workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
@@ -4044,6 +4283,12 @@
4044
4283
  }).keydown([ctrl, "numpad-"], (e) => {
4045
4284
  e.inputEvent.preventDefault();
4046
4285
  services?.uiService.zoom(-0.1);
4286
+ }).keydown([ctrl, "0"], (e) => {
4287
+ e.inputEvent.preventDefault();
4288
+ services?.uiService.set("zoom", services.uiService.calcZoom());
4289
+ }).keydown([ctrl, "1"], (e) => {
4290
+ e.inputEvent.preventDefault();
4291
+ services?.uiService.set("zoom", 1);
4047
4292
  });
4048
4293
  });
4049
4294
  vue.onUnmounted(() => {
@@ -4051,39 +4296,33 @@
4051
4296
  workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
4052
4297
  keycon.destroy();
4053
4298
  });
4054
- return {
4055
- workspace,
4056
- page: vue.computed(() => services?.editorService.get("page"))
4299
+ return (_ctx, _cache) => {
4300
+ return vue.openBlock(), vue.createElementBlock("div", {
4301
+ class: "m-editor-workspace",
4302
+ tabindex: "1",
4303
+ ref_key: "workspace",
4304
+ ref: workspace
4305
+ }, [
4306
+ vue.renderSlot(_ctx.$slots, "stage", {}, () => [
4307
+ (vue.openBlock(), vue.createBlock(_sfc_main$2, {
4308
+ key: vue.unref(page)?.id
4309
+ }))
4310
+ ]),
4311
+ vue.renderSlot(_ctx.$slots, "workspace-content"),
4312
+ vue.createVNode(_sfc_main$6, null, {
4313
+ "page-bar-title": vue.withCtx(({ page: page2 }) => [
4314
+ vue.renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
4315
+ ]),
4316
+ "page-bar-popover": vue.withCtx(({ page: page2 }) => [
4317
+ vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
4318
+ ]),
4319
+ _: 3
4320
+ })
4321
+ ], 512);
4057
4322
  };
4058
4323
  }
4059
4324
  });
4060
4325
 
4061
- const _hoisted_1 = {
4062
- class: "m-editor-workspace",
4063
- tabindex: "1",
4064
- ref: "workspace"
4065
- };
4066
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4067
- const _component_magic_stage = vue.resolveComponent("magic-stage");
4068
- const _component_page_bar = vue.resolveComponent("page-bar");
4069
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
4070
- (vue.openBlock(), vue.createBlock(_component_magic_stage, {
4071
- key: _ctx.page?.id
4072
- })),
4073
- vue.renderSlot(_ctx.$slots, "workspace-content"),
4074
- vue.createVNode(_component_page_bar, null, {
4075
- "page-bar-title": vue.withCtx(({ page }) => [
4076
- vue.renderSlot(_ctx.$slots, "page-bar-title", { page })
4077
- ]),
4078
- "page-bar-popover": vue.withCtx(({ page }) => [
4079
- vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
4080
- ]),
4081
- _: 3
4082
- })
4083
- ], 512);
4084
- }
4085
- const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4086
-
4087
4326
  class ComponentList extends BaseService {
4088
4327
  state = vue.reactive({
4089
4328
  list: []
@@ -4100,132 +4339,12 @@
4100
4339
  }
4101
4340
  const componentListService = new ComponentList();
4102
4341
 
4103
- const DEFAULT_LEFT_COLUMN_WIDTH = 310;
4104
- const MIN_LEFT_COLUMN_WIDTH = 45;
4105
- const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
4106
- const MIN_RIGHT_COLUMN_WIDTH = 1;
4107
- const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
4108
- const defaultColumnWidth = {
4109
- left: DEFAULT_LEFT_COLUMN_WIDTH,
4110
- center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
4111
- right: DEFAULT_RIGHT_COLUMN_WIDTH
4112
- };
4113
- const state = vue.reactive({
4114
- uiSelectMode: false,
4115
- showSrc: false,
4116
- zoom: 1,
4117
- stageContainerRect: {
4118
- width: 0,
4119
- height: 0
4120
- },
4121
- stageRect: {
4122
- width: 375,
4123
- height: 817
4124
- },
4125
- columnWidth: defaultColumnWidth,
4126
- showGuides: true,
4127
- showRule: true,
4128
- propsPanelSize: "small"
4129
- });
4130
- class Ui extends BaseService {
4131
- constructor() {
4132
- super([]);
4133
- globalThis.addEventListener("resize", () => {
4134
- this.setColumnWidth({
4135
- center: "auto"
4136
- });
4137
- });
4138
- const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
4139
- if (columnWidthCacheData) {
4140
- try {
4141
- const columnWidthCache = JSON.parse(columnWidthCacheData);
4142
- this.setColumnWidth(columnWidthCache);
4143
- } catch (e) {
4144
- console.error(e);
4145
- }
4146
- }
4147
- }
4148
- set(name, value) {
4149
- const mask = editorService.get("stage")?.mask;
4150
- if (name === "columnWidth") {
4151
- this.setColumnWidth(value);
4152
- return;
4153
- }
4154
- if (name === "stageRect") {
4155
- this.setStageRect(value);
4156
- return;
4157
- }
4158
- if (name === "showGuides") {
4159
- mask?.showGuides(value);
4160
- }
4161
- if (name === "showRule") {
4162
- mask?.showRule(value);
4163
- }
4164
- state[name] = value;
4165
- if (name === "stageContainerRect") {
4166
- state.zoom = this.calcZoom();
4167
- }
4168
- }
4169
- get(name) {
4170
- return state[name];
4171
- }
4172
- zoom(zoom) {
4173
- this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
4174
- if (this.get("zoom") < 0.1)
4175
- this.set("zoom", 0.1);
4176
- }
4177
- setColumnWidth({ left, center, right }) {
4178
- const columnWidth = {
4179
- ...vue.toRaw(this.get("columnWidth"))
4180
- };
4181
- if (left) {
4182
- columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
4183
- }
4184
- if (right) {
4185
- columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
4186
- }
4187
- if (!center || center === "auto") {
4188
- const bodyWidth = globalThis.document.body.clientWidth;
4189
- columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
4190
- if (columnWidth.center <= 0) {
4191
- columnWidth.left = defaultColumnWidth.left;
4192
- columnWidth.center = defaultColumnWidth.center;
4193
- columnWidth.right = defaultColumnWidth.right;
4194
- }
4195
- } else {
4196
- columnWidth.center = center;
4197
- }
4198
- globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
4199
- state.columnWidth = columnWidth;
4200
- }
4201
- setStageRect(value) {
4202
- state.stageRect = {
4203
- ...state.stageRect,
4204
- ...value
4205
- };
4206
- state.zoom = this.calcZoom();
4207
- }
4208
- calcZoom() {
4209
- const { stageRect, stageContainerRect } = state;
4210
- const { height, width } = stageContainerRect;
4211
- if (!width || !height)
4212
- return 1;
4213
- const stageWidth = stageRect.width + 30;
4214
- const stageHeight = stageRect.height + 30;
4215
- if (width > stageWidth && height > stageHeight) {
4216
- return 1;
4217
- }
4218
- return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
4219
- }
4220
- }
4221
- const uiService = new Ui();
4222
-
4223
4342
  const _sfc_main = vue.defineComponent({
4224
4343
  name: "m-editor",
4225
4344
  components: {
4226
- NavMenu,
4345
+ NavMenu: _sfc_main$f,
4227
4346
  Sidebar,
4228
- Workspace,
4347
+ Workspace: _sfc_main$1,
4229
4348
  PropsPanel,
4230
4349
  Framework
4231
4350
  },
@@ -4402,6 +4521,9 @@
4402
4521
  workspace: vue.withCtx(() => [
4403
4522
  vue.renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
4404
4523
  vue.createVNode(_component_workspace, null, {
4524
+ stage: vue.withCtx(() => [
4525
+ vue.renderSlot(_ctx.$slots, "stage")
4526
+ ]),
4405
4527
  "workspace-content": vue.withCtx(() => [
4406
4528
  vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
4407
4529
  ]),
@@ -4445,7 +4567,7 @@
4445
4567
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4446
4568
  setConfig(option);
4447
4569
  app.component(Editor.name, Editor);
4448
- app.component("m-fields-ui-select", _sfc_main$l);
4570
+ app.component("m-fields-ui-select", _sfc_main$m);
4449
4571
  app.component(CodeLink.name, CodeLink);
4450
4572
  app.component(Code.name, Code);
4451
4573
  app.component(CodeEditor.name, CodeEditor);
@@ -4453,10 +4575,12 @@
4453
4575
  };
4454
4576
 
4455
4577
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
4578
+ exports.ColumnLayout = ColumnLayout;
4456
4579
  exports.ComponentListPanel = ComponentListPanel;
4457
- exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
4580
+ exports.ContentMenu = _sfc_main$c;
4458
4581
  exports.Fixed2Other = Fixed2Other;
4459
4582
  exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
4583
+ exports.Icon = _sfc_main$h;
4460
4584
  exports.Keys = Keys;
4461
4585
  exports.LayerOffset = LayerOffset;
4462
4586
  exports.LayerPanel = LayerPanel;
@@ -4464,7 +4588,7 @@
4464
4588
  exports.PropsPanel = PropsPanel;
4465
4589
  exports.TMagicCodeEditor = CodeEditor;
4466
4590
  exports.TMagicEditor = Editor;
4467
- exports.ToolButton = _sfc_main$f;
4591
+ exports.ToolButton = _sfc_main$g;
4468
4592
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
4469
4593
  exports.change2Fixed = change2Fixed;
4470
4594
  exports.debug = debug;
@@ -4493,6 +4617,7 @@
4493
4617
  exports.setLayout = setLayout;
4494
4618
  exports.storageService = storageService;
4495
4619
  exports.uiService = uiService;
4620
+ exports.useStage = useStage;
4496
4621
  exports.warn = warn;
4497
4622
 
4498
4623
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });