@tmagic/editor 1.1.0-beta.4 → 1.1.0-beta.7

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 (100) hide show
  1. package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1361 -1144
  2. package/dist/tmagic-editor.mjs.map +1 -0
  3. package/dist/tmagic-editor.umd.js +1375 -1158
  4. package/dist/tmagic-editor.umd.js.map +1 -1
  5. package/package.json +21 -19
  6. package/src/Editor.vue +14 -12
  7. package/src/components/ContentMenu.vue +87 -99
  8. package/src/components/ScrollViewer.vue +1 -1
  9. package/src/components/ToolButton.vue +150 -167
  10. package/src/fields/UISelect.vue +49 -70
  11. package/src/index.ts +2 -1
  12. package/src/layouts/AddPageBox.vue +2 -2
  13. package/src/layouts/Framework.vue +1 -1
  14. package/src/layouts/NavMenu.vue +2 -2
  15. package/src/layouts/PropsPanel.vue +1 -1
  16. package/src/layouts/Resizer.vue +1 -1
  17. package/src/layouts/sidebar/ComponentListPanel.vue +2 -2
  18. package/src/layouts/sidebar/LayerMenu.vue +2 -2
  19. package/src/layouts/sidebar/LayerPanel.vue +13 -4
  20. package/src/layouts/sidebar/Sidebar.vue +1 -1
  21. package/src/layouts/sidebar/TabPane.vue +2 -2
  22. package/src/layouts/workspace/PageBar.vue +63 -192
  23. package/src/layouts/workspace/PageBarScrollContainer.vue +111 -0
  24. package/src/layouts/workspace/Stage.vue +195 -222
  25. package/src/layouts/workspace/ViewerMenu.vue +142 -146
  26. package/src/layouts/workspace/Workspace.vue +11 -11
  27. package/src/services/BaseService.ts +1 -1
  28. package/src/services/componentList.ts +3 -3
  29. package/src/services/editor.ts +117 -135
  30. package/src/services/events.ts +1 -1
  31. package/src/services/history.ts +1 -1
  32. package/src/services/props.ts +62 -10
  33. package/src/services/storage.ts +133 -0
  34. package/src/services/ui.ts +2 -2
  35. package/src/type.ts +22 -6
  36. package/src/utils/config.ts +1 -1
  37. package/src/utils/editor.ts +1 -1
  38. package/src/utils/operator.ts +210 -0
  39. package/src/utils/props.ts +2 -24
  40. package/src/utils/scroll-viewer.ts +1 -1
  41. package/tsconfig.build.json +13 -0
  42. package/{dist/types/src → types}/Editor.vue.d.ts +7 -8
  43. package/types/components/ContentMenu.vue.d.ts +116 -0
  44. package/types/components/Icon.vue.d.ts +13 -0
  45. package/types/components/ScrollViewer.vue.d.ts +22 -0
  46. package/types/components/ToolButton.vue.d.ts +109 -0
  47. package/types/fields/Code.vue.d.ts +23 -0
  48. package/{dist/types/src → types}/fields/CodeLink.vue.d.ts +4 -6
  49. package/types/fields/UISelect.vue.d.ts +83 -0
  50. package/{dist/types/src → types}/index.d.ts +4 -1
  51. package/types/layouts/AddPageBox.vue.d.ts +4 -0
  52. package/{dist/types/src → types}/layouts/CodeEditor.vue.d.ts +11 -13
  53. package/types/layouts/Framework.vue.d.ts +22 -0
  54. package/types/layouts/NavMenu.vue.d.ts +25 -0
  55. package/types/layouts/PropsPanel.vue.d.ts +245 -0
  56. package/types/layouts/Resizer.vue.d.ts +12 -0
  57. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +14 -0
  58. package/types/layouts/sidebar/LayerMenu.vue.d.ts +100 -0
  59. package/types/layouts/sidebar/LayerPanel.vue.d.ts +1099 -0
  60. package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
  61. package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
  62. package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
  63. package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +48 -0
  64. package/types/layouts/workspace/Stage.vue.d.ts +46 -0
  65. package/types/layouts/workspace/ViewerMenu.vue.d.ts +88 -0
  66. package/types/layouts/workspace/Workspace.vue.d.ts +6 -0
  67. package/{dist/types/src → types}/services/BaseService.d.ts +0 -0
  68. package/types/services/componentList.d.ts +14 -0
  69. package/{dist/types/src → types}/services/editor.d.ts +26 -11
  70. package/{dist/types/src → types}/services/events.d.ts +0 -0
  71. package/{dist/types/src → types}/services/history.d.ts +0 -0
  72. package/{dist/types/src → types}/services/props.d.ts +25 -1
  73. package/types/services/storage.d.ts +56 -0
  74. package/{dist/types/src → types}/services/ui.d.ts +1 -1
  75. package/{dist/types/src → types}/type.d.ts +15 -0
  76. package/{dist/types/src → types}/utils/compose.d.ts +1 -1
  77. package/{dist/types/src → types}/utils/config.d.ts +0 -0
  78. package/{dist/types/src → types}/utils/editor.d.ts +2 -2
  79. package/{dist/types/src → types}/utils/index.d.ts +0 -0
  80. package/{dist/types/src → types}/utils/logger.d.ts +0 -0
  81. package/types/utils/operator.d.ts +44 -0
  82. package/{dist/types/src → types}/utils/polyfills.d.ts +0 -0
  83. package/{dist/types/src → types}/utils/props.d.ts +2 -22
  84. package/{dist/types/src → types}/utils/scroll-viewer.d.ts +0 -0
  85. package/{dist/types/src → types}/utils/undo-redo.d.ts +0 -0
  86. package/dist/tmagic-editor.es.js.map +0 -1
  87. package/dist/types/src/components/Icon.vue.d.ts +0 -14
  88. package/dist/types/src/components/ScrollViewer.vue.d.ts +0 -24
  89. package/dist/types/src/fields/Code.vue.d.ts +0 -25
  90. package/dist/types/src/layouts/AddPageBox.vue.d.ts +0 -5
  91. package/dist/types/src/layouts/Framework.vue.d.ts +0 -24
  92. package/dist/types/src/layouts/NavMenu.vue.d.ts +0 -27
  93. package/dist/types/src/layouts/PropsPanel.vue.d.ts +0 -13
  94. package/dist/types/src/layouts/Resizer.vue.d.ts +0 -14
  95. package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -16
  96. package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +0 -16
  97. package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +0 -8
  98. package/dist/types/src/shims-vue.d.ts +0 -6
  99. package/dist/types/src/vite-env.d.ts +0 -1
  100. package/src/vite-env.d.ts +0 -1
@@ -1,11 +1,11 @@
1
- import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, ref, watchEffect, inject, markRaw, createElementBlock, createVNode, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, watch, onMounted, onUnmounted, reactive, toRaw, createElementVNode, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, renderList, normalizeProps, mergeProps, getCurrentInstance, nextTick, Teleport, 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, markRaw, renderList, normalizeProps, mergeProps, getCurrentInstance, Teleport, nextTick, toHandlers, createSlots, provide } from 'vue';
2
2
  import serialize from 'serialize-javascript';
3
- import { Delete, Pointer, Close, Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Files, DocumentCopy, Coin, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
4
- import { throttle, cloneDeep, mergeWith, random } from 'lodash-es';
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';
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 } from '@tmagic/stage';
7
7
  import { NodeType } from '@tmagic/schema';
8
- import { toLine, isPop, getNodePath, isNumber, isPage, removeClassNameByClassName } from '@tmagic/utils';
8
+ import { isPop, getNodePath, isNumber, isPage, toLine, removeClassNameByClassName } from '@tmagic/utils';
9
9
  import { EventEmitter } from 'events';
10
10
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
11
11
  import Gesto from 'gesto';
@@ -19,15 +19,7 @@ if (typeof globalThis === "undefined") {
19
19
  window.globalThis = window;
20
20
  }
21
21
 
22
- var _export_sfc = (sfc, props) => {
23
- const target = sfc.__vccOpts || sfc;
24
- for (const [key, val] of props) {
25
- target[key] = val;
26
- }
27
- return target;
28
- };
29
-
30
- const _sfc_main$m = defineComponent({
22
+ const _sfc_main$n = defineComponent({
31
23
  name: "m-fields-vs-code",
32
24
  props: ["model", "name", "config", "prop"],
33
25
  emits: ["change"],
@@ -44,7 +36,16 @@ const _sfc_main$m = defineComponent({
44
36
  };
45
37
  }
46
38
  });
47
- function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
39
+
40
+ const _export_sfc = (sfc, props) => {
41
+ const target = sfc.__vccOpts || sfc;
42
+ for (const [key, val] of props) {
43
+ target[key] = val;
44
+ }
45
+ return target;
46
+ };
47
+
48
+ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
48
49
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
49
50
  return openBlock(), createBlock(_component_magic_code_editor, {
50
51
  style: normalizeStyle(`height: ${_ctx.height}`),
@@ -53,9 +54,9 @@ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
53
54
  onSave: _ctx.save
54
55
  }, null, 8, ["style", "init-values", "language", "onSave"]);
55
56
  }
56
- var Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$m]]);
57
+ const Code = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$g]]);
57
58
 
58
- const _sfc_main$l = defineComponent({
59
+ const _sfc_main$m = defineComponent({
59
60
  name: "m-fields-code-link",
60
61
  props: {
61
62
  config: {
@@ -110,7 +111,8 @@ const _sfc_main$l = defineComponent({
110
111
  };
111
112
  }
112
113
  });
113
- function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
114
+
115
+ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
114
116
  const _component_m_fields_link = resolveComponent("m-fields-link");
115
117
  return openBlock(), createBlock(_component_m_fields_link, {
116
118
  config: _ctx.formConfig,
@@ -119,26 +121,20 @@ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
119
121
  onChange: _ctx.changeHandler
120
122
  }, null, 8, ["config", "model", "onChange"]);
121
123
  }
122
- var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
124
+ const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
123
125
 
124
- var UISelect_vue_vue_type_style_index_0_lang = /* #__PURE__ */ (() => ".m-fields-ui-select {\n cursor: pointer;\n}\n.m-fields-ui-select i {\n margin-right: 3px;\n}\n.m-fields-ui-select span {\n color: #2882e0;\n}")();
125
-
126
- const _sfc_main$k = defineComponent({
127
- name: "m-fields-ui-select",
126
+ const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
127
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
128
+ __name: "UISelect",
128
129
  props: {
129
- labelWidth: String,
130
- config: Object,
131
- model: Object,
132
- prop: {
133
- type: String,
134
- default() {
135
- return "";
136
- }
137
- },
138
- name: String
130
+ config: null,
131
+ model: null,
132
+ prop: null,
133
+ name: null
139
134
  },
140
135
  emits: ["change"],
141
- setup(props, { emit }) {
136
+ setup(__props, { emit }) {
137
+ const props = __props;
142
138
  const services = inject("services");
143
139
  const mForm = inject("mForm");
144
140
  const val = computed(() => props.model[props.name]);
@@ -160,92 +156,84 @@ const _sfc_main$k = defineComponent({
160
156
  cancelHandler();
161
157
  }
162
158
  };
163
- return {
164
- Delete: markRaw(Delete),
165
- Pointer: markRaw(Pointer),
166
- Close: markRaw(Close),
167
- val,
168
- uiSelectMode,
169
- toName: computed(() => {
170
- const config = services?.editorService.getNodeById(val.value);
171
- return config?.name || "";
172
- }),
173
- startSelect() {
174
- if (!services?.uiService)
175
- return;
176
- services.uiService.set("uiSelectMode", true);
177
- uiSelectMode.value = true;
178
- globalThis.document.addEventListener("ui-select", clickHandler);
179
- },
180
- cancelHandler,
181
- deleteHandler() {
182
- if (props.model) {
183
- props.model[props.name] = "";
184
- emit("change", "");
185
- mForm?.$emit("field-change", props.prop, "");
186
- }
159
+ const toName = computed(() => {
160
+ const config = services?.editorService.getNodeById(val.value);
161
+ return config?.name || "";
162
+ });
163
+ const startSelect = () => {
164
+ if (!services?.uiService)
165
+ return;
166
+ services.uiService.set("uiSelectMode", true);
167
+ uiSelectMode.value = true;
168
+ globalThis.document.addEventListener("ui-select", clickHandler);
169
+ };
170
+ const deleteHandler = () => {
171
+ if (props.model) {
172
+ props.model[props.name] = "";
173
+ emit("change", "");
174
+ mForm?.$emit("field-change", props.prop, "");
187
175
  }
188
176
  };
189
- }
190
- });
191
- const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
192
- function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
193
- const _component_el_button = resolveComponent("el-button");
194
- const _component_el_tooltip = resolveComponent("el-tooltip");
195
- return _ctx.uiSelectMode ? (openBlock(), createElementBlock("div", {
196
- key: 0,
197
- class: "m-fields-ui-select",
198
- onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
199
- }, [
200
- createVNode(_component_el_button, {
201
- type: "danger",
202
- icon: _ctx.Delete,
203
- text: "",
204
- style: { "padding": "0" }
205
- }, {
206
- default: withCtx(() => [
207
- _hoisted_1$d
208
- ]),
209
- _: 1
210
- }, 8, ["icon"])
211
- ])) : (openBlock(), createElementBlock("div", {
212
- key: 1,
213
- class: "m-fields-ui-select",
214
- onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
215
- style: { "display": "flex" }
216
- }, [
217
- createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
218
- default: withCtx(() => [
219
- _ctx.val ? (openBlock(), createBlock(_component_el_button, {
220
- key: 0,
221
- style: { "padding": "0" },
222
- type: "danger",
223
- icon: _ctx.Close,
224
- text: "",
225
- onClick: withModifiers(_ctx.deleteHandler, ["stop"])
226
- }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
227
- ]),
228
- _: 1
229
- }),
230
- createVNode(_component_el_tooltip, {
231
- content: _ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
232
- }, {
233
- default: withCtx(() => [
177
+ return (_ctx, _cache) => {
178
+ const _component_el_button = resolveComponent("el-button");
179
+ const _component_el_tooltip = resolveComponent("el-tooltip");
180
+ return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
181
+ key: 0,
182
+ class: "m-fields-ui-select",
183
+ onClick: cancelHandler
184
+ }, [
234
185
  createVNode(_component_el_button, {
186
+ type: "danger",
187
+ icon: unref(Delete),
235
188
  text: "",
236
- style: { "padding": "0", "margin": "0" }
189
+ style: { "padding": "0" }
237
190
  }, {
238
191
  default: withCtx(() => [
239
- createTextVNode(toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
192
+ _hoisted_1$d
240
193
  ]),
241
194
  _: 1
242
- })
243
- ]),
244
- _: 1
245
- }, 8, ["content"])
246
- ]));
247
- }
248
- var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
195
+ }, 8, ["icon"])
196
+ ])) : (openBlock(), createElementBlock("div", {
197
+ key: 1,
198
+ class: "m-fields-ui-select",
199
+ onClick: startSelect,
200
+ style: { "display": "flex" }
201
+ }, [
202
+ createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
203
+ default: withCtx(() => [
204
+ unref(val) ? (openBlock(), createBlock(_component_el_button, {
205
+ key: 0,
206
+ style: { "padding": "0" },
207
+ type: "danger",
208
+ icon: unref(Close),
209
+ text: "",
210
+ onClick: withModifiers(deleteHandler, ["stop"])
211
+ }, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
212
+ ]),
213
+ _: 1
214
+ }),
215
+ createVNode(_component_el_tooltip, {
216
+ content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
217
+ }, {
218
+ default: withCtx(() => [
219
+ createVNode(_component_el_button, {
220
+ text: "",
221
+ style: { "padding": "0", "margin": "0" }
222
+ }, {
223
+ default: withCtx(() => [
224
+ createTextVNode(toDisplayString(unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
225
+ ]),
226
+ _: 1
227
+ })
228
+ ]),
229
+ _: 1
230
+ }, 8, ["content"])
231
+ ]));
232
+ };
233
+ }
234
+ });
235
+
236
+ const UISelect_vue_vue_type_style_index_0_lang = '';
249
237
 
250
238
  const toString = (v, language) => {
251
239
  let value = "";
@@ -262,7 +250,7 @@ const toString = (v, language) => {
262
250
  }
263
251
  return value;
264
252
  };
265
- const _sfc_main$j = defineComponent({
253
+ const _sfc_main$k = defineComponent({
266
254
  name: "magic-code-editor",
267
255
  props: {
268
256
  initValues: {
@@ -369,14 +357,15 @@ const _sfc_main$j = defineComponent({
369
357
  };
370
358
  }
371
359
  });
360
+
372
361
  const _hoisted_1$c = {
373
362
  ref: "codeEditor",
374
363
  class: "magic-code-editor"
375
364
  };
376
- function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
365
+ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
377
366
  return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
378
367
  }
379
- var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
368
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
380
369
 
381
370
  let $TMAGIC_EDITOR = {};
382
371
  const setConfig = (option) => {
@@ -385,6 +374,9 @@ const setConfig = (option) => {
385
374
  const getConfig = (key) => $TMAGIC_EDITOR[key];
386
375
 
387
376
  class UndoRedo {
377
+ elementList;
378
+ listCursor;
379
+ listMaxSize;
388
380
  constructor(listMaxSize = 200) {
389
381
  const minListMaxSize = 2;
390
382
  this.elementList = [];
@@ -480,12 +472,12 @@ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethod
480
472
  }
481
473
  };
482
474
  class BaseService extends EventEmitter {
475
+ pluginOptionsList = {};
476
+ middleware = {};
477
+ taskList = [];
478
+ doingTask = false;
483
479
  constructor(methods = [], serialMethods = []) {
484
480
  super();
485
- this.pluginOptionsList = {};
486
- this.middleware = {};
487
- this.taskList = [];
488
- this.doingTask = false;
489
481
  methods.forEach((propertyName) => {
490
482
  const scope = this;
491
483
  const sourceMethod = scope[propertyName];
@@ -542,14 +534,14 @@ class BaseService extends EventEmitter {
542
534
  }
543
535
 
544
536
  class History extends BaseService {
537
+ state = reactive({
538
+ pageSteps: {},
539
+ pageId: void 0,
540
+ canRedo: false,
541
+ canUndo: false
542
+ });
545
543
  constructor() {
546
544
  super([]);
547
- this.state = reactive({
548
- pageSteps: {},
549
- pageId: void 0,
550
- canRedo: false,
551
- canUndo: false
552
- });
553
545
  this.on("change", this.setCanUndoRedo);
554
546
  }
555
547
  reset() {
@@ -618,88 +610,88 @@ class History extends BaseService {
618
610
  this.state.canUndo = undoRedo?.canUndo() || false;
619
611
  }
620
612
  }
621
- var historyService = new History();
613
+ const historyService = new History();
622
614
 
623
- class Props extends BaseService {
615
+ var Protocol = /* @__PURE__ */ ((Protocol2) => {
616
+ Protocol2["OBJECT"] = "object";
617
+ Protocol2["JSON"] = "json";
618
+ Protocol2["STRING"] = "string";
619
+ Protocol2["NUMBER"] = "number";
620
+ Protocol2["BOOLEAN"] = "boolean";
621
+ return Protocol2;
622
+ })(Protocol || {});
623
+ class WebStorage extends BaseService {
624
+ storage = globalThis.localStorage;
625
+ namespace = "tmagic";
624
626
  constructor() {
625
- super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "createId", "setNewItemId"]);
626
- this.state = reactive({
627
- propsConfigMap: {},
628
- propsValueMap: {}
629
- });
627
+ super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
630
628
  }
631
- setPropsConfigs(configs) {
632
- Object.keys(configs).forEach((type) => {
633
- this.setPropsConfig(toLine(type), configs[type]);
634
- });
635
- this.emit("props-configs-change");
629
+ async getStorage() {
630
+ return this.storage;
636
631
  }
637
- setPropsConfig(type, config) {
638
- this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
632
+ async getNamespace() {
633
+ return this.namespace;
639
634
  }
640
- async getPropsConfig(type) {
641
- if (type === "area") {
642
- return await this.getPropsConfig("button");
635
+ async clear() {
636
+ const storage2 = await this.getStorage();
637
+ storage2.clear();
638
+ }
639
+ async getItem(key, options = {}) {
640
+ const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
641
+ const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
642
+ if (item === null)
643
+ return null;
644
+ switch (protocol) {
645
+ case "object" /* OBJECT */:
646
+ return eval(`(${item})`);
647
+ case "json" /* JSON */:
648
+ return JSON.parse(item);
649
+ case "number" /* NUMBER */:
650
+ return Number(item);
651
+ case "boolean" /* BOOLEAN */:
652
+ return Boolean(item);
653
+ default:
654
+ return item;
643
655
  }
644
- return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
645
656
  }
646
- setPropsValues(values) {
647
- Object.keys(values).forEach((type) => {
648
- this.setPropsValue(toLine(type), values[type]);
649
- });
657
+ async key(index) {
658
+ const storage2 = await this.getStorage();
659
+ return storage2.key(index);
650
660
  }
651
- setPropsValue(type, value) {
652
- this.state.propsValueMap[type] = value;
661
+ async removeItem(key2, options2 = {}) {
662
+ const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
663
+ storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
653
664
  }
654
- async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
655
- if (type === "area") {
656
- const value = await this.getPropsValue("button");
657
- value.className = "action-area";
658
- value.text = "";
659
- if (value.style) {
660
- value.style.backgroundColor = "rgba(255, 255, 255, 0)";
661
- }
662
- return value;
665
+ async setItem(key2, value, options2 = {}) {
666
+ const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
667
+ let item2 = value;
668
+ const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
669
+ if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
670
+ item2 = `${protocol2}${value}`;
671
+ } else {
672
+ item2 = `${protocol2}${serialize(value)}`;
663
673
  }
664
- const data = cloneDeep(defaultValue);
665
- await this.setNewItemId(data);
674
+ storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
675
+ }
676
+ getValueAndProtocol(value) {
677
+ let protocol2 = "";
678
+ if (value === null) {
679
+ return {
680
+ item: value,
681
+ protocol: protocol2
682
+ };
683
+ }
684
+ const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
685
+ protocol2 = $1;
686
+ return $3;
687
+ });
666
688
  return {
667
- ...getDefaultPropsValue(type, await this.createId(type)),
668
- ...mergeWith(cloneDeep(this.state.propsValueMap[type] || {}), data)
689
+ protocol: protocol2,
690
+ item: item2
669
691
  };
670
692
  }
671
- async createId(type) {
672
- return `${type}_${random(1e4, false)}`;
673
- }
674
- async setNewItemId(config, parent) {
675
- const oldId = config.id;
676
- config.id = await this.createId(config.type || "component");
677
- if (isPop(config) && parent?.type === NodeType.PAGE) {
678
- updatePopId(oldId, config.id, parent);
679
- }
680
- if (config.items && Array.isArray(config.items)) {
681
- for (const item of config.items) {
682
- await this.setNewItemId(item, config);
683
- }
684
- }
685
- }
686
693
  }
687
- const updatePopId = (oldId, popId, pageConfig) => {
688
- pageConfig.items?.forEach((config) => {
689
- if (config.pop === oldId) {
690
- config.pop = popId;
691
- return;
692
- }
693
- if (config.popId === oldId) {
694
- config.popId = popId;
695
- return;
696
- }
697
- if (Array.isArray(config.items)) {
698
- updatePopId(oldId, popId, config);
699
- }
700
- });
701
- };
702
- var propsService = new Props();
694
+ const storageService = new WebStorage();
703
695
 
704
696
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
705
697
  LayerOffset2["TOP"] = "top";
@@ -863,7 +855,266 @@ const fixNodeLeft = (config, parent, doc) => {
863
855
  return config.style.left;
864
856
  };
865
857
 
858
+ class Props extends BaseService {
859
+ state = reactive({
860
+ propsConfigMap: {},
861
+ propsValueMap: {}
862
+ });
863
+ constructor() {
864
+ super([
865
+ "setPropsConfig",
866
+ "getPropsConfig",
867
+ "setPropsValue",
868
+ "getPropsValue",
869
+ "createId",
870
+ "setNewItemId",
871
+ "getDefaultPropsValue"
872
+ ]);
873
+ }
874
+ setPropsConfigs(configs) {
875
+ Object.keys(configs).forEach((type) => {
876
+ this.setPropsConfig(toLine(type), configs[type]);
877
+ });
878
+ this.emit("props-configs-change");
879
+ }
880
+ setPropsConfig(type, config) {
881
+ this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
882
+ }
883
+ async getPropsConfig(type) {
884
+ if (type === "area") {
885
+ return await this.getPropsConfig("button");
886
+ }
887
+ return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
888
+ }
889
+ setPropsValues(values) {
890
+ Object.keys(values).forEach((type) => {
891
+ this.setPropsValue(toLine(type), values[type]);
892
+ });
893
+ }
894
+ setPropsValue(type, value) {
895
+ this.state.propsValueMap[type] = value;
896
+ }
897
+ async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
898
+ if (type === "area") {
899
+ const value = await this.getPropsValue("button");
900
+ value.className = "action-area";
901
+ value.text = "";
902
+ if (value.style) {
903
+ value.style.backgroundColor = "rgba(255, 255, 255, 0)";
904
+ }
905
+ return value;
906
+ }
907
+ const [id, defaultPropsValue, data] = await Promise.all([
908
+ this.createId(type),
909
+ this.getDefaultPropsValue(type),
910
+ this.setNewItemId(cloneDeep({
911
+ type,
912
+ ...defaultValue
913
+ }))
914
+ ]);
915
+ return {
916
+ id,
917
+ ...defaultPropsValue,
918
+ ...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
919
+ };
920
+ }
921
+ guid(digit = 8) {
922
+ return "x".repeat(digit).replace(/[xy]/g, (c) => {
923
+ const r = Math.random() * 16 | 0;
924
+ const v = c == "x" ? r : r & 3 | 8;
925
+ return v.toString(16);
926
+ });
927
+ }
928
+ async createId(type) {
929
+ return `${type}_${this.guid()}`;
930
+ }
931
+ async setNewItemId(config, parent) {
932
+ const oldId = config.id;
933
+ config.id = await this.createId(config.type || "component");
934
+ if (isPop(config) && parent?.type === NodeType.PAGE) {
935
+ updatePopId(oldId, config.id, parent);
936
+ }
937
+ if (config.items && Array.isArray(config.items)) {
938
+ for (const item of config.items) {
939
+ await this.setNewItemId(item, config);
940
+ }
941
+ }
942
+ return config;
943
+ }
944
+ async getDefaultPropsValue(type) {
945
+ return ["page", "container"].includes(type) ? {
946
+ type,
947
+ layout: "absolute",
948
+ style: {},
949
+ name: type,
950
+ items: []
951
+ } : {
952
+ type,
953
+ style: {},
954
+ name: type
955
+ };
956
+ }
957
+ }
958
+ const updatePopId = (oldId, popId, pageConfig) => {
959
+ pageConfig.items?.forEach((config) => {
960
+ if (config.pop === oldId) {
961
+ config.pop = popId;
962
+ return;
963
+ }
964
+ if (config.popId === oldId) {
965
+ config.popId = popId;
966
+ return;
967
+ }
968
+ if (Array.isArray(config.items)) {
969
+ updatePopId(oldId, popId, config);
970
+ }
971
+ });
972
+ };
973
+ const propsService = new Props();
974
+
975
+ const beforePaste = async (position, config) => {
976
+ if (!config[0]?.style)
977
+ return config;
978
+ const curNode = editorService.get("node");
979
+ const { left: referenceLeft, top: referenceTop } = config[0].style;
980
+ const pasteConfigs = await Promise.all(config.map(async (configItem) => {
981
+ const { offsetX = 0, offsetY = 0, ...positionClone } = position;
982
+ let pastePosition = positionClone;
983
+ if (!isEmpty(pastePosition) && curNode.items) {
984
+ pastePosition = getPositionInContainer(pastePosition, curNode.id);
985
+ }
986
+ if (pastePosition.left && configItem.style?.left) {
987
+ pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
988
+ }
989
+ if (pastePosition.top && configItem.style?.top) {
990
+ pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
991
+ }
992
+ const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
993
+ if (pasteConfig.style) {
994
+ const { left, top } = pasteConfig.style;
995
+ if (typeof left === "number" || !!left && !isNaN(Number(left))) {
996
+ pasteConfig.style.left = Number(left) + offsetX;
997
+ }
998
+ if (typeof top === "number" || !!top && !isNaN(Number(top))) {
999
+ pasteConfig.style.top = Number(top) + offsetY;
1000
+ }
1001
+ pasteConfig.style = {
1002
+ ...pasteConfig.style,
1003
+ ...pastePosition
1004
+ };
1005
+ }
1006
+ if (isPage(pasteConfig)) {
1007
+ pasteConfig.name = generatePageNameByApp(editorService.get("root"));
1008
+ }
1009
+ return pasteConfig;
1010
+ }));
1011
+ return pasteConfigs;
1012
+ };
1013
+ const beforeAdd = async (addNode, parent) => {
1014
+ const { type, inputEvent, ...config } = addNode;
1015
+ const curNode = editorService.get("node");
1016
+ let parentNode;
1017
+ const isPage2 = type === NodeType.PAGE;
1018
+ if (isPage2) {
1019
+ parentNode = editorService.get("root");
1020
+ } else if (parent && typeof parent !== "function") {
1021
+ parentNode = parent;
1022
+ } else if (curNode.items) {
1023
+ parentNode = curNode;
1024
+ } else {
1025
+ parentNode = editorService.getParentById(curNode.id, false);
1026
+ }
1027
+ if (!parentNode)
1028
+ throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1029
+ const layout = await editorService.getLayout(toRaw(parentNode), addNode);
1030
+ const newNode = { ...toRaw(await propsService.getPropsValue(type, config)) };
1031
+ newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, editorService.get("stage"));
1032
+ if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
1033
+ throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
1034
+ }
1035
+ parentNode?.items?.push(newNode);
1036
+ return {
1037
+ parentNode,
1038
+ newNode,
1039
+ layout,
1040
+ isPage: isPage2
1041
+ };
1042
+ };
1043
+ const getPositionInContainer = (position = {}, id) => {
1044
+ let { left = 0, top = 0 } = position;
1045
+ const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
1046
+ const parentElRect = parentEl?.getBoundingClientRect();
1047
+ left = left - (parentElRect?.left || 0);
1048
+ top = top - (parentElRect?.top || 0);
1049
+ return {
1050
+ left,
1051
+ top
1052
+ };
1053
+ };
1054
+ const notifyAddToStage = async (parentNode, newNode, layout) => {
1055
+ const stage = editorService.get("stage");
1056
+ const root = editorService.get("root");
1057
+ await stage?.add({ config: cloneDeep(newNode), parent: cloneDeep(parentNode), root: cloneDeep(root) });
1058
+ if (layout === Layout.ABSOLUTE) {
1059
+ const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
1060
+ if (typeof fixedLeft !== "undefined" && newNode.style) {
1061
+ newNode.style.left = fixedLeft;
1062
+ await stage?.update({ config: cloneDeep(newNode), root: cloneDeep(root) });
1063
+ }
1064
+ }
1065
+ };
1066
+ const beforeRemove = async (node) => {
1067
+ if (!node?.id)
1068
+ return;
1069
+ const stage = editorService.get("stage");
1070
+ const root = editorService.get("root");
1071
+ if (!root)
1072
+ throw new Error("\u6CA1\u6709root");
1073
+ const { parent, node: curNode } = editorService.getNodeInfo(node.id, false);
1074
+ if (!parent || !curNode)
1075
+ throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1076
+ const index = getNodeIndex(curNode, parent);
1077
+ if (typeof index !== "number" || index === -1)
1078
+ throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1079
+ parent.items?.splice(index, 1);
1080
+ stage?.remove({ id: node.id, root: cloneDeep(root) });
1081
+ if (node.type === NodeType.PAGE) {
1082
+ editorService.state.pageLength -= 1;
1083
+ if (root.items[0]) {
1084
+ await editorService.select(root.items[0]);
1085
+ stage?.select(root.items[0].id);
1086
+ } else {
1087
+ editorService.set("node", null);
1088
+ editorService.set("nodes", []);
1089
+ editorService.set("parent", null);
1090
+ editorService.set("page", null);
1091
+ editorService.set("stage", null);
1092
+ editorService.set("highlightNode", null);
1093
+ editorService.resetModifiedNodeId();
1094
+ historyService.reset();
1095
+ editorService.emit("remove", node);
1096
+ return;
1097
+ }
1098
+ } else {
1099
+ await editorService.select(parent);
1100
+ stage?.select(parent.id);
1101
+ }
1102
+ return parent;
1103
+ };
1104
+
866
1105
  class Editor$1 extends BaseService {
1106
+ state = reactive({
1107
+ root: null,
1108
+ page: null,
1109
+ parent: null,
1110
+ node: null,
1111
+ nodes: [],
1112
+ stage: null,
1113
+ highlightNode: null,
1114
+ modifiedNodeIds: /* @__PURE__ */ new Map(),
1115
+ pageLength: 0
1116
+ });
1117
+ isHistoryStateChange = false;
867
1118
  constructor() {
868
1119
  super([
869
1120
  "getLayout",
@@ -882,20 +1133,12 @@ class Editor$1 extends BaseService {
882
1133
  "redo",
883
1134
  "highlight"
884
1135
  ], ["select", "update", "moveLayer"]);
885
- this.isHistoryStateChange = false;
886
- this.state = reactive({
887
- root: null,
888
- page: null,
889
- parent: null,
890
- node: null,
891
- stage: null,
892
- highlightNode: null,
893
- modifiedNodeIds: /* @__PURE__ */ new Map(),
894
- pageLength: 0
895
- });
896
1136
  }
897
1137
  set(name, value) {
898
1138
  this.state[name] = value;
1139
+ if (name === "nodes") {
1140
+ this.set("node", value[0]);
1141
+ }
899
1142
  if (name === "root") {
900
1143
  this.state.pageLength = value?.items?.length || 0;
901
1144
  this.emit("root-change", value);
@@ -950,9 +1193,9 @@ class Editor$1 extends BaseService {
950
1193
  }
951
1194
  return Layout.ABSOLUTE;
952
1195
  }
953
- async select(config2) {
954
- const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
955
- this.set("node", node);
1196
+ async select(config) {
1197
+ const { node, page, parent } = this.selectedConfigExceptionHandler(config);
1198
+ this.set("nodes", [node]);
956
1199
  this.set("page", page || null);
957
1200
  this.set("parent", parent || null);
958
1201
  if (page) {
@@ -992,106 +1235,87 @@ class Editor$1 extends BaseService {
992
1235
  this.get("stage")?.select(nextPage.id);
993
1236
  return nextPage;
994
1237
  }
995
- highlight(config2) {
996
- const { node } = this.selectedConfigExceptionHandler(config2);
1238
+ highlight(config) {
1239
+ const { node } = this.selectedConfigExceptionHandler(config);
997
1240
  const currentHighlightNode = this.get("highlightNode");
998
1241
  if (currentHighlightNode === node)
999
1242
  return;
1000
1243
  this.set("highlightNode", node);
1001
1244
  }
1002
- async add(addNode, parent) {
1003
- const { type, inputEvent, ...config2 } = addNode;
1004
- const curNode = this.get("node");
1005
- let parentNode;
1006
- const isPage2 = type === NodeType.PAGE;
1007
- if (isPage2) {
1008
- parentNode = this.get("root");
1009
- } else if (parent && typeof parent !== "function") {
1010
- parentNode = parent;
1011
- } else if (curNode.items) {
1012
- parentNode = curNode;
1013
- } else {
1014
- parentNode = this.getParentById(curNode.id, false);
1015
- }
1016
- if (!parentNode)
1017
- throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1018
- const layout = await this.getLayout(toRaw(parentNode), addNode);
1019
- const newNode = { ...toRaw(await propsService.getPropsValue(type, config2)) };
1020
- newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, this.get("stage"));
1021
- if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
1022
- throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
1023
- }
1024
- parentNode?.items?.push(newNode);
1025
- const stage = this.get("stage");
1026
- const root = this.get("root");
1027
- await stage?.add({ config: cloneDeep(newNode), parent: cloneDeep(parentNode), root: cloneDeep(root) });
1028
- if (layout === Layout.ABSOLUTE) {
1029
- const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
1030
- if (typeof fixedLeft !== "undefined") {
1031
- newNode.style.left = fixedLeft;
1032
- await stage?.update({ config: cloneDeep(newNode), root: cloneDeep(root) });
1033
- }
1034
- }
1245
+ multiSelect(ids) {
1246
+ const nodes = [];
1247
+ const idsUnique = uniq(ids);
1248
+ idsUnique.forEach((id) => {
1249
+ const { node } = this.getNodeInfo(id);
1250
+ if (!node)
1251
+ return;
1252
+ nodes.push(node);
1253
+ });
1254
+ this.set("nodes", nodes);
1255
+ }
1256
+ async multiAdd(configs) {
1257
+ const stage = this.get("stage");
1258
+ const newNodes = await Promise.all(configs.map(async (configItem) => {
1259
+ const { parentNode, newNode, layout } = await beforeAdd(configItem);
1260
+ await notifyAddToStage(parentNode, newNode, layout);
1261
+ return newNode;
1262
+ }));
1263
+ const newNodeIds = newNodes.map((node) => node.id);
1264
+ this.addModifiedNodeId(newNodeIds.join("-"));
1265
+ this.pushHistoryState();
1266
+ stage?.multiSelect(newNodeIds);
1267
+ this.emit("multiAdd", newNodes);
1268
+ return newNodes;
1269
+ }
1270
+ async add(addNode, parent) {
1271
+ const stage = this.get("stage");
1272
+ const { parentNode, newNode, layout, isPage: isPage2 } = await beforeAdd(addNode, parent);
1273
+ await notifyAddToStage(parentNode, newNode, layout);
1035
1274
  await this.select(newNode);
1036
1275
  this.addModifiedNodeId(newNode.id);
1037
1276
  if (!isPage2) {
1038
1277
  this.pushHistoryState();
1039
1278
  }
1040
- stage?.select(newNode.id);
1041
1279
  if (isPage2) {
1042
1280
  this.state.pageLength += 1;
1281
+ } else {
1282
+ stage?.select(newNode.id);
1043
1283
  }
1044
1284
  this.emit("add", newNode);
1045
1285
  return newNode;
1046
1286
  }
1047
- async remove(node) {
1048
- if (!node?.id)
1049
- return;
1050
- const root = this.get("root");
1051
- if (!root)
1052
- throw new Error("\u6CA1\u6709root");
1053
- const { parent, node: curNode } = this.getNodeInfo(node.id, false);
1054
- if (!parent || !curNode)
1055
- throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1056
- const index = getNodeIndex(curNode, parent);
1057
- if (typeof index !== "number" || index === -1)
1058
- throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1059
- parent.items?.splice(index, 1);
1060
- const stage = this.get("stage");
1061
- stage?.remove({ id: node.id, root: cloneDeep(this.get("root")) });
1062
- if (node.type === NodeType.PAGE) {
1063
- this.state.pageLength -= 1;
1064
- if (root.items[0]) {
1065
- await this.select(root.items[0]);
1066
- stage?.select(root.items[0].id);
1067
- } else {
1068
- this.set("node", null);
1069
- this.set("parent", null);
1070
- this.set("page", null);
1071
- this.set("stage", null);
1072
- this.set("highlightNode", null);
1073
- this.resetModifiedNodeId();
1074
- historyService.reset();
1075
- this.emit("remove", node);
1076
- return node;
1077
- }
1078
- } else {
1079
- await this.select(parent);
1080
- stage?.select(parent.id);
1287
+ async remove(nodeOrNodeList) {
1288
+ if (Array.isArray(nodeOrNodeList)) {
1289
+ const nodes = nodeOrNodeList;
1290
+ return this.multiRemove(nodes);
1081
1291
  }
1082
- this.addModifiedNodeId(parent.id);
1292
+ const node = nodeOrNodeList;
1293
+ const removeParent = await beforeRemove(node);
1294
+ if (!removeParent)
1295
+ return node;
1296
+ this.addModifiedNodeId(removeParent.id);
1083
1297
  this.pushHistoryState();
1084
1298
  this.emit("remove", node);
1085
1299
  return node;
1086
1300
  }
1087
- async update(config2) {
1088
- if (!config2?.id)
1301
+ async multiRemove(nodes) {
1302
+ await Promise.all(nodes.map(async (removeNode) => {
1303
+ await beforeRemove(removeNode);
1304
+ }));
1305
+ const nodeIds = nodes.map((node) => node.id);
1306
+ this.addModifiedNodeId(nodeIds.join("-"));
1307
+ this.pushHistoryState();
1308
+ this.emit("multiRemove", nodes);
1309
+ return nodes;
1310
+ }
1311
+ async update(config) {
1312
+ if (!config?.id)
1089
1313
  throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
1090
- const info = this.getNodeInfo(config2.id, false);
1314
+ const info = this.getNodeInfo(config.id, false);
1091
1315
  if (!info.node)
1092
- throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
1316
+ throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
1093
1317
  const node = cloneDeep(toRaw(info.node));
1094
- let newConfig = await this.toggleFixedPosition(toRaw(config2), node, this.get("root"));
1318
+ let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get("root"));
1095
1319
  newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
1096
1320
  if (Array.isArray(srcValue)) {
1097
1321
  return srcValue;
@@ -1116,9 +1340,10 @@ class Editor$1 extends BaseService {
1116
1340
  newConfig = setLayout(newConfig, newLayout);
1117
1341
  }
1118
1342
  parentNodeItems[index] = newConfig;
1119
- if (`${newConfig.id}` === `${this.get("node").id}`) {
1120
- this.set("node", newConfig);
1121
- }
1343
+ const nodes = this.get("nodes");
1344
+ const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
1345
+ nodes.splice(targetIndex, 1, newConfig);
1346
+ this.set("nodes", nodes);
1122
1347
  this.get("stage")?.update({ config: cloneDeep(newConfig), root: cloneDeep(this.get("root")) });
1123
1348
  if (newConfig.type === NodeType.PAGE) {
1124
1349
  this.set("page", newConfig);
@@ -1142,34 +1367,19 @@ class Editor$1 extends BaseService {
1142
1367
  this.addModifiedNodeId(parent.id);
1143
1368
  this.pushHistoryState();
1144
1369
  }
1145
- async copy(config2) {
1146
- globalThis.localStorage.setItem(COPY_STORAGE_KEY, serialize(config2));
1370
+ async copy(config) {
1371
+ await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
1372
+ protocol: Protocol.OBJECT
1373
+ });
1147
1374
  }
1148
1375
  async paste(position = {}) {
1149
- const configStr = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
1150
- let config = {};
1151
- if (!configStr) {
1152
- return;
1153
- }
1154
- try {
1155
- eval(`config = ${configStr}`);
1156
- } catch (e) {
1157
- console.error(e);
1376
+ const config = await storageService.getItem(COPY_STORAGE_KEY);
1377
+ if (!config)
1158
1378
  return;
1159
- }
1160
- await propsService.setNewItemId(config, this.get("root"));
1161
- if (config.style) {
1162
- config.style = {
1163
- ...config.style,
1164
- ...position
1165
- };
1166
- }
1167
- if (isPage(config)) {
1168
- config.name = generatePageNameByApp(this.get("root"));
1169
- }
1170
- return await this.add(config);
1379
+ const pasteConfigs = await beforePaste(position, config);
1380
+ return await this.multiAdd(pasteConfigs);
1171
1381
  }
1172
- async alignCenter(config2) {
1382
+ async alignCenter(config) {
1173
1383
  const parent = this.get("parent");
1174
1384
  const node = this.get("node");
1175
1385
  const layout = await this.getLayout(toRaw(parent), toRaw(node));
@@ -1194,9 +1404,9 @@ class Editor$1 extends BaseService {
1194
1404
  config: cloneDeep(toRaw(node)),
1195
1405
  root: cloneDeep(this.get("root"))
1196
1406
  });
1197
- this.addModifiedNodeId(config2.id);
1407
+ this.addModifiedNodeId(config.id);
1198
1408
  this.pushHistoryState();
1199
- return config2;
1409
+ return config;
1200
1410
  }
1201
1411
  async moveLayer(offset) {
1202
1412
  const parent = this.get("parent");
@@ -1215,8 +1425,8 @@ class Editor$1 extends BaseService {
1215
1425
  root: cloneDeep(this.get("root"))
1216
1426
  });
1217
1427
  }
1218
- async moveToContainer(config2, targetId) {
1219
- const { node, parent } = this.getNodeInfo(config2.id, false);
1428
+ async moveToContainer(config, targetId) {
1429
+ const { node, parent } = this.getNodeInfo(config.id, false);
1220
1430
  const target = this.getNodeById(targetId, false);
1221
1431
  const stage = this.get("stage");
1222
1432
  if (node && parent && stage) {
@@ -1225,7 +1435,7 @@ class Editor$1 extends BaseService {
1225
1435
  parent.items?.splice(index, 1);
1226
1436
  await stage.remove({ id: node.id, root });
1227
1437
  const layout = await this.getLayout(target);
1228
- const newConfig = mergeWith(cloneDeep(node), config2, (objValue, srcValue) => {
1438
+ const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
1229
1439
  if (Array.isArray(srcValue)) {
1230
1440
  return srcValue;
1231
1441
  }
@@ -1276,6 +1486,7 @@ class Editor$1 extends BaseService {
1276
1486
  this.removeAllListeners();
1277
1487
  this.set("root", null);
1278
1488
  this.set("node", null);
1489
+ this.set("nodes", []);
1279
1490
  this.set("page", null);
1280
1491
  this.set("parent", null);
1281
1492
  }
@@ -1322,12 +1533,12 @@ class Editor$1 extends BaseService {
1322
1533
  }
1323
1534
  return newConfig;
1324
1535
  }
1325
- selectedConfigExceptionHandler(config2) {
1536
+ selectedConfigExceptionHandler(config) {
1326
1537
  let id;
1327
- if (typeof config2 === "string" || typeof config2 === "number") {
1328
- id = config2;
1538
+ if (typeof config === "string" || typeof config === "number") {
1539
+ id = config;
1329
1540
  } else {
1330
- id = config2.id;
1541
+ id = config.id;
1331
1542
  }
1332
1543
  if (!id) {
1333
1544
  throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
@@ -1345,7 +1556,7 @@ class Editor$1 extends BaseService {
1345
1556
  };
1346
1557
  }
1347
1558
  }
1348
- var editorService = new Editor$1();
1559
+ const editorService = new Editor$1();
1349
1560
 
1350
1561
  const eventMap = reactive({});
1351
1562
  const methodMap = reactive({});
@@ -1389,7 +1600,7 @@ class Events extends BaseService {
1389
1600
  return cloneDeep(methodMap[type] || DEFAULT_METHODS);
1390
1601
  }
1391
1602
  }
1392
- var eventsService = new Events();
1603
+ const eventsService = new Events();
1393
1604
 
1394
1605
  const fillConfig = (config = []) => [
1395
1606
  {
@@ -1595,32 +1806,34 @@ const fillConfig = (config = []) => [
1595
1806
  }
1596
1807
  ];
1597
1808
  const DEFAULT_CONFIG = fillConfig([]);
1598
- const getDefaultPropsValue = (type, id) => ["page", "container"].includes(type) ? {
1599
- type,
1600
- id,
1601
- layout: "absolute",
1602
- style: {},
1603
- name: type,
1604
- items: []
1605
- } : {
1606
- type,
1607
- id,
1608
- style: {},
1609
- name: type
1610
- };
1611
1809
 
1612
1810
  const log = (...args) => {
1811
+ if (process.env.NODE_ENV === "development") {
1812
+ console.log("magic editor: ", ...args);
1813
+ }
1613
1814
  };
1614
1815
  const info = (...args) => {
1816
+ if (process.env.NODE_ENV === "development") {
1817
+ console.info("magic editor: ", ...args);
1818
+ }
1615
1819
  };
1616
1820
  const warn = (...args) => {
1821
+ if (process.env.NODE_ENV === "development") {
1822
+ console.warn("magic editor: ", ...args);
1823
+ }
1617
1824
  };
1618
1825
  const debug = (...args) => {
1826
+ if (process.env.NODE_ENV === "development") {
1827
+ console.debug("magic editor: ", ...args);
1828
+ }
1619
1829
  };
1620
1830
  const error = (...args) => {
1831
+ if (process.env.NODE_ENV === "development") {
1832
+ console.error("magic editor: ", ...args);
1833
+ }
1621
1834
  };
1622
1835
 
1623
- const _sfc_main$i = defineComponent({
1836
+ const _sfc_main$j = defineComponent({
1624
1837
  components: { Plus },
1625
1838
  setup() {
1626
1839
  const services = inject("services");
@@ -1637,10 +1850,11 @@ const _sfc_main$i = defineComponent({
1637
1850
  };
1638
1851
  }
1639
1852
  });
1853
+
1640
1854
  const _hoisted_1$b = { class: "m-editor-empty-panel" };
1641
1855
  const _hoisted_2$4 = { class: "m-editor-empty-content" };
1642
- const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1643
- function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1856
+ const _hoisted_3$1 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1857
+ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1644
1858
  const _component_plus = resolveComponent("plus");
1645
1859
  const _component_el_icon = resolveComponent("el-icon");
1646
1860
  return openBlock(), createElementBlock("div", _hoisted_1$b, [
@@ -1657,14 +1871,14 @@ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1657
1871
  _: 1
1658
1872
  })
1659
1873
  ]),
1660
- _hoisted_3$2
1874
+ _hoisted_3$1
1661
1875
  ])
1662
1876
  ])
1663
1877
  ]);
1664
1878
  }
1665
- var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
1879
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
1666
1880
 
1667
- const _sfc_main$h = defineComponent({
1881
+ const _sfc_main$i = defineComponent({
1668
1882
  name: "m-editor-resize",
1669
1883
  props: {
1670
1884
  type: {
@@ -1706,18 +1920,19 @@ const _sfc_main$h = defineComponent({
1706
1920
  };
1707
1921
  }
1708
1922
  });
1923
+
1709
1924
  const _hoisted_1$a = {
1710
1925
  ref: "target",
1711
1926
  class: "m-editor-resizer"
1712
1927
  };
1713
- function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1928
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1714
1929
  return openBlock(), createElementBlock("span", _hoisted_1$a, [
1715
1930
  renderSlot(_ctx.$slots, "default")
1716
1931
  ], 512);
1717
1932
  }
1718
- var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
1933
+ const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
1719
1934
 
1720
- const _sfc_main$g = defineComponent({
1935
+ const _sfc_main$h = defineComponent({
1721
1936
  components: {
1722
1937
  AddPageBox,
1723
1938
  Resizer
@@ -1746,12 +1961,13 @@ const _sfc_main$g = defineComponent({
1746
1961
  };
1747
1962
  }
1748
1963
  });
1964
+
1749
1965
  const _hoisted_1$9 = { class: "m-editor" };
1750
1966
  const _hoisted_2$3 = {
1751
1967
  key: 1,
1752
1968
  class: "m-editor-content"
1753
1969
  };
1754
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1970
+ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
1755
1971
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
1756
1972
  const _component_resizer = resolveComponent("resizer");
1757
1973
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
@@ -1797,9 +2013,9 @@ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1797
2013
  ]))
1798
2014
  ]);
1799
2015
  }
1800
- var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
2016
+ const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
1801
2017
 
1802
- const _sfc_main$f = defineComponent({
2018
+ const _sfc_main$g = defineComponent({
1803
2019
  name: "m-icon",
1804
2020
  components: { Edit },
1805
2021
  props: {
@@ -1813,8 +2029,9 @@ const _sfc_main$f = defineComponent({
1813
2029
  };
1814
2030
  }
1815
2031
  });
2032
+
1816
2033
  const _hoisted_1$8 = ["src"];
1817
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2034
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1818
2035
  const _component_edit = resolveComponent("edit");
1819
2036
  const _component_el_icon = resolveComponent("el-icon");
1820
2037
  return !_ctx.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
@@ -1835,10 +2052,19 @@ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
1835
2052
  _: 1
1836
2053
  }));
1837
2054
  }
1838
- var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
2055
+ const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
1839
2056
 
1840
- const _sfc_main$e = defineComponent({
1841
- components: { MIcon, ArrowDown },
2057
+ const _hoisted_1$7 = {
2058
+ key: 1,
2059
+ class: "menu-item-text"
2060
+ };
2061
+ const _hoisted_2$2 = {
2062
+ class: "menu-item-text",
2063
+ style: { "margin": "0 5px" }
2064
+ };
2065
+ const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
2066
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2067
+ __name: "ToolButton",
1842
2068
  props: {
1843
2069
  data: {
1844
2070
  type: [Object, String],
@@ -1853,7 +2079,8 @@ const _sfc_main$e = defineComponent({
1853
2079
  default: "click"
1854
2080
  }
1855
2081
  },
1856
- setup(props) {
2082
+ setup(__props) {
2083
+ const props = __props;
1857
2084
  const services = inject("services");
1858
2085
  const uiService = services?.uiService;
1859
2086
  const zoom = computed(() => uiService?.get("zoom") ?? 1);
@@ -1950,176 +2177,155 @@ const _sfc_main$e = defineComponent({
1950
2177
  item2.handler?.(services, event);
1951
2178
  }
1952
2179
  };
1953
- return {
1954
- ZoomIn: markRaw(ZoomIn),
1955
- ZoomOut: markRaw(ZoomOut),
1956
- item,
1957
- zoom,
1958
- disabled,
1959
- display: computed(() => {
1960
- if (!item.value)
1961
- return false;
1962
- if (typeof item.value === "string")
1963
- return true;
1964
- if (typeof item.value.display === "function") {
1965
- return item.value.display(services);
1966
- }
1967
- return item.value.display ?? true;
1968
- }),
1969
- zoomInHandler,
1970
- zoomOutHandler,
1971
- dropdownHandler(command) {
1972
- if (command.item.handler) {
1973
- command.item.handler(services);
1974
- }
1975
- },
1976
- clickHandler(item2, event) {
1977
- if (props.eventType !== "click")
1978
- return;
1979
- if (item2.type === "button") {
1980
- buttonHandler(item2, event);
1981
- }
1982
- },
1983
- mousedownHandler(item2, event) {
1984
- if (props.eventType !== "mousedown")
1985
- return;
1986
- if (item2.type === "button") {
1987
- buttonHandler(item2, event);
1988
- }
1989
- },
1990
- mouseupHandler(item2, event) {
1991
- if (props.eventType !== "mouseup")
1992
- return;
1993
- if (item2.type === "button") {
1994
- buttonHandler(item2, event);
1995
- }
2180
+ const display = computed(() => {
2181
+ if (!item.value)
2182
+ return false;
2183
+ if (typeof item.value === "string")
2184
+ return true;
2185
+ if (typeof item.value.display === "function") {
2186
+ return item.value.display(services);
2187
+ }
2188
+ return item.value.display ?? true;
2189
+ });
2190
+ const dropdownHandler = (command) => {
2191
+ if (command.item.handler) {
2192
+ command.item.handler(services);
1996
2193
  }
1997
2194
  };
1998
- }
1999
- });
2000
- const _hoisted_1$7 = {
2001
- key: 1,
2002
- class: "menu-item-text"
2003
- };
2004
- const _hoisted_2$2 = {
2005
- class: "menu-item-text",
2006
- style: { "margin": "0 5px" }
2007
- };
2008
- const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
2009
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2010
- const _component_el_divider = resolveComponent("el-divider");
2011
- const _component_tool_button = resolveComponent("tool-button", true);
2012
- const _component_m_icon = resolveComponent("m-icon");
2013
- const _component_el_button = resolveComponent("el-button");
2014
- const _component_el_tooltip = resolveComponent("el-tooltip");
2015
- const _component_arrow_down = resolveComponent("arrow-down");
2016
- const _component_el_icon = resolveComponent("el-icon");
2017
- const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
2018
- const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
2019
- const _component_el_dropdown = resolveComponent("el-dropdown");
2020
- return _ctx.display ? (openBlock(), createElementBlock("div", {
2021
- key: 0,
2022
- class: normalizeClass(["menu-item", _ctx.item.type]),
2023
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
2024
- onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
2025
- onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
2026
- }, [
2027
- _ctx.item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2028
- key: 0,
2029
- direction: _ctx.item.direction || "vertical"
2030
- }, null, 8, ["direction"])) : _ctx.item.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$7, toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2031
- createVNode(_component_tool_button, {
2032
- data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2033
- "event-type": _ctx.eventType
2034
- }, null, 8, ["data", "event-type"]),
2035
- createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
2036
- createVNode(_component_tool_button, {
2037
- data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
2038
- "event-type": _ctx.eventType
2039
- }, null, 8, ["data", "event-type"])
2040
- ], 64)) : _ctx.item.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
2041
- _ctx.item.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
2195
+ const clickHandler = (item2, event) => {
2196
+ if (props.eventType !== "click")
2197
+ return;
2198
+ if (item2.type === "button") {
2199
+ buttonHandler(item2, event);
2200
+ }
2201
+ };
2202
+ const mousedownHandler = (item2, event) => {
2203
+ if (props.eventType !== "mousedown")
2204
+ return;
2205
+ if (item2.type === "button") {
2206
+ buttonHandler(item2, event);
2207
+ }
2208
+ };
2209
+ const mouseupHandler = (item2, event) => {
2210
+ if (props.eventType !== "mouseup")
2211
+ return;
2212
+ if (item2.type === "button") {
2213
+ buttonHandler(item2, event);
2214
+ }
2215
+ };
2216
+ return (_ctx, _cache) => {
2217
+ const _component_el_divider = resolveComponent("el-divider");
2218
+ const _component_tool_button = resolveComponent("tool-button", true);
2219
+ const _component_el_button = resolveComponent("el-button");
2220
+ const _component_el_tooltip = resolveComponent("el-tooltip");
2221
+ const _component_el_icon = resolveComponent("el-icon");
2222
+ const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
2223
+ const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
2224
+ const _component_el_dropdown = resolveComponent("el-dropdown");
2225
+ return unref(display) ? (openBlock(), createElementBlock("div", {
2042
2226
  key: 0,
2043
- effect: "dark",
2044
- placement: "bottom-start",
2045
- content: _ctx.item.tooltip
2046
- }, {
2047
- default: withCtx(() => [
2048
- createVNode(_component_el_button, {
2227
+ class: normalizeClass(["menu-item", unref(item).type]),
2228
+ onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(item), $event)),
2229
+ onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(unref(item), $event)),
2230
+ onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(unref(item), $event))
2231
+ }, [
2232
+ unref(item).type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2233
+ key: 0,
2234
+ direction: unref(item).direction || "vertical"
2235
+ }, 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 }, [
2236
+ createVNode(_component_tool_button, {
2237
+ data: { type: "button", icon: unref(ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2238
+ "event-type": __props.eventType
2239
+ }, null, 8, ["data", "event-type"]),
2240
+ createElementVNode("span", _hoisted_2$2, toDisplayString(parseInt(`${unref(zoom) * 100}`, 10)) + "%", 1),
2241
+ createVNode(_component_tool_button, {
2242
+ data: { type: "button", icon: unref(ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
2243
+ "event-type": __props.eventType
2244
+ }, null, 8, ["data", "event-type"])
2245
+ ], 64)) : unref(item).type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
2246
+ unref(item).tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
2247
+ key: 0,
2248
+ effect: "dark",
2249
+ placement: "bottom-start",
2250
+ content: unref(item).tooltip
2251
+ }, {
2252
+ default: withCtx(() => [
2253
+ createVNode(_component_el_button, {
2254
+ size: "small",
2255
+ text: "",
2256
+ disabled: unref(disabled)
2257
+ }, {
2258
+ default: withCtx(() => [
2259
+ unref(item).icon ? (openBlock(), createBlock(MIcon, {
2260
+ key: 0,
2261
+ icon: unref(item).icon
2262
+ }, null, 8, ["icon"])) : createCommentVNode("", true),
2263
+ createElementVNode("span", null, toDisplayString(unref(item).text), 1)
2264
+ ]),
2265
+ _: 1
2266
+ }, 8, ["disabled"])
2267
+ ]),
2268
+ _: 1
2269
+ }, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
2270
+ key: 1,
2049
2271
  size: "small",
2050
2272
  text: "",
2051
- disabled: _ctx.disabled
2273
+ disabled: unref(disabled)
2052
2274
  }, {
2053
2275
  default: withCtx(() => [
2054
- _ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
2276
+ unref(item).icon ? (openBlock(), createBlock(MIcon, {
2055
2277
  key: 0,
2056
- icon: _ctx.item.icon
2278
+ icon: unref(item).icon
2057
2279
  }, null, 8, ["icon"])) : createCommentVNode("", true),
2058
- createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
2280
+ createElementVNode("span", null, toDisplayString(unref(item).text), 1)
2059
2281
  ]),
2060
2282
  _: 1
2061
- }, 8, ["disabled"])
2062
- ]),
2063
- _: 1
2064
- }, 8, ["content"])) : (openBlock(), createBlock(_component_el_button, {
2065
- key: 1,
2066
- size: "small",
2067
- text: "",
2068
- disabled: _ctx.disabled
2069
- }, {
2070
- default: withCtx(() => [
2071
- _ctx.item.icon ? (openBlock(), createBlock(_component_m_icon, {
2072
- key: 0,
2073
- icon: _ctx.item.icon
2074
- }, null, 8, ["icon"])) : createCommentVNode("", true),
2075
- createElementVNode("span", null, toDisplayString(_ctx.item.text), 1)
2076
- ]),
2077
- _: 1
2078
- }, 8, ["disabled"]))
2079
- ], 64)) : _ctx.item.type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
2080
- key: 4,
2081
- trigger: "click",
2082
- disabled: _ctx.disabled,
2083
- onCommand: _ctx.dropdownHandler
2084
- }, {
2085
- dropdown: withCtx(() => [
2086
- _ctx.item.items && _ctx.item.items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
2283
+ }, 8, ["disabled"]))
2284
+ ], 64)) : unref(item).type === "dropdown" ? (openBlock(), createBlock(_component_el_dropdown, {
2285
+ key: 4,
2286
+ trigger: "click",
2287
+ disabled: unref(disabled),
2288
+ onCommand: dropdownHandler
2289
+ }, {
2290
+ dropdown: withCtx(() => [
2291
+ unref(item).items && unref(item).items.length ? (openBlock(), createBlock(_component_el_dropdown_menu, { key: 0 }, {
2292
+ default: withCtx(() => [
2293
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(item).items, (subItem, index) => {
2294
+ return openBlock(), createBlock(_component_el_dropdown_item, {
2295
+ key: index,
2296
+ command: { item: unref(item), subItem }
2297
+ }, {
2298
+ default: withCtx(() => [
2299
+ createTextVNode(toDisplayString(subItem.text), 1)
2300
+ ]),
2301
+ _: 2
2302
+ }, 1032, ["command"]);
2303
+ }), 128))
2304
+ ]),
2305
+ _: 1
2306
+ })) : createCommentVNode("", true)
2307
+ ]),
2087
2308
  default: withCtx(() => [
2088
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.item.items, (subItem, index) => {
2089
- return openBlock(), createBlock(_component_el_dropdown_item, {
2090
- key: index,
2091
- command: { item: _ctx.item, subItem }
2092
- }, {
2309
+ createElementVNode("span", _hoisted_3, [
2310
+ createTextVNode(toDisplayString(unref(item).text), 1),
2311
+ createVNode(_component_el_icon, { class: "el-icon--right" }, {
2093
2312
  default: withCtx(() => [
2094
- createTextVNode(toDisplayString(subItem.text), 1)
2313
+ createVNode(unref(ArrowDown))
2095
2314
  ]),
2096
- _: 2
2097
- }, 1032, ["command"]);
2098
- }), 128))
2315
+ _: 1
2316
+ })
2317
+ ])
2099
2318
  ]),
2100
2319
  _: 1
2101
- })) : createCommentVNode("", true)
2102
- ]),
2103
- default: withCtx(() => [
2104
- createElementVNode("span", _hoisted_3$1, [
2105
- createTextVNode(toDisplayString(_ctx.item.text), 1),
2106
- createVNode(_component_el_icon, { class: "el-icon--right" }, {
2107
- default: withCtx(() => [
2108
- createVNode(_component_arrow_down)
2109
- ]),
2110
- _: 1
2111
- })
2112
- ])
2113
- ]),
2114
- _: 1
2115
- }, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.item.component), normalizeProps(mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : createCommentVNode("", true)
2116
- ], 34)) : createCommentVNode("", true);
2117
- }
2118
- var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
2320
+ }, 8, ["disabled"])) : unref(item).type === "component" ? (openBlock(), createBlock(resolveDynamicComponent(unref(item).component), normalizeProps(mergeProps({ key: 5 }, unref(item).props || {})), null, 16)) : createCommentVNode("", true)
2321
+ ], 34)) : createCommentVNode("", true);
2322
+ };
2323
+ }
2324
+ });
2119
2325
 
2120
- const _sfc_main$d = defineComponent({
2326
+ const _sfc_main$e = defineComponent({
2121
2327
  name: "nav-menu",
2122
- components: { ToolButton },
2328
+ components: { ToolButton: _sfc_main$f },
2123
2329
  props: {
2124
2330
  data: {
2125
2331
  type: Object,
@@ -2137,7 +2343,8 @@ const _sfc_main$d = defineComponent({
2137
2343
  };
2138
2344
  }
2139
2345
  });
2140
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2346
+
2347
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2141
2348
  const _component_tool_button = resolveComponent("tool-button");
2142
2349
  return openBlock(), createElementBlock("div", {
2143
2350
  class: "m-editor-nav-menu",
@@ -2159,9 +2366,9 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2159
2366
  }), 128))
2160
2367
  ], 4);
2161
2368
  }
2162
- var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
2369
+ const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
2163
2370
 
2164
- const _sfc_main$c = defineComponent({
2371
+ const _sfc_main$d = defineComponent({
2165
2372
  name: "m-editor-props-panel",
2166
2373
  emits: ["mounted"],
2167
2374
  setup(props, { emit }) {
@@ -2208,8 +2415,9 @@ const _sfc_main$c = defineComponent({
2208
2415
  };
2209
2416
  }
2210
2417
  });
2418
+
2211
2419
  const _hoisted_1$6 = { class: "`m-editor-props-panel" };
2212
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2420
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2213
2421
  const _component_m_form = resolveComponent("m-form");
2214
2422
  return openBlock(), createElementBlock("div", _hoisted_1$6, [
2215
2423
  renderSlot(_ctx.$slots, "props-panel-header"),
@@ -2224,9 +2432,9 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2224
2432
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
2225
2433
  ]);
2226
2434
  }
2227
- var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
2435
+ const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
2228
2436
 
2229
- const _sfc_main$b = defineComponent({
2437
+ const _sfc_main$c = defineComponent({
2230
2438
  name: "ui-component-panel",
2231
2439
  components: { MIcon },
2232
2440
  setup() {
@@ -2292,9 +2500,10 @@ const _sfc_main$b = defineComponent({
2292
2500
  };
2293
2501
  }
2294
2502
  });
2503
+
2295
2504
  const _hoisted_1$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2296
2505
  const _hoisted_2$1 = ["onClick", "onDragstart"];
2297
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2506
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2298
2507
  const _component_el_input = resolveComponent("el-input");
2299
2508
  const _component_m_icon = resolveComponent("m-icon");
2300
2509
  const _component_el_tooltip = resolveComponent("el-tooltip");
@@ -2366,22 +2575,17 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2366
2575
  _: 3
2367
2576
  });
2368
2577
  }
2369
- var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
2578
+ const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
2370
2579
 
2371
- const _sfc_main$a = defineComponent({
2372
- components: { ToolButton },
2580
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
2581
+ __name: "ContentMenu",
2373
2582
  props: {
2374
- menuData: {
2375
- type: Array,
2376
- default: () => []
2377
- },
2378
- isSubMenu: {
2379
- type: Boolean,
2380
- default: false
2381
- }
2583
+ menuData: { default: () => [] },
2584
+ isSubMenu: { type: Boolean, default: false }
2382
2585
  },
2383
2586
  emits: ["hide", "show"],
2384
- setup(props, { emit }) {
2587
+ setup(__props, { expose, emit }) {
2588
+ const props = __props;
2385
2589
  const menu = ref();
2386
2590
  const subMenu = ref();
2387
2591
  const visible = ref(false);
@@ -2407,6 +2611,36 @@ const _sfc_main$a = defineComponent({
2407
2611
  }
2408
2612
  hide();
2409
2613
  };
2614
+ const show = (e) => {
2615
+ setTimeout(() => {
2616
+ visible.value = true;
2617
+ nextTick(() => {
2618
+ const menuHeight = menu.value?.clientHeight || 0;
2619
+ let top = e.clientY;
2620
+ if (menuHeight + e.clientY > document.body.clientHeight) {
2621
+ top = document.body.clientHeight - menuHeight;
2622
+ }
2623
+ menuStyle.value = {
2624
+ top: `${top}px`,
2625
+ left: `${e.clientX}px`
2626
+ };
2627
+ emit("show");
2628
+ });
2629
+ }, 300);
2630
+ };
2631
+ const showSubMenu = (item) => {
2632
+ const menuItem = item;
2633
+ if (typeof item !== "object" || !menuItem.items?.length) {
2634
+ return;
2635
+ }
2636
+ subMenuData.value = menuItem.items;
2637
+ if (menu.value) {
2638
+ subMenu.value.show({
2639
+ clientX: menu.value.offsetLeft + menu.value.clientWidth,
2640
+ clientY: menu.value.offsetTop
2641
+ });
2642
+ }
2643
+ };
2410
2644
  onMounted(() => {
2411
2645
  if (props.isSubMenu)
2412
2646
  return;
@@ -2417,81 +2651,47 @@ const _sfc_main$a = defineComponent({
2417
2651
  return;
2418
2652
  globalThis.removeEventListener("mousedown", hideHandler, true);
2419
2653
  });
2420
- return {
2421
- menu,
2422
- subMenu,
2423
- visible,
2424
- menuStyle,
2425
- subMenuData,
2654
+ expose({
2426
2655
  hide,
2427
- show(e) {
2428
- setTimeout(() => {
2429
- visible.value = true;
2430
- nextTick(() => {
2431
- const menuHeight = menu.value?.clientHeight || 0;
2432
- let top = e.clientY;
2433
- if (menuHeight + e.clientY > document.body.clientHeight) {
2434
- top = document.body.clientHeight - menuHeight;
2435
- }
2436
- menuStyle.value = {
2437
- top: `${top}px`,
2438
- left: `${e.clientX}px`
2439
- };
2440
- emit("show");
2441
- });
2442
- }, 300);
2443
- },
2444
- showSubMenu(item) {
2445
- const menuItem = item;
2446
- if (typeof item !== "object" || !menuItem.items?.length) {
2447
- return;
2448
- }
2449
- subMenuData.value = menuItem.items;
2450
- if (menu.value) {
2451
- subMenu.value.show({
2452
- clientX: menu.value.offsetLeft + menu.value.clientWidth,
2453
- clientY: menu.value.offsetTop
2454
- });
2455
- }
2456
- }
2656
+ show
2657
+ });
2658
+ return (_ctx, _cache) => {
2659
+ const _component_content_menu = resolveComponent("content-menu", true);
2660
+ return __props.menuData.length && visible.value ? (openBlock(), createElementBlock("div", {
2661
+ key: 0,
2662
+ class: "magic-editor-content-menu",
2663
+ ref_key: "menu",
2664
+ ref: menu,
2665
+ style: normalizeStyle(menuStyle.value)
2666
+ }, [
2667
+ createElementVNode("div", null, [
2668
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
2669
+ return openBlock(), createBlock(_sfc_main$f, {
2670
+ "event-type": "mouseup",
2671
+ data: item,
2672
+ key: index,
2673
+ onMouseup: hide,
2674
+ onMouseenter: ($event) => showSubMenu(item)
2675
+ }, null, 8, ["data", "onMouseenter"]);
2676
+ }), 128))
2677
+ ]),
2678
+ (openBlock(), createBlock(Teleport, { to: "body" }, [
2679
+ createVNode(_component_content_menu, {
2680
+ class: "sub-menu",
2681
+ ref_key: "subMenu",
2682
+ ref: subMenu,
2683
+ "menu-data": subMenuData.value,
2684
+ "is-sub-menu": true,
2685
+ onHide: hide
2686
+ }, null, 8, ["menu-data"])
2687
+ ]))
2688
+ ], 4)) : createCommentVNode("", true);
2457
2689
  };
2458
2690
  }
2459
2691
  });
2460
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2461
- const _component_tool_button = resolveComponent("tool-button");
2462
- const _component_content_menu = resolveComponent("content-menu", true);
2463
- return _ctx.menuData.length && _ctx.visible ? (openBlock(), createElementBlock("div", {
2464
- key: 0,
2465
- class: "magic-editor-content-menu",
2466
- ref: "menu",
2467
- style: normalizeStyle(_ctx.menuStyle)
2468
- }, [
2469
- createElementVNode("div", null, [
2470
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
2471
- return openBlock(), createBlock(_component_tool_button, {
2472
- "event-type": "mouseup",
2473
- data: item,
2474
- key: index,
2475
- onMouseup: _ctx.hide,
2476
- onMouseenter: ($event) => _ctx.showSubMenu(item)
2477
- }, null, 8, ["data", "onMouseup", "onMouseenter"]);
2478
- }), 128))
2479
- ]),
2480
- (openBlock(), createBlock(Teleport, { to: "body" }, [
2481
- createVNode(_component_content_menu, {
2482
- class: "sub-menu",
2483
- ref: "subMenu",
2484
- "menu-data": _ctx.subMenuData,
2485
- "is-sub-menu": true,
2486
- onHide: _ctx.hide
2487
- }, null, 8, ["menu-data", "onHide"])
2488
- ]))
2489
- ], 4)) : createCommentVNode("", true);
2490
- }
2491
- var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
2492
2692
 
2493
- const _sfc_main$9 = defineComponent({
2494
- components: { ContentMenu },
2693
+ const _sfc_main$a = defineComponent({
2694
+ components: { ContentMenu: _sfc_main$b },
2495
2695
  setup() {
2496
2696
  const services = inject("services");
2497
2697
  const menu = ref();
@@ -2573,7 +2773,8 @@ const _sfc_main$9 = defineComponent({
2573
2773
  };
2574
2774
  }
2575
2775
  });
2576
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2776
+
2777
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2577
2778
  const _component_content_menu = resolveComponent("content-menu");
2578
2779
  return openBlock(), createBlock(_component_content_menu, {
2579
2780
  "menu-data": _ctx.menuData,
@@ -2581,7 +2782,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2581
2782
  style: { "overflow": "initial" }
2582
2783
  }, null, 8, ["menu-data"]);
2583
2784
  }
2584
- var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
2785
+ const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
2585
2786
 
2586
2787
  const throttleTime = 150;
2587
2788
  const select = async (data, editorService) => {
@@ -2615,9 +2816,17 @@ const useDrop = (tree, editorService) => ({
2615
2816
  return true;
2616
2817
  return false;
2617
2818
  },
2618
- handleDragEnd() {
2819
+ async handleDragEnd(e) {
2619
2820
  if (!tree.value)
2620
2821
  return;
2822
+ const { data: node } = e;
2823
+ const parent = editorService?.getParentById(node.id, false);
2824
+ const layout = await editorService?.getLayout(parent);
2825
+ node.style.position = layout;
2826
+ if (layout === Layout.RELATIVE) {
2827
+ node.style.top = 0;
2828
+ node.style.left = 0;
2829
+ }
2621
2830
  const { data } = tree.value;
2622
2831
  const [page] = data;
2623
2832
  editorService?.update(page);
@@ -2673,7 +2882,7 @@ const useFilter = (tree) => ({
2673
2882
  tree.value?.filter(val);
2674
2883
  }
2675
2884
  });
2676
- const _sfc_main$8 = defineComponent({
2885
+ const _sfc_main$9 = defineComponent({
2677
2886
  name: "magic-editor-layer-panel",
2678
2887
  components: { LayerMenu },
2679
2888
  setup() {
@@ -2720,8 +2929,9 @@ const _sfc_main$8 = defineComponent({
2720
2929
  };
2721
2930
  }
2722
2931
  });
2932
+
2723
2933
  const _hoisted_1$4 = ["id", "onMouseenter"];
2724
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2934
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2725
2935
  const _component_el_input = resolveComponent("el-input");
2726
2936
  const _component_el_tree = resolveComponent("el-tree");
2727
2937
  const _component_layer_menu = resolveComponent("layer-menu");
@@ -2783,9 +2993,9 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2783
2993
  _: 3
2784
2994
  });
2785
2995
  }
2786
- var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
2996
+ const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
2787
2997
 
2788
- const _sfc_main$7 = defineComponent({
2998
+ const _sfc_main$8 = defineComponent({
2789
2999
  components: { MIcon },
2790
3000
  props: {
2791
3001
  data: {
@@ -2822,11 +3032,12 @@ const _sfc_main$7 = defineComponent({
2822
3032
  };
2823
3033
  }
2824
3034
  });
3035
+
2825
3036
  const _hoisted_1$3 = {
2826
3037
  key: 1,
2827
3038
  class: "magic-editor-tab-panel-title"
2828
3039
  };
2829
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3040
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
2830
3041
  const _component_m_icon = resolveComponent("m-icon");
2831
3042
  const _component_el_tab_pane = resolveComponent("el-tab-pane");
2832
3043
  return _ctx.config ? (openBlock(), createBlock(_component_el_tab_pane, {
@@ -2872,9 +3083,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2872
3083
  _: 3
2873
3084
  }, 8, ["name"])) : createCommentVNode("", true);
2874
3085
  }
2875
- var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
3086
+ const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
2876
3087
 
2877
- const _sfc_main$6 = defineComponent({
3088
+ const _sfc_main$7 = defineComponent({
2878
3089
  components: { TabPane },
2879
3090
  name: "m-sidebar",
2880
3091
  props: {
@@ -2893,7 +3104,8 @@ const _sfc_main$6 = defineComponent({
2893
3104
  };
2894
3105
  }
2895
3106
  });
2896
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
3107
+
3108
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
2897
3109
  const _component_tab_pane = resolveComponent("tab-pane");
2898
3110
  const _component_el_tabs = resolveComponent("el-tabs");
2899
3111
  return _ctx.data.type === "tabs" && _ctx.data.items.length ? (openBlock(), createBlock(_component_el_tabs, {
@@ -2928,331 +3140,258 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2928
3140
  _: 3
2929
3141
  }, 8, ["modelValue"])) : createCommentVNode("", true);
2930
3142
  }
2931
- var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
3143
+ const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
2932
3144
 
2933
- const useScroll = (root) => {
2934
- const pageBar = ref();
2935
- const itemsContainer = ref();
2936
- const pageBarWidth = ref(0);
2937
- const canScroll = ref(false);
2938
- const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
2939
- let translateLeft = 0;
2940
- const resizeObserver = new ResizeObserver((entries) => {
2941
- for (const { contentRect } of entries) {
2942
- const { width } = contentRect;
2943
- pageBarWidth.value = width || 0;
2944
- setCanScroll();
2945
- }
2946
- });
2947
- const setCanScroll = () => {
2948
- if (itemsContainer.value) {
2949
- canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
2950
- }
2951
- };
2952
- const scroll = (type) => {
2953
- if (!itemsContainer.value)
2954
- return;
2955
- const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
2956
- if (type === "left") {
2957
- translateLeft += 100;
2958
- if (translateLeft > 0) {
2959
- translateLeft = 0;
3145
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
3146
+ __name: "PageBarScrollContainer",
3147
+ setup(__props) {
3148
+ const services = inject("services");
3149
+ const editorService = services?.editorService;
3150
+ const pageBar = ref();
3151
+ const itemsContainer = ref();
3152
+ const pageBarWidth = ref(0);
3153
+ const canScroll = ref(false);
3154
+ const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
3155
+ let translateLeft = 0;
3156
+ const resizeObserver = new ResizeObserver((entries) => {
3157
+ for (const { contentRect } of entries) {
3158
+ const { width } = contentRect;
3159
+ pageBarWidth.value = width || 0;
3160
+ setCanScroll();
2960
3161
  }
2961
- } else if (type === "right") {
2962
- translateLeft -= 100;
2963
- if (-translateLeft > maxScrollLeft) {
2964
- translateLeft = -maxScrollLeft;
3162
+ });
3163
+ const setCanScroll = () => {
3164
+ if (itemsContainer.value) {
3165
+ canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
2965
3166
  }
2966
- } else if (type === "start") {
2967
- translateLeft = 0;
2968
- } else if (type === "end") {
2969
- translateLeft = -maxScrollLeft;
2970
- }
2971
- itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
2972
- };
2973
- onMounted(() => {
2974
- pageBar.value && resizeObserver.observe(pageBar.value);
2975
- });
2976
- onUnmounted(() => {
2977
- resizeObserver.disconnect();
2978
- });
2979
- watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
2980
- setTimeout(() => {
2981
- setCanScroll();
2982
- if (length < preLength) {
2983
- scroll("start");
2984
- } else {
2985
- scroll("end");
3167
+ };
3168
+ const scroll = (type) => {
3169
+ if (!itemsContainer.value)
3170
+ return;
3171
+ const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
3172
+ if (type === "left") {
3173
+ translateLeft += 100;
3174
+ if (translateLeft > 0) {
3175
+ translateLeft = 0;
3176
+ }
3177
+ } else if (type === "right") {
3178
+ translateLeft -= 100;
3179
+ if (-translateLeft > maxScrollLeft) {
3180
+ translateLeft = -maxScrollLeft;
3181
+ }
3182
+ } else if (type === "start") {
3183
+ translateLeft = 0;
3184
+ } else if (type === "end") {
3185
+ translateLeft = -maxScrollLeft;
2986
3186
  }
3187
+ itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
3188
+ };
3189
+ onMounted(() => {
3190
+ pageBar.value && resizeObserver.observe(pageBar.value);
3191
+ });
3192
+ onUnmounted(() => {
3193
+ resizeObserver.disconnect();
2987
3194
  });
2988
- });
2989
- return {
2990
- pageBar,
2991
- itemsContainer,
2992
- canScroll,
2993
- itemsContainerWidth,
2994
- scroll
2995
- };
2996
- };
2997
- const _sfc_main$5 = defineComponent({
2998
- components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
2999
- setup() {
3000
- const services = inject("services");
3001
- const editorService = services?.editorService;
3002
3195
  const root = computed(() => editorService?.get("root"));
3003
- return {
3004
- Delete: markRaw(Delete),
3005
- DocumentCopy: markRaw(DocumentCopy),
3006
- ...useScroll(root),
3007
- root,
3008
- page: computed(() => editorService?.get("page")),
3009
- switchPage(page) {
3010
- editorService?.select(page);
3011
- },
3012
- addPage() {
3013
- if (!editorService)
3014
- return;
3015
- const pageConfig = {
3016
- type: NodeType.PAGE,
3017
- name: generatePageNameByApp(toRaw(editorService.get("root")))
3018
- };
3019
- editorService.add(pageConfig);
3020
- },
3021
- copy(node) {
3022
- node && editorService?.copy(node);
3023
- editorService?.paste({
3024
- left: 0,
3025
- top: 0
3026
- });
3027
- },
3028
- remove(node) {
3029
- editorService?.remove(node);
3030
- }
3196
+ watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
3197
+ setTimeout(() => {
3198
+ setCanScroll();
3199
+ if (length < preLength) {
3200
+ scroll("start");
3201
+ } else {
3202
+ scroll("end");
3203
+ }
3204
+ });
3205
+ });
3206
+ const addPage = () => {
3207
+ if (!editorService)
3208
+ return;
3209
+ const pageConfig = {
3210
+ type: NodeType.PAGE,
3211
+ name: generatePageNameByApp(toRaw(editorService.get("root")))
3212
+ };
3213
+ editorService.add(pageConfig);
3031
3214
  };
3032
- }
3033
- });
3034
- const _hoisted_1$2 = {
3035
- class: "m-editor-page-bar",
3036
- ref: "pageBar"
3037
- };
3038
- const _hoisted_2 = ["onClick"];
3039
- const _hoisted_3 = { class: "m-editor-page-bar-title" };
3040
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3041
- const _component_plus = resolveComponent("plus");
3042
- const _component_el_icon = resolveComponent("el-icon");
3043
- const _component_arrow_left_bold = resolveComponent("arrow-left-bold");
3044
- const _component_el_tooltip = resolveComponent("el-tooltip");
3045
- const _component_tool_button = resolveComponent("tool-button");
3046
- const _component_caret_bottom = resolveComponent("caret-bottom");
3047
- const _component_el_popover = resolveComponent("el-popover");
3048
- const _component_arrow_right_bold = resolveComponent("arrow-right-bold");
3049
- return openBlock(), createElementBlock("div", _hoisted_1$2, [
3050
- createElementVNode("div", {
3051
- id: "m-editor-page-bar-add-icon",
3052
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3053
- onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
3054
- }, [
3055
- createVNode(_component_el_icon, null, {
3056
- default: withCtx(() => [
3057
- createVNode(_component_plus)
3058
- ]),
3059
- _: 1
3060
- })
3061
- ]),
3062
- _ctx.canScroll ? (openBlock(), createElementBlock("div", {
3063
- key: 0,
3064
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3065
- onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
3066
- }, [
3067
- createVNode(_component_el_icon, null, {
3068
- default: withCtx(() => [
3069
- createVNode(_component_arrow_left_bold)
3215
+ return (_ctx, _cache) => {
3216
+ const _component_el_icon = resolveComponent("el-icon");
3217
+ return openBlock(), createElementBlock("div", {
3218
+ class: "m-editor-page-bar",
3219
+ ref_key: "pageBar",
3220
+ ref: pageBar
3221
+ }, [
3222
+ createElementVNode("div", {
3223
+ id: "m-editor-page-bar-add-icon",
3224
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3225
+ onClick: addPage
3226
+ }, [
3227
+ createVNode(_component_el_icon, null, {
3228
+ default: withCtx(() => [
3229
+ createVNode(unref(Plus))
3230
+ ]),
3231
+ _: 1
3232
+ })
3070
3233
  ]),
3071
- _: 1
3072
- })
3073
- ])) : createCommentVNode("", true),
3074
- _ctx.root ? (openBlock(), createElementBlock("div", {
3075
- key: 1,
3076
- class: "m-editor-page-bar-items",
3077
- ref: "itemsContainer",
3078
- style: normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
3079
- }, [
3080
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.root.items, (item) => {
3081
- return openBlock(), createElementBlock("div", {
3082
- key: item.key,
3083
- class: normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
3084
- onClick: ($event) => _ctx.switchPage(item)
3234
+ canScroll.value ? (openBlock(), createElementBlock("div", {
3235
+ key: 0,
3236
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3237
+ onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
3085
3238
  }, [
3086
- createElementVNode("div", _hoisted_3, [
3087
- renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3088
- createVNode(_component_el_tooltip, {
3089
- effect: "dark",
3090
- placement: "top-start",
3091
- content: item.name
3092
- }, {
3093
- default: withCtx(() => [
3094
- createElementVNode("span", null, toDisplayString(item.name), 1)
3095
- ]),
3096
- _: 2
3097
- }, 1032, ["content"])
3098
- ])
3099
- ]),
3100
- createVNode(_component_el_popover, {
3101
- "popper-class": "page-bar-popover",
3102
- placement: "top",
3103
- width: 160,
3104
- trigger: "hover"
3105
- }, {
3106
- reference: withCtx(() => [
3107
- createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3108
- default: withCtx(() => [
3109
- createVNode(_component_caret_bottom)
3110
- ]),
3111
- _: 1
3112
- })
3239
+ createVNode(_component_el_icon, null, {
3240
+ default: withCtx(() => [
3241
+ createVNode(unref(ArrowLeftBold))
3113
3242
  ]),
3243
+ _: 1
3244
+ })
3245
+ ])) : createCommentVNode("", true),
3246
+ unref(root) ? (openBlock(), createElementBlock("div", {
3247
+ key: 1,
3248
+ class: "m-editor-page-bar-items",
3249
+ ref_key: "itemsContainer",
3250
+ ref: itemsContainer,
3251
+ style: normalizeStyle(`width: ${unref(itemsContainerWidth)}px`)
3252
+ }, [
3253
+ renderSlot(_ctx.$slots, "default")
3254
+ ], 4)) : createCommentVNode("", true),
3255
+ canScroll.value ? (openBlock(), createElementBlock("div", {
3256
+ key: 2,
3257
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3258
+ onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
3259
+ }, [
3260
+ createVNode(_component_el_icon, null, {
3114
3261
  default: withCtx(() => [
3115
- createElementVNode("div", null, [
3116
- renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3117
- createVNode(_component_tool_button, {
3118
- data: {
3119
- type: "button",
3120
- text: "\u590D\u5236",
3121
- icon: _ctx.DocumentCopy,
3122
- handler: () => _ctx.copy(item)
3123
- }
3124
- }, null, 8, ["data"]),
3125
- createVNode(_component_tool_button, {
3126
- data: {
3127
- type: "button",
3128
- text: "\u5220\u9664",
3129
- icon: _ctx.Delete,
3130
- handler: () => _ctx.remove(item)
3131
- }
3132
- }, null, 8, ["data"])
3133
- ])
3134
- ])
3262
+ createVNode(unref(ArrowRightBold))
3135
3263
  ]),
3136
- _: 2
3137
- }, 1024)
3138
- ], 10, _hoisted_2);
3139
- }), 128))
3140
- ], 4)) : createCommentVNode("", true),
3141
- _ctx.canScroll ? (openBlock(), createElementBlock("div", {
3142
- key: 2,
3143
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3144
- onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
3145
- }, [
3146
- createVNode(_component_el_icon, null, {
3147
- default: withCtx(() => [
3148
- createVNode(_component_arrow_right_bold)
3149
- ]),
3150
- _: 1
3151
- })
3152
- ])) : createCommentVNode("", true)
3153
- ], 512);
3154
- }
3155
- var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
3156
-
3157
- class ScrollViewer$1 {
3158
- constructor(options) {
3159
- this.enter = false;
3160
- this.targetEnter = false;
3161
- this.keydown = false;
3162
- this.zoom = 1;
3163
- this.scrollLeft = 0;
3164
- this.scrollTop = 0;
3165
- this.x = 0;
3166
- this.y = 0;
3167
- this.resizeObserver = new ResizeObserver((entries) => {
3168
- for (const { contentRect } of entries) {
3169
- const { width, height } = contentRect;
3170
- const targetRect = this.target.getBoundingClientRect();
3171
- const targetWidth = targetRect.width * this.zoom;
3172
- const targetMarginTop = Number(this.target.style.marginTop) || 0;
3173
- const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3174
- if (targetWidth < width) {
3175
- this.target._left = 0;
3176
- }
3177
- if (targetHeight < height) {
3178
- this.target._top = 0;
3179
- }
3180
- this.scroll();
3181
- }
3182
- });
3183
- this.wheelHandler = (event) => {
3184
- if (this.targetEnter)
3185
- return;
3186
- const { deltaX, deltaY, currentTarget } = event;
3187
- if (currentTarget !== this.container)
3188
- return;
3189
- this.setScrollOffset(deltaX, deltaY);
3190
- this.scroll();
3191
- this.scrollLeft = this.target._left;
3192
- this.scrollTop = this.target._top;
3193
- };
3194
- this.mouseEnterHandler = () => {
3195
- this.enter = true;
3196
- };
3197
- this.mouseLeaveHandler = () => {
3198
- this.enter = false;
3199
- };
3200
- this.targetMouseEnterHandler = () => {
3201
- this.targetEnter = true;
3264
+ _: 1
3265
+ })
3266
+ ])) : createCommentVNode("", true)
3267
+ ], 512);
3202
3268
  };
3203
- this.targetMouseLeaveHandler = () => {
3204
- this.targetEnter = false;
3269
+ }
3270
+ });
3271
+
3272
+ const _hoisted_1$2 = ["onClick"];
3273
+ const _hoisted_2 = { class: "m-editor-page-bar-title" };
3274
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3275
+ __name: "PageBar",
3276
+ setup(__props) {
3277
+ const services = inject("services");
3278
+ const editorService = services?.editorService;
3279
+ const root = computed(() => editorService?.get("root"));
3280
+ const page = computed(() => editorService?.get("page"));
3281
+ const switchPage = (page2) => {
3282
+ editorService?.select(page2);
3205
3283
  };
3206
- this.mousedownHandler = (event) => {
3207
- if (!this.keydown)
3208
- return;
3209
- event.stopImmediatePropagation();
3210
- event.stopPropagation();
3211
- this.target.style.cursor = "grabbing";
3212
- this.x = event.clientX;
3213
- this.y = event.clientY;
3214
- document.addEventListener("mousemove", this.mousemoveHandler);
3215
- document.addEventListener("mouseup", this.mouseupHandler);
3284
+ const copy = (node) => {
3285
+ node && editorService?.copy(node);
3286
+ editorService?.paste({
3287
+ left: 0,
3288
+ top: 0
3289
+ });
3216
3290
  };
3217
- this.mouseupHandler = () => {
3218
- this.x = 0;
3219
- this.y = 0;
3220
- this.scrollLeft = this.target._left;
3221
- this.scrollTop = this.target._top;
3222
- this.removeHandler();
3291
+ const remove = (node) => {
3292
+ editorService?.remove(node);
3223
3293
  };
3224
- this.mousemoveHandler = (event) => {
3225
- event.stopImmediatePropagation();
3226
- event.stopPropagation();
3227
- const deltaX = event.clientX - this.x;
3228
- const deltaY = event.clientY - this.y;
3229
- this.setScrollOffset(deltaX, deltaY);
3230
- this.scroll();
3294
+ return (_ctx, _cache) => {
3295
+ const _component_el_tooltip = resolveComponent("el-tooltip");
3296
+ const _component_el_icon = resolveComponent("el-icon");
3297
+ const _component_el_popover = resolveComponent("el-popover");
3298
+ return openBlock(), createBlock(_sfc_main$6, null, {
3299
+ default: withCtx(() => [
3300
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
3301
+ return openBlock(), createElementBlock("div", {
3302
+ class: normalizeClass(["m-editor-page-bar-item", { active: unref(page)?.id === item.id }]),
3303
+ key: item.key,
3304
+ onClick: ($event) => switchPage(item)
3305
+ }, [
3306
+ createElementVNode("div", _hoisted_2, [
3307
+ renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3308
+ createVNode(_component_el_tooltip, {
3309
+ effect: "dark",
3310
+ placement: "top-start",
3311
+ content: item.name
3312
+ }, {
3313
+ default: withCtx(() => [
3314
+ createElementVNode("span", null, toDisplayString(item.name), 1)
3315
+ ]),
3316
+ _: 2
3317
+ }, 1032, ["content"])
3318
+ ])
3319
+ ]),
3320
+ createVNode(_component_el_popover, {
3321
+ "popper-class": "page-bar-popover",
3322
+ placement: "top",
3323
+ width: 160,
3324
+ trigger: "hover"
3325
+ }, {
3326
+ reference: withCtx(() => [
3327
+ createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3328
+ default: withCtx(() => [
3329
+ createVNode(unref(CaretBottom))
3330
+ ]),
3331
+ _: 1
3332
+ })
3333
+ ]),
3334
+ default: withCtx(() => [
3335
+ createElementVNode("div", null, [
3336
+ renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3337
+ createVNode(_sfc_main$f, {
3338
+ data: {
3339
+ type: "button",
3340
+ text: "\u590D\u5236",
3341
+ icon: unref(DocumentCopy),
3342
+ handler: () => copy(item)
3343
+ }
3344
+ }, null, 8, ["data"]),
3345
+ createVNode(_sfc_main$f, {
3346
+ data: {
3347
+ type: "button",
3348
+ text: "\u5220\u9664",
3349
+ icon: unref(Delete),
3350
+ handler: () => remove(item)
3351
+ }
3352
+ }, null, 8, ["data"])
3353
+ ])
3354
+ ])
3355
+ ]),
3356
+ _: 2
3357
+ }, 1024)
3358
+ ], 10, _hoisted_1$2);
3359
+ }), 128))
3360
+ ]),
3361
+ _: 3
3362
+ });
3231
3363
  };
3232
- this.keydownHandler = (event) => {
3233
- if (event.code === Keys.ESCAPE && this.enter) {
3234
- event.preventDefault();
3235
- event.stopImmediatePropagation();
3236
- event.stopPropagation();
3237
- }
3238
- if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3239
- return;
3364
+ }
3365
+ });
3366
+
3367
+ class ScrollViewer$1 {
3368
+ enter = false;
3369
+ targetEnter = false;
3370
+ keydown = false;
3371
+ container;
3372
+ target;
3373
+ zoom = 1;
3374
+ scrollLeft = 0;
3375
+ scrollTop = 0;
3376
+ x = 0;
3377
+ y = 0;
3378
+ resizeObserver = new ResizeObserver((entries) => {
3379
+ for (const { contentRect } of entries) {
3380
+ const { width, height } = contentRect;
3381
+ const targetRect = this.target.getBoundingClientRect();
3382
+ const targetWidth = targetRect.width * this.zoom;
3383
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3384
+ const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3385
+ if (targetWidth < width) {
3386
+ this.target._left = 0;
3240
3387
  }
3241
- this.keydown = true;
3242
- this.target.style.cursor = "grab";
3243
- this.container.addEventListener("mousedown", this.mousedownHandler);
3244
- };
3245
- this.keyupHandler = (event) => {
3246
- if (event.code !== Keys.ESCAPE || !this.keydown) {
3247
- return;
3388
+ if (targetHeight < height) {
3389
+ this.target._top = 0;
3248
3390
  }
3249
- event.preventDefault();
3250
- event.stopImmediatePropagation();
3251
- event.stopPropagation();
3252
- this.keydown = false;
3253
- event.preventDefault();
3254
- this.removeHandler();
3255
- };
3391
+ this.scroll();
3392
+ }
3393
+ });
3394
+ constructor(options) {
3256
3395
  this.container = options.container;
3257
3396
  this.target = options.target;
3258
3397
  this.zoom = options.zoom;
@@ -3288,6 +3427,79 @@ class ScrollViewer$1 {
3288
3427
  document.removeEventListener("mousemove", this.mousemoveHandler);
3289
3428
  document.removeEventListener("mouseup", this.mouseupHandler);
3290
3429
  }
3430
+ wheelHandler = (event) => {
3431
+ if (this.targetEnter)
3432
+ return;
3433
+ const { deltaX, deltaY, currentTarget } = event;
3434
+ if (currentTarget !== this.container)
3435
+ return;
3436
+ this.setScrollOffset(deltaX, deltaY);
3437
+ this.scroll();
3438
+ this.scrollLeft = this.target._left;
3439
+ this.scrollTop = this.target._top;
3440
+ };
3441
+ mouseEnterHandler = () => {
3442
+ this.enter = true;
3443
+ };
3444
+ mouseLeaveHandler = () => {
3445
+ this.enter = false;
3446
+ };
3447
+ targetMouseEnterHandler = () => {
3448
+ this.targetEnter = true;
3449
+ };
3450
+ targetMouseLeaveHandler = () => {
3451
+ this.targetEnter = false;
3452
+ };
3453
+ mousedownHandler = (event) => {
3454
+ if (!this.keydown)
3455
+ return;
3456
+ event.stopImmediatePropagation();
3457
+ event.stopPropagation();
3458
+ this.target.style.cursor = "grabbing";
3459
+ this.x = event.clientX;
3460
+ this.y = event.clientY;
3461
+ document.addEventListener("mousemove", this.mousemoveHandler);
3462
+ document.addEventListener("mouseup", this.mouseupHandler);
3463
+ };
3464
+ mouseupHandler = () => {
3465
+ this.x = 0;
3466
+ this.y = 0;
3467
+ this.scrollLeft = this.target._left;
3468
+ this.scrollTop = this.target._top;
3469
+ this.removeHandler();
3470
+ };
3471
+ mousemoveHandler = (event) => {
3472
+ event.stopImmediatePropagation();
3473
+ event.stopPropagation();
3474
+ const deltaX = event.clientX - this.x;
3475
+ const deltaY = event.clientY - this.y;
3476
+ this.setScrollOffset(deltaX, deltaY);
3477
+ this.scroll();
3478
+ };
3479
+ keydownHandler = (event) => {
3480
+ if (event.code === Keys.ESCAPE && this.enter) {
3481
+ event.preventDefault();
3482
+ event.stopImmediatePropagation();
3483
+ event.stopPropagation();
3484
+ }
3485
+ if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3486
+ return;
3487
+ }
3488
+ this.keydown = true;
3489
+ this.target.style.cursor = "grab";
3490
+ this.container.addEventListener("mousedown", this.mousedownHandler);
3491
+ };
3492
+ keyupHandler = (event) => {
3493
+ if (event.code !== Keys.ESCAPE || !this.keydown) {
3494
+ return;
3495
+ }
3496
+ event.preventDefault();
3497
+ event.stopImmediatePropagation();
3498
+ event.stopPropagation();
3499
+ this.keydown = false;
3500
+ event.preventDefault();
3501
+ this.removeHandler();
3502
+ };
3291
3503
  setScrollOffset(deltaX, deltaY) {
3292
3504
  const { width, height } = this.container.getBoundingClientRect();
3293
3505
  const targetRect = this.target.getBoundingClientRect();
@@ -3355,11 +3567,12 @@ const _sfc_main$4 = defineComponent({
3355
3567
  };
3356
3568
  }
3357
3569
  });
3570
+
3358
3571
  const _hoisted_1$1 = {
3359
3572
  class: "m-editor-scroll-viewer-container",
3360
3573
  ref: "container"
3361
3574
  };
3362
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3575
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3363
3576
  return openBlock(), createElementBlock("div", _hoisted_1$1, [
3364
3577
  createElementVNode("div", {
3365
3578
  ref: "el",
@@ -3369,170 +3582,172 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3369
3582
  ], 4)
3370
3583
  ], 512);
3371
3584
  }
3372
- var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
3585
+ const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
3373
3586
 
3374
- const _sfc_main$3 = defineComponent({
3375
- components: { ContentMenu },
3376
- setup() {
3587
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3588
+ __name: "ViewerMenu",
3589
+ props: {
3590
+ isMultiSelect: { type: Boolean, default: false }
3591
+ },
3592
+ setup(__props, { expose }) {
3593
+ const props = __props;
3377
3594
  const services = inject("services");
3378
3595
  const editorService = services?.editorService;
3379
3596
  const menu = ref();
3380
3597
  const canPaste = ref(false);
3381
3598
  const canCenter = ref(false);
3382
3599
  const node = computed(() => editorService?.get("node"));
3600
+ const nodes = computed(() => editorService?.get("nodes"));
3383
3601
  const parent = computed(() => editorService?.get("parent"));
3384
- const isPage = computed(() => node.value?.type === NodeType.PAGE);
3602
+ const stage = computed(() => editorService?.get("stage"));
3385
3603
  const stageContentMenu = inject("stageContentMenu", []);
3386
- onMounted(() => {
3387
- const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
3604
+ const menuData = reactive([
3605
+ {
3606
+ type: "button",
3607
+ text: "\u6C34\u5E73\u5C45\u4E2D",
3608
+ display: () => canCenter.value && !props.isMultiSelect,
3609
+ handler: () => {
3610
+ if (!node.value)
3611
+ return;
3612
+ editorService?.alignCenter(node.value);
3613
+ }
3614
+ },
3615
+ {
3616
+ type: "button",
3617
+ text: "\u590D\u5236",
3618
+ icon: markRaw(DocumentCopy),
3619
+ handler: () => {
3620
+ nodes.value && editorService?.copy(nodes.value);
3621
+ canPaste.value = true;
3622
+ }
3623
+ },
3624
+ {
3625
+ type: "button",
3626
+ text: "\u7C98\u8D34",
3627
+ display: () => canPaste.value,
3628
+ handler: () => {
3629
+ const rect = menu.value?.$el.getBoundingClientRect();
3630
+ const parentRect = stage.value?.container?.getBoundingClientRect();
3631
+ const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
3632
+ const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
3633
+ if (!nodes.value || nodes.value.length === 0)
3634
+ return;
3635
+ editorService?.paste({ left: initialLeft, top: initialTop });
3636
+ }
3637
+ },
3638
+ {
3639
+ type: "divider",
3640
+ direction: "horizontal",
3641
+ display: () => {
3642
+ if (!node.value)
3643
+ return false;
3644
+ return !isPage(node.value);
3645
+ }
3646
+ },
3647
+ {
3648
+ type: "button",
3649
+ text: "\u4E0A\u79FB\u4E00\u5C42",
3650
+ icon: markRaw(Top),
3651
+ display: () => !isPage(node.value) && !props.isMultiSelect,
3652
+ handler: () => {
3653
+ editorService?.moveLayer(1);
3654
+ }
3655
+ },
3656
+ {
3657
+ type: "button",
3658
+ text: "\u4E0B\u79FB\u4E00\u5C42",
3659
+ icon: markRaw(Bottom),
3660
+ display: () => !isPage(node.value) && !props.isMultiSelect,
3661
+ handler: () => {
3662
+ editorService?.moveLayer(-1);
3663
+ }
3664
+ },
3665
+ {
3666
+ type: "button",
3667
+ text: "\u7F6E\u9876",
3668
+ display: () => !isPage(node.value) && !props.isMultiSelect,
3669
+ handler: () => {
3670
+ editorService?.moveLayer(LayerOffset.TOP);
3671
+ }
3672
+ },
3673
+ {
3674
+ type: "button",
3675
+ text: "\u7F6E\u5E95",
3676
+ display: () => !isPage(node.value) && !props.isMultiSelect,
3677
+ handler: () => {
3678
+ editorService?.moveLayer(LayerOffset.BOTTOM);
3679
+ }
3680
+ },
3681
+ {
3682
+ type: "divider",
3683
+ direction: "horizontal",
3684
+ display: () => !isPage(node.value) && !props.isMultiSelect
3685
+ },
3686
+ {
3687
+ type: "button",
3688
+ text: "\u5220\u9664",
3689
+ icon: Delete,
3690
+ display: () => !isPage(node.value),
3691
+ handler: () => {
3692
+ nodes.value && editorService?.remove(nodes.value);
3693
+ }
3694
+ },
3695
+ {
3696
+ type: "divider",
3697
+ direction: "horizontal"
3698
+ },
3699
+ {
3700
+ type: "button",
3701
+ text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
3702
+ handler: () => {
3703
+ editorService?.get("stage").clearGuides();
3704
+ }
3705
+ },
3706
+ ...stageContentMenu
3707
+ ]);
3708
+ onMounted(async () => {
3709
+ const data = await storageService.getItem(COPY_STORAGE_KEY);
3388
3710
  canPaste.value = data !== "undefined" && !!data;
3389
3711
  });
3390
3712
  watch(parent, async () => {
3391
3713
  if (!parent.value || !editorService)
3392
3714
  return canCenter.value = false;
3393
3715
  const layout = await editorService.getLayout(parent.value);
3394
- canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${node.value?.type}`);
3716
+ const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
3717
+ const isTypeConform = nodes.value?.every((selectedNode) => ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
3718
+ canCenter.value = isLayoutConform && !!isTypeConform;
3395
3719
  }, { immediate: true });
3396
- return {
3397
- menu,
3398
- menuData: reactive([
3399
- {
3400
- type: "button",
3401
- text: "\u6C34\u5E73\u5C45\u4E2D",
3402
- display: () => canCenter.value,
3403
- handler: () => {
3404
- node.value && editorService?.alignCenter(node.value);
3405
- }
3406
- },
3407
- {
3408
- type: "button",
3409
- text: "\u590D\u5236",
3410
- icon: markRaw(DocumentCopy),
3411
- handler: () => {
3412
- node.value && editorService?.copy(node.value);
3413
- canPaste.value = true;
3414
- }
3415
- },
3416
- {
3417
- type: "button",
3418
- text: "\u7C98\u8D34",
3419
- display: () => canPaste.value,
3420
- handler: () => {
3421
- const stage = editorService?.get("stage");
3422
- const rect = menu.value?.$el.getBoundingClientRect();
3423
- const parentRect = stage?.container?.getBoundingClientRect();
3424
- let left = (rect?.left || 0) - (parentRect?.left || 0);
3425
- let top = (rect?.top || 0) - (parentRect?.top || 0);
3426
- if (node.value?.items && stage) {
3427
- const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
3428
- const parentElRect = parentEl?.getBoundingClientRect();
3429
- left = left - (parentElRect?.left || 0);
3430
- top = top - (parentElRect?.top || 0);
3431
- }
3432
- editorService?.paste({ left, top });
3433
- }
3434
- },
3435
- {
3436
- type: "divider",
3437
- direction: "horizontal",
3438
- display: () => !isPage.value
3439
- },
3440
- {
3441
- type: "button",
3442
- text: "\u4E0A\u79FB\u4E00\u5C42",
3443
- icon: markRaw(Top),
3444
- display: () => !isPage.value,
3445
- handler: () => {
3446
- editorService?.moveLayer(1);
3447
- }
3448
- },
3449
- {
3450
- type: "button",
3451
- text: "\u4E0B\u79FB\u4E00\u5C42",
3452
- icon: markRaw(Bottom),
3453
- display: () => !isPage.value,
3454
- handler: () => {
3455
- editorService?.moveLayer(-1);
3456
- }
3457
- },
3458
- {
3459
- type: "button",
3460
- text: "\u7F6E\u9876",
3461
- display: () => !isPage.value,
3462
- handler: () => {
3463
- editorService?.moveLayer(LayerOffset.TOP);
3464
- }
3465
- },
3466
- {
3467
- type: "button",
3468
- text: "\u7F6E\u5E95",
3469
- display: () => !isPage.value,
3470
- handler: () => {
3471
- editorService?.moveLayer(LayerOffset.BOTTOM);
3472
- }
3473
- },
3474
- {
3475
- type: "divider",
3476
- direction: "horizontal",
3477
- display: () => !isPage.value
3478
- },
3479
- {
3480
- type: "button",
3481
- text: "\u5220\u9664",
3482
- icon: Delete,
3483
- display: () => !isPage.value,
3484
- handler: () => {
3485
- node.value && editorService?.remove(node.value);
3486
- }
3487
- },
3488
- {
3489
- type: "divider",
3490
- direction: "horizontal"
3491
- },
3492
- {
3493
- type: "button",
3494
- text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
3495
- handler: () => {
3496
- editorService?.get("stage").clearGuides();
3497
- }
3498
- },
3499
- ...stageContentMenu
3500
- ]),
3501
- show(e) {
3502
- menu.value?.show(e);
3503
- }
3720
+ const show = (e) => {
3721
+ menu.value?.show(e);
3722
+ };
3723
+ expose({ show });
3724
+ return (_ctx, _cache) => {
3725
+ return openBlock(), createBlock(_sfc_main$b, {
3726
+ "menu-data": menuData,
3727
+ ref_key: "menu",
3728
+ ref: menu
3729
+ }, null, 8, ["menu-data"]);
3504
3730
  };
3505
3731
  }
3506
3732
  });
3507
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3508
- const _component_content_menu = resolveComponent("content-menu");
3509
- return openBlock(), createBlock(_component_content_menu, {
3510
- "menu-data": _ctx.menuData,
3511
- ref: "menu"
3512
- }, null, 8, ["menu-data"]);
3513
- }
3514
- var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
3515
3733
 
3516
- const _sfc_main$2 = defineComponent({
3517
- name: "magic-stage",
3518
- components: {
3519
- ViewerMenu,
3520
- ScrollViewer
3521
- },
3522
- setup() {
3734
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3735
+ __name: "Stage",
3736
+ setup(__props) {
3737
+ let stage = null;
3738
+ let runtime = null;
3523
3739
  const services = inject("services");
3524
3740
  const stageOptions = inject("stageOptions");
3525
3741
  const stageWrap = ref();
3526
3742
  const stageContainer = ref();
3527
3743
  const menu = ref();
3744
+ const isMultiSelect = computed(() => services?.editorService.get("nodes")?.length > 1);
3528
3745
  const stageRect = computed(() => services?.uiService.get("stageRect"));
3529
3746
  const uiSelectMode = computed(() => services?.uiService.get("uiSelectMode"));
3530
3747
  const root = computed(() => services?.editorService.get("root"));
3531
3748
  const page = computed(() => services?.editorService.get("page"));
3532
3749
  const zoom = computed(() => services?.uiService.get("zoom") || 1);
3533
3750
  const node = computed(() => services?.editorService.get("node"));
3534
- let stage = null;
3535
- let runtime = null;
3536
3751
  const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
3537
3752
  watchEffect(() => {
3538
3753
  if (stage)
@@ -3572,6 +3787,9 @@ const _sfc_main$2 = defineComponent({
3572
3787
  stage?.on("highlight", (el) => {
3573
3788
  services?.editorService.highlight(el.id);
3574
3789
  });
3790
+ stage?.on("multiSelect", (els) => {
3791
+ services?.editorService.multiSelect(els.map((el) => el.id));
3792
+ });
3575
3793
  stage?.on("update", (ev) => {
3576
3794
  if (ev.parentEl) {
3577
3795
  services?.editorService.moveToContainer({ id: ev.el.id, style: ev.style }, ev.parentEl.id);
@@ -3630,100 +3848,96 @@ const _sfc_main$2 = defineComponent({
3630
3848
  resizeObserver.disconnect();
3631
3849
  services?.editorService.set("stage", null);
3632
3850
  });
3633
- return {
3634
- stageWrap,
3635
- stageContainer,
3636
- menu,
3637
- stageRect,
3638
- zoom,
3639
- contextmenuHandler(e2) {
3640
- e2.preventDefault();
3641
- menu.value?.show(e2);
3642
- },
3643
- dragoverHandler(e2) {
3644
- e2.preventDefault();
3645
- if (e2.dataTransfer) {
3646
- e2.dataTransfer.dropEffect = "move";
3647
- }
3648
- },
3649
- async dropHandler(e) {
3650
- e.preventDefault();
3651
- const doc = stage?.renderer.contentWindow?.document;
3652
- const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
3653
- let parent = page.value;
3654
- if (parentEl) {
3655
- parent = services?.editorService.getNodeById(parentEl.id, false);
3656
- }
3657
- if (e.dataTransfer && parent && stageContainer.value && stage) {
3658
- const config = eval(`(${e.dataTransfer.getData("data")})`);
3659
- const layout = await services?.editorService.getLayout(parent);
3660
- const containerRect = stageContainer.value.getBoundingClientRect();
3661
- const { scrollTop, scrollLeft } = stage.mask;
3662
- const { style = {} } = config;
3663
- let top = 0;
3664
- let left = 0;
3665
- let position = "relative";
3666
- if (layout === Layout.ABSOLUTE) {
3667
- position = "absolute";
3668
- top = e.clientY - containerRect.top + scrollTop;
3669
- left = e.clientX - containerRect.left + scrollLeft;
3670
- if (parentEl && doc) {
3671
- const { left: parentLeft, top: parentTop } = getOffset(parentEl);
3672
- left = left - calcValueByFontsize(doc, parentLeft);
3673
- top = top - calcValueByFontsize(doc, parentTop);
3674
- }
3851
+ const contextmenuHandler = (e2) => {
3852
+ e2.preventDefault();
3853
+ menu.value?.show(e2);
3854
+ };
3855
+ const dragoverHandler = (e2) => {
3856
+ e2.preventDefault();
3857
+ if (e2.dataTransfer) {
3858
+ e2.dataTransfer.dropEffect = "move";
3859
+ }
3860
+ };
3861
+ const dropHandler = async (e) => {
3862
+ e.preventDefault();
3863
+ const doc = stage?.renderer.contentWindow?.document;
3864
+ const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
3865
+ let parent = page.value;
3866
+ if (parentEl) {
3867
+ parent = services?.editorService.getNodeById(parentEl.id, false);
3868
+ }
3869
+ if (e.dataTransfer && parent && stageContainer.value && stage) {
3870
+ const config = eval(`(${e.dataTransfer.getData("data")})`);
3871
+ const layout = await services?.editorService.getLayout(parent);
3872
+ const containerRect = stageContainer.value.getBoundingClientRect();
3873
+ const { scrollTop, scrollLeft } = stage.mask;
3874
+ const { style = {} } = config;
3875
+ let top = 0;
3876
+ let left = 0;
3877
+ let position = "relative";
3878
+ if (layout === Layout.ABSOLUTE) {
3879
+ position = "absolute";
3880
+ top = e.clientY - containerRect.top + scrollTop;
3881
+ left = e.clientX - containerRect.left + scrollLeft;
3882
+ if (parentEl && doc) {
3883
+ const { left: parentLeft, top: parentTop } = getOffset(parentEl);
3884
+ left = left - calcValueByFontsize(doc, parentLeft);
3885
+ top = top - calcValueByFontsize(doc, parentTop);
3675
3886
  }
3676
- config.style = {
3677
- ...style,
3678
- position,
3679
- top,
3680
- left
3681
- };
3682
- config.inputEvent = e;
3683
- services?.editorService.add(config, parent);
3684
3887
  }
3888
+ config.style = {
3889
+ ...style,
3890
+ position,
3891
+ top,
3892
+ left
3893
+ };
3894
+ config.inputEvent = e;
3895
+ services?.editorService.add(config, parent);
3685
3896
  }
3686
3897
  };
3898
+ return (_ctx, _cache) => {
3899
+ return openBlock(), createBlock(ScrollViewer, {
3900
+ class: "m-editor-stage",
3901
+ ref_key: "stageWrap",
3902
+ ref: stageWrap,
3903
+ width: unref(stageRect)?.width,
3904
+ height: unref(stageRect)?.height,
3905
+ zoom: unref(zoom)
3906
+ }, {
3907
+ default: withCtx(() => [
3908
+ createElementVNode("div", {
3909
+ class: "m-editor-stage-container",
3910
+ ref_key: "stageContainer",
3911
+ ref: stageContainer,
3912
+ style: normalizeStyle(`transform: scale(${unref(zoom)})`),
3913
+ onContextmenu: contextmenuHandler,
3914
+ onDrop: dropHandler,
3915
+ onDragover: dragoverHandler
3916
+ }, null, 36),
3917
+ (openBlock(), createBlock(Teleport, { to: "body" }, [
3918
+ createVNode(_sfc_main$3, {
3919
+ ref_key: "menu",
3920
+ ref: menu,
3921
+ "is-multi-select": unref(isMultiSelect)
3922
+ }, null, 8, ["is-multi-select"])
3923
+ ]))
3924
+ ]),
3925
+ _: 1
3926
+ }, 8, ["width", "height", "zoom"]);
3927
+ };
3687
3928
  }
3688
3929
  });
3689
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3690
- const _component_viewer_menu = resolveComponent("viewer-menu");
3691
- const _component_scroll_viewer = resolveComponent("scroll-viewer");
3692
- return openBlock(), createBlock(_component_scroll_viewer, {
3693
- class: "m-editor-stage",
3694
- ref: "stageWrap",
3695
- width: _ctx.stageRect?.width,
3696
- height: _ctx.stageRect?.height,
3697
- zoom: _ctx.zoom
3698
- }, {
3699
- default: withCtx(() => [
3700
- createElementVNode("div", {
3701
- class: "m-editor-stage-container",
3702
- ref: "stageContainer",
3703
- style: normalizeStyle(`transform: scale(${_ctx.zoom})`),
3704
- onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
3705
- onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
3706
- onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
3707
- }, null, 36),
3708
- (openBlock(), createBlock(Teleport, { to: "body" }, [
3709
- createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
3710
- ]))
3711
- ]),
3712
- _: 1
3713
- }, 8, ["width", "height", "zoom"]);
3714
- }
3715
- var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
3716
3930
 
3717
3931
  const _sfc_main$1 = defineComponent({
3718
3932
  name: "m-editor-workspace",
3719
3933
  components: {
3720
- PageBar,
3721
- MagicStage
3934
+ PageBar: _sfc_main$5,
3935
+ MagicStage: _sfc_main$2
3722
3936
  },
3723
3937
  setup() {
3724
3938
  const services = inject("services");
3725
3939
  const workspace = ref();
3726
- const node = computed(() => services?.editorService.get("node"));
3940
+ const nodes = computed(() => services?.editorService.get("nodes"));
3727
3941
  let keycon;
3728
3942
  const mouseenterHandler = () => {
3729
3943
  workspace.value?.focus();
@@ -3739,26 +3953,26 @@ const _sfc_main$1 = defineComponent({
3739
3953
  const ctrl = isMac ? "meta" : "ctrl";
3740
3954
  keycon.keyup("delete", (e) => {
3741
3955
  e.inputEvent.preventDefault();
3742
- if (!node.value || isPage(node.value))
3956
+ if (!nodes.value || isPage(nodes.value[0]))
3743
3957
  return;
3744
- services?.editorService.remove(node.value);
3958
+ services?.editorService.remove(nodes.value);
3745
3959
  }).keyup("backspace", (e) => {
3746
3960
  e.inputEvent.preventDefault();
3747
- if (!node.value || isPage(node.value))
3961
+ if (!nodes.value || isPage(nodes.value[0]))
3748
3962
  return;
3749
- services?.editorService.remove(node.value);
3963
+ services?.editorService.remove(nodes.value);
3750
3964
  }).keydown([ctrl, "c"], (e) => {
3751
3965
  e.inputEvent.preventDefault();
3752
- node.value && services?.editorService.copy(node.value);
3966
+ nodes.value && services?.editorService.copy(nodes.value);
3753
3967
  }).keydown([ctrl, "v"], (e) => {
3754
3968
  e.inputEvent.preventDefault();
3755
- node.value && services?.editorService.paste();
3969
+ nodes.value && services?.editorService.paste();
3756
3970
  }).keydown([ctrl, "x"], (e) => {
3757
3971
  e.inputEvent.preventDefault();
3758
- if (!node.value || isPage(node.value))
3972
+ if (!nodes.value || isPage(nodes.value[0]))
3759
3973
  return;
3760
- services?.editorService.copy(node.value);
3761
- services?.editorService.remove(node.value);
3974
+ services?.editorService.copy(nodes.value);
3975
+ services?.editorService.remove(nodes.value);
3762
3976
  }).keydown([ctrl, "z"], (e) => {
3763
3977
  e.inputEvent.preventDefault();
3764
3978
  services?.editorService.undo();
@@ -3820,6 +4034,7 @@ const _sfc_main$1 = defineComponent({
3820
4034
  };
3821
4035
  }
3822
4036
  });
4037
+
3823
4038
  const _hoisted_1 = {
3824
4039
  class: "m-editor-workspace",
3825
4040
  tabindex: "1",
@@ -3844,14 +4059,14 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3844
4059
  })
3845
4060
  ], 512);
3846
4061
  }
3847
- var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4062
+ const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
3848
4063
 
3849
4064
  class ComponentList extends BaseService {
4065
+ state = reactive({
4066
+ list: []
4067
+ });
3850
4068
  constructor() {
3851
4069
  super([]);
3852
- this.state = reactive({
3853
- list: []
3854
- });
3855
4070
  }
3856
4071
  setList(componentGroupList) {
3857
4072
  this.state.list = componentGroupList;
@@ -3860,7 +4075,7 @@ class ComponentList extends BaseService {
3860
4075
  return this.state.list;
3861
4076
  }
3862
4077
  }
3863
- var componentListService = new ComponentList();
4078
+ const componentListService = new ComponentList();
3864
4079
 
3865
4080
  const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3866
4081
  const MIN_LEFT_COLUMN_WIDTH = 45;
@@ -3980,7 +4195,7 @@ class Ui extends BaseService {
3980
4195
  return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
3981
4196
  }
3982
4197
  }
3983
- var uiService = new Ui();
4198
+ const uiService = new Ui();
3984
4199
 
3985
4200
  const _sfc_main = defineComponent({
3986
4201
  name: "m-editor",
@@ -4110,7 +4325,8 @@ const _sfc_main = defineComponent({
4110
4325
  historyService,
4111
4326
  propsService,
4112
4327
  editorService,
4113
- uiService
4328
+ uiService,
4329
+ storageService
4114
4330
  };
4115
4331
  provide("services", services);
4116
4332
  provide("layerContentMenu", props.layerContentMenu);
@@ -4129,6 +4345,7 @@ const _sfc_main = defineComponent({
4129
4345
  return services;
4130
4346
  }
4131
4347
  });
4348
+
4132
4349
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4133
4350
  const _component_nav_menu = resolveComponent("nav-menu");
4134
4351
  const _component_sidebar = resolveComponent("sidebar");
@@ -4189,23 +4406,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4189
4406
  _: 3
4190
4407
  }, 8, ["code-options"]);
4191
4408
  }
4192
- var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
4409
+ const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
4193
4410
 
4194
- var index$1 = /* #__PURE__ */ (() => ".m-editor-nav-menu {\n display: flex;\n z-index: 5;\n -webkit-box-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n align-items: center;\n background-color: #ffffff;\n font-size: 19.2px;\n color: #070303;\n font-weight: 400;\n box-sizing: border-box;\n margin: 0px;\n flex: 0 0 35px;\n border-bottom: 1px solid #d8dee8;\n}\n.m-editor-nav-menu > div {\n display: flex;\n height: 100%;\n z-index: 1;\n align-items: center;\n}\n.m-editor-nav-menu .menu-center {\n justify-content: center;\n}\n.m-editor-nav-menu .menu-right {\n justify-content: flex-end;\n}\n.m-editor-nav-menu .menu-item {\n flex-direction: row;\n -webkit-box-align: center;\n align-items: center;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1;\n height: 100%;\n color: rgba(255, 255, 255, 0.7);\n box-sizing: inherit;\n z-index: 1;\n display: flex !important;\n transition: all 0.3s ease 0s;\n border-bottom: 2px solid transparent;\n margin: 0;\n}\n.m-editor-nav-menu .menu-item .is-disabled {\n opacity: 0.5;\n}\n.m-editor-nav-menu .menu-item .is-text {\n padding: 5px;\n}\n.m-editor-nav-menu .menu-item .is-text,\n.m-editor-nav-menu .menu-item i {\n color: #070303;\n}\n.m-editor-nav-menu .menu-item .icon {\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n height: 100%;\n padding: 0px 8px;\n}\n.m-editor-nav-menu .menu-item .menu-item-text {\n color: #070303;\n}\n.m-editor {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.m-editor-content {\n width: 100%;\n height: calc(100% - 35px);\n display: flex;\n justify-self: space-between;\n}\n.m-editor-framework-center {\n position: relative;\n transform: translateZ(0);\n flex: 1;\n}\n.m-editor-framework-left {\n background-color: #ffffff;\n}\n.m-editor-framework-center .el-scrollbar__view {\n height: 100%;\n min-height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-empty-panel {\n display: flex;\n flex: 1;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: calc(100% - 32px);\n}\n.m-editor-empty-content {\n display: flex;\n justify-content: space-evenly;\n flex-direction: row;\n width: 100%;\n}\n.m-editor-empty-button {\n border: 3px solid rgba(0, 0, 0, 0.2);\n padding: 10px 40px;\n color: rgba(0, 0, 0, 0.6);\n cursor: pointer;\n}\n.m-editor-empty-button i {\n height: 180px;\n line-height: 180px;\n font-size: 100px;\n}\n.m-editor-empty-button p {\n text-align: center;\n font-size: 20px;\n margin-top: 5px;\n}\n.m-editor-empty-button:hover {\n border-color: #2882e0;\n color: #2882e0;\n}\n.m-editor-sidebar {\n height: 100%;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header {\n background: #2882e0;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header.is-left {\n width: 40px;\n margin-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav-wrap {\n margin: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav {\n border: 0;\n border-radius: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .tab-label {\n margin-left: 2px;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left {\n line-height: 15px;\n border: 0;\n height: auto;\n padding: 8px;\n color: rgb(255, 255, 255);\n box-sizing: border-box;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active {\n background: #ffffff;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active i {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active .magic-editor-tab-panel-title {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left:first-child {\n border-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i {\n font-size: 25px;\n color: rgba(255, 255, 255, 0.6);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i:hover {\n color: rgb(255, 255, 255);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .magic-editor-tab-panel-title {\n font-size: 12px;\n white-space: normal;\n}\n.m-editor-sidebar .el-scrollbar {\n height: 100%;\n}\n.m-editor-sidebar .el-tree {\n min-height: 100%;\n}\n.m-editor-sidebar .fold-icon {\n position: absolute;\n bottom: 8px;\n left: 0px;\n width: 45px;\n padding-left: 8px;\n color: #fff;\n font-size: 32px;\n opacity: 0.8;\n cursor: pointer;\n}\n.m-editor-sidebar .fold-icon:hover {\n background: rgba(0, 0, 0, 0.2);\n}\n.m-editor-sidebar .el-tabs__content,\n.m-editor-sidebar .el-tab-pane {\n height: 100%;\n}\n.magic-editor-layer-panel {\n background: #ffffff;\n}\n.magic-editor-layer-panel .search-input {\n background: #ffffff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.magic-editor-layer-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.magic-editor-layer-panel .node-content {\n flex: 1;\n display: flex;\n width: 100%;\n}\n.magic-editor-layer-panel .node-content > div {\n width: 8px;\n}\n.magic-editor-layer-panel .node-content > span {\n width: calc(100% - 68px);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.magic-editor-layer-panel .node-content > i {\n margin-right: 10px;\n font-size: 20px;\n}\n.magic-editor-layer-panel .node-content > i.lock {\n color: #bbb;\n}\n.magic-editor-layer-panel,\n.magic-editor-layer-panel .el-tree {\n background-color: #ffffff;\n color: #313a40;\n}\n.magic-editor-layer-panel .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.magic-editor-layer-panel .cus-tree-node {\n width: 100%;\n overflow: hidden;\n}\n.magic-editor-layer-panel .cus-tree-node-hover {\n background-color: #f3f5f9;\n width: 100%;\n}\n.magic-editor-layer-panel .el-tree-node:focus > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.ui-tree-tip {\n width: 100%;\n height: 25px;\n margin-left: 10px;\n background: #ffffff;\n font-style: italic;\n color: #555554;\n position: absolute;\n top: 40px;\n left: 0;\n z-index: 1;\n}\n.ui-component-panel {\n height: 100%;\n border-top: 0 !important;\n margin-top: 50px;\n background-color: #ffffff;\n}\n.ui-component-panel .search-input {\n background: #f8fbff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n box-sizing: border-box;\n z-index: 1;\n}\n.ui-component-panel .search-input .el-input__prefix {\n padding: 10px;\n}\n.ui-component-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.ui-component-panel .el-collapse-item > div:first-of-type {\n border-bottom: 1px solid #d9dbdd;\n margin-bottom: 10px;\n}\n.ui-component-panel .el-collapse-item__header {\n background: #ffffff;\n color: #070303;\n height: 25px;\n line-height: 25px;\n padding-left: 10px;\n font-size: 12px;\n}\n.ui-component-panel .el-collapse-item__header i {\n margin-right: 5px;\n font-size: 14px;\n}\n.ui-component-panel .el-collapse-item__wrap {\n background: #ffffff;\n border-bottom: 0;\n}\n.ui-component-panel .el-collapse-item__wrap .el-collapse-item__content {\n padding: 10px;\n display: flex;\n flex-wrap: wrap;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item {\n display: flex;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 5px 10px;\n box-sizing: border-box;\n color: #070303;\n flex-direction: column;\n width: 42px;\n cursor: pointer;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i {\n font-size: 20px;\n background: #fff;\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 5px;\n color: #909090;\n border: 1px solid #d9dbdd;\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n margin-bottom: 5px;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i:hover {\n background: #2882e0;\n color: #fff;\n border-color: #4e8be1;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item span {\n font-size: 12px;\n text-align: center;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item .el-tooltip {\n width: 50px;\n height: 30px;\n line-height: 15px;\n display: block;\n white-space: normal;\n margin: 0;\n}\n.m-editor-resizer {\n border-left: 1px solid transparent;\n border-right: 1px solid transparent;\n width: 8px;\n margin: 0 -5px;\n height: 100%;\n opacity: 0.9;\n background: padding-box #d8dee8;\n box-sizing: border-box;\n cursor: col-resize;\n z-index: 1;\n}\n.m-editor-resizer:hover {\n border-color: #d8dee8;\n}\n.m-editor-resizer .icon-container {\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.4s;\n width: 20px;\n height: 120px;\n line-height: 120px;\n text-align: center;\n background: #d8dee8;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n cursor: pointer;\n}\n.m-editor-resizer .icon-container.position-left {\n transform: translate(calc(-100% - 4px), -50%);\n}\n.m-editor-resizer .icon-container.position-right {\n transform: translate(calc(100% + 4px), -50%);\n}\n.m-editor-resizer .icon {\n color: #fff;\n font-size: 18px;\n}\n.magic-editor-resizer:hover .icon-container {\n visibility: visible;\n opacity: 1;\n}\n.m-editor-workspace {\n height: 100%;\n width: 100%;\n user-select: none;\n}\n.m-editor-workspace:focus-visible {\n outline: 0;\n}\n.m-editor-page-bar {\n position: fixed;\n bottom: 0;\n left: 0;\n display: flex;\n width: 100%;\n height: 32px;\n line-height: 32px;\n color: #070303;\n background-color: #f3f3f3;\n border-top: 1px solid #d9dbdd;\n z-index: 2;\n overflow: hidden;\n}\n.m-editor-page-bar-items {\n display: flex;\n transition: transform 0.3s;\n}\n.m-editor-page-bar-item {\n padding: 0 10px;\n cursor: pointer;\n border-right: 1px solid #d9dbdd;\n display: flex;\n justify-items: center;\n align-items: center;\n background-color: #f3f3f3;\n white-space: nowrap;\n}\n.m-editor-page-bar-item.active {\n background-color: #fff;\n cursor: text;\n}\n.m-editor-page-bar-item.active .m-editor-page-bar-menu-icon {\n cursor: pointer;\n}\n.m-editor-page-bar-item-icon {\n position: relative;\n z-index: 1;\n}\n.m-editor-page-bar-item-title {\n max-width: 150px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n.page-bar-popover.el-popper.el-popover {\n padding: 10px 0;\n}\n.page-bar-popover .menu-item {\n cursor: pointer;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n}\n.page-bar-popover .menu-item .el-button--text,\n.page-bar-popover .menu-item i {\n color: #070303;\n}\n.page-bar-popover .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-props-panel {\n padding: 0 10px;\n}\n.m-editor-props-panel.small .el-form-item__label {\n font-size: 12px;\n}\n.m-editor-props-panel.small .m-fieldset legend {\n font-size: 12px;\n}\n.m-editor-props-panel.small .el-tabs__item {\n font-size: 12px;\n}\n.m-editor-props-panel .el-input__wrapper {\n border-radius: 0;\n}\n.m-editor-props-panel-popper.small span,\n.m-editor-props-panel-popper.small a,\n.m-editor-props-panel-popper.small p {\n font-size: 12px;\n}\n.magic-editor-content-menu {\n position: fixed;\n font-size: 12px;\n background: #fff;\n box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);\n z-index: 9999;\n transform-origin: 0% 0%;\n font-weight: 600;\n padding: 4px 0px;\n overflow: auto;\n max-height: 100%;\n}\n.magic-editor-content-menu .menu-item {\n color: #333;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n min-width: 140px;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n border-left: 2px solid transparent;\n}\n.magic-editor-content-menu .menu-item .el-button {\n width: 100%;\n justify-content: flex-start;\n}\n.magic-editor-content-menu .menu-item .el-button--text,\n.magic-editor-content-menu .menu-item i {\n color: #070303;\n}\n.magic-editor-content-menu .menu-item.divider {\n padding: 0 14px;\n}\n.magic-editor-content-menu .menu-item.divider .el-divider {\n margin: 0;\n}\n.magic-editor-content-menu .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-stage {\n position: relative;\n width: 100%;\n height: calc(100% - 32px);\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-stage-container {\n width: 100%;\n height: 100%;\n z-index: 0;\n position: relative;\n transition: transform 0.3s;\n box-sizing: content-box;\n box-shadow: rgba(0, 0, 0, 0.04) 0px 3px 5px;\n}\n.m-editor-stage-container::-webkit-scrollbar {\n width: 0 !important;\n}\n.magic-code-editor {\n width: 100%;\n}\n.magic-code-editor .margin {\n margin: 0;\n}")();
4411
+ const index$1 = '';
4195
4412
 
4196
4413
  const defaultInstallOpt = {};
4197
- var index = {
4414
+ const index = {
4198
4415
  install: (app, opt) => {
4199
4416
  const option = Object.assign(defaultInstallOpt, opt || {});
4200
4417
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4201
4418
  setConfig(option);
4202
4419
  app.component(Editor.name, Editor);
4203
- app.component(uiSelect.name, uiSelect);
4420
+ app.component("m-fields-ui-select", _sfc_main$l);
4204
4421
  app.component(CodeLink.name, CodeLink);
4205
4422
  app.component(Code.name, Code);
4206
4423
  app.component(CodeEditor.name, CodeEditor);
4207
4424
  }
4208
4425
  };
4209
4426
 
4210
- export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, generatePageName, generatePageNameByApp, getConfig, getDefaultPropsValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, uiService, warn };
4211
- //# sourceMappingURL=tmagic-editor.es.js.map
4427
+ export { COPY_STORAGE_KEY, ComponentListPanel, DEFAULT_CONFIG, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, Keys, LayerOffset, LayerPanel, Layout, PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$f as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, warn };
4428
+ //# sourceMappingURL=tmagic-editor.mjs.map