@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
@@ -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"])
@@ -270,7 +270,7 @@
270
270
  }
271
271
  return value;
272
272
  };
273
- const _sfc_main$k = vue.defineComponent({
273
+ const _sfc_main$l = vue.defineComponent({
274
274
  name: "magic-code-editor",
275
275
  props: {
276
276
  initValues: {
@@ -378,14 +378,14 @@
378
378
  }
379
379
  });
380
380
 
381
- const _hoisted_1$c = {
381
+ const _hoisted_1$a = {
382
382
  ref: "codeEditor",
383
383
  class: "magic-code-editor"
384
384
  };
385
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
386
- 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);
387
387
  }
388
- 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]]);
389
389
 
390
390
  let $TMAGIC_EDITOR = {};
391
391
  const setConfig = (option) => {
@@ -713,6 +713,12 @@
713
713
  }
714
714
  const storageService = new WebStorage();
715
715
 
716
+ var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
717
+ ColumnLayout2["LEFT"] = "left";
718
+ ColumnLayout2["CENTER"] = "center";
719
+ ColumnLayout2["RIGHT"] = "right";
720
+ return ColumnLayout2;
721
+ })(ColumnLayout || {});
716
722
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
717
723
  LayerOffset2["TOP"] = "top";
718
724
  LayerOffset2["BOTTOM"] = "bottom";
@@ -1848,7 +1854,189 @@
1848
1854
  }
1849
1855
  };
1850
1856
 
1851
- 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({
1852
2040
  components: { Plus: iconsVue.Plus },
1853
2041
  setup() {
1854
2042
  const services = vue.inject("services");
@@ -1866,13 +2054,13 @@
1866
2054
  }
1867
2055
  });
1868
2056
 
1869
- const _hoisted_1$b = { class: "m-editor-empty-panel" };
2057
+ const _hoisted_1$9 = { class: "m-editor-empty-panel" };
1870
2058
  const _hoisted_2$4 = { class: "m-editor-empty-content" };
1871
- const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1872
- 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) {
1873
2061
  const _component_plus = vue.resolveComponent("plus");
1874
2062
  const _component_el_icon = vue.resolveComponent("el-icon");
1875
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
2063
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
1876
2064
  vue.createElementVNode("div", _hoisted_2$4, [
1877
2065
  vue.createElementVNode("div", {
1878
2066
  class: "m-editor-empty-button",
@@ -1886,14 +2074,14 @@
1886
2074
  _: 1
1887
2075
  })
1888
2076
  ]),
1889
- _hoisted_3$1
2077
+ _hoisted_3
1890
2078
  ])
1891
2079
  ])
1892
2080
  ]);
1893
2081
  }
1894
- 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]]);
1895
2083
 
1896
- const _sfc_main$i = vue.defineComponent({
2084
+ const _sfc_main$j = vue.defineComponent({
1897
2085
  name: "m-editor-resize",
1898
2086
  props: {
1899
2087
  type: {
@@ -1936,18 +2124,18 @@
1936
2124
  }
1937
2125
  });
1938
2126
 
1939
- const _hoisted_1$a = {
2127
+ const _hoisted_1$8 = {
1940
2128
  ref: "target",
1941
2129
  class: "m-editor-resizer"
1942
2130
  };
1943
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1944
- 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, [
1945
2133
  vue.renderSlot(_ctx.$slots, "default")
1946
2134
  ], 512);
1947
2135
  }
1948
- 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]]);
1949
2137
 
1950
- const _sfc_main$h = vue.defineComponent({
2138
+ const _sfc_main$i = vue.defineComponent({
1951
2139
  components: {
1952
2140
  AddPageBox,
1953
2141
  Resizer
@@ -1977,17 +2165,17 @@
1977
2165
  }
1978
2166
  });
1979
2167
 
1980
- const _hoisted_1$9 = { class: "m-editor" };
2168
+ const _hoisted_1$7 = { class: "m-editor" };
1981
2169
  const _hoisted_2$3 = {
1982
2170
  key: 1,
1983
2171
  class: "m-editor-content"
1984
2172
  };
1985
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2173
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
1986
2174
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
1987
2175
  const _component_resizer = vue.resolveComponent("resizer");
1988
2176
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
1989
2177
  const _component_add_page_box = vue.resolveComponent("add-page-box");
1990
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
2178
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
1991
2179
  vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
1992
2180
  _ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
1993
2181
  key: 0,
@@ -2028,211 +2216,112 @@
2028
2216
  ]))
2029
2217
  ]);
2030
2218
  }
2031
- 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]]);
2032
2220
 
2033
- const _sfc_main$g = vue.defineComponent({
2034
- name: "m-icon",
2035
- components: { Edit: iconsVue.Edit },
2221
+ const _hoisted_1$6 = ["src"];
2222
+ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
2223
+ __name: "Icon",
2036
2224
  props: {
2037
- icon: {
2038
- type: [String, Object]
2039
- }
2225
+ icon: null
2040
2226
  },
2041
- setup() {
2042
- return {
2043
- 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
+ }));
2044
2249
  };
2045
2250
  }
2046
2251
  });
2047
2252
 
2048
- const _hoisted_1$8 = ["src"];
2049
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2050
- const _component_edit = vue.resolveComponent("edit");
2051
- const _component_el_icon = vue.resolveComponent("el-icon");
2052
- return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
2053
- default: vue.withCtx(() => [
2054
- vue.createVNode(_component_edit)
2055
- ]),
2056
- _: 1
2057
- })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
2058
- default: vue.withCtx(() => [
2059
- vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
2060
- ]),
2061
- _: 1
2062
- })) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2063
- key: 2,
2064
- class: vue.normalizeClass(_ctx.icon)
2065
- }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
2066
- default: vue.withCtx(() => [
2067
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.toRaw(_ctx.icon))))
2068
- ]),
2069
- _: 1
2070
- }));
2071
- }
2072
- const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
2073
-
2074
- const _hoisted_1$7 = {
2253
+ const _hoisted_1$5 = {
2075
2254
  key: 1,
2076
2255
  class: "menu-item-text"
2077
2256
  };
2078
- const _hoisted_2$2 = {
2079
- class: "menu-item-text",
2080
- style: { "margin": "0 5px" }
2081
- };
2082
- const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
2083
- 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({
2084
2259
  __name: "ToolButton",
2085
2260
  props: {
2086
- data: {
2087
- type: [Object, String],
2088
- require: true,
2089
- default: () => ({
2090
- type: "text",
2091
- display: false
2092
- })
2093
- },
2094
- eventType: {
2095
- type: String,
2096
- default: "click"
2097
- }
2261
+ data: { default: () => ({
2262
+ type: "text",
2263
+ display: false
2264
+ }) },
2265
+ eventType: { default: "click" }
2098
2266
  },
2099
2267
  setup(__props) {
2100
2268
  const props = __props;
2101
2269
  const services = vue.inject("services");
2102
- const uiService = services?.uiService;
2103
- const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
2104
- const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
2105
- const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
2106
- const zoomInHandler = () => uiService?.zoom(0.1);
2107
- const zoomOutHandler = () => uiService?.zoom(-0.1);
2108
- const item = vue.computed(() => {
2109
- if (typeof props.data !== "string") {
2110
- return props.data;
2111
- }
2112
- switch (props.data) {
2113
- case "/":
2114
- return {
2115
- type: "divider"
2116
- };
2117
- case "zoom":
2118
- return {
2119
- type: "zoom"
2120
- };
2121
- case "delete":
2122
- return {
2123
- type: "button",
2124
- icon: vue.markRaw(iconsVue.Delete),
2125
- tooltip: "\u522A\u9664",
2126
- disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
2127
- handler: () => services?.editorService.remove(services?.editorService.get("node"))
2128
- };
2129
- case "undo":
2130
- return {
2131
- type: "button",
2132
- icon: vue.markRaw(iconsVue.Back),
2133
- tooltip: "\u540E\u9000",
2134
- disabled: () => !services?.historyService.state.canUndo,
2135
- handler: () => services?.editorService.undo()
2136
- };
2137
- case "redo":
2138
- return {
2139
- type: "button",
2140
- icon: vue.markRaw(iconsVue.Right),
2141
- tooltip: "\u524D\u8FDB",
2142
- disabled: () => !services?.historyService.state.canRedo,
2143
- handler: () => services?.editorService.redo()
2144
- };
2145
- case "zoom-in":
2146
- return {
2147
- type: "button",
2148
- icon: vue.markRaw(iconsVue.ZoomIn),
2149
- tooltip: "\u653E\u5927",
2150
- handler: zoomInHandler
2151
- };
2152
- case "zoom-out":
2153
- return {
2154
- type: "button",
2155
- icon: vue.markRaw(iconsVue.ZoomOut),
2156
- tooltip: "\u7E2E\u5C0F",
2157
- handler: zoomOutHandler
2158
- };
2159
- case "rule":
2160
- return {
2161
- type: "button",
2162
- icon: vue.markRaw(iconsVue.ScaleToOriginal),
2163
- tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2164
- handler: () => uiService?.set("showRule", !showRule.value)
2165
- };
2166
- case "guides":
2167
- return {
2168
- type: "button",
2169
- icon: vue.markRaw(iconsVue.Grid),
2170
- tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2171
- handler: () => uiService?.set("showGuides", !showGuides.value)
2172
- };
2173
- default:
2174
- return {
2175
- type: "text",
2176
- text: props.data
2177
- };
2178
- }
2179
- });
2180
2270
  const disabled = vue.computed(() => {
2181
- if (typeof item.value === "string")
2271
+ if (typeof props.data === "string")
2182
2272
  return false;
2183
- if (item.value.type === "component")
2273
+ if (props.data.type === "component")
2184
2274
  return false;
2185
- if (typeof item.value.disabled === "function") {
2186
- return item.value.disabled(services);
2275
+ if (typeof props.data.disabled === "function") {
2276
+ return props.data.disabled(services);
2187
2277
  }
2188
- return item.value.disabled;
2278
+ return props.data.disabled;
2189
2279
  });
2190
- const buttonHandler = (item2, event) => {
2191
- if (disabled.value)
2192
- return;
2193
- if (typeof item2.handler === "function" && services) {
2194
- item2.handler?.(services, event);
2195
- }
2196
- };
2197
2280
  const display = vue.computed(() => {
2198
- if (!item.value)
2281
+ if (!props.data)
2199
2282
  return false;
2200
- if (typeof item.value === "string")
2283
+ if (typeof props.data === "string")
2201
2284
  return true;
2202
- if (typeof item.value.display === "function") {
2203
- return item.value.display(services);
2285
+ if (typeof props.data.display === "function") {
2286
+ return props.data.display(services);
2204
2287
  }
2205
- return item.value.display ?? true;
2288
+ return props.data.display ?? true;
2206
2289
  });
2290
+ const buttonHandler = (item, event) => {
2291
+ if (disabled.value)
2292
+ return;
2293
+ if (typeof item.handler === "function" && services) {
2294
+ item.handler?.(services, event);
2295
+ }
2296
+ };
2207
2297
  const dropdownHandler = (command) => {
2208
2298
  if (command.item.handler) {
2209
2299
  command.item.handler(services);
2210
2300
  }
2211
2301
  };
2212
- const clickHandler = (item2, event) => {
2302
+ const clickHandler = (item, event) => {
2213
2303
  if (props.eventType !== "click")
2214
2304
  return;
2215
- if (item2.type === "button") {
2216
- buttonHandler(item2, event);
2305
+ if (item.type === "button") {
2306
+ buttonHandler(item, event);
2217
2307
  }
2218
2308
  };
2219
- const mousedownHandler = (item2, event) => {
2309
+ const mousedownHandler = (item, event) => {
2220
2310
  if (props.eventType !== "mousedown")
2221
2311
  return;
2222
- if (item2.type === "button") {
2223
- buttonHandler(item2, event);
2312
+ if (item.type === "button") {
2313
+ buttonHandler(item, event);
2224
2314
  }
2225
2315
  };
2226
- const mouseupHandler = (item2, event) => {
2316
+ const mouseupHandler = (item, event) => {
2227
2317
  if (props.eventType !== "mouseup")
2228
2318
  return;
2229
- if (item2.type === "button") {
2230
- buttonHandler(item2, event);
2319
+ if (item.type === "button") {
2320
+ buttonHandler(item, event);
2231
2321
  }
2232
2322
  };
2233
2323
  return (_ctx, _cache) => {
2234
2324
  const _component_el_divider = vue.resolveComponent("el-divider");
2235
- const _component_tool_button = vue.resolveComponent("tool-button", true);
2236
2325
  const _component_el_button = vue.resolveComponent("el-button");
2237
2326
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2238
2327
  const _component_el_icon = vue.resolveComponent("el-icon");
@@ -2241,30 +2330,20 @@
2241
2330
  const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2242
2331
  return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
2243
2332
  key: 0,
2244
- class: vue.normalizeClass(["menu-item", vue.unref(item).type]),
2245
- onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(vue.unref(item), $event)),
2246
- onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(vue.unref(item), $event)),
2247
- 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))
2248
2337
  }, [
2249
- vue.unref(item).type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2338
+ __props.data.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2250
2339
  key: 0,
2251
- direction: vue.unref(item).direction || "vertical"
2252
- }, 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 }, [
2253
- vue.createVNode(_component_tool_button, {
2254
- data: { type: "button", icon: vue.unref(iconsVue.ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2255
- "event-type": __props.eventType
2256
- }, null, 8, ["data", "event-type"]),
2257
- vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${vue.unref(zoom) * 100}`, 10)) + "%", 1),
2258
- vue.createVNode(_component_tool_button, {
2259
- data: { type: "button", icon: vue.unref(iconsVue.ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
2260
- "event-type": __props.eventType
2261
- }, null, 8, ["data", "event-type"])
2262
- ], 64)) : vue.unref(item).type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
2263
- 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, {
2264
2343
  key: 0,
2265
2344
  effect: "dark",
2266
2345
  placement: "bottom-start",
2267
- content: vue.unref(item).tooltip
2346
+ content: __props.data.tooltip
2268
2347
  }, {
2269
2348
  default: vue.withCtx(() => [
2270
2349
  vue.createVNode(_component_el_button, {
@@ -2273,11 +2352,11 @@
2273
2352
  disabled: vue.unref(disabled)
2274
2353
  }, {
2275
2354
  default: vue.withCtx(() => [
2276
- vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
2355
+ __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
2277
2356
  key: 0,
2278
- icon: vue.unref(item).icon
2357
+ icon: __props.data.icon
2279
2358
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2280
- vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
2359
+ vue.createElementVNode("span", null, vue.toDisplayString(__props.data.text), 1)
2281
2360
  ]),
2282
2361
  _: 1
2283
2362
  }, 8, ["disabled"])
@@ -2290,27 +2369,27 @@
2290
2369
  disabled: vue.unref(disabled)
2291
2370
  }, {
2292
2371
  default: vue.withCtx(() => [
2293
- vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
2372
+ __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
2294
2373
  key: 0,
2295
- icon: vue.unref(item).icon
2374
+ icon: __props.data.icon
2296
2375
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2297
- vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
2376
+ vue.createElementVNode("span", null, vue.toDisplayString(__props.data.text), 1)
2298
2377
  ]),
2299
2378
  _: 1
2300
2379
  }, 8, ["disabled"]))
2301
- ], 64)) : vue.unref(item).type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2302
- key: 4,
2380
+ ], 64)) : __props.data.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2381
+ key: 3,
2303
2382
  trigger: "click",
2304
2383
  disabled: vue.unref(disabled),
2305
2384
  onCommand: dropdownHandler
2306
2385
  }, {
2307
2386
  dropdown: vue.withCtx(() => [
2308
- 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 }, {
2309
2388
  default: vue.withCtx(() => [
2310
- (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) => {
2311
2390
  return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
2312
2391
  key: index,
2313
- command: { item: vue.unref(item), subItem }
2392
+ command: { data: __props.data, subItem }
2314
2393
  }, {
2315
2394
  default: vue.withCtx(() => [
2316
2395
  vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
@@ -2323,8 +2402,8 @@
2323
2402
  })) : vue.createCommentVNode("", true)
2324
2403
  ]),
2325
2404
  default: vue.withCtx(() => [
2326
- vue.createElementVNode("span", _hoisted_3, [
2327
- 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),
2328
2407
  vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
2329
2408
  default: vue.withCtx(() => [
2330
2409
  vue.createVNode(vue.unref(iconsVue.ArrowDown))
@@ -2334,58 +2413,175 @@
2334
2413
  ])
2335
2414
  ]),
2336
2415
  _: 1
2337
- }, 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)
2338
2417
  ], 34)) : vue.createCommentVNode("", true);
2339
2418
  };
2340
2419
  }
2341
2420
  });
2342
2421
 
2343
- const _sfc_main$e = vue.defineComponent({
2344
- name: "nav-menu",
2345
- components: { ToolButton: _sfc_main$f },
2422
+ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
2423
+ __name: "NavMenu",
2346
2424
  props: {
2347
- data: {
2348
- type: Object,
2349
- default: () => ({})
2350
- },
2351
- height: {
2352
- type: Number
2353
- }
2425
+ data: { default: () => ({}) },
2426
+ height: { default: 35 }
2354
2427
  },
2355
- setup(props) {
2428
+ setup(__props) {
2429
+ const props = __props;
2356
2430
  const services = vue.inject("services");
2357
- return {
2358
- keys: vue.computed(() => Object.keys(props.data)),
2359
- 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;
2360
2545
  };
2361
- }
2362
- });
2363
-
2364
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2365
- const _component_tool_button = vue.resolveComponent("tool-button");
2366
- return vue.openBlock(), vue.createElementBlock("div", {
2367
- class: "m-editor-nav-menu",
2368
- style: vue.normalizeStyle({ height: `${_ctx.height}px` })
2369
- }, [
2370
- (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) => {
2371
2561
  return vue.openBlock(), vue.createElementBlock("div", {
2372
- class: vue.normalizeClass(`menu-${key}`),
2373
- key,
2374
- style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.[key]}px`)
2562
+ class: "m-editor-nav-menu",
2563
+ style: vue.normalizeStyle({ height: `${__props.height}px` })
2375
2564
  }, [
2376
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data[key], (item, index) => {
2377
- return vue.openBlock(), vue.createBlock(_component_tool_button, {
2378
- data: item,
2379
- key: index
2380
- }, 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);
2381
2578
  }), 128))
2382
- ], 6);
2383
- }), 128))
2384
- ], 4);
2385
- }
2386
- const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
2579
+ ], 4);
2580
+ };
2581
+ }
2582
+ });
2387
2583
 
2388
- const _sfc_main$d = vue.defineComponent({
2584
+ const _sfc_main$e = vue.defineComponent({
2389
2585
  name: "m-editor-props-panel",
2390
2586
  emits: ["mounted"],
2391
2587
  setup(props, { emit }) {
@@ -2433,10 +2629,10 @@
2433
2629
  }
2434
2630
  });
2435
2631
 
2436
- const _hoisted_1$6 = { class: "`m-editor-props-panel" };
2437
- 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) {
2438
2634
  const _component_m_form = vue.resolveComponent("m-form");
2439
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
2635
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
2440
2636
  vue.renderSlot(_ctx.$slots, "props-panel-header"),
2441
2637
  vue.createVNode(_component_m_form, {
2442
2638
  class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
@@ -2449,11 +2645,11 @@
2449
2645
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
2450
2646
  ]);
2451
2647
  }
2452
- 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]]);
2453
2649
 
2454
- const _sfc_main$c = vue.defineComponent({
2650
+ const _sfc_main$d = vue.defineComponent({
2455
2651
  name: "ui-component-panel",
2456
- components: { MIcon },
2652
+ components: { MIcon: _sfc_main$h },
2457
2653
  setup() {
2458
2654
  const searchText = vue.ref("");
2459
2655
  const services = vue.inject("services");
@@ -2518,9 +2714,9 @@
2518
2714
  }
2519
2715
  });
2520
2716
 
2521
- 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);
2522
2718
  const _hoisted_2$1 = ["onClick", "onDragstart"];
2523
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2719
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2524
2720
  const _component_el_input = vue.resolveComponent("el-input");
2525
2721
  const _component_m_icon = vue.resolveComponent("m-icon");
2526
2722
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -2551,7 +2747,7 @@
2551
2747
  name: index
2552
2748
  }, {
2553
2749
  title: vue.withCtx(() => [
2554
- _hoisted_1$5,
2750
+ _hoisted_1$3,
2555
2751
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
2556
2752
  ]),
2557
2753
  default: vue.withCtx(() => [
@@ -2592,9 +2788,9 @@
2592
2788
  _: 3
2593
2789
  });
2594
2790
  }
2595
- 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]]);
2596
2792
 
2597
- const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
2793
+ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
2598
2794
  __name: "ContentMenu",
2599
2795
  props: {
2600
2796
  menuData: { default: () => [] },
@@ -2683,7 +2879,7 @@
2683
2879
  }, [
2684
2880
  vue.createElementVNode("div", null, [
2685
2881
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
2686
- return vue.openBlock(), vue.createBlock(_sfc_main$f, {
2882
+ return vue.openBlock(), vue.createBlock(_sfc_main$g, {
2687
2883
  "event-type": "mouseup",
2688
2884
  data: item,
2689
2885
  key: index,
@@ -2707,8 +2903,8 @@
2707
2903
  }
2708
2904
  });
2709
2905
 
2710
- const _sfc_main$a = vue.defineComponent({
2711
- components: { ContentMenu: _sfc_main$b },
2906
+ const _sfc_main$b = vue.defineComponent({
2907
+ components: { ContentMenu: _sfc_main$c },
2712
2908
  setup() {
2713
2909
  const services = vue.inject("services");
2714
2910
  const menu = vue.ref();
@@ -2791,7 +2987,7 @@
2791
2987
  }
2792
2988
  });
2793
2989
 
2794
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2990
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
2795
2991
  const _component_content_menu = vue.resolveComponent("content-menu");
2796
2992
  return vue.openBlock(), vue.createBlock(_component_content_menu, {
2797
2993
  "menu-data": _ctx.menuData,
@@ -2799,7 +2995,7 @@
2799
2995
  style: { "overflow": "initial" }
2800
2996
  }, null, 8, ["menu-data"]);
2801
2997
  }
2802
- 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]]);
2803
2999
 
2804
3000
  const throttleTime = 150;
2805
3001
  const select = async (data, editorService) => {
@@ -2926,7 +3122,7 @@
2926
3122
  tree.value?.filter(val);
2927
3123
  }
2928
3124
  });
2929
- const _sfc_main$9 = vue.defineComponent({
3125
+ const _sfc_main$a = vue.defineComponent({
2930
3126
  name: "magic-editor-layer-panel",
2931
3127
  components: { LayerMenu },
2932
3128
  setup() {
@@ -2974,8 +3170,8 @@
2974
3170
  }
2975
3171
  });
2976
3172
 
2977
- const _hoisted_1$4 = ["id", "onMouseenter"];
2978
- 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) {
2979
3175
  const _component_el_input = vue.resolveComponent("el-input");
2980
3176
  const _component_el_tree = vue.resolveComponent("el-tree");
2981
3177
  const _component_layer_menu = vue.resolveComponent("layer-menu");
@@ -3028,7 +3224,7 @@
3028
3224
  }, () => [
3029
3225
  vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
3030
3226
  ])
3031
- ], 42, _hoisted_1$4)
3227
+ ], 42, _hoisted_1$2)
3032
3228
  ]),
3033
3229
  _: 3
3034
3230
  }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : vue.createCommentVNode("", true),
@@ -3039,10 +3235,10 @@
3039
3235
  _: 3
3040
3236
  });
3041
3237
  }
3042
- 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]]);
3043
3239
 
3044
- const _sfc_main$8 = vue.defineComponent({
3045
- components: { MIcon },
3240
+ const _sfc_main$9 = vue.defineComponent({
3241
+ components: { MIcon: _sfc_main$h },
3046
3242
  props: {
3047
3243
  data: {
3048
3244
  type: [Object, String]
@@ -3079,11 +3275,11 @@
3079
3275
  }
3080
3276
  });
3081
3277
 
3082
- const _hoisted_1$3 = {
3278
+ const _hoisted_1$1 = {
3083
3279
  key: 1,
3084
3280
  class: "magic-editor-tab-panel-title"
3085
3281
  };
3086
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3282
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3087
3283
  const _component_m_icon = vue.resolveComponent("m-icon");
3088
3284
  const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
3089
3285
  return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
@@ -3098,7 +3294,7 @@
3098
3294
  key: 0,
3099
3295
  icon: _ctx.config.icon
3100
3296
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
3101
- _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)
3102
3298
  ]))
3103
3299
  ]),
3104
3300
  default: vue.withCtx(() => [
@@ -3129,9 +3325,9 @@
3129
3325
  _: 3
3130
3326
  }, 8, ["name"])) : vue.createCommentVNode("", true);
3131
3327
  }
3132
- 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]]);
3133
3329
 
3134
- const _sfc_main$7 = vue.defineComponent({
3330
+ const _sfc_main$8 = vue.defineComponent({
3135
3331
  components: { TabPane },
3136
3332
  name: "m-sidebar",
3137
3333
  props: {
@@ -3151,7 +3347,7 @@
3151
3347
  }
3152
3348
  });
3153
3349
 
3154
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3350
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3155
3351
  const _component_tab_pane = vue.resolveComponent("tab-pane");
3156
3352
  const _component_el_tabs = vue.resolveComponent("el-tabs");
3157
3353
  return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
@@ -3186,9 +3382,9 @@
3186
3382
  _: 3
3187
3383
  }, 8, ["modelValue"])) : vue.createCommentVNode("", true);
3188
3384
  }
3189
- 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]]);
3190
3386
 
3191
- const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
3387
+ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
3192
3388
  __name: "PageBarScrollContainer",
3193
3389
  setup(__props) {
3194
3390
  const services = vue.inject("services");
@@ -3315,9 +3511,9 @@
3315
3511
  }
3316
3512
  });
3317
3513
 
3318
- const _hoisted_1$2 = ["onClick"];
3514
+ const _hoisted_1 = ["onClick"];
3319
3515
  const _hoisted_2 = { class: "m-editor-page-bar-title" };
3320
- const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
3516
+ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
3321
3517
  __name: "PageBar",
3322
3518
  setup(__props) {
3323
3519
  const services = vue.inject("services");
@@ -3341,7 +3537,7 @@
3341
3537
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
3342
3538
  const _component_el_icon = vue.resolveComponent("el-icon");
3343
3539
  const _component_el_popover = vue.resolveComponent("el-popover");
3344
- return vue.openBlock(), vue.createBlock(_sfc_main$6, null, {
3540
+ return vue.openBlock(), vue.createBlock(_sfc_main$7, null, {
3345
3541
  default: vue.withCtx(() => [
3346
3542
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
3347
3543
  return vue.openBlock(), vue.createElementBlock("div", {
@@ -3380,7 +3576,7 @@
3380
3576
  default: vue.withCtx(() => [
3381
3577
  vue.createElementVNode("div", null, [
3382
3578
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3383
- vue.createVNode(_sfc_main$f, {
3579
+ vue.createVNode(_sfc_main$g, {
3384
3580
  data: {
3385
3581
  type: "button",
3386
3582
  text: "\u590D\u5236",
@@ -3388,7 +3584,7 @@
3388
3584
  handler: () => copy(item)
3389
3585
  }
3390
3586
  }, null, 8, ["data"]),
3391
- vue.createVNode(_sfc_main$f, {
3587
+ vue.createVNode(_sfc_main$g, {
3392
3588
  data: {
3393
3589
  type: "button",
3394
3590
  text: "\u5220\u9664",
@@ -3401,7 +3597,7 @@
3401
3597
  ]),
3402
3598
  _: 2
3403
3599
  }, 1024)
3404
- ], 10, _hoisted_1$2);
3600
+ ], 10, _hoisted_1);
3405
3601
  }), 128))
3406
3602
  ]),
3407
3603
  _: 3
@@ -3410,190 +3606,245 @@
3410
3606
  }
3411
3607
  });
3412
3608
 
3413
- class ScrollViewer$1 {
3414
- enter = false;
3415
- targetEnter = false;
3416
- keydown = false;
3609
+ class ScrollViewer extends events.EventEmitter {
3417
3610
  container;
3418
3611
  target;
3419
3612
  zoom = 1;
3420
3613
  scrollLeft = 0;
3421
3614
  scrollTop = 0;
3422
- x = 0;
3423
- y = 0;
3424
- resizeObserver = new ResizeObserver((entries) => {
3425
- for (const { contentRect } of entries) {
3426
- const { width, height } = contentRect;
3427
- const targetRect = this.target.getBoundingClientRect();
3428
- const targetWidth = targetRect.width * this.zoom;
3429
- const targetMarginTop = Number(this.target.style.marginTop) || 0;
3430
- const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3431
- if (targetWidth < width) {
3432
- this.target._left = 0;
3433
- }
3434
- if (targetHeight < height) {
3435
- this.target._top = 0;
3436
- }
3437
- this.scroll();
3438
- }
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();
3439
3624
  });
3440
3625
  constructor(options) {
3626
+ super();
3441
3627
  this.container = options.container;
3442
3628
  this.target = options.target;
3443
3629
  this.zoom = options.zoom;
3444
- globalThis.addEventListener("keydown", this.keydownHandler);
3445
- globalThis.addEventListener("keyup", this.keyupHandler);
3446
- this.container.addEventListener("mouseenter", this.mouseEnterHandler);
3447
- this.container.addEventListener("mouseleave", this.mouseLeaveHandler);
3448
- this.target.addEventListener("mouseenter", this.targetMouseEnterHandler);
3449
- this.target.addEventListener("mouseleave", this.targetMouseLeaveHandler);
3450
- this.container.addEventListener("wheel", this.wheelHandler);
3630
+ this.container.addEventListener("wheel", this.wheelHandler, false);
3631
+ this.setSize();
3632
+ this.setScrollSize();
3451
3633
  this.resizeObserver.observe(this.container);
3452
3634
  }
3453
3635
  destroy() {
3454
3636
  this.resizeObserver.disconnect();
3455
- this.container.removeEventListener("mouseenter", this.mouseEnterHandler);
3456
- this.container.removeEventListener("mouseleave", this.mouseLeaveHandler);
3457
- this.target.removeEventListener("mouseenter", this.targetMouseEnterHandler);
3458
- this.target.removeEventListener("mouseleave", this.targetMouseLeaveHandler);
3459
- globalThis.removeEventListener("keydown", this.keydownHandler);
3460
- globalThis.removeEventListener("keyup", this.keyupHandler);
3637
+ this.container.removeEventListener("wheel", this.wheelHandler, false);
3638
+ this.removeAllListeners();
3461
3639
  }
3462
3640
  setZoom(zoom) {
3463
3641
  this.zoom = zoom;
3642
+ this.setScrollSize();
3464
3643
  }
3465
- scroll() {
3466
- const scrollLeft = this.target._left;
3467
- const scrollTop = this.target._top;
3468
- this.target.style.transform = `translate(${scrollLeft}px, ${scrollTop}px)`;
3469
- }
3470
- removeHandler() {
3471
- this.target.style.cursor = "";
3472
- this.target.removeEventListener("mousedown", this.mousedownHandler);
3473
- document.removeEventListener("mousemove", this.mousemoveHandler);
3474
- 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)`;
3475
3654
  }
3476
3655
  wheelHandler = (event) => {
3477
- if (this.targetEnter)
3478
- return;
3479
3656
  const { deltaX, deltaY, currentTarget } = event;
3480
3657
  if (currentTarget !== this.container)
3481
3658
  return;
3482
- this.setScrollOffset(deltaX, deltaY);
3483
- this.scroll();
3484
- this.scrollLeft = this.target._left;
3485
- this.scrollTop = this.target._top;
3486
- };
3487
- mouseEnterHandler = () => {
3488
- this.enter = true;
3489
- };
3490
- mouseLeaveHandler = () => {
3491
- this.enter = false;
3492
- };
3493
- targetMouseEnterHandler = () => {
3494
- this.targetEnter = true;
3495
- };
3496
- targetMouseLeaveHandler = () => {
3497
- this.targetEnter = false;
3498
- };
3499
- mousedownHandler = (event) => {
3500
- if (!this.keydown)
3501
- return;
3502
- event.stopImmediatePropagation();
3503
- event.stopPropagation();
3504
- this.target.style.cursor = "grabbing";
3505
- this.x = event.clientX;
3506
- this.y = event.clientY;
3507
- document.addEventListener("mousemove", this.mousemoveHandler);
3508
- document.addEventListener("mouseup", this.mouseupHandler);
3509
- };
3510
- mouseupHandler = () => {
3511
- this.x = 0;
3512
- this.y = 0;
3513
- this.scrollLeft = this.target._left;
3514
- this.scrollTop = this.target._top;
3515
- this.removeHandler();
3516
- };
3517
- mousemoveHandler = (event) => {
3518
- event.stopImmediatePropagation();
3519
- event.stopPropagation();
3520
- const deltaX = event.clientX - this.x;
3521
- const deltaY = event.clientY - this.y;
3522
- this.setScrollOffset(deltaX, deltaY);
3523
- this.scroll();
3524
- };
3525
- keydownHandler = (event) => {
3526
- if (event.code === Keys.ESCAPE && this.enter) {
3527
- event.preventDefault();
3528
- event.stopImmediatePropagation();
3529
- event.stopPropagation();
3659
+ let top;
3660
+ if (this.scrollHeight > this.height) {
3661
+ top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
3530
3662
  }
3531
- if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3532
- return;
3663
+ let left;
3664
+ if (this.scrollWidth > this.width) {
3665
+ left = this.scrollLeft + this.getPos(deltaX, this.scrollLeft, this.scrollWidth, this.width);
3533
3666
  }
3534
- this.keydown = true;
3535
- this.target.style.cursor = "grab";
3536
- 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
+ });
3537
3674
  };
3538
- keyupHandler = (event) => {
3539
- if (event.code !== Keys.ESCAPE || !this.keydown) {
3540
- 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
+ }
3686
+ }
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;
3541
3701
  }
3542
- event.preventDefault();
3543
- event.stopImmediatePropagation();
3544
- event.stopPropagation();
3545
- this.keydown = false;
3546
- event.preventDefault();
3547
- this.removeHandler();
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
+ });
3548
3718
  };
3549
- setScrollOffset(deltaX, deltaY) {
3719
+ setSize = () => {
3550
3720
  const { width, height } = this.container.getBoundingClientRect();
3551
- const targetRect = this.target.getBoundingClientRect();
3552
- const targetWidth = targetRect.width * this.zoom;
3553
- const targetHeight = targetRect.height * this.zoom;
3554
- let y = 0;
3555
- if (targetHeight > height) {
3556
- if (deltaY > 0) {
3557
- y = this.scrollTop + Math.min(targetHeight - height - this.scrollTop, deltaY);
3558
- } else {
3559
- 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();
3560
3770
  }
3561
- }
3562
- let x = 0;
3563
- if (targetWidth > width) {
3564
- if (deltaX > 0) {
3565
- 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
+ }
3566
3784
  } else {
3567
- 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
+ }
3568
3791
  }
3569
- }
3570
- this.target._left = x;
3571
- 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
+ };
3572
3807
  }
3573
- }
3808
+ });
3574
3809
 
3575
- const _sfc_main$4 = vue.defineComponent({
3576
- name: "m-editor-scroll-viewer",
3810
+ const ScrollBar_vue_vue_type_style_index_0_lang = '';
3811
+
3812
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
3813
+ __name: "ScrollViewer",
3577
3814
  props: {
3578
- width: Number,
3579
- height: Number,
3580
- zoom: {
3581
- type: Number,
3582
- default: 1
3583
- }
3815
+ width: { default: 0 },
3816
+ height: { default: 0 },
3817
+ wrapWidth: { default: 0 },
3818
+ wrapHeight: { default: 0 },
3819
+ zoom: { default: 1 }
3584
3820
  },
3585
- setup(props) {
3821
+ setup(__props, { expose }) {
3822
+ const props = __props;
3586
3823
  const container = vue.ref();
3587
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);
3588
3833
  let scrollViewer;
3589
3834
  vue.onMounted(() => {
3590
3835
  if (!container.value || !el.value)
3591
3836
  return;
3592
- scrollViewer = new ScrollViewer$1({
3837
+ scrollViewer = new ScrollViewer({
3593
3838
  container: container.value,
3594
3839
  target: el.value,
3595
3840
  zoom: props.zoom
3596
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
+ });
3597
3848
  });
3598
3849
  vue.onUnmounted(() => {
3599
3850
  scrollViewer.destroy();
@@ -3601,35 +3852,56 @@
3601
3852
  vue.watch(() => props.zoom, () => {
3602
3853
  scrollViewer.setZoom(props.zoom);
3603
3854
  });
3604
- return {
3605
- container,
3606
- el,
3607
- style: vue.computed(() => `
3608
- width: ${props.width}px;
3609
- height: ${props.height}px;
3610
- position: absolute;
3611
- margin-top: 30px;
3612
- `)
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);
3613
3901
  };
3614
3902
  }
3615
3903
  });
3616
3904
 
3617
- const _hoisted_1$1 = {
3618
- class: "m-editor-scroll-viewer-container",
3619
- ref: "container"
3620
- };
3621
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3622
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
3623
- vue.createElementVNode("div", {
3624
- ref: "el",
3625
- style: vue.normalizeStyle(_ctx.style)
3626
- }, [
3627
- vue.renderSlot(_ctx.$slots, "default")
3628
- ], 4)
3629
- ], 512);
3630
- }
3631
- const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
3632
-
3633
3905
  const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
3634
3906
  __name: "ViewerMenu",
3635
3907
  props: {
@@ -3766,7 +4038,7 @@
3766
4038
  };
3767
4039
  expose({ show });
3768
4040
  return (_ctx, _cache) => {
3769
- return vue.openBlock(), vue.createBlock(_sfc_main$b, {
4041
+ return vue.openBlock(), vue.createBlock(_sfc_main$c, {
3770
4042
  "menu-data": menuData,
3771
4043
  ref_key: "menu",
3772
4044
  ref: menu
@@ -3787,12 +4059,11 @@
3787
4059
  const menu = vue.ref();
3788
4060
  const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
3789
4061
  const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
3790
- const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
4062
+ const stageContainerRect = vue.computed(() => services?.uiService.get("stageContainerRect"));
3791
4063
  const root = vue.computed(() => services?.editorService.get("root"));
3792
4064
  const page = vue.computed(() => services?.editorService.get("page"));
3793
4065
  const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
3794
4066
  const node = vue.computed(() => services?.editorService.get("node"));
3795
- const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
3796
4067
  vue.watchEffect(() => {
3797
4068
  if (stage)
3798
4069
  return;
@@ -3800,64 +4071,9 @@
3800
4071
  return;
3801
4072
  if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
3802
4073
  return;
3803
- stage = new StageCore__default.default({
3804
- render: stageOptions.render,
3805
- runtimeUrl: stageOptions.runtimeUrl,
3806
- zoom: zoom.value,
3807
- autoScrollIntoView: stageOptions.autoScrollIntoView,
3808
- isContainer: stageOptions.isContainer,
3809
- containerHighlightClassName: stageOptions.containerHighlightClassName,
3810
- containerHighlightDuration: stageOptions.containerHighlightDuration,
3811
- containerHighlightType: stageOptions.containerHighlightType,
3812
- canSelect: (el, event, stop) => {
3813
- const elCanSelect = stageOptions.canSelect(el);
3814
- if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
3815
- document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
3816
- return stop();
3817
- }
3818
- return elCanSelect;
3819
- },
3820
- moveableOptions: stageOptions.moveableOptions,
3821
- updateDragEl: stageOptions.updateDragEl
3822
- });
4074
+ stage = useStage(stageOptions);
3823
4075
  services?.editorService.set("stage", vue.markRaw(stage));
3824
4076
  stage?.mount(stageContainer.value);
3825
- stage.mask.setGuides([
3826
- getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
3827
- getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
3828
- ]);
3829
- stage?.on("select", (el) => {
3830
- services?.editorService.select(el.id);
3831
- });
3832
- stage?.on("highlight", (el) => {
3833
- services?.editorService.highlight(el.id);
3834
- });
3835
- stage?.on("multiSelect", (els) => {
3836
- services?.editorService.multiSelect(els.map((el) => el.id));
3837
- });
3838
- stage?.on("update", (ev) => {
3839
- if (ev.parentEl) {
3840
- for (const data of ev.data) {
3841
- services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
3842
- }
3843
- return;
3844
- }
3845
- services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
3846
- });
3847
- stage?.on("sort", (ev) => {
3848
- services?.editorService.sort(ev.src, ev.dist);
3849
- });
3850
- stage?.on("changeGuides", (e2) => {
3851
- services?.uiService.set("showGuides", true);
3852
- if (!root.value || !page.value)
3853
- return;
3854
- const storageKey = getGuideLineKey(e2.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY);
3855
- if (e2.guides.length) {
3856
- globalThis.localStorage.setItem(storageKey, JSON.stringify(e2.guides));
3857
- } else {
3858
- globalThis.localStorage.removeItem(storageKey);
3859
- }
3860
- });
3861
4077
  if (!node.value?.id)
3862
4078
  return;
3863
4079
  stage?.on("runtime-ready", (rt) => {
@@ -3943,12 +4159,14 @@
3943
4159
  }
3944
4160
  };
3945
4161
  return (_ctx, _cache) => {
3946
- return vue.openBlock(), vue.createBlock(ScrollViewer, {
4162
+ return vue.openBlock(), vue.createBlock(_sfc_main$4, {
3947
4163
  class: "m-editor-stage",
3948
4164
  ref_key: "stageWrap",
3949
4165
  ref: stageWrap,
3950
4166
  width: vue.unref(stageRect)?.width,
3951
4167
  height: vue.unref(stageRect)?.height,
4168
+ "wrap-width": vue.unref(stageContainerRect)?.width,
4169
+ "wrap-height": vue.unref(stageContainerRect)?.height,
3952
4170
  zoom: vue.unref(zoom)
3953
4171
  }, {
3954
4172
  default: vue.withCtx(() => [
@@ -3956,7 +4174,7 @@
3956
4174
  class: "m-editor-stage-container",
3957
4175
  ref_key: "stageContainer",
3958
4176
  ref: stageContainer,
3959
- style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})`),
4177
+ style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)});`),
3960
4178
  onContextmenu: contextmenuHandler,
3961
4179
  onDrop: dropHandler,
3962
4180
  onDragover: dragoverHandler
@@ -3970,28 +4188,25 @@
3970
4188
  ]))
3971
4189
  ]),
3972
4190
  _: 1
3973
- }, 8, ["width", "height", "zoom"]);
4191
+ }, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
3974
4192
  };
3975
4193
  }
3976
4194
  });
3977
4195
 
3978
- const _sfc_main$1 = vue.defineComponent({
3979
- name: "m-editor-workspace",
3980
- components: {
3981
- PageBar: _sfc_main$5,
3982
- MagicStage: _sfc_main$2
3983
- },
3984
- setup() {
4196
+ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
4197
+ __name: "Workspace",
4198
+ setup(__props) {
3985
4199
  const services = vue.inject("services");
3986
4200
  const workspace = vue.ref();
3987
4201
  const nodes = vue.computed(() => services?.editorService.get("nodes"));
3988
- let keycon;
4202
+ const page = vue.computed(() => services?.editorService.get("page"));
3989
4203
  const mouseenterHandler = () => {
3990
4204
  workspace.value?.focus();
3991
4205
  };
3992
4206
  const mouseleaveHandler = () => {
3993
4207
  workspace.value?.blur();
3994
4208
  };
4209
+ let keycon;
3995
4210
  vue.onMounted(() => {
3996
4211
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3997
4212
  workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
@@ -4068,6 +4283,12 @@
4068
4283
  }).keydown([ctrl, "numpad-"], (e) => {
4069
4284
  e.inputEvent.preventDefault();
4070
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);
4071
4292
  });
4072
4293
  });
4073
4294
  vue.onUnmounted(() => {
@@ -4075,41 +4296,33 @@
4075
4296
  workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
4076
4297
  keycon.destroy();
4077
4298
  });
4078
- return {
4079
- workspace,
4080
- 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);
4081
4322
  };
4082
4323
  }
4083
4324
  });
4084
4325
 
4085
- const _hoisted_1 = {
4086
- class: "m-editor-workspace",
4087
- tabindex: "1",
4088
- ref: "workspace"
4089
- };
4090
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4091
- const _component_magic_stage = vue.resolveComponent("magic-stage");
4092
- const _component_page_bar = vue.resolveComponent("page-bar");
4093
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
4094
- vue.renderSlot(_ctx.$slots, "stage", {}, () => [
4095
- (vue.openBlock(), vue.createBlock(_component_magic_stage, {
4096
- key: _ctx.page?.id
4097
- }))
4098
- ]),
4099
- vue.renderSlot(_ctx.$slots, "workspace-content"),
4100
- vue.createVNode(_component_page_bar, null, {
4101
- "page-bar-title": vue.withCtx(({ page }) => [
4102
- vue.renderSlot(_ctx.$slots, "page-bar-title", { page })
4103
- ]),
4104
- "page-bar-popover": vue.withCtx(({ page }) => [
4105
- vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
4106
- ]),
4107
- _: 3
4108
- })
4109
- ], 512);
4110
- }
4111
- const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4112
-
4113
4326
  class ComponentList extends BaseService {
4114
4327
  state = vue.reactive({
4115
4328
  list: []
@@ -4126,132 +4339,12 @@
4126
4339
  }
4127
4340
  const componentListService = new ComponentList();
4128
4341
 
4129
- const DEFAULT_LEFT_COLUMN_WIDTH = 310;
4130
- const MIN_LEFT_COLUMN_WIDTH = 45;
4131
- const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
4132
- const MIN_RIGHT_COLUMN_WIDTH = 1;
4133
- const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
4134
- const defaultColumnWidth = {
4135
- left: DEFAULT_LEFT_COLUMN_WIDTH,
4136
- center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
4137
- right: DEFAULT_RIGHT_COLUMN_WIDTH
4138
- };
4139
- const state = vue.reactive({
4140
- uiSelectMode: false,
4141
- showSrc: false,
4142
- zoom: 1,
4143
- stageContainerRect: {
4144
- width: 0,
4145
- height: 0
4146
- },
4147
- stageRect: {
4148
- width: 375,
4149
- height: 817
4150
- },
4151
- columnWidth: defaultColumnWidth,
4152
- showGuides: true,
4153
- showRule: true,
4154
- propsPanelSize: "small"
4155
- });
4156
- class Ui extends BaseService {
4157
- constructor() {
4158
- super([]);
4159
- globalThis.addEventListener("resize", () => {
4160
- this.setColumnWidth({
4161
- center: "auto"
4162
- });
4163
- });
4164
- const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
4165
- if (columnWidthCacheData) {
4166
- try {
4167
- const columnWidthCache = JSON.parse(columnWidthCacheData);
4168
- this.setColumnWidth(columnWidthCache);
4169
- } catch (e) {
4170
- console.error(e);
4171
- }
4172
- }
4173
- }
4174
- set(name, value) {
4175
- const mask = editorService.get("stage")?.mask;
4176
- if (name === "columnWidth") {
4177
- this.setColumnWidth(value);
4178
- return;
4179
- }
4180
- if (name === "stageRect") {
4181
- this.setStageRect(value);
4182
- return;
4183
- }
4184
- if (name === "showGuides") {
4185
- mask?.showGuides(value);
4186
- }
4187
- if (name === "showRule") {
4188
- mask?.showRule(value);
4189
- }
4190
- state[name] = value;
4191
- if (name === "stageContainerRect") {
4192
- state.zoom = this.calcZoom();
4193
- }
4194
- }
4195
- get(name) {
4196
- return state[name];
4197
- }
4198
- zoom(zoom) {
4199
- this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
4200
- if (this.get("zoom") < 0.1)
4201
- this.set("zoom", 0.1);
4202
- }
4203
- setColumnWidth({ left, center, right }) {
4204
- const columnWidth = {
4205
- ...vue.toRaw(this.get("columnWidth"))
4206
- };
4207
- if (left) {
4208
- columnWidth.left = Math.max(left, MIN_LEFT_COLUMN_WIDTH);
4209
- }
4210
- if (right) {
4211
- columnWidth.right = Math.max(right, MIN_RIGHT_COLUMN_WIDTH);
4212
- }
4213
- if (!center || center === "auto") {
4214
- const bodyWidth = globalThis.document.body.clientWidth;
4215
- columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
4216
- if (columnWidth.center <= 0) {
4217
- columnWidth.left = defaultColumnWidth.left;
4218
- columnWidth.center = defaultColumnWidth.center;
4219
- columnWidth.right = defaultColumnWidth.right;
4220
- }
4221
- } else {
4222
- columnWidth.center = center;
4223
- }
4224
- globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
4225
- state.columnWidth = columnWidth;
4226
- }
4227
- setStageRect(value) {
4228
- state.stageRect = {
4229
- ...state.stageRect,
4230
- ...value
4231
- };
4232
- state.zoom = this.calcZoom();
4233
- }
4234
- calcZoom() {
4235
- const { stageRect, stageContainerRect } = state;
4236
- const { height, width } = stageContainerRect;
4237
- if (!width || !height)
4238
- return 1;
4239
- const stageWidth = stageRect.width + 30;
4240
- const stageHeight = stageRect.height + 30;
4241
- if (width > stageWidth && height > stageHeight) {
4242
- return 1;
4243
- }
4244
- return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
4245
- }
4246
- }
4247
- const uiService = new Ui();
4248
-
4249
4342
  const _sfc_main = vue.defineComponent({
4250
4343
  name: "m-editor",
4251
4344
  components: {
4252
- NavMenu,
4345
+ NavMenu: _sfc_main$f,
4253
4346
  Sidebar,
4254
- Workspace,
4347
+ Workspace: _sfc_main$1,
4255
4348
  PropsPanel,
4256
4349
  Framework
4257
4350
  },
@@ -4474,7 +4567,7 @@
4474
4567
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4475
4568
  setConfig(option);
4476
4569
  app.component(Editor.name, Editor);
4477
- app.component("m-fields-ui-select", _sfc_main$l);
4570
+ app.component("m-fields-ui-select", _sfc_main$m);
4478
4571
  app.component(CodeLink.name, CodeLink);
4479
4572
  app.component(Code.name, Code);
4480
4573
  app.component(CodeEditor.name, CodeEditor);
@@ -4482,9 +4575,12 @@
4482
4575
  };
4483
4576
 
4484
4577
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
4578
+ exports.ColumnLayout = ColumnLayout;
4485
4579
  exports.ComponentListPanel = ComponentListPanel;
4580
+ exports.ContentMenu = _sfc_main$c;
4486
4581
  exports.Fixed2Other = Fixed2Other;
4487
4582
  exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
4583
+ exports.Icon = _sfc_main$h;
4488
4584
  exports.Keys = Keys;
4489
4585
  exports.LayerOffset = LayerOffset;
4490
4586
  exports.LayerPanel = LayerPanel;
@@ -4492,7 +4588,7 @@
4492
4588
  exports.PropsPanel = PropsPanel;
4493
4589
  exports.TMagicCodeEditor = CodeEditor;
4494
4590
  exports.TMagicEditor = Editor;
4495
- exports.ToolButton = _sfc_main$f;
4591
+ exports.ToolButton = _sfc_main$g;
4496
4592
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
4497
4593
  exports.change2Fixed = change2Fixed;
4498
4594
  exports.debug = debug;
@@ -4521,6 +4617,7 @@
4521
4617
  exports.setLayout = setLayout;
4522
4618
  exports.storageService = storageService;
4523
4619
  exports.uiService = uiService;
4620
+ exports.useStage = useStage;
4524
4621
  exports.warn = warn;
4525
4622
 
4526
4623
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });