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

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 (105) hide show
  1. package/dist/style.css +5 -1
  2. package/dist/{tmagic-editor.es.js → tmagic-editor.mjs} +1405 -1190
  3. package/dist/tmagic-editor.mjs.map +1 -0
  4. package/dist/tmagic-editor.umd.js +1420 -1204
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/package.json +21 -19
  7. package/src/Editor.vue +23 -15
  8. package/src/components/ContentMenu.vue +87 -99
  9. package/src/components/Icon.vue +1 -1
  10. package/src/components/ScrollViewer.vue +2 -2
  11. package/src/components/ToolButton.vue +150 -167
  12. package/src/fields/UISelect.vue +49 -70
  13. package/src/index.ts +2 -1
  14. package/src/layouts/AddPageBox.vue +2 -2
  15. package/src/layouts/Framework.vue +1 -1
  16. package/src/layouts/NavMenu.vue +2 -2
  17. package/src/layouts/PropsPanel.vue +1 -1
  18. package/src/layouts/Resizer.vue +1 -1
  19. package/src/layouts/sidebar/ComponentListPanel.vue +6 -17
  20. package/src/layouts/sidebar/LayerMenu.vue +2 -2
  21. package/src/layouts/sidebar/LayerPanel.vue +13 -4
  22. package/src/layouts/sidebar/Sidebar.vue +1 -1
  23. package/src/layouts/sidebar/TabPane.vue +2 -2
  24. package/src/layouts/workspace/PageBar.vue +63 -192
  25. package/src/layouts/workspace/PageBarScrollContainer.vue +111 -0
  26. package/src/layouts/workspace/Stage.vue +198 -219
  27. package/src/layouts/workspace/ViewerMenu.vue +140 -147
  28. package/src/layouts/workspace/Workspace.vue +11 -11
  29. package/src/services/BaseService.ts +5 -10
  30. package/src/services/componentList.ts +3 -3
  31. package/src/services/editor.ts +197 -147
  32. package/src/services/events.ts +1 -1
  33. package/src/services/history.ts +1 -1
  34. package/src/services/props.ts +63 -11
  35. package/src/services/storage.ts +133 -0
  36. package/src/services/ui.ts +10 -4
  37. package/src/theme/component-list-panel.scss +5 -0
  38. package/src/theme/framework.scss +1 -1
  39. package/src/theme/stage.scss +2 -2
  40. package/src/type.ts +25 -7
  41. package/src/utils/config.ts +1 -1
  42. package/src/utils/editor.ts +20 -12
  43. package/src/utils/operator.ts +109 -0
  44. package/src/utils/props.ts +2 -24
  45. package/src/utils/scroll-viewer.ts +1 -1
  46. package/tsconfig.build.json +13 -0
  47. package/{dist/types/src → types}/Editor.vue.d.ts +17 -9
  48. package/types/components/ContentMenu.vue.d.ts +116 -0
  49. package/types/components/Icon.vue.d.ts +13 -0
  50. package/types/components/ScrollViewer.vue.d.ts +22 -0
  51. package/types/components/ToolButton.vue.d.ts +109 -0
  52. package/types/fields/Code.vue.d.ts +23 -0
  53. package/{dist/types/src → types}/fields/CodeLink.vue.d.ts +4 -6
  54. package/types/fields/UISelect.vue.d.ts +83 -0
  55. package/{dist/types/src → types}/index.d.ts +4 -1
  56. package/types/layouts/AddPageBox.vue.d.ts +4 -0
  57. package/{dist/types/src → types}/layouts/CodeEditor.vue.d.ts +11 -13
  58. package/types/layouts/Framework.vue.d.ts +22 -0
  59. package/types/layouts/NavMenu.vue.d.ts +25 -0
  60. package/types/layouts/PropsPanel.vue.d.ts +245 -0
  61. package/types/layouts/Resizer.vue.d.ts +12 -0
  62. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +14 -0
  63. package/types/layouts/sidebar/LayerMenu.vue.d.ts +100 -0
  64. package/types/layouts/sidebar/LayerPanel.vue.d.ts +1099 -0
  65. package/{dist/types/src → types}/layouts/sidebar/Sidebar.vue.d.ts +3 -5
  66. package/types/layouts/sidebar/TabPane.vue.d.ts +14 -0
  67. package/types/layouts/workspace/PageBar.vue.d.ts +54 -0
  68. package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +48 -0
  69. package/types/layouts/workspace/Stage.vue.d.ts +46 -0
  70. package/types/layouts/workspace/ViewerMenu.vue.d.ts +88 -0
  71. package/types/layouts/workspace/Workspace.vue.d.ts +6 -0
  72. package/{dist/types/src → types}/services/BaseService.d.ts +0 -0
  73. package/types/services/componentList.d.ts +14 -0
  74. package/{dist/types/src → types}/services/editor.d.ts +21 -14
  75. package/{dist/types/src → types}/services/events.d.ts +0 -0
  76. package/{dist/types/src → types}/services/history.d.ts +0 -0
  77. package/{dist/types/src → types}/services/props.d.ts +26 -2
  78. package/types/services/storage.d.ts +56 -0
  79. package/{dist/types/src → types}/services/ui.d.ts +1 -1
  80. package/{dist/types/src → types}/type.d.ts +18 -1
  81. package/{dist/types/src → types}/utils/compose.d.ts +1 -1
  82. package/{dist/types/src → types}/utils/config.d.ts +0 -0
  83. package/{dist/types/src → types}/utils/editor.d.ts +6 -3
  84. package/{dist/types/src → types}/utils/index.d.ts +0 -0
  85. package/{dist/types/src → types}/utils/logger.d.ts +0 -0
  86. package/types/utils/operator.d.ts +21 -0
  87. package/{dist/types/src → types}/utils/polyfills.d.ts +0 -0
  88. package/{dist/types/src → types}/utils/props.d.ts +2 -22
  89. package/{dist/types/src → types}/utils/scroll-viewer.d.ts +0 -0
  90. package/{dist/types/src → types}/utils/undo-redo.d.ts +0 -0
  91. package/dist/tmagic-editor.es.js.map +0 -1
  92. package/dist/types/src/components/Icon.vue.d.ts +0 -14
  93. package/dist/types/src/components/ScrollViewer.vue.d.ts +0 -24
  94. package/dist/types/src/fields/Code.vue.d.ts +0 -25
  95. package/dist/types/src/layouts/AddPageBox.vue.d.ts +0 -5
  96. package/dist/types/src/layouts/Framework.vue.d.ts +0 -24
  97. package/dist/types/src/layouts/NavMenu.vue.d.ts +0 -27
  98. package/dist/types/src/layouts/PropsPanel.vue.d.ts +0 -13
  99. package/dist/types/src/layouts/Resizer.vue.d.ts +0 -14
  100. package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +0 -16
  101. package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +0 -16
  102. package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +0 -8
  103. package/dist/types/src/shims-vue.d.ts +0 -6
  104. package/dist/types/src/vite-env.d.ts +0 -1
  105. package/src/vite-env.d.ts +0 -1
@@ -4,31 +4,31 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.iconsVue, global.lodashEs, global.monaco, global.StageCore, global.schema, global.utils, global.events, global.core, global.Gesto, global.ElementPlus, global.KeyController));
5
5
  })(this, (function (exports, vue, serialize, iconsVue, lodashEs, monaco, StageCore, schema, utils, events, core, Gesto, elementPlus, KeyController) { 'use strict';
6
6
 
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
+ const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
8
8
 
9
9
  function _interopNamespace(e) {
10
10
  if (e && e.__esModule) return e;
11
- var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
11
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
12
12
  if (e) {
13
- Object.keys(e).forEach(function (k) {
13
+ for (const k in e) {
14
14
  if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
15
+ const d = Object.getOwnPropertyDescriptor(e, k);
16
16
  Object.defineProperty(n, k, d.get ? d : {
17
17
  enumerable: true,
18
- get: function () { return e[k]; }
18
+ get: () => e[k]
19
19
  });
20
20
  }
21
- });
21
+ }
22
22
  }
23
- n["default"] = e;
23
+ n.default = e;
24
24
  return Object.freeze(n);
25
25
  }
26
26
 
27
- var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
28
- var monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
29
- var StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
30
- var Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
31
- var KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
27
+ const serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
28
+ const monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
29
+ const StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
30
+ const Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
31
+ const KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
32
32
 
33
33
  if (typeof global === "undefined") {
34
34
  window.global = window;
@@ -37,15 +37,7 @@
37
37
  window.globalThis = window;
38
38
  }
39
39
 
40
- var _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
- const _sfc_main$m = vue.defineComponent({
40
+ const _sfc_main$n = vue.defineComponent({
49
41
  name: "m-fields-vs-code",
50
42
  props: ["model", "name", "config", "prop"],
51
43
  emits: ["change"],
@@ -62,7 +54,16 @@
62
54
  };
63
55
  }
64
56
  });
65
- function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
57
+
58
+ const _export_sfc = (sfc, props) => {
59
+ const target = sfc.__vccOpts || sfc;
60
+ for (const [key, val] of props) {
61
+ target[key] = val;
62
+ }
63
+ return target;
64
+ };
65
+
66
+ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
66
67
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
67
68
  return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
68
69
  style: vue.normalizeStyle(`height: ${_ctx.height}`),
@@ -71,9 +72,9 @@
71
72
  onSave: _ctx.save
72
73
  }, null, 8, ["style", "init-values", "language", "onSave"]);
73
74
  }
74
- var Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$m]]);
75
+ const Code = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$g]]);
75
76
 
76
- const _sfc_main$l = vue.defineComponent({
77
+ const _sfc_main$m = vue.defineComponent({
77
78
  name: "m-fields-code-link",
78
79
  props: {
79
80
  config: {
@@ -97,7 +98,7 @@
97
98
  vue.watchEffect(() => {
98
99
  if (!props.model || !props.name)
99
100
  return;
100
- modelValue.value.form[props.name] = serialize__default["default"](props.model[props.name], {
101
+ modelValue.value.form[props.name] = serialize__default.default(props.model[props.name], {
101
102
  space: 2,
102
103
  unsafe: true
103
104
  }).replace(/"(\w+)":\s/g, "$1: ");
@@ -128,7 +129,8 @@
128
129
  };
129
130
  }
130
131
  });
131
- function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
132
+
133
+ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
132
134
  const _component_m_fields_link = vue.resolveComponent("m-fields-link");
133
135
  return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
134
136
  config: _ctx.formConfig,
@@ -137,26 +139,20 @@
137
139
  onChange: _ctx.changeHandler
138
140
  }, null, 8, ["config", "model", "onChange"]);
139
141
  }
140
- var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
142
+ const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$f]]);
141
143
 
142
- 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}")();
143
-
144
- const _sfc_main$k = vue.defineComponent({
145
- name: "m-fields-ui-select",
144
+ const _hoisted_1$d = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
145
+ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
146
+ __name: "UISelect",
146
147
  props: {
147
- labelWidth: String,
148
- config: Object,
149
- model: Object,
150
- prop: {
151
- type: String,
152
- default() {
153
- return "";
154
- }
155
- },
156
- name: String
148
+ config: null,
149
+ model: null,
150
+ prop: null,
151
+ name: null
157
152
  },
158
153
  emits: ["change"],
159
- setup(props, { emit }) {
154
+ setup(__props, { emit }) {
155
+ const props = __props;
160
156
  const services = vue.inject("services");
161
157
  const mForm = vue.inject("mForm");
162
158
  const val = vue.computed(() => props.model[props.name]);
@@ -178,97 +174,89 @@
178
174
  cancelHandler();
179
175
  }
180
176
  };
181
- return {
182
- Delete: vue.markRaw(iconsVue.Delete),
183
- Pointer: vue.markRaw(iconsVue.Pointer),
184
- Close: vue.markRaw(iconsVue.Close),
185
- val,
186
- uiSelectMode,
187
- toName: vue.computed(() => {
188
- const config = services?.editorService.getNodeById(val.value);
189
- return config?.name || "";
190
- }),
191
- startSelect() {
192
- if (!services?.uiService)
193
- return;
194
- services.uiService.set("uiSelectMode", true);
195
- uiSelectMode.value = true;
196
- globalThis.document.addEventListener("ui-select", clickHandler);
197
- },
198
- cancelHandler,
199
- deleteHandler() {
200
- if (props.model) {
201
- props.model[props.name] = "";
202
- emit("change", "");
203
- mForm?.$emit("field-change", props.prop, "");
204
- }
177
+ const toName = vue.computed(() => {
178
+ const config = services?.editorService.getNodeById(val.value);
179
+ return config?.name || "";
180
+ });
181
+ const startSelect = () => {
182
+ if (!services?.uiService)
183
+ return;
184
+ services.uiService.set("uiSelectMode", true);
185
+ uiSelectMode.value = true;
186
+ globalThis.document.addEventListener("ui-select", clickHandler);
187
+ };
188
+ const deleteHandler = () => {
189
+ if (props.model) {
190
+ props.model[props.name] = "";
191
+ emit("change", "");
192
+ mForm?.$emit("field-change", props.prop, "");
205
193
  }
206
194
  };
207
- }
208
- });
209
- const _hoisted_1$d = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
210
- function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
211
- const _component_el_button = vue.resolveComponent("el-button");
212
- const _component_el_tooltip = vue.resolveComponent("el-tooltip");
213
- return _ctx.uiSelectMode ? (vue.openBlock(), vue.createElementBlock("div", {
214
- key: 0,
215
- class: "m-fields-ui-select",
216
- onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
217
- }, [
218
- vue.createVNode(_component_el_button, {
219
- type: "danger",
220
- icon: _ctx.Delete,
221
- text: "",
222
- style: { "padding": "0" }
223
- }, {
224
- default: vue.withCtx(() => [
225
- _hoisted_1$d
226
- ]),
227
- _: 1
228
- }, 8, ["icon"])
229
- ])) : (vue.openBlock(), vue.createElementBlock("div", {
230
- key: 1,
231
- class: "m-fields-ui-select",
232
- onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
233
- style: { "display": "flex" }
234
- }, [
235
- vue.createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
236
- default: vue.withCtx(() => [
237
- _ctx.val ? (vue.openBlock(), vue.createBlock(_component_el_button, {
238
- key: 0,
239
- style: { "padding": "0" },
240
- type: "danger",
241
- icon: _ctx.Close,
242
- text: "",
243
- onClick: vue.withModifiers(_ctx.deleteHandler, ["stop"])
244
- }, null, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true)
245
- ]),
246
- _: 1
247
- }),
248
- vue.createVNode(_component_el_tooltip, {
249
- content: _ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
250
- }, {
251
- default: vue.withCtx(() => [
195
+ return (_ctx, _cache) => {
196
+ const _component_el_button = vue.resolveComponent("el-button");
197
+ const _component_el_tooltip = vue.resolveComponent("el-tooltip");
198
+ return uiSelectMode.value ? (vue.openBlock(), vue.createElementBlock("div", {
199
+ key: 0,
200
+ class: "m-fields-ui-select",
201
+ onClick: cancelHandler
202
+ }, [
252
203
  vue.createVNode(_component_el_button, {
204
+ type: "danger",
205
+ icon: vue.unref(iconsVue.Delete),
253
206
  text: "",
254
- style: { "padding": "0", "margin": "0" }
207
+ style: { "padding": "0" }
255
208
  }, {
256
209
  default: vue.withCtx(() => [
257
- vue.createTextVNode(vue.toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
210
+ _hoisted_1$d
258
211
  ]),
259
212
  _: 1
260
- })
261
- ]),
262
- _: 1
263
- }, 8, ["content"])
264
- ]));
265
- }
266
- var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
213
+ }, 8, ["icon"])
214
+ ])) : (vue.openBlock(), vue.createElementBlock("div", {
215
+ key: 1,
216
+ class: "m-fields-ui-select",
217
+ onClick: startSelect,
218
+ style: { "display": "flex" }
219
+ }, [
220
+ vue.createVNode(_component_el_tooltip, { content: "\u6E05\u9664" }, {
221
+ default: vue.withCtx(() => [
222
+ vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_button, {
223
+ key: 0,
224
+ style: { "padding": "0" },
225
+ type: "danger",
226
+ icon: vue.unref(iconsVue.Close),
227
+ text: "",
228
+ onClick: vue.withModifiers(deleteHandler, ["stop"])
229
+ }, null, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true)
230
+ ]),
231
+ _: 1
232
+ }),
233
+ vue.createVNode(_component_el_tooltip, {
234
+ content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
235
+ }, {
236
+ default: vue.withCtx(() => [
237
+ vue.createVNode(_component_el_button, {
238
+ text: "",
239
+ style: { "padding": "0", "margin": "0" }
240
+ }, {
241
+ default: vue.withCtx(() => [
242
+ vue.createTextVNode(vue.toDisplayString(vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
243
+ ]),
244
+ _: 1
245
+ })
246
+ ]),
247
+ _: 1
248
+ }, 8, ["content"])
249
+ ]));
250
+ };
251
+ }
252
+ });
253
+
254
+ const UISelect_vue_vue_type_style_index_0_lang = '';
267
255
 
268
256
  const toString = (v, language) => {
269
257
  let value = "";
270
258
  if (typeof v !== "string") {
271
- value = serialize__default["default"](v, {
259
+ value = serialize__default.default(v, {
272
260
  space: 2,
273
261
  unsafe: true
274
262
  }).replace(/"(\w+)":\s/g, "$1: ");
@@ -280,7 +268,7 @@
280
268
  }
281
269
  return value;
282
270
  };
283
- const _sfc_main$j = vue.defineComponent({
271
+ const _sfc_main$k = vue.defineComponent({
284
272
  name: "magic-code-editor",
285
273
  props: {
286
274
  initValues: {
@@ -387,14 +375,15 @@
387
375
  };
388
376
  }
389
377
  });
378
+
390
379
  const _hoisted_1$c = {
391
380
  ref: "codeEditor",
392
381
  class: "magic-code-editor"
393
382
  };
394
- function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
383
+ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
395
384
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
396
385
  }
397
- var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
386
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
398
387
 
399
388
  let $TMAGIC_EDITOR = {};
400
389
  const setConfig = (option) => {
@@ -403,6 +392,9 @@
403
392
  const getConfig = (key) => $TMAGIC_EDITOR[key];
404
393
 
405
394
  class UndoRedo {
395
+ elementList;
396
+ listCursor;
397
+ listMaxSize;
406
398
  constructor(listMaxSize = 200) {
407
399
  const minListMaxSize = 2;
408
400
  this.elementList = [];
@@ -479,17 +471,12 @@
479
471
  try {
480
472
  let beforeArgs = args;
481
473
  for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
482
- let beforeReturnValue = await beforeMethod(...beforeArgs) || [];
483
- if (isError(beforeReturnValue))
484
- throw beforeReturnValue;
485
- if (!Array.isArray(beforeReturnValue)) {
486
- beforeReturnValue = [beforeReturnValue];
474
+ beforeArgs = await beforeMethod(...beforeArgs) || [];
475
+ if (isError(beforeArgs))
476
+ throw beforeArgs;
477
+ if (!Array.isArray(beforeArgs)) {
478
+ beforeArgs = [beforeArgs];
487
479
  }
488
- beforeArgs = beforeArgs.map((v, index) => {
489
- if (typeof beforeReturnValue[index] === "undefined")
490
- return v;
491
- return beforeReturnValue[index];
492
- });
493
480
  }
494
481
  let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
495
482
  for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
@@ -503,12 +490,12 @@
503
490
  }
504
491
  };
505
492
  class BaseService extends events.EventEmitter {
493
+ pluginOptionsList = {};
494
+ middleware = {};
495
+ taskList = [];
496
+ doingTask = false;
506
497
  constructor(methods = [], serialMethods = []) {
507
498
  super();
508
- this.pluginOptionsList = {};
509
- this.middleware = {};
510
- this.taskList = [];
511
- this.doingTask = false;
512
499
  methods.forEach((propertyName) => {
513
500
  const scope = this;
514
501
  const sourceMethod = scope[propertyName];
@@ -565,14 +552,14 @@
565
552
  }
566
553
 
567
554
  class History extends BaseService {
555
+ state = vue.reactive({
556
+ pageSteps: {},
557
+ pageId: void 0,
558
+ canRedo: false,
559
+ canUndo: false
560
+ });
568
561
  constructor() {
569
562
  super([]);
570
- this.state = vue.reactive({
571
- pageSteps: {},
572
- pageId: void 0,
573
- canRedo: false,
574
- canUndo: false
575
- });
576
563
  this.on("change", this.setCanUndoRedo);
577
564
  }
578
565
  reset() {
@@ -641,88 +628,88 @@
641
628
  this.state.canUndo = undoRedo?.canUndo() || false;
642
629
  }
643
630
  }
644
- var historyService = new History();
631
+ const historyService = new History();
645
632
 
646
- class Props extends BaseService {
633
+ var Protocol = /* @__PURE__ */ ((Protocol2) => {
634
+ Protocol2["OBJECT"] = "object";
635
+ Protocol2["JSON"] = "json";
636
+ Protocol2["STRING"] = "string";
637
+ Protocol2["NUMBER"] = "number";
638
+ Protocol2["BOOLEAN"] = "boolean";
639
+ return Protocol2;
640
+ })(Protocol || {});
641
+ class WebStorage extends BaseService {
642
+ storage = globalThis.localStorage;
643
+ namespace = "tmagic";
647
644
  constructor() {
648
- super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "createId", "setNewItemId"]);
649
- this.state = vue.reactive({
650
- propsConfigMap: {},
651
- propsValueMap: {}
652
- });
645
+ super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
653
646
  }
654
- setPropsConfigs(configs) {
655
- Object.keys(configs).forEach((type) => {
656
- this.setPropsConfig(utils.toLine(type), configs[type]);
657
- });
658
- this.emit("props-configs-change");
647
+ async getStorage() {
648
+ return this.storage;
659
649
  }
660
- setPropsConfig(type, config) {
661
- this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
650
+ async getNamespace() {
651
+ return this.namespace;
662
652
  }
663
- async getPropsConfig(type) {
664
- if (type === "area") {
665
- return await this.getPropsConfig("button");
653
+ async clear() {
654
+ const storage2 = await this.getStorage();
655
+ storage2.clear();
656
+ }
657
+ async getItem(key, options = {}) {
658
+ const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
659
+ const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
660
+ if (item === null)
661
+ return null;
662
+ switch (protocol) {
663
+ case "object" /* OBJECT */:
664
+ return eval(`(${item})`);
665
+ case "json" /* JSON */:
666
+ return JSON.parse(item);
667
+ case "number" /* NUMBER */:
668
+ return Number(item);
669
+ case "boolean" /* BOOLEAN */:
670
+ return Boolean(item);
671
+ default:
672
+ return item;
666
673
  }
667
- return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
668
674
  }
669
- setPropsValues(values) {
670
- Object.keys(values).forEach((type) => {
671
- this.setPropsValue(utils.toLine(type), values[type]);
672
- });
675
+ async key(index) {
676
+ const storage2 = await this.getStorage();
677
+ return storage2.key(index);
673
678
  }
674
- setPropsValue(type, value) {
675
- this.state.propsValueMap[type] = value;
679
+ async removeItem(key2, options2 = {}) {
680
+ const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
681
+ storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
676
682
  }
677
- async getPropsValue(type, defaultValue = {}) {
678
- if (type === "area") {
679
- const value = await this.getPropsValue("button");
680
- value.className = "action-area";
681
- value.text = "";
682
- if (value.style) {
683
- value.style.backgroundColor = "rgba(255, 255, 255, 0)";
684
- }
685
- return value;
683
+ async setItem(key2, value, options2 = {}) {
684
+ const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
685
+ let item2 = value;
686
+ const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
687
+ if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
688
+ item2 = `${protocol2}${value}`;
689
+ } else {
690
+ item2 = `${protocol2}${serialize__default.default(value)}`;
691
+ }
692
+ storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
693
+ }
694
+ getValueAndProtocol(value) {
695
+ let protocol2 = "";
696
+ if (value === null) {
697
+ return {
698
+ item: value,
699
+ protocol: protocol2
700
+ };
686
701
  }
687
- const data = lodashEs.cloneDeep(defaultValue);
688
- await this.setNewItemId(data);
702
+ const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
703
+ protocol2 = $1;
704
+ return $3;
705
+ });
689
706
  return {
690
- ...getDefaultPropsValue(type, await this.createId(type)),
691
- ...lodashEs.mergeWith(lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
707
+ protocol: protocol2,
708
+ item: item2
692
709
  };
693
710
  }
694
- async createId(type) {
695
- return `${type}_${lodashEs.random(1e4, false)}`;
696
- }
697
- async setNewItemId(config, parent) {
698
- const oldId = config.id;
699
- config.id = await this.createId(config.type || "component");
700
- if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
701
- updatePopId(oldId, config.id, parent);
702
- }
703
- if (config.items && Array.isArray(config.items)) {
704
- for (const item of config.items) {
705
- await this.setNewItemId(item, config);
706
- }
707
- }
708
- }
709
711
  }
710
- const updatePopId = (oldId, popId, pageConfig) => {
711
- pageConfig.items?.forEach((config) => {
712
- if (config.pop === oldId) {
713
- config.pop = popId;
714
- return;
715
- }
716
- if (config.popId === oldId) {
717
- config.popId = popId;
718
- return;
719
- }
720
- if (Array.isArray(config.items)) {
721
- updatePopId(oldId, popId, config);
722
- }
723
- });
724
- };
725
- var propsService = new Props();
712
+ const storageService = new WebStorage();
726
713
 
727
714
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
728
715
  LayerOffset2["TOP"] = "top";
@@ -774,10 +761,10 @@
774
761
  top: 0,
775
762
  left: 0
776
763
  });
777
- const getMiddleTop = (style = {}, parentNode, stage) => {
778
- let height = style.height || 0;
779
- if (!stage || typeof style.top !== "undefined" || !parentNode.style)
780
- return style.top;
764
+ const getMiddleTop = (node, parentNode, stage) => {
765
+ let height = node.style?.height || 0;
766
+ if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
767
+ return node.style?.top;
781
768
  if (!utils.isNumber(height)) {
782
769
  height = 0;
783
770
  }
@@ -788,12 +775,11 @@
788
775
  }
789
776
  return (parentHeight - height) / 2;
790
777
  };
791
- const getInitPositionStyle = (style = {}, layout, parentNode, stage) => {
778
+ const getInitPositionStyle = (style = {}, layout) => {
792
779
  if (layout === Layout.ABSOLUTE) {
793
780
  return {
794
781
  ...style,
795
- position: "absolute",
796
- top: getMiddleTop(style, parentNode, stage)
782
+ position: "absolute"
797
783
  };
798
784
  }
799
785
  if (layout === Layout.RELATIVE) {
@@ -879,34 +865,229 @@
879
865
  return config.style?.left;
880
866
  const el = doc.getElementById(`${config.id}`);
881
867
  const parentEl = doc.getElementById(`${parent.id}`);
882
- if (el && parentEl && el.offsetWidth + config.style?.left > parentEl.offsetWidth) {
868
+ const left = Number(config.style?.left) || 0;
869
+ if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
883
870
  return parentEl.offsetWidth - el.offsetWidth;
884
871
  }
885
872
  return config.style.left;
886
873
  };
887
-
888
- const log = (...args) => {
874
+ const fixNodePosition = (config, parent, stage) => {
875
+ if (config.style?.position !== "absolute") {
876
+ return config.style;
877
+ }
878
+ return {
879
+ ...config.style || {},
880
+ top: getMiddleTop(config, parent, stage),
881
+ left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
882
+ };
889
883
  };
890
- const info = (...args) => {
884
+
885
+ class Props extends BaseService {
886
+ state = vue.reactive({
887
+ propsConfigMap: {},
888
+ propsValueMap: {}
889
+ });
890
+ constructor() {
891
+ super([
892
+ "setPropsConfig",
893
+ "getPropsConfig",
894
+ "setPropsValue",
895
+ "getPropsValue",
896
+ "createId",
897
+ "setNewItemId",
898
+ "getDefaultPropsValue"
899
+ ]);
900
+ }
901
+ setPropsConfigs(configs) {
902
+ Object.keys(configs).forEach((type) => {
903
+ this.setPropsConfig(utils.toLine(type), configs[type]);
904
+ });
905
+ this.emit("props-configs-change");
906
+ }
907
+ setPropsConfig(type, config) {
908
+ this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
909
+ }
910
+ async getPropsConfig(type) {
911
+ if (type === "area") {
912
+ return await this.getPropsConfig("button");
913
+ }
914
+ return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
915
+ }
916
+ setPropsValues(values) {
917
+ Object.keys(values).forEach((type) => {
918
+ this.setPropsValue(utils.toLine(type), values[type]);
919
+ });
920
+ }
921
+ setPropsValue(type, value) {
922
+ this.state.propsValueMap[type] = value;
923
+ }
924
+ async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
925
+ if (type === "area") {
926
+ const value = await this.getPropsValue("button");
927
+ value.className = "action-area";
928
+ value.text = "";
929
+ if (value.style) {
930
+ value.style.backgroundColor = "rgba(255, 255, 255, 0)";
931
+ }
932
+ return value;
933
+ }
934
+ const [id, defaultPropsValue, data] = await Promise.all([
935
+ this.createId(type),
936
+ this.getDefaultPropsValue(type),
937
+ this.setNewItemId(lodashEs.cloneDeep({
938
+ type,
939
+ ...defaultValue
940
+ }))
941
+ ]);
942
+ return {
943
+ id,
944
+ ...defaultPropsValue,
945
+ ...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
946
+ };
947
+ }
948
+ guid(digit = 8) {
949
+ return "x".repeat(digit).replace(/[xy]/g, (c) => {
950
+ const r = Math.random() * 16 | 0;
951
+ const v = c == "x" ? r : r & 3 | 8;
952
+ return v.toString(16);
953
+ });
954
+ }
955
+ async createId(type) {
956
+ return `${type}_${this.guid()}`;
957
+ }
958
+ async setNewItemId(config, parent) {
959
+ const oldId = config.id;
960
+ config.id = await this.createId(config.type || "component");
961
+ if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
962
+ updatePopId(oldId, config.id, parent);
963
+ }
964
+ if (config.items && Array.isArray(config.items)) {
965
+ for (const item of config.items) {
966
+ await this.setNewItemId(item, config);
967
+ }
968
+ }
969
+ return config;
970
+ }
971
+ async getDefaultPropsValue(type) {
972
+ return ["page", "container"].includes(type) ? {
973
+ type,
974
+ layout: "absolute",
975
+ style: {},
976
+ name: type,
977
+ items: []
978
+ } : {
979
+ type,
980
+ style: {},
981
+ name: type
982
+ };
983
+ }
984
+ }
985
+ const updatePopId = (oldId, popId, pageConfig) => {
986
+ pageConfig.items?.forEach((config) => {
987
+ if (config.pop === oldId) {
988
+ config.pop = popId;
989
+ return;
990
+ }
991
+ if (config.popId === oldId) {
992
+ config.popId = popId;
993
+ return;
994
+ }
995
+ if (Array.isArray(config.items)) {
996
+ updatePopId(oldId, popId, config);
997
+ }
998
+ });
891
999
  };
892
- const warn = (...args) => {
1000
+ const propsService = new Props();
1001
+
1002
+ const beforePaste = async (position, config) => {
1003
+ if (!config[0]?.style)
1004
+ return config;
1005
+ const curNode = editorService.get("node");
1006
+ const { left: referenceLeft, top: referenceTop } = config[0].style;
1007
+ const pasteConfigs = await Promise.all(config.map(async (configItem) => {
1008
+ const { offsetX = 0, offsetY = 0, ...positionClone } = position;
1009
+ let pastePosition = positionClone;
1010
+ if (!lodashEs.isEmpty(pastePosition) && curNode.items) {
1011
+ pastePosition = getPositionInContainer(pastePosition, curNode.id);
1012
+ }
1013
+ if (pastePosition.left && configItem.style?.left) {
1014
+ pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
1015
+ }
1016
+ if (pastePosition.top && configItem.style?.top) {
1017
+ pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
1018
+ }
1019
+ const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
1020
+ if (pasteConfig.style) {
1021
+ const { left, top } = pasteConfig.style;
1022
+ if (typeof left === "number" || !!left && !isNaN(Number(left))) {
1023
+ pasteConfig.style.left = Number(left) + offsetX;
1024
+ }
1025
+ if (typeof top === "number" || !!top && !isNaN(Number(top))) {
1026
+ pasteConfig.style.top = Number(top) + offsetY;
1027
+ }
1028
+ pasteConfig.style = {
1029
+ ...pasteConfig.style,
1030
+ ...pastePosition
1031
+ };
1032
+ }
1033
+ if (utils.isPage(pasteConfig)) {
1034
+ pasteConfig.name = generatePageNameByApp(editorService.get("root"));
1035
+ }
1036
+ return pasteConfig;
1037
+ }));
1038
+ return pasteConfigs;
893
1039
  };
894
- const debug = (...args) => {
1040
+ const getPositionInContainer = (position = {}, id) => {
1041
+ let { left = 0, top = 0 } = position;
1042
+ const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
1043
+ const parentElRect = parentEl?.getBoundingClientRect();
1044
+ left = left - (parentElRect?.left || 0);
1045
+ top = top - (parentElRect?.top || 0);
1046
+ return {
1047
+ left,
1048
+ top
1049
+ };
895
1050
  };
896
- const error = (...args) => {
1051
+ const getAddParent = (node) => {
1052
+ const curNode = editorService.get("node");
1053
+ let parentNode;
1054
+ if (utils.isPage(node)) {
1055
+ parentNode = editorService.get("root");
1056
+ } else if (curNode.items) {
1057
+ parentNode = curNode;
1058
+ } else {
1059
+ parentNode = editorService.getParentById(curNode.id, false);
1060
+ }
1061
+ return parentNode;
897
1062
  };
898
1063
 
899
1064
  class Editor$1 extends BaseService {
1065
+ state = vue.reactive({
1066
+ root: null,
1067
+ page: null,
1068
+ parent: null,
1069
+ node: null,
1070
+ nodes: [],
1071
+ stage: null,
1072
+ highlightNode: null,
1073
+ modifiedNodeIds: /* @__PURE__ */ new Map(),
1074
+ pageLength: 0
1075
+ });
1076
+ isHistoryStateChange = false;
900
1077
  constructor() {
901
1078
  super([
902
1079
  "getLayout",
903
1080
  "select",
1081
+ "doAdd",
904
1082
  "add",
1083
+ "doRemove",
905
1084
  "remove",
1085
+ "doUpdate",
906
1086
  "update",
907
1087
  "sort",
908
1088
  "copy",
909
1089
  "paste",
1090
+ "duAlignCenter",
910
1091
  "alignCenter",
911
1092
  "moveLayer",
912
1093
  "moveToContainer",
@@ -915,20 +1096,12 @@
915
1096
  "redo",
916
1097
  "highlight"
917
1098
  ], ["select", "update", "moveLayer"]);
918
- this.isHistoryStateChange = false;
919
- this.state = vue.reactive({
920
- root: null,
921
- page: null,
922
- parent: null,
923
- node: null,
924
- stage: null,
925
- highlightNode: null,
926
- modifiedNodeIds: /* @__PURE__ */ new Map(),
927
- pageLength: 0
928
- });
929
1099
  }
930
1100
  set(name, value) {
931
1101
  this.state[name] = value;
1102
+ if (name === "nodes") {
1103
+ this.set("node", value[0]);
1104
+ }
932
1105
  if (name === "root") {
933
1106
  this.state.pageLength = value?.items?.length || 0;
934
1107
  this.emit("root-change", value);
@@ -983,9 +1156,9 @@
983
1156
  }
984
1157
  return Layout.ABSOLUTE;
985
1158
  }
986
- async select(config2) {
987
- const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
988
- this.set("node", node);
1159
+ async select(config) {
1160
+ const { node, page, parent } = this.selectedConfigExceptionHandler(config);
1161
+ this.set("nodes", [node]);
989
1162
  this.set("page", page || null);
990
1163
  this.set("parent", parent || null);
991
1164
  if (page) {
@@ -1025,65 +1198,83 @@
1025
1198
  this.get("stage")?.select(nextPage.id);
1026
1199
  return nextPage;
1027
1200
  }
1028
- highlight(config2) {
1029
- const { node } = this.selectedConfigExceptionHandler(config2);
1201
+ highlight(config) {
1202
+ const { node } = this.selectedConfigExceptionHandler(config);
1030
1203
  const currentHighlightNode = this.get("highlightNode");
1031
1204
  if (currentHighlightNode === node)
1032
1205
  return;
1033
1206
  this.set("highlightNode", node);
1034
1207
  }
1035
- async add(addNode, parent) {
1036
- const { type, ...config2 } = addNode;
1208
+ multiSelect(ids) {
1209
+ const nodes = [];
1210
+ const idsUnique = lodashEs.uniq(ids);
1211
+ idsUnique.forEach((id) => {
1212
+ const { node } = this.getNodeInfo(id);
1213
+ if (!node)
1214
+ return;
1215
+ nodes.push(node);
1216
+ });
1217
+ this.set("nodes", nodes);
1218
+ }
1219
+ async doAdd(node, parent) {
1220
+ const root = this.get("root");
1037
1221
  const curNode = this.get("node");
1038
- let parentNode;
1039
- const isPage2 = type === schema.NodeType.PAGE;
1040
- if (isPage2) {
1041
- parentNode = this.get("root");
1042
- } else if (parent && typeof parent !== "function") {
1043
- parentNode = parent;
1044
- } else if (curNode.items) {
1045
- parentNode = curNode;
1046
- } else {
1047
- parentNode = this.getParentById(curNode.id, false);
1048
- }
1049
- if (!parentNode)
1050
- throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1051
- const layout = await this.getLayout(vue.toRaw(parentNode), addNode);
1052
- const newNode = { ...vue.toRaw(await propsService.getPropsValue(type, config2)) };
1053
- newNode.style = getInitPositionStyle(newNode.style, layout, parentNode, this.get("stage"));
1054
- if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
1222
+ const stage = this.get("stage");
1223
+ if ((parent?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
1055
1224
  throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
1056
1225
  }
1057
- parentNode?.items?.push(newNode);
1226
+ parent?.items?.push(node);
1227
+ const layout = await this.getLayout(vue.toRaw(parent), node);
1228
+ node.style = getInitPositionStyle(node.style, layout);
1229
+ await stage?.add({
1230
+ config: lodashEs.cloneDeep(node),
1231
+ parent: lodashEs.cloneDeep(parent),
1232
+ parentId: parent.id,
1233
+ root: lodashEs.cloneDeep(root)
1234
+ });
1235
+ node.style = fixNodePosition(node, parent, stage);
1236
+ await stage?.update({ config: lodashEs.cloneDeep(node), parentId: parent.id, root: lodashEs.cloneDeep(root) });
1237
+ this.addModifiedNodeId(node.id);
1238
+ return node;
1239
+ }
1240
+ async add(addNode, parent) {
1058
1241
  const stage = this.get("stage");
1059
- const root = this.get("root");
1060
- await stage?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(root) });
1061
- if (layout === Layout.ABSOLUTE) {
1062
- const fixedLeft = fixNodeLeft(newNode, parentNode, stage?.renderer.contentWindow?.document);
1063
- if (typeof fixedLeft !== "undefined") {
1064
- newNode.style.left = fixedLeft;
1065
- await stage?.update({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(root) });
1066
- }
1067
- }
1068
- await this.select(newNode);
1069
- this.addModifiedNodeId(newNode.id);
1070
- if (!isPage2) {
1071
- this.pushHistoryState();
1242
+ const addNodes = [];
1243
+ if (!Array.isArray(addNode)) {
1244
+ const { type, inputEvent, ...config } = addNode;
1245
+ if (!type)
1246
+ throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
1247
+ addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
1248
+ } else {
1249
+ addNodes.push(...addNode);
1072
1250
  }
1073
- stage?.select(newNode.id);
1074
- if (isPage2) {
1075
- this.state.pageLength += 1;
1251
+ const newNodes = await Promise.all(addNodes.map((node) => {
1252
+ const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
1253
+ if (!parentNode)
1254
+ throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1255
+ return this.doAdd(node, parentNode);
1256
+ }));
1257
+ if (newNodes.length > 1) {
1258
+ const newNodeIds = newNodes.map((node) => node.id);
1259
+ stage?.multiSelect(newNodeIds);
1260
+ await this.multiSelect(newNodeIds);
1261
+ } else {
1262
+ await this.select(newNodes[0]);
1263
+ if (utils.isPage(newNodes[0])) {
1264
+ this.state.pageLength += 1;
1265
+ } else {
1266
+ stage?.select(newNodes[0].id);
1267
+ }
1076
1268
  }
1077
- this.emit("add", newNode);
1078
- return newNode;
1269
+ this.pushHistoryState();
1270
+ this.emit("add", newNodes);
1271
+ return newNodes.length > 1 ? newNodes[0] : newNodes;
1079
1272
  }
1080
- async remove(node) {
1081
- if (!node?.id)
1082
- return;
1273
+ async doRemove(node) {
1083
1274
  const root = this.get("root");
1084
1275
  if (!root)
1085
1276
  throw new Error("\u6CA1\u6709root");
1086
- const { parent, node: curNode } = this.getNodeInfo(node.id, false);
1277
+ const { parent, node: curNode } = this.getNodeInfo(node.id);
1087
1278
  if (!parent || !curNode)
1088
1279
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1089
1280
  const index = getNodeIndex(curNode, parent);
@@ -1091,7 +1282,7 @@
1091
1282
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1092
1283
  parent.items?.splice(index, 1);
1093
1284
  const stage = this.get("stage");
1094
- stage?.remove({ id: node.id, root: lodashEs.cloneDeep(this.get("root")) });
1285
+ stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
1095
1286
  if (node.type === schema.NodeType.PAGE) {
1096
1287
  this.state.pageLength -= 1;
1097
1288
  if (root.items[0]) {
@@ -1105,26 +1296,28 @@
1105
1296
  this.set("highlightNode", null);
1106
1297
  this.resetModifiedNodeId();
1107
1298
  historyService.reset();
1108
- this.emit("remove", node);
1109
- return node;
1299
+ return;
1110
1300
  }
1111
1301
  } else {
1112
1302
  await this.select(parent);
1113
1303
  stage?.select(parent.id);
1114
1304
  }
1115
1305
  this.addModifiedNodeId(parent.id);
1306
+ }
1307
+ async remove(nodeOrNodeList) {
1308
+ const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
1309
+ await Promise.all(nodes.map((node) => this.doRemove(node)));
1116
1310
  this.pushHistoryState();
1117
- this.emit("remove", node);
1118
- return node;
1311
+ this.emit("remove");
1119
1312
  }
1120
- async update(config2) {
1121
- if (!config2?.id)
1313
+ async doUpdate(config) {
1314
+ if (!config?.id)
1122
1315
  throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
1123
- const info = this.getNodeInfo(config2.id, false);
1316
+ const info = this.getNodeInfo(config.id, false);
1124
1317
  if (!info.node)
1125
- throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
1318
+ throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
1126
1319
  const node = lodashEs.cloneDeep(vue.toRaw(info.node));
1127
- let newConfig = await this.toggleFixedPosition(vue.toRaw(config2), node, this.get("root"));
1320
+ let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, this.get("root"));
1128
1321
  newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue) => {
1129
1322
  if (Array.isArray(srcValue)) {
1130
1323
  return srcValue;
@@ -1149,18 +1342,28 @@
1149
1342
  newConfig = setLayout(newConfig, newLayout);
1150
1343
  }
1151
1344
  parentNodeItems[index] = newConfig;
1152
- if (`${newConfig.id}` === `${this.get("node").id}`) {
1153
- this.set("node", newConfig);
1154
- }
1155
- this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: lodashEs.cloneDeep(this.get("root")) });
1345
+ const nodes = this.get("nodes");
1346
+ const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
1347
+ nodes.splice(targetIndex, 1, newConfig);
1348
+ this.set("nodes", nodes);
1349
+ this.get("stage")?.update({
1350
+ config: lodashEs.cloneDeep(newConfig),
1351
+ parentId: parent.id,
1352
+ root: lodashEs.cloneDeep(this.get("root"))
1353
+ });
1156
1354
  if (newConfig.type === schema.NodeType.PAGE) {
1157
1355
  this.set("page", newConfig);
1158
1356
  }
1159
1357
  this.addModifiedNodeId(newConfig.id);
1160
- this.pushHistoryState();
1161
- this.emit("update", newConfig);
1162
1358
  return newConfig;
1163
1359
  }
1360
+ async update(config) {
1361
+ const nodes = Array.isArray(config) ? config : [config];
1362
+ const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
1363
+ this.pushHistoryState();
1364
+ this.emit("update", newNodes);
1365
+ return newNodes.length > 1 ? newNodes[0] : newNodes;
1366
+ }
1164
1367
  async sort(id1, id2) {
1165
1368
  const node = this.get("node");
1166
1369
  const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
@@ -1171,65 +1374,57 @@
1171
1374
  parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
1172
1375
  await this.update(parent);
1173
1376
  await this.select(node);
1174
- this.get("stage")?.update({ config: lodashEs.cloneDeep(node), root: lodashEs.cloneDeep(this.get("root")) });
1377
+ this.get("stage")?.update({
1378
+ config: lodashEs.cloneDeep(node),
1379
+ parentId: parent.id,
1380
+ root: lodashEs.cloneDeep(this.get("root"))
1381
+ });
1175
1382
  this.addModifiedNodeId(parent.id);
1176
1383
  this.pushHistoryState();
1177
1384
  }
1178
- async copy(config2) {
1179
- globalThis.localStorage.setItem(COPY_STORAGE_KEY, serialize__default["default"](config2));
1385
+ async copy(config) {
1386
+ await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
1387
+ protocol: Protocol.OBJECT
1388
+ });
1180
1389
  }
1181
1390
  async paste(position = {}) {
1182
- const configStr = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
1183
- let config = {};
1184
- if (!configStr) {
1185
- return;
1186
- }
1187
- try {
1188
- eval(`config = ${configStr}`);
1189
- } catch (e) {
1190
- console.error(e);
1391
+ const config = await storageService.getItem(COPY_STORAGE_KEY);
1392
+ if (!Array.isArray(config))
1191
1393
  return;
1192
- }
1193
- await propsService.setNewItemId(config, this.get("root"));
1194
- if (config.style) {
1195
- config.style = {
1196
- ...config.style,
1197
- ...position
1198
- };
1199
- }
1200
- if (utils.isPage(config)) {
1201
- config.name = generatePageNameByApp(this.get("root"));
1202
- }
1203
- return await this.add(config);
1394
+ const pasteConfigs = await beforePaste(position, config);
1395
+ return this.add(pasteConfigs);
1204
1396
  }
1205
- async alignCenter(config2) {
1206
- const parent = this.get("parent");
1207
- const node = this.get("node");
1208
- const layout = await this.getLayout(vue.toRaw(parent), vue.toRaw(node));
1397
+ async doAlignCenter(config) {
1398
+ const parent = this.getParentById(config.id);
1399
+ if (!parent)
1400
+ throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
1401
+ const node = lodashEs.cloneDeep(vue.toRaw(config));
1402
+ const layout = await this.getLayout(parent, node);
1209
1403
  if (layout === Layout.RELATIVE) {
1210
- return;
1404
+ return config;
1211
1405
  }
1212
1406
  if (!node.style)
1213
- return;
1407
+ return config;
1214
1408
  const stage = this.get("stage");
1215
1409
  const doc = stage?.renderer.contentWindow?.document;
1216
1410
  if (doc) {
1217
- const parentEl = doc.getElementById(`${parent.id}`);
1218
1411
  const el = doc.getElementById(`${node.id}`);
1412
+ const parentEl = el?.offsetParent;
1219
1413
  if (parentEl && el) {
1220
1414
  node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
1221
1415
  }
1222
1416
  } else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
1223
1417
  node.style.left = (parent.style.width - node.style.width) / 2;
1224
1418
  }
1225
- await this.update(node);
1226
- this.get("stage")?.update({
1227
- config: lodashEs.cloneDeep(vue.toRaw(node)),
1228
- root: lodashEs.cloneDeep(this.get("root"))
1229
- });
1230
- this.addModifiedNodeId(config2.id);
1231
- this.pushHistoryState();
1232
- return config2;
1419
+ return node;
1420
+ }
1421
+ async alignCenter(config) {
1422
+ const nodes = Array.isArray(config) ? config : [config];
1423
+ const stage = this.get("stage");
1424
+ const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
1425
+ const newNode = await this.update(newNodes);
1426
+ await stage?.multiSelect(newNodes.map((node) => node.id));
1427
+ return newNode;
1233
1428
  }
1234
1429
  async moveLayer(offset) {
1235
1430
  const parent = this.get("parent");
@@ -1245,28 +1440,29 @@
1245
1440
  }
1246
1441
  this.get("stage")?.update({
1247
1442
  config: lodashEs.cloneDeep(vue.toRaw(parent)),
1443
+ parentId: parent.id,
1248
1444
  root: lodashEs.cloneDeep(this.get("root"))
1249
1445
  });
1250
1446
  }
1251
- async moveToContainer(config2, targetId) {
1252
- const { node, parent } = this.getNodeInfo(config2.id, false);
1447
+ async moveToContainer(config, targetId) {
1448
+ const { node, parent } = this.getNodeInfo(config.id, false);
1253
1449
  const target = this.getNodeById(targetId, false);
1254
1450
  const stage = this.get("stage");
1255
1451
  if (node && parent && stage) {
1256
1452
  const root = lodashEs.cloneDeep(this.get("root"));
1257
1453
  const index = getNodeIndex(node, parent);
1258
1454
  parent.items?.splice(index, 1);
1259
- await stage.remove({ id: node.id, root });
1455
+ await stage.remove({ id: node.id, parentId: parent.id, root });
1260
1456
  const layout = await this.getLayout(target);
1261
- const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config2, (objValue, srcValue) => {
1457
+ const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
1262
1458
  if (Array.isArray(srcValue)) {
1263
1459
  return srcValue;
1264
1460
  }
1265
1461
  });
1266
- newConfig.style = getInitPositionStyle(newConfig.style, layout, target, stage);
1462
+ newConfig.style = getInitPositionStyle(newConfig.style, layout);
1267
1463
  target.items.push(newConfig);
1268
1464
  await stage.select(targetId);
1269
- await stage.update({ config: lodashEs.cloneDeep(target), root });
1465
+ await stage.update({ config: lodashEs.cloneDeep(target), parentId: parent.id, root });
1270
1466
  await this.select(newConfig);
1271
1467
  stage.select(newConfig.id);
1272
1468
  this.addModifiedNodeId(target.id);
@@ -1289,7 +1485,7 @@
1289
1485
  const node = vue.toRaw(this.get("node"));
1290
1486
  if (!node || utils.isPage(node))
1291
1487
  return;
1292
- const { style, id } = node;
1488
+ const { style, id, type } = node;
1293
1489
  if (!style || style.position !== "absolute")
1294
1490
  return;
1295
1491
  if (top && !utils.isNumber(style.top))
@@ -1298,6 +1494,7 @@
1298
1494
  return;
1299
1495
  this.update({
1300
1496
  id,
1497
+ type,
1301
1498
  style: {
1302
1499
  ...style,
1303
1500
  left: Number(style.left) + left,
@@ -1309,6 +1506,7 @@
1309
1506
  this.removeAllListeners();
1310
1507
  this.set("root", null);
1311
1508
  this.set("node", null);
1509
+ this.set("nodes", []);
1312
1510
  this.set("page", null);
1313
1511
  this.set("parent", null);
1314
1512
  }
@@ -1355,12 +1553,12 @@
1355
1553
  }
1356
1554
  return newConfig;
1357
1555
  }
1358
- selectedConfigExceptionHandler(config2) {
1556
+ selectedConfigExceptionHandler(config) {
1359
1557
  let id;
1360
- if (typeof config2 === "string" || typeof config2 === "number") {
1361
- id = config2;
1558
+ if (typeof config === "string" || typeof config === "number") {
1559
+ id = config;
1362
1560
  } else {
1363
- id = config2.id;
1561
+ id = config.id;
1364
1562
  }
1365
1563
  if (!id) {
1366
1564
  throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
@@ -1378,7 +1576,7 @@
1378
1576
  };
1379
1577
  }
1380
1578
  }
1381
- var editorService = new Editor$1();
1579
+ const editorService = new Editor$1();
1382
1580
 
1383
1581
  const eventMap = vue.reactive({});
1384
1582
  const methodMap = vue.reactive({});
@@ -1422,7 +1620,7 @@
1422
1620
  return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
1423
1621
  }
1424
1622
  }
1425
- var eventsService = new Events();
1623
+ const eventsService = new Events();
1426
1624
 
1427
1625
  const fillConfig = (config = []) => [
1428
1626
  {
@@ -1628,21 +1826,34 @@
1628
1826
  }
1629
1827
  ];
1630
1828
  const DEFAULT_CONFIG = fillConfig([]);
1631
- const getDefaultPropsValue = (type, id) => ["page", "container"].includes(type) ? {
1632
- type,
1633
- id,
1634
- layout: "absolute",
1635
- style: {},
1636
- name: type,
1637
- items: []
1638
- } : {
1639
- type,
1640
- id,
1641
- style: {},
1642
- name: type
1829
+
1830
+ const log = (...args) => {
1831
+ if (process.env.NODE_ENV === "development") {
1832
+ console.log("magic editor: ", ...args);
1833
+ }
1834
+ };
1835
+ const info = (...args) => {
1836
+ if (process.env.NODE_ENV === "development") {
1837
+ console.info("magic editor: ", ...args);
1838
+ }
1839
+ };
1840
+ const warn = (...args) => {
1841
+ if (process.env.NODE_ENV === "development") {
1842
+ console.warn("magic editor: ", ...args);
1843
+ }
1844
+ };
1845
+ const debug = (...args) => {
1846
+ if (process.env.NODE_ENV === "development") {
1847
+ console.debug("magic editor: ", ...args);
1848
+ }
1849
+ };
1850
+ const error = (...args) => {
1851
+ if (process.env.NODE_ENV === "development") {
1852
+ console.error("magic editor: ", ...args);
1853
+ }
1643
1854
  };
1644
1855
 
1645
- const _sfc_main$i = vue.defineComponent({
1856
+ const _sfc_main$j = vue.defineComponent({
1646
1857
  components: { Plus: iconsVue.Plus },
1647
1858
  setup() {
1648
1859
  const services = vue.inject("services");
@@ -1659,10 +1870,11 @@
1659
1870
  };
1660
1871
  }
1661
1872
  });
1873
+
1662
1874
  const _hoisted_1$b = { class: "m-editor-empty-panel" };
1663
1875
  const _hoisted_2$4 = { class: "m-editor-empty-content" };
1664
- const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1665
- function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1876
+ const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1877
+ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1666
1878
  const _component_plus = vue.resolveComponent("plus");
1667
1879
  const _component_el_icon = vue.resolveComponent("el-icon");
1668
1880
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
@@ -1679,14 +1891,14 @@
1679
1891
  _: 1
1680
1892
  })
1681
1893
  ]),
1682
- _hoisted_3$2
1894
+ _hoisted_3$1
1683
1895
  ])
1684
1896
  ])
1685
1897
  ]);
1686
1898
  }
1687
- var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
1899
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
1688
1900
 
1689
- const _sfc_main$h = vue.defineComponent({
1901
+ const _sfc_main$i = vue.defineComponent({
1690
1902
  name: "m-editor-resize",
1691
1903
  props: {
1692
1904
  type: {
@@ -1700,7 +1912,7 @@
1700
1912
  vue.onMounted(() => {
1701
1913
  if (!target.value)
1702
1914
  return;
1703
- getso = new Gesto__default["default"](target.value, {
1915
+ getso = new Gesto__default.default(target.value, {
1704
1916
  container: window,
1705
1917
  pinchOutside: true
1706
1918
  }).on("drag", (e) => {
@@ -1728,18 +1940,19 @@
1728
1940
  };
1729
1941
  }
1730
1942
  });
1943
+
1731
1944
  const _hoisted_1$a = {
1732
1945
  ref: "target",
1733
1946
  class: "m-editor-resizer"
1734
1947
  };
1735
- function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1948
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1736
1949
  return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
1737
1950
  vue.renderSlot(_ctx.$slots, "default")
1738
1951
  ], 512);
1739
1952
  }
1740
- var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
1953
+ const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
1741
1954
 
1742
- const _sfc_main$g = vue.defineComponent({
1955
+ const _sfc_main$h = vue.defineComponent({
1743
1956
  components: {
1744
1957
  AddPageBox,
1745
1958
  Resizer
@@ -1768,12 +1981,13 @@
1768
1981
  };
1769
1982
  }
1770
1983
  });
1984
+
1771
1985
  const _hoisted_1$9 = { class: "m-editor" };
1772
1986
  const _hoisted_2$3 = {
1773
1987
  key: 1,
1774
1988
  class: "m-editor-content"
1775
1989
  };
1776
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1990
+ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
1777
1991
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
1778
1992
  const _component_resizer = vue.resolveComponent("resizer");
1779
1993
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
@@ -1819,9 +2033,9 @@
1819
2033
  ]))
1820
2034
  ]);
1821
2035
  }
1822
- var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
2036
+ const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
1823
2037
 
1824
- const _sfc_main$f = vue.defineComponent({
2038
+ const _sfc_main$g = vue.defineComponent({
1825
2039
  name: "m-icon",
1826
2040
  components: { Edit: iconsVue.Edit },
1827
2041
  props: {
@@ -1835,8 +2049,9 @@
1835
2049
  };
1836
2050
  }
1837
2051
  });
2052
+
1838
2053
  const _hoisted_1$8 = ["src"];
1839
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2054
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1840
2055
  const _component_edit = vue.resolveComponent("edit");
1841
2056
  const _component_el_icon = vue.resolveComponent("el-icon");
1842
2057
  return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
@@ -1844,10 +2059,12 @@
1844
2059
  vue.createVNode(_component_edit)
1845
2060
  ]),
1846
2061
  _: 1
1847
- })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
1848
- key: 1,
1849
- src: _ctx.icon
1850
- }, null, 8, _hoisted_1$8)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2062
+ })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
2063
+ default: vue.withCtx(() => [
2064
+ vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
2065
+ ]),
2066
+ _: 1
2067
+ })) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
1851
2068
  key: 2,
1852
2069
  class: vue.normalizeClass(_ctx.icon)
1853
2070
  }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
@@ -1857,10 +2074,19 @@
1857
2074
  _: 1
1858
2075
  }));
1859
2076
  }
1860
- var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
2077
+ const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
1861
2078
 
1862
- const _sfc_main$e = vue.defineComponent({
1863
- components: { MIcon, ArrowDown: iconsVue.ArrowDown },
2079
+ const _hoisted_1$7 = {
2080
+ key: 1,
2081
+ class: "menu-item-text"
2082
+ };
2083
+ const _hoisted_2$2 = {
2084
+ class: "menu-item-text",
2085
+ style: { "margin": "0 5px" }
2086
+ };
2087
+ const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
2088
+ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
2089
+ __name: "ToolButton",
1864
2090
  props: {
1865
2091
  data: {
1866
2092
  type: [Object, String],
@@ -1875,7 +2101,8 @@
1875
2101
  default: "click"
1876
2102
  }
1877
2103
  },
1878
- setup(props) {
2104
+ setup(__props) {
2105
+ const props = __props;
1879
2106
  const services = vue.inject("services");
1880
2107
  const uiService = services?.uiService;
1881
2108
  const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
@@ -1972,176 +2199,155 @@
1972
2199
  item2.handler?.(services, event);
1973
2200
  }
1974
2201
  };
1975
- return {
1976
- ZoomIn: vue.markRaw(iconsVue.ZoomIn),
1977
- ZoomOut: vue.markRaw(iconsVue.ZoomOut),
1978
- item,
1979
- zoom,
1980
- disabled,
1981
- display: vue.computed(() => {
1982
- if (!item.value)
1983
- return false;
1984
- if (typeof item.value === "string")
1985
- return true;
1986
- if (typeof item.value.display === "function") {
1987
- return item.value.display(services);
1988
- }
1989
- return item.value.display ?? true;
1990
- }),
1991
- zoomInHandler,
1992
- zoomOutHandler,
1993
- dropdownHandler(command) {
1994
- if (command.item.handler) {
1995
- command.item.handler(services);
1996
- }
1997
- },
1998
- clickHandler(item2, event) {
1999
- if (props.eventType !== "click")
2000
- return;
2001
- if (item2.type === "button") {
2002
- buttonHandler(item2, event);
2003
- }
2004
- },
2005
- mousedownHandler(item2, event) {
2006
- if (props.eventType !== "mousedown")
2007
- return;
2008
- if (item2.type === "button") {
2009
- buttonHandler(item2, event);
2010
- }
2011
- },
2012
- mouseupHandler(item2, event) {
2013
- if (props.eventType !== "mouseup")
2014
- return;
2015
- if (item2.type === "button") {
2016
- buttonHandler(item2, event);
2017
- }
2202
+ const display = vue.computed(() => {
2203
+ if (!item.value)
2204
+ return false;
2205
+ if (typeof item.value === "string")
2206
+ return true;
2207
+ if (typeof item.value.display === "function") {
2208
+ return item.value.display(services);
2209
+ }
2210
+ return item.value.display ?? true;
2211
+ });
2212
+ const dropdownHandler = (command) => {
2213
+ if (command.item.handler) {
2214
+ command.item.handler(services);
2018
2215
  }
2019
2216
  };
2020
- }
2021
- });
2022
- const _hoisted_1$7 = {
2023
- key: 1,
2024
- class: "menu-item-text"
2025
- };
2026
- const _hoisted_2$2 = {
2027
- class: "menu-item-text",
2028
- style: { "margin": "0 5px" }
2029
- };
2030
- const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
2031
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2032
- const _component_el_divider = vue.resolveComponent("el-divider");
2033
- const _component_tool_button = vue.resolveComponent("tool-button", true);
2034
- const _component_m_icon = vue.resolveComponent("m-icon");
2035
- const _component_el_button = vue.resolveComponent("el-button");
2036
- const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2037
- const _component_arrow_down = vue.resolveComponent("arrow-down");
2038
- const _component_el_icon = vue.resolveComponent("el-icon");
2039
- const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
2040
- const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
2041
- const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2042
- return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", {
2043
- key: 0,
2044
- class: vue.normalizeClass(["menu-item", _ctx.item.type]),
2045
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
2046
- onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
2047
- onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
2048
- }, [
2049
- _ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2050
- key: 0,
2051
- direction: _ctx.item.direction || "vertical"
2052
- }, null, 8, ["direction"])) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, vue.toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
2053
- vue.createVNode(_component_tool_button, {
2054
- data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2055
- "event-type": _ctx.eventType
2056
- }, null, 8, ["data", "event-type"]),
2057
- vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
2058
- vue.createVNode(_component_tool_button, {
2059
- data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
2060
- "event-type": _ctx.eventType
2061
- }, null, 8, ["data", "event-type"])
2062
- ], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
2063
- _ctx.item.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2217
+ const clickHandler = (item2, event) => {
2218
+ if (props.eventType !== "click")
2219
+ return;
2220
+ if (item2.type === "button") {
2221
+ buttonHandler(item2, event);
2222
+ }
2223
+ };
2224
+ const mousedownHandler = (item2, event) => {
2225
+ if (props.eventType !== "mousedown")
2226
+ return;
2227
+ if (item2.type === "button") {
2228
+ buttonHandler(item2, event);
2229
+ }
2230
+ };
2231
+ const mouseupHandler = (item2, event) => {
2232
+ if (props.eventType !== "mouseup")
2233
+ return;
2234
+ if (item2.type === "button") {
2235
+ buttonHandler(item2, event);
2236
+ }
2237
+ };
2238
+ return (_ctx, _cache) => {
2239
+ const _component_el_divider = vue.resolveComponent("el-divider");
2240
+ const _component_tool_button = vue.resolveComponent("tool-button", true);
2241
+ const _component_el_button = vue.resolveComponent("el-button");
2242
+ const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2243
+ const _component_el_icon = vue.resolveComponent("el-icon");
2244
+ const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
2245
+ const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
2246
+ const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2247
+ return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
2064
2248
  key: 0,
2065
- effect: "dark",
2066
- placement: "bottom-start",
2067
- content: _ctx.item.tooltip
2068
- }, {
2069
- default: vue.withCtx(() => [
2070
- vue.createVNode(_component_el_button, {
2249
+ class: vue.normalizeClass(["menu-item", vue.unref(item).type]),
2250
+ onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(vue.unref(item), $event)),
2251
+ onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(vue.unref(item), $event)),
2252
+ onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(vue.unref(item), $event))
2253
+ }, [
2254
+ vue.unref(item).type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2255
+ key: 0,
2256
+ direction: vue.unref(item).direction || "vertical"
2257
+ }, null, 8, ["direction"])) : vue.unref(item).type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, vue.toDisplayString(vue.unref(item).text), 1)) : vue.unref(item).type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
2258
+ vue.createVNode(_component_tool_button, {
2259
+ data: { type: "button", icon: vue.unref(iconsVue.ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2260
+ "event-type": __props.eventType
2261
+ }, null, 8, ["data", "event-type"]),
2262
+ vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${vue.unref(zoom) * 100}`, 10)) + "%", 1),
2263
+ vue.createVNode(_component_tool_button, {
2264
+ data: { type: "button", icon: vue.unref(iconsVue.ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
2265
+ "event-type": __props.eventType
2266
+ }, null, 8, ["data", "event-type"])
2267
+ ], 64)) : vue.unref(item).type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
2268
+ vue.unref(item).tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2269
+ key: 0,
2270
+ effect: "dark",
2271
+ placement: "bottom-start",
2272
+ content: vue.unref(item).tooltip
2273
+ }, {
2274
+ default: vue.withCtx(() => [
2275
+ vue.createVNode(_component_el_button, {
2276
+ size: "small",
2277
+ text: "",
2278
+ disabled: vue.unref(disabled)
2279
+ }, {
2280
+ default: vue.withCtx(() => [
2281
+ vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
2282
+ key: 0,
2283
+ icon: vue.unref(item).icon
2284
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2285
+ vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
2286
+ ]),
2287
+ _: 1
2288
+ }, 8, ["disabled"])
2289
+ ]),
2290
+ _: 1
2291
+ }, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
2292
+ key: 1,
2071
2293
  size: "small",
2072
2294
  text: "",
2073
- disabled: _ctx.disabled
2295
+ disabled: vue.unref(disabled)
2074
2296
  }, {
2075
2297
  default: vue.withCtx(() => [
2076
- _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2298
+ vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
2077
2299
  key: 0,
2078
- icon: _ctx.item.icon
2300
+ icon: vue.unref(item).icon
2079
2301
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2080
- vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2302
+ vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
2081
2303
  ]),
2082
2304
  _: 1
2083
- }, 8, ["disabled"])
2084
- ]),
2085
- _: 1
2086
- }, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
2087
- key: 1,
2088
- size: "small",
2089
- text: "",
2090
- disabled: _ctx.disabled
2091
- }, {
2092
- default: vue.withCtx(() => [
2093
- _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2094
- key: 0,
2095
- icon: _ctx.item.icon
2096
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2097
- vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2098
- ]),
2099
- _: 1
2100
- }, 8, ["disabled"]))
2101
- ], 64)) : _ctx.item.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2102
- key: 4,
2103
- trigger: "click",
2104
- disabled: _ctx.disabled,
2105
- onCommand: _ctx.dropdownHandler
2106
- }, {
2107
- dropdown: vue.withCtx(() => [
2108
- _ctx.item.items && _ctx.item.items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
2305
+ }, 8, ["disabled"]))
2306
+ ], 64)) : vue.unref(item).type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2307
+ key: 4,
2308
+ trigger: "click",
2309
+ disabled: vue.unref(disabled),
2310
+ onCommand: dropdownHandler
2311
+ }, {
2312
+ dropdown: vue.withCtx(() => [
2313
+ vue.unref(item).items && vue.unref(item).items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
2314
+ default: vue.withCtx(() => [
2315
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(item).items, (subItem, index) => {
2316
+ return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
2317
+ key: index,
2318
+ command: { item: vue.unref(item), subItem }
2319
+ }, {
2320
+ default: vue.withCtx(() => [
2321
+ vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
2322
+ ]),
2323
+ _: 2
2324
+ }, 1032, ["command"]);
2325
+ }), 128))
2326
+ ]),
2327
+ _: 1
2328
+ })) : vue.createCommentVNode("", true)
2329
+ ]),
2109
2330
  default: vue.withCtx(() => [
2110
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.item.items, (subItem, index) => {
2111
- return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
2112
- key: index,
2113
- command: { item: _ctx.item, subItem }
2114
- }, {
2331
+ vue.createElementVNode("span", _hoisted_3, [
2332
+ vue.createTextVNode(vue.toDisplayString(vue.unref(item).text), 1),
2333
+ vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
2115
2334
  default: vue.withCtx(() => [
2116
- vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
2335
+ vue.createVNode(vue.unref(iconsVue.ArrowDown))
2117
2336
  ]),
2118
- _: 2
2119
- }, 1032, ["command"]);
2120
- }), 128))
2337
+ _: 1
2338
+ })
2339
+ ])
2121
2340
  ]),
2122
2341
  _: 1
2123
- })) : vue.createCommentVNode("", true)
2124
- ]),
2125
- default: vue.withCtx(() => [
2126
- vue.createElementVNode("span", _hoisted_3$1, [
2127
- vue.createTextVNode(vue.toDisplayString(_ctx.item.text), 1),
2128
- vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
2129
- default: vue.withCtx(() => [
2130
- vue.createVNode(_component_arrow_down)
2131
- ]),
2132
- _: 1
2133
- })
2134
- ])
2135
- ]),
2136
- _: 1
2137
- }, 8, ["disabled", "onCommand"])) : _ctx.item.type === "component" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.item.component), vue.normalizeProps(vue.mergeProps({ key: 5 }, _ctx.item.props || {})), null, 16)) : vue.createCommentVNode("", true)
2138
- ], 34)) : vue.createCommentVNode("", true);
2139
- }
2140
- var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
2342
+ }, 8, ["disabled"])) : vue.unref(item).type === "component" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(item).component), vue.normalizeProps(vue.mergeProps({ key: 5 }, vue.unref(item).props || {})), null, 16)) : vue.createCommentVNode("", true)
2343
+ ], 34)) : vue.createCommentVNode("", true);
2344
+ };
2345
+ }
2346
+ });
2141
2347
 
2142
- const _sfc_main$d = vue.defineComponent({
2348
+ const _sfc_main$e = vue.defineComponent({
2143
2349
  name: "nav-menu",
2144
- components: { ToolButton },
2350
+ components: { ToolButton: _sfc_main$f },
2145
2351
  props: {
2146
2352
  data: {
2147
2353
  type: Object,
@@ -2159,7 +2365,8 @@
2159
2365
  };
2160
2366
  }
2161
2367
  });
2162
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2368
+
2369
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2163
2370
  const _component_tool_button = vue.resolveComponent("tool-button");
2164
2371
  return vue.openBlock(), vue.createElementBlock("div", {
2165
2372
  class: "m-editor-nav-menu",
@@ -2181,9 +2388,9 @@
2181
2388
  }), 128))
2182
2389
  ], 4);
2183
2390
  }
2184
- var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
2391
+ const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
2185
2392
 
2186
- const _sfc_main$c = vue.defineComponent({
2393
+ const _sfc_main$d = vue.defineComponent({
2187
2394
  name: "m-editor-props-panel",
2188
2395
  emits: ["mounted"],
2189
2396
  setup(props, { emit }) {
@@ -2230,8 +2437,9 @@
2230
2437
  };
2231
2438
  }
2232
2439
  });
2440
+
2233
2441
  const _hoisted_1$6 = { class: "`m-editor-props-panel" };
2234
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2442
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2235
2443
  const _component_m_form = vue.resolveComponent("m-form");
2236
2444
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
2237
2445
  vue.renderSlot(_ctx.$slots, "props-panel-header"),
@@ -2246,9 +2454,9 @@
2246
2454
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
2247
2455
  ]);
2248
2456
  }
2249
- var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
2457
+ const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
2250
2458
 
2251
- const _sfc_main$b = vue.defineComponent({
2459
+ const _sfc_main$c = vue.defineComponent({
2252
2460
  name: "ui-component-panel",
2253
2461
  components: { MIcon },
2254
2462
  setup() {
@@ -2278,7 +2486,7 @@
2278
2486
  dragstartHandler({ text, type, data = {} }, e) {
2279
2487
  if (e.dataTransfer) {
2280
2488
  e.dataTransfer.effectAllowed = "move";
2281
- e.dataTransfer.setData("data", serialize__default["default"]({
2489
+ e.dataTransfer.setData("data", serialize__default.default({
2282
2490
  name: text,
2283
2491
  type,
2284
2492
  ...data
@@ -2307,27 +2515,17 @@
2307
2515
  }
2308
2516
  return;
2309
2517
  }
2310
- if (timeout)
2518
+ if (timeout || !stage.value)
2311
2519
  return;
2312
- timeout = globalThis.setTimeout(async () => {
2313
- if (!stageOptions || !stage.value)
2314
- return;
2315
- const doc = stage.value.renderer.contentWindow?.document;
2316
- const els = stage.value.getElementsFromPoint(e);
2317
- for (const el of els) {
2318
- if (doc && !el.id.startsWith(StageCore.GHOST_EL_ID_PREFIX) && await stageOptions.isContainer(el)) {
2319
- utils.addClassName(el, doc, stageOptions?.containerHighlightClassName);
2320
- break;
2321
- }
2322
- }
2323
- }, stageOptions?.containerHighlightDuration);
2520
+ timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
2324
2521
  }
2325
2522
  };
2326
2523
  }
2327
2524
  });
2525
+
2328
2526
  const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2329
2527
  const _hoisted_2$1 = ["onClick", "onDragstart"];
2330
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2528
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2331
2529
  const _component_el_input = vue.resolveComponent("el-input");
2332
2530
  const _component_m_icon = vue.resolveComponent("m-icon");
2333
2531
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -2399,22 +2597,17 @@
2399
2597
  _: 3
2400
2598
  });
2401
2599
  }
2402
- var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
2600
+ const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
2403
2601
 
2404
- const _sfc_main$a = vue.defineComponent({
2405
- components: { ToolButton },
2602
+ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
2603
+ __name: "ContentMenu",
2406
2604
  props: {
2407
- menuData: {
2408
- type: Array,
2409
- default: () => []
2410
- },
2411
- isSubMenu: {
2412
- type: Boolean,
2413
- default: false
2414
- }
2605
+ menuData: { default: () => [] },
2606
+ isSubMenu: { type: Boolean, default: false }
2415
2607
  },
2416
2608
  emits: ["hide", "show"],
2417
- setup(props, { emit }) {
2609
+ setup(__props, { expose, emit }) {
2610
+ const props = __props;
2418
2611
  const menu = vue.ref();
2419
2612
  const subMenu = vue.ref();
2420
2613
  const visible = vue.ref(false);
@@ -2440,6 +2633,36 @@
2440
2633
  }
2441
2634
  hide();
2442
2635
  };
2636
+ const show = (e) => {
2637
+ setTimeout(() => {
2638
+ visible.value = true;
2639
+ vue.nextTick(() => {
2640
+ const menuHeight = menu.value?.clientHeight || 0;
2641
+ let top = e.clientY;
2642
+ if (menuHeight + e.clientY > document.body.clientHeight) {
2643
+ top = document.body.clientHeight - menuHeight;
2644
+ }
2645
+ menuStyle.value = {
2646
+ top: `${top}px`,
2647
+ left: `${e.clientX}px`
2648
+ };
2649
+ emit("show");
2650
+ });
2651
+ }, 300);
2652
+ };
2653
+ const showSubMenu = (item) => {
2654
+ const menuItem = item;
2655
+ if (typeof item !== "object" || !menuItem.items?.length) {
2656
+ return;
2657
+ }
2658
+ subMenuData.value = menuItem.items;
2659
+ if (menu.value) {
2660
+ subMenu.value.show({
2661
+ clientX: menu.value.offsetLeft + menu.value.clientWidth,
2662
+ clientY: menu.value.offsetTop
2663
+ });
2664
+ }
2665
+ };
2443
2666
  vue.onMounted(() => {
2444
2667
  if (props.isSubMenu)
2445
2668
  return;
@@ -2450,81 +2673,47 @@
2450
2673
  return;
2451
2674
  globalThis.removeEventListener("mousedown", hideHandler, true);
2452
2675
  });
2453
- return {
2454
- menu,
2455
- subMenu,
2456
- visible,
2457
- menuStyle,
2458
- subMenuData,
2676
+ expose({
2459
2677
  hide,
2460
- show(e) {
2461
- setTimeout(() => {
2462
- visible.value = true;
2463
- vue.nextTick(() => {
2464
- const menuHeight = menu.value?.clientHeight || 0;
2465
- let top = e.clientY;
2466
- if (menuHeight + e.clientY > document.body.clientHeight) {
2467
- top = document.body.clientHeight - menuHeight;
2468
- }
2469
- menuStyle.value = {
2470
- top: `${top}px`,
2471
- left: `${e.clientX}px`
2472
- };
2473
- emit("show");
2474
- });
2475
- }, 300);
2476
- },
2477
- showSubMenu(item) {
2478
- const menuItem = item;
2479
- if (typeof item !== "object" || !menuItem.items?.length) {
2480
- return;
2481
- }
2482
- subMenuData.value = menuItem.items;
2483
- if (menu.value) {
2484
- subMenu.value.show({
2485
- clientX: menu.value.offsetLeft + menu.value.clientWidth,
2486
- clientY: menu.value.offsetTop
2487
- });
2488
- }
2489
- }
2678
+ show
2679
+ });
2680
+ return (_ctx, _cache) => {
2681
+ const _component_content_menu = vue.resolveComponent("content-menu", true);
2682
+ return __props.menuData.length && visible.value ? (vue.openBlock(), vue.createElementBlock("div", {
2683
+ key: 0,
2684
+ class: "magic-editor-content-menu",
2685
+ ref_key: "menu",
2686
+ ref: menu,
2687
+ style: vue.normalizeStyle(menuStyle.value)
2688
+ }, [
2689
+ vue.createElementVNode("div", null, [
2690
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
2691
+ return vue.openBlock(), vue.createBlock(_sfc_main$f, {
2692
+ "event-type": "mouseup",
2693
+ data: item,
2694
+ key: index,
2695
+ onMouseup: hide,
2696
+ onMouseenter: ($event) => showSubMenu(item)
2697
+ }, null, 8, ["data", "onMouseenter"]);
2698
+ }), 128))
2699
+ ]),
2700
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
2701
+ vue.createVNode(_component_content_menu, {
2702
+ class: "sub-menu",
2703
+ ref_key: "subMenu",
2704
+ ref: subMenu,
2705
+ "menu-data": subMenuData.value,
2706
+ "is-sub-menu": true,
2707
+ onHide: hide
2708
+ }, null, 8, ["menu-data"])
2709
+ ]))
2710
+ ], 4)) : vue.createCommentVNode("", true);
2490
2711
  };
2491
2712
  }
2492
2713
  });
2493
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2494
- const _component_tool_button = vue.resolveComponent("tool-button");
2495
- const _component_content_menu = vue.resolveComponent("content-menu", true);
2496
- return _ctx.menuData.length && _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
2497
- key: 0,
2498
- class: "magic-editor-content-menu",
2499
- ref: "menu",
2500
- style: vue.normalizeStyle(_ctx.menuStyle)
2501
- }, [
2502
- vue.createElementVNode("div", null, [
2503
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
2504
- return vue.openBlock(), vue.createBlock(_component_tool_button, {
2505
- "event-type": "mouseup",
2506
- data: item,
2507
- key: index,
2508
- onMouseup: _ctx.hide,
2509
- onMouseenter: ($event) => _ctx.showSubMenu(item)
2510
- }, null, 8, ["data", "onMouseup", "onMouseenter"]);
2511
- }), 128))
2512
- ]),
2513
- (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
2514
- vue.createVNode(_component_content_menu, {
2515
- class: "sub-menu",
2516
- ref: "subMenu",
2517
- "menu-data": _ctx.subMenuData,
2518
- "is-sub-menu": true,
2519
- onHide: _ctx.hide
2520
- }, null, 8, ["menu-data", "onHide"])
2521
- ]))
2522
- ], 4)) : vue.createCommentVNode("", true);
2523
- }
2524
- var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
2525
2714
 
2526
- const _sfc_main$9 = vue.defineComponent({
2527
- components: { ContentMenu },
2715
+ const _sfc_main$a = vue.defineComponent({
2716
+ components: { ContentMenu: _sfc_main$b },
2528
2717
  setup() {
2529
2718
  const services = vue.inject("services");
2530
2719
  const menu = vue.ref();
@@ -2606,7 +2795,8 @@
2606
2795
  };
2607
2796
  }
2608
2797
  });
2609
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2798
+
2799
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2610
2800
  const _component_content_menu = vue.resolveComponent("content-menu");
2611
2801
  return vue.openBlock(), vue.createBlock(_component_content_menu, {
2612
2802
  "menu-data": _ctx.menuData,
@@ -2614,7 +2804,7 @@
2614
2804
  style: { "overflow": "initial" }
2615
2805
  }, null, 8, ["menu-data"]);
2616
2806
  }
2617
- var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
2807
+ const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
2618
2808
 
2619
2809
  const throttleTime = 150;
2620
2810
  const select = async (data, editorService) => {
@@ -2648,9 +2838,17 @@
2648
2838
  return true;
2649
2839
  return false;
2650
2840
  },
2651
- handleDragEnd() {
2841
+ async handleDragEnd(e) {
2652
2842
  if (!tree.value)
2653
2843
  return;
2844
+ const { data: node } = e;
2845
+ const parent = editorService?.getParentById(node.id, false);
2846
+ const layout = await editorService?.getLayout(parent);
2847
+ node.style.position = layout;
2848
+ if (layout === Layout.RELATIVE) {
2849
+ node.style.top = 0;
2850
+ node.style.left = 0;
2851
+ }
2654
2852
  const { data } = tree.value;
2655
2853
  const [page] = data;
2656
2854
  editorService?.update(page);
@@ -2706,7 +2904,7 @@
2706
2904
  tree.value?.filter(val);
2707
2905
  }
2708
2906
  });
2709
- const _sfc_main$8 = vue.defineComponent({
2907
+ const _sfc_main$9 = vue.defineComponent({
2710
2908
  name: "magic-editor-layer-panel",
2711
2909
  components: { LayerMenu },
2712
2910
  setup() {
@@ -2753,8 +2951,9 @@
2753
2951
  };
2754
2952
  }
2755
2953
  });
2954
+
2756
2955
  const _hoisted_1$4 = ["id", "onMouseenter"];
2757
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2956
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2758
2957
  const _component_el_input = vue.resolveComponent("el-input");
2759
2958
  const _component_el_tree = vue.resolveComponent("el-tree");
2760
2959
  const _component_layer_menu = vue.resolveComponent("layer-menu");
@@ -2816,9 +3015,9 @@
2816
3015
  _: 3
2817
3016
  });
2818
3017
  }
2819
- var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
3018
+ const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
2820
3019
 
2821
- const _sfc_main$7 = vue.defineComponent({
3020
+ const _sfc_main$8 = vue.defineComponent({
2822
3021
  components: { MIcon },
2823
3022
  props: {
2824
3023
  data: {
@@ -2855,11 +3054,12 @@
2855
3054
  };
2856
3055
  }
2857
3056
  });
3057
+
2858
3058
  const _hoisted_1$3 = {
2859
3059
  key: 1,
2860
3060
  class: "magic-editor-tab-panel-title"
2861
3061
  };
2862
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3062
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
2863
3063
  const _component_m_icon = vue.resolveComponent("m-icon");
2864
3064
  const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
2865
3065
  return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
@@ -2905,9 +3105,9 @@
2905
3105
  _: 3
2906
3106
  }, 8, ["name"])) : vue.createCommentVNode("", true);
2907
3107
  }
2908
- var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
3108
+ const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
2909
3109
 
2910
- const _sfc_main$6 = vue.defineComponent({
3110
+ const _sfc_main$7 = vue.defineComponent({
2911
3111
  components: { TabPane },
2912
3112
  name: "m-sidebar",
2913
3113
  props: {
@@ -2926,7 +3126,8 @@
2926
3126
  };
2927
3127
  }
2928
3128
  });
2929
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
3129
+
3130
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
2930
3131
  const _component_tab_pane = vue.resolveComponent("tab-pane");
2931
3132
  const _component_el_tabs = vue.resolveComponent("el-tabs");
2932
3133
  return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
@@ -2961,331 +3162,258 @@
2961
3162
  _: 3
2962
3163
  }, 8, ["modelValue"])) : vue.createCommentVNode("", true);
2963
3164
  }
2964
- var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
3165
+ const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
2965
3166
 
2966
- const useScroll = (root) => {
2967
- const pageBar = vue.ref();
2968
- const itemsContainer = vue.ref();
2969
- const pageBarWidth = vue.ref(0);
2970
- const canScroll = vue.ref(false);
2971
- const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
2972
- let translateLeft = 0;
2973
- const resizeObserver = new ResizeObserver((entries) => {
2974
- for (const { contentRect } of entries) {
2975
- const { width } = contentRect;
2976
- pageBarWidth.value = width || 0;
2977
- setCanScroll();
2978
- }
2979
- });
2980
- const setCanScroll = () => {
2981
- if (itemsContainer.value) {
2982
- canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
2983
- }
2984
- };
2985
- const scroll = (type) => {
2986
- if (!itemsContainer.value)
2987
- return;
2988
- const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
2989
- if (type === "left") {
2990
- translateLeft += 100;
2991
- if (translateLeft > 0) {
2992
- translateLeft = 0;
3167
+ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
3168
+ __name: "PageBarScrollContainer",
3169
+ setup(__props) {
3170
+ const services = vue.inject("services");
3171
+ const editorService = services?.editorService;
3172
+ const pageBar = vue.ref();
3173
+ const itemsContainer = vue.ref();
3174
+ const pageBarWidth = vue.ref(0);
3175
+ const canScroll = vue.ref(false);
3176
+ const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
3177
+ let translateLeft = 0;
3178
+ const resizeObserver = new ResizeObserver((entries) => {
3179
+ for (const { contentRect } of entries) {
3180
+ const { width } = contentRect;
3181
+ pageBarWidth.value = width || 0;
3182
+ setCanScroll();
2993
3183
  }
2994
- } else if (type === "right") {
2995
- translateLeft -= 100;
2996
- if (-translateLeft > maxScrollLeft) {
2997
- translateLeft = -maxScrollLeft;
3184
+ });
3185
+ const setCanScroll = () => {
3186
+ if (itemsContainer.value) {
3187
+ canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
2998
3188
  }
2999
- } else if (type === "start") {
3000
- translateLeft = 0;
3001
- } else if (type === "end") {
3002
- translateLeft = -maxScrollLeft;
3003
- }
3004
- itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
3005
- };
3006
- vue.onMounted(() => {
3007
- pageBar.value && resizeObserver.observe(pageBar.value);
3008
- });
3009
- vue.onUnmounted(() => {
3010
- resizeObserver.disconnect();
3011
- });
3012
- vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
3013
- setTimeout(() => {
3014
- setCanScroll();
3015
- if (length < preLength) {
3016
- scroll("start");
3017
- } else {
3018
- scroll("end");
3189
+ };
3190
+ const scroll = (type) => {
3191
+ if (!itemsContainer.value)
3192
+ return;
3193
+ const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
3194
+ if (type === "left") {
3195
+ translateLeft += 100;
3196
+ if (translateLeft > 0) {
3197
+ translateLeft = 0;
3198
+ }
3199
+ } else if (type === "right") {
3200
+ translateLeft -= 100;
3201
+ if (-translateLeft > maxScrollLeft) {
3202
+ translateLeft = -maxScrollLeft;
3203
+ }
3204
+ } else if (type === "start") {
3205
+ translateLeft = 0;
3206
+ } else if (type === "end") {
3207
+ translateLeft = -maxScrollLeft;
3019
3208
  }
3209
+ itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
3210
+ };
3211
+ vue.onMounted(() => {
3212
+ pageBar.value && resizeObserver.observe(pageBar.value);
3213
+ });
3214
+ vue.onUnmounted(() => {
3215
+ resizeObserver.disconnect();
3020
3216
  });
3021
- });
3022
- return {
3023
- pageBar,
3024
- itemsContainer,
3025
- canScroll,
3026
- itemsContainerWidth,
3027
- scroll
3028
- };
3029
- };
3030
- const _sfc_main$5 = vue.defineComponent({
3031
- components: { ArrowLeftBold: iconsVue.ArrowLeftBold, ArrowRightBold: iconsVue.ArrowRightBold, CaretBottom: iconsVue.CaretBottom, Plus: iconsVue.Plus, ToolButton },
3032
- setup() {
3033
- const services = vue.inject("services");
3034
- const editorService = services?.editorService;
3035
3217
  const root = vue.computed(() => editorService?.get("root"));
3036
- return {
3037
- Delete: vue.markRaw(iconsVue.Delete),
3038
- DocumentCopy: vue.markRaw(iconsVue.DocumentCopy),
3039
- ...useScroll(root),
3040
- root,
3041
- page: vue.computed(() => editorService?.get("page")),
3042
- switchPage(page) {
3043
- editorService?.select(page);
3044
- },
3045
- addPage() {
3046
- if (!editorService)
3047
- return;
3048
- const pageConfig = {
3049
- type: schema.NodeType.PAGE,
3050
- name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
3051
- };
3052
- editorService.add(pageConfig);
3053
- },
3054
- copy(node) {
3055
- node && editorService?.copy(node);
3056
- editorService?.paste({
3057
- left: 0,
3058
- top: 0
3059
- });
3060
- },
3061
- remove(node) {
3062
- editorService?.remove(node);
3063
- }
3218
+ vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
3219
+ setTimeout(() => {
3220
+ setCanScroll();
3221
+ if (length < preLength) {
3222
+ scroll("start");
3223
+ } else {
3224
+ scroll("end");
3225
+ }
3226
+ });
3227
+ });
3228
+ const addPage = () => {
3229
+ if (!editorService)
3230
+ return;
3231
+ const pageConfig = {
3232
+ type: schema.NodeType.PAGE,
3233
+ name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
3234
+ };
3235
+ editorService.add(pageConfig);
3064
3236
  };
3065
- }
3066
- });
3067
- const _hoisted_1$2 = {
3068
- class: "m-editor-page-bar",
3069
- ref: "pageBar"
3070
- };
3071
- const _hoisted_2 = ["onClick"];
3072
- const _hoisted_3 = { class: "m-editor-page-bar-title" };
3073
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3074
- const _component_plus = vue.resolveComponent("plus");
3075
- const _component_el_icon = vue.resolveComponent("el-icon");
3076
- const _component_arrow_left_bold = vue.resolveComponent("arrow-left-bold");
3077
- const _component_el_tooltip = vue.resolveComponent("el-tooltip");
3078
- const _component_tool_button = vue.resolveComponent("tool-button");
3079
- const _component_caret_bottom = vue.resolveComponent("caret-bottom");
3080
- const _component_el_popover = vue.resolveComponent("el-popover");
3081
- const _component_arrow_right_bold = vue.resolveComponent("arrow-right-bold");
3082
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
3083
- vue.createElementVNode("div", {
3084
- id: "m-editor-page-bar-add-icon",
3085
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3086
- onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
3087
- }, [
3088
- vue.createVNode(_component_el_icon, null, {
3089
- default: vue.withCtx(() => [
3090
- vue.createVNode(_component_plus)
3091
- ]),
3092
- _: 1
3093
- })
3094
- ]),
3095
- _ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
3096
- key: 0,
3097
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3098
- onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
3099
- }, [
3100
- vue.createVNode(_component_el_icon, null, {
3101
- default: vue.withCtx(() => [
3102
- vue.createVNode(_component_arrow_left_bold)
3237
+ return (_ctx, _cache) => {
3238
+ const _component_el_icon = vue.resolveComponent("el-icon");
3239
+ return vue.openBlock(), vue.createElementBlock("div", {
3240
+ class: "m-editor-page-bar",
3241
+ ref_key: "pageBar",
3242
+ ref: pageBar
3243
+ }, [
3244
+ vue.createElementVNode("div", {
3245
+ id: "m-editor-page-bar-add-icon",
3246
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3247
+ onClick: addPage
3248
+ }, [
3249
+ vue.createVNode(_component_el_icon, null, {
3250
+ default: vue.withCtx(() => [
3251
+ vue.createVNode(vue.unref(iconsVue.Plus))
3252
+ ]),
3253
+ _: 1
3254
+ })
3103
3255
  ]),
3104
- _: 1
3105
- })
3106
- ])) : vue.createCommentVNode("", true),
3107
- _ctx.root ? (vue.openBlock(), vue.createElementBlock("div", {
3108
- key: 1,
3109
- class: "m-editor-page-bar-items",
3110
- ref: "itemsContainer",
3111
- style: vue.normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
3112
- }, [
3113
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.root.items, (item) => {
3114
- return vue.openBlock(), vue.createElementBlock("div", {
3115
- key: item.key,
3116
- class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
3117
- onClick: ($event) => _ctx.switchPage(item)
3256
+ canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
3257
+ key: 0,
3258
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3259
+ onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
3118
3260
  }, [
3119
- vue.createElementVNode("div", _hoisted_3, [
3120
- vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3121
- vue.createVNode(_component_el_tooltip, {
3122
- effect: "dark",
3123
- placement: "top-start",
3124
- content: item.name
3125
- }, {
3126
- default: vue.withCtx(() => [
3127
- vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
3128
- ]),
3129
- _: 2
3130
- }, 1032, ["content"])
3131
- ])
3132
- ]),
3133
- vue.createVNode(_component_el_popover, {
3134
- "popper-class": "page-bar-popover",
3135
- placement: "top",
3136
- width: 160,
3137
- trigger: "hover"
3138
- }, {
3139
- reference: vue.withCtx(() => [
3140
- vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3141
- default: vue.withCtx(() => [
3142
- vue.createVNode(_component_caret_bottom)
3143
- ]),
3144
- _: 1
3145
- })
3261
+ vue.createVNode(_component_el_icon, null, {
3262
+ default: vue.withCtx(() => [
3263
+ vue.createVNode(vue.unref(iconsVue.ArrowLeftBold))
3146
3264
  ]),
3265
+ _: 1
3266
+ })
3267
+ ])) : vue.createCommentVNode("", true),
3268
+ vue.unref(root) ? (vue.openBlock(), vue.createElementBlock("div", {
3269
+ key: 1,
3270
+ class: "m-editor-page-bar-items",
3271
+ ref_key: "itemsContainer",
3272
+ ref: itemsContainer,
3273
+ style: vue.normalizeStyle(`width: ${vue.unref(itemsContainerWidth)}px`)
3274
+ }, [
3275
+ vue.renderSlot(_ctx.$slots, "default")
3276
+ ], 4)) : vue.createCommentVNode("", true),
3277
+ canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
3278
+ key: 2,
3279
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3280
+ onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
3281
+ }, [
3282
+ vue.createVNode(_component_el_icon, null, {
3147
3283
  default: vue.withCtx(() => [
3148
- vue.createElementVNode("div", null, [
3149
- vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3150
- vue.createVNode(_component_tool_button, {
3151
- data: {
3152
- type: "button",
3153
- text: "\u590D\u5236",
3154
- icon: _ctx.DocumentCopy,
3155
- handler: () => _ctx.copy(item)
3156
- }
3157
- }, null, 8, ["data"]),
3158
- vue.createVNode(_component_tool_button, {
3159
- data: {
3160
- type: "button",
3161
- text: "\u5220\u9664",
3162
- icon: _ctx.Delete,
3163
- handler: () => _ctx.remove(item)
3164
- }
3165
- }, null, 8, ["data"])
3166
- ])
3167
- ])
3284
+ vue.createVNode(vue.unref(iconsVue.ArrowRightBold))
3168
3285
  ]),
3169
- _: 2
3170
- }, 1024)
3171
- ], 10, _hoisted_2);
3172
- }), 128))
3173
- ], 4)) : vue.createCommentVNode("", true),
3174
- _ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
3175
- key: 2,
3176
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3177
- onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
3178
- }, [
3179
- vue.createVNode(_component_el_icon, null, {
3180
- default: vue.withCtx(() => [
3181
- vue.createVNode(_component_arrow_right_bold)
3182
- ]),
3183
- _: 1
3184
- })
3185
- ])) : vue.createCommentVNode("", true)
3186
- ], 512);
3187
- }
3188
- var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
3189
-
3190
- class ScrollViewer$1 {
3191
- constructor(options) {
3192
- this.enter = false;
3193
- this.targetEnter = false;
3194
- this.keydown = false;
3195
- this.zoom = 1;
3196
- this.scrollLeft = 0;
3197
- this.scrollTop = 0;
3198
- this.x = 0;
3199
- this.y = 0;
3200
- this.resizeObserver = new ResizeObserver((entries) => {
3201
- for (const { contentRect } of entries) {
3202
- const { width, height } = contentRect;
3203
- const targetRect = this.target.getBoundingClientRect();
3204
- const targetWidth = targetRect.width * this.zoom;
3205
- const targetMarginTop = Number(this.target.style.marginTop) || 0;
3206
- const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3207
- if (targetWidth < width) {
3208
- this.target._left = 0;
3209
- }
3210
- if (targetHeight < height) {
3211
- this.target._top = 0;
3212
- }
3213
- this.scroll();
3214
- }
3215
- });
3216
- this.wheelHandler = (event) => {
3217
- if (this.targetEnter)
3218
- return;
3219
- const { deltaX, deltaY, currentTarget } = event;
3220
- if (currentTarget !== this.container)
3221
- return;
3222
- this.setScrollOffset(deltaX, deltaY);
3223
- this.scroll();
3224
- this.scrollLeft = this.target._left;
3225
- this.scrollTop = this.target._top;
3226
- };
3227
- this.mouseEnterHandler = () => {
3228
- this.enter = true;
3229
- };
3230
- this.mouseLeaveHandler = () => {
3231
- this.enter = false;
3232
- };
3233
- this.targetMouseEnterHandler = () => {
3234
- this.targetEnter = true;
3286
+ _: 1
3287
+ })
3288
+ ])) : vue.createCommentVNode("", true)
3289
+ ], 512);
3235
3290
  };
3236
- this.targetMouseLeaveHandler = () => {
3237
- this.targetEnter = false;
3291
+ }
3292
+ });
3293
+
3294
+ const _hoisted_1$2 = ["onClick"];
3295
+ const _hoisted_2 = { class: "m-editor-page-bar-title" };
3296
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
3297
+ __name: "PageBar",
3298
+ setup(__props) {
3299
+ const services = vue.inject("services");
3300
+ const editorService = services?.editorService;
3301
+ const root = vue.computed(() => editorService?.get("root"));
3302
+ const page = vue.computed(() => editorService?.get("page"));
3303
+ const switchPage = (page2) => {
3304
+ editorService?.select(page2);
3238
3305
  };
3239
- this.mousedownHandler = (event) => {
3240
- if (!this.keydown)
3241
- return;
3242
- event.stopImmediatePropagation();
3243
- event.stopPropagation();
3244
- this.target.style.cursor = "grabbing";
3245
- this.x = event.clientX;
3246
- this.y = event.clientY;
3247
- document.addEventListener("mousemove", this.mousemoveHandler);
3248
- document.addEventListener("mouseup", this.mouseupHandler);
3306
+ const copy = (node) => {
3307
+ node && editorService?.copy(node);
3308
+ editorService?.paste({
3309
+ left: 0,
3310
+ top: 0
3311
+ });
3249
3312
  };
3250
- this.mouseupHandler = () => {
3251
- this.x = 0;
3252
- this.y = 0;
3253
- this.scrollLeft = this.target._left;
3254
- this.scrollTop = this.target._top;
3255
- this.removeHandler();
3313
+ const remove = (node) => {
3314
+ editorService?.remove(node);
3256
3315
  };
3257
- this.mousemoveHandler = (event) => {
3258
- event.stopImmediatePropagation();
3259
- event.stopPropagation();
3260
- const deltaX = event.clientX - this.x;
3261
- const deltaY = event.clientY - this.y;
3262
- this.setScrollOffset(deltaX, deltaY);
3263
- this.scroll();
3316
+ return (_ctx, _cache) => {
3317
+ const _component_el_tooltip = vue.resolveComponent("el-tooltip");
3318
+ const _component_el_icon = vue.resolveComponent("el-icon");
3319
+ const _component_el_popover = vue.resolveComponent("el-popover");
3320
+ return vue.openBlock(), vue.createBlock(_sfc_main$6, null, {
3321
+ default: vue.withCtx(() => [
3322
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
3323
+ return vue.openBlock(), vue.createElementBlock("div", {
3324
+ class: vue.normalizeClass(["m-editor-page-bar-item", { active: vue.unref(page)?.id === item.id }]),
3325
+ key: item.key,
3326
+ onClick: ($event) => switchPage(item)
3327
+ }, [
3328
+ vue.createElementVNode("div", _hoisted_2, [
3329
+ vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3330
+ vue.createVNode(_component_el_tooltip, {
3331
+ effect: "dark",
3332
+ placement: "top-start",
3333
+ content: item.name
3334
+ }, {
3335
+ default: vue.withCtx(() => [
3336
+ vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
3337
+ ]),
3338
+ _: 2
3339
+ }, 1032, ["content"])
3340
+ ])
3341
+ ]),
3342
+ vue.createVNode(_component_el_popover, {
3343
+ "popper-class": "page-bar-popover",
3344
+ placement: "top",
3345
+ width: 160,
3346
+ trigger: "hover"
3347
+ }, {
3348
+ reference: vue.withCtx(() => [
3349
+ vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3350
+ default: vue.withCtx(() => [
3351
+ vue.createVNode(vue.unref(iconsVue.CaretBottom))
3352
+ ]),
3353
+ _: 1
3354
+ })
3355
+ ]),
3356
+ default: vue.withCtx(() => [
3357
+ vue.createElementVNode("div", null, [
3358
+ vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3359
+ vue.createVNode(_sfc_main$f, {
3360
+ data: {
3361
+ type: "button",
3362
+ text: "\u590D\u5236",
3363
+ icon: vue.unref(iconsVue.DocumentCopy),
3364
+ handler: () => copy(item)
3365
+ }
3366
+ }, null, 8, ["data"]),
3367
+ vue.createVNode(_sfc_main$f, {
3368
+ data: {
3369
+ type: "button",
3370
+ text: "\u5220\u9664",
3371
+ icon: vue.unref(iconsVue.Delete),
3372
+ handler: () => remove(item)
3373
+ }
3374
+ }, null, 8, ["data"])
3375
+ ])
3376
+ ])
3377
+ ]),
3378
+ _: 2
3379
+ }, 1024)
3380
+ ], 10, _hoisted_1$2);
3381
+ }), 128))
3382
+ ]),
3383
+ _: 3
3384
+ });
3264
3385
  };
3265
- this.keydownHandler = (event) => {
3266
- if (event.code === Keys.ESCAPE && this.enter) {
3267
- event.preventDefault();
3268
- event.stopImmediatePropagation();
3269
- event.stopPropagation();
3270
- }
3271
- if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3272
- return;
3386
+ }
3387
+ });
3388
+
3389
+ class ScrollViewer$1 {
3390
+ enter = false;
3391
+ targetEnter = false;
3392
+ keydown = false;
3393
+ container;
3394
+ target;
3395
+ zoom = 1;
3396
+ scrollLeft = 0;
3397
+ scrollTop = 0;
3398
+ x = 0;
3399
+ y = 0;
3400
+ resizeObserver = new ResizeObserver((entries) => {
3401
+ for (const { contentRect } of entries) {
3402
+ const { width, height } = contentRect;
3403
+ const targetRect = this.target.getBoundingClientRect();
3404
+ const targetWidth = targetRect.width * this.zoom;
3405
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3406
+ const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3407
+ if (targetWidth < width) {
3408
+ this.target._left = 0;
3273
3409
  }
3274
- this.keydown = true;
3275
- this.target.style.cursor = "grab";
3276
- this.container.addEventListener("mousedown", this.mousedownHandler);
3277
- };
3278
- this.keyupHandler = (event) => {
3279
- if (event.code !== Keys.ESCAPE || !this.keydown) {
3280
- return;
3410
+ if (targetHeight < height) {
3411
+ this.target._top = 0;
3281
3412
  }
3282
- event.preventDefault();
3283
- event.stopImmediatePropagation();
3284
- event.stopPropagation();
3285
- this.keydown = false;
3286
- event.preventDefault();
3287
- this.removeHandler();
3288
- };
3413
+ this.scroll();
3414
+ }
3415
+ });
3416
+ constructor(options) {
3289
3417
  this.container = options.container;
3290
3418
  this.target = options.target;
3291
3419
  this.zoom = options.zoom;
@@ -3321,6 +3449,79 @@
3321
3449
  document.removeEventListener("mousemove", this.mousemoveHandler);
3322
3450
  document.removeEventListener("mouseup", this.mouseupHandler);
3323
3451
  }
3452
+ wheelHandler = (event) => {
3453
+ if (this.targetEnter)
3454
+ return;
3455
+ const { deltaX, deltaY, currentTarget } = event;
3456
+ if (currentTarget !== this.container)
3457
+ return;
3458
+ this.setScrollOffset(deltaX, deltaY);
3459
+ this.scroll();
3460
+ this.scrollLeft = this.target._left;
3461
+ this.scrollTop = this.target._top;
3462
+ };
3463
+ mouseEnterHandler = () => {
3464
+ this.enter = true;
3465
+ };
3466
+ mouseLeaveHandler = () => {
3467
+ this.enter = false;
3468
+ };
3469
+ targetMouseEnterHandler = () => {
3470
+ this.targetEnter = true;
3471
+ };
3472
+ targetMouseLeaveHandler = () => {
3473
+ this.targetEnter = false;
3474
+ };
3475
+ mousedownHandler = (event) => {
3476
+ if (!this.keydown)
3477
+ return;
3478
+ event.stopImmediatePropagation();
3479
+ event.stopPropagation();
3480
+ this.target.style.cursor = "grabbing";
3481
+ this.x = event.clientX;
3482
+ this.y = event.clientY;
3483
+ document.addEventListener("mousemove", this.mousemoveHandler);
3484
+ document.addEventListener("mouseup", this.mouseupHandler);
3485
+ };
3486
+ mouseupHandler = () => {
3487
+ this.x = 0;
3488
+ this.y = 0;
3489
+ this.scrollLeft = this.target._left;
3490
+ this.scrollTop = this.target._top;
3491
+ this.removeHandler();
3492
+ };
3493
+ mousemoveHandler = (event) => {
3494
+ event.stopImmediatePropagation();
3495
+ event.stopPropagation();
3496
+ const deltaX = event.clientX - this.x;
3497
+ const deltaY = event.clientY - this.y;
3498
+ this.setScrollOffset(deltaX, deltaY);
3499
+ this.scroll();
3500
+ };
3501
+ keydownHandler = (event) => {
3502
+ if (event.code === Keys.ESCAPE && this.enter) {
3503
+ event.preventDefault();
3504
+ event.stopImmediatePropagation();
3505
+ event.stopPropagation();
3506
+ }
3507
+ if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3508
+ return;
3509
+ }
3510
+ this.keydown = true;
3511
+ this.target.style.cursor = "grab";
3512
+ this.container.addEventListener("mousedown", this.mousedownHandler);
3513
+ };
3514
+ keyupHandler = (event) => {
3515
+ if (event.code !== Keys.ESCAPE || !this.keydown) {
3516
+ return;
3517
+ }
3518
+ event.preventDefault();
3519
+ event.stopImmediatePropagation();
3520
+ event.stopPropagation();
3521
+ this.keydown = false;
3522
+ event.preventDefault();
3523
+ this.removeHandler();
3524
+ };
3324
3525
  setScrollOffset(deltaX, deltaY) {
3325
3526
  const { width, height } = this.container.getBoundingClientRect();
3326
3527
  const targetRect = this.target.getBoundingClientRect();
@@ -3381,18 +3582,19 @@
3381
3582
  el,
3382
3583
  style: vue.computed(() => `
3383
3584
  width: ${props.width}px;
3384
- height: ${(props.height || 0) - 40}px;
3585
+ height: ${props.height}px;
3385
3586
  position: absolute;
3386
3587
  margin-top: 30px;
3387
3588
  `)
3388
3589
  };
3389
3590
  }
3390
3591
  });
3592
+
3391
3593
  const _hoisted_1$1 = {
3392
3594
  class: "m-editor-scroll-viewer-container",
3393
3595
  ref: "container"
3394
3596
  };
3395
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3597
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3396
3598
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
3397
3599
  vue.createElementVNode("div", {
3398
3600
  ref: "el",
@@ -3402,170 +3604,170 @@
3402
3604
  ], 4)
3403
3605
  ], 512);
3404
3606
  }
3405
- var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
3607
+ const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
3406
3608
 
3407
- const _sfc_main$3 = vue.defineComponent({
3408
- components: { ContentMenu },
3409
- setup() {
3609
+ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
3610
+ __name: "ViewerMenu",
3611
+ props: {
3612
+ isMultiSelect: { type: Boolean, default: false }
3613
+ },
3614
+ setup(__props, { expose }) {
3615
+ const props = __props;
3410
3616
  const services = vue.inject("services");
3411
3617
  const editorService = services?.editorService;
3412
3618
  const menu = vue.ref();
3413
3619
  const canPaste = vue.ref(false);
3414
3620
  const canCenter = vue.ref(false);
3415
3621
  const node = vue.computed(() => editorService?.get("node"));
3622
+ const nodes = vue.computed(() => editorService?.get("nodes"));
3416
3623
  const parent = vue.computed(() => editorService?.get("parent"));
3417
- const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
3624
+ const stage = vue.computed(() => editorService?.get("stage"));
3418
3625
  const stageContentMenu = vue.inject("stageContentMenu", []);
3419
- vue.onMounted(() => {
3420
- const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
3421
- canPaste.value = data !== "undefined" && !!data;
3422
- });
3626
+ const menuData = vue.reactive([
3627
+ {
3628
+ type: "button",
3629
+ text: "\u6C34\u5E73\u5C45\u4E2D",
3630
+ display: () => canCenter.value,
3631
+ handler: () => {
3632
+ if (!nodes.value)
3633
+ return;
3634
+ editorService?.alignCenter(nodes.value);
3635
+ }
3636
+ },
3637
+ {
3638
+ type: "button",
3639
+ text: "\u590D\u5236",
3640
+ icon: vue.markRaw(iconsVue.DocumentCopy),
3641
+ handler: () => {
3642
+ nodes.value && editorService?.copy(nodes.value);
3643
+ canPaste.value = true;
3644
+ }
3645
+ },
3646
+ {
3647
+ type: "button",
3648
+ text: "\u7C98\u8D34",
3649
+ display: () => canPaste.value,
3650
+ handler: () => {
3651
+ const rect = menu.value?.$el.getBoundingClientRect();
3652
+ const parentRect = stage.value?.container?.getBoundingClientRect();
3653
+ const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
3654
+ const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
3655
+ if (!nodes.value || nodes.value.length === 0)
3656
+ return;
3657
+ editorService?.paste({ left: initialLeft, top: initialTop });
3658
+ }
3659
+ },
3660
+ {
3661
+ type: "divider",
3662
+ direction: "horizontal",
3663
+ display: () => {
3664
+ if (!node.value)
3665
+ return false;
3666
+ return !utils.isPage(node.value);
3667
+ }
3668
+ },
3669
+ {
3670
+ type: "button",
3671
+ text: "\u4E0A\u79FB\u4E00\u5C42",
3672
+ icon: vue.markRaw(iconsVue.Top),
3673
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect,
3674
+ handler: () => {
3675
+ editorService?.moveLayer(1);
3676
+ }
3677
+ },
3678
+ {
3679
+ type: "button",
3680
+ text: "\u4E0B\u79FB\u4E00\u5C42",
3681
+ icon: vue.markRaw(iconsVue.Bottom),
3682
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect,
3683
+ handler: () => {
3684
+ editorService?.moveLayer(-1);
3685
+ }
3686
+ },
3687
+ {
3688
+ type: "button",
3689
+ text: "\u7F6E\u9876",
3690
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect,
3691
+ handler: () => {
3692
+ editorService?.moveLayer(LayerOffset.TOP);
3693
+ }
3694
+ },
3695
+ {
3696
+ type: "button",
3697
+ text: "\u7F6E\u5E95",
3698
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect,
3699
+ handler: () => {
3700
+ editorService?.moveLayer(LayerOffset.BOTTOM);
3701
+ }
3702
+ },
3703
+ {
3704
+ type: "divider",
3705
+ direction: "horizontal",
3706
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect
3707
+ },
3708
+ {
3709
+ type: "button",
3710
+ text: "\u5220\u9664",
3711
+ icon: iconsVue.Delete,
3712
+ display: () => !utils.isPage(node.value),
3713
+ handler: () => {
3714
+ nodes.value && editorService?.remove(nodes.value);
3715
+ }
3716
+ },
3717
+ {
3718
+ type: "divider",
3719
+ direction: "horizontal"
3720
+ },
3721
+ {
3722
+ type: "button",
3723
+ text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
3724
+ handler: () => {
3725
+ editorService?.get("stage").clearGuides();
3726
+ }
3727
+ },
3728
+ ...stageContentMenu
3729
+ ]);
3423
3730
  vue.watch(parent, async () => {
3424
3731
  if (!parent.value || !editorService)
3425
3732
  return canCenter.value = false;
3426
3733
  const layout = await editorService.getLayout(parent.value);
3427
- canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${node.value?.type}`);
3734
+ const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
3735
+ const isTypeConform = nodes.value?.every((selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
3736
+ canCenter.value = isLayoutConform && !!isTypeConform;
3428
3737
  }, { immediate: true });
3429
- return {
3430
- menu,
3431
- menuData: vue.reactive([
3432
- {
3433
- type: "button",
3434
- text: "\u6C34\u5E73\u5C45\u4E2D",
3435
- display: () => canCenter.value,
3436
- handler: () => {
3437
- node.value && editorService?.alignCenter(node.value);
3438
- }
3439
- },
3440
- {
3441
- type: "button",
3442
- text: "\u590D\u5236",
3443
- icon: vue.markRaw(iconsVue.DocumentCopy),
3444
- handler: () => {
3445
- node.value && editorService?.copy(node.value);
3446
- canPaste.value = true;
3447
- }
3448
- },
3449
- {
3450
- type: "button",
3451
- text: "\u7C98\u8D34",
3452
- display: () => canPaste.value,
3453
- handler: () => {
3454
- const stage = editorService?.get("stage");
3455
- const rect = menu.value?.$el.getBoundingClientRect();
3456
- const parentRect = stage?.container?.getBoundingClientRect();
3457
- let left = (rect?.left || 0) - (parentRect?.left || 0);
3458
- let top = (rect?.top || 0) - (parentRect?.top || 0);
3459
- if (node.value?.items && stage) {
3460
- const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
3461
- const parentElRect = parentEl?.getBoundingClientRect();
3462
- left = left - (parentElRect?.left || 0);
3463
- top = top - (parentElRect?.top || 0);
3464
- }
3465
- editorService?.paste({ left, top });
3466
- }
3467
- },
3468
- {
3469
- type: "divider",
3470
- direction: "horizontal",
3471
- display: () => !isPage.value
3472
- },
3473
- {
3474
- type: "button",
3475
- text: "\u4E0A\u79FB\u4E00\u5C42",
3476
- icon: vue.markRaw(iconsVue.Top),
3477
- display: () => !isPage.value,
3478
- handler: () => {
3479
- editorService?.moveLayer(1);
3480
- }
3481
- },
3482
- {
3483
- type: "button",
3484
- text: "\u4E0B\u79FB\u4E00\u5C42",
3485
- icon: vue.markRaw(iconsVue.Bottom),
3486
- display: () => !isPage.value,
3487
- handler: () => {
3488
- editorService?.moveLayer(-1);
3489
- }
3490
- },
3491
- {
3492
- type: "button",
3493
- text: "\u7F6E\u9876",
3494
- display: () => !isPage.value,
3495
- handler: () => {
3496
- editorService?.moveLayer(LayerOffset.TOP);
3497
- }
3498
- },
3499
- {
3500
- type: "button",
3501
- text: "\u7F6E\u5E95",
3502
- display: () => !isPage.value,
3503
- handler: () => {
3504
- editorService?.moveLayer(LayerOffset.BOTTOM);
3505
- }
3506
- },
3507
- {
3508
- type: "divider",
3509
- direction: "horizontal",
3510
- display: () => !isPage.value
3511
- },
3512
- {
3513
- type: "button",
3514
- text: "\u5220\u9664",
3515
- icon: iconsVue.Delete,
3516
- display: () => !isPage.value,
3517
- handler: () => {
3518
- node.value && editorService?.remove(node.value);
3519
- }
3520
- },
3521
- {
3522
- type: "divider",
3523
- direction: "horizontal"
3524
- },
3525
- {
3526
- type: "button",
3527
- text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
3528
- handler: () => {
3529
- editorService?.get("stage").clearGuides();
3530
- }
3531
- },
3532
- ...stageContentMenu
3533
- ]),
3534
- show(e) {
3535
- menu.value?.show(e);
3536
- }
3738
+ const show = async (e) => {
3739
+ menu.value?.show(e);
3740
+ const data = await storageService.getItem(COPY_STORAGE_KEY);
3741
+ canPaste.value = data !== "undefined" && !!data;
3742
+ };
3743
+ expose({ show });
3744
+ return (_ctx, _cache) => {
3745
+ return vue.openBlock(), vue.createBlock(_sfc_main$b, {
3746
+ "menu-data": menuData,
3747
+ ref_key: "menu",
3748
+ ref: menu
3749
+ }, null, 8, ["menu-data"]);
3537
3750
  };
3538
3751
  }
3539
3752
  });
3540
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3541
- const _component_content_menu = vue.resolveComponent("content-menu");
3542
- return vue.openBlock(), vue.createBlock(_component_content_menu, {
3543
- "menu-data": _ctx.menuData,
3544
- ref: "menu"
3545
- }, null, 8, ["menu-data"]);
3546
- }
3547
- var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
3548
3753
 
3549
- const _sfc_main$2 = vue.defineComponent({
3550
- name: "magic-stage",
3551
- components: {
3552
- ViewerMenu,
3553
- ScrollViewer
3554
- },
3555
- setup() {
3754
+ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
3755
+ __name: "Stage",
3756
+ setup(__props) {
3757
+ let stage = null;
3758
+ let runtime = null;
3556
3759
  const services = vue.inject("services");
3557
3760
  const stageOptions = vue.inject("stageOptions");
3558
3761
  const stageWrap = vue.ref();
3559
3762
  const stageContainer = vue.ref();
3560
3763
  const menu = vue.ref();
3764
+ const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
3561
3765
  const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
3562
3766
  const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
3563
3767
  const root = vue.computed(() => services?.editorService.get("root"));
3564
3768
  const page = vue.computed(() => services?.editorService.get("page"));
3565
3769
  const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
3566
3770
  const node = vue.computed(() => services?.editorService.get("node"));
3567
- let stage = null;
3568
- let runtime = null;
3569
3771
  const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
3570
3772
  vue.watchEffect(() => {
3571
3773
  if (stage)
@@ -3574,7 +3776,7 @@
3574
3776
  return;
3575
3777
  if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
3576
3778
  return;
3577
- stage = new StageCore__default["default"]({
3779
+ stage = new StageCore__default.default({
3578
3780
  render: stageOptions.render,
3579
3781
  runtimeUrl: stageOptions.runtimeUrl,
3580
3782
  zoom: zoom.value,
@@ -3582,6 +3784,7 @@
3582
3784
  isContainer: stageOptions.isContainer,
3583
3785
  containerHighlightClassName: stageOptions.containerHighlightClassName,
3584
3786
  containerHighlightDuration: stageOptions.containerHighlightDuration,
3787
+ containerHighlightType: stageOptions.containerHighlightType,
3585
3788
  canSelect: (el, event, stop) => {
3586
3789
  const elCanSelect = stageOptions.canSelect(el);
3587
3790
  if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
@@ -3605,12 +3808,17 @@
3605
3808
  stage?.on("highlight", (el) => {
3606
3809
  services?.editorService.highlight(el.id);
3607
3810
  });
3811
+ stage?.on("multiSelect", (els) => {
3812
+ services?.editorService.multiSelect(els.map((el) => el.id));
3813
+ });
3608
3814
  stage?.on("update", (ev) => {
3609
3815
  if (ev.parentEl) {
3610
- services?.editorService.moveToContainer({ id: ev.el.id, style: ev.style }, ev.parentEl.id);
3816
+ for (const data of ev.data) {
3817
+ services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
3818
+ }
3611
3819
  return;
3612
3820
  }
3613
- services?.editorService.update({ id: ev.el.id, style: ev.style });
3821
+ services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
3614
3822
  });
3615
3823
  stage?.on("sort", (ev) => {
3616
3824
  services?.editorService.sort(ev.src, ev.dist);
@@ -3663,99 +3871,96 @@
3663
3871
  resizeObserver.disconnect();
3664
3872
  services?.editorService.set("stage", null);
3665
3873
  });
3666
- return {
3667
- stageWrap,
3668
- stageContainer,
3669
- menu,
3670
- stageRect,
3671
- zoom,
3672
- contextmenuHandler(e2) {
3673
- e2.preventDefault();
3674
- menu.value?.show(e2);
3675
- },
3676
- dragoverHandler(e2) {
3677
- e2.preventDefault();
3678
- if (e2.dataTransfer) {
3679
- e2.dataTransfer.dropEffect = "move";
3680
- }
3681
- },
3682
- async dropHandler(e) {
3683
- e.preventDefault();
3684
- const doc = stage?.renderer.contentWindow?.document;
3685
- const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
3686
- let parent = page.value;
3687
- if (parentEl) {
3688
- parent = services?.editorService.getNodeById(parentEl.id, false);
3689
- }
3690
- if (e.dataTransfer && parent && stageContainer.value && stage) {
3691
- const config = eval(`(${e.dataTransfer.getData("data")})`);
3692
- const layout = await services?.editorService.getLayout(parent);
3693
- const containerRect = stageContainer.value.getBoundingClientRect();
3694
- const { scrollTop, scrollLeft } = stage.mask;
3695
- const { style = {} } = config;
3696
- let top = 0;
3697
- let left = 0;
3698
- let position = "relative";
3699
- if (layout === Layout.ABSOLUTE) {
3700
- position = "absolute";
3701
- top = e.clientY - containerRect.top + scrollTop;
3702
- left = e.clientX - containerRect.left + scrollLeft;
3703
- if (parentEl && doc) {
3704
- const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
3705
- left = left - StageCore.calcValueByFontsize(doc, parentLeft);
3706
- top = top - StageCore.calcValueByFontsize(doc, parentTop);
3707
- }
3874
+ const contextmenuHandler = (e2) => {
3875
+ e2.preventDefault();
3876
+ menu.value?.show(e2);
3877
+ };
3878
+ const dragoverHandler = (e2) => {
3879
+ e2.preventDefault();
3880
+ if (e2.dataTransfer) {
3881
+ e2.dataTransfer.dropEffect = "move";
3882
+ }
3883
+ };
3884
+ const dropHandler = async (e) => {
3885
+ e.preventDefault();
3886
+ const doc = stage?.renderer.contentWindow?.document;
3887
+ const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
3888
+ let parent = page.value;
3889
+ if (parentEl) {
3890
+ parent = services?.editorService.getNodeById(parentEl.id, false);
3891
+ }
3892
+ if (e.dataTransfer && parent && stageContainer.value && stage) {
3893
+ const config = eval(`(${e.dataTransfer.getData("data")})`);
3894
+ const layout = await services?.editorService.getLayout(parent);
3895
+ const containerRect = stageContainer.value.getBoundingClientRect();
3896
+ const { scrollTop, scrollLeft } = stage.mask;
3897
+ const { style = {} } = config;
3898
+ let top = 0;
3899
+ let left = 0;
3900
+ let position = "relative";
3901
+ if (layout === Layout.ABSOLUTE) {
3902
+ position = "absolute";
3903
+ top = e.clientY - containerRect.top + scrollTop;
3904
+ left = e.clientX - containerRect.left + scrollLeft;
3905
+ if (parentEl && doc) {
3906
+ const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
3907
+ left = left - StageCore.calcValueByFontsize(doc, parentLeft);
3908
+ top = top - StageCore.calcValueByFontsize(doc, parentTop);
3708
3909
  }
3709
- config.style = {
3710
- ...style,
3711
- position,
3712
- top,
3713
- left
3714
- };
3715
- services?.editorService.add(config, parent);
3716
3910
  }
3911
+ config.style = {
3912
+ ...style,
3913
+ position,
3914
+ top,
3915
+ left
3916
+ };
3917
+ config.inputEvent = e;
3918
+ services?.editorService.add(config, parent);
3717
3919
  }
3718
3920
  };
3921
+ return (_ctx, _cache) => {
3922
+ return vue.openBlock(), vue.createBlock(ScrollViewer, {
3923
+ class: "m-editor-stage",
3924
+ ref_key: "stageWrap",
3925
+ ref: stageWrap,
3926
+ width: vue.unref(stageRect)?.width,
3927
+ height: vue.unref(stageRect)?.height,
3928
+ zoom: vue.unref(zoom)
3929
+ }, {
3930
+ default: vue.withCtx(() => [
3931
+ vue.createElementVNode("div", {
3932
+ class: "m-editor-stage-container",
3933
+ ref_key: "stageContainer",
3934
+ ref: stageContainer,
3935
+ style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})`),
3936
+ onContextmenu: contextmenuHandler,
3937
+ onDrop: dropHandler,
3938
+ onDragover: dragoverHandler
3939
+ }, null, 36),
3940
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3941
+ vue.createVNode(_sfc_main$3, {
3942
+ ref_key: "menu",
3943
+ ref: menu,
3944
+ "is-multi-select": vue.unref(isMultiSelect)
3945
+ }, null, 8, ["is-multi-select"])
3946
+ ]))
3947
+ ]),
3948
+ _: 1
3949
+ }, 8, ["width", "height", "zoom"]);
3950
+ };
3719
3951
  }
3720
3952
  });
3721
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3722
- const _component_viewer_menu = vue.resolveComponent("viewer-menu");
3723
- const _component_scroll_viewer = vue.resolveComponent("scroll-viewer");
3724
- return vue.openBlock(), vue.createBlock(_component_scroll_viewer, {
3725
- class: "m-editor-stage",
3726
- ref: "stageWrap",
3727
- width: _ctx.stageRect?.width,
3728
- height: _ctx.stageRect?.height,
3729
- zoom: _ctx.zoom
3730
- }, {
3731
- default: vue.withCtx(() => [
3732
- vue.createElementVNode("div", {
3733
- class: "m-editor-stage-container",
3734
- ref: "stageContainer",
3735
- style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
3736
- onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
3737
- onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
3738
- onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
3739
- }, null, 36),
3740
- (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3741
- vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
3742
- ]))
3743
- ]),
3744
- _: 1
3745
- }, 8, ["width", "height", "zoom"]);
3746
- }
3747
- var MagicStage = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
3748
3953
 
3749
3954
  const _sfc_main$1 = vue.defineComponent({
3750
3955
  name: "m-editor-workspace",
3751
3956
  components: {
3752
- PageBar,
3753
- MagicStage
3957
+ PageBar: _sfc_main$5,
3958
+ MagicStage: _sfc_main$2
3754
3959
  },
3755
3960
  setup() {
3756
3961
  const services = vue.inject("services");
3757
3962
  const workspace = vue.ref();
3758
- const node = vue.computed(() => services?.editorService.get("node"));
3963
+ const nodes = vue.computed(() => services?.editorService.get("nodes"));
3759
3964
  let keycon;
3760
3965
  const mouseenterHandler = () => {
3761
3966
  workspace.value?.focus();
@@ -3766,31 +3971,31 @@
3766
3971
  vue.onMounted(() => {
3767
3972
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3768
3973
  workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
3769
- keycon = new KeyController__default["default"](workspace.value);
3974
+ keycon = new KeyController__default.default(workspace.value);
3770
3975
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
3771
3976
  const ctrl = isMac ? "meta" : "ctrl";
3772
3977
  keycon.keyup("delete", (e) => {
3773
3978
  e.inputEvent.preventDefault();
3774
- if (!node.value || utils.isPage(node.value))
3979
+ if (!nodes.value || utils.isPage(nodes.value[0]))
3775
3980
  return;
3776
- services?.editorService.remove(node.value);
3981
+ services?.editorService.remove(nodes.value);
3777
3982
  }).keyup("backspace", (e) => {
3778
3983
  e.inputEvent.preventDefault();
3779
- if (!node.value || utils.isPage(node.value))
3984
+ if (!nodes.value || utils.isPage(nodes.value[0]))
3780
3985
  return;
3781
- services?.editorService.remove(node.value);
3986
+ services?.editorService.remove(nodes.value);
3782
3987
  }).keydown([ctrl, "c"], (e) => {
3783
3988
  e.inputEvent.preventDefault();
3784
- node.value && services?.editorService.copy(node.value);
3989
+ nodes.value && services?.editorService.copy(nodes.value);
3785
3990
  }).keydown([ctrl, "v"], (e) => {
3786
3991
  e.inputEvent.preventDefault();
3787
- node.value && services?.editorService.paste();
3992
+ nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
3788
3993
  }).keydown([ctrl, "x"], (e) => {
3789
3994
  e.inputEvent.preventDefault();
3790
- if (!node.value || utils.isPage(node.value))
3995
+ if (!nodes.value || utils.isPage(nodes.value[0]))
3791
3996
  return;
3792
- services?.editorService.copy(node.value);
3793
- services?.editorService.remove(node.value);
3997
+ services?.editorService.copy(nodes.value);
3998
+ services?.editorService.remove(nodes.value);
3794
3999
  }).keydown([ctrl, "z"], (e) => {
3795
4000
  e.inputEvent.preventDefault();
3796
4001
  services?.editorService.undo();
@@ -3852,6 +4057,7 @@
3852
4057
  };
3853
4058
  }
3854
4059
  });
4060
+
3855
4061
  const _hoisted_1 = {
3856
4062
  class: "m-editor-workspace",
3857
4063
  tabindex: "1",
@@ -3876,14 +4082,14 @@
3876
4082
  })
3877
4083
  ], 512);
3878
4084
  }
3879
- var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4085
+ const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
3880
4086
 
3881
4087
  class ComponentList extends BaseService {
4088
+ state = vue.reactive({
4089
+ list: []
4090
+ });
3882
4091
  constructor() {
3883
4092
  super([]);
3884
- this.state = vue.reactive({
3885
- list: []
3886
- });
3887
4093
  }
3888
4094
  setList(componentGroupList) {
3889
4095
  this.state.list = componentGroupList;
@@ -3892,7 +4098,7 @@
3892
4098
  return this.state.list;
3893
4099
  }
3894
4100
  }
3895
- var componentListService = new ComponentList();
4101
+ const componentListService = new ComponentList();
3896
4102
 
3897
4103
  const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3898
4104
  const MIN_LEFT_COLUMN_WIDTH = 45;
@@ -4004,13 +4210,15 @@
4004
4210
  const { height, width } = stageContainerRect;
4005
4211
  if (!width || !height)
4006
4212
  return 1;
4007
- if (width > stageRect.width && height > stageRect.height) {
4213
+ const stageWidth = stageRect.width + 30;
4214
+ const stageHeight = stageRect.height + 30;
4215
+ if (width > stageWidth && height > stageHeight) {
4008
4216
  return 1;
4009
4217
  }
4010
- return Math.min((width - 100) / stageRect.width || 1, (height - 100) / stageRect.height || 1);
4218
+ return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
4011
4219
  }
4012
4220
  }
4013
- var uiService = new Ui();
4221
+ const uiService = new Ui();
4014
4222
 
4015
4223
  const _sfc_main = vue.defineComponent({
4016
4224
  name: "m-editor",
@@ -4085,6 +4293,10 @@
4085
4293
  type: Number,
4086
4294
  default: 800
4087
4295
  },
4296
+ containerHighlightType: {
4297
+ type: String,
4298
+ default: StageCore.ContainerHighlightType.DEFAULT
4299
+ },
4088
4300
  stageRect: {
4089
4301
  type: [String, Object]
4090
4302
  },
@@ -4140,7 +4352,8 @@
4140
4352
  historyService,
4141
4353
  propsService,
4142
4354
  editorService,
4143
- uiService
4355
+ uiService,
4356
+ storageService
4144
4357
  };
4145
4358
  vue.provide("services", services);
4146
4359
  vue.provide("layerContentMenu", props.layerContentMenu);
@@ -4154,11 +4367,13 @@
4154
4367
  updateDragEl: props.updateDragEl,
4155
4368
  isContainer: props.isContainer,
4156
4369
  containerHighlightClassName: props.containerHighlightClassName,
4157
- containerHighlightDuration: props.containerHighlightDuration
4370
+ containerHighlightDuration: props.containerHighlightDuration,
4371
+ containerHighlightType: props.containerHighlightType
4158
4372
  }));
4159
4373
  return services;
4160
4374
  }
4161
4375
  });
4376
+
4162
4377
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4163
4378
  const _component_nav_menu = vue.resolveComponent("nav-menu");
4164
4379
  const _component_sidebar = vue.resolveComponent("sidebar");
@@ -4219,18 +4434,18 @@
4219
4434
  _: 3
4220
4435
  }, 8, ["code-options"]);
4221
4436
  }
4222
- var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
4437
+ const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
4223
4438
 
4224
- 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 border: 1px solid #d9dbdd;\n transition: transform 0.3s;\n box-sizing: content-box;\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}")();
4439
+ const index$1 = '';
4225
4440
 
4226
4441
  const defaultInstallOpt = {};
4227
- var index = {
4442
+ const index = {
4228
4443
  install: (app, opt) => {
4229
4444
  const option = Object.assign(defaultInstallOpt, opt || {});
4230
4445
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4231
4446
  setConfig(option);
4232
4447
  app.component(Editor.name, Editor);
4233
- app.component(uiSelect.name, uiSelect);
4448
+ app.component("m-fields-ui-select", _sfc_main$l);
4234
4449
  app.component(CodeLink.name, CodeLink);
4235
4450
  app.component(Code.name, Code);
4236
4451
  app.component(CodeEditor.name, CodeEditor);
@@ -4249,20 +4464,20 @@
4249
4464
  exports.PropsPanel = PropsPanel;
4250
4465
  exports.TMagicCodeEditor = CodeEditor;
4251
4466
  exports.TMagicEditor = Editor;
4252
- exports.ToolButton = ToolButton;
4467
+ exports.ToolButton = _sfc_main$f;
4253
4468
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
4254
4469
  exports.change2Fixed = change2Fixed;
4255
4470
  exports.debug = debug;
4256
- exports["default"] = index;
4471
+ exports.default = index;
4257
4472
  exports.editorService = editorService;
4258
4473
  exports.error = error;
4259
4474
  exports.eventsService = eventsService;
4260
4475
  exports.fillConfig = fillConfig;
4261
4476
  exports.fixNodeLeft = fixNodeLeft;
4477
+ exports.fixNodePosition = fixNodePosition;
4262
4478
  exports.generatePageName = generatePageName;
4263
4479
  exports.generatePageNameByApp = generatePageNameByApp;
4264
4480
  exports.getConfig = getConfig;
4265
- exports.getDefaultPropsValue = getDefaultPropsValue;
4266
4481
  exports.getGuideLineFromCache = getGuideLineFromCache;
4267
4482
  exports.getInitPositionStyle = getInitPositionStyle;
4268
4483
  exports.getNodeIndex = getNodeIndex;
@@ -4276,6 +4491,7 @@
4276
4491
  exports.propsService = propsService;
4277
4492
  exports.setConfig = setConfig;
4278
4493
  exports.setLayout = setLayout;
4494
+ exports.storageService = storageService;
4279
4495
  exports.uiService = uiService;
4280
4496
  exports.warn = warn;
4281
4497