@tmagic/editor 1.1.0-beta.12 → 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 (40) hide show
  1. package/dist/style.css +46 -0
  2. package/dist/tmagic-editor.mjs +781 -688
  3. package/dist/tmagic-editor.mjs.map +1 -1
  4. package/dist/tmagic-editor.umd.js +783 -686
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/package.json +8 -8
  7. package/src/Editor.vue +3 -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/index.ts +2 -0
  14. package/src/layouts/NavMenu.vue +156 -23
  15. package/src/layouts/sidebar/LayerMenu.vue +3 -3
  16. package/src/layouts/workspace/Stage.vue +8 -90
  17. package/src/layouts/workspace/ViewerMenu.vue +3 -3
  18. package/src/layouts/workspace/Workspace.vue +131 -138
  19. package/src/services/ui.ts +16 -20
  20. package/src/theme/nav-menu.scss +6 -0
  21. package/src/type.ts +26 -10
  22. package/src/utils/index.ts +1 -0
  23. package/src/utils/scroll-viewer.ts +90 -158
  24. package/src/utils/stage.ts +91 -0
  25. package/types/Editor.vue.d.ts +7 -7
  26. package/types/components/ContentMenu.vue.d.ts +8 -8
  27. package/types/components/Icon.vue.d.ts +62 -12
  28. package/types/components/ScrollBar.vue.d.ts +83 -0
  29. package/types/components/ScrollViewer.vue.d.ts +131 -19
  30. package/types/components/ToolButton.vue.d.ts +56 -59
  31. package/types/index.d.ts +2 -0
  32. package/types/layouts/NavMenu.vue.d.ts +92 -23
  33. package/types/layouts/sidebar/LayerMenu.vue.d.ts +7 -7
  34. package/types/layouts/sidebar/LayerPanel.vue.d.ts +12 -12
  35. package/types/layouts/workspace/Workspace.vue.d.ts +54 -4
  36. package/types/services/ui.d.ts +1 -1
  37. package/types/type.d.ts +23 -10
  38. package/types/utils/index.d.ts +1 -0
  39. package/types/utils/scroll-viewer.d.ts +16 -18
  40. package/types/utils/stage.d.ts +3 -0
@@ -1,6 +1,6 @@
1
- import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createVNode, unref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, markRaw, renderList, normalizeProps, mergeProps, getCurrentInstance, Teleport, nextTick, toHandlers, createSlots, provide } from 'vue';
1
+ import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, createElementBlock, createVNode, unref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, Teleport, nextTick, toHandlers, createSlots, provide } from 'vue';
2
2
  import serialize from 'serialize-javascript';
3
- import { Delete, Close, Plus, Edit, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, ArrowDown, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
3
+ import { Delete, Close, Plus, Edit, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
4
4
  import { throttle, cloneDeep, mergeWith, isEmpty, uniq } from 'lodash-es';
5
5
  import * as monaco from 'monaco-editor';
6
6
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
@@ -19,7 +19,7 @@ if (typeof globalThis === "undefined") {
19
19
  window.globalThis = window;
20
20
  }
21
21
 
22
- const _sfc_main$n = defineComponent({
22
+ const _sfc_main$o = defineComponent({
23
23
  name: "m-fields-vs-code",
24
24
  props: ["model", "name", "config", "prop"],
25
25
  emits: ["change"],
@@ -45,7 +45,7 @@ const _export_sfc = (sfc, props) => {
45
45
  return target;
46
46
  };
47
47
 
48
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
48
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
49
49
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
50
50
  return openBlock(), createBlock(_component_magic_code_editor, {
51
51
  style: normalizeStyle(`height: ${_ctx.height}`),
@@ -54,9 +54,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
54
54
  onSave: _ctx.save
55
55
  }, null, 8, ["style", "init-values", "language", "onSave"]);
56
56
  }
57
- const Code = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$g]]);
57
+ const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$c]]);
58
58
 
59
- const _sfc_main$m = defineComponent({
59
+ const _sfc_main$n = defineComponent({
60
60
  name: "m-fields-code-link",
61
61
  props: {
62
62
  config: {
@@ -112,7 +112,7 @@ const _sfc_main$m = defineComponent({
112
112
  }
113
113
  });
114
114
 
115
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
115
+ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
116
116
  const _component_m_fields_link = resolveComponent("m-fields-link");
117
117
  return openBlock(), createBlock(_component_m_fields_link, {
118
118
  config: _ctx.formConfig,
@@ -121,10 +121,10 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
121
121
  onChange: _ctx.changeHandler
122
122
  }, null, 8, ["config", "model", "onChange"]);
123
123
  }
124
- const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
124
+ const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$b]]);
125
125
 
126
- const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
127
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
126
+ const _hoisted_1$b = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
127
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
128
128
  __name: "UISelect",
129
129
  props: {
130
130
  config: null,
@@ -189,7 +189,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
189
189
  style: { "padding": "0" }
190
190
  }, {
191
191
  default: withCtx(() => [
192
- _hoisted_1$d
192
+ _hoisted_1$b
193
193
  ]),
194
194
  _: 1
195
195
  }, 8, ["icon"])
@@ -252,7 +252,7 @@ const toString = (v, language) => {
252
252
  }
253
253
  return value;
254
254
  };
255
- const _sfc_main$k = defineComponent({
255
+ const _sfc_main$l = defineComponent({
256
256
  name: "magic-code-editor",
257
257
  props: {
258
258
  initValues: {
@@ -360,14 +360,14 @@ const _sfc_main$k = defineComponent({
360
360
  }
361
361
  });
362
362
 
363
- const _hoisted_1$c = {
363
+ const _hoisted_1$a = {
364
364
  ref: "codeEditor",
365
365
  class: "magic-code-editor"
366
366
  };
367
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
368
- return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
367
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
368
+ return openBlock(), createElementBlock("div", _hoisted_1$a, null, 512);
369
369
  }
370
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
370
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$a]]);
371
371
 
372
372
  let $TMAGIC_EDITOR = {};
373
373
  const setConfig = (option) => {
@@ -695,6 +695,12 @@ class WebStorage extends BaseService {
695
695
  }
696
696
  const storageService = new WebStorage();
697
697
 
698
+ var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
699
+ ColumnLayout2["LEFT"] = "left";
700
+ ColumnLayout2["CENTER"] = "center";
701
+ ColumnLayout2["RIGHT"] = "right";
702
+ return ColumnLayout2;
703
+ })(ColumnLayout || {});
698
704
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
699
705
  LayerOffset2["TOP"] = "top";
700
706
  LayerOffset2["BOTTOM"] = "bottom";
@@ -1830,7 +1836,189 @@ const error = (...args) => {
1830
1836
  }
1831
1837
  };
1832
1838
 
1833
- const _sfc_main$j = defineComponent({
1839
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
1840
+ const MIN_LEFT_COLUMN_WIDTH = 45;
1841
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
1842
+ const MIN_RIGHT_COLUMN_WIDTH = 1;
1843
+ const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
1844
+ const defaultColumnWidth = {
1845
+ left: DEFAULT_LEFT_COLUMN_WIDTH,
1846
+ center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
1847
+ right: DEFAULT_RIGHT_COLUMN_WIDTH
1848
+ };
1849
+ const state = reactive({
1850
+ uiSelectMode: false,
1851
+ showSrc: false,
1852
+ zoom: 1,
1853
+ stageContainerRect: {
1854
+ width: 0,
1855
+ height: 0
1856
+ },
1857
+ stageRect: {
1858
+ width: 375,
1859
+ height: 817
1860
+ },
1861
+ columnWidth: defaultColumnWidth,
1862
+ showGuides: true,
1863
+ showRule: true,
1864
+ propsPanelSize: "small"
1865
+ });
1866
+ class Ui extends BaseService {
1867
+ constructor() {
1868
+ super([]);
1869
+ globalThis.addEventListener("resize", () => {
1870
+ this.setColumnWidth({
1871
+ center: "auto"
1872
+ });
1873
+ });
1874
+ const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
1875
+ if (columnWidthCacheData) {
1876
+ try {
1877
+ const columnWidthCache = JSON.parse(columnWidthCacheData);
1878
+ this.setColumnWidth(columnWidthCache);
1879
+ } catch (e) {
1880
+ console.error(e);
1881
+ }
1882
+ }
1883
+ }
1884
+ set(name, value) {
1885
+ const mask = editorService.get("stage")?.mask;
1886
+ if (name === "columnWidth") {
1887
+ this.setColumnWidth(value);
1888
+ return;
1889
+ }
1890
+ if (name === "stageRect") {
1891
+ this.setStageRect(value);
1892
+ return;
1893
+ }
1894
+ if (name === "showGuides") {
1895
+ mask?.showGuides(value);
1896
+ }
1897
+ if (name === "showRule") {
1898
+ mask?.showRule(value);
1899
+ }
1900
+ state[name] = value;
1901
+ }
1902
+ get(name) {
1903
+ return state[name];
1904
+ }
1905
+ zoom(zoom) {
1906
+ this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
1907
+ if (this.get("zoom") < 0.1)
1908
+ this.set("zoom", 0.1);
1909
+ }
1910
+ calcZoom() {
1911
+ const { stageRect, stageContainerRect } = state;
1912
+ const { height, width } = stageContainerRect;
1913
+ if (!width || !height)
1914
+ return 1;
1915
+ const stageWidth = stageRect.width + 30;
1916
+ const stageHeight = stageRect.height + 30;
1917
+ if (width > stageWidth && height > stageHeight) {
1918
+ return 1;
1919
+ }
1920
+ return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
1921
+ }
1922
+ setColumnWidth({ left, center, right }) {
1923
+ const columnWidth = {
1924
+ ...toRaw(this.get("columnWidth"))
1925
+ };
1926
+ if (left) {
1927
+ columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
1928
+ }
1929
+ if (right) {
1930
+ columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
1931
+ }
1932
+ if (!center || center === "auto") {
1933
+ const bodyWidth = globalThis.document.body.clientWidth;
1934
+ columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
1935
+ if (columnWidth.center <= 0) {
1936
+ columnWidth.left = defaultColumnWidth.left;
1937
+ columnWidth.center = defaultColumnWidth.center;
1938
+ columnWidth.right = defaultColumnWidth.right;
1939
+ }
1940
+ } else {
1941
+ columnWidth.center = center;
1942
+ }
1943
+ globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
1944
+ state.columnWidth = columnWidth;
1945
+ }
1946
+ setStageRect(value) {
1947
+ state.stageRect = {
1948
+ ...state.stageRect,
1949
+ ...value
1950
+ };
1951
+ state.zoom = this.calcZoom();
1952
+ }
1953
+ }
1954
+ const uiService = new Ui();
1955
+
1956
+ const root = computed(() => editorService.get("root"));
1957
+ const page = computed(() => editorService.get("page"));
1958
+ const zoom = computed(() => uiService.get("zoom") || 1);
1959
+ const uiSelectMode = computed(() => uiService.get("uiSelectMode"));
1960
+ const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
1961
+ const useStage = (stageOptions) => {
1962
+ const stage = new StageCore({
1963
+ render: stageOptions.render,
1964
+ runtimeUrl: stageOptions.runtimeUrl,
1965
+ zoom: zoom.value,
1966
+ autoScrollIntoView: stageOptions.autoScrollIntoView,
1967
+ isContainer: stageOptions.isContainer,
1968
+ containerHighlightClassName: stageOptions.containerHighlightClassName,
1969
+ containerHighlightDuration: stageOptions.containerHighlightDuration,
1970
+ containerHighlightType: stageOptions.containerHighlightType,
1971
+ canSelect: (el, event, stop) => {
1972
+ const elCanSelect = stageOptions.canSelect(el);
1973
+ if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
1974
+ document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
1975
+ return stop();
1976
+ }
1977
+ return elCanSelect;
1978
+ },
1979
+ moveableOptions: stageOptions.moveableOptions,
1980
+ updateDragEl: stageOptions.updateDragEl
1981
+ });
1982
+ stage.mask.setGuides([
1983
+ getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
1984
+ getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
1985
+ ]);
1986
+ stage.on("select", (el) => {
1987
+ editorService.select(el.id);
1988
+ });
1989
+ stage.on("highlight", (el) => {
1990
+ editorService.highlight(el.id);
1991
+ });
1992
+ stage.on("multiSelect", (els) => {
1993
+ editorService.multiSelect(els.map((el) => el.id));
1994
+ });
1995
+ stage.on("update", (ev) => {
1996
+ if (ev.parentEl) {
1997
+ for (const data of ev.data) {
1998
+ editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
1999
+ }
2000
+ return;
2001
+ }
2002
+ editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
2003
+ });
2004
+ stage.on("sort", (ev) => {
2005
+ editorService.sort(ev.src, ev.dist);
2006
+ });
2007
+ stage.on("changeGuides", (e) => {
2008
+ uiService.set("showGuides", true);
2009
+ if (!root.value || !page.value)
2010
+ return;
2011
+ const storageKey = getGuideLineKey(e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
2012
+ if (e.guides.length) {
2013
+ globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
2014
+ } else {
2015
+ globalThis.localStorage.removeItem(storageKey);
2016
+ }
2017
+ });
2018
+ return stage;
2019
+ };
2020
+
2021
+ const _sfc_main$k = defineComponent({
1834
2022
  components: { Plus },
1835
2023
  setup() {
1836
2024
  const services = inject("services");
@@ -1848,13 +2036,13 @@ const _sfc_main$j = defineComponent({
1848
2036
  }
1849
2037
  });
1850
2038
 
1851
- const _hoisted_1$b = { class: "m-editor-empty-panel" };
2039
+ const _hoisted_1$9 = { class: "m-editor-empty-panel" };
1852
2040
  const _hoisted_2$4 = { class: "m-editor-empty-content" };
1853
- const _hoisted_3$1 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1854
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2041
+ const _hoisted_3 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2042
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
1855
2043
  const _component_plus = resolveComponent("plus");
1856
2044
  const _component_el_icon = resolveComponent("el-icon");
1857
- return openBlock(), createElementBlock("div", _hoisted_1$b, [
2045
+ return openBlock(), createElementBlock("div", _hoisted_1$9, [
1858
2046
  createElementVNode("div", _hoisted_2$4, [
1859
2047
  createElementVNode("div", {
1860
2048
  class: "m-editor-empty-button",
@@ -1868,14 +2056,14 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1868
2056
  _: 1
1869
2057
  })
1870
2058
  ]),
1871
- _hoisted_3$1
2059
+ _hoisted_3
1872
2060
  ])
1873
2061
  ])
1874
2062
  ]);
1875
2063
  }
1876
- const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
2064
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$9]]);
1877
2065
 
1878
- const _sfc_main$i = defineComponent({
2066
+ const _sfc_main$j = defineComponent({
1879
2067
  name: "m-editor-resize",
1880
2068
  props: {
1881
2069
  type: {
@@ -1918,18 +2106,18 @@ const _sfc_main$i = defineComponent({
1918
2106
  }
1919
2107
  });
1920
2108
 
1921
- const _hoisted_1$a = {
2109
+ const _hoisted_1$8 = {
1922
2110
  ref: "target",
1923
2111
  class: "m-editor-resizer"
1924
2112
  };
1925
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1926
- return openBlock(), createElementBlock("span", _hoisted_1$a, [
2113
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2114
+ return openBlock(), createElementBlock("span", _hoisted_1$8, [
1927
2115
  renderSlot(_ctx.$slots, "default")
1928
2116
  ], 512);
1929
2117
  }
1930
- const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
2118
+ const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$8]]);
1931
2119
 
1932
- const _sfc_main$h = defineComponent({
2120
+ const _sfc_main$i = defineComponent({
1933
2121
  components: {
1934
2122
  AddPageBox,
1935
2123
  Resizer
@@ -1959,17 +2147,17 @@ const _sfc_main$h = defineComponent({
1959
2147
  }
1960
2148
  });
1961
2149
 
1962
- const _hoisted_1$9 = { class: "m-editor" };
2150
+ const _hoisted_1$7 = { class: "m-editor" };
1963
2151
  const _hoisted_2$3 = {
1964
2152
  key: 1,
1965
2153
  class: "m-editor-content"
1966
2154
  };
1967
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2155
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
1968
2156
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
1969
2157
  const _component_resizer = resolveComponent("resizer");
1970
2158
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
1971
2159
  const _component_add_page_box = resolveComponent("add-page-box");
1972
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
2160
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
1973
2161
  renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
1974
2162
  _ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
1975
2163
  key: 0,
@@ -2010,211 +2198,112 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2010
2198
  ]))
2011
2199
  ]);
2012
2200
  }
2013
- const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
2201
+ const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$7]]);
2014
2202
 
2015
- const _sfc_main$g = defineComponent({
2016
- name: "m-icon",
2017
- components: { Edit },
2203
+ const _hoisted_1$6 = ["src"];
2204
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
2205
+ __name: "Icon",
2018
2206
  props: {
2019
- icon: {
2020
- type: [String, Object]
2021
- }
2207
+ icon: null
2022
2208
  },
2023
- setup() {
2024
- return {
2025
- toRaw
2209
+ setup(__props) {
2210
+ return (_ctx, _cache) => {
2211
+ const _component_el_icon = resolveComponent("el-icon");
2212
+ return !__props.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
2213
+ default: withCtx(() => [
2214
+ createVNode(unref(Edit))
2215
+ ]),
2216
+ _: 1
2217
+ })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
2218
+ default: withCtx(() => [
2219
+ createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$6)
2220
+ ]),
2221
+ _: 1
2222
+ })) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
2223
+ key: 2,
2224
+ class: normalizeClass(__props.icon)
2225
+ }, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
2226
+ default: withCtx(() => [
2227
+ (openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
2228
+ ]),
2229
+ _: 1
2230
+ }));
2026
2231
  };
2027
2232
  }
2028
2233
  });
2029
2234
 
2030
- const _hoisted_1$8 = ["src"];
2031
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2032
- const _component_edit = resolveComponent("edit");
2033
- const _component_el_icon = resolveComponent("el-icon");
2034
- return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
2035
- default: withCtx(() => [
2036
- createVNode(_component_edit)
2037
- ]),
2038
- _: 1
2039
- })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
2040
- default: withCtx(() => [
2041
- createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
2042
- ]),
2043
- _: 1
2044
- })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
2045
- key: 2,
2046
- class: normalizeClass(_ctx.icon)
2047
- }, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
2048
- default: withCtx(() => [
2049
- (openBlock(), createBlock(resolveDynamicComponent(_ctx.toRaw(_ctx.icon))))
2050
- ]),
2051
- _: 1
2052
- }));
2053
- }
2054
- const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
2055
-
2056
- const _hoisted_1$7 = {
2235
+ const _hoisted_1$5 = {
2057
2236
  key: 1,
2058
2237
  class: "menu-item-text"
2059
2238
  };
2060
- const _hoisted_2$2 = {
2061
- class: "menu-item-text",
2062
- style: { "margin": "0 5px" }
2063
- };
2064
- const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
2065
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
2239
+ const _hoisted_2$2 = { class: "el-dropdown-link menubar-menu-button" };
2240
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2066
2241
  __name: "ToolButton",
2067
2242
  props: {
2068
- data: {
2069
- type: [Object, String],
2070
- require: true,
2071
- default: () => ({
2072
- type: "text",
2073
- display: false
2074
- })
2075
- },
2076
- eventType: {
2077
- type: String,
2078
- default: "click"
2079
- }
2243
+ data: { default: () => ({
2244
+ type: "text",
2245
+ display: false
2246
+ }) },
2247
+ eventType: { default: "click" }
2080
2248
  },
2081
2249
  setup(__props) {
2082
2250
  const props = __props;
2083
2251
  const services = inject("services");
2084
- const uiService = services?.uiService;
2085
- const zoom = computed(() => uiService?.get("zoom") ?? 1);
2086
- const showGuides = computed(() => uiService?.get("showGuides") ?? true);
2087
- const showRule = computed(() => uiService?.get("showRule") ?? true);
2088
- const zoomInHandler = () => uiService?.zoom(0.1);
2089
- const zoomOutHandler = () => uiService?.zoom(-0.1);
2090
- const item = computed(() => {
2091
- if (typeof props.data !== "string") {
2092
- return props.data;
2093
- }
2094
- switch (props.data) {
2095
- case "/":
2096
- return {
2097
- type: "divider"
2098
- };
2099
- case "zoom":
2100
- return {
2101
- type: "zoom"
2102
- };
2103
- case "delete":
2104
- return {
2105
- type: "button",
2106
- icon: markRaw(Delete),
2107
- tooltip: "\u522A\u9664",
2108
- disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
2109
- handler: () => services?.editorService.remove(services?.editorService.get("node"))
2110
- };
2111
- case "undo":
2112
- return {
2113
- type: "button",
2114
- icon: markRaw(Back),
2115
- tooltip: "\u540E\u9000",
2116
- disabled: () => !services?.historyService.state.canUndo,
2117
- handler: () => services?.editorService.undo()
2118
- };
2119
- case "redo":
2120
- return {
2121
- type: "button",
2122
- icon: markRaw(Right),
2123
- tooltip: "\u524D\u8FDB",
2124
- disabled: () => !services?.historyService.state.canRedo,
2125
- handler: () => services?.editorService.redo()
2126
- };
2127
- case "zoom-in":
2128
- return {
2129
- type: "button",
2130
- icon: markRaw(ZoomIn),
2131
- tooltip: "\u653E\u5927",
2132
- handler: zoomInHandler
2133
- };
2134
- case "zoom-out":
2135
- return {
2136
- type: "button",
2137
- icon: markRaw(ZoomOut),
2138
- tooltip: "\u7E2E\u5C0F",
2139
- handler: zoomOutHandler
2140
- };
2141
- case "rule":
2142
- return {
2143
- type: "button",
2144
- icon: markRaw(ScaleToOriginal),
2145
- tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2146
- handler: () => uiService?.set("showRule", !showRule.value)
2147
- };
2148
- case "guides":
2149
- return {
2150
- type: "button",
2151
- icon: markRaw(Grid),
2152
- tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2153
- handler: () => uiService?.set("showGuides", !showGuides.value)
2154
- };
2155
- default:
2156
- return {
2157
- type: "text",
2158
- text: props.data
2159
- };
2160
- }
2161
- });
2162
2252
  const disabled = computed(() => {
2163
- if (typeof item.value === "string")
2253
+ if (typeof props.data === "string")
2164
2254
  return false;
2165
- if (item.value.type === "component")
2255
+ if (props.data.type === "component")
2166
2256
  return false;
2167
- if (typeof item.value.disabled === "function") {
2168
- return item.value.disabled(services);
2257
+ if (typeof props.data.disabled === "function") {
2258
+ return props.data.disabled(services);
2169
2259
  }
2170
- return item.value.disabled;
2260
+ return props.data.disabled;
2171
2261
  });
2172
- const buttonHandler = (item2, event) => {
2173
- if (disabled.value)
2174
- return;
2175
- if (typeof item2.handler === "function" && services) {
2176
- item2.handler?.(services, event);
2177
- }
2178
- };
2179
2262
  const display = computed(() => {
2180
- if (!item.value)
2263
+ if (!props.data)
2181
2264
  return false;
2182
- if (typeof item.value === "string")
2265
+ if (typeof props.data === "string")
2183
2266
  return true;
2184
- if (typeof item.value.display === "function") {
2185
- return item.value.display(services);
2267
+ if (typeof props.data.display === "function") {
2268
+ return props.data.display(services);
2186
2269
  }
2187
- return item.value.display ?? true;
2270
+ return props.data.display ?? true;
2188
2271
  });
2272
+ const buttonHandler = (item, event) => {
2273
+ if (disabled.value)
2274
+ return;
2275
+ if (typeof item.handler === "function" && services) {
2276
+ item.handler?.(services, event);
2277
+ }
2278
+ };
2189
2279
  const dropdownHandler = (command) => {
2190
2280
  if (command.item.handler) {
2191
2281
  command.item.handler(services);
2192
2282
  }
2193
2283
  };
2194
- const clickHandler = (item2, event) => {
2284
+ const clickHandler = (item, event) => {
2195
2285
  if (props.eventType !== "click")
2196
2286
  return;
2197
- if (item2.type === "button") {
2198
- buttonHandler(item2, event);
2287
+ if (item.type === "button") {
2288
+ buttonHandler(item, event);
2199
2289
  }
2200
2290
  };
2201
- const mousedownHandler = (item2, event) => {
2291
+ const mousedownHandler = (item, event) => {
2202
2292
  if (props.eventType !== "mousedown")
2203
2293
  return;
2204
- if (item2.type === "button") {
2205
- buttonHandler(item2, event);
2294
+ if (item.type === "button") {
2295
+ buttonHandler(item, event);
2206
2296
  }
2207
2297
  };
2208
- const mouseupHandler = (item2, event) => {
2298
+ const mouseupHandler = (item, event) => {
2209
2299
  if (props.eventType !== "mouseup")
2210
2300
  return;
2211
- if (item2.type === "button") {
2212
- buttonHandler(item2, event);
2301
+ if (item.type === "button") {
2302
+ buttonHandler(item, event);
2213
2303
  }
2214
2304
  };
2215
2305
  return (_ctx, _cache) => {
2216
2306
  const _component_el_divider = resolveComponent("el-divider");
2217
- const _component_tool_button = resolveComponent("tool-button", true);
2218
2307
  const _component_el_button = resolveComponent("el-button");
2219
2308
  const _component_el_tooltip = resolveComponent("el-tooltip");
2220
2309
  const _component_el_icon = resolveComponent("el-icon");
@@ -2223,30 +2312,20 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2223
2312
  const _component_el_dropdown = resolveComponent("el-dropdown");
2224
2313
  return unref(display) ? (openBlock(), createElementBlock("div", {
2225
2314
  key: 0,
2226
- class: normalizeClass(["menu-item", unref(item).type]),
2227
- onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(item), $event)),
2228
- onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(unref(item), $event)),
2229
- onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(unref(item), $event))
2315
+ class: normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
2316
+ onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(__props.data, $event)),
2317
+ onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
2318
+ onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
2230
2319
  }, [
2231
- unref(item).type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2320
+ __props.data.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2232
2321
  key: 0,
2233
- direction: unref(item).direction || "vertical"
2234
- }, null, 8, ["direction"])) : unref(item).type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$7, toDisplayString(unref(item).text), 1)) : unref(item).type === "zoom" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2235
- createVNode(_component_tool_button, {
2236
- data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2237
- "event-type": __props.eventType
2238
- }, null, 8, ["data", "event-type"]),
2239
- createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
2240
- createVNode(_component_tool_button, {
2241
- data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
2242
- "event-type": __props.eventType
2243
- }, null, 8, ["data", "event-type"])
2244
- ], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
2245
- unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
2322
+ direction: __props.data.direction || "vertical"
2323
+ }, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$5, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2324
+ __props.data.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
2246
2325
  key: 0,
2247
2326
  effect: "dark",
2248
2327
  placement: "bottom-start",
2249
- content: unref(item).tooltip
2328
+ content: __props.data.tooltip
2250
2329
  }, {
2251
2330
  default: withCtx(() => [
2252
2331
  createVNode(_component_el_button, {
@@ -2255,11 +2334,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2255
2334
  disabled: unref(disabled)
2256
2335
  }, {
2257
2336
  default: withCtx(() => [
2258
- unref(item).icon ? (openBlock(), createBlock(MIcon, {
2337
+ __props.data.icon ? (openBlock(), createBlock(_sfc_main$h, {
2259
2338
  key: 0,
2260
- icon: unref(item).icon
2339
+ icon: __props.data.icon
2261
2340
  }, null, 8, ["icon"])) : createCommentVNode("", true),
2262
- createElementVNode("span", null, toDisplayString(unref(item).text), 1)
2341
+ createElementVNode("span", null, toDisplayString(__props.data.text), 1)
2263
2342
  ]),
2264
2343
  _: 1
2265
2344
  }, 8, ["disabled"])
@@ -2272,27 +2351,27 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2272
2351
  disabled: unref(disabled)
2273
2352
  }, {
2274
2353
  default: withCtx(() => [
2275
- unref(item).icon ? (openBlock(), createBlock(MIcon, {
2354
+ __props.data.icon ? (openBlock(), createBlock(_sfc_main$h, {
2276
2355
  key: 0,
2277
- icon: unref(item).icon
2356
+ icon: __props.data.icon
2278
2357
  }, null, 8, ["icon"])) : createCommentVNode("", true),
2279
- createElementVNode("span", null, toDisplayString(unref(item).text), 1)
2358
+ createElementVNode("span", null, toDisplayString(__props.data.text), 1)
2280
2359
  ]),
2281
2360
  _: 1
2282
2361
  }, 8, ["disabled"]))
2283
- ], 64)) : unref(item).type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
2284
- key: 4,
2362
+ ], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
2363
+ key: 3,
2285
2364
  trigger: "click",
2286
2365
  disabled: unref(disabled),
2287
2366
  onCommand: dropdownHandler
2288
2367
  }, {
2289
2368
  dropdown: withCtx(() => [
2290
- unref(item).items && unref(item).items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
2369
+ __props.data.items && __props.data.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
2291
2370
  default: withCtx(() => [
2292
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(item).items, (subItem, index) => {
2371
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data.items, (subItem, index) => {
2293
2372
  return openBlock(), createBlock(_component_el_dropdown_item, {
2294
2373
  key: index,
2295
- command: { item: unref(item), subItem }
2374
+ command: { data: __props.data, subItem }
2296
2375
  }, {
2297
2376
  default: withCtx(() => [
2298
2377
  createTextVNode(toDisplayString(subItem.text), 1)
@@ -2305,8 +2384,8 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2305
2384
  })) : createCommentVNode("", true)
2306
2385
  ]),
2307
2386
  default: withCtx(() => [
2308
- createElementVNode("span", _hoisted_3, [
2309
- createTextVNode(toDisplayString(unref(item).text), 1),
2387
+ createElementVNode("span", _hoisted_2$2, [
2388
+ createTextVNode(toDisplayString(__props.data.text), 1),
2310
2389
  createVNode(_component_el_icon, { class: "el-icon--right" }, {
2311
2390
  default: withCtx(() => [
2312
2391
  createVNode(unref(ArrowDown))
@@ -2316,58 +2395,175 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2316
2395
  ])
2317
2396
  ]),
2318
2397
  _: 1
2319
- }, 8, ["disabled"])) : unref(item).type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(unref(item).component), normalizeProps(mergeProps({ key: 5 }, unref(item).props || {})), null, 16)) : createCommentVNode("", true)
2398
+ }, 8, ["disabled"])) : __props.data.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(__props.data.component), normalizeProps(mergeProps({ key: 4 }, __props.data.props || {})), null, 16)) : createCommentVNode("", true)
2320
2399
  ], 34)) : createCommentVNode("", true);
2321
2400
  };
2322
2401
  }
2323
2402
  });
2324
2403
 
2325
- const _sfc_main$e = defineComponent({
2326
- name: "nav-menu",
2327
- components: { ToolButton: _sfc_main$f },
2404
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2405
+ __name: "NavMenu",
2328
2406
  props: {
2329
- data: {
2330
- type: Object,
2331
- default: () => ({})
2332
- },
2333
- height: {
2334
- type: Number
2335
- }
2407
+ data: { default: () => ({}) },
2408
+ height: { default: 35 }
2336
2409
  },
2337
- setup(props) {
2410
+ setup(__props) {
2411
+ const props = __props;
2338
2412
  const services = inject("services");
2339
- return {
2340
- keys: computed(() => Object.keys(props.data)),
2341
- columnWidth: computed(() => services?.uiService.get("columnWidth"))
2413
+ const uiService = services?.uiService;
2414
+ const columnWidth = computed(() => services?.uiService.get("columnWidth"));
2415
+ const keys = Object.values(ColumnLayout);
2416
+ const showGuides = computed(() => uiService?.get("showGuides") ?? true);
2417
+ const showRule = computed(() => uiService?.get("showRule") ?? true);
2418
+ const zoom = computed(() => uiService?.get("zoom") ?? 1);
2419
+ const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
2420
+ const ctrl = isMac ? "Command" : "Ctrl";
2421
+ const getConfig = (item) => {
2422
+ if (typeof item !== "string") {
2423
+ return [item];
2424
+ }
2425
+ const config = [];
2426
+ switch (item) {
2427
+ case "/":
2428
+ config.push({
2429
+ type: "divider",
2430
+ className: "divider"
2431
+ });
2432
+ break;
2433
+ case "zoom":
2434
+ config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
2435
+ break;
2436
+ case "delete":
2437
+ config.push({
2438
+ type: "button",
2439
+ className: "delete",
2440
+ icon: markRaw(Delete),
2441
+ tooltip: `\u522A\u9664(Delete)`,
2442
+ disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
2443
+ handler: () => services?.editorService.remove(services?.editorService.get("node"))
2444
+ });
2445
+ break;
2446
+ case "undo":
2447
+ config.push({
2448
+ type: "button",
2449
+ className: "undo",
2450
+ icon: markRaw(Back),
2451
+ tooltip: `\u540E\u9000(${ctrl}+z)`,
2452
+ disabled: () => !services?.historyService.state.canUndo,
2453
+ handler: () => services?.editorService.undo()
2454
+ });
2455
+ break;
2456
+ case "redo":
2457
+ config.push({
2458
+ type: "button",
2459
+ className: "redo",
2460
+ icon: markRaw(Right),
2461
+ tooltip: `\u524D\u8FDB(${ctrl}+Shift+z)`,
2462
+ disabled: () => !services?.historyService.state.canRedo,
2463
+ handler: () => services?.editorService.redo()
2464
+ });
2465
+ break;
2466
+ case "zoom-in":
2467
+ config.push({
2468
+ type: "button",
2469
+ className: "zoom-in",
2470
+ icon: markRaw(ZoomIn),
2471
+ tooltip: `\u653E\u5927(${ctrl}+=)`,
2472
+ handler: () => uiService?.zoom(0.1)
2473
+ });
2474
+ break;
2475
+ case "zoom-out":
2476
+ config.push({
2477
+ type: "button",
2478
+ className: "zoom-out",
2479
+ icon: markRaw(ZoomOut),
2480
+ tooltip: `\u7E2E\u5C0F(${ctrl}+-)`,
2481
+ handler: () => uiService?.zoom(-0.1)
2482
+ });
2483
+ break;
2484
+ case "scale-to-original":
2485
+ config.push({
2486
+ type: "button",
2487
+ className: "scale-to-original",
2488
+ icon: markRaw(ScaleToOriginal),
2489
+ tooltip: `\u7F29\u653E\u5230\u5B9E\u9645\u5927\u5C0F(${ctrl}+1)`,
2490
+ handler: () => uiService?.set("zoom", 1)
2491
+ });
2492
+ break;
2493
+ case "scale-to-fit":
2494
+ config.push({
2495
+ type: "button",
2496
+ className: "scale-to-fit",
2497
+ icon: markRaw(FullScreen),
2498
+ tooltip: `\u7F29\u653E\u4EE5\u9002\u5E94(${ctrl}+0)`,
2499
+ handler: () => uiService?.set("zoom", uiService.calcZoom())
2500
+ });
2501
+ break;
2502
+ case "rule":
2503
+ config.push({
2504
+ type: "button",
2505
+ className: "rule",
2506
+ icon: markRaw(Memo),
2507
+ tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2508
+ handler: () => uiService?.set("showRule", !showRule.value)
2509
+ });
2510
+ break;
2511
+ case "guides":
2512
+ config.push({
2513
+ type: "button",
2514
+ className: "guides",
2515
+ icon: markRaw(Grid),
2516
+ tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2517
+ handler: () => uiService?.set("showGuides", !showGuides.value)
2518
+ });
2519
+ break;
2520
+ default:
2521
+ config.push({
2522
+ type: "text",
2523
+ text: item
2524
+ });
2525
+ }
2526
+ return config;
2342
2527
  };
2343
- }
2344
- });
2345
-
2346
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2347
- const _component_tool_button = resolveComponent("tool-button");
2348
- return openBlock(), createElementBlock("div", {
2349
- class: "m-editor-nav-menu",
2350
- style: normalizeStyle({ height: `${_ctx.height}px` })
2351
- }, [
2352
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.keys, (key) => {
2528
+ const buttons = computed(() => {
2529
+ const data = {
2530
+ [ColumnLayout.LEFT]: [],
2531
+ [ColumnLayout.CENTER]: [],
2532
+ [ColumnLayout.RIGHT]: []
2533
+ };
2534
+ keys.forEach((key) => {
2535
+ const items = props.data[key] || [];
2536
+ items.forEach((item) => {
2537
+ data[key].push(...getConfig(item));
2538
+ });
2539
+ });
2540
+ return data;
2541
+ });
2542
+ return (_ctx, _cache) => {
2353
2543
  return openBlock(), createElementBlock("div", {
2354
- class: normalizeClass(`menu-${key}`),
2355
- key,
2356
- style: normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
2544
+ class: "m-editor-nav-menu",
2545
+ style: normalizeStyle({ height: `${__props.height}px` })
2357
2546
  }, [
2358
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data[key], (item, index) => {
2359
- return openBlock(), createBlock(_component_tool_button, {
2360
- data: item,
2361
- key: index
2362
- }, null, 8, ["data"]);
2547
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(keys), (key) => {
2548
+ return openBlock(), createElementBlock("div", {
2549
+ class: normalizeClass(`menu-${key}`),
2550
+ key,
2551
+ style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
2552
+ }, [
2553
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
2554
+ return openBlock(), createBlock(_sfc_main$g, {
2555
+ data: item,
2556
+ key: index
2557
+ }, null, 8, ["data"]);
2558
+ }), 128))
2559
+ ], 6);
2363
2560
  }), 128))
2364
- ], 6);
2365
- }), 128))
2366
- ], 4);
2367
- }
2368
- const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
2561
+ ], 4);
2562
+ };
2563
+ }
2564
+ });
2369
2565
 
2370
- const _sfc_main$d = defineComponent({
2566
+ const _sfc_main$e = defineComponent({
2371
2567
  name: "m-editor-props-panel",
2372
2568
  emits: ["mounted"],
2373
2569
  setup(props, { emit }) {
@@ -2415,10 +2611,10 @@ const _sfc_main$d = defineComponent({
2415
2611
  }
2416
2612
  });
2417
2613
 
2418
- const _hoisted_1$6 = { class: "`m-editor-props-panel" };
2419
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2614
+ const _hoisted_1$4 = { class: "`m-editor-props-panel" };
2615
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2420
2616
  const _component_m_form = resolveComponent("m-form");
2421
- return openBlock(), createElementBlock("div", _hoisted_1$6, [
2617
+ return openBlock(), createElementBlock("div", _hoisted_1$4, [
2422
2618
  renderSlot(_ctx.$slots, "props-panel-header"),
2423
2619
  createVNode(_component_m_form, {
2424
2620
  class: normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
@@ -2431,11 +2627,11 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2431
2627
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
2432
2628
  ]);
2433
2629
  }
2434
- const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
2630
+ const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$6]]);
2435
2631
 
2436
- const _sfc_main$c = defineComponent({
2632
+ const _sfc_main$d = defineComponent({
2437
2633
  name: "ui-component-panel",
2438
- components: { MIcon },
2634
+ components: { MIcon: _sfc_main$h },
2439
2635
  setup() {
2440
2636
  const searchText = ref("");
2441
2637
  const services = inject("services");
@@ -2500,9 +2696,9 @@ const _sfc_main$c = defineComponent({
2500
2696
  }
2501
2697
  });
2502
2698
 
2503
- const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2699
+ const _hoisted_1$3 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2504
2700
  const _hoisted_2$1 = ["onClick", "onDragstart"];
2505
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2701
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2506
2702
  const _component_el_input = resolveComponent("el-input");
2507
2703
  const _component_m_icon = resolveComponent("m-icon");
2508
2704
  const _component_el_tooltip = resolveComponent("el-tooltip");
@@ -2533,7 +2729,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2533
2729
  name: index
2534
2730
  }, {
2535
2731
  title: withCtx(() => [
2536
- _hoisted_1$5,
2732
+ _hoisted_1$3,
2537
2733
  createTextVNode(toDisplayString(group.title), 1)
2538
2734
  ]),
2539
2735
  default: withCtx(() => [
@@ -2574,9 +2770,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2574
2770
  _: 3
2575
2771
  });
2576
2772
  }
2577
- const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
2773
+ const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$5]]);
2578
2774
 
2579
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
2775
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
2580
2776
  __name: "ContentMenu",
2581
2777
  props: {
2582
2778
  menuData: { default: () => [] },
@@ -2665,7 +2861,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2665
2861
  }, [
2666
2862
  createElementVNode("div", null, [
2667
2863
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
2668
- return openBlock(), createBlock(_sfc_main$f, {
2864
+ return openBlock(), createBlock(_sfc_main$g, {
2669
2865
  "event-type": "mouseup",
2670
2866
  data: item,
2671
2867
  key: index,
@@ -2689,8 +2885,8 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2689
2885
  }
2690
2886
  });
2691
2887
 
2692
- const _sfc_main$a = defineComponent({
2693
- components: { ContentMenu: _sfc_main$b },
2888
+ const _sfc_main$b = defineComponent({
2889
+ components: { ContentMenu: _sfc_main$c },
2694
2890
  setup() {
2695
2891
  const services = inject("services");
2696
2892
  const menu = ref();
@@ -2773,7 +2969,7 @@ const _sfc_main$a = defineComponent({
2773
2969
  }
2774
2970
  });
2775
2971
 
2776
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2972
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
2777
2973
  const _component_content_menu = resolveComponent("content-menu");
2778
2974
  return openBlock(), createBlock(_component_content_menu, {
2779
2975
  "menu-data": _ctx.menuData,
@@ -2781,7 +2977,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2781
2977
  style: { "overflow": "initial" }
2782
2978
  }, null, 8, ["menu-data"]);
2783
2979
  }
2784
- const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
2980
+ const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
2785
2981
 
2786
2982
  const throttleTime = 150;
2787
2983
  const select = async (data, editorService) => {
@@ -2908,7 +3104,7 @@ const useFilter = (tree) => ({
2908
3104
  tree.value?.filter(val);
2909
3105
  }
2910
3106
  });
2911
- const _sfc_main$9 = defineComponent({
3107
+ const _sfc_main$a = defineComponent({
2912
3108
  name: "magic-editor-layer-panel",
2913
3109
  components: { LayerMenu },
2914
3110
  setup() {
@@ -2956,8 +3152,8 @@ const _sfc_main$9 = defineComponent({
2956
3152
  }
2957
3153
  });
2958
3154
 
2959
- const _hoisted_1$4 = ["id", "onMouseenter"];
2960
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3155
+ const _hoisted_1$2 = ["id", "onMouseenter"];
3156
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
2961
3157
  const _component_el_input = resolveComponent("el-input");
2962
3158
  const _component_el_tree = resolveComponent("el-tree");
2963
3159
  const _component_layer_menu = resolveComponent("layer-menu");
@@ -3010,7 +3206,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3010
3206
  }, () => [
3011
3207
  createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
3012
3208
  ])
3013
- ], 42, _hoisted_1$4)
3209
+ ], 42, _hoisted_1$2)
3014
3210
  ]),
3015
3211
  _: 3
3016
3212
  }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
@@ -3021,10 +3217,10 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3021
3217
  _: 3
3022
3218
  });
3023
3219
  }
3024
- const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
3220
+ const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
3025
3221
 
3026
- const _sfc_main$8 = defineComponent({
3027
- components: { MIcon },
3222
+ const _sfc_main$9 = defineComponent({
3223
+ components: { MIcon: _sfc_main$h },
3028
3224
  props: {
3029
3225
  data: {
3030
3226
  type: [Object, String]
@@ -3061,11 +3257,11 @@ const _sfc_main$8 = defineComponent({
3061
3257
  }
3062
3258
  });
3063
3259
 
3064
- const _hoisted_1$3 = {
3260
+ const _hoisted_1$1 = {
3065
3261
  key: 1,
3066
3262
  class: "magic-editor-tab-panel-title"
3067
3263
  };
3068
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3264
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3069
3265
  const _component_m_icon = resolveComponent("m-icon");
3070
3266
  const _component_el_tab_pane = resolveComponent("el-tab-pane");
3071
3267
  return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
@@ -3080,7 +3276,7 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3080
3276
  key: 0,
3081
3277
  icon: _ctx.config.icon
3082
3278
  }, null, 8, ["icon"])) : createCommentVNode("", true),
3083
- _ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
3279
+ _ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$1, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
3084
3280
  ]))
3085
3281
  ]),
3086
3282
  default: withCtx(() => [
@@ -3111,9 +3307,9 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3111
3307
  _: 3
3112
3308
  }, 8, ["name"])) : createCommentVNode("", true);
3113
3309
  }
3114
- const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
3310
+ const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
3115
3311
 
3116
- const _sfc_main$7 = defineComponent({
3312
+ const _sfc_main$8 = defineComponent({
3117
3313
  components: { TabPane },
3118
3314
  name: "m-sidebar",
3119
3315
  props: {
@@ -3133,7 +3329,7 @@ const _sfc_main$7 = defineComponent({
3133
3329
  }
3134
3330
  });
3135
3331
 
3136
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3332
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3137
3333
  const _component_tab_pane = resolveComponent("tab-pane");
3138
3334
  const _component_el_tabs = resolveComponent("el-tabs");
3139
3335
  return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
@@ -3168,9 +3364,9 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3168
3364
  _: 3
3169
3365
  }, 8, ["modelValue"])) : createCommentVNode("", true);
3170
3366
  }
3171
- const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
3367
+ const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
3172
3368
 
3173
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3369
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3174
3370
  __name: "PageBarScrollContainer",
3175
3371
  setup(__props) {
3176
3372
  const services = inject("services");
@@ -3297,9 +3493,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3297
3493
  }
3298
3494
  });
3299
3495
 
3300
- const _hoisted_1$2 = ["onClick"];
3496
+ const _hoisted_1 = ["onClick"];
3301
3497
  const _hoisted_2 = { class: "m-editor-page-bar-title" };
3302
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3498
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3303
3499
  __name: "PageBar",
3304
3500
  setup(__props) {
3305
3501
  const services = inject("services");
@@ -3323,7 +3519,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3323
3519
  const _component_el_tooltip = resolveComponent("el-tooltip");
3324
3520
  const _component_el_icon = resolveComponent("el-icon");
3325
3521
  const _component_el_popover = resolveComponent("el-popover");
3326
- return openBlock(), createBlock(_sfc_main$6, null, {
3522
+ return openBlock(), createBlock(_sfc_main$7, null, {
3327
3523
  default: withCtx(() => [
3328
3524
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
3329
3525
  return openBlock(), createElementBlock("div", {
@@ -3362,7 +3558,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3362
3558
  default: withCtx(() => [
3363
3559
  createElementVNode("div", null, [
3364
3560
  renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3365
- createVNode(_sfc_main$f, {
3561
+ createVNode(_sfc_main$g, {
3366
3562
  data: {
3367
3563
  type: "button",
3368
3564
  text: "\u590D\u5236",
@@ -3370,7 +3566,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3370
3566
  handler: () => copy(item)
3371
3567
  }
3372
3568
  }, null, 8, ["data"]),
3373
- createVNode(_sfc_main$f, {
3569
+ createVNode(_sfc_main$g, {
3374
3570
  data: {
3375
3571
  type: "button",
3376
3572
  text: "\u5220\u9664",
@@ -3383,7 +3579,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3383
3579
  ]),
3384
3580
  _: 2
3385
3581
  }, 1024)
3386
- ], 10, _hoisted_1$2);
3582
+ ], 10, _hoisted_1);
3387
3583
  }), 128))
3388
3584
  ]),
3389
3585
  _: 3
@@ -3392,190 +3588,245 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3392
3588
  }
3393
3589
  });
3394
3590
 
3395
- class ScrollViewer$1 {
3396
- enter = false;
3397
- targetEnter = false;
3398
- keydown = false;
3591
+ class ScrollViewer extends EventEmitter {
3399
3592
  container;
3400
3593
  target;
3401
3594
  zoom = 1;
3402
3595
  scrollLeft = 0;
3403
3596
  scrollTop = 0;
3404
- x = 0;
3405
- y = 0;
3406
- resizeObserver = new ResizeObserver((entries) => {
3407
- for (const { contentRect } of entries) {
3408
- const { width, height } = contentRect;
3409
- const targetRect = this.target.getBoundingClientRect();
3410
- const targetWidth = targetRect.width * this.zoom;
3411
- const targetMarginTop = Number(this.target.style.marginTop) || 0;
3412
- const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3413
- if (targetWidth < width) {
3414
- this.target._left = 0;
3415
- }
3416
- if (targetHeight < height) {
3417
- this.target._top = 0;
3418
- }
3419
- this.scroll();
3420
- }
3597
+ scrollHeight = 0;
3598
+ scrollWidth = 0;
3599
+ width = 0;
3600
+ height = 0;
3601
+ translateXCorrectionValue = 0;
3602
+ translateYCorrectionValue = 0;
3603
+ resizeObserver = new ResizeObserver(() => {
3604
+ this.setSize();
3605
+ this.setScrollSize();
3421
3606
  });
3422
3607
  constructor(options) {
3608
+ super();
3423
3609
  this.container = options.container;
3424
3610
  this.target = options.target;
3425
3611
  this.zoom = options.zoom;
3426
- globalThis.addEventListener("keydown", this.keydownHandler);
3427
- globalThis.addEventListener("keyup", this.keyupHandler);
3428
- this.container.addEventListener("mouseenter", this.mouseEnterHandler);
3429
- this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
3430
- this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
3431
- this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
3432
- this.container.addEventListener("wheel", this.wheelHandler);
3612
+ this.container.addEventListener("wheel", this.wheelHandler, false);
3613
+ this.setSize();
3614
+ this.setScrollSize();
3433
3615
  this.resizeObserver.observe(this.container);
3434
3616
  }
3435
3617
  destroy() {
3436
3618
  this.resizeObserver.disconnect();
3437
- this.container.removeEventListener("mouseenter", this.mouseEnterHandler);
3438
- this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
3439
- this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
3440
- this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
3441
- globalThis.removeEventListener("keydown", this.keydownHandler);
3442
- globalThis.removeEventListener("keyup", this.keyupHandler);
3619
+ this.container.removeEventListener("wheel", this.wheelHandler, false);
3620
+ this.removeAllListeners();
3443
3621
  }
3444
3622
  setZoom(zoom) {
3445
3623
  this.zoom = zoom;
3624
+ this.setScrollSize();
3446
3625
  }
3447
- scroll() {
3448
- const scrollLeft = this.target._left;
3449
- const scrollTop = this.target._top;
3450
- this.target.style.transform = `translate(${scrollLeft}px, ${scrollTop}px)`;
3451
- }
3452
- removeHandler() {
3453
- this.target.style.cursor = "";
3454
- this.target.removeEventListener("mousedown", this.mousedownHandler);
3455
- document.removeEventListener("mousemove", this.mousemoveHandler);
3456
- document.removeEventListener("mouseup", this.mouseupHandler);
3626
+ scrollTo({ left, top }) {
3627
+ if (typeof left !== "undefined") {
3628
+ this.scrollLeft = left;
3629
+ }
3630
+ if (typeof top !== "undefined") {
3631
+ this.scrollTop = top;
3632
+ }
3633
+ const translateX = -this.scrollLeft + this.translateXCorrectionValue;
3634
+ const translateY = -this.scrollTop + this.translateYCorrectionValue;
3635
+ this.target.style.transform = `translate(${translateX}px, ${translateY}px)`;
3457
3636
  }
3458
3637
  wheelHandler = (event) => {
3459
- if (this.targetEnter)
3460
- return;
3461
3638
  const { deltaX, deltaY, currentTarget } = event;
3462
3639
  if (currentTarget !== this.container)
3463
3640
  return;
3464
- this.setScrollOffset(deltaX, deltaY);
3465
- this.scroll();
3466
- this.scrollLeft = this.target._left;
3467
- this.scrollTop = this.target._top;
3468
- };
3469
- mouseEnterHandler = () => {
3470
- this.enter = true;
3471
- };
3472
- mouseLeaveHandler = () => {
3473
- this.enter = false;
3474
- };
3475
- targetMouseEnterHandler = () => {
3476
- this.targetEnter = true;
3477
- };
3478
- targetMouseLeaveHandler = () => {
3479
- this.targetEnter = false;
3480
- };
3481
- mousedownHandler = (event) => {
3482
- if (!this.keydown)
3483
- return;
3484
- event.stopImmediatePropagation();
3485
- event.stopPropagation();
3486
- this.target.style.cursor = "grabbing";
3487
- this.x = event.clientX;
3488
- this.y = event.clientY;
3489
- document.addEventListener("mousemove", this.mousemoveHandler);
3490
- document.addEventListener("mouseup", this.mouseupHandler);
3491
- };
3492
- mouseupHandler = () => {
3493
- this.x = 0;
3494
- this.y = 0;
3495
- this.scrollLeft = this.target._left;
3496
- this.scrollTop = this.target._top;
3497
- this.removeHandler();
3498
- };
3499
- mousemoveHandler = (event) => {
3500
- event.stopImmediatePropagation();
3501
- event.stopPropagation();
3502
- const deltaX = event.clientX - this.x;
3503
- const deltaY = event.clientY - this.y;
3504
- this.setScrollOffset(deltaX, deltaY);
3505
- this.scroll();
3506
- };
3507
- keydownHandler = (event) => {
3508
- if (event.code === Keys.ESCAPE && this.enter) {
3509
- event.preventDefault();
3510
- event.stopImmediatePropagation();
3511
- event.stopPropagation();
3641
+ let top;
3642
+ if (this.scrollHeight > this.height) {
3643
+ top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
3512
3644
  }
3513
- if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3514
- return;
3645
+ let left;
3646
+ if (this.scrollWidth > this.width) {
3647
+ left = this.scrollLeft + this.getPos(deltaX, this.scrollLeft, this.scrollWidth, this.width);
3515
3648
  }
3516
- this.keydown = true;
3517
- this.target.style.cursor = "grab";
3518
- this.container.addEventListener("mousedown", this.mousedownHandler);
3649
+ this.scrollTo({ left, top });
3650
+ this.emit("scroll", {
3651
+ scrollLeft: this.scrollLeft,
3652
+ scrollTop: this.scrollTop,
3653
+ scrollHeight: this.scrollHeight,
3654
+ scrollWidth: this.scrollWidth
3655
+ });
3519
3656
  };
3520
- keyupHandler = (event) => {
3521
- if (event.code !== Keys.ESCAPE || !this.keydown) {
3522
- return;
3657
+ getPos(delta, scrollPos, scrollSize, size) {
3658
+ let pos = 0;
3659
+ if (delta < 0) {
3660
+ if (scrollPos > 0) {
3661
+ pos = Math.max(delta, -scrollPos);
3662
+ }
3663
+ } else {
3664
+ const leftPos = scrollSize - size - scrollPos;
3665
+ if (leftPos > 0) {
3666
+ pos = Math.min(delta, leftPos);
3667
+ }
3668
+ }
3669
+ return pos;
3670
+ }
3671
+ setScrollSize = () => {
3672
+ const targetRect = this.target.getBoundingClientRect();
3673
+ this.scrollWidth = targetRect.width * this.zoom + 100;
3674
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3675
+ this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + 100;
3676
+ let left;
3677
+ let top;
3678
+ if (this.scrollWidth < this.width) {
3679
+ left = 0;
3680
+ this.translateXCorrectionValue = 0;
3681
+ } else {
3682
+ this.translateXCorrectionValue = (this.scrollWidth - this.width) / 2;
3523
3683
  }
3524
- event.preventDefault();
3525
- event.stopImmediatePropagation();
3526
- event.stopPropagation();
3527
- this.keydown = false;
3528
- event.preventDefault();
3529
- this.removeHandler();
3684
+ if (this.scrollHeight < this.height) {
3685
+ top = 0;
3686
+ this.translateYCorrectionValue = 0;
3687
+ } else {
3688
+ this.translateYCorrectionValue = (this.scrollHeight - this.height) / 2;
3689
+ }
3690
+ this.scrollTo({
3691
+ left,
3692
+ top
3693
+ });
3694
+ this.emit("scroll", {
3695
+ scrollLeft: this.scrollLeft,
3696
+ scrollTop: this.scrollTop,
3697
+ scrollHeight: this.scrollHeight,
3698
+ scrollWidth: this.scrollWidth
3699
+ });
3530
3700
  };
3531
- setScrollOffset(deltaX, deltaY) {
3701
+ setSize = () => {
3532
3702
  const { width, height } = this.container.getBoundingClientRect();
3533
- const targetRect = this.target.getBoundingClientRect();
3534
- const targetWidth = targetRect.width * this.zoom;
3535
- const targetHeight = targetRect.height * this.zoom;
3536
- let y = 0;
3537
- if (targetHeight > height) {
3538
- if (deltaY > 0) {
3539
- y = this.scrollTop + Math.min(targetHeight - height - this.scrollTop, deltaY);
3540
- } else {
3541
- y = this.scrollTop + Math.max(-(targetHeight - height + this.scrollTop), deltaY);
3703
+ this.width = width;
3704
+ this.height = height;
3705
+ };
3706
+ }
3707
+
3708
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3709
+ __name: "ScrollBar",
3710
+ props: {
3711
+ size: null,
3712
+ scrollSize: null,
3713
+ isHorizontal: { type: Boolean },
3714
+ pos: null
3715
+ },
3716
+ emits: ["scroll"],
3717
+ setup(__props, { emit }) {
3718
+ const props = __props;
3719
+ const bar = ref();
3720
+ const thumb = ref();
3721
+ const thumbSize = computed(() => props.size * (props.size / props.scrollSize));
3722
+ const thumbPos = computed(() => props.pos / props.scrollSize * props.size);
3723
+ const thumbStyle = computed(() => ({
3724
+ [props.isHorizontal ? "width" : "height"]: `${thumbSize.value}px`,
3725
+ transform: `translate${props.isHorizontal ? "X" : "Y"}(${thumbPos.value}px)`
3726
+ }));
3727
+ let gesto;
3728
+ onMounted(() => {
3729
+ if (!thumb.value)
3730
+ return;
3731
+ const thumbEl = thumb.value;
3732
+ gesto = new Gesto(thumbEl, {
3733
+ container: window
3734
+ });
3735
+ gesto.on("dragStart", (e) => {
3736
+ e.inputEvent.stopPropagation();
3737
+ e.inputEvent.preventDefault();
3738
+ }).on("drag", (e) => {
3739
+ scrollBy(getDelta(e));
3740
+ });
3741
+ bar.value?.addEventListener("wheel", wheelHandler, false);
3742
+ });
3743
+ onUnmounted(() => {
3744
+ if (gesto)
3745
+ gesto.off();
3746
+ bar.value?.removeEventListener("wheel", wheelHandler, false);
3747
+ });
3748
+ const wheelHandler = (e) => {
3749
+ const delta = props.isHorizontal ? e.deltaX : e.deltaY;
3750
+ if (delta) {
3751
+ e.preventDefault();
3542
3752
  }
3543
- }
3544
- let x = 0;
3545
- if (targetWidth > width) {
3546
- if (deltaX > 0) {
3547
- x = this.scrollLeft + Math.min(targetWidth - width - this.scrollLeft, deltaX);
3753
+ scrollBy(delta);
3754
+ };
3755
+ const getDelta = (e) => {
3756
+ const ratio = (props.isHorizontal ? e.deltaX : e.deltaY) / props.size;
3757
+ return props.scrollSize * ratio;
3758
+ };
3759
+ const scrollBy = (delta) => {
3760
+ if (delta < 0) {
3761
+ if (props.pos <= 0) {
3762
+ emit("scroll", 0);
3763
+ } else {
3764
+ emit("scroll", -Math.min(-delta, props.pos));
3765
+ }
3548
3766
  } else {
3549
- x = this.scrollLeft + Math.max(-(targetWidth - width + this.scrollLeft), deltaX);
3767
+ const leftPos = props.size - (thumbSize.value + thumbPos.value);
3768
+ if (leftPos <= 0) {
3769
+ emit("scroll", 0);
3770
+ } else {
3771
+ emit("scroll", Math.min(delta, leftPos));
3772
+ }
3550
3773
  }
3551
- }
3552
- this.target._left = x;
3553
- this.target._top = y;
3774
+ };
3775
+ return (_ctx, _cache) => {
3776
+ return openBlock(), createElementBlock("div", {
3777
+ ref_key: "bar",
3778
+ ref: bar,
3779
+ class: normalizeClass(["m-editor-scroll-bar", __props.isHorizontal ? "horizontal" : "vertical"])
3780
+ }, [
3781
+ createElementVNode("div", {
3782
+ ref_key: "thumb",
3783
+ ref: thumb,
3784
+ class: "m-editor-scroll-bar-thumb",
3785
+ style: normalizeStyle(unref(thumbStyle))
3786
+ }, null, 4)
3787
+ ], 2);
3788
+ };
3554
3789
  }
3555
- }
3790
+ });
3556
3791
 
3557
- const _sfc_main$4 = defineComponent({
3558
- name: "m-editor-scroll-viewer",
3792
+ const ScrollBar_vue_vue_type_style_index_0_lang = '';
3793
+
3794
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3795
+ __name: "ScrollViewer",
3559
3796
  props: {
3560
- width: Number,
3561
- height: Number,
3562
- zoom: {
3563
- type: Number,
3564
- default: 1
3565
- }
3797
+ width: { default: 0 },
3798
+ height: { default: 0 },
3799
+ wrapWidth: { default: 0 },
3800
+ wrapHeight: { default: 0 },
3801
+ zoom: { default: 1 }
3566
3802
  },
3567
- setup(props) {
3803
+ setup(__props, { expose }) {
3804
+ const props = __props;
3568
3805
  const container = ref();
3569
3806
  const el = ref();
3807
+ const style = computed(() => `
3808
+ width: ${props.width}px;
3809
+ height: ${props.height}px;
3810
+ position: absolute;
3811
+ margin-top: 30px;
3812
+ `);
3813
+ const scrollWidth = ref(0);
3814
+ const scrollHeight = ref(0);
3570
3815
  let scrollViewer;
3571
3816
  onMounted(() => {
3572
3817
  if (!container.value || !el.value)
3573
3818
  return;
3574
- scrollViewer = new ScrollViewer$1({
3819
+ scrollViewer = new ScrollViewer({
3575
3820
  container: container.value,
3576
3821
  target: el.value,
3577
3822
  zoom: props.zoom
3578
3823
  });
3824
+ scrollViewer.on("scroll", (data) => {
3825
+ hOffset.value = data.scrollLeft;
3826
+ vOffset.value = data.scrollTop;
3827
+ scrollWidth.value = data.scrollWidth;
3828
+ scrollHeight.value = data.scrollHeight;
3829
+ });
3579
3830
  });
3580
3831
  onUnmounted(() => {
3581
3832
  scrollViewer.destroy();
@@ -3583,35 +3834,56 @@ const _sfc_main$4 = defineComponent({
3583
3834
  watch(() => props.zoom, () => {
3584
3835
  scrollViewer.setZoom(props.zoom);
3585
3836
  });
3586
- return {
3587
- container,
3588
- el,
3589
- style: computed(() => `
3590
- width: ${props.width}px;
3591
- height: ${props.height}px;
3592
- position: absolute;
3593
- margin-top: 30px;
3594
- `)
3837
+ const vOffset = ref(0);
3838
+ const vScrollHandler = (delta) => {
3839
+ vOffset.value += delta;
3840
+ scrollViewer.scrollTo({
3841
+ top: vOffset.value
3842
+ });
3843
+ };
3844
+ const hOffset = ref(0);
3845
+ const hScrollHandler = (delta) => {
3846
+ hOffset.value += delta;
3847
+ scrollViewer.scrollTo({
3848
+ left: hOffset.value
3849
+ });
3850
+ };
3851
+ expose({
3852
+ container
3853
+ });
3854
+ return (_ctx, _cache) => {
3855
+ return openBlock(), createElementBlock("div", {
3856
+ class: "m-editor-scroll-viewer-container",
3857
+ ref_key: "container",
3858
+ ref: container
3859
+ }, [
3860
+ createElementVNode("div", {
3861
+ ref_key: "el",
3862
+ ref: el,
3863
+ style: normalizeStyle(unref(style))
3864
+ }, [
3865
+ renderSlot(_ctx.$slots, "default")
3866
+ ], 4),
3867
+ scrollHeight.value > __props.wrapHeight ? (openBlock(), createBlock(_sfc_main$5, {
3868
+ key: 0,
3869
+ "scroll-size": scrollHeight.value,
3870
+ size: __props.wrapHeight,
3871
+ pos: vOffset.value,
3872
+ onScroll: vScrollHandler
3873
+ }, null, 8, ["scroll-size", "size", "pos"])) : createCommentVNode("", true),
3874
+ scrollWidth.value > __props.wrapWidth ? (openBlock(), createBlock(_sfc_main$5, {
3875
+ key: 1,
3876
+ "is-horizontal": true,
3877
+ "scroll-size": scrollWidth.value,
3878
+ pos: hOffset.value,
3879
+ size: __props.wrapWidth,
3880
+ onScroll: hScrollHandler
3881
+ }, null, 8, ["scroll-size", "pos", "size"])) : createCommentVNode("", true)
3882
+ ], 512);
3595
3883
  };
3596
3884
  }
3597
3885
  });
3598
3886
 
3599
- const _hoisted_1$1 = {
3600
- class: "m-editor-scroll-viewer-container",
3601
- ref: "container"
3602
- };
3603
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3604
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
3605
- createElementVNode("div", {
3606
- ref: "el",
3607
- style: normalizeStyle(_ctx.style)
3608
- }, [
3609
- renderSlot(_ctx.$slots, "default")
3610
- ], 4)
3611
- ], 512);
3612
- }
3613
- const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
3614
-
3615
3887
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3616
3888
  __name: "ViewerMenu",
3617
3889
  props: {
@@ -3748,7 +4020,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3748
4020
  };
3749
4021
  expose({ show });
3750
4022
  return (_ctx, _cache) => {
3751
- return openBlock(), createBlock(_sfc_main$b, {
4023
+ return openBlock(), createBlock(_sfc_main$c, {
3752
4024
  "menu-data": menuData,
3753
4025
  ref_key: "menu",
3754
4026
  ref: menu
@@ -3769,12 +4041,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3769
4041
  const menu = ref();
3770
4042
  const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
3771
4043
  const stageRect = computed(() => services?.uiService.get("stageRect"));
3772
- const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
4044
+ const stageContainerRect = computed(() => services?.uiService.get("stageContainerRect"));
3773
4045
  const root = computed(() => services?.editorService.get("root"));
3774
4046
  const page = computed(() => services?.editorService.get("page"));
3775
4047
  const zoom = computed(() => services?.uiService.get("zoom") || 1);
3776
4048
  const node = computed(() => services?.editorService.get("node"));
3777
- const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
3778
4049
  watchEffect(() => {
3779
4050
  if (stage)
3780
4051
  return;
@@ -3782,64 +4053,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3782
4053
  return;
3783
4054
  if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
3784
4055
  return;
3785
- stage = new StageCore({
3786
- render: stageOptions.render,
3787
- runtimeUrl: stageOptions.runtimeUrl,
3788
- zoom: zoom.value,
3789
- autoScrollIntoView: stageOptions.autoScrollIntoView,
3790
- isContainer: stageOptions.isContainer,
3791
- containerHighlightClassName: stageOptions.containerHighlightClassName,
3792
- containerHighlightDuration: stageOptions.containerHighlightDuration,
3793
- containerHighlightType: stageOptions.containerHighlightType,
3794
- canSelect: (el, event, stop) => {
3795
- const elCanSelect = stageOptions.canSelect(el);
3796
- if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
3797
- document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
3798
- return stop();
3799
- }
3800
- return elCanSelect;
3801
- },
3802
- moveableOptions: stageOptions.moveableOptions,
3803
- updateDragEl: stageOptions.updateDragEl
3804
- });
4056
+ stage = useStage(stageOptions);
3805
4057
  services?.editorService.set("stage", markRaw(stage));
3806
4058
  stage?.mount(stageContainer.value);
3807
- stage.mask.setGuides([
3808
- getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
3809
- getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
3810
- ]);
3811
- stage?.on("select", (el) => {
3812
- services?.editorService.select(el.id);
3813
- });
3814
- stage?.on("highlight", (el) => {
3815
- services?.editorService.highlight(el.id);
3816
- });
3817
- stage?.on("multiSelect", (els) => {
3818
- services?.editorService.multiSelect(els.map((el) => el.id));
3819
- });
3820
- stage?.on("update", (ev) => {
3821
- if (ev.parentEl) {
3822
- for (const data of ev.data) {
3823
- services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
3824
- }
3825
- return;
3826
- }
3827
- services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
3828
- });
3829
- stage?.on("sort", (ev) => {
3830
- services?.editorService.sort(ev.src, ev.dist);
3831
- });
3832
- stage?.on("changeGuides", (e2) => {
3833
- services?.uiService.set("showGuides", true);
3834
- if (!root.value || !page.value)
3835
- return;
3836
- const storageKey = getGuideLineKey(e2.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
3837
- if (e2.guides.length) {
3838
- globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
3839
- } else {
3840
- globalThis.localStorage.removeItem(storageKey);
3841
- }
3842
- });
3843
4059
  if (!node.value?.id)
3844
4060
  return;
3845
4061
  stage?.on("runtime-ready", (rt) => {
@@ -3925,12 +4141,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3925
4141
  }
3926
4142
  };
3927
4143
  return (_ctx, _cache) => {
3928
- return openBlock(), createBlock(ScrollViewer, {
4144
+ return openBlock(), createBlock(_sfc_main$4, {
3929
4145
  class: "m-editor-stage",
3930
4146
  ref_key: "stageWrap",
3931
4147
  ref: stageWrap,
3932
4148
  width: unref(stageRect)?.width,
3933
4149
  height: unref(stageRect)?.height,
4150
+ "wrap-width": unref(stageContainerRect)?.width,
4151
+ "wrap-height": unref(stageContainerRect)?.height,
3934
4152
  zoom: unref(zoom)
3935
4153
  }, {
3936
4154
  default: withCtx(() => [
@@ -3938,7 +4156,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3938
4156
  class: "m-editor-stage-container",
3939
4157
  ref_key: "stageContainer",
3940
4158
  ref: stageContainer,
3941
- style: normalizeStyle(`transform: scale(${unref(zoom)})`),
4159
+ style: normalizeStyle(`transform: scale(${unref(zoom)});`),
3942
4160
  onContextmenu: contextmenuHandler,
3943
4161
  onDrop: dropHandler,
3944
4162
  onDragover: dragoverHandler
@@ -3952,28 +4170,25 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3952
4170
  ]))
3953
4171
  ]),
3954
4172
  _: 1
3955
- }, 8, ["width", "height", "zoom"]);
4173
+ }, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
3956
4174
  };
3957
4175
  }
3958
4176
  });
3959
4177
 
3960
- const _sfc_main$1 = defineComponent({
3961
- name: "m-editor-workspace",
3962
- components: {
3963
- PageBar: _sfc_main$5,
3964
- MagicStage: _sfc_main$2
3965
- },
3966
- setup() {
4178
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
4179
+ __name: "Workspace",
4180
+ setup(__props) {
3967
4181
  const services = inject("services");
3968
4182
  const workspace = ref();
3969
4183
  const nodes = computed(() => services?.editorService.get("nodes"));
3970
- let keycon;
4184
+ const page = computed(() => services?.editorService.get("page"));
3971
4185
  const mouseenterHandler = () => {
3972
4186
  workspace.value?.focus();
3973
4187
  };
3974
4188
  const mouseleaveHandler = () => {
3975
4189
  workspace.value?.blur();
3976
4190
  };
4191
+ let keycon;
3977
4192
  onMounted(() => {
3978
4193
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3979
4194
  workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
@@ -4050,6 +4265,12 @@ const _sfc_main$1 = defineComponent({
4050
4265
  }).keydown([ctrl, "numpad-"], (e) => {
4051
4266
  e.inputEvent.preventDefault();
4052
4267
  services?.uiService.zoom(-0.1);
4268
+ }).keydown([ctrl, "0"], (e) => {
4269
+ e.inputEvent.preventDefault();
4270
+ services?.uiService.set("zoom", services.uiService.calcZoom());
4271
+ }).keydown([ctrl, "1"], (e) => {
4272
+ e.inputEvent.preventDefault();
4273
+ services?.uiService.set("zoom", 1);
4053
4274
  });
4054
4275
  });
4055
4276
  onUnmounted(() => {
@@ -4057,41 +4278,33 @@ const _sfc_main$1 = defineComponent({
4057
4278
  workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
4058
4279
  keycon.destroy();
4059
4280
  });
4060
- return {
4061
- workspace,
4062
- page: computed(() => services?.editorService.get("page"))
4281
+ return (_ctx, _cache) => {
4282
+ return openBlock(), createElementBlock("div", {
4283
+ class: "m-editor-workspace",
4284
+ tabindex: "1",
4285
+ ref_key: "workspace",
4286
+ ref: workspace
4287
+ }, [
4288
+ renderSlot(_ctx.$slots, "stage", {}, () => [
4289
+ (openBlock(), createBlock(_sfc_main$2, {
4290
+ key: unref(page)?.id
4291
+ }))
4292
+ ]),
4293
+ renderSlot(_ctx.$slots, "workspace-content"),
4294
+ createVNode(_sfc_main$6, null, {
4295
+ "page-bar-title": withCtx(({ page: page2 }) => [
4296
+ renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
4297
+ ]),
4298
+ "page-bar-popover": withCtx(({ page: page2 }) => [
4299
+ renderSlot(_ctx.$slots, "page-bar-popover", { page: page2 })
4300
+ ]),
4301
+ _: 3
4302
+ })
4303
+ ], 512);
4063
4304
  };
4064
4305
  }
4065
4306
  });
4066
4307
 
4067
- const _hoisted_1 = {
4068
- class: "m-editor-workspace",
4069
- tabindex: "1",
4070
- ref: "workspace"
4071
- };
4072
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4073
- const _component_magic_stage = resolveComponent("magic-stage");
4074
- const _component_page_bar = resolveComponent("page-bar");
4075
- return openBlock(), createElementBlock("div", _hoisted_1, [
4076
- renderSlot(_ctx.$slots, "stage", {}, () => [
4077
- (openBlock(), createBlock(_component_magic_stage, {
4078
- key: _ctx.page?.id
4079
- }))
4080
- ]),
4081
- renderSlot(_ctx.$slots, "workspace-content"),
4082
- createVNode(_component_page_bar, null, {
4083
- "page-bar-title": withCtx(({ page }) => [
4084
- renderSlot(_ctx.$slots, "page-bar-title", { page })
4085
- ]),
4086
- "page-bar-popover": withCtx(({ page }) => [
4087
- renderSlot(_ctx.$slots, "page-bar-popover", { page })
4088
- ]),
4089
- _: 3
4090
- })
4091
- ], 512);
4092
- }
4093
- const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4094
-
4095
4308
  class ComponentList extends BaseService {
4096
4309
  state = reactive({
4097
4310
  list: []
@@ -4108,132 +4321,12 @@ class ComponentList extends BaseService {
4108
4321
  }
4109
4322
  const componentListService = new ComponentList();
4110
4323
 
4111
- const DEFAULT_LEFT_COLUMN_WIDTH = 310;
4112
- const MIN_LEFT_COLUMN_WIDTH = 45;
4113
- const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
4114
- const MIN_RIGHT_COLUMN_WIDTH = 1;
4115
- const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
4116
- const defaultColumnWidth = {
4117
- left: DEFAULT_LEFT_COLUMN_WIDTH,
4118
- center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
4119
- right: DEFAULT_RIGHT_COLUMN_WIDTH
4120
- };
4121
- const state = reactive({
4122
- uiSelectMode: false,
4123
- showSrc: false,
4124
- zoom: 1,
4125
- stageContainerRect: {
4126
- width: 0,
4127
- height: 0
4128
- },
4129
- stageRect: {
4130
- width: 375,
4131
- height: 817
4132
- },
4133
- columnWidth: defaultColumnWidth,
4134
- showGuides: true,
4135
- showRule: true,
4136
- propsPanelSize: "small"
4137
- });
4138
- class Ui extends BaseService {
4139
- constructor() {
4140
- super([]);
4141
- globalThis.addEventListener("resize", () => {
4142
- this.setColumnWidth({
4143
- center: "auto"
4144
- });
4145
- });
4146
- const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
4147
- if (columnWidthCacheData) {
4148
- try {
4149
- const columnWidthCache = JSON.parse(columnWidthCacheData);
4150
- this.setColumnWidth(columnWidthCache);
4151
- } catch (e) {
4152
- console.error(e);
4153
- }
4154
- }
4155
- }
4156
- set(name, value) {
4157
- const mask = editorService.get("stage")?.mask;
4158
- if (name === "columnWidth") {
4159
- this.setColumnWidth(value);
4160
- return;
4161
- }
4162
- if (name === "stageRect") {
4163
- this.setStageRect(value);
4164
- return;
4165
- }
4166
- if (name === "showGuides") {
4167
- mask?.showGuides(value);
4168
- }
4169
- if (name === "showRule") {
4170
- mask?.showRule(value);
4171
- }
4172
- state[name] = value;
4173
- if (name === "stageContainerRect") {
4174
- state.zoom = this.calcZoom();
4175
- }
4176
- }
4177
- get(name) {
4178
- return state[name];
4179
- }
4180
- zoom(zoom) {
4181
- this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
4182
- if (this.get("zoom") < 0.1)
4183
- this.set("zoom", 0.1);
4184
- }
4185
- setColumnWidth({ left, center, right }) {
4186
- const columnWidth = {
4187
- ...toRaw(this.get("columnWidth"))
4188
- };
4189
- if (left) {
4190
- columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
4191
- }
4192
- if (right) {
4193
- columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
4194
- }
4195
- if (!center || center === "auto") {
4196
- const bodyWidth = globalThis.document.body.clientWidth;
4197
- columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
4198
- if (columnWidth.center <= 0) {
4199
- columnWidth.left = defaultColumnWidth.left;
4200
- columnWidth.center = defaultColumnWidth.center;
4201
- columnWidth.right = defaultColumnWidth.right;
4202
- }
4203
- } else {
4204
- columnWidth.center = center;
4205
- }
4206
- globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
4207
- state.columnWidth = columnWidth;
4208
- }
4209
- setStageRect(value) {
4210
- state.stageRect = {
4211
- ...state.stageRect,
4212
- ...value
4213
- };
4214
- state.zoom = this.calcZoom();
4215
- }
4216
- calcZoom() {
4217
- const { stageRect, stageContainerRect } = state;
4218
- const { height, width } = stageContainerRect;
4219
- if (!width || !height)
4220
- return 1;
4221
- const stageWidth = stageRect.width + 30;
4222
- const stageHeight = stageRect.height + 30;
4223
- if (width > stageWidth && height > stageHeight) {
4224
- return 1;
4225
- }
4226
- return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
4227
- }
4228
- }
4229
- const uiService = new Ui();
4230
-
4231
4324
  const _sfc_main = defineComponent({
4232
4325
  name: "m-editor",
4233
4326
  components: {
4234
- NavMenu,
4327
+ NavMenu: _sfc_main$f,
4235
4328
  Sidebar,
4236
- Workspace,
4329
+ Workspace: _sfc_main$1,
4237
4330
  PropsPanel,
4238
4331
  Framework
4239
4332
  },
@@ -4456,12 +4549,12 @@ const index = {
4456
4549
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4457
4550
  setConfig(option);
4458
4551
  app.component(Editor.name, Editor);
4459
- app.component("m-fields-ui-select", _sfc_main$l);
4552
+ app.component("m-fields-ui-select", _sfc_main$m);
4460
4553
  app.component(CodeLink.name, CodeLink);
4461
4554
  app.component(Code.name, Code);
4462
4555
  app.component(CodeEditor.name, CodeEditor);
4463
4556
  }
4464
4557
  };
4465
4558
 
4466
- export { COPY_STORAGE_KEY, ComponentListPanel, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$f as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, warn };
4559
+ export { COPY_STORAGE_KEY, ColumnLayout, ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$h as Icon, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$g as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, useStage, warn };
4467
4560
  //# sourceMappingURL=tmagic-editor.mjs.map