@tmagic/editor 1.1.0-beta.0 → 1.1.0-beta.11

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} +1445 -1199
  3. package/dist/tmagic-editor.mjs.map +1 -0
  4. package/dist/tmagic-editor.umd.js +1483 -1236
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/package.json +22 -20
  7. package/src/Editor.vue +23 -15
  8. package/src/components/ContentMenu.vue +87 -99
  9. package/src/components/Icon.vue +2 -2
  10. package/src/components/ScrollViewer.vue +2 -2
  11. package/src/components/ToolButton.vue +151 -168
  12. package/src/fields/UISelect.vue +51 -72
  13. package/src/index.ts +2 -1
  14. package/src/layouts/AddPageBox.vue +3 -3
  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 +3 -3
  21. package/src/layouts/sidebar/LayerPanel.vue +52 -12
  22. package/src/layouts/sidebar/Sidebar.vue +1 -1
  23. package/src/layouts/sidebar/TabPane.vue +3 -3
  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 +141 -148
  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 +1101 -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
@@ -1,34 +1,34 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons'), require('lodash-es'), require('monaco-editor'), require('@tmagic/stage'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons', 'lodash-es', 'monaco-editor', '@tmagic/stage', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.icons, global.lodashEs, global.monaco, global.StageCore, global.schema, global.utils, global.events, global.core, global.Gesto, global.ElementPlus, global.KeyController));
5
- })(this, (function (exports, vue, serialize, icons, lodashEs, monaco, StageCore, schema, utils, events, core, Gesto, elementPlus, KeyController) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('@tmagic/stage'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', '@tmagic/stage', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'], factory) :
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
+ })(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,91 @@
178
174
  cancelHandler();
179
175
  }
180
176
  };
181
- return {
182
- Delete: vue.markRaw(icons.Delete),
183
- Pointer: vue.markRaw(icons.Pointer),
184
- Close: vue.markRaw(icons.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.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
221
+ key: 0,
222
+ content: "\u6E05\u9664"
223
+ }, {
224
+ default: vue.withCtx(() => [
225
+ vue.createVNode(_component_el_button, {
226
+ style: { "padding": "0" },
227
+ type: "danger",
228
+ icon: vue.unref(iconsVue.Close),
229
+ text: "",
230
+ onClick: vue.withModifiers(deleteHandler, ["stop"])
231
+ }, null, 8, ["icon", "onClick"])
232
+ ]),
233
+ _: 1
234
+ })) : vue.createCommentVNode("", true),
235
+ vue.createVNode(_component_el_tooltip, {
236
+ content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
237
+ }, {
238
+ default: vue.withCtx(() => [
239
+ vue.createVNode(_component_el_button, {
240
+ text: "",
241
+ style: { "padding": "0", "margin": "0" }
242
+ }, {
243
+ default: vue.withCtx(() => [
244
+ vue.createTextVNode(vue.toDisplayString(vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
245
+ ]),
246
+ _: 1
247
+ })
248
+ ]),
249
+ _: 1
250
+ }, 8, ["content"])
251
+ ]));
252
+ };
253
+ }
254
+ });
255
+
256
+ const UISelect_vue_vue_type_style_index_0_lang = '';
267
257
 
268
258
  const toString = (v, language) => {
269
259
  let value = "";
270
260
  if (typeof v !== "string") {
271
- value = serialize__default["default"](v, {
261
+ value = serialize__default.default(v, {
272
262
  space: 2,
273
263
  unsafe: true
274
264
  }).replace(/"(\w+)":\s/g, "$1: ");
@@ -280,7 +270,7 @@
280
270
  }
281
271
  return value;
282
272
  };
283
- const _sfc_main$j = vue.defineComponent({
273
+ const _sfc_main$k = vue.defineComponent({
284
274
  name: "magic-code-editor",
285
275
  props: {
286
276
  initValues: {
@@ -387,14 +377,15 @@
387
377
  };
388
378
  }
389
379
  });
380
+
390
381
  const _hoisted_1$c = {
391
382
  ref: "codeEditor",
392
383
  class: "magic-code-editor"
393
384
  };
394
- function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
385
+ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
395
386
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
396
387
  }
397
- var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
388
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$e]]);
398
389
 
399
390
  let $TMAGIC_EDITOR = {};
400
391
  const setConfig = (option) => {
@@ -403,6 +394,9 @@
403
394
  const getConfig = (key) => $TMAGIC_EDITOR[key];
404
395
 
405
396
  class UndoRedo {
397
+ elementList;
398
+ listCursor;
399
+ listMaxSize;
406
400
  constructor(listMaxSize = 200) {
407
401
  const minListMaxSize = 2;
408
402
  this.elementList = [];
@@ -479,17 +473,12 @@
479
473
  try {
480
474
  let beforeArgs = args;
481
475
  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];
476
+ beforeArgs = await beforeMethod(...beforeArgs) || [];
477
+ if (isError(beforeArgs))
478
+ throw beforeArgs;
479
+ if (!Array.isArray(beforeArgs)) {
480
+ beforeArgs = [beforeArgs];
487
481
  }
488
- beforeArgs = beforeArgs.map((v, index) => {
489
- if (typeof beforeReturnValue[index] === "undefined")
490
- return v;
491
- return beforeReturnValue[index];
492
- });
493
482
  }
494
483
  let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
495
484
  for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
@@ -503,12 +492,12 @@
503
492
  }
504
493
  };
505
494
  class BaseService extends events.EventEmitter {
495
+ pluginOptionsList = {};
496
+ middleware = {};
497
+ taskList = [];
498
+ doingTask = false;
506
499
  constructor(methods = [], serialMethods = []) {
507
500
  super();
508
- this.pluginOptionsList = {};
509
- this.middleware = {};
510
- this.taskList = [];
511
- this.doingTask = false;
512
501
  methods.forEach((propertyName) => {
513
502
  const scope = this;
514
503
  const sourceMethod = scope[propertyName];
@@ -565,14 +554,14 @@
565
554
  }
566
555
 
567
556
  class History extends BaseService {
557
+ state = vue.reactive({
558
+ pageSteps: {},
559
+ pageId: void 0,
560
+ canRedo: false,
561
+ canUndo: false
562
+ });
568
563
  constructor() {
569
564
  super([]);
570
- this.state = vue.reactive({
571
- pageSteps: {},
572
- pageId: void 0,
573
- canRedo: false,
574
- canUndo: false
575
- });
576
565
  this.on("change", this.setCanUndoRedo);
577
566
  }
578
567
  reset() {
@@ -641,88 +630,88 @@
641
630
  this.state.canUndo = undoRedo?.canUndo() || false;
642
631
  }
643
632
  }
644
- var historyService = new History();
633
+ const historyService = new History();
645
634
 
646
- class Props extends BaseService {
635
+ var Protocol = /* @__PURE__ */ ((Protocol2) => {
636
+ Protocol2["OBJECT"] = "object";
637
+ Protocol2["JSON"] = "json";
638
+ Protocol2["STRING"] = "string";
639
+ Protocol2["NUMBER"] = "number";
640
+ Protocol2["BOOLEAN"] = "boolean";
641
+ return Protocol2;
642
+ })(Protocol || {});
643
+ class WebStorage extends BaseService {
644
+ storage = globalThis.localStorage;
645
+ namespace = "tmagic";
647
646
  constructor() {
648
- super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "createId", "setNewItemId"]);
649
- this.state = vue.reactive({
650
- propsConfigMap: {},
651
- propsValueMap: {}
652
- });
647
+ super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
653
648
  }
654
- setPropsConfigs(configs) {
655
- Object.keys(configs).forEach((type) => {
656
- this.setPropsConfig(utils.toLine(type), configs[type]);
657
- });
658
- this.emit("props-configs-change");
649
+ async getStorage() {
650
+ return this.storage;
659
651
  }
660
- setPropsConfig(type, config) {
661
- this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
652
+ async getNamespace() {
653
+ return this.namespace;
662
654
  }
663
- async getPropsConfig(type) {
664
- if (type === "area") {
665
- return await this.getPropsConfig("button");
655
+ async clear() {
656
+ const storage2 = await this.getStorage();
657
+ storage2.clear();
658
+ }
659
+ async getItem(key, options = {}) {
660
+ const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
661
+ const { protocol = options.protocol, item } = this.getValueAndProtocol(storage.getItem(`${options.namespace || namespace}:${key}`));
662
+ if (item === null)
663
+ return null;
664
+ switch (protocol) {
665
+ case "object" /* OBJECT */:
666
+ return eval(`(${item})`);
667
+ case "json" /* JSON */:
668
+ return JSON.parse(item);
669
+ case "number" /* NUMBER */:
670
+ return Number(item);
671
+ case "boolean" /* BOOLEAN */:
672
+ return Boolean(item);
673
+ default:
674
+ return item;
666
675
  }
667
- return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
668
676
  }
669
- setPropsValues(values) {
670
- Object.keys(values).forEach((type) => {
671
- this.setPropsValue(utils.toLine(type), values[type]);
672
- });
677
+ async key(index) {
678
+ const storage2 = await this.getStorage();
679
+ return storage2.key(index);
673
680
  }
674
- setPropsValue(type, value) {
675
- this.state.propsValueMap[type] = value;
681
+ async removeItem(key2, options2 = {}) {
682
+ const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
683
+ storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
676
684
  }
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;
685
+ async setItem(key2, value, options2 = {}) {
686
+ const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
687
+ let item2 = value;
688
+ const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
689
+ if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
690
+ item2 = `${protocol2}${value}`;
691
+ } else {
692
+ item2 = `${protocol2}${serialize__default.default(value)}`;
693
+ }
694
+ storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
695
+ }
696
+ getValueAndProtocol(value) {
697
+ let protocol2 = "";
698
+ if (value === null) {
699
+ return {
700
+ item: value,
701
+ protocol: protocol2
702
+ };
686
703
  }
687
- const data = lodashEs.cloneDeep(defaultValue);
688
- await this.setNewItemId(data);
704
+ const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
705
+ protocol2 = $1;
706
+ return $3;
707
+ });
689
708
  return {
690
- ...getDefaultPropsValue(type, await this.createId(type)),
691
- ...lodashEs.mergeWith(lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
709
+ protocol: protocol2,
710
+ item: item2
692
711
  };
693
712
  }
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
713
  }
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();
714
+ const storageService = new WebStorage();
726
715
 
727
716
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
728
717
  LayerOffset2["TOP"] = "top";
@@ -774,10 +763,10 @@
774
763
  top: 0,
775
764
  left: 0
776
765
  });
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;
766
+ const getMiddleTop = (node, parentNode, stage) => {
767
+ let height = node.style?.height || 0;
768
+ if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
769
+ return node.style?.top;
781
770
  if (!utils.isNumber(height)) {
782
771
  height = 0;
783
772
  }
@@ -788,12 +777,11 @@
788
777
  }
789
778
  return (parentHeight - height) / 2;
790
779
  };
791
- const getInitPositionStyle = (style = {}, layout, parentNode, stage) => {
780
+ const getInitPositionStyle = (style = {}, layout) => {
792
781
  if (layout === Layout.ABSOLUTE) {
793
782
  return {
794
783
  ...style,
795
- position: "absolute",
796
- top: getMiddleTop(style, parentNode, stage)
784
+ position: "absolute"
797
785
  };
798
786
  }
799
787
  if (layout === Layout.RELATIVE) {
@@ -879,34 +867,229 @@
879
867
  return config.style?.left;
880
868
  const el = doc.getElementById(`${config.id}`);
881
869
  const parentEl = doc.getElementById(`${parent.id}`);
882
- if (el && parentEl && el.offsetWidth + config.style?.left > parentEl.offsetWidth) {
870
+ const left = Number(config.style?.left) || 0;
871
+ if (el && parentEl && el.offsetWidth + left > parentEl.offsetWidth) {
883
872
  return parentEl.offsetWidth - el.offsetWidth;
884
873
  }
885
874
  return config.style.left;
886
875
  };
887
-
888
- const log = (...args) => {
876
+ const fixNodePosition = (config, parent, stage) => {
877
+ if (config.style?.position !== "absolute") {
878
+ return config.style;
879
+ }
880
+ return {
881
+ ...config.style || {},
882
+ top: getMiddleTop(config, parent, stage),
883
+ left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
884
+ };
889
885
  };
890
- const info = (...args) => {
886
+
887
+ class Props extends BaseService {
888
+ state = vue.reactive({
889
+ propsConfigMap: {},
890
+ propsValueMap: {}
891
+ });
892
+ constructor() {
893
+ super([
894
+ "setPropsConfig",
895
+ "getPropsConfig",
896
+ "setPropsValue",
897
+ "getPropsValue",
898
+ "createId",
899
+ "setNewItemId",
900
+ "getDefaultPropsValue"
901
+ ]);
902
+ }
903
+ setPropsConfigs(configs) {
904
+ Object.keys(configs).forEach((type) => {
905
+ this.setPropsConfig(utils.toLine(type), configs[type]);
906
+ });
907
+ this.emit("props-configs-change");
908
+ }
909
+ setPropsConfig(type, config) {
910
+ this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
911
+ }
912
+ async getPropsConfig(type) {
913
+ if (type === "area") {
914
+ return await this.getPropsConfig("button");
915
+ }
916
+ return lodashEs.cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
917
+ }
918
+ setPropsValues(values) {
919
+ Object.keys(values).forEach((type) => {
920
+ this.setPropsValue(utils.toLine(type), values[type]);
921
+ });
922
+ }
923
+ setPropsValue(type, value) {
924
+ this.state.propsValueMap[type] = value;
925
+ }
926
+ async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
927
+ if (type === "area") {
928
+ const value = await this.getPropsValue("button");
929
+ value.className = "action-area";
930
+ value.text = "";
931
+ if (value.style) {
932
+ value.style.backgroundColor = "rgba(255, 255, 255, 0)";
933
+ }
934
+ return value;
935
+ }
936
+ const [id, defaultPropsValue, data] = await Promise.all([
937
+ this.createId(type),
938
+ this.getDefaultPropsValue(type),
939
+ this.setNewItemId(lodashEs.cloneDeep({
940
+ type,
941
+ ...defaultValue
942
+ }))
943
+ ]);
944
+ return {
945
+ id,
946
+ ...defaultPropsValue,
947
+ ...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
948
+ };
949
+ }
950
+ guid(digit = 8) {
951
+ return "x".repeat(digit).replace(/[xy]/g, (c) => {
952
+ const r = Math.random() * 16 | 0;
953
+ const v = c == "x" ? r : r & 3 | 8;
954
+ return v.toString(16);
955
+ });
956
+ }
957
+ async createId(type) {
958
+ return `${type}_${this.guid()}`;
959
+ }
960
+ async setNewItemId(config, parent) {
961
+ const oldId = config.id;
962
+ config.id = await this.createId(config.type || "component");
963
+ if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
964
+ updatePopId(oldId, config.id, parent);
965
+ }
966
+ if (config.items && Array.isArray(config.items)) {
967
+ for (const item of config.items) {
968
+ await this.setNewItemId(item, config);
969
+ }
970
+ }
971
+ return config;
972
+ }
973
+ async getDefaultPropsValue(type) {
974
+ return ["page", "container"].includes(type) ? {
975
+ type,
976
+ layout: "absolute",
977
+ style: {},
978
+ name: type,
979
+ items: []
980
+ } : {
981
+ type,
982
+ style: {},
983
+ name: type
984
+ };
985
+ }
986
+ }
987
+ const updatePopId = (oldId, popId, pageConfig) => {
988
+ pageConfig.items?.forEach((config) => {
989
+ if (config.pop === oldId) {
990
+ config.pop = popId;
991
+ return;
992
+ }
993
+ if (config.popId === oldId) {
994
+ config.popId = popId;
995
+ return;
996
+ }
997
+ if (Array.isArray(config.items)) {
998
+ updatePopId(oldId, popId, config);
999
+ }
1000
+ });
891
1001
  };
892
- const warn = (...args) => {
1002
+ const propsService = new Props();
1003
+
1004
+ const beforePaste = async (position, config) => {
1005
+ if (!config[0]?.style)
1006
+ return config;
1007
+ const curNode = editorService.get("node");
1008
+ const { left: referenceLeft, top: referenceTop } = config[0].style;
1009
+ const pasteConfigs = await Promise.all(config.map(async (configItem) => {
1010
+ const { offsetX = 0, offsetY = 0, ...positionClone } = position;
1011
+ let pastePosition = positionClone;
1012
+ if (!lodashEs.isEmpty(pastePosition) && curNode.items) {
1013
+ pastePosition = getPositionInContainer(pastePosition, curNode.id);
1014
+ }
1015
+ if (pastePosition.left && configItem.style?.left) {
1016
+ pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
1017
+ }
1018
+ if (pastePosition.top && configItem.style?.top) {
1019
+ pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
1020
+ }
1021
+ const pasteConfig = await propsService.setNewItemId(configItem, editorService.get("root"));
1022
+ if (pasteConfig.style) {
1023
+ const { left, top } = pasteConfig.style;
1024
+ if (typeof left === "number" || !!left && !isNaN(Number(left))) {
1025
+ pasteConfig.style.left = Number(left) + offsetX;
1026
+ }
1027
+ if (typeof top === "number" || !!top && !isNaN(Number(top))) {
1028
+ pasteConfig.style.top = Number(top) + offsetY;
1029
+ }
1030
+ pasteConfig.style = {
1031
+ ...pasteConfig.style,
1032
+ ...pastePosition
1033
+ };
1034
+ }
1035
+ if (utils.isPage(pasteConfig)) {
1036
+ pasteConfig.name = generatePageNameByApp(editorService.get("root"));
1037
+ }
1038
+ return pasteConfig;
1039
+ }));
1040
+ return pasteConfigs;
893
1041
  };
894
- const debug = (...args) => {
1042
+ const getPositionInContainer = (position = {}, id) => {
1043
+ let { left = 0, top = 0 } = position;
1044
+ const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
1045
+ const parentElRect = parentEl?.getBoundingClientRect();
1046
+ left = left - (parentElRect?.left || 0);
1047
+ top = top - (parentElRect?.top || 0);
1048
+ return {
1049
+ left,
1050
+ top
1051
+ };
895
1052
  };
896
- const error = (...args) => {
1053
+ const getAddParent = (node) => {
1054
+ const curNode = editorService.get("node");
1055
+ let parentNode;
1056
+ if (utils.isPage(node)) {
1057
+ parentNode = editorService.get("root");
1058
+ } else if (curNode.items) {
1059
+ parentNode = curNode;
1060
+ } else {
1061
+ parentNode = editorService.getParentById(curNode.id, false);
1062
+ }
1063
+ return parentNode;
897
1064
  };
898
1065
 
899
1066
  class Editor$1 extends BaseService {
1067
+ state = vue.reactive({
1068
+ root: null,
1069
+ page: null,
1070
+ parent: null,
1071
+ node: null,
1072
+ nodes: [],
1073
+ stage: null,
1074
+ highlightNode: null,
1075
+ modifiedNodeIds: /* @__PURE__ */ new Map(),
1076
+ pageLength: 0
1077
+ });
1078
+ isHistoryStateChange = false;
900
1079
  constructor() {
901
1080
  super([
902
1081
  "getLayout",
903
1082
  "select",
1083
+ "doAdd",
904
1084
  "add",
1085
+ "doRemove",
905
1086
  "remove",
1087
+ "doUpdate",
906
1088
  "update",
907
1089
  "sort",
908
1090
  "copy",
909
1091
  "paste",
1092
+ "duAlignCenter",
910
1093
  "alignCenter",
911
1094
  "moveLayer",
912
1095
  "moveToContainer",
@@ -915,20 +1098,12 @@
915
1098
  "redo",
916
1099
  "highlight"
917
1100
  ], ["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
1101
  }
930
1102
  set(name, value) {
931
1103
  this.state[name] = value;
1104
+ if (name === "nodes") {
1105
+ this.set("node", value[0]);
1106
+ }
932
1107
  if (name === "root") {
933
1108
  this.state.pageLength = value?.items?.length || 0;
934
1109
  this.emit("root-change", value);
@@ -983,9 +1158,9 @@
983
1158
  }
984
1159
  return Layout.ABSOLUTE;
985
1160
  }
986
- async select(config2) {
987
- const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
988
- this.set("node", node);
1161
+ async select(config) {
1162
+ const { node, page, parent } = this.selectedConfigExceptionHandler(config);
1163
+ this.set("nodes", [node]);
989
1164
  this.set("page", page || null);
990
1165
  this.set("parent", parent || null);
991
1166
  if (page) {
@@ -1025,65 +1200,83 @@
1025
1200
  this.get("stage")?.select(nextPage.id);
1026
1201
  return nextPage;
1027
1202
  }
1028
- highlight(config2) {
1029
- const { node } = this.selectedConfigExceptionHandler(config2);
1203
+ highlight(config) {
1204
+ const { node } = this.selectedConfigExceptionHandler(config);
1030
1205
  const currentHighlightNode = this.get("highlightNode");
1031
1206
  if (currentHighlightNode === node)
1032
1207
  return;
1033
1208
  this.set("highlightNode", node);
1034
1209
  }
1035
- async add(addNode, parent) {
1036
- const { type, ...config2 } = addNode;
1210
+ multiSelect(ids) {
1211
+ const nodes = [];
1212
+ const idsUnique = lodashEs.uniq(ids);
1213
+ idsUnique.forEach((id) => {
1214
+ const { node } = this.getNodeInfo(id);
1215
+ if (!node)
1216
+ return;
1217
+ nodes.push(node);
1218
+ });
1219
+ this.set("nodes", nodes);
1220
+ }
1221
+ async doAdd(node, parent) {
1222
+ const root = this.get("root");
1037
1223
  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) {
1224
+ const stage = this.get("stage");
1225
+ if ((parent?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
1055
1226
  throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
1056
1227
  }
1057
- parentNode?.items?.push(newNode);
1058
- 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();
1228
+ parent?.items?.push(node);
1229
+ const layout = await this.getLayout(vue.toRaw(parent), node);
1230
+ node.style = getInitPositionStyle(node.style, layout);
1231
+ await stage?.add({
1232
+ config: lodashEs.cloneDeep(node),
1233
+ parent: lodashEs.cloneDeep(parent),
1234
+ parentId: parent.id,
1235
+ root: lodashEs.cloneDeep(root)
1236
+ });
1237
+ node.style = fixNodePosition(node, parent, stage);
1238
+ await stage?.update({ config: lodashEs.cloneDeep(node), parentId: parent.id, root: lodashEs.cloneDeep(root) });
1239
+ this.addModifiedNodeId(node.id);
1240
+ return node;
1241
+ }
1242
+ async add(addNode, parent) {
1243
+ const stage = this.get("stage");
1244
+ const addNodes = [];
1245
+ if (!Array.isArray(addNode)) {
1246
+ const { type, inputEvent, ...config } = addNode;
1247
+ if (!type)
1248
+ throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
1249
+ addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
1250
+ } else {
1251
+ addNodes.push(...addNode);
1072
1252
  }
1073
- stage?.select(newNode.id);
1074
- if (isPage2) {
1075
- this.state.pageLength += 1;
1253
+ const newNodes = await Promise.all(addNodes.map((node) => {
1254
+ const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
1255
+ if (!parentNode)
1256
+ throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
1257
+ return this.doAdd(node, parentNode);
1258
+ }));
1259
+ if (newNodes.length > 1) {
1260
+ const newNodeIds = newNodes.map((node) => node.id);
1261
+ stage?.multiSelect(newNodeIds);
1262
+ await this.multiSelect(newNodeIds);
1263
+ } else {
1264
+ await this.select(newNodes[0]);
1265
+ if (utils.isPage(newNodes[0])) {
1266
+ this.state.pageLength += 1;
1267
+ } else {
1268
+ stage?.select(newNodes[0].id);
1269
+ }
1076
1270
  }
1077
- this.emit("add", newNode);
1078
- return newNode;
1271
+ this.pushHistoryState();
1272
+ this.emit("add", newNodes);
1273
+ return newNodes.length > 1 ? newNodes[0] : newNodes;
1079
1274
  }
1080
- async remove(node) {
1081
- if (!node?.id)
1082
- return;
1275
+ async doRemove(node) {
1083
1276
  const root = this.get("root");
1084
1277
  if (!root)
1085
1278
  throw new Error("\u6CA1\u6709root");
1086
- const { parent, node: curNode } = this.getNodeInfo(node.id, false);
1279
+ const { parent, node: curNode } = this.getNodeInfo(node.id);
1087
1280
  if (!parent || !curNode)
1088
1281
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1089
1282
  const index = getNodeIndex(curNode, parent);
@@ -1091,7 +1284,7 @@
1091
1284
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
1092
1285
  parent.items?.splice(index, 1);
1093
1286
  const stage = this.get("stage");
1094
- stage?.remove({ id: node.id, root: lodashEs.cloneDeep(this.get("root")) });
1287
+ stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
1095
1288
  if (node.type === schema.NodeType.PAGE) {
1096
1289
  this.state.pageLength -= 1;
1097
1290
  if (root.items[0]) {
@@ -1105,26 +1298,28 @@
1105
1298
  this.set("highlightNode", null);
1106
1299
  this.resetModifiedNodeId();
1107
1300
  historyService.reset();
1108
- this.emit("remove", node);
1109
- return node;
1301
+ return;
1110
1302
  }
1111
1303
  } else {
1112
1304
  await this.select(parent);
1113
1305
  stage?.select(parent.id);
1114
1306
  }
1115
1307
  this.addModifiedNodeId(parent.id);
1308
+ }
1309
+ async remove(nodeOrNodeList) {
1310
+ const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
1311
+ await Promise.all(nodes.map((node) => this.doRemove(node)));
1116
1312
  this.pushHistoryState();
1117
- this.emit("remove", node);
1118
- return node;
1313
+ this.emit("remove");
1119
1314
  }
1120
- async update(config2) {
1121
- if (!config2?.id)
1315
+ async doUpdate(config) {
1316
+ if (!config?.id)
1122
1317
  throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
1123
- const info = this.getNodeInfo(config2.id, false);
1318
+ const info = this.getNodeInfo(config.id, false);
1124
1319
  if (!info.node)
1125
- throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
1320
+ throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
1126
1321
  const node = lodashEs.cloneDeep(vue.toRaw(info.node));
1127
- let newConfig = await this.toggleFixedPosition(vue.toRaw(config2), node, this.get("root"));
1322
+ let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, this.get("root"));
1128
1323
  newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue) => {
1129
1324
  if (Array.isArray(srcValue)) {
1130
1325
  return srcValue;
@@ -1149,18 +1344,28 @@
1149
1344
  newConfig = setLayout(newConfig, newLayout);
1150
1345
  }
1151
1346
  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")) });
1347
+ const nodes = this.get("nodes");
1348
+ const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
1349
+ nodes.splice(targetIndex, 1, newConfig);
1350
+ this.set("nodes", nodes);
1351
+ this.get("stage")?.update({
1352
+ config: lodashEs.cloneDeep(newConfig),
1353
+ parentId: parent.id,
1354
+ root: lodashEs.cloneDeep(this.get("root"))
1355
+ });
1156
1356
  if (newConfig.type === schema.NodeType.PAGE) {
1157
1357
  this.set("page", newConfig);
1158
1358
  }
1159
1359
  this.addModifiedNodeId(newConfig.id);
1160
- this.pushHistoryState();
1161
- this.emit("update", newConfig);
1162
1360
  return newConfig;
1163
1361
  }
1362
+ async update(config) {
1363
+ const nodes = Array.isArray(config) ? config : [config];
1364
+ const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
1365
+ this.pushHistoryState();
1366
+ this.emit("update", newNodes);
1367
+ return newNodes.length > 1 ? newNodes[0] : newNodes;
1368
+ }
1164
1369
  async sort(id1, id2) {
1165
1370
  const node = this.get("node");
1166
1371
  const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
@@ -1171,65 +1376,57 @@
1171
1376
  parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
1172
1377
  await this.update(parent);
1173
1378
  await this.select(node);
1174
- this.get("stage")?.update({ config: lodashEs.cloneDeep(node), root: lodashEs.cloneDeep(this.get("root")) });
1379
+ this.get("stage")?.update({
1380
+ config: lodashEs.cloneDeep(node),
1381
+ parentId: parent.id,
1382
+ root: lodashEs.cloneDeep(this.get("root"))
1383
+ });
1175
1384
  this.addModifiedNodeId(parent.id);
1176
1385
  this.pushHistoryState();
1177
1386
  }
1178
- async copy(config2) {
1179
- globalThis.localStorage.setItem(COPY_STORAGE_KEY, serialize__default["default"](config2));
1387
+ async copy(config) {
1388
+ await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
1389
+ protocol: Protocol.OBJECT
1390
+ });
1180
1391
  }
1181
1392
  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);
1393
+ const config = await storageService.getItem(COPY_STORAGE_KEY);
1394
+ if (!Array.isArray(config))
1191
1395
  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);
1396
+ const pasteConfigs = await beforePaste(position, config);
1397
+ return this.add(pasteConfigs);
1204
1398
  }
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));
1399
+ async doAlignCenter(config) {
1400
+ const parent = this.getParentById(config.id);
1401
+ if (!parent)
1402
+ throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
1403
+ const node = lodashEs.cloneDeep(vue.toRaw(config));
1404
+ const layout = await this.getLayout(parent, node);
1209
1405
  if (layout === Layout.RELATIVE) {
1210
- return;
1406
+ return config;
1211
1407
  }
1212
1408
  if (!node.style)
1213
- return;
1409
+ return config;
1214
1410
  const stage = this.get("stage");
1215
1411
  const doc = stage?.renderer.contentWindow?.document;
1216
1412
  if (doc) {
1217
- const parentEl = doc.getElementById(`${parent.id}`);
1218
1413
  const el = doc.getElementById(`${node.id}`);
1414
+ const parentEl = el?.offsetParent;
1219
1415
  if (parentEl && el) {
1220
1416
  node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
1221
1417
  }
1222
1418
  } else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
1223
1419
  node.style.left = (parent.style.width - node.style.width) / 2;
1224
1420
  }
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;
1421
+ return node;
1422
+ }
1423
+ async alignCenter(config) {
1424
+ const nodes = Array.isArray(config) ? config : [config];
1425
+ const stage = this.get("stage");
1426
+ const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
1427
+ const newNode = await this.update(newNodes);
1428
+ await stage?.multiSelect(newNodes.map((node) => node.id));
1429
+ return newNode;
1233
1430
  }
1234
1431
  async moveLayer(offset) {
1235
1432
  const parent = this.get("parent");
@@ -1245,28 +1442,29 @@
1245
1442
  }
1246
1443
  this.get("stage")?.update({
1247
1444
  config: lodashEs.cloneDeep(vue.toRaw(parent)),
1445
+ parentId: parent.id,
1248
1446
  root: lodashEs.cloneDeep(this.get("root"))
1249
1447
  });
1250
1448
  }
1251
- async moveToContainer(config2, targetId) {
1252
- const { node, parent } = this.getNodeInfo(config2.id, false);
1449
+ async moveToContainer(config, targetId) {
1450
+ const { node, parent } = this.getNodeInfo(config.id, false);
1253
1451
  const target = this.getNodeById(targetId, false);
1254
1452
  const stage = this.get("stage");
1255
1453
  if (node && parent && stage) {
1256
1454
  const root = lodashEs.cloneDeep(this.get("root"));
1257
1455
  const index = getNodeIndex(node, parent);
1258
1456
  parent.items?.splice(index, 1);
1259
- await stage.remove({ id: node.id, root });
1457
+ await stage.remove({ id: node.id, parentId: parent.id, root });
1260
1458
  const layout = await this.getLayout(target);
1261
- const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config2, (objValue, srcValue) => {
1459
+ const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
1262
1460
  if (Array.isArray(srcValue)) {
1263
1461
  return srcValue;
1264
1462
  }
1265
1463
  });
1266
- newConfig.style = getInitPositionStyle(newConfig.style, layout, target, stage);
1464
+ newConfig.style = getInitPositionStyle(newConfig.style, layout);
1267
1465
  target.items.push(newConfig);
1268
1466
  await stage.select(targetId);
1269
- await stage.update({ config: lodashEs.cloneDeep(target), root });
1467
+ await stage.update({ config: lodashEs.cloneDeep(target), parentId: parent.id, root });
1270
1468
  await this.select(newConfig);
1271
1469
  stage.select(newConfig.id);
1272
1470
  this.addModifiedNodeId(target.id);
@@ -1289,7 +1487,7 @@
1289
1487
  const node = vue.toRaw(this.get("node"));
1290
1488
  if (!node || utils.isPage(node))
1291
1489
  return;
1292
- const { style, id } = node;
1490
+ const { style, id, type } = node;
1293
1491
  if (!style || style.position !== "absolute")
1294
1492
  return;
1295
1493
  if (top && !utils.isNumber(style.top))
@@ -1298,6 +1496,7 @@
1298
1496
  return;
1299
1497
  this.update({
1300
1498
  id,
1499
+ type,
1301
1500
  style: {
1302
1501
  ...style,
1303
1502
  left: Number(style.left) + left,
@@ -1309,6 +1508,7 @@
1309
1508
  this.removeAllListeners();
1310
1509
  this.set("root", null);
1311
1510
  this.set("node", null);
1511
+ this.set("nodes", []);
1312
1512
  this.set("page", null);
1313
1513
  this.set("parent", null);
1314
1514
  }
@@ -1355,12 +1555,12 @@
1355
1555
  }
1356
1556
  return newConfig;
1357
1557
  }
1358
- selectedConfigExceptionHandler(config2) {
1558
+ selectedConfigExceptionHandler(config) {
1359
1559
  let id;
1360
- if (typeof config2 === "string" || typeof config2 === "number") {
1361
- id = config2;
1560
+ if (typeof config === "string" || typeof config === "number") {
1561
+ id = config;
1362
1562
  } else {
1363
- id = config2.id;
1563
+ id = config.id;
1364
1564
  }
1365
1565
  if (!id) {
1366
1566
  throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
@@ -1378,7 +1578,7 @@
1378
1578
  };
1379
1579
  }
1380
1580
  }
1381
- var editorService = new Editor$1();
1581
+ const editorService = new Editor$1();
1382
1582
 
1383
1583
  const eventMap = vue.reactive({});
1384
1584
  const methodMap = vue.reactive({});
@@ -1422,7 +1622,7 @@
1422
1622
  return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
1423
1623
  }
1424
1624
  }
1425
- var eventsService = new Events();
1625
+ const eventsService = new Events();
1426
1626
 
1427
1627
  const fillConfig = (config = []) => [
1428
1628
  {
@@ -1628,22 +1828,35 @@
1628
1828
  }
1629
1829
  ];
1630
1830
  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
1831
+
1832
+ const log = (...args) => {
1833
+ if (process.env.NODE_ENV === "development") {
1834
+ console.log("magic editor: ", ...args);
1835
+ }
1836
+ };
1837
+ const info = (...args) => {
1838
+ if (process.env.NODE_ENV === "development") {
1839
+ console.info("magic editor: ", ...args);
1840
+ }
1841
+ };
1842
+ const warn = (...args) => {
1843
+ if (process.env.NODE_ENV === "development") {
1844
+ console.warn("magic editor: ", ...args);
1845
+ }
1846
+ };
1847
+ const debug = (...args) => {
1848
+ if (process.env.NODE_ENV === "development") {
1849
+ console.debug("magic editor: ", ...args);
1850
+ }
1851
+ };
1852
+ const error = (...args) => {
1853
+ if (process.env.NODE_ENV === "development") {
1854
+ console.error("magic editor: ", ...args);
1855
+ }
1643
1856
  };
1644
1857
 
1645
- const _sfc_main$i = vue.defineComponent({
1646
- components: { Plus: icons.Plus },
1858
+ const _sfc_main$j = vue.defineComponent({
1859
+ components: { Plus: iconsVue.Plus },
1647
1860
  setup() {
1648
1861
  const services = vue.inject("services");
1649
1862
  return {
@@ -1659,10 +1872,11 @@
1659
1872
  };
1660
1873
  }
1661
1874
  });
1875
+
1662
1876
  const _hoisted_1$b = { class: "m-editor-empty-panel" };
1663
1877
  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) {
1878
+ const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1879
+ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1666
1880
  const _component_plus = vue.resolveComponent("plus");
1667
1881
  const _component_el_icon = vue.resolveComponent("el-icon");
1668
1882
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
@@ -1679,14 +1893,14 @@
1679
1893
  _: 1
1680
1894
  })
1681
1895
  ]),
1682
- _hoisted_3$2
1896
+ _hoisted_3$1
1683
1897
  ])
1684
1898
  ])
1685
1899
  ]);
1686
1900
  }
1687
- var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
1901
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$d]]);
1688
1902
 
1689
- const _sfc_main$h = vue.defineComponent({
1903
+ const _sfc_main$i = vue.defineComponent({
1690
1904
  name: "m-editor-resize",
1691
1905
  props: {
1692
1906
  type: {
@@ -1700,7 +1914,7 @@
1700
1914
  vue.onMounted(() => {
1701
1915
  if (!target.value)
1702
1916
  return;
1703
- getso = new Gesto__default["default"](target.value, {
1917
+ getso = new Gesto__default.default(target.value, {
1704
1918
  container: window,
1705
1919
  pinchOutside: true
1706
1920
  }).on("drag", (e) => {
@@ -1728,18 +1942,19 @@
1728
1942
  };
1729
1943
  }
1730
1944
  });
1945
+
1731
1946
  const _hoisted_1$a = {
1732
1947
  ref: "target",
1733
1948
  class: "m-editor-resizer"
1734
1949
  };
1735
- function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1950
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1736
1951
  return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
1737
1952
  vue.renderSlot(_ctx.$slots, "default")
1738
1953
  ], 512);
1739
1954
  }
1740
- var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
1955
+ const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$c]]);
1741
1956
 
1742
- const _sfc_main$g = vue.defineComponent({
1957
+ const _sfc_main$h = vue.defineComponent({
1743
1958
  components: {
1744
1959
  AddPageBox,
1745
1960
  Resizer
@@ -1768,12 +1983,13 @@
1768
1983
  };
1769
1984
  }
1770
1985
  });
1986
+
1771
1987
  const _hoisted_1$9 = { class: "m-editor" };
1772
1988
  const _hoisted_2$3 = {
1773
1989
  key: 1,
1774
1990
  class: "m-editor-content"
1775
1991
  };
1776
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1992
+ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
1777
1993
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
1778
1994
  const _component_resizer = vue.resolveComponent("resizer");
1779
1995
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
@@ -1819,11 +2035,11 @@
1819
2035
  ]))
1820
2036
  ]);
1821
2037
  }
1822
- var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
2038
+ const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$b]]);
1823
2039
 
1824
- const _sfc_main$f = vue.defineComponent({
2040
+ const _sfc_main$g = vue.defineComponent({
1825
2041
  name: "m-icon",
1826
- components: { Edit: icons.Edit },
2042
+ components: { Edit: iconsVue.Edit },
1827
2043
  props: {
1828
2044
  icon: {
1829
2045
  type: [String, Object]
@@ -1835,8 +2051,9 @@
1835
2051
  };
1836
2052
  }
1837
2053
  });
2054
+
1838
2055
  const _hoisted_1$8 = ["src"];
1839
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2056
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
1840
2057
  const _component_edit = vue.resolveComponent("edit");
1841
2058
  const _component_el_icon = vue.resolveComponent("el-icon");
1842
2059
  return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
@@ -1844,10 +2061,12 @@
1844
2061
  vue.createVNode(_component_edit)
1845
2062
  ]),
1846
2063
  _: 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", {
2064
+ })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 1 }, {
2065
+ default: vue.withCtx(() => [
2066
+ vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$8)
2067
+ ]),
2068
+ _: 1
2069
+ })) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
1851
2070
  key: 2,
1852
2071
  class: vue.normalizeClass(_ctx.icon)
1853
2072
  }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
@@ -1857,10 +2076,19 @@
1857
2076
  _: 1
1858
2077
  }));
1859
2078
  }
1860
- var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
2079
+ const MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$a]]);
1861
2080
 
1862
- const _sfc_main$e = vue.defineComponent({
1863
- components: { MIcon, ArrowDown: icons.ArrowDown },
2081
+ const _hoisted_1$7 = {
2082
+ key: 1,
2083
+ class: "menu-item-text"
2084
+ };
2085
+ const _hoisted_2$2 = {
2086
+ class: "menu-item-text",
2087
+ style: { "margin": "0 5px" }
2088
+ };
2089
+ const _hoisted_3 = { class: "el-dropdown-link menubar-menu-button" };
2090
+ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
2091
+ __name: "ToolButton",
1864
2092
  props: {
1865
2093
  data: {
1866
2094
  type: [Object, String],
@@ -1875,7 +2103,8 @@
1875
2103
  default: "click"
1876
2104
  }
1877
2105
  },
1878
- setup(props) {
2106
+ setup(__props) {
2107
+ const props = __props;
1879
2108
  const services = vue.inject("services");
1880
2109
  const uiService = services?.uiService;
1881
2110
  const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
@@ -1899,7 +2128,7 @@
1899
2128
  case "delete":
1900
2129
  return {
1901
2130
  type: "button",
1902
- icon: vue.markRaw(icons.Delete),
2131
+ icon: vue.markRaw(iconsVue.Delete),
1903
2132
  tooltip: "\u522A\u9664",
1904
2133
  disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
1905
2134
  handler: () => services?.editorService.remove(services?.editorService.get("node"))
@@ -1907,7 +2136,7 @@
1907
2136
  case "undo":
1908
2137
  return {
1909
2138
  type: "button",
1910
- icon: vue.markRaw(icons.Back),
2139
+ icon: vue.markRaw(iconsVue.Back),
1911
2140
  tooltip: "\u540E\u9000",
1912
2141
  disabled: () => !services?.historyService.state.canUndo,
1913
2142
  handler: () => services?.editorService.undo()
@@ -1915,7 +2144,7 @@
1915
2144
  case "redo":
1916
2145
  return {
1917
2146
  type: "button",
1918
- icon: vue.markRaw(icons.Right),
2147
+ icon: vue.markRaw(iconsVue.Right),
1919
2148
  tooltip: "\u524D\u8FDB",
1920
2149
  disabled: () => !services?.historyService.state.canRedo,
1921
2150
  handler: () => services?.editorService.redo()
@@ -1923,28 +2152,28 @@
1923
2152
  case "zoom-in":
1924
2153
  return {
1925
2154
  type: "button",
1926
- icon: vue.markRaw(icons.ZoomIn),
2155
+ icon: vue.markRaw(iconsVue.ZoomIn),
1927
2156
  tooltip: "\u653E\u5927",
1928
2157
  handler: zoomInHandler
1929
2158
  };
1930
2159
  case "zoom-out":
1931
2160
  return {
1932
2161
  type: "button",
1933
- icon: vue.markRaw(icons.ZoomOut),
2162
+ icon: vue.markRaw(iconsVue.ZoomOut),
1934
2163
  tooltip: "\u7E2E\u5C0F",
1935
2164
  handler: zoomOutHandler
1936
2165
  };
1937
2166
  case "rule":
1938
2167
  return {
1939
2168
  type: "button",
1940
- icon: vue.markRaw(icons.ScaleToOriginal),
2169
+ icon: vue.markRaw(iconsVue.ScaleToOriginal),
1941
2170
  tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
1942
2171
  handler: () => uiService?.set("showRule", !showRule.value)
1943
2172
  };
1944
2173
  case "guides":
1945
2174
  return {
1946
2175
  type: "button",
1947
- icon: vue.markRaw(icons.Grid),
2176
+ icon: vue.markRaw(iconsVue.Grid),
1948
2177
  tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
1949
2178
  handler: () => uiService?.set("showGuides", !showGuides.value)
1950
2179
  };
@@ -1972,176 +2201,155 @@
1972
2201
  item2.handler?.(services, event);
1973
2202
  }
1974
2203
  };
1975
- return {
1976
- ZoomIn: vue.markRaw(icons.ZoomIn),
1977
- ZoomOut: vue.markRaw(icons.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
- }
2204
+ const display = vue.computed(() => {
2205
+ if (!item.value)
2206
+ return false;
2207
+ if (typeof item.value === "string")
2208
+ return true;
2209
+ if (typeof item.value.display === "function") {
2210
+ return item.value.display(services);
2211
+ }
2212
+ return item.value.display ?? true;
2213
+ });
2214
+ const dropdownHandler = (command) => {
2215
+ if (command.item.handler) {
2216
+ command.item.handler(services);
2018
2217
  }
2019
2218
  };
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, {
2219
+ const clickHandler = (item2, event) => {
2220
+ if (props.eventType !== "click")
2221
+ return;
2222
+ if (item2.type === "button") {
2223
+ buttonHandler(item2, event);
2224
+ }
2225
+ };
2226
+ const mousedownHandler = (item2, event) => {
2227
+ if (props.eventType !== "mousedown")
2228
+ return;
2229
+ if (item2.type === "button") {
2230
+ buttonHandler(item2, event);
2231
+ }
2232
+ };
2233
+ const mouseupHandler = (item2, event) => {
2234
+ if (props.eventType !== "mouseup")
2235
+ return;
2236
+ if (item2.type === "button") {
2237
+ buttonHandler(item2, event);
2238
+ }
2239
+ };
2240
+ return (_ctx, _cache) => {
2241
+ const _component_el_divider = vue.resolveComponent("el-divider");
2242
+ const _component_tool_button = vue.resolveComponent("tool-button", true);
2243
+ const _component_el_button = vue.resolveComponent("el-button");
2244
+ const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2245
+ const _component_el_icon = vue.resolveComponent("el-icon");
2246
+ const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
2247
+ const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
2248
+ const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2249
+ return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
2064
2250
  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, {
2251
+ class: vue.normalizeClass(["menu-item", vue.unref(item).type]),
2252
+ onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(vue.unref(item), $event)),
2253
+ onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(vue.unref(item), $event)),
2254
+ onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(vue.unref(item), $event))
2255
+ }, [
2256
+ vue.unref(item).type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2257
+ key: 0,
2258
+ direction: vue.unref(item).direction || "vertical"
2259
+ }, 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 }, [
2260
+ vue.createVNode(_component_tool_button, {
2261
+ data: { type: "button", icon: vue.unref(iconsVue.ZoomOut), handler: zoomOutHandler, tooltip: "\u7F29\u5C0F" },
2262
+ "event-type": __props.eventType
2263
+ }, null, 8, ["data", "event-type"]),
2264
+ vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${vue.unref(zoom) * 100}`, 10)) + "%", 1),
2265
+ vue.createVNode(_component_tool_button, {
2266
+ data: { type: "button", icon: vue.unref(iconsVue.ZoomIn), handler: zoomInHandler, tooltip: "\u653E\u5927" },
2267
+ "event-type": __props.eventType
2268
+ }, null, 8, ["data", "event-type"])
2269
+ ], 64)) : vue.unref(item).type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
2270
+ vue.unref(item).tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2271
+ key: 0,
2272
+ effect: "dark",
2273
+ placement: "bottom-start",
2274
+ content: vue.unref(item).tooltip
2275
+ }, {
2276
+ default: vue.withCtx(() => [
2277
+ vue.createVNode(_component_el_button, {
2278
+ size: "small",
2279
+ text: "",
2280
+ disabled: vue.unref(disabled)
2281
+ }, {
2282
+ default: vue.withCtx(() => [
2283
+ vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
2284
+ key: 0,
2285
+ icon: vue.unref(item).icon
2286
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2287
+ vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
2288
+ ]),
2289
+ _: 1
2290
+ }, 8, ["disabled"])
2291
+ ]),
2292
+ _: 1
2293
+ }, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
2294
+ key: 1,
2071
2295
  size: "small",
2072
2296
  text: "",
2073
- disabled: _ctx.disabled
2297
+ disabled: vue.unref(disabled)
2074
2298
  }, {
2075
2299
  default: vue.withCtx(() => [
2076
- _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2300
+ vue.unref(item).icon ? (vue.openBlock(), vue.createBlock(MIcon, {
2077
2301
  key: 0,
2078
- icon: _ctx.item.icon
2302
+ icon: vue.unref(item).icon
2079
2303
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2080
- vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2304
+ vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(item).text), 1)
2081
2305
  ]),
2082
2306
  _: 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 }, {
2307
+ }, 8, ["disabled"]))
2308
+ ], 64)) : vue.unref(item).type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2309
+ key: 4,
2310
+ trigger: "click",
2311
+ disabled: vue.unref(disabled),
2312
+ onCommand: dropdownHandler
2313
+ }, {
2314
+ dropdown: vue.withCtx(() => [
2315
+ vue.unref(item).items && vue.unref(item).items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
2316
+ default: vue.withCtx(() => [
2317
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(item).items, (subItem, index) => {
2318
+ return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
2319
+ key: index,
2320
+ command: { item: vue.unref(item), subItem }
2321
+ }, {
2322
+ default: vue.withCtx(() => [
2323
+ vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
2324
+ ]),
2325
+ _: 2
2326
+ }, 1032, ["command"]);
2327
+ }), 128))
2328
+ ]),
2329
+ _: 1
2330
+ })) : vue.createCommentVNode("", true)
2331
+ ]),
2109
2332
  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
- }, {
2333
+ vue.createElementVNode("span", _hoisted_3, [
2334
+ vue.createTextVNode(vue.toDisplayString(vue.unref(item).text), 1),
2335
+ vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
2115
2336
  default: vue.withCtx(() => [
2116
- vue.createTextVNode(vue.toDisplayString(subItem.text), 1)
2337
+ vue.createVNode(vue.unref(iconsVue.ArrowDown))
2117
2338
  ]),
2118
- _: 2
2119
- }, 1032, ["command"]);
2120
- }), 128))
2339
+ _: 1
2340
+ })
2341
+ ])
2121
2342
  ]),
2122
2343
  _: 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]]);
2344
+ }, 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)
2345
+ ], 34)) : vue.createCommentVNode("", true);
2346
+ };
2347
+ }
2348
+ });
2141
2349
 
2142
- const _sfc_main$d = vue.defineComponent({
2350
+ const _sfc_main$e = vue.defineComponent({
2143
2351
  name: "nav-menu",
2144
- components: { ToolButton },
2352
+ components: { ToolButton: _sfc_main$f },
2145
2353
  props: {
2146
2354
  data: {
2147
2355
  type: Object,
@@ -2159,7 +2367,8 @@
2159
2367
  };
2160
2368
  }
2161
2369
  });
2162
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2370
+
2371
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2163
2372
  const _component_tool_button = vue.resolveComponent("tool-button");
2164
2373
  return vue.openBlock(), vue.createElementBlock("div", {
2165
2374
  class: "m-editor-nav-menu",
@@ -2181,9 +2390,9 @@
2181
2390
  }), 128))
2182
2391
  ], 4);
2183
2392
  }
2184
- var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
2393
+ const NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
2185
2394
 
2186
- const _sfc_main$c = vue.defineComponent({
2395
+ const _sfc_main$d = vue.defineComponent({
2187
2396
  name: "m-editor-props-panel",
2188
2397
  emits: ["mounted"],
2189
2398
  setup(props, { emit }) {
@@ -2230,8 +2439,9 @@
2230
2439
  };
2231
2440
  }
2232
2441
  });
2442
+
2233
2443
  const _hoisted_1$6 = { class: "`m-editor-props-panel" };
2234
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2444
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2235
2445
  const _component_m_form = vue.resolveComponent("m-form");
2236
2446
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
2237
2447
  vue.renderSlot(_ctx.$slots, "props-panel-header"),
@@ -2246,9 +2456,9 @@
2246
2456
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"])
2247
2457
  ]);
2248
2458
  }
2249
- var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
2459
+ const PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
2250
2460
 
2251
- const _sfc_main$b = vue.defineComponent({
2461
+ const _sfc_main$c = vue.defineComponent({
2252
2462
  name: "ui-component-panel",
2253
2463
  components: { MIcon },
2254
2464
  setup() {
@@ -2278,7 +2488,7 @@
2278
2488
  dragstartHandler({ text, type, data = {} }, e) {
2279
2489
  if (e.dataTransfer) {
2280
2490
  e.dataTransfer.effectAllowed = "move";
2281
- e.dataTransfer.setData("data", serialize__default["default"]({
2491
+ e.dataTransfer.setData("data", serialize__default.default({
2282
2492
  name: text,
2283
2493
  type,
2284
2494
  ...data
@@ -2307,27 +2517,17 @@
2307
2517
  }
2308
2518
  return;
2309
2519
  }
2310
- if (timeout)
2520
+ if (timeout || !stage.value)
2311
2521
  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);
2522
+ timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
2324
2523
  }
2325
2524
  };
2326
2525
  }
2327
2526
  });
2527
+
2328
2528
  const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2329
2529
  const _hoisted_2$1 = ["onClick", "onDragstart"];
2330
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2530
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2331
2531
  const _component_el_input = vue.resolveComponent("el-input");
2332
2532
  const _component_m_icon = vue.resolveComponent("m-icon");
2333
2533
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -2399,22 +2599,17 @@
2399
2599
  _: 3
2400
2600
  });
2401
2601
  }
2402
- var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
2602
+ const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
2403
2603
 
2404
- const _sfc_main$a = vue.defineComponent({
2405
- components: { ToolButton },
2604
+ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
2605
+ __name: "ContentMenu",
2406
2606
  props: {
2407
- menuData: {
2408
- type: Array,
2409
- default: () => []
2410
- },
2411
- isSubMenu: {
2412
- type: Boolean,
2413
- default: false
2414
- }
2607
+ menuData: { default: () => [] },
2608
+ isSubMenu: { type: Boolean, default: false }
2415
2609
  },
2416
2610
  emits: ["hide", "show"],
2417
- setup(props, { emit }) {
2611
+ setup(__props, { expose, emit }) {
2612
+ const props = __props;
2418
2613
  const menu = vue.ref();
2419
2614
  const subMenu = vue.ref();
2420
2615
  const visible = vue.ref(false);
@@ -2440,6 +2635,36 @@
2440
2635
  }
2441
2636
  hide();
2442
2637
  };
2638
+ const show = (e) => {
2639
+ setTimeout(() => {
2640
+ visible.value = true;
2641
+ vue.nextTick(() => {
2642
+ const menuHeight = menu.value?.clientHeight || 0;
2643
+ let top = e.clientY;
2644
+ if (menuHeight + e.clientY > document.body.clientHeight) {
2645
+ top = document.body.clientHeight - menuHeight;
2646
+ }
2647
+ menuStyle.value = {
2648
+ top: `${top}px`,
2649
+ left: `${e.clientX}px`
2650
+ };
2651
+ emit("show");
2652
+ });
2653
+ }, 300);
2654
+ };
2655
+ const showSubMenu = (item) => {
2656
+ const menuItem = item;
2657
+ if (typeof item !== "object" || !menuItem.items?.length) {
2658
+ return;
2659
+ }
2660
+ subMenuData.value = menuItem.items;
2661
+ if (menu.value) {
2662
+ subMenu.value.show({
2663
+ clientX: menu.value.offsetLeft + menu.value.clientWidth,
2664
+ clientY: menu.value.offsetTop
2665
+ });
2666
+ }
2667
+ };
2443
2668
  vue.onMounted(() => {
2444
2669
  if (props.isSubMenu)
2445
2670
  return;
@@ -2450,81 +2675,47 @@
2450
2675
  return;
2451
2676
  globalThis.removeEventListener("mousedown", hideHandler, true);
2452
2677
  });
2453
- return {
2454
- menu,
2455
- subMenu,
2456
- visible,
2457
- menuStyle,
2458
- subMenuData,
2678
+ expose({
2459
2679
  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
- }
2680
+ show
2681
+ });
2682
+ return (_ctx, _cache) => {
2683
+ const _component_content_menu = vue.resolveComponent("content-menu", true);
2684
+ return __props.menuData.length && visible.value ? (vue.openBlock(), vue.createElementBlock("div", {
2685
+ key: 0,
2686
+ class: "magic-editor-content-menu",
2687
+ ref_key: "menu",
2688
+ ref: menu,
2689
+ style: vue.normalizeStyle(menuStyle.value)
2690
+ }, [
2691
+ vue.createElementVNode("div", null, [
2692
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
2693
+ return vue.openBlock(), vue.createBlock(_sfc_main$f, {
2694
+ "event-type": "mouseup",
2695
+ data: item,
2696
+ key: index,
2697
+ onMouseup: hide,
2698
+ onMouseenter: ($event) => showSubMenu(item)
2699
+ }, null, 8, ["data", "onMouseenter"]);
2700
+ }), 128))
2701
+ ]),
2702
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
2703
+ vue.createVNode(_component_content_menu, {
2704
+ class: "sub-menu",
2705
+ ref_key: "subMenu",
2706
+ ref: subMenu,
2707
+ "menu-data": subMenuData.value,
2708
+ "is-sub-menu": true,
2709
+ onHide: hide
2710
+ }, null, 8, ["menu-data"])
2711
+ ]))
2712
+ ], 4)) : vue.createCommentVNode("", true);
2490
2713
  };
2491
2714
  }
2492
2715
  });
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
2716
 
2526
- const _sfc_main$9 = vue.defineComponent({
2527
- components: { ContentMenu },
2717
+ const _sfc_main$a = vue.defineComponent({
2718
+ components: { ContentMenu: _sfc_main$b },
2528
2719
  setup() {
2529
2720
  const services = vue.inject("services");
2530
2721
  const menu = vue.ref();
@@ -2551,7 +2742,7 @@
2551
2742
  {
2552
2743
  text: "\u6807\u7B7E\u9875",
2553
2744
  type: "button",
2554
- icon: icons.Files,
2745
+ icon: iconsVue.Files,
2555
2746
  handler: () => {
2556
2747
  services?.editorService.add({
2557
2748
  type: "tab-pane"
@@ -2576,14 +2767,14 @@
2576
2767
  {
2577
2768
  type: "button",
2578
2769
  text: "\u65B0\u589E",
2579
- icon: vue.markRaw(icons.Plus),
2770
+ icon: vue.markRaw(iconsVue.Plus),
2580
2771
  display: () => node.value?.items,
2581
2772
  items: getSubMenuData.value
2582
2773
  },
2583
2774
  {
2584
2775
  type: "button",
2585
2776
  text: "\u590D\u5236",
2586
- icon: vue.markRaw(icons.DocumentCopy),
2777
+ icon: vue.markRaw(iconsVue.DocumentCopy),
2587
2778
  display: () => !isRoot.value,
2588
2779
  handler: () => {
2589
2780
  node.value && services?.editorService.copy(node.value);
@@ -2592,7 +2783,7 @@
2592
2783
  {
2593
2784
  type: "button",
2594
2785
  text: "\u5220\u9664",
2595
- icon: vue.markRaw(icons.Delete),
2786
+ icon: vue.markRaw(iconsVue.Delete),
2596
2787
  display: () => !isRoot.value && !isPage.value,
2597
2788
  handler: () => {
2598
2789
  node.value && services?.editorService.remove(node.value);
@@ -2606,7 +2797,8 @@
2606
2797
  };
2607
2798
  }
2608
2799
  });
2609
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2800
+
2801
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2610
2802
  const _component_content_menu = vue.resolveComponent("content-menu");
2611
2803
  return vue.openBlock(), vue.createBlock(_component_content_menu, {
2612
2804
  "menu-data": _ctx.menuData,
@@ -2614,7 +2806,7 @@
2614
2806
  style: { "overflow": "initial" }
2615
2807
  }, null, 8, ["menu-data"]);
2616
2808
  }
2617
- var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
2809
+ const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$6]]);
2618
2810
 
2619
2811
  const throttleTime = 150;
2620
2812
  const select = async (data, editorService) => {
@@ -2648,32 +2840,58 @@
2648
2840
  return true;
2649
2841
  return false;
2650
2842
  },
2651
- handleDragEnd() {
2843
+ async handleDragEnd(e) {
2652
2844
  if (!tree.value)
2653
2845
  return;
2846
+ const { data: node } = e;
2847
+ const parent = editorService?.getParentById(node.id, false);
2848
+ const layout = await editorService?.getLayout(parent);
2849
+ node.style.position = layout;
2850
+ if (layout === Layout.RELATIVE) {
2851
+ node.style.top = 0;
2852
+ node.style.left = 0;
2853
+ }
2654
2854
  const { data } = tree.value;
2655
2855
  const [page] = data;
2656
2856
  editorService?.update(page);
2657
2857
  }
2658
2858
  });
2659
2859
  const useStatus = (tree, editorService) => {
2660
- const highlightNode = vue.ref();
2661
2860
  const node = vue.ref();
2662
2861
  const page = vue.computed(() => editorService?.get("page"));
2862
+ const expandedKeys = /* @__PURE__ */ new Map();
2863
+ const expandNodes = () => {
2864
+ expandedKeys.forEach((key) => {
2865
+ if (!tree.value)
2866
+ return;
2867
+ tree.value.getNode(key)?.expand();
2868
+ });
2869
+ };
2663
2870
  vue.watchEffect(() => {
2664
2871
  if (!tree.value)
2665
2872
  return;
2666
- node.value = editorService?.get("node");
2667
- node.value && tree.value.setCurrentKey(node.value.id, true);
2668
- const parent = editorService?.get("parent");
2873
+ if (!editorService)
2874
+ return;
2875
+ node.value = editorService.get("node");
2876
+ if (!node.value)
2877
+ return;
2878
+ tree.value.setCurrentKey(node.value.id, true);
2879
+ const parent = editorService.get("parent");
2669
2880
  if (!parent?.id)
2670
2881
  return;
2671
2882
  const treeNode = tree.value.getNode(parent.id);
2672
2883
  treeNode?.updateChildren();
2673
- highlightNode.value = editorService?.get("highlightNode");
2674
- });
2675
- return {
2676
- values: vue.computed(() => page.value ? [page.value] : []),
2884
+ setTimeout(() => {
2885
+ tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
2886
+ if (node2.expanded && node2.data.items) {
2887
+ expandedKeys.set(id, id);
2888
+ }
2889
+ });
2890
+ expandNodes();
2891
+ });
2892
+ });
2893
+ return {
2894
+ values: vue.computed(() => page.value ? [page.value] : []),
2677
2895
  loadItems: (node2, resolve) => {
2678
2896
  if (Array.isArray(node2.data)) {
2679
2897
  return resolve(node2.data);
@@ -2683,9 +2901,18 @@
2683
2901
  }
2684
2902
  resolve([]);
2685
2903
  },
2686
- highlightNode,
2904
+ highlightNode: vue.computed(() => editorService?.get("highlightNode")),
2687
2905
  clickNode: node,
2688
- expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
2906
+ expandedKeys: vue.computed(() => node.value ? [node.value.id] : []),
2907
+ handleCollapse: (data) => {
2908
+ expandedKeys.delete(data.id);
2909
+ },
2910
+ handleExpand: (data) => {
2911
+ const parent = editorService?.getParentById(data.id);
2912
+ if (!parent?.id)
2913
+ return;
2914
+ expandedKeys.set(parent.id, parent.id);
2915
+ }
2689
2916
  };
2690
2917
  };
2691
2918
  const useFilter = (tree) => ({
@@ -2706,7 +2933,7 @@
2706
2933
  tree.value?.filter(val);
2707
2934
  }
2708
2935
  });
2709
- const _sfc_main$8 = vue.defineComponent({
2936
+ const _sfc_main$9 = vue.defineComponent({
2710
2937
  name: "magic-editor-layer-panel",
2711
2938
  components: { LayerMenu },
2712
2939
  setup() {
@@ -2753,8 +2980,9 @@
2753
2980
  };
2754
2981
  }
2755
2982
  });
2983
+
2756
2984
  const _hoisted_1$4 = ["id", "onMouseenter"];
2757
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2985
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2758
2986
  const _component_el_input = vue.resolveComponent("el-input");
2759
2987
  const _component_el_tree = vue.resolveComponent("el-tree");
2760
2988
  const _component_layer_menu = vue.resolveComponent("layer-menu");
@@ -2775,6 +3003,7 @@
2775
3003
  key: 0,
2776
3004
  ref: "tree",
2777
3005
  "node-key": "id",
3006
+ "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
2778
3007
  draggable: "",
2779
3008
  "default-expanded-keys": _ctx.expandedKeys,
2780
3009
  load: _ctx.loadItems,
@@ -2789,7 +3018,8 @@
2789
3018
  onNodeClick: _ctx.clickHandler,
2790
3019
  onNodeContextmenu: _ctx.contextmenu,
2791
3020
  onNodeDragEnd: _ctx.handleDragEnd,
2792
- "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
3021
+ onNodeCollapse: _ctx.handleCollapse,
3022
+ onNodeExpand: _ctx.handleExpand
2793
3023
  }, {
2794
3024
  default: vue.withCtx(({ node, data }) => [
2795
3025
  vue.createElementVNode("div", {
@@ -2808,7 +3038,7 @@
2808
3038
  ], 42, _hoisted_1$4)
2809
3039
  ]),
2810
3040
  _: 3
2811
- }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
3041
+ }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : vue.createCommentVNode("", true),
2812
3042
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
2813
3043
  vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
2814
3044
  ]))
@@ -2816,9 +3046,9 @@
2816
3046
  _: 3
2817
3047
  });
2818
3048
  }
2819
- var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
3049
+ const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$5]]);
2820
3050
 
2821
- const _sfc_main$7 = vue.defineComponent({
3051
+ const _sfc_main$8 = vue.defineComponent({
2822
3052
  components: { MIcon },
2823
3053
  props: {
2824
3054
  data: {
@@ -2835,7 +3065,7 @@
2835
3065
  case "component-list":
2836
3066
  return {
2837
3067
  type: "component",
2838
- icon: icons.Coin,
3068
+ icon: iconsVue.Coin,
2839
3069
  text: "\u7EC4\u4EF6",
2840
3070
  component: ComponentListPanel,
2841
3071
  slots: {}
@@ -2843,7 +3073,7 @@
2843
3073
  case "layer":
2844
3074
  return {
2845
3075
  type: "component",
2846
- icon: icons.Files,
3076
+ icon: iconsVue.Files,
2847
3077
  text: "\u5DF2\u9009\u7EC4\u4EF6",
2848
3078
  component: LayerPanel,
2849
3079
  slots: {}
@@ -2855,11 +3085,12 @@
2855
3085
  };
2856
3086
  }
2857
3087
  });
3088
+
2858
3089
  const _hoisted_1$3 = {
2859
3090
  key: 1,
2860
3091
  class: "magic-editor-tab-panel-title"
2861
3092
  };
2862
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3093
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
2863
3094
  const _component_m_icon = vue.resolveComponent("m-icon");
2864
3095
  const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
2865
3096
  return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
@@ -2905,9 +3136,9 @@
2905
3136
  _: 3
2906
3137
  }, 8, ["name"])) : vue.createCommentVNode("", true);
2907
3138
  }
2908
- var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
3139
+ const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$4]]);
2909
3140
 
2910
- const _sfc_main$6 = vue.defineComponent({
3141
+ const _sfc_main$7 = vue.defineComponent({
2911
3142
  components: { TabPane },
2912
3143
  name: "m-sidebar",
2913
3144
  props: {
@@ -2926,7 +3157,8 @@
2926
3157
  };
2927
3158
  }
2928
3159
  });
2929
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
3160
+
3161
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
2930
3162
  const _component_tab_pane = vue.resolveComponent("tab-pane");
2931
3163
  const _component_el_tabs = vue.resolveComponent("el-tabs");
2932
3164
  return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
@@ -2961,331 +3193,258 @@
2961
3193
  _: 3
2962
3194
  }, 8, ["modelValue"])) : vue.createCommentVNode("", true);
2963
3195
  }
2964
- var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
3196
+ const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$3]]);
2965
3197
 
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;
3198
+ const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
3199
+ __name: "PageBarScrollContainer",
3200
+ setup(__props) {
3201
+ const services = vue.inject("services");
3202
+ const editorService = services?.editorService;
3203
+ const pageBar = vue.ref();
3204
+ const itemsContainer = vue.ref();
3205
+ const pageBarWidth = vue.ref(0);
3206
+ const canScroll = vue.ref(false);
3207
+ const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
3208
+ let translateLeft = 0;
3209
+ const resizeObserver = new ResizeObserver((entries) => {
3210
+ for (const { contentRect } of entries) {
3211
+ const { width } = contentRect;
3212
+ pageBarWidth.value = width || 0;
3213
+ setCanScroll();
2993
3214
  }
2994
- } else if (type === "right") {
2995
- translateLeft -= 100;
2996
- if (-translateLeft > maxScrollLeft) {
2997
- translateLeft = -maxScrollLeft;
3215
+ });
3216
+ const setCanScroll = () => {
3217
+ if (itemsContainer.value) {
3218
+ canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
2998
3219
  }
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");
3220
+ };
3221
+ const scroll = (type) => {
3222
+ if (!itemsContainer.value)
3223
+ return;
3224
+ const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
3225
+ if (type === "left") {
3226
+ translateLeft += 100;
3227
+ if (translateLeft > 0) {
3228
+ translateLeft = 0;
3229
+ }
3230
+ } else if (type === "right") {
3231
+ translateLeft -= 100;
3232
+ if (-translateLeft > maxScrollLeft) {
3233
+ translateLeft = -maxScrollLeft;
3234
+ }
3235
+ } else if (type === "start") {
3236
+ translateLeft = 0;
3237
+ } else if (type === "end") {
3238
+ translateLeft = -maxScrollLeft;
3019
3239
  }
3240
+ itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
3241
+ };
3242
+ vue.onMounted(() => {
3243
+ pageBar.value && resizeObserver.observe(pageBar.value);
3244
+ });
3245
+ vue.onUnmounted(() => {
3246
+ resizeObserver.disconnect();
3020
3247
  });
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: icons.ArrowLeftBold, ArrowRightBold: icons.ArrowRightBold, CaretBottom: icons.CaretBottom, Plus: icons.Plus, ToolButton },
3032
- setup() {
3033
- const services = vue.inject("services");
3034
- const editorService = services?.editorService;
3035
3248
  const root = vue.computed(() => editorService?.get("root"));
3036
- return {
3037
- Delete: vue.markRaw(icons.Delete),
3038
- DocumentCopy: vue.markRaw(icons.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
- }
3249
+ vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
3250
+ setTimeout(() => {
3251
+ setCanScroll();
3252
+ if (length < preLength) {
3253
+ scroll("start");
3254
+ } else {
3255
+ scroll("end");
3256
+ }
3257
+ });
3258
+ });
3259
+ const addPage = () => {
3260
+ if (!editorService)
3261
+ return;
3262
+ const pageConfig = {
3263
+ type: schema.NodeType.PAGE,
3264
+ name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
3265
+ };
3266
+ editorService.add(pageConfig);
3064
3267
  };
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)
3268
+ return (_ctx, _cache) => {
3269
+ const _component_el_icon = vue.resolveComponent("el-icon");
3270
+ return vue.openBlock(), vue.createElementBlock("div", {
3271
+ class: "m-editor-page-bar",
3272
+ ref_key: "pageBar",
3273
+ ref: pageBar
3274
+ }, [
3275
+ vue.createElementVNode("div", {
3276
+ id: "m-editor-page-bar-add-icon",
3277
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3278
+ onClick: addPage
3279
+ }, [
3280
+ vue.createVNode(_component_el_icon, null, {
3281
+ default: vue.withCtx(() => [
3282
+ vue.createVNode(vue.unref(iconsVue.Plus))
3283
+ ]),
3284
+ _: 1
3285
+ })
3103
3286
  ]),
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)
3287
+ canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
3288
+ key: 0,
3289
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3290
+ onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
3118
3291
  }, [
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
- })
3292
+ vue.createVNode(_component_el_icon, null, {
3293
+ default: vue.withCtx(() => [
3294
+ vue.createVNode(vue.unref(iconsVue.ArrowLeftBold))
3146
3295
  ]),
3296
+ _: 1
3297
+ })
3298
+ ])) : vue.createCommentVNode("", true),
3299
+ vue.unref(root) ? (vue.openBlock(), vue.createElementBlock("div", {
3300
+ key: 1,
3301
+ class: "m-editor-page-bar-items",
3302
+ ref_key: "itemsContainer",
3303
+ ref: itemsContainer,
3304
+ style: vue.normalizeStyle(`width: ${vue.unref(itemsContainerWidth)}px`)
3305
+ }, [
3306
+ vue.renderSlot(_ctx.$slots, "default")
3307
+ ], 4)) : vue.createCommentVNode("", true),
3308
+ canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
3309
+ key: 2,
3310
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3311
+ onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
3312
+ }, [
3313
+ vue.createVNode(_component_el_icon, null, {
3147
3314
  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
- ])
3315
+ vue.createVNode(vue.unref(iconsVue.ArrowRightBold))
3168
3316
  ]),
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;
3317
+ _: 1
3318
+ })
3319
+ ])) : vue.createCommentVNode("", true)
3320
+ ], 512);
3235
3321
  };
3236
- this.targetMouseLeaveHandler = () => {
3237
- this.targetEnter = false;
3322
+ }
3323
+ });
3324
+
3325
+ const _hoisted_1$2 = ["onClick"];
3326
+ const _hoisted_2 = { class: "m-editor-page-bar-title" };
3327
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
3328
+ __name: "PageBar",
3329
+ setup(__props) {
3330
+ const services = vue.inject("services");
3331
+ const editorService = services?.editorService;
3332
+ const root = vue.computed(() => editorService?.get("root"));
3333
+ const page = vue.computed(() => editorService?.get("page"));
3334
+ const switchPage = (page2) => {
3335
+ editorService?.select(page2);
3238
3336
  };
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);
3337
+ const copy = (node) => {
3338
+ node && editorService?.copy(node);
3339
+ editorService?.paste({
3340
+ left: 0,
3341
+ top: 0
3342
+ });
3249
3343
  };
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();
3344
+ const remove = (node) => {
3345
+ editorService?.remove(node);
3256
3346
  };
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();
3347
+ return (_ctx, _cache) => {
3348
+ const _component_el_tooltip = vue.resolveComponent("el-tooltip");
3349
+ const _component_el_icon = vue.resolveComponent("el-icon");
3350
+ const _component_el_popover = vue.resolveComponent("el-popover");
3351
+ return vue.openBlock(), vue.createBlock(_sfc_main$6, null, {
3352
+ default: vue.withCtx(() => [
3353
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
3354
+ return vue.openBlock(), vue.createElementBlock("div", {
3355
+ class: vue.normalizeClass(["m-editor-page-bar-item", { active: vue.unref(page)?.id === item.id }]),
3356
+ key: item.key,
3357
+ onClick: ($event) => switchPage(item)
3358
+ }, [
3359
+ vue.createElementVNode("div", _hoisted_2, [
3360
+ vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3361
+ vue.createVNode(_component_el_tooltip, {
3362
+ effect: "dark",
3363
+ placement: "top-start",
3364
+ content: item.name
3365
+ }, {
3366
+ default: vue.withCtx(() => [
3367
+ vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
3368
+ ]),
3369
+ _: 2
3370
+ }, 1032, ["content"])
3371
+ ])
3372
+ ]),
3373
+ vue.createVNode(_component_el_popover, {
3374
+ "popper-class": "page-bar-popover",
3375
+ placement: "top",
3376
+ width: 160,
3377
+ trigger: "hover"
3378
+ }, {
3379
+ reference: vue.withCtx(() => [
3380
+ vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3381
+ default: vue.withCtx(() => [
3382
+ vue.createVNode(vue.unref(iconsVue.CaretBottom))
3383
+ ]),
3384
+ _: 1
3385
+ })
3386
+ ]),
3387
+ default: vue.withCtx(() => [
3388
+ vue.createElementVNode("div", null, [
3389
+ vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3390
+ vue.createVNode(_sfc_main$f, {
3391
+ data: {
3392
+ type: "button",
3393
+ text: "\u590D\u5236",
3394
+ icon: vue.unref(iconsVue.DocumentCopy),
3395
+ handler: () => copy(item)
3396
+ }
3397
+ }, null, 8, ["data"]),
3398
+ vue.createVNode(_sfc_main$f, {
3399
+ data: {
3400
+ type: "button",
3401
+ text: "\u5220\u9664",
3402
+ icon: vue.unref(iconsVue.Delete),
3403
+ handler: () => remove(item)
3404
+ }
3405
+ }, null, 8, ["data"])
3406
+ ])
3407
+ ])
3408
+ ]),
3409
+ _: 2
3410
+ }, 1024)
3411
+ ], 10, _hoisted_1$2);
3412
+ }), 128))
3413
+ ]),
3414
+ _: 3
3415
+ });
3264
3416
  };
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;
3417
+ }
3418
+ });
3419
+
3420
+ class ScrollViewer$1 {
3421
+ enter = false;
3422
+ targetEnter = false;
3423
+ keydown = false;
3424
+ container;
3425
+ target;
3426
+ zoom = 1;
3427
+ scrollLeft = 0;
3428
+ scrollTop = 0;
3429
+ x = 0;
3430
+ y = 0;
3431
+ resizeObserver = new ResizeObserver((entries) => {
3432
+ for (const { contentRect } of entries) {
3433
+ const { width, height } = contentRect;
3434
+ const targetRect = this.target.getBoundingClientRect();
3435
+ const targetWidth = targetRect.width * this.zoom;
3436
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3437
+ const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3438
+ if (targetWidth < width) {
3439
+ this.target._left = 0;
3273
3440
  }
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;
3441
+ if (targetHeight < height) {
3442
+ this.target._top = 0;
3281
3443
  }
3282
- event.preventDefault();
3283
- event.stopImmediatePropagation();
3284
- event.stopPropagation();
3285
- this.keydown = false;
3286
- event.preventDefault();
3287
- this.removeHandler();
3288
- };
3444
+ this.scroll();
3445
+ }
3446
+ });
3447
+ constructor(options) {
3289
3448
  this.container = options.container;
3290
3449
  this.target = options.target;
3291
3450
  this.zoom = options.zoom;
@@ -3321,6 +3480,79 @@
3321
3480
  document.removeEventListener("mousemove", this.mousemoveHandler);
3322
3481
  document.removeEventListener("mouseup", this.mouseupHandler);
3323
3482
  }
3483
+ wheelHandler = (event) => {
3484
+ if (this.targetEnter)
3485
+ return;
3486
+ const { deltaX, deltaY, currentTarget } = event;
3487
+ if (currentTarget !== this.container)
3488
+ return;
3489
+ this.setScrollOffset(deltaX, deltaY);
3490
+ this.scroll();
3491
+ this.scrollLeft = this.target._left;
3492
+ this.scrollTop = this.target._top;
3493
+ };
3494
+ mouseEnterHandler = () => {
3495
+ this.enter = true;
3496
+ };
3497
+ mouseLeaveHandler = () => {
3498
+ this.enter = false;
3499
+ };
3500
+ targetMouseEnterHandler = () => {
3501
+ this.targetEnter = true;
3502
+ };
3503
+ targetMouseLeaveHandler = () => {
3504
+ this.targetEnter = false;
3505
+ };
3506
+ mousedownHandler = (event) => {
3507
+ if (!this.keydown)
3508
+ return;
3509
+ event.stopImmediatePropagation();
3510
+ event.stopPropagation();
3511
+ this.target.style.cursor = "grabbing";
3512
+ this.x = event.clientX;
3513
+ this.y = event.clientY;
3514
+ document.addEventListener("mousemove", this.mousemoveHandler);
3515
+ document.addEventListener("mouseup", this.mouseupHandler);
3516
+ };
3517
+ mouseupHandler = () => {
3518
+ this.x = 0;
3519
+ this.y = 0;
3520
+ this.scrollLeft = this.target._left;
3521
+ this.scrollTop = this.target._top;
3522
+ this.removeHandler();
3523
+ };
3524
+ mousemoveHandler = (event) => {
3525
+ event.stopImmediatePropagation();
3526
+ event.stopPropagation();
3527
+ const deltaX = event.clientX - this.x;
3528
+ const deltaY = event.clientY - this.y;
3529
+ this.setScrollOffset(deltaX, deltaY);
3530
+ this.scroll();
3531
+ };
3532
+ keydownHandler = (event) => {
3533
+ if (event.code === Keys.ESCAPE && this.enter) {
3534
+ event.preventDefault();
3535
+ event.stopImmediatePropagation();
3536
+ event.stopPropagation();
3537
+ }
3538
+ if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3539
+ return;
3540
+ }
3541
+ this.keydown = true;
3542
+ this.target.style.cursor = "grab";
3543
+ this.container.addEventListener("mousedown", this.mousedownHandler);
3544
+ };
3545
+ keyupHandler = (event) => {
3546
+ if (event.code !== Keys.ESCAPE || !this.keydown) {
3547
+ return;
3548
+ }
3549
+ event.preventDefault();
3550
+ event.stopImmediatePropagation();
3551
+ event.stopPropagation();
3552
+ this.keydown = false;
3553
+ event.preventDefault();
3554
+ this.removeHandler();
3555
+ };
3324
3556
  setScrollOffset(deltaX, deltaY) {
3325
3557
  const { width, height } = this.container.getBoundingClientRect();
3326
3558
  const targetRect = this.target.getBoundingClientRect();
@@ -3381,18 +3613,19 @@
3381
3613
  el,
3382
3614
  style: vue.computed(() => `
3383
3615
  width: ${props.width}px;
3384
- height: ${(props.height || 0) - 40}px;
3616
+ height: ${props.height}px;
3385
3617
  position: absolute;
3386
3618
  margin-top: 30px;
3387
3619
  `)
3388
3620
  };
3389
3621
  }
3390
3622
  });
3623
+
3391
3624
  const _hoisted_1$1 = {
3392
3625
  class: "m-editor-scroll-viewer-container",
3393
3626
  ref: "container"
3394
3627
  };
3395
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3628
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3396
3629
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
3397
3630
  vue.createElementVNode("div", {
3398
3631
  ref: "el",
@@ -3402,170 +3635,170 @@
3402
3635
  ], 4)
3403
3636
  ], 512);
3404
3637
  }
3405
- var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
3638
+ const ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$2]]);
3406
3639
 
3407
- const _sfc_main$3 = vue.defineComponent({
3408
- components: { ContentMenu },
3409
- setup() {
3640
+ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
3641
+ __name: "ViewerMenu",
3642
+ props: {
3643
+ isMultiSelect: { type: Boolean, default: false }
3644
+ },
3645
+ setup(__props, { expose }) {
3646
+ const props = __props;
3410
3647
  const services = vue.inject("services");
3411
3648
  const editorService = services?.editorService;
3412
3649
  const menu = vue.ref();
3413
3650
  const canPaste = vue.ref(false);
3414
3651
  const canCenter = vue.ref(false);
3415
3652
  const node = vue.computed(() => editorService?.get("node"));
3653
+ const nodes = vue.computed(() => editorService?.get("nodes"));
3416
3654
  const parent = vue.computed(() => editorService?.get("parent"));
3417
- const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
3655
+ const stage = vue.computed(() => editorService?.get("stage"));
3418
3656
  const stageContentMenu = vue.inject("stageContentMenu", []);
3419
- vue.onMounted(() => {
3420
- const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
3421
- canPaste.value = data !== "undefined" && !!data;
3422
- });
3657
+ const menuData = vue.reactive([
3658
+ {
3659
+ type: "button",
3660
+ text: "\u6C34\u5E73\u5C45\u4E2D",
3661
+ display: () => canCenter.value,
3662
+ handler: () => {
3663
+ if (!nodes.value)
3664
+ return;
3665
+ editorService?.alignCenter(nodes.value);
3666
+ }
3667
+ },
3668
+ {
3669
+ type: "button",
3670
+ text: "\u590D\u5236",
3671
+ icon: vue.markRaw(iconsVue.DocumentCopy),
3672
+ handler: () => {
3673
+ nodes.value && editorService?.copy(nodes.value);
3674
+ canPaste.value = true;
3675
+ }
3676
+ },
3677
+ {
3678
+ type: "button",
3679
+ text: "\u7C98\u8D34",
3680
+ display: () => canPaste.value,
3681
+ handler: () => {
3682
+ const rect = menu.value?.$el.getBoundingClientRect();
3683
+ const parentRect = stage.value?.container?.getBoundingClientRect();
3684
+ const initialLeft = (rect?.left || 0) - (parentRect?.left || 0);
3685
+ const initialTop = (rect?.top || 0) - (parentRect?.top || 0);
3686
+ if (!nodes.value || nodes.value.length === 0)
3687
+ return;
3688
+ editorService?.paste({ left: initialLeft, top: initialTop });
3689
+ }
3690
+ },
3691
+ {
3692
+ type: "divider",
3693
+ direction: "horizontal",
3694
+ display: () => {
3695
+ if (!node.value)
3696
+ return false;
3697
+ return !utils.isPage(node.value);
3698
+ }
3699
+ },
3700
+ {
3701
+ type: "button",
3702
+ text: "\u4E0A\u79FB\u4E00\u5C42",
3703
+ icon: vue.markRaw(iconsVue.Top),
3704
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect,
3705
+ handler: () => {
3706
+ editorService?.moveLayer(1);
3707
+ }
3708
+ },
3709
+ {
3710
+ type: "button",
3711
+ text: "\u4E0B\u79FB\u4E00\u5C42",
3712
+ icon: vue.markRaw(iconsVue.Bottom),
3713
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect,
3714
+ handler: () => {
3715
+ editorService?.moveLayer(-1);
3716
+ }
3717
+ },
3718
+ {
3719
+ type: "button",
3720
+ text: "\u7F6E\u9876",
3721
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect,
3722
+ handler: () => {
3723
+ editorService?.moveLayer(LayerOffset.TOP);
3724
+ }
3725
+ },
3726
+ {
3727
+ type: "button",
3728
+ text: "\u7F6E\u5E95",
3729
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect,
3730
+ handler: () => {
3731
+ editorService?.moveLayer(LayerOffset.BOTTOM);
3732
+ }
3733
+ },
3734
+ {
3735
+ type: "divider",
3736
+ direction: "horizontal",
3737
+ display: () => !utils.isPage(node.value) && !props.isMultiSelect
3738
+ },
3739
+ {
3740
+ type: "button",
3741
+ text: "\u5220\u9664",
3742
+ icon: iconsVue.Delete,
3743
+ display: () => !utils.isPage(node.value),
3744
+ handler: () => {
3745
+ nodes.value && editorService?.remove(nodes.value);
3746
+ }
3747
+ },
3748
+ {
3749
+ type: "divider",
3750
+ direction: "horizontal"
3751
+ },
3752
+ {
3753
+ type: "button",
3754
+ text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
3755
+ handler: () => {
3756
+ editorService?.get("stage").clearGuides();
3757
+ }
3758
+ },
3759
+ ...stageContentMenu
3760
+ ]);
3423
3761
  vue.watch(parent, async () => {
3424
3762
  if (!parent.value || !editorService)
3425
3763
  return canCenter.value = false;
3426
3764
  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}`);
3765
+ const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
3766
+ const isTypeConform = nodes.value?.every((selectedNode) => ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${selectedNode?.type}`));
3767
+ canCenter.value = isLayoutConform && !!isTypeConform;
3428
3768
  }, { 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(icons.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(icons.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(icons.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: icons.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
- }
3769
+ const show = async (e) => {
3770
+ menu.value?.show(e);
3771
+ const data = await storageService.getItem(COPY_STORAGE_KEY);
3772
+ canPaste.value = data !== "undefined" && !!data;
3773
+ };
3774
+ expose({ show });
3775
+ return (_ctx, _cache) => {
3776
+ return vue.openBlock(), vue.createBlock(_sfc_main$b, {
3777
+ "menu-data": menuData,
3778
+ ref_key: "menu",
3779
+ ref: menu
3780
+ }, null, 8, ["menu-data"]);
3537
3781
  };
3538
3782
  }
3539
3783
  });
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
3784
 
3549
- const _sfc_main$2 = vue.defineComponent({
3550
- name: "magic-stage",
3551
- components: {
3552
- ViewerMenu,
3553
- ScrollViewer
3554
- },
3555
- setup() {
3785
+ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
3786
+ __name: "Stage",
3787
+ setup(__props) {
3788
+ let stage = null;
3789
+ let runtime = null;
3556
3790
  const services = vue.inject("services");
3557
3791
  const stageOptions = vue.inject("stageOptions");
3558
3792
  const stageWrap = vue.ref();
3559
3793
  const stageContainer = vue.ref();
3560
3794
  const menu = vue.ref();
3795
+ const isMultiSelect = vue.computed(() => services?.editorService.get("nodes")?.length > 1);
3561
3796
  const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
3562
3797
  const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
3563
3798
  const root = vue.computed(() => services?.editorService.get("root"));
3564
3799
  const page = vue.computed(() => services?.editorService.get("page"));
3565
3800
  const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
3566
3801
  const node = vue.computed(() => services?.editorService.get("node"));
3567
- let stage = null;
3568
- let runtime = null;
3569
3802
  const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
3570
3803
  vue.watchEffect(() => {
3571
3804
  if (stage)
@@ -3574,7 +3807,7 @@
3574
3807
  return;
3575
3808
  if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
3576
3809
  return;
3577
- stage = new StageCore__default["default"]({
3810
+ stage = new StageCore__default.default({
3578
3811
  render: stageOptions.render,
3579
3812
  runtimeUrl: stageOptions.runtimeUrl,
3580
3813
  zoom: zoom.value,
@@ -3582,6 +3815,7 @@
3582
3815
  isContainer: stageOptions.isContainer,
3583
3816
  containerHighlightClassName: stageOptions.containerHighlightClassName,
3584
3817
  containerHighlightDuration: stageOptions.containerHighlightDuration,
3818
+ containerHighlightType: stageOptions.containerHighlightType,
3585
3819
  canSelect: (el, event, stop) => {
3586
3820
  const elCanSelect = stageOptions.canSelect(el);
3587
3821
  if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
@@ -3605,12 +3839,17 @@
3605
3839
  stage?.on("highlight", (el) => {
3606
3840
  services?.editorService.highlight(el.id);
3607
3841
  });
3842
+ stage?.on("multiSelect", (els) => {
3843
+ services?.editorService.multiSelect(els.map((el) => el.id));
3844
+ });
3608
3845
  stage?.on("update", (ev) => {
3609
3846
  if (ev.parentEl) {
3610
- services?.editorService.moveToContainer({ id: ev.el.id, style: ev.style }, ev.parentEl.id);
3847
+ for (const data of ev.data) {
3848
+ services?.editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
3849
+ }
3611
3850
  return;
3612
3851
  }
3613
- services?.editorService.update({ id: ev.el.id, style: ev.style });
3852
+ services?.editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
3614
3853
  });
3615
3854
  stage?.on("sort", (ev) => {
3616
3855
  services?.editorService.sort(ev.src, ev.dist);
@@ -3663,99 +3902,96 @@
3663
3902
  resizeObserver.disconnect();
3664
3903
  services?.editorService.set("stage", null);
3665
3904
  });
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
- }
3905
+ const contextmenuHandler = (e2) => {
3906
+ e2.preventDefault();
3907
+ menu.value?.show(e2);
3908
+ };
3909
+ const dragoverHandler = (e2) => {
3910
+ e2.preventDefault();
3911
+ if (e2.dataTransfer) {
3912
+ e2.dataTransfer.dropEffect = "move";
3913
+ }
3914
+ };
3915
+ const dropHandler = async (e) => {
3916
+ e.preventDefault();
3917
+ const doc = stage?.renderer.contentWindow?.document;
3918
+ const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
3919
+ let parent = page.value;
3920
+ if (parentEl) {
3921
+ parent = services?.editorService.getNodeById(parentEl.id, false);
3922
+ }
3923
+ if (e.dataTransfer && parent && stageContainer.value && stage) {
3924
+ const config = eval(`(${e.dataTransfer.getData("data")})`);
3925
+ const layout = await services?.editorService.getLayout(parent);
3926
+ const containerRect = stageContainer.value.getBoundingClientRect();
3927
+ const { scrollTop, scrollLeft } = stage.mask;
3928
+ const { style = {} } = config;
3929
+ let top = 0;
3930
+ let left = 0;
3931
+ let position = "relative";
3932
+ if (layout === Layout.ABSOLUTE) {
3933
+ position = "absolute";
3934
+ top = e.clientY - containerRect.top + scrollTop;
3935
+ left = e.clientX - containerRect.left + scrollLeft;
3936
+ if (parentEl && doc) {
3937
+ const { left: parentLeft, top: parentTop } = StageCore.getOffset(parentEl);
3938
+ left = left - StageCore.calcValueByFontsize(doc, parentLeft);
3939
+ top = top - StageCore.calcValueByFontsize(doc, parentTop);
3708
3940
  }
3709
- config.style = {
3710
- ...style,
3711
- position,
3712
- top,
3713
- left
3714
- };
3715
- services?.editorService.add(config, parent);
3716
3941
  }
3942
+ config.style = {
3943
+ ...style,
3944
+ position,
3945
+ top,
3946
+ left
3947
+ };
3948
+ config.inputEvent = e;
3949
+ services?.editorService.add(config, parent);
3717
3950
  }
3718
3951
  };
3952
+ return (_ctx, _cache) => {
3953
+ return vue.openBlock(), vue.createBlock(ScrollViewer, {
3954
+ class: "m-editor-stage",
3955
+ ref_key: "stageWrap",
3956
+ ref: stageWrap,
3957
+ width: vue.unref(stageRect)?.width,
3958
+ height: vue.unref(stageRect)?.height,
3959
+ zoom: vue.unref(zoom)
3960
+ }, {
3961
+ default: vue.withCtx(() => [
3962
+ vue.createElementVNode("div", {
3963
+ class: "m-editor-stage-container",
3964
+ ref_key: "stageContainer",
3965
+ ref: stageContainer,
3966
+ style: vue.normalizeStyle(`transform: scale(${vue.unref(zoom)})`),
3967
+ onContextmenu: contextmenuHandler,
3968
+ onDrop: dropHandler,
3969
+ onDragover: dragoverHandler
3970
+ }, null, 36),
3971
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3972
+ vue.createVNode(_sfc_main$3, {
3973
+ ref_key: "menu",
3974
+ ref: menu,
3975
+ "is-multi-select": vue.unref(isMultiSelect)
3976
+ }, null, 8, ["is-multi-select"])
3977
+ ]))
3978
+ ]),
3979
+ _: 1
3980
+ }, 8, ["width", "height", "zoom"]);
3981
+ };
3719
3982
  }
3720
3983
  });
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
3984
 
3749
3985
  const _sfc_main$1 = vue.defineComponent({
3750
3986
  name: "m-editor-workspace",
3751
3987
  components: {
3752
- PageBar,
3753
- MagicStage
3988
+ PageBar: _sfc_main$5,
3989
+ MagicStage: _sfc_main$2
3754
3990
  },
3755
3991
  setup() {
3756
3992
  const services = vue.inject("services");
3757
3993
  const workspace = vue.ref();
3758
- const node = vue.computed(() => services?.editorService.get("node"));
3994
+ const nodes = vue.computed(() => services?.editorService.get("nodes"));
3759
3995
  let keycon;
3760
3996
  const mouseenterHandler = () => {
3761
3997
  workspace.value?.focus();
@@ -3766,31 +4002,31 @@
3766
4002
  vue.onMounted(() => {
3767
4003
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3768
4004
  workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
3769
- keycon = new KeyController__default["default"](workspace.value);
4005
+ keycon = new KeyController__default.default(workspace.value);
3770
4006
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
3771
4007
  const ctrl = isMac ? "meta" : "ctrl";
3772
4008
  keycon.keyup("delete", (e) => {
3773
4009
  e.inputEvent.preventDefault();
3774
- if (!node.value || utils.isPage(node.value))
4010
+ if (!nodes.value || utils.isPage(nodes.value[0]))
3775
4011
  return;
3776
- services?.editorService.remove(node.value);
4012
+ services?.editorService.remove(nodes.value);
3777
4013
  }).keyup("backspace", (e) => {
3778
4014
  e.inputEvent.preventDefault();
3779
- if (!node.value || utils.isPage(node.value))
4015
+ if (!nodes.value || utils.isPage(nodes.value[0]))
3780
4016
  return;
3781
- services?.editorService.remove(node.value);
4017
+ services?.editorService.remove(nodes.value);
3782
4018
  }).keydown([ctrl, "c"], (e) => {
3783
4019
  e.inputEvent.preventDefault();
3784
- node.value && services?.editorService.copy(node.value);
4020
+ nodes.value && services?.editorService.copy(nodes.value);
3785
4021
  }).keydown([ctrl, "v"], (e) => {
3786
4022
  e.inputEvent.preventDefault();
3787
- node.value && services?.editorService.paste();
4023
+ nodes.value && services?.editorService.paste({ offsetX: 10, offsetY: 10 });
3788
4024
  }).keydown([ctrl, "x"], (e) => {
3789
4025
  e.inputEvent.preventDefault();
3790
- if (!node.value || utils.isPage(node.value))
4026
+ if (!nodes.value || utils.isPage(nodes.value[0]))
3791
4027
  return;
3792
- services?.editorService.copy(node.value);
3793
- services?.editorService.remove(node.value);
4028
+ services?.editorService.copy(nodes.value);
4029
+ services?.editorService.remove(nodes.value);
3794
4030
  }).keydown([ctrl, "z"], (e) => {
3795
4031
  e.inputEvent.preventDefault();
3796
4032
  services?.editorService.undo();
@@ -3852,6 +4088,7 @@
3852
4088
  };
3853
4089
  }
3854
4090
  });
4091
+
3855
4092
  const _hoisted_1 = {
3856
4093
  class: "m-editor-workspace",
3857
4094
  tabindex: "1",
@@ -3876,14 +4113,14 @@
3876
4113
  })
3877
4114
  ], 512);
3878
4115
  }
3879
- var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4116
+ const Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
3880
4117
 
3881
4118
  class ComponentList extends BaseService {
4119
+ state = vue.reactive({
4120
+ list: []
4121
+ });
3882
4122
  constructor() {
3883
4123
  super([]);
3884
- this.state = vue.reactive({
3885
- list: []
3886
- });
3887
4124
  }
3888
4125
  setList(componentGroupList) {
3889
4126
  this.state.list = componentGroupList;
@@ -3892,7 +4129,7 @@
3892
4129
  return this.state.list;
3893
4130
  }
3894
4131
  }
3895
- var componentListService = new ComponentList();
4132
+ const componentListService = new ComponentList();
3896
4133
 
3897
4134
  const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3898
4135
  const MIN_LEFT_COLUMN_WIDTH = 45;
@@ -4004,13 +4241,15 @@
4004
4241
  const { height, width } = stageContainerRect;
4005
4242
  if (!width || !height)
4006
4243
  return 1;
4007
- if (width > stageRect.width && height > stageRect.height) {
4244
+ const stageWidth = stageRect.width + 30;
4245
+ const stageHeight = stageRect.height + 30;
4246
+ if (width > stageWidth && height > stageHeight) {
4008
4247
  return 1;
4009
4248
  }
4010
- return Math.min((width - 100) / stageRect.width || 1, (height - 100) / stageRect.height || 1);
4249
+ return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
4011
4250
  }
4012
4251
  }
4013
- var uiService = new Ui();
4252
+ const uiService = new Ui();
4014
4253
 
4015
4254
  const _sfc_main = vue.defineComponent({
4016
4255
  name: "m-editor",
@@ -4085,6 +4324,10 @@
4085
4324
  type: Number,
4086
4325
  default: 800
4087
4326
  },
4327
+ containerHighlightType: {
4328
+ type: String,
4329
+ default: StageCore.ContainerHighlightType.DEFAULT
4330
+ },
4088
4331
  stageRect: {
4089
4332
  type: [String, Object]
4090
4333
  },
@@ -4140,7 +4383,8 @@
4140
4383
  historyService,
4141
4384
  propsService,
4142
4385
  editorService,
4143
- uiService
4386
+ uiService,
4387
+ storageService
4144
4388
  };
4145
4389
  vue.provide("services", services);
4146
4390
  vue.provide("layerContentMenu", props.layerContentMenu);
@@ -4154,11 +4398,13 @@
4154
4398
  updateDragEl: props.updateDragEl,
4155
4399
  isContainer: props.isContainer,
4156
4400
  containerHighlightClassName: props.containerHighlightClassName,
4157
- containerHighlightDuration: props.containerHighlightDuration
4401
+ containerHighlightDuration: props.containerHighlightDuration,
4402
+ containerHighlightType: props.containerHighlightType
4158
4403
  }));
4159
4404
  return services;
4160
4405
  }
4161
4406
  });
4407
+
4162
4408
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4163
4409
  const _component_nav_menu = vue.resolveComponent("nav-menu");
4164
4410
  const _component_sidebar = vue.resolveComponent("sidebar");
@@ -4219,18 +4465,18 @@
4219
4465
  _: 3
4220
4466
  }, 8, ["code-options"]);
4221
4467
  }
4222
- var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
4468
+ const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
4223
4469
 
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}")();
4470
+ const index$1 = '';
4225
4471
 
4226
4472
  const defaultInstallOpt = {};
4227
- var index = {
4473
+ const index = {
4228
4474
  install: (app, opt) => {
4229
4475
  const option = Object.assign(defaultInstallOpt, opt || {});
4230
4476
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4231
4477
  setConfig(option);
4232
4478
  app.component(Editor.name, Editor);
4233
- app.component(uiSelect.name, uiSelect);
4479
+ app.component("m-fields-ui-select", _sfc_main$l);
4234
4480
  app.component(CodeLink.name, CodeLink);
4235
4481
  app.component(Code.name, Code);
4236
4482
  app.component(CodeEditor.name, CodeEditor);
@@ -4249,20 +4495,20 @@
4249
4495
  exports.PropsPanel = PropsPanel;
4250
4496
  exports.TMagicCodeEditor = CodeEditor;
4251
4497
  exports.TMagicEditor = Editor;
4252
- exports.ToolButton = ToolButton;
4498
+ exports.ToolButton = _sfc_main$f;
4253
4499
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
4254
4500
  exports.change2Fixed = change2Fixed;
4255
4501
  exports.debug = debug;
4256
- exports["default"] = index;
4502
+ exports.default = index;
4257
4503
  exports.editorService = editorService;
4258
4504
  exports.error = error;
4259
4505
  exports.eventsService = eventsService;
4260
4506
  exports.fillConfig = fillConfig;
4261
4507
  exports.fixNodeLeft = fixNodeLeft;
4508
+ exports.fixNodePosition = fixNodePosition;
4262
4509
  exports.generatePageName = generatePageName;
4263
4510
  exports.generatePageNameByApp = generatePageNameByApp;
4264
4511
  exports.getConfig = getConfig;
4265
- exports.getDefaultPropsValue = getDefaultPropsValue;
4266
4512
  exports.getGuideLineFromCache = getGuideLineFromCache;
4267
4513
  exports.getInitPositionStyle = getInitPositionStyle;
4268
4514
  exports.getNodeIndex = getNodeIndex;
@@ -4276,6 +4522,7 @@
4276
4522
  exports.propsService = propsService;
4277
4523
  exports.setConfig = setConfig;
4278
4524
  exports.setLayout = setLayout;
4525
+ exports.storageService = storageService;
4279
4526
  exports.uiService = uiService;
4280
4527
  exports.warn = warn;
4281
4528