@tmagic/editor 1.0.0-beta.8 → 1.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +1 -0
  2. package/dist/style.css +94 -45
  3. package/dist/tmagic-editor.es.js +1622 -2069
  4. package/dist/tmagic-editor.es.js.map +1 -1
  5. package/dist/tmagic-editor.umd.js +1621 -2071
  6. package/dist/tmagic-editor.umd.js.map +1 -1
  7. package/dist/types/src/Editor.vue.d.ts +50 -2
  8. package/dist/types/src/fields/Code.vue.d.ts +4 -4
  9. package/dist/types/src/fields/CodeLink.vue.d.ts +1 -3
  10. package/dist/types/src/index.d.ts +1 -0
  11. package/dist/types/src/layouts/CodeEditor.vue.d.ts +13 -4
  12. package/dist/types/src/layouts/Framework.vue.d.ts +15 -3
  13. package/dist/types/src/layouts/PropsPanel.vue.d.ts +4 -5
  14. package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +2 -1
  15. package/dist/types/src/layouts/sidebar/Sidebar.vue.d.ts +2 -3
  16. package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +14 -0
  17. package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +5 -31
  18. package/dist/types/src/services/BaseService.d.ts +5 -2
  19. package/dist/types/src/services/editor.d.ts +16 -6
  20. package/dist/types/src/services/history.d.ts +2 -18
  21. package/dist/types/src/services/props.d.ts +8 -2
  22. package/dist/types/src/services/ui.d.ts +2 -0
  23. package/dist/types/src/type.d.ts +25 -9
  24. package/dist/types/src/utils/editor.d.ts +5 -10
  25. package/dist/types/src/utils/polyfills.d.ts +0 -0
  26. package/dist/types/src/utils/props.d.ts +8 -1
  27. package/package.json +35 -12
  28. package/src/Editor.vue +44 -9
  29. package/src/components/ContentMenu.vue +140 -0
  30. package/src/components/ScrollViewer.vue +1 -1
  31. package/src/components/ToolButton.vue +72 -31
  32. package/src/fields/UISelect.vue +14 -6
  33. package/src/index.ts +2 -0
  34. package/src/layouts/AddPageBox.vue +3 -1
  35. package/src/layouts/CodeEditor.vue +20 -13
  36. package/src/layouts/Framework.vue +20 -7
  37. package/src/layouts/PropsPanel.vue +5 -4
  38. package/src/layouts/sidebar/ComponentListPanel.vue +25 -3
  39. package/src/layouts/sidebar/LayerMenu.vue +93 -95
  40. package/src/layouts/sidebar/LayerPanel.vue +80 -59
  41. package/src/layouts/sidebar/Sidebar.vue +13 -52
  42. package/src/layouts/sidebar/TabPane.vue +68 -0
  43. package/src/layouts/workspace/PageBar.vue +145 -17
  44. package/src/layouts/workspace/Stage.vue +65 -91
  45. package/src/layouts/workspace/ViewerMenu.vue +122 -68
  46. package/src/layouts/workspace/Workspace.vue +125 -42
  47. package/src/services/BaseService.ts +71 -23
  48. package/src/services/editor.ts +231 -69
  49. package/src/services/history.ts +7 -0
  50. package/src/services/props.ts +64 -9
  51. package/src/services/ui.ts +35 -5
  52. package/src/theme/common/var.scss +3 -2
  53. package/src/theme/component-list-panel.scss +2 -0
  54. package/src/theme/content-menu.scss +33 -26
  55. package/src/theme/layer-panel.scss +10 -0
  56. package/src/theme/nav-menu.scss +6 -2
  57. package/src/theme/page-bar.scss +42 -2
  58. package/src/theme/props-panel.scss +19 -17
  59. package/src/theme/workspace.scss +4 -0
  60. package/src/type.ts +27 -9
  61. package/src/utils/editor.ts +37 -56
  62. package/src/utils/polyfills.ts +8 -0
  63. package/src/utils/props.ts +50 -8
  64. package/LICENSE +0 -5432
  65. package/dist/types/src/components/ToolButton.vue.d.ts +0 -35
  66. package/dist/types/src/fields/UISelect.vue.d.ts +0 -32
  67. package/dist/types/src/layouts/sidebar/LayerMenu.vue.d.ts +0 -31
  68. package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -973
  69. package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +0 -11
  70. package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -192
  71. package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
  72. package/tsconfig.json +0 -9
  73. package/vite.config.ts +0 -30
@@ -1,14 +1,14 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('monaco-editor'), require('@element-plus/icons'), require('lodash-es'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('element-plus'), require('@tmagic/stage')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'monaco-editor', '@element-plus/icons', 'lodash-es', '@tmagic/utils', 'events', '@tmagic/core', 'element-plus', '@tmagic/stage'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.monaco, global.icons, global.lodashEs, global.utils, global.events, global.core, global.elementPlus, global.StageCore));
5
- })(this, (function (exports, vue, serialize, monaco, icons, lodashEs, utils, events, core, elementPlus, StageCore) { 'use strict';
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/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon'), require('@tmagic/stage')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons', 'lodash-es', 'monaco-editor', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon', '@tmagic/stage'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.icons, global.lodashEs, global.monaco, global.schema, global.utils, global.events, global.core, global.Gesto, global.ElementPlus, global.KeyController, global.StageCore));
5
+ })(this, (function (exports, vue, serialize, icons, lodashEs, monaco, schema, utils, events, core, Gesto, elementPlus, KeyController, StageCore) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return 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 = {__proto__: null, [Symbol.toStringTag]: 'Module'};
11
+ var n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
12
12
  if (e) {
13
13
  Object.keys(e).forEach(function (k) {
14
14
  if (k !== 'default') {
@@ -26,8 +26,17 @@
26
26
 
27
27
  var serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
28
28
  var monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
29
+ var Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
30
+ var KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
29
31
  var StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
30
32
 
33
+ if (typeof global === "undefined") {
34
+ window.global = window;
35
+ }
36
+ if (typeof globalThis === "undefined") {
37
+ window.globalThis = window;
38
+ }
39
+
31
40
  var _export_sfc = (sfc, props) => {
32
41
  const target = sfc.__vccOpts || sfc;
33
42
  for (const [key, val] of props) {
@@ -36,7 +45,7 @@
36
45
  return target;
37
46
  };
38
47
 
39
- const _sfc_main$k = vue.defineComponent({
48
+ const _sfc_main$m = vue.defineComponent({
40
49
  name: "m-fields-vs-code",
41
50
  props: ["model", "name", "config", "prop"],
42
51
  emits: ["change"],
@@ -53,7 +62,7 @@
53
62
  };
54
63
  }
55
64
  });
56
- function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) {
65
+ function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) {
57
66
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
58
67
  return vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
59
68
  style: vue.normalizeStyle(`height: ${_ctx.height}`),
@@ -62,9 +71,9 @@
62
71
  onSave: _ctx.save
63
72
  }, null, 8, ["style", "init-values", "language", "onSave"]);
64
73
  }
65
- var Code = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
74
+ var Code = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$m]]);
66
75
 
67
- const _sfc_main$j = vue.defineComponent({
76
+ const _sfc_main$l = vue.defineComponent({
68
77
  name: "m-fields-code-link",
69
78
  props: {
70
79
  config: {
@@ -119,7 +128,7 @@
119
128
  };
120
129
  }
121
130
  });
122
- function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
131
+ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) {
123
132
  const _component_m_fields_link = vue.resolveComponent("m-fields-link");
124
133
  return vue.openBlock(), vue.createBlock(_component_m_fields_link, {
125
134
  config: _ctx.formConfig,
@@ -128,11 +137,11 @@
128
137
  onChange: _ctx.changeHandler
129
138
  }, null, 8, ["config", "model", "onChange"]);
130
139
  }
131
- var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
140
+ var CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$l]]);
132
141
 
133
- var UISelect_vue_vue_type_style_index_0_lang = '';
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}")();
134
143
 
135
- const _sfc_main$i = vue.defineComponent({
144
+ const _sfc_main$k = vue.defineComponent({
136
145
  name: "m-fields-ui-select",
137
146
  props: {
138
147
  labelWidth: String,
@@ -170,6 +179,9 @@
170
179
  }
171
180
  };
172
181
  return {
182
+ Delete: vue.markRaw(icons.Delete),
183
+ Pointer: vue.markRaw(icons.Pointer),
184
+ Close: vue.markRaw(icons.Close),
173
185
  val,
174
186
  uiSelectMode,
175
187
  toName: vue.computed(() => {
@@ -194,34 +206,64 @@
194
206
  };
195
207
  }
196
208
  });
197
- const _hoisted_1$d = /* @__PURE__ */ vue.createElementVNode("i", {
198
- class: "el-icon-delete",
199
- style: { "color": "rgb(221, 75, 57)" }
200
- }, "\u53D6\u6D88", -1);
201
- const _hoisted_2$7 = [
202
- _hoisted_1$d
203
- ];
204
- const _hoisted_3$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
205
- function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
209
+ const _hoisted_1$c = /* @__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");
206
213
  return _ctx.uiSelectMode ? (vue.openBlock(), vue.createElementBlock("div", {
207
214
  key: 0,
208
215
  class: "m-fields-ui-select",
209
216
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.cancelHandler && _ctx.cancelHandler(...args))
210
- }, _hoisted_2$7)) : (vue.openBlock(), vue.createElementBlock("div", {
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$c
226
+ ]),
227
+ _: 1
228
+ }, 8, ["icon"])
229
+ ])) : (vue.openBlock(), vue.createElementBlock("div", {
211
230
  key: 1,
212
231
  class: "m-fields-ui-select",
213
- onClick: _cache[2] || (_cache[2] = (...args) => _ctx.startSelect && _ctx.startSelect(...args))
232
+ onClick: _cache[1] || (_cache[1] = (...args) => _ctx.startSelect && _ctx.startSelect(...args)),
233
+ style: { "display": "flex" }
214
234
  }, [
215
- _hoisted_3$5,
216
- vue.createElementVNode("span", null, vue.toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1),
217
- _ctx.val ? (vue.openBlock(), vue.createElementBlock("i", {
218
- key: 0,
219
- class: "el-icon-delete",
220
- onClick: _cache[1] || (_cache[1] = vue.withModifiers((...args) => _ctx.deleteHandler && _ctx.deleteHandler(...args), ["stop"]))
221
- })) : vue.createCommentVNode("", true)
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(() => [
252
+ vue.createVNode(_component_el_button, {
253
+ text: "",
254
+ style: { "padding": "0", "margin": "0" }
255
+ }, {
256
+ default: vue.withCtx(() => [
257
+ vue.createTextVNode(vue.toDisplayString(_ctx.val ? _ctx.toName + "_" + _ctx.val : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
258
+ ]),
259
+ _: 1
260
+ })
261
+ ]),
262
+ _: 1
263
+ }, 8, ["content"])
222
264
  ]));
223
265
  }
224
- var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
266
+ var uiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$k]]);
225
267
 
226
268
  const toString = (v, language) => {
227
269
  let value = "";
@@ -238,7 +280,7 @@
238
280
  }
239
281
  return value;
240
282
  };
241
- const _sfc_main$h = vue.defineComponent({
283
+ const _sfc_main$j = vue.defineComponent({
242
284
  name: "magic-code-editor",
243
285
  props: {
244
286
  initValues: {
@@ -248,12 +290,16 @@
248
290
  type: [String, Object]
249
291
  },
250
292
  type: {
251
- type: [String],
293
+ type: String,
252
294
  default: () => ""
253
295
  },
254
296
  language: {
255
- type: [String],
297
+ type: String,
256
298
  default: () => "javascript"
299
+ },
300
+ options: {
301
+ type: Object,
302
+ default: () => ({})
257
303
  }
258
304
  },
259
305
  emits: ["initd", "save"],
@@ -263,6 +309,10 @@
263
309
  const values = vue.ref("");
264
310
  const loading = vue.ref(false);
265
311
  const codeEditor = vue.ref();
312
+ const resizeObserver = new globalThis.ResizeObserver(lodashEs.throttle(() => {
313
+ vsEditor?.layout();
314
+ vsDiffEditor?.layout();
315
+ }, 300));
266
316
  const setEditorValue = (v, m) => {
267
317
  values.value = toString(v, props.language);
268
318
  if (props.type === "diff") {
@@ -275,10 +325,6 @@
275
325
  }
276
326
  return vsEditor?.setValue(values.value);
277
327
  };
278
- const resizeHandler = () => {
279
- vsEditor?.layout();
280
- vsDiffEditor?.layout();
281
- };
282
328
  const getEditorValue = () => props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
283
329
  const init = async () => {
284
330
  if (!codeEditor.value)
@@ -286,11 +332,8 @@
286
332
  const options = {
287
333
  value: values.value,
288
334
  language: props.language,
289
- tabSize: 2,
290
335
  theme: "vs-dark",
291
- fontFamily: 'dm, Menlo, Monaco, "Courier New", monospace',
292
- fontSize: 15,
293
- formatOnPaste: true
336
+ ...props.options
294
337
  };
295
338
  if (props.type === "diff") {
296
339
  vsDiffEditor = monaco__namespace.editor.createDiffEditor(codeEditor.value, options);
@@ -303,6 +346,7 @@
303
346
  codeEditor.value.addEventListener("keydown", (e) => {
304
347
  if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
305
348
  e.preventDefault();
349
+ e.stopPropagation();
306
350
  emit("save", getEditorValue());
307
351
  }
308
352
  });
@@ -311,7 +355,7 @@
311
355
  emit("save", getEditorValue());
312
356
  });
313
357
  }
314
- globalThis.addEventListener("resize", resizeHandler);
358
+ resizeObserver.observe(codeEditor.value);
315
359
  };
316
360
  vue.watch(() => props.initValues, (v, preV) => {
317
361
  if (v !== preV) {
@@ -326,7 +370,7 @@
326
370
  init();
327
371
  });
328
372
  vue.onUnmounted(() => {
329
- globalThis.removeEventListener("resize", resizeHandler);
373
+ resizeObserver.disconnect();
330
374
  });
331
375
  return {
332
376
  values,
@@ -343,14 +387,14 @@
343
387
  };
344
388
  }
345
389
  });
346
- const _hoisted_1$c = {
390
+ const _hoisted_1$b = {
347
391
  ref: "codeEditor",
348
392
  class: "magic-code-editor"
349
393
  };
350
- function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
351
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
394
+ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) {
395
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, null, 512);
352
396
  }
353
- var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
397
+ var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$j]]);
354
398
 
355
399
  let $TMAGIC_EDITOR = {};
356
400
  const setConfig = (option) => {
@@ -359,9 +403,6 @@
359
403
  const getConfig = (key) => $TMAGIC_EDITOR[key];
360
404
 
361
405
  class UndoRedo {
362
- elementList;
363
- listCursor;
364
- listMaxSize;
365
406
  constructor(listMaxSize = 200) {
366
407
  const minListMaxSize = 2;
367
408
  this.elementList = [];
@@ -434,11 +475,40 @@
434
475
 
435
476
  const methodName = (prefix, name) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
436
477
  const isError = (error) => Object.prototype.toString.call(error) === "[object Error]";
478
+ const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethodName, fn) => {
479
+ try {
480
+ let beforeArgs = args;
481
+ 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];
487
+ }
488
+ beforeArgs = beforeArgs.map((v, index) => {
489
+ if (typeof beforeReturnValue[index] === "undefined")
490
+ return v;
491
+ return beforeReturnValue[index];
492
+ });
493
+ }
494
+ let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
495
+ for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
496
+ returnValue = await afterMethod(returnValue, ...beforeArgs);
497
+ if (isError(returnValue))
498
+ throw returnValue;
499
+ }
500
+ return returnValue;
501
+ } catch (error) {
502
+ throw error;
503
+ }
504
+ };
437
505
  class BaseService extends events.EventEmitter {
438
- pluginOptionsList = {};
439
- middleware = {};
440
- constructor(methods) {
506
+ constructor(methods = [], serialMethods = []) {
441
507
  super();
508
+ this.pluginOptionsList = {};
509
+ this.middleware = {};
510
+ this.taskList = [];
511
+ this.doingTask = false;
442
512
  methods.forEach((propertyName) => {
443
513
  const scope = this;
444
514
  const sourceMethod = scope[propertyName];
@@ -450,27 +520,23 @@
450
520
  const fn = compose(this.middleware[propertyName]);
451
521
  Object.defineProperty(scope, propertyName, {
452
522
  value: async (...args) => {
453
- let beforeArgs = args;
454
- for (const beforeMethod of this.pluginOptionsList[beforeMethodName]) {
455
- let beforeReturnValue = await beforeMethod(...beforeArgs) || [];
456
- if (isError(beforeReturnValue))
457
- throw beforeReturnValue;
458
- if (!Array.isArray(beforeReturnValue)) {
459
- beforeReturnValue = [beforeReturnValue];
460
- }
461
- beforeArgs = beforeArgs.map((v, index) => {
462
- if (typeof beforeReturnValue[index] === "undefined")
463
- return v;
464
- return beforeReturnValue[index];
465
- });
523
+ if (!serialMethods.includes(propertyName)) {
524
+ return doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
466
525
  }
467
- let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
468
- for (const afterMethod of this.pluginOptionsList[afterMethodName]) {
469
- returnValue = await afterMethod(...beforeArgs, returnValue);
470
- if (isError(returnValue))
471
- throw returnValue;
526
+ const promise = new Promise((resolve, reject) => {
527
+ this.taskList.push(async () => {
528
+ try {
529
+ const value = await doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
530
+ resolve(value);
531
+ } catch (e) {
532
+ reject(e);
533
+ }
534
+ });
535
+ });
536
+ if (!this.doingTask) {
537
+ this.doTask();
472
538
  }
473
- return returnValue;
539
+ return promise;
474
540
  }
475
541
  });
476
542
  });
@@ -487,19 +553,34 @@
487
553
  this.pluginOptionsList[methodName2].push(method);
488
554
  });
489
555
  }
556
+ async doTask() {
557
+ this.doingTask = true;
558
+ let task = this.taskList.shift();
559
+ while (task) {
560
+ await task();
561
+ task = this.taskList.shift();
562
+ }
563
+ this.doingTask = false;
564
+ }
490
565
  }
491
566
 
492
567
  class History extends BaseService {
493
- state = vue.reactive({
494
- pageSteps: {},
495
- pageId: void 0,
496
- canRedo: false,
497
- canUndo: false
498
- });
499
568
  constructor() {
500
569
  super([]);
570
+ this.state = vue.reactive({
571
+ pageSteps: {},
572
+ pageId: void 0,
573
+ canRedo: false,
574
+ canUndo: false
575
+ });
501
576
  this.on("change", this.setCanUndoRedo);
502
577
  }
578
+ reset() {
579
+ this.state.pageSteps = {};
580
+ this.state.pageId = void 0;
581
+ this.state.canRedo = false;
582
+ this.state.canUndo = false;
583
+ }
503
584
  changePage(page) {
504
585
  if (!page)
505
586
  return;
@@ -563,12 +644,12 @@
563
644
  var historyService = new History();
564
645
 
565
646
  class Props extends BaseService {
566
- state = vue.reactive({
567
- propsConfigMap: {},
568
- propsValueMap: {}
569
- });
570
647
  constructor() {
571
- super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue"]);
648
+ super(["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "createId", "setNewItemId"]);
649
+ this.state = vue.reactive({
650
+ propsConfigMap: {},
651
+ propsValueMap: {}
652
+ });
572
653
  }
573
654
  setPropsConfigs(configs) {
574
655
  Object.keys(configs).forEach((type) => {
@@ -593,7 +674,7 @@
593
674
  setPropsValue(type, value) {
594
675
  this.state.propsValueMap[type] = value;
595
676
  }
596
- async getPropsValue(type) {
677
+ async getPropsValue(type, defaultValue = {}) {
597
678
  if (type === "area") {
598
679
  const value = await this.getPropsValue("button");
599
680
  value.className = "action-area";
@@ -603,12 +684,44 @@
603
684
  }
604
685
  return value;
605
686
  }
606
- return lodashEs.cloneDeep({
607
- ...getDefaultPropsValue(type),
608
- ...this.state.propsValueMap[type] || {}
609
- });
687
+ const data = lodashEs.cloneDeep(defaultValue);
688
+ await this.setNewItemId(data);
689
+ return {
690
+ ...getDefaultPropsValue(type, await this.createId(type)),
691
+ ...lodashEs.mergeWith(lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
692
+ };
693
+ }
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
+ }
610
708
  }
611
709
  }
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
+ };
612
725
  var propsService = new Props();
613
726
 
614
727
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
@@ -629,10 +742,9 @@
629
742
  })(Keys || {});
630
743
 
631
744
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
632
- const generateId = (type) => `${type}_${lodashEs.random(1e4, false)}`;
633
745
  const getPageList = (app) => {
634
746
  if (app.items && Array.isArray(app.items)) {
635
- return app.items.filter((item) => item.type === "page");
747
+ return app.items.filter((item) => item.type === schema.NodeType.PAGE);
636
748
  }
637
749
  return [];
638
750
  };
@@ -649,32 +761,6 @@
649
761
  return pageName;
650
762
  };
651
763
  const generatePageNameByApp = (app) => generatePageName(getPageNameList(getPageList(app)));
652
- const updatePopId = (oldId, popId, pageConfig) => {
653
- pageConfig.items?.forEach((config) => {
654
- if (config.pop === oldId) {
655
- config.pop = popId;
656
- return;
657
- }
658
- if (config.popId === oldId) {
659
- config.popId = popId;
660
- return;
661
- }
662
- if (Array.isArray(config.items)) {
663
- updatePopId(oldId, popId, config);
664
- }
665
- });
666
- };
667
- const setNewItemId = (config, parent) => {
668
- const oldId = config.id;
669
- config.id = generateId(config.type);
670
- config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
671
- if (utils.isPop(config) && parent?.type === "page") {
672
- updatePopId(oldId, config.id, parent);
673
- }
674
- if (config.items && Array.isArray(config.items)) {
675
- config.items.forEach((item) => setNewItemId(item, config));
676
- }
677
- };
678
764
  const isFixed = (node) => node.style?.position === "fixed";
679
765
  const getNodeIndex = (node, parent) => {
680
766
  const items = parent?.items || [];
@@ -689,11 +775,28 @@
689
775
  };
690
776
  return node;
691
777
  };
692
- const initPosition = (node, layout) => {
778
+ const setTop2Middle = (node, parentNode, stage) => {
779
+ const style = node.style || {};
780
+ let height = style.height || 0;
781
+ if (!stage || typeof style.top !== "undefined" || !parentNode.style)
782
+ return style;
783
+ if (!utils.isNumber(height)) {
784
+ height = 0;
785
+ }
786
+ const { height: parentHeight } = parentNode.style;
787
+ if (utils.isPage(parentNode)) {
788
+ const { scrollTop = 0, wrapperHeight } = stage.mask;
789
+ style.top = (wrapperHeight - height) / 2 + scrollTop;
790
+ } else {
791
+ style.top = (parentHeight - height) / 2;
792
+ }
793
+ return style;
794
+ };
795
+ const initPosition = (node, layout, parentNode, stage) => {
693
796
  if (layout === Layout.ABSOLUTE) {
694
797
  node.style = {
695
798
  position: "absolute",
696
- ...node.style || {}
799
+ ...setTop2Middle(node, parentNode, stage)
697
800
  };
698
801
  return node;
699
802
  }
@@ -740,7 +843,9 @@
740
843
  const cur = path.pop();
741
844
  const offset = {
742
845
  left: cur?.style?.left || 0,
743
- top: cur?.style?.top || 0
846
+ top: cur?.style?.top || 0,
847
+ right: "",
848
+ bottom: ""
744
849
  };
745
850
  path.forEach((value) => {
746
851
  offset.left = offset.left - globalThis.parseFloat(value.style?.left || 0);
@@ -774,15 +879,6 @@
774
879
  };
775
880
 
776
881
  class Editor$1 extends BaseService {
777
- isHistoryStateChange = false;
778
- state = vue.reactive({
779
- root: null,
780
- page: null,
781
- parent: null,
782
- node: null,
783
- stage: null,
784
- modifiedNodeIds: /* @__PURE__ */ new Map()
785
- });
786
882
  constructor() {
787
883
  super([
788
884
  "getLayout",
@@ -795,13 +891,27 @@
795
891
  "paste",
796
892
  "alignCenter",
797
893
  "moveLayer",
894
+ "move",
798
895
  "undo",
799
- "redo"
800
- ]);
896
+ "redo",
897
+ "highlight"
898
+ ], ["select", "update", "moveLayer"]);
899
+ this.isHistoryStateChange = false;
900
+ this.state = vue.reactive({
901
+ root: null,
902
+ page: null,
903
+ parent: null,
904
+ node: null,
905
+ stage: null,
906
+ highlightNode: null,
907
+ modifiedNodeIds: /* @__PURE__ */ new Map(),
908
+ pageLength: 0
909
+ });
801
910
  }
802
911
  set(name, value) {
803
912
  this.state[name] = value;
804
913
  if (name === "root") {
914
+ this.state.pageLength = value?.items?.length || 0;
805
915
  this.emit("root-change", value);
806
916
  }
807
917
  }
@@ -809,7 +919,7 @@
809
919
  return this.state[name];
810
920
  }
811
921
  getNodeInfo(id) {
812
- const root = this.get("root");
922
+ const root = vue.toRaw(this.get("root"));
813
923
  if (!root)
814
924
  return {};
815
925
  if (id === root.id) {
@@ -823,7 +933,7 @@
823
933
  info.node = path[path.length - 1];
824
934
  info.parent = path[path.length - 2];
825
935
  path.forEach((item) => {
826
- if (item.type === "page") {
936
+ if (item.type === schema.NodeType.PAGE) {
827
937
  info.page = item;
828
938
  return;
829
939
  }
@@ -840,31 +950,19 @@
840
950
  const { parent } = this.getNodeInfo(id);
841
951
  return parent;
842
952
  }
843
- async getLayout(node) {
844
- if (node.layout) {
845
- return node.layout;
953
+ async getLayout(parent, node) {
954
+ if (node && typeof node !== "function" && isFixed(node))
955
+ return Layout.FIXED;
956
+ if (parent.layout) {
957
+ return parent.layout;
846
958
  }
847
- if (!node.style?.position) {
959
+ if (!parent.style?.position) {
848
960
  return Layout.RELATIVE;
849
961
  }
850
962
  return Layout.ABSOLUTE;
851
963
  }
852
964
  async select(config2) {
853
- let id;
854
- if (typeof config2 === "string" || typeof config2 === "number") {
855
- id = config2;
856
- } else {
857
- id = config2.id;
858
- }
859
- if (!id) {
860
- throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
861
- }
862
- const { node, parent, page } = this.getNodeInfo(id);
863
- if (!node)
864
- throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
865
- if (node.id === this.state.root?.id) {
866
- throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
867
- }
965
+ const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
868
966
  this.set("node", node);
869
967
  this.set("page", page || null);
870
968
  this.set("parent", parent || null);
@@ -873,12 +971,51 @@
873
971
  } else {
874
972
  historyService.empty();
875
973
  }
974
+ if (node?.id) {
975
+ this.get("stage")?.renderer.runtime?.getApp?.()?.emit("editor:select", {
976
+ node,
977
+ page,
978
+ parent
979
+ }, utils.getNodePath(node.id, this.get("root").items));
980
+ }
981
+ this.emit("select", node);
876
982
  return node;
877
983
  }
878
- async add({ type, ...config2 }, parent) {
984
+ async selectNextNode() {
985
+ const node = vue.toRaw(this.get("node"));
986
+ if (!node || utils.isPage(node) || node.type === schema.NodeType.ROOT)
987
+ return node;
988
+ const parent = vue.toRaw(this.getParentById(node.id));
989
+ if (!parent)
990
+ return node;
991
+ const index = getNodeIndex(node, parent);
992
+ const nextNode = parent.items[index + 1] || parent.items[0];
993
+ await this.select(nextNode);
994
+ this.get("stage")?.select(nextNode.id);
995
+ return nextNode;
996
+ }
997
+ async selectNextPage() {
998
+ const root = vue.toRaw(this.get("root"));
999
+ const page = vue.toRaw(this.get("page"));
1000
+ const index = getNodeIndex(page, root);
1001
+ const nextPage = root.items[index + 1] || root.items[0];
1002
+ await this.select(nextPage);
1003
+ this.get("stage")?.select(nextPage.id);
1004
+ return nextPage;
1005
+ }
1006
+ highlight(config2) {
1007
+ const { node } = this.selectedConfigExceptionHandler(config2);
1008
+ const currentHighlightNode = this.get("highlightNode");
1009
+ if (currentHighlightNode === node)
1010
+ return;
1011
+ this.set("highlightNode", node);
1012
+ }
1013
+ async add(addNode, parent) {
1014
+ const { type, ...config2 } = addNode;
879
1015
  const curNode = this.get("node");
880
1016
  let parentNode;
881
- if (type === "page") {
1017
+ const isPage2 = type === schema.NodeType.PAGE;
1018
+ if (isPage2) {
882
1019
  parentNode = this.get("root");
883
1020
  } else if (parent && typeof parent !== "function") {
884
1021
  parentNode = parent;
@@ -889,16 +1026,24 @@
889
1026
  }
890
1027
  if (!parentNode)
891
1028
  throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
892
- const layout = await this.getLayout(parentNode);
893
- const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type)), ...config2 }, layout);
894
- if ((parentNode?.type === "app" || curNode.type === "app") && newNode.type !== "page") {
1029
+ const layout = await this.getLayout(vue.toRaw(parentNode), addNode);
1030
+ const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
1031
+ if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
895
1032
  throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
896
1033
  }
897
1034
  parentNode?.items?.push(newNode);
898
- await this.get("stage")?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(this.get("root")) });
1035
+ const stage = this.get("stage");
1036
+ await stage?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(this.get("root")) });
899
1037
  await this.select(newNode);
900
1038
  this.addModifiedNodeId(newNode.id);
901
- this.pushHistoryState();
1039
+ if (!isPage2) {
1040
+ this.pushHistoryState();
1041
+ }
1042
+ stage?.select(newNode.id);
1043
+ if (isPage2) {
1044
+ this.state.pageLength += 1;
1045
+ }
1046
+ this.emit("add", newNode);
902
1047
  return newNode;
903
1048
  }
904
1049
  async remove(node) {
@@ -914,14 +1059,31 @@
914
1059
  if (typeof index !== "number" || index === -1)
915
1060
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
916
1061
  parent.items?.splice(index, 1);
917
- this.get("stage")?.remove({ id: node.id, root: this.get("root") });
918
- if (node.type === "page") {
919
- await this.select(root.items[0] || root);
1062
+ const stage = this.get("stage");
1063
+ stage?.remove({ id: node.id, root: this.get("root") });
1064
+ if (node.type === schema.NodeType.PAGE) {
1065
+ this.state.pageLength -= 1;
1066
+ if (root.items[0]) {
1067
+ await this.select(root.items[0]);
1068
+ stage?.select(root.items[0].id);
1069
+ } else {
1070
+ this.set("node", null);
1071
+ this.set("parent", null);
1072
+ this.set("page", null);
1073
+ this.set("stage", null);
1074
+ this.set("highlightNode", null);
1075
+ this.resetModifiedNodeId();
1076
+ historyService.reset();
1077
+ this.emit("remove", node);
1078
+ return node;
1079
+ }
920
1080
  } else {
921
1081
  await this.select(parent);
1082
+ stage?.select(parent.id);
922
1083
  }
923
1084
  this.addModifiedNodeId(parent.id);
924
1085
  this.pushHistoryState();
1086
+ this.emit("remove", node);
925
1087
  return node;
926
1088
  }
927
1089
  async update(config2) {
@@ -939,7 +1101,7 @@
939
1101
  });
940
1102
  if (!newConfig.type)
941
1103
  throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
942
- if (newConfig.type === "app") {
1104
+ if (newConfig.type === schema.NodeType.ROOT) {
943
1105
  this.set("root", newConfig);
944
1106
  return newConfig;
945
1107
  }
@@ -956,15 +1118,16 @@
956
1118
  newConfig = setLayout(newConfig, newLayout);
957
1119
  }
958
1120
  parentNodeItems[index] = newConfig;
959
- if (newConfig.id === this.get("node").id) {
1121
+ if (`${newConfig.id}` === `${this.get("node").id}`) {
960
1122
  this.set("node", newConfig);
961
1123
  }
962
1124
  this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: this.get("root") });
963
- if (newConfig.type === "page") {
1125
+ if (newConfig.type === schema.NodeType.PAGE) {
964
1126
  this.set("page", newConfig);
965
1127
  }
966
1128
  this.addModifiedNodeId(newConfig.id);
967
1129
  this.pushHistoryState();
1130
+ this.emit("update", newConfig);
968
1131
  return newConfig;
969
1132
  }
970
1133
  async sort(id1, id2) {
@@ -996,23 +1159,36 @@
996
1159
  console.error(e);
997
1160
  return;
998
1161
  }
999
- setNewItemId(config, this.get("root"));
1162
+ await propsService.setNewItemId(config, this.get("root"));
1000
1163
  if (config.style) {
1001
1164
  config.style = {
1002
1165
  ...config.style,
1003
1166
  ...position
1004
1167
  };
1005
1168
  }
1169
+ if (utils.isPage(config)) {
1170
+ config.name = generatePageNameByApp(this.get("root"));
1171
+ }
1006
1172
  return await this.add(config);
1007
1173
  }
1008
1174
  async alignCenter(config2) {
1009
1175
  const parent = this.get("parent");
1010
1176
  const node = this.get("node");
1011
- const layout = await this.getLayout(parent);
1177
+ const layout = await this.getLayout(vue.toRaw(parent), vue.toRaw(node));
1012
1178
  if (layout === Layout.RELATIVE) {
1013
1179
  return;
1014
1180
  }
1015
- if (parent.style?.width && node.style?.width) {
1181
+ if (!node.style)
1182
+ return;
1183
+ const stage = this.get("stage");
1184
+ const doc = stage?.renderer.contentWindow?.document;
1185
+ if (doc) {
1186
+ const parentEl = doc.getElementById(`${parent.id}`);
1187
+ const el = doc.getElementById(`${node.id}`);
1188
+ if (parentEl && el) {
1189
+ node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
1190
+ }
1191
+ } else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
1016
1192
  node.style.left = (parent.style.width - node.style.width) / 2;
1017
1193
  }
1018
1194
  await this.update(node);
@@ -1026,9 +1202,9 @@
1026
1202
  const node = this.get("node");
1027
1203
  const brothers = parent?.items || [];
1028
1204
  const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
1029
- if (offset === LayerOffset.BOTTOM) {
1205
+ if (offset === LayerOffset.TOP) {
1030
1206
  brothers.splice(brothers.length - 1, 0, brothers.splice(index, 1)[0]);
1031
- } else if (offset === LayerOffset.TOP) {
1207
+ } else if (offset === LayerOffset.BOTTOM) {
1032
1208
  brothers.splice(0, 0, brothers.splice(index, 1)[0]);
1033
1209
  } else {
1034
1210
  brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
@@ -1045,6 +1221,26 @@
1045
1221
  await this.changeHistoryState(value);
1046
1222
  return value;
1047
1223
  }
1224
+ async move(left, top) {
1225
+ const node = vue.toRaw(this.get("node"));
1226
+ if (!node || utils.isPage(node))
1227
+ return;
1228
+ const { style, id } = node;
1229
+ if (!style || style.position !== "absolute")
1230
+ return;
1231
+ if (top && !utils.isNumber(style.top))
1232
+ return;
1233
+ if (left && !utils.isNumber(style.left))
1234
+ return;
1235
+ this.update({
1236
+ id,
1237
+ style: {
1238
+ ...style,
1239
+ left: Number(style.left) + left,
1240
+ top: Number(style.top) + top
1241
+ }
1242
+ });
1243
+ }
1048
1244
  destroy() {
1049
1245
  this.removeAllListeners();
1050
1246
  this.set("root", null);
@@ -1077,7 +1273,12 @@
1077
1273
  this.isHistoryStateChange = true;
1078
1274
  await this.update(value.data);
1079
1275
  this.set("modifiedNodeIds", value.modifiedNodeIds);
1080
- setTimeout(() => value.nodeId && this.select(value.nodeId), 0);
1276
+ setTimeout(async () => {
1277
+ if (!value.nodeId)
1278
+ return;
1279
+ await this.select(value.nodeId);
1280
+ this.get("stage")?.select(value.nodeId);
1281
+ }, 0);
1081
1282
  }
1082
1283
  async toggleFixedPosition(dist, src, root) {
1083
1284
  let newConfig = lodashEs.cloneDeep(dist);
@@ -1090,6 +1291,28 @@
1090
1291
  }
1091
1292
  return newConfig;
1092
1293
  }
1294
+ selectedConfigExceptionHandler(config2) {
1295
+ let id;
1296
+ if (typeof config2 === "string" || typeof config2 === "number") {
1297
+ id = config2;
1298
+ } else {
1299
+ id = config2.id;
1300
+ }
1301
+ if (!id) {
1302
+ throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
1303
+ }
1304
+ const { node, parent, page } = this.getNodeInfo(id);
1305
+ if (!node)
1306
+ throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
1307
+ if (node.id === this.state.root?.id) {
1308
+ throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
1309
+ }
1310
+ return {
1311
+ node,
1312
+ parent,
1313
+ page
1314
+ };
1315
+ }
1093
1316
  }
1094
1317
  var editorService = new Editor$1();
1095
1318
 
@@ -1247,6 +1470,40 @@
1247
1470
  defaultValue: "100% 100%"
1248
1471
  }
1249
1472
  ]
1473
+ },
1474
+ {
1475
+ type: "fieldset",
1476
+ legend: "\u5B57\u4F53",
1477
+ items: [
1478
+ {
1479
+ name: "color",
1480
+ text: "\u989C\u8272",
1481
+ type: "colorPicker"
1482
+ },
1483
+ {
1484
+ name: "fontSize",
1485
+ text: "\u5927\u5C0F"
1486
+ },
1487
+ {
1488
+ name: "fontWeight",
1489
+ text: "\u7C97\u7EC6"
1490
+ }
1491
+ ]
1492
+ },
1493
+ {
1494
+ type: "fieldset",
1495
+ legend: "\u53D8\u5F62",
1496
+ name: "transform",
1497
+ items: [
1498
+ {
1499
+ name: "rotate",
1500
+ text: "\u65CB\u8F6C\u89D2\u5EA6"
1501
+ },
1502
+ {
1503
+ name: "scale",
1504
+ text: "\u7F29\u653E"
1505
+ }
1506
+ ]
1250
1507
  }
1251
1508
  ]
1252
1509
  }
@@ -1279,7 +1536,7 @@
1279
1536
  type: "select",
1280
1537
  options: (mForm, { model }) => {
1281
1538
  const node = editorService.getNodeById(model.to);
1282
- if (!node)
1539
+ if (!node?.type)
1283
1540
  return [];
1284
1541
  return eventsService.getMethod(node.type).map((option) => ({
1285
1542
  text: option.label,
@@ -1307,14 +1564,20 @@
1307
1564
  }
1308
1565
  ];
1309
1566
  const DEFAULT_CONFIG = fillConfig([]);
1310
- const getDefaultPropsValue = (type) => ({
1567
+ const getDefaultPropsValue = (type, id) => ["page", "container"].includes(type) ? {
1568
+ type,
1569
+ id,
1570
+ style: {},
1571
+ name: type,
1572
+ items: []
1573
+ } : {
1311
1574
  type,
1312
- id: generateId(type),
1575
+ id,
1313
1576
  style: {},
1314
1577
  name: type
1315
- });
1578
+ };
1316
1579
 
1317
- const _sfc_main$g = vue.defineComponent({
1580
+ const _sfc_main$i = vue.defineComponent({
1318
1581
  components: { Plus: icons.Plus },
1319
1582
  setup() {
1320
1583
  const services = vue.inject("services");
@@ -1324,21 +1587,21 @@
1324
1587
  if (!editorService)
1325
1588
  return;
1326
1589
  editorService.add({
1327
- type: "page",
1590
+ type: schema.NodeType.PAGE,
1328
1591
  name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
1329
1592
  });
1330
1593
  }
1331
1594
  };
1332
1595
  }
1333
1596
  });
1334
- const _hoisted_1$b = { class: "m-editor-empty-panel" };
1335
- const _hoisted_2$6 = { class: "m-editor-empty-content" };
1336
- const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1337
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1597
+ const _hoisted_1$a = { class: "m-editor-empty-panel" };
1598
+ const _hoisted_2$4 = { class: "m-editor-empty-content" };
1599
+ const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1600
+ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1338
1601
  const _component_plus = vue.resolveComponent("plus");
1339
1602
  const _component_el_icon = vue.resolveComponent("el-icon");
1340
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
1341
- vue.createElementVNode("div", _hoisted_2$6, [
1603
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
1604
+ vue.createElementVNode("div", _hoisted_2$4, [
1342
1605
  vue.createElementVNode("div", {
1343
1606
  class: "m-editor-empty-button",
1344
1607
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
@@ -1351,1249 +1614,88 @@
1351
1614
  _: 1
1352
1615
  })
1353
1616
  ]),
1354
- _hoisted_3$4
1617
+ _hoisted_3$2
1355
1618
  ])
1356
1619
  ])
1357
1620
  ]);
1358
1621
  }
1359
- var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
1360
-
1361
- /*
1362
- Copyright (c) 2018 Daybrush
1363
- @name: @daybrush/utils
1364
- license: MIT
1365
- author: Daybrush
1366
- repository: https://github.com/daybrush/utils
1367
- @version 1.6.0
1368
- */
1369
- /**
1370
- * get string "object"
1371
- * @memberof Consts
1372
- * @example
1373
- import {OBJECT} from "@daybrush/utils";
1374
-
1375
- console.log(OBJECT); // "object"
1376
- */
1377
-
1378
- var OBJECT = "object";
1379
- /**
1380
- * Check the type that the value is object.
1381
- * @memberof Utils
1382
- * @param {string} value - Value to check the type
1383
- * @return {} true if the type is correct, false otherwise
1384
- * @example
1385
- import {isObject} from "@daybrush/utils";
1386
-
1387
- console.log(isObject({})); // true
1388
- console.log(isObject(undefined)); // false
1389
- console.log(isObject("")); // false
1390
- console.log(isObject(null)); // false
1391
- */
1392
-
1393
- function isObject(value) {
1394
- return value && typeof value === OBJECT;
1395
- }
1396
- /**
1397
- * Date.now() method
1398
- * @memberof CrossBrowser
1399
- * @return {number} milliseconds
1400
- * @example
1401
- import {now} from "@daybrush/utils";
1402
-
1403
- console.log(now()); // 12121324241(milliseconds)
1404
- */
1405
-
1406
- function now() {
1407
- return Date.now ? Date.now() : new Date().getTime();
1408
- }
1409
- /**
1410
- * Returns the index of the first element in the array that satisfies the provided testing function.
1411
- * @function
1412
- * @memberof CrossBrowser
1413
- * @param - The array `findIndex` was called upon.
1414
- * @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
1415
- * @param - Returns defaultIndex if not found by the function.
1416
- * @example
1417
- import { findIndex } from "@daybrush/utils";
1418
-
1419
- findIndex([{a: 1}, {a: 2}, {a: 3}, {a: 4}], ({ a }) => a === 2); // 1
1420
- */
1421
-
1422
- function findIndex(arr, callback, defaultIndex) {
1423
- if (defaultIndex === void 0) {
1424
- defaultIndex = -1;
1425
- }
1426
-
1427
- var length = arr.length;
1622
+ var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
1428
1623
 
1429
- for (var i = 0; i < length; ++i) {
1430
- if (callback(arr[i], i, arr)) {
1431
- return i;
1624
+ const _sfc_main$h = vue.defineComponent({
1625
+ name: "m-editor-resize",
1626
+ props: {
1627
+ type: {
1628
+ type: String
1432
1629
  }
1630
+ },
1631
+ setup(props) {
1632
+ const services = vue.inject("services");
1633
+ const target = vue.ref();
1634
+ let getso;
1635
+ vue.onMounted(() => {
1636
+ if (!target.value)
1637
+ return;
1638
+ getso = new Gesto__default["default"](target.value, {
1639
+ container: window,
1640
+ pinchOutside: true
1641
+ }).on("drag", (e) => {
1642
+ if (!target.value || !services)
1643
+ return;
1644
+ let { left, right } = {
1645
+ ...vue.toRaw(services.uiService.get("columnWidth"))
1646
+ };
1647
+ if (props.type === "left") {
1648
+ left += e.deltaX;
1649
+ } else if (props.type === "right") {
1650
+ right -= e.deltaX;
1651
+ }
1652
+ services.uiService.set("columnWidth", {
1653
+ left,
1654
+ right
1655
+ });
1656
+ });
1657
+ });
1658
+ vue.onUnmounted(() => {
1659
+ getso?.unset();
1660
+ });
1661
+ return {
1662
+ target
1663
+ };
1433
1664
  }
1434
-
1435
- return defaultIndex;
1436
- }
1437
- /**
1438
- * Sets up a function that will be called whenever the specified event is delivered to the target
1439
- * @memberof DOM
1440
- * @param - event target
1441
- * @param - A case-sensitive string representing the event type to listen for.
1442
- * @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs
1443
- * @param - An options object that specifies characteristics about the event listener.
1444
- * @example
1445
- import {addEvent} from "@daybrush/utils";
1446
-
1447
- addEvent(el, "click", e => {
1448
- console.log(e);
1449
1665
  });
1450
- */
1451
-
1452
- function addEvent(el, type, listener, options) {
1453
- el.addEventListener(type, listener, options);
1454
- }
1455
- /**
1456
- * removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()
1457
- * @memberof DOM
1458
- * @param - event target
1459
- * @param - A case-sensitive string representing the event type to listen for.
1460
- * @param - The EventListener function of the event handler to remove from the event target.
1461
- * @param - An options object that specifies characteristics about the event listener.
1462
- * @example
1463
- import {addEvent, removeEvent} from "@daybrush/utils";
1464
- const listener = e => {
1465
- console.log(e);
1466
- };
1467
- addEvent(el, "click", listener);
1468
- removeEvent(el, "click", listener);
1469
- */
1470
-
1471
- function removeEvent(el, type, listener, options) {
1472
- el.removeEventListener(type, listener, options);
1473
- }
1474
-
1475
- /*
1476
- Copyright (c) 2019 Daybrush
1477
- name: @scena/event-emitter
1478
- license: MIT
1479
- author: Daybrush
1480
- repository: git+https://github.com/daybrush/gesture.git
1481
- version: 1.0.5
1482
- */
1483
-
1484
- /*! *****************************************************************************
1485
- Copyright (c) Microsoft Corporation.
1486
-
1487
- Permission to use, copy, modify, and/or distribute this software for any
1488
- purpose with or without fee is hereby granted.
1489
-
1490
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1491
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1492
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1493
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1494
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1495
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1496
- PERFORMANCE OF THIS SOFTWARE.
1497
- ***************************************************************************** */
1498
- var __assign$1 = function () {
1499
- __assign$1 = Object.assign || function __assign(t) {
1500
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1501
- s = arguments[i];
1502
-
1503
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1504
- }
1505
-
1506
- return t;
1507
- };
1508
-
1509
- return __assign$1.apply(this, arguments);
1510
- };
1511
- function __spreadArrays() {
1512
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1513
-
1514
- for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
1515
-
1516
- return r;
1517
- }
1518
-
1519
- /**
1520
- * Implement EventEmitter on object or component.
1521
- */
1522
-
1523
- var EventEmitter =
1524
- /*#__PURE__*/
1525
- function () {
1526
- function EventEmitter() {
1527
- this._events = {};
1528
- }
1529
- /**
1530
- * Add a listener to the registered event.
1531
- * @param - Name of the event to be added
1532
- * @param - listener function of the event to be added
1533
- * @example
1534
- * import EventEmitter from "@scena/event-emitter";
1535
- * cosnt emitter = new EventEmitter();
1536
- *
1537
- * // Add listener in "a" event
1538
- * emitter.on("a", () => {
1539
- * });
1540
- * // Add listeners
1541
- * emitter.on({
1542
- * a: () => {},
1543
- * b: () => {},
1544
- * });
1545
- */
1546
-
1547
-
1548
- var __proto = EventEmitter.prototype;
1549
-
1550
- __proto.on = function (eventName, listener) {
1551
- if (isObject(eventName)) {
1552
- for (var name in eventName) {
1553
- this.on(name, eventName[name]);
1554
- }
1555
- } else {
1556
- this._addEvent(eventName, listener, {});
1557
- }
1558
-
1559
- return this;
1560
- };
1561
- /**
1562
- * Remove listeners registered in the event target.
1563
- * @param - Name of the event to be removed
1564
- * @param - listener function of the event to be removed
1565
- * @example
1566
- * import EventEmitter from "@scena/event-emitter";
1567
- * cosnt emitter = new EventEmitter();
1568
- *
1569
- * // Remove all listeners.
1570
- * emitter.off();
1571
- *
1572
- * // Remove all listeners in "A" event.
1573
- * emitter.off("a");
1574
- *
1575
- *
1576
- * // Remove "listener" listener in "a" event.
1577
- * emitter.off("a", listener);
1578
- */
1579
-
1580
-
1581
- __proto.off = function (eventName, listener) {
1582
- if (!eventName) {
1583
- this._events = {};
1584
- } else if (isObject(eventName)) {
1585
- for (var name in eventName) {
1586
- this.off(name);
1587
- }
1588
- } else if (!listener) {
1589
- this._events[eventName] = [];
1590
- } else {
1591
- var events = this._events[eventName];
1592
-
1593
- if (events) {
1594
- var index = findIndex(events, function (e) {
1595
- return e.listener === listener;
1596
- });
1597
-
1598
- if (index > -1) {
1599
- events.splice(index, 1);
1600
- }
1601
- }
1602
- }
1603
-
1604
- return this;
1605
- };
1606
- /**
1607
- * Add a disposable listener and Use promise to the registered event.
1608
- * @param - Name of the event to be added
1609
- * @param - disposable listener function of the event to be added
1610
- * @example
1611
- * import EventEmitter from "@scena/event-emitter";
1612
- * cosnt emitter = new EventEmitter();
1613
- *
1614
- * // Add a disposable listener in "a" event
1615
- * emitter.once("a", () => {
1616
- * });
1617
- *
1618
- * // Use Promise
1619
- * emitter.once("a").then(e => {
1620
- * });
1621
- */
1622
-
1623
-
1624
- __proto.once = function (eventName, listener) {
1625
- var _this = this;
1626
-
1627
- if (listener) {
1628
- this._addEvent(eventName, listener, {
1629
- once: true
1630
- });
1631
- }
1632
-
1633
- return new Promise(function (resolve) {
1634
- _this._addEvent(eventName, resolve, {
1635
- once: true
1636
- });
1637
- });
1638
- };
1639
- /**
1640
- * Fires an event to call listeners.
1641
- * @param - Event name
1642
- * @param - Event parameter
1643
- * @return If false, stop the event.
1644
- * @example
1645
- *
1646
- * import EventEmitter from "@scena/event-emitter";
1647
- *
1648
- *
1649
- * const emitter = new EventEmitter();
1650
- *
1651
- * emitter.on("a", e => {
1652
- * });
1653
- *
1654
- *
1655
- * emitter.emit("a", {
1656
- * a: 1,
1657
- * });
1658
- */
1659
-
1660
-
1661
- __proto.emit = function (eventName, param) {
1662
- var _this = this;
1663
-
1664
- if (param === void 0) {
1665
- param = {};
1666
- }
1667
-
1668
- var events = this._events[eventName];
1669
-
1670
- if (!eventName || !events) {
1671
- return true;
1672
- }
1673
-
1674
- var isStop = false;
1675
- param.eventType = eventName;
1676
-
1677
- param.stop = function () {
1678
- isStop = true;
1679
- };
1680
-
1681
- param.currentTarget = this;
1682
-
1683
- __spreadArrays(events).forEach(function (info) {
1684
- info.listener(param);
1685
-
1686
- if (info.once) {
1687
- _this.off(eventName, info.listener);
1688
- }
1689
- });
1690
-
1691
- return !isStop;
1692
- };
1693
- /**
1694
- * Fires an event to call listeners.
1695
- * @param - Event name
1696
- * @param - Event parameter
1697
- * @return If false, stop the event.
1698
- * @example
1699
- *
1700
- * import EventEmitter from "@scena/event-emitter";
1701
- *
1702
- *
1703
- * const emitter = new EventEmitter();
1704
- *
1705
- * emitter.on("a", e => {
1706
- * });
1707
- *
1708
- *
1709
- * emitter.emit("a", {
1710
- * a: 1,
1711
- * });
1712
- */
1713
-
1714
- /**
1715
- * Fires an event to call listeners.
1716
- * @param - Event name
1717
- * @param - Event parameter
1718
- * @return If false, stop the event.
1719
- * @example
1720
- *
1721
- * import EventEmitter from "@scena/event-emitter";
1722
- *
1723
- *
1724
- * const emitter = new EventEmitter();
1725
- *
1726
- * emitter.on("a", e => {
1727
- * });
1728
- *
1729
- * // emit
1730
- * emitter.trigger("a", {
1731
- * a: 1,
1732
- * });
1733
- */
1734
-
1735
-
1736
- __proto.trigger = function (eventName, param) {
1737
- if (param === void 0) {
1738
- param = {};
1739
- }
1740
-
1741
- return this.emit(eventName, param);
1742
- };
1743
-
1744
- __proto._addEvent = function (eventName, listener, options) {
1745
- var events = this._events;
1746
- events[eventName] = events[eventName] || [];
1747
- var listeners = events[eventName];
1748
- listeners.push(__assign$1({
1749
- listener: listener
1750
- }, options));
1751
- };
1752
-
1753
- return EventEmitter;
1754
- }();
1755
-
1756
- var EventEmitter$1 = EventEmitter;
1757
-
1758
- /*
1759
- Copyright (c) 2019 Daybrush
1760
- name: gesto
1761
- license: MIT
1762
- author: Daybrush
1763
- repository: git+https://github.com/daybrush/gesture.git
1764
- version: 1.5.0
1765
- */
1766
-
1767
- /*! *****************************************************************************
1768
- Copyright (c) Microsoft Corporation. All rights reserved.
1769
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
1770
- this file except in compliance with the License. You may obtain a copy of the
1771
- License at http://www.apache.org/licenses/LICENSE-2.0
1772
-
1773
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1774
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
1775
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
1776
- MERCHANTABLITY OR NON-INFRINGEMENT.
1777
-
1778
- See the Apache Version 2.0 License for specific language governing permissions
1779
- and limitations under the License.
1780
- ***************************************************************************** */
1781
-
1782
- /* global Reflect, Promise */
1783
- var extendStatics = function (d, b) {
1784
- extendStatics = Object.setPrototypeOf || {
1785
- __proto__: []
1786
- } instanceof Array && function (d, b) {
1787
- d.__proto__ = b;
1788
- } || function (d, b) {
1789
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
1790
- };
1791
-
1792
- return extendStatics(d, b);
1793
- };
1794
-
1795
- function __extends(d, b) {
1796
- extendStatics(d, b);
1797
-
1798
- function __() {
1799
- this.constructor = d;
1800
- }
1801
-
1802
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1803
- }
1804
- var __assign = function () {
1805
- __assign = Object.assign || function __assign(t) {
1806
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1807
- s = arguments[i];
1808
-
1809
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1810
- }
1811
-
1812
- return t;
1813
- };
1814
-
1815
- return __assign.apply(this, arguments);
1816
- };
1817
-
1818
- function getRad(pos1, pos2) {
1819
- var distX = pos2[0] - pos1[0];
1820
- var distY = pos2[1] - pos1[1];
1821
- var rad = Math.atan2(distY, distX);
1822
- return rad >= 0 ? rad : rad + Math.PI * 2;
1823
- }
1824
- function getRotatiion(touches) {
1825
- return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180;
1826
- }
1827
- function isMultiTouch(e) {
1828
- return e.touches && e.touches.length >= 2;
1829
- }
1830
- function getEventClients(e) {
1831
- if (e.touches) {
1832
- return getClients(e.touches);
1833
- } else {
1834
- return [getClient(e)];
1835
- }
1836
- }
1837
- function getPosition(clients, prevClients, startClients) {
1838
- var length = startClients.length;
1839
-
1840
- var _a = getAverageClient(clients, length),
1841
- clientX = _a.clientX,
1842
- clientY = _a.clientY,
1843
- originalClientX = _a.originalClientX,
1844
- originalClientY = _a.originalClientY;
1845
-
1846
- var _b = getAverageClient(prevClients, length),
1847
- prevX = _b.clientX,
1848
- prevY = _b.clientY;
1849
-
1850
- var _c = getAverageClient(startClients, length),
1851
- startX = _c.clientX,
1852
- startY = _c.clientY;
1853
-
1854
- var deltaX = clientX - prevX;
1855
- var deltaY = clientY - prevY;
1856
- var distX = clientX - startX;
1857
- var distY = clientY - startY;
1858
- return {
1859
- clientX: originalClientX,
1860
- clientY: originalClientY,
1861
- deltaX: deltaX,
1862
- deltaY: deltaY,
1863
- distX: distX,
1864
- distY: distY
1865
- };
1866
- }
1867
- function getDist(clients) {
1868
- return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2));
1869
- }
1870
- function getClients(touches) {
1871
- var length = Math.min(touches.length, 2);
1872
- var clients = [];
1873
-
1874
- for (var i = 0; i < length; ++i) {
1875
- clients.push(getClient(touches[i]));
1876
- }
1877
-
1878
- return clients;
1879
- }
1880
- function getClient(e) {
1881
- return {
1882
- clientX: e.clientX,
1883
- clientY: e.clientY
1884
- };
1885
- }
1886
- function getAverageClient(clients, length) {
1887
- if (length === void 0) {
1888
- length = clients.length;
1889
- }
1890
-
1891
- var sumClient = {
1892
- clientX: 0,
1893
- clientY: 0,
1894
- originalClientX: 0,
1895
- originalClientY: 0
1896
- };
1897
-
1898
- for (var i = 0; i < length; ++i) {
1899
- var client = clients[i];
1900
- sumClient.originalClientX += "originalClientX" in client ? client.originalClientX : client.clientX;
1901
- sumClient.originalClientY += "originalClientY" in client ? client.originalClientY : client.clientY;
1902
- sumClient.clientX += client.clientX;
1903
- sumClient.clientY += client.clientY;
1904
- }
1905
-
1906
- if (!length) {
1907
- return sumClient;
1908
- }
1909
-
1910
- return {
1911
- clientX: sumClient.clientX / length,
1912
- clientY: sumClient.clientY / length,
1913
- originalClientX: sumClient.originalClientX / length,
1914
- originalClientY: sumClient.originalClientY / length
1915
- };
1916
- }
1917
-
1918
- var ClientStore =
1919
- /*#__PURE__*/
1920
- function () {
1921
- function ClientStore(clients) {
1922
- this.prevClients = [];
1923
- this.startClients = [];
1924
- this.movement = 0;
1925
- this.length = 0;
1926
- this.startClients = clients;
1927
- this.prevClients = clients;
1928
- this.length = clients.length;
1929
- }
1930
-
1931
- var __proto = ClientStore.prototype;
1932
-
1933
- __proto.addClients = function (clients) {
1934
- if (clients === void 0) {
1935
- clients = this.prevClients;
1936
- }
1937
-
1938
- var position = this.getPosition(clients);
1939
- var deltaX = position.deltaX,
1940
- deltaY = position.deltaY;
1941
- this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
1942
- this.prevClients = clients;
1943
- return position;
1944
- };
1945
-
1946
- __proto.getAngle = function (clients) {
1947
- if (clients === void 0) {
1948
- clients = this.prevClients;
1949
- }
1950
-
1951
- return getRotatiion(clients);
1952
- };
1953
-
1954
- __proto.getRotation = function (clients) {
1955
- if (clients === void 0) {
1956
- clients = this.prevClients;
1957
- }
1958
-
1959
- return getRotatiion(clients) - getRotatiion(this.startClients);
1960
- };
1961
-
1962
- __proto.getPosition = function (clients) {
1963
- return getPosition(clients || this.prevClients, this.prevClients, this.startClients);
1964
- };
1965
-
1966
- __proto.getPositions = function (clients) {
1967
- if (clients === void 0) {
1968
- clients = this.prevClients;
1969
- }
1970
-
1971
- var prevClients = this.prevClients;
1972
- return this.startClients.map(function (startClient, i) {
1973
- return getPosition([clients[i]], [prevClients[i]], [startClient]);
1974
- });
1975
- };
1976
-
1977
- __proto.getMovement = function (clients) {
1978
- var movement = this.movement;
1979
-
1980
- if (!clients) {
1981
- return movement;
1982
- }
1983
-
1984
- var currentClient = getAverageClient(clients, this.length);
1985
- var prevClient = getAverageClient(this.prevClients, this.length);
1986
- var deltaX = currentClient.clientX - prevClient.clientX;
1987
- var deltaY = currentClient.clientY - prevClient.clientY;
1988
- return Math.sqrt(deltaX * deltaX + deltaY * deltaY) + movement;
1989
- };
1990
-
1991
- __proto.getDistance = function (clients) {
1992
- if (clients === void 0) {
1993
- clients = this.prevClients;
1994
- }
1995
-
1996
- return getDist(clients);
1997
- };
1998
-
1999
- __proto.getScale = function (clients) {
2000
- if (clients === void 0) {
2001
- clients = this.prevClients;
2002
- }
2003
-
2004
- return getDist(clients) / getDist(this.startClients);
2005
- };
2006
-
2007
- __proto.move = function (deltaX, deltaY) {
2008
- this.startClients.forEach(function (client) {
2009
- client.clientX -= deltaX;
2010
- client.clientY -= deltaY;
2011
- });
2012
- this.prevClients.forEach(function (client) {
2013
- client.clientX -= deltaX;
2014
- client.clientY -= deltaY;
2015
- });
2016
- };
2017
-
2018
- return ClientStore;
2019
- }();
2020
-
2021
- var INPUT_TAGNAMES = ["textarea", "input"];
2022
- /**
2023
- * You can set up drag, pinch events in any browser.
2024
- */
2025
-
2026
- var Gesto =
2027
- /*#__PURE__*/
2028
- function (_super) {
2029
- __extends(Gesto, _super);
2030
- /**
2031
- *
2032
- */
2033
-
2034
-
2035
- function Gesto(targets, options) {
2036
- if (options === void 0) {
2037
- options = {};
2038
- }
2039
-
2040
- var _this = _super.call(this) || this;
2041
-
2042
- _this.options = {};
2043
- _this.flag = false;
2044
- _this.pinchFlag = false;
2045
- _this.datas = {};
2046
- _this.isDrag = false;
2047
- _this.isPinch = false;
2048
- _this.isMouse = false;
2049
- _this.isTouch = false;
2050
- _this.clientStores = [];
2051
- _this.targets = [];
2052
- _this.prevTime = 0;
2053
- _this.doubleFlag = false;
2054
-
2055
- _this.onDragStart = function (e, isTrusted) {
2056
- if (isTrusted === void 0) {
2057
- isTrusted = true;
2058
- }
2059
-
2060
- if (!_this.flag && e.cancelable === false) {
2061
- return;
2062
- }
2063
-
2064
- var _a = _this.options,
2065
- container = _a.container,
2066
- pinchOutside = _a.pinchOutside,
2067
- preventRightClick = _a.preventRightClick,
2068
- preventDefault = _a.preventDefault,
2069
- checkInput = _a.checkInput;
2070
- var isTouch = _this.isTouch;
2071
- var isDragStart = !_this.flag;
2072
-
2073
- if (isDragStart) {
2074
- var activeElement = document.activeElement;
2075
- var target = e.target;
2076
- var tagName = target.tagName.toLowerCase();
2077
- var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1;
2078
- var hasContentEditable = target.isContentEditable;
2079
-
2080
- if (hasInput || hasContentEditable) {
2081
- if (checkInput || activeElement === target) {
2082
- // force false or already focused.
2083
- return false;
2084
- }
2085
-
2086
- if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
2087
- return false;
2088
- }
2089
- } else if ((preventDefault || e.type === "touchstart") && activeElement) {
2090
- var activeTagName = activeElement.tagName;
2091
-
2092
- if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) {
2093
- activeElement.blur();
2094
- }
2095
- }
2096
-
2097
- _this.clientStores = [new ClientStore(getEventClients(e))];
2098
- _this.flag = true;
2099
- _this.isDrag = false;
2100
- _this.datas = {};
2101
-
2102
- if (preventRightClick && (e.which === 3 || e.button === 2)) {
2103
- _this.initDrag();
2104
-
2105
- return false;
2106
- }
2107
-
2108
- _this.doubleFlag = now() - _this.prevTime < 200;
2109
-
2110
- var result = _this.emit("dragStart", __assign({
2111
- datas: _this.datas,
2112
- inputEvent: e,
2113
- isTrusted: isTrusted,
2114
- isDouble: _this.doubleFlag
2115
- }, _this.getCurrentStore().getPosition()));
2116
-
2117
- if (result === false) {
2118
- _this.initDrag();
2119
- }
2120
-
2121
- _this.flag && preventDefault && e.preventDefault();
2122
- }
2123
-
2124
- if (!_this.flag) {
2125
- return false;
2126
- }
2127
-
2128
- var timer = 0;
2129
-
2130
- if (isDragStart && isTouch && pinchOutside) {
2131
- timer = setTimeout(function () {
2132
- addEvent(container, "touchstart", _this.onDragStart, {
2133
- passive: false
2134
- });
2135
- });
2136
- }
2137
-
2138
- if (!isDragStart && isTouch && pinchOutside) {
2139
- removeEvent(container, "touchstart", _this.onDragStart);
2140
- }
2141
-
2142
- if (_this.flag && isMultiTouch(e)) {
2143
- clearTimeout(timer);
2144
-
2145
- if (isDragStart && e.touches.length !== e.changedTouches.length) {
2146
- return;
2147
- }
2148
-
2149
- if (!_this.pinchFlag) {
2150
- _this.onPinchStart(e);
2151
- }
2152
- }
2153
- };
2154
-
2155
- _this.onDrag = function (e, isScroll) {
2156
- if (!_this.flag) {
2157
- return;
2158
- }
2159
-
2160
- var clients = getEventClients(e);
2161
-
2162
- var result = _this.moveClients(clients, e, false);
2163
-
2164
- if (_this.pinchFlag || result.deltaX || result.deltaY) {
2165
- var dragResult = _this.emit("drag", __assign({}, result, {
2166
- isScroll: !!isScroll,
2167
- inputEvent: e
2168
- }));
2169
-
2170
- if (dragResult === false) {
2171
- _this.stop();
2172
-
2173
- return;
2174
- }
2175
- }
2176
-
2177
- if (_this.pinchFlag) {
2178
- _this.onPinch(e, clients);
2179
- }
2180
-
2181
- _this.getCurrentStore().addClients(clients);
2182
- };
2183
-
2184
- _this.onDragEnd = function (e) {
2185
- if (!_this.flag) {
2186
- return;
2187
- }
2188
-
2189
- var _a = _this.options,
2190
- pinchOutside = _a.pinchOutside,
2191
- container = _a.container;
2192
-
2193
- if (_this.isTouch && pinchOutside) {
2194
- removeEvent(container, "touchstart", _this.onDragStart);
2195
- }
2196
-
2197
- _this.flag = false;
2198
-
2199
- var position = _this.getCurrentStore().getPosition();
2200
-
2201
- var currentTime = now();
2202
- var isDouble = !_this.isDrag && _this.doubleFlag;
2203
- _this.prevTime = _this.isDrag || isDouble ? 0 : currentTime;
2204
-
2205
- _this.emit("dragEnd", __assign({
2206
- datas: _this.datas,
2207
- isDouble: isDouble,
2208
- isDrag: _this.isDrag,
2209
- isClick: !_this.isDrag,
2210
- inputEvent: e
2211
- }, position));
2212
-
2213
- if (_this.pinchFlag) {
2214
- _this.onPinchEnd(e);
2215
- }
2216
-
2217
- _this.clientStores = [];
2218
- };
2219
-
2220
- _this.onBlur = function () {
2221
- _this.onDragEnd();
2222
- };
2223
-
2224
- var elements = [].concat(targets);
2225
- _this.options = __assign({
2226
- checkInput: false,
2227
- container: elements.length > 1 ? window : elements[0],
2228
- preventRightClick: true,
2229
- preventDefault: true,
2230
- checkWindowBlur: false,
2231
- pinchThreshold: 0,
2232
- events: ["touch", "mouse"]
2233
- }, options);
2234
- var _a = _this.options,
2235
- container = _a.container,
2236
- events = _a.events,
2237
- checkWindowBlur = _a.checkWindowBlur;
2238
- _this.isTouch = events.indexOf("touch") > -1;
2239
- _this.isMouse = events.indexOf("mouse") > -1;
2240
- _this.targets = elements;
2241
-
2242
- if (_this.isMouse) {
2243
- elements.forEach(function (el) {
2244
- addEvent(el, "mousedown", _this.onDragStart);
2245
- });
2246
- addEvent(container, "mousemove", _this.onDrag);
2247
- addEvent(container, "mouseup", _this.onDragEnd);
2248
- addEvent(container, "contextmenu", _this.onDragEnd);
2249
- }
2250
-
2251
- if (checkWindowBlur) {
2252
- addEvent(window, "blur", _this.onBlur);
2253
- }
2254
-
2255
- if (_this.isTouch) {
2256
- var passive_1 = {
2257
- passive: false
2258
- };
2259
- elements.forEach(function (el) {
2260
- addEvent(el, "touchstart", _this.onDragStart, passive_1);
2261
- });
2262
- addEvent(container, "touchmove", _this.onDrag, passive_1);
2263
- addEvent(container, "touchend", _this.onDragEnd, passive_1);
2264
- addEvent(container, "touchcancel", _this.onDragEnd, passive_1);
2265
- }
2266
-
2267
- return _this;
2268
- }
2269
- /**
2270
- * Stop Gesto's drag events.
2271
- */
2272
-
2273
-
2274
- var __proto = Gesto.prototype;
2275
-
2276
- __proto.stop = function () {
2277
- this.isDrag = false;
2278
- this.flag = false;
2279
- this.clientStores = [];
2280
- this.datas = {};
2281
- };
2282
- /**
2283
- * The total moved distance
2284
- */
2285
-
2286
-
2287
- __proto.getMovement = function (clients) {
2288
- return this.getCurrentStore().getMovement(clients) + this.clientStores.slice(1).reduce(function (prev, cur) {
2289
- return prev + cur.movement;
2290
- }, 0);
2291
- };
2292
- /**
2293
- * Whether to drag
2294
- */
2295
-
2296
-
2297
- __proto.isDragging = function () {
2298
- return this.isDrag;
2299
- };
2300
- /**
2301
- * Whether to start drag
2302
- */
2303
-
2304
-
2305
- __proto.isFlag = function () {
2306
- return this.flag;
2307
- };
2308
- /**
2309
- * Whether to start pinch
2310
- */
2311
-
2312
-
2313
- __proto.isPinchFlag = function () {
2314
- return this.pinchFlag;
2315
- };
2316
- /**
2317
- * Whether to start double click
2318
- */
2319
-
2320
-
2321
- __proto.isDoubleFlag = function () {
2322
- return this.doubleFlag;
2323
- };
2324
- /**
2325
- * Whether to pinch
2326
- */
2327
-
2328
-
2329
- __proto.isPinching = function () {
2330
- return this.isPinch;
2331
- };
2332
- /**
2333
- * If a scroll event occurs, it is corrected by the scroll distance.
2334
- */
2335
-
2336
-
2337
- __proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) {
2338
- if (isCallDrag === void 0) {
2339
- isCallDrag = true;
2340
- }
2341
-
2342
- if (!this.flag) {
2343
- return;
2344
- }
2345
-
2346
- this.clientStores[0].move(deltaX, deltaY);
2347
- isCallDrag && this.onDrag(e, true);
2348
- };
2349
- /**
2350
- * Create a virtual drag event.
2351
- */
2352
-
2353
-
2354
- __proto.move = function (_a, inputEvent) {
2355
- var deltaX = _a[0],
2356
- deltaY = _a[1];
2357
- var store = this.getCurrentStore();
2358
- var nextClients = store.prevClients;
2359
- return this.moveClients(nextClients.map(function (_a) {
2360
- var clientX = _a.clientX,
2361
- clientY = _a.clientY;
2362
- return {
2363
- clientX: clientX + deltaX,
2364
- clientY: clientY + deltaY,
2365
- originalClientX: clientX,
2366
- originalClientY: clientY
2367
- };
2368
- }), inputEvent, true);
2369
- };
2370
- /**
2371
- * The dragStart event is triggered by an external event.
2372
- */
2373
-
2374
-
2375
- __proto.triggerDragStart = function (e) {
2376
- this.onDragStart(e, false);
2377
- };
2378
- /**
2379
- * Set the event data while dragging.
2380
- */
2381
-
2382
-
2383
- __proto.setEventDatas = function (datas) {
2384
- var currentDatas = this.datas;
2385
-
2386
- for (var name in datas) {
2387
- currentDatas[name] = datas[name];
2388
- }
2389
-
2390
- return this;
2391
- };
2392
- /**
2393
- * Set the event data while dragging.
2394
- */
2395
-
2396
-
2397
- __proto.getEventDatas = function () {
2398
- return this.datas;
2399
- };
2400
- /**
2401
- * Unset Gesto
2402
- */
2403
-
2404
-
2405
- __proto.unset = function () {
2406
- var _this = this;
2407
-
2408
- var targets = this.targets;
2409
- var container = this.options.container;
2410
- this.off();
2411
- removeEvent(window, "blur", this.onBlur);
2412
-
2413
- if (this.isMouse) {
2414
- targets.forEach(function (target) {
2415
- removeEvent(target, "mousedown", _this.onDragStart);
2416
- });
2417
- removeEvent(container, "mousemove", this.onDrag);
2418
- removeEvent(container, "mouseup", this.onDragEnd);
2419
- removeEvent(container, "contextmenu", this.onDragEnd);
2420
- }
2421
-
2422
- if (this.isTouch) {
2423
- targets.forEach(function (target) {
2424
- removeEvent(target, "touchstart", _this.onDragStart);
2425
- });
2426
- removeEvent(container, "touchstart", this.onDragStart);
2427
- removeEvent(container, "touchmove", this.onDrag);
2428
- removeEvent(container, "touchend", this.onDragEnd);
2429
- removeEvent(container, "touchcancel", this.onDragEnd);
2430
- }
2431
- };
2432
-
2433
- __proto.onPinchStart = function (e) {
2434
- var pinchThreshold = this.options.pinchThreshold;
2435
-
2436
- if (this.isDrag && this.getMovement() > pinchThreshold) {
2437
- return;
2438
- }
2439
-
2440
- var store = new ClientStore(getEventClients(e));
2441
- this.pinchFlag = true;
2442
- this.clientStores.splice(0, 0, store);
2443
- var result = this.emit("pinchStart", __assign({
2444
- datas: this.datas,
2445
- angle: store.getAngle(),
2446
- touches: this.getCurrentStore().getPositions()
2447
- }, store.getPosition(), {
2448
- inputEvent: e
2449
- }));
2450
-
2451
- if (result === false) {
2452
- this.pinchFlag = false;
2453
- }
2454
- };
2455
-
2456
- __proto.onPinch = function (e, clients) {
2457
- if (!this.flag || !this.pinchFlag || clients.length < 2) {
2458
- return;
2459
- }
2460
-
2461
- var store = this.getCurrentStore();
2462
- this.isPinch = true;
2463
- this.emit("pinch", __assign({
2464
- datas: this.datas,
2465
- movement: this.getMovement(clients),
2466
- angle: store.getAngle(clients),
2467
- rotation: store.getRotation(clients),
2468
- touches: store.getPositions(clients),
2469
- scale: store.getScale(clients),
2470
- distance: store.getDistance(clients)
2471
- }, store.getPosition(clients), {
2472
- inputEvent: e
2473
- }));
2474
- };
2475
-
2476
- __proto.onPinchEnd = function (e) {
2477
- if (!this.pinchFlag) {
2478
- return;
2479
- }
2480
-
2481
- var isPinch = this.isPinch;
2482
- this.isPinch = false;
2483
- this.pinchFlag = false;
2484
- var store = this.getCurrentStore();
2485
- this.emit("pinchEnd", __assign({
2486
- datas: this.datas,
2487
- isPinch: isPinch,
2488
- touches: store.getPositions()
2489
- }, store.getPosition(), {
2490
- inputEvent: e
2491
- }));
2492
- this.isPinch = false;
2493
- this.pinchFlag = false;
2494
- };
2495
-
2496
- __proto.initDrag = function () {
2497
- this.clientStores = [];
2498
- this.pinchFlag = false;
2499
- this.doubleFlag = false;
2500
- this.prevTime = 0;
2501
- this.flag = false;
2502
- };
2503
-
2504
- __proto.getCurrentStore = function () {
2505
- return this.clientStores[0];
2506
- };
2507
-
2508
- __proto.moveClients = function (clients, inputEvent, isAdd) {
2509
- var store = this.getCurrentStore();
2510
- var position = store[isAdd ? "addClients" : "getPosition"](clients);
2511
- this.isDrag = true;
2512
- return __assign({
2513
- datas: this.datas
2514
- }, position, {
2515
- movement: this.getMovement(clients),
2516
- isDrag: this.isDrag,
2517
- isPinch: this.isPinch,
2518
- isScroll: false,
2519
- inputEvent: inputEvent
2520
- });
2521
- };
2522
-
2523
- return Gesto;
2524
- }(EventEmitter$1);
2525
-
2526
- var Gesto$1 = Gesto;
2527
-
2528
- const _sfc_main$f = vue.defineComponent({
2529
- name: "m-editor-resize",
2530
- props: {
2531
- type: {
2532
- type: String
2533
- }
2534
- },
2535
- setup(props) {
2536
- const services = vue.inject("services");
2537
- const target = vue.ref();
2538
- let getso;
2539
- vue.onMounted(() => {
2540
- if (!target.value)
2541
- return;
2542
- getso = new Gesto$1(target.value, {
2543
- container: window,
2544
- pinchOutside: true
2545
- }).on("drag", (e) => {
2546
- if (!target.value || !services)
2547
- return;
2548
- let { left, right } = {
2549
- ...vue.toRaw(services.uiService.get("columnWidth"))
2550
- };
2551
- if (props.type === "left") {
2552
- left += e.deltaX;
2553
- } else if (props.type === "right") {
2554
- right -= e.deltaX;
2555
- }
2556
- services.uiService.set("columnWidth", {
2557
- left,
2558
- right
2559
- });
2560
- });
2561
- });
2562
- vue.onUnmounted(() => {
2563
- getso?.unset();
2564
- });
2565
- return {
2566
- target
2567
- };
2568
- }
2569
- });
2570
- const _hoisted_1$a = {
1666
+ const _hoisted_1$9 = {
2571
1667
  ref: "target",
2572
1668
  class: "m-editor-resizer"
2573
1669
  };
2574
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2575
- return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
1670
+ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1671
+ return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$9, [
2576
1672
  vue.renderSlot(_ctx.$slots, "default")
2577
1673
  ], 512);
2578
1674
  }
2579
- var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
1675
+ var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
2580
1676
 
2581
- const _sfc_main$e = vue.defineComponent({
1677
+ const _sfc_main$g = vue.defineComponent({
2582
1678
  components: {
2583
1679
  AddPageBox,
2584
1680
  Resizer
2585
1681
  },
1682
+ props: {
1683
+ codeOptions: {
1684
+ type: Object,
1685
+ default: () => ({})
1686
+ }
1687
+ },
2586
1688
  setup() {
2587
- const services = vue.inject("services");
2588
- const root = vue.computed(() => services?.editorService.get("root"));
1689
+ const { editorService, uiService } = vue.inject("services") || {};
1690
+ const root = vue.computed(() => editorService?.get("root"));
2589
1691
  return {
2590
1692
  root,
2591
- pageLength: vue.computed(() => root.value?.items?.length || 0),
2592
- showSrc: vue.computed(() => services?.uiService.get("showSrc")),
2593
- columnWidth: vue.computed(() => services?.uiService.get("columnWidth")),
1693
+ pageLength: vue.computed(() => editorService?.get("pageLength") || 0),
1694
+ showSrc: vue.computed(() => uiService?.get("showSrc")),
1695
+ columnWidth: vue.computed(() => uiService?.get("columnWidth")),
2594
1696
  saveCode(value) {
2595
1697
  try {
2596
- services?.editorService.set("root", eval(value));
1698
+ editorService?.set("root", eval(value));
2597
1699
  } catch (e) {
2598
1700
  console.error(e);
2599
1701
  }
@@ -2601,24 +1703,25 @@
2601
1703
  };
2602
1704
  }
2603
1705
  });
2604
- const _hoisted_1$9 = { class: "m-editor" };
2605
- const _hoisted_2$5 = {
1706
+ const _hoisted_1$8 = { class: "m-editor" };
1707
+ const _hoisted_2$3 = {
2606
1708
  key: 1,
2607
1709
  class: "m-editor-content"
2608
1710
  };
2609
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
1711
+ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2610
1712
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
2611
1713
  const _component_resizer = vue.resolveComponent("resizer");
2612
1714
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
2613
1715
  const _component_add_page_box = vue.resolveComponent("add-page-box");
2614
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
1716
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2615
1717
  vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2616
1718
  _ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
2617
1719
  key: 0,
2618
1720
  class: "m-editor-content",
2619
1721
  "init-values": _ctx.root,
1722
+ options: _ctx.codeOptions,
2620
1723
  onSave: _ctx.saveCode
2621
- }, null, 8, ["init-values", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$5, [
1724
+ }, null, 8, ["init-values", "options", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
2622
1725
  vue.createElementVNode("div", {
2623
1726
  class: "m-editor-framework-left",
2624
1727
  style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
@@ -2651,9 +1754,9 @@
2651
1754
  ]))
2652
1755
  ]);
2653
1756
  }
2654
- var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
1757
+ var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
2655
1758
 
2656
- const _sfc_main$d = vue.defineComponent({
1759
+ const _sfc_main$f = vue.defineComponent({
2657
1760
  name: "m-icon",
2658
1761
  components: { Edit: icons.Edit },
2659
1762
  props: {
@@ -2667,8 +1770,8 @@
2667
1770
  };
2668
1771
  }
2669
1772
  });
2670
- const _hoisted_1$8 = ["src"];
2671
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1773
+ const _hoisted_1$7 = ["src"];
1774
+ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2672
1775
  const _component_edit = vue.resolveComponent("edit");
2673
1776
  const _component_el_icon = vue.resolveComponent("el-icon");
2674
1777
  return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
@@ -2679,7 +1782,7 @@
2679
1782
  })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
2680
1783
  key: 1,
2681
1784
  src: _ctx.icon
2682
- }, null, 8, _hoisted_1$8)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
1785
+ }, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2683
1786
  key: 2,
2684
1787
  class: vue.normalizeClass(_ctx.icon)
2685
1788
  }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
@@ -2689,9 +1792,9 @@
2689
1792
  _: 1
2690
1793
  }));
2691
1794
  }
2692
- var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
1795
+ var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
2693
1796
 
2694
- const _sfc_main$c = vue.defineComponent({
1797
+ const _sfc_main$e = vue.defineComponent({
2695
1798
  components: { MIcon, ArrowDown: icons.ArrowDown },
2696
1799
  props: {
2697
1800
  data: {
@@ -2701,16 +1804,20 @@
2701
1804
  type: "text",
2702
1805
  display: false
2703
1806
  })
1807
+ },
1808
+ eventType: {
1809
+ type: String,
1810
+ default: "click"
2704
1811
  }
2705
1812
  },
2706
1813
  setup(props) {
2707
1814
  const services = vue.inject("services");
2708
1815
  const uiService = services?.uiService;
2709
- const zoomInHandler = () => uiService?.set("zoom", zoom.value + 0.1);
2710
- const zoomOutHandler = () => uiService?.set("zoom", zoom.value - 0.1);
2711
1816
  const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
2712
1817
  const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
2713
1818
  const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
1819
+ const zoomInHandler = () => uiService?.zoom(0.1);
1820
+ const zoomOutHandler = () => uiService?.zoom(-0.1);
2714
1821
  const item = vue.computed(() => {
2715
1822
  if (typeof props.data !== "string") {
2716
1823
  return props.data;
@@ -2727,15 +1834,15 @@
2727
1834
  case "delete":
2728
1835
  return {
2729
1836
  type: "button",
2730
- icon: icons.Delete,
1837
+ icon: vue.markRaw(icons.Delete),
2731
1838
  tooltip: "\u522A\u9664",
2732
- disabled: () => services?.editorService.get("node")?.type === "page",
1839
+ disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
2733
1840
  handler: () => services?.editorService.remove(services?.editorService.get("node"))
2734
1841
  };
2735
1842
  case "undo":
2736
1843
  return {
2737
1844
  type: "button",
2738
- icon: icons.Back,
1845
+ icon: vue.markRaw(icons.Back),
2739
1846
  tooltip: "\u540E\u9000",
2740
1847
  disabled: () => !services?.historyService.state.canUndo,
2741
1848
  handler: () => services?.editorService.undo()
@@ -2743,7 +1850,7 @@
2743
1850
  case "redo":
2744
1851
  return {
2745
1852
  type: "button",
2746
- icon: icons.Right,
1853
+ icon: vue.markRaw(icons.Right),
2747
1854
  tooltip: "\u524D\u8FDB",
2748
1855
  disabled: () => !services?.historyService.state.canRedo,
2749
1856
  handler: () => services?.editorService.redo()
@@ -2751,28 +1858,28 @@
2751
1858
  case "zoom-in":
2752
1859
  return {
2753
1860
  type: "button",
2754
- icon: icons.ZoomIn,
1861
+ icon: vue.markRaw(icons.ZoomIn),
2755
1862
  tooltip: "\u653E\u5927",
2756
1863
  handler: zoomInHandler
2757
1864
  };
2758
1865
  case "zoom-out":
2759
1866
  return {
2760
1867
  type: "button",
2761
- icon: icons.ZoomOut,
1868
+ icon: vue.markRaw(icons.ZoomOut),
2762
1869
  tooltip: "\u7E2E\u5C0F",
2763
1870
  handler: zoomOutHandler
2764
1871
  };
2765
1872
  case "rule":
2766
1873
  return {
2767
1874
  type: "button",
2768
- icon: icons.ScaleToOriginal,
1875
+ icon: vue.markRaw(icons.ScaleToOriginal),
2769
1876
  tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2770
1877
  handler: () => uiService?.set("showRule", !showRule.value)
2771
1878
  };
2772
1879
  case "guides":
2773
1880
  return {
2774
1881
  type: "button",
2775
- icon: icons.Grid,
1882
+ icon: vue.markRaw(icons.Grid),
2776
1883
  tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2777
1884
  handler: () => uiService?.set("showGuides", !showGuides.value)
2778
1885
  };
@@ -2793,9 +1900,16 @@
2793
1900
  }
2794
1901
  return item.value.disabled;
2795
1902
  });
1903
+ const buttonHandler = (item2, event) => {
1904
+ if (disabled.value)
1905
+ return;
1906
+ if (typeof item2.handler === "function" && services) {
1907
+ item2.handler?.(services, event);
1908
+ }
1909
+ };
2796
1910
  return {
2797
- ZoomIn: icons.ZoomIn,
2798
- ZoomOut: icons.ZoomOut,
1911
+ ZoomIn: vue.markRaw(icons.ZoomIn),
1912
+ ZoomOut: vue.markRaw(icons.ZoomOut),
2799
1913
  item,
2800
1914
  zoom,
2801
1915
  disabled,
@@ -2816,31 +1930,42 @@
2816
1930
  command.item.handler(services);
2817
1931
  }
2818
1932
  },
2819
- buttonHandler(item2) {
2820
- if (disabled.value)
1933
+ clickHandler(item2, event) {
1934
+ if (props.eventType !== "click")
1935
+ return;
1936
+ if (item2.type === "button") {
1937
+ buttonHandler(item2, event);
1938
+ }
1939
+ },
1940
+ mousedownHandler(item2, event) {
1941
+ if (props.eventType !== "mousedown")
1942
+ return;
1943
+ if (item2.type === "button") {
1944
+ buttonHandler(item2, event);
1945
+ }
1946
+ },
1947
+ mouseupHandler(item2, event) {
1948
+ if (props.eventType !== "mouseup")
2821
1949
  return;
2822
- if (typeof item2.handler === "function") {
2823
- item2.handler?.(services);
1950
+ if (item2.type === "button") {
1951
+ buttonHandler(item2, event);
2824
1952
  }
2825
1953
  }
2826
1954
  };
2827
1955
  }
2828
1956
  });
2829
- const _hoisted_1$7 = {
2830
- key: 0,
2831
- class: "menu-item"
2832
- };
2833
- const _hoisted_2$4 = {
1957
+ const _hoisted_1$6 = {
2834
1958
  key: 1,
2835
1959
  class: "menu-item-text"
2836
1960
  };
2837
- const _hoisted_3$3 = {
1961
+ const _hoisted_2$2 = {
2838
1962
  class: "menu-item-text",
2839
1963
  style: { "margin": "0 5px" }
2840
1964
  };
2841
- const _hoisted_4$3 = { class: "el-dropdown-link menubar-menu-button" };
2842
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1965
+ const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
1966
+ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2843
1967
  const _component_el_divider = vue.resolveComponent("el-divider");
1968
+ const _component_tool_button = vue.resolveComponent("tool-button", true);
2844
1969
  const _component_m_icon = vue.resolveComponent("m-icon");
2845
1970
  const _component_el_button = vue.resolveComponent("el-button");
2846
1971
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -2849,44 +1974,66 @@
2849
1974
  const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
2850
1975
  const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
2851
1976
  const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2852
- return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
1977
+ return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", {
1978
+ key: 0,
1979
+ class: vue.normalizeClass(["menu-item", _ctx.item.type]),
1980
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
1981
+ onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
1982
+ onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
1983
+ }, [
2853
1984
  _ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2854
1985
  key: 0,
2855
- direction: "vertical"
2856
- })) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$4, vue.toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
2857
- vue.createVNode(_component_m_icon, {
2858
- icon: _ctx.ZoomIn,
2859
- onClick: _ctx.zoomInHandler
2860
- }, null, 8, ["icon", "onClick"]),
2861
- vue.createElementVNode("span", _hoisted_3$3, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
2862
- vue.createVNode(_component_m_icon, {
2863
- icon: _ctx.ZoomOut,
2864
- onClick: _ctx.zoomOutHandler
2865
- }, null, 8, ["icon", "onClick"])
2866
- ], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2867
- key: 3,
2868
- effect: "dark",
2869
- placement: "bottom-start",
2870
- content: _ctx.item.tooltip || _ctx.item.text
2871
- }, {
2872
- default: vue.withCtx(() => [
2873
- vue.createVNode(_component_el_button, {
2874
- size: "small",
2875
- type: "text",
2876
- disabled: _ctx.disabled,
2877
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.buttonHandler(_ctx.item))
2878
- }, {
2879
- default: vue.withCtx(() => [
2880
- vue.createVNode(_component_m_icon, {
2881
- icon: _ctx.item.icon
2882
- }, null, 8, ["icon"]),
2883
- vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2884
- ]),
2885
- _: 1
2886
- }, 8, ["disabled"])
2887
- ]),
2888
- _: 1
2889
- }, 8, ["content"])) : _ctx.item.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
1986
+ direction: _ctx.item.direction || "vertical"
1987
+ }, null, 8, ["direction"])) : _ctx.item.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, vue.toDisplayString(_ctx.item.text), 1)) : _ctx.item.type === "zoom" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
1988
+ vue.createVNode(_component_tool_button, {
1989
+ data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
1990
+ "event-type": _ctx.eventType
1991
+ }, null, 8, ["data", "event-type"]),
1992
+ vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
1993
+ vue.createVNode(_component_tool_button, {
1994
+ data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
1995
+ "event-type": _ctx.eventType
1996
+ }, null, 8, ["data", "event-type"])
1997
+ ], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
1998
+ _ctx.item.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
1999
+ key: 0,
2000
+ effect: "dark",
2001
+ placement: "bottom-start",
2002
+ content: _ctx.item.tooltip
2003
+ }, {
2004
+ default: vue.withCtx(() => [
2005
+ vue.createVNode(_component_el_button, {
2006
+ size: "small",
2007
+ text: "",
2008
+ disabled: _ctx.disabled
2009
+ }, {
2010
+ default: vue.withCtx(() => [
2011
+ _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2012
+ key: 0,
2013
+ icon: _ctx.item.icon
2014
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2015
+ vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2016
+ ]),
2017
+ _: 1
2018
+ }, 8, ["disabled"])
2019
+ ]),
2020
+ _: 1
2021
+ }, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
2022
+ key: 1,
2023
+ size: "small",
2024
+ text: "",
2025
+ disabled: _ctx.disabled
2026
+ }, {
2027
+ default: vue.withCtx(() => [
2028
+ _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2029
+ key: 0,
2030
+ icon: _ctx.item.icon
2031
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2032
+ vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2033
+ ]),
2034
+ _: 1
2035
+ }, 8, ["disabled"]))
2036
+ ], 64)) : _ctx.item.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2890
2037
  key: 4,
2891
2038
  trigger: "click",
2892
2039
  disabled: _ctx.disabled,
@@ -2911,7 +2058,7 @@
2911
2058
  })) : vue.createCommentVNode("", true)
2912
2059
  ]),
2913
2060
  default: vue.withCtx(() => [
2914
- vue.createElementVNode("span", _hoisted_4$3, [
2061
+ vue.createElementVNode("span", _hoisted_3$1, [
2915
2062
  vue.createTextVNode(vue.toDisplayString(_ctx.item.text), 1),
2916
2063
  vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
2917
2064
  default: vue.withCtx(() => [
@@ -2923,11 +2070,11 @@
2923
2070
  ]),
2924
2071
  _: 1
2925
2072
  }, 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)
2926
- ])) : vue.createCommentVNode("", true);
2073
+ ], 34)) : vue.createCommentVNode("", true);
2927
2074
  }
2928
- var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
2075
+ var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
2929
2076
 
2930
- const _sfc_main$b = vue.defineComponent({
2077
+ const _sfc_main$d = vue.defineComponent({
2931
2078
  name: "nav-menu",
2932
2079
  components: { ToolButton },
2933
2080
  props: {
@@ -2947,7 +2094,7 @@
2947
2094
  };
2948
2095
  }
2949
2096
  });
2950
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2097
+ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2951
2098
  const _component_tool_button = vue.resolveComponent("tool-button");
2952
2099
  return vue.openBlock(), vue.createElementBlock("div", {
2953
2100
  class: "m-editor-nav-menu",
@@ -2969,9 +2116,9 @@
2969
2116
  }), 128))
2970
2117
  ], 4);
2971
2118
  }
2972
- var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
2119
+ var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
2973
2120
 
2974
- const _sfc_main$a = vue.defineComponent({
2121
+ const _sfc_main$c = vue.defineComponent({
2975
2122
  name: "m-editor-props-panel",
2976
2123
  emits: ["mounted"],
2977
2124
  setup(props, { emit }) {
@@ -2986,9 +2133,9 @@
2986
2133
  curFormConfig.value = [];
2987
2134
  return;
2988
2135
  }
2989
- values.value = node.value;
2990
2136
  const type = node.value.type || (node.value.items ? "container" : "text");
2991
2137
  curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
2138
+ values.value = node.value;
2992
2139
  };
2993
2140
  vue.watchEffect(init);
2994
2141
  services?.propsService.on("props-configs-change", init);
@@ -2999,6 +2146,7 @@
2999
2146
  values,
3000
2147
  configForm,
3001
2148
  curFormConfig,
2149
+ propsPanelSize: vue.computed(() => services?.uiService.get("propsPanelSize") || "small"),
3002
2150
  async submit() {
3003
2151
  try {
3004
2152
  const values2 = await configForm.value?.submitForm();
@@ -3017,21 +2165,21 @@
3017
2165
  };
3018
2166
  }
3019
2167
  });
3020
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2168
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
3021
2169
  const _component_m_form = vue.resolveComponent("m-form");
3022
2170
  return vue.openBlock(), vue.createBlock(_component_m_form, {
3023
- class: "m-editor-props-panel",
3024
- "popper-class": "m-editor-props-panel-popper",
2171
+ class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
2172
+ "popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
3025
2173
  ref: "configForm",
3026
- size: "small",
2174
+ size: _ctx.propsPanelSize,
3027
2175
  "init-values": _ctx.values,
3028
2176
  config: _ctx.curFormConfig,
3029
2177
  onChange: _ctx.submit
3030
- }, null, 8, ["init-values", "config", "onChange"]);
2178
+ }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"]);
3031
2179
  }
3032
- var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
2180
+ var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
3033
2181
 
3034
- const _sfc_main$9 = vue.defineComponent({
2182
+ const _sfc_main$b = vue.defineComponent({
3035
2183
  name: "ui-component-panel",
3036
2184
  components: { MIcon },
3037
2185
  setup() {
@@ -3046,19 +2194,29 @@
3046
2194
  searchText,
3047
2195
  collapseValue,
3048
2196
  list,
3049
- appendComponent({ text, type, ...config }) {
2197
+ appendComponent({ text, type, data = {} }) {
3050
2198
  services?.editorService.add({
3051
2199
  name: text,
3052
2200
  type,
3053
- ...config
2201
+ ...data
3054
2202
  });
2203
+ },
2204
+ dragstartHandler({ text, type, data = {} }, e) {
2205
+ if (e.dataTransfer) {
2206
+ e.dataTransfer.effectAllowed = "move";
2207
+ e.dataTransfer.setData("data", serialize__default["default"]({
2208
+ name: text,
2209
+ type,
2210
+ ...data
2211
+ }).replace(/"(\w+)":\s/g, "$1: "));
2212
+ }
3055
2213
  }
3056
2214
  };
3057
2215
  }
3058
2216
  });
3059
- const _hoisted_1$6 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3060
- const _hoisted_2$3 = ["onClick"];
3061
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2217
+ const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2218
+ const _hoisted_2$1 = ["onClick", "onDragstart"];
2219
+ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
3062
2220
  const _component_el_input = vue.resolveComponent("el-input");
3063
2221
  const _component_m_icon = vue.resolveComponent("m-icon");
3064
2222
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -3088,15 +2246,17 @@
3088
2246
  name: index
3089
2247
  }, {
3090
2248
  title: vue.withCtx(() => [
3091
- _hoisted_1$6,
2249
+ _hoisted_1$5,
3092
2250
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
3093
2251
  ]),
3094
2252
  default: vue.withCtx(() => [
3095
2253
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.items, (item) => {
3096
2254
  return vue.openBlock(), vue.createElementBlock("div", {
3097
2255
  class: "component-item",
2256
+ draggable: "true",
3098
2257
  key: item.type,
3099
- onClick: ($event) => _ctx.appendComponent(item)
2258
+ onClick: ($event) => _ctx.appendComponent(item),
2259
+ onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
3100
2260
  }, [
3101
2261
  vue.createVNode(_component_m_icon, {
3102
2262
  icon: item.icon
@@ -3111,7 +2271,7 @@
3111
2271
  ]),
3112
2272
  _: 2
3113
2273
  }, 1032, ["content"])
3114
- ], 8, _hoisted_2$3);
2274
+ ], 40, _hoisted_2$1);
3115
2275
  }), 128))
3116
2276
  ]),
3117
2277
  _: 2
@@ -3125,135 +2285,246 @@
3125
2285
  _: 1
3126
2286
  });
3127
2287
  }
3128
- var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
2288
+ var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
3129
2289
 
3130
- const _sfc_main$8 = vue.defineComponent({
3131
- name: "magic-editor-content-menu",
2290
+ const _sfc_main$a = vue.defineComponent({
2291
+ components: { ToolButton },
3132
2292
  props: {
3133
- componentGroupList: {
2293
+ menuData: {
3134
2294
  type: Array,
3135
2295
  default: () => []
2296
+ },
2297
+ isSubMenu: {
2298
+ type: Boolean,
2299
+ default: false
3136
2300
  }
3137
2301
  },
3138
- setup(props) {
2302
+ emits: ["hide", "show"],
2303
+ setup(props, { emit }) {
2304
+ const menu = vue.ref();
2305
+ const subMenu = vue.ref();
2306
+ const visible = vue.ref(false);
2307
+ const subMenuData = vue.ref([]);
2308
+ const menuStyle = vue.ref({
2309
+ left: "0",
2310
+ top: "0"
2311
+ });
2312
+ const hide = () => {
2313
+ if (!visible.value)
2314
+ return;
2315
+ visible.value = false;
2316
+ subMenu.value?.hide();
2317
+ emit("hide");
2318
+ };
2319
+ const hideHandler = (e) => {
2320
+ const target = e.target;
2321
+ if (!visible.value || !target) {
2322
+ return;
2323
+ }
2324
+ if (menu.value?.contains(target) || subMenu.value?.$el?.contains(target)) {
2325
+ return;
2326
+ }
2327
+ hide();
2328
+ };
2329
+ vue.onMounted(() => {
2330
+ if (props.isSubMenu)
2331
+ return;
2332
+ globalThis.addEventListener("mousedown", hideHandler, true);
2333
+ });
2334
+ vue.onUnmounted(() => {
2335
+ if (props.isSubMenu)
2336
+ return;
2337
+ globalThis.removeEventListener("mousedown", hideHandler, true);
2338
+ });
2339
+ return {
2340
+ menu,
2341
+ subMenu,
2342
+ visible,
2343
+ menuStyle,
2344
+ subMenuData,
2345
+ hide,
2346
+ show(e) {
2347
+ setTimeout(() => {
2348
+ visible.value = true;
2349
+ vue.nextTick(() => {
2350
+ const menuHeight = menu.value?.clientHeight || 0;
2351
+ let top = e.clientY;
2352
+ if (menuHeight + e.clientY > document.body.clientHeight) {
2353
+ top = document.body.clientHeight - menuHeight;
2354
+ }
2355
+ menuStyle.value = {
2356
+ top: `${top}px`,
2357
+ left: `${e.clientX}px`
2358
+ };
2359
+ emit("show");
2360
+ });
2361
+ }, 300);
2362
+ },
2363
+ showSubMenu(item) {
2364
+ const menuItem = item;
2365
+ if (typeof item !== "object" || !menuItem.items?.length) {
2366
+ return;
2367
+ }
2368
+ subMenuData.value = menuItem.items;
2369
+ if (menu.value) {
2370
+ subMenu.value.show({
2371
+ clientX: menu.value.offsetLeft + menu.value.clientWidth,
2372
+ clientY: menu.value.offsetTop
2373
+ });
2374
+ }
2375
+ }
2376
+ };
2377
+ }
2378
+ });
2379
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2380
+ const _component_tool_button = vue.resolveComponent("tool-button");
2381
+ const _component_content_menu = vue.resolveComponent("content-menu", true);
2382
+ return _ctx.menuData.length && _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
2383
+ key: 0,
2384
+ class: "magic-editor-content-menu",
2385
+ ref: "menu",
2386
+ style: vue.normalizeStyle(_ctx.menuStyle)
2387
+ }, [
2388
+ vue.createElementVNode("div", null, [
2389
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
2390
+ return vue.openBlock(), vue.createBlock(_component_tool_button, {
2391
+ "event-type": "mouseup",
2392
+ data: item,
2393
+ key: index,
2394
+ onMouseup: _ctx.hide,
2395
+ onMouseenter: ($event) => _ctx.showSubMenu(item)
2396
+ }, null, 8, ["data", "onMouseup", "onMouseenter"]);
2397
+ }), 128))
2398
+ ]),
2399
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
2400
+ vue.createVNode(_component_content_menu, {
2401
+ class: "sub-menu",
2402
+ ref: "subMenu",
2403
+ "menu-data": _ctx.subMenuData,
2404
+ "is-sub-menu": true,
2405
+ onHide: _ctx.hide
2406
+ }, null, 8, ["menu-data", "onHide"])
2407
+ ]))
2408
+ ], 4)) : vue.createCommentVNode("", true);
2409
+ }
2410
+ var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
2411
+
2412
+ const _sfc_main$9 = vue.defineComponent({
2413
+ components: { ContentMenu },
2414
+ setup() {
3139
2415
  const services = vue.inject("services");
3140
- const subVisible = vue.ref(false);
2416
+ const menu = vue.ref();
3141
2417
  const node = vue.computed(() => services?.editorService.get("node"));
3142
- return {
3143
- subVisible,
3144
- node,
3145
- menu: vue.computed(() => ({
3146
- app: [
3147
- {
3148
- type: "page",
3149
- text: "\u9875\u9762"
3150
- }
3151
- ],
3152
- component: props.componentGroupList
3153
- })),
3154
- append(config) {
2418
+ const isRoot = vue.computed(() => node.value?.type === schema.NodeType.ROOT);
2419
+ const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
2420
+ const componentList = vue.computed(() => services?.componentListService.getList() || []);
2421
+ const layerContentMenu = vue.inject("layerContentMenu", []);
2422
+ const createMenuItems = (group) => group.items.map((component) => ({
2423
+ text: component.text,
2424
+ type: "button",
2425
+ icon: component.icon,
2426
+ handler: () => {
3155
2427
  services?.editorService.add({
3156
- name: config.text,
3157
- type: config.type
2428
+ name: component.text,
2429
+ type: component.type,
2430
+ ...component.data || {}
3158
2431
  });
3159
- },
3160
- remove() {
3161
- node.value && services?.editorService.remove(node.value);
3162
- },
3163
- copy(node2) {
3164
- services?.editorService.copy(node2);
3165
- },
3166
- setSubVisiable(v) {
3167
- subVisible.value = v;
2432
+ }
2433
+ }));
2434
+ const getSubMenuData = vue.computed(() => {
2435
+ if (node.value?.type === "tabs") {
2436
+ return [
2437
+ {
2438
+ text: "\u6807\u7B7E\u9875",
2439
+ type: "button",
2440
+ icon: icons.Files,
2441
+ handler: () => {
2442
+ services?.editorService.add({
2443
+ type: "tab-pane"
2444
+ });
2445
+ }
2446
+ }
2447
+ ];
2448
+ }
2449
+ if (node.value?.items) {
2450
+ return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
2451
+ {
2452
+ type: "divider",
2453
+ direction: "horizontal"
2454
+ }
2455
+ ] : []), []) || [];
2456
+ }
2457
+ return [];
2458
+ });
2459
+ return {
2460
+ menu,
2461
+ menuData: vue.computed(() => [
2462
+ {
2463
+ type: "button",
2464
+ text: "\u65B0\u589E",
2465
+ icon: vue.markRaw(icons.Plus),
2466
+ display: () => node.value?.items,
2467
+ items: getSubMenuData.value
2468
+ },
2469
+ {
2470
+ type: "button",
2471
+ text: "\u590D\u5236",
2472
+ icon: vue.markRaw(icons.DocumentCopy),
2473
+ display: () => !isRoot.value,
2474
+ handler: () => {
2475
+ node.value && services?.editorService.copy(node.value);
2476
+ }
2477
+ },
2478
+ {
2479
+ type: "button",
2480
+ text: "\u5220\u9664",
2481
+ icon: vue.markRaw(icons.Delete),
2482
+ display: () => !isRoot.value && !isPage.value,
2483
+ handler: () => {
2484
+ node.value && services?.editorService.remove(node.value);
2485
+ }
2486
+ },
2487
+ ...layerContentMenu
2488
+ ]),
2489
+ show(e) {
2490
+ menu.value?.show(e);
3168
2491
  }
3169
2492
  };
3170
2493
  }
3171
2494
  });
3172
- const _hoisted_1$5 = {
3173
- key: 0,
3174
- class: "magic-editor-content-menu"
3175
- };
3176
- const _hoisted_2$2 = ["onClick"];
3177
- const _hoisted_3$2 = ["onClick"];
3178
- const _hoisted_4$2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3179
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
3180
- const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
3181
- return _ctx.node ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
3182
- _ctx.node.items ? (vue.openBlock(), vue.createElementBlock("div", {
3183
- key: 0,
3184
- class: "magic-editor-content-menu-item",
3185
- onMouseenter: _cache[0] || (_cache[0] = ($event) => _ctx.setSubVisiable(true)),
3186
- onMouseleave: _cache[1] || (_cache[1] = ($event) => _ctx.setSubVisiable(false))
3187
- }, " \u65B0\u589E ", 32)) : vue.createCommentVNode("", true),
3188
- _ctx.node.type !== "app" ? (vue.openBlock(), vue.createElementBlock("div", {
3189
- key: 1,
3190
- class: "magic-editor-content-menu-item",
3191
- onClick: _cache[2] || (_cache[2] = () => _ctx.copy(_ctx.node))
3192
- }, "\u590D\u5236")) : vue.createCommentVNode("", true),
3193
- _ctx.node.type !== "app" && _ctx.node.type !== "page" ? (vue.openBlock(), vue.createElementBlock("div", {
3194
- key: 2,
3195
- class: "magic-editor-content-menu-item",
3196
- onClick: _cache[3] || (_cache[3] = () => _ctx.remove())
3197
- }, " \u5220\u9664 ")) : vue.createCommentVNode("", true),
3198
- vue.withDirectives(vue.createElementVNode("div", {
3199
- class: "subMenu",
3200
- onMouseenter: _cache[5] || (_cache[5] = ($event) => _ctx.setSubVisiable(true)),
3201
- onMouseleave: _cache[6] || (_cache[6] = ($event) => _ctx.setSubVisiable(false))
3202
- }, [
3203
- vue.createVNode(_component_el_scrollbar, null, {
3204
- default: vue.withCtx(() => [
3205
- _ctx.node.type === "tabs" ? (vue.openBlock(), vue.createElementBlock("div", {
3206
- key: 0,
3207
- class: "magic-editor-content-menu-item",
3208
- onClick: _cache[4] || (_cache[4] = () => _ctx.append({
3209
- type: "tab-pane"
3210
- }))
3211
- }, " \u6807\u7B7E ")) : _ctx.node.type === "app" ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(_ctx.menu.app, (item) => {
3212
- return vue.openBlock(), vue.createElementBlock("div", {
3213
- class: "magic-editor-content-menu-item",
3214
- key: item.type,
3215
- onClick: () => _ctx.append(item)
3216
- }, vue.toDisplayString(item.text), 9, _hoisted_2$2);
3217
- }), 128)) : _ctx.node.items ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 2 }, vue.renderList(_ctx.menu.component, (list) => {
3218
- return vue.openBlock(), vue.createElementBlock("div", {
3219
- key: list.title
3220
- }, [
3221
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.items, (item) => {
3222
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
3223
- item ? (vue.openBlock(), vue.createElementBlock("div", {
3224
- class: "magic-editor-content-menu-item",
3225
- key: item.type,
3226
- onClick: () => _ctx.append(item)
3227
- }, vue.toDisplayString(item.text), 9, _hoisted_3$2)) : vue.createCommentVNode("", true)
3228
- ], 64);
3229
- }), 256)),
3230
- _hoisted_4$2
3231
- ]);
3232
- }), 128)) : vue.createCommentVNode("", true)
3233
- ]),
3234
- _: 1
3235
- })
3236
- ], 544), [
3237
- [vue.vShow, _ctx.subVisible]
3238
- ])
3239
- ])) : vue.createCommentVNode("", true);
2495
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2496
+ const _component_content_menu = vue.resolveComponent("content-menu");
2497
+ return vue.openBlock(), vue.createBlock(_component_content_menu, {
2498
+ "menu-data": _ctx.menuData,
2499
+ ref: "menu",
2500
+ style: { "overflow": "initial" }
2501
+ }, null, 8, ["menu-data"]);
3240
2502
  }
3241
- var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
2503
+ var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
3242
2504
 
3243
- const select = (data, editorService) => {
2505
+ const throttleTime = 150;
2506
+ const select = async (data, editorService) => {
3244
2507
  if (!data.id) {
3245
2508
  throw new Error("\u6CA1\u6709id");
3246
2509
  }
3247
- editorService?.select(data);
2510
+ await editorService?.select(data);
2511
+ editorService?.get("stage")?.select(data.id);
2512
+ };
2513
+ const highlight = (data, editorService) => {
2514
+ if (!data?.id) {
2515
+ throw new Error("\u6CA1\u6709id");
2516
+ }
2517
+ editorService?.highlight(data);
2518
+ editorService?.get("stage")?.highlight(data.id);
3248
2519
  };
3249
2520
  const useDrop = (tree, editorService) => ({
3250
2521
  allowDrop: (draggingNode, dropNode, type) => {
3251
2522
  const { data } = dropNode || {};
3252
2523
  const { data: ingData } = draggingNode;
3253
2524
  const { type: ingType } = ingData;
3254
- if (ingType !== "page" && data.type === "page")
2525
+ if (ingType !== schema.NodeType.PAGE && data.type === schema.NodeType.PAGE)
3255
2526
  return false;
3256
- if (ingType === "page" && data.type !== "page")
2527
+ if (ingType === schema.NodeType.PAGE && data.type !== schema.NodeType.PAGE)
3257
2528
  return false;
3258
2529
  if (!data || !data.type)
3259
2530
  return false;
@@ -3272,29 +2543,35 @@
3272
2543
  }
3273
2544
  });
3274
2545
  const useStatus = (tree, editorService) => {
2546
+ const highlightNode = vue.ref();
2547
+ const node = vue.ref();
3275
2548
  const page = vue.computed(() => editorService?.get("page"));
3276
2549
  vue.watchEffect(() => {
3277
2550
  if (!tree.value)
3278
2551
  return;
3279
- const node = editorService?.get("node");
3280
- node && tree.value.setCurrentKey(node.id, true);
2552
+ node.value = editorService?.get("node");
2553
+ node.value && tree.value.setCurrentKey(node.value.id, true);
3281
2554
  const parent = editorService?.get("parent");
3282
2555
  if (!parent?.id)
3283
2556
  return;
3284
2557
  const treeNode = tree.value.getNode(parent.id);
3285
2558
  treeNode?.updateChildren();
2559
+ highlightNode.value = editorService?.get("highlightNode");
3286
2560
  });
3287
2561
  return {
3288
2562
  values: vue.computed(() => page.value ? [page.value] : []),
3289
- loadItems: (node, resolve) => {
3290
- if (Array.isArray(node.data)) {
3291
- return resolve(node.data);
2563
+ loadItems: (node2, resolve) => {
2564
+ if (Array.isArray(node2.data)) {
2565
+ return resolve(node2.data);
3292
2566
  }
3293
- if (Array.isArray(node.data?.items)) {
3294
- return resolve(node.data?.items);
2567
+ if (Array.isArray(node2.data?.items)) {
2568
+ return resolve(node2.data?.items);
3295
2569
  }
3296
2570
  resolve([]);
3297
- }
2571
+ },
2572
+ highlightNode,
2573
+ clickNode: node,
2574
+ expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
3298
2575
  };
3299
2576
  };
3300
2577
  const useFilter = (tree) => ({
@@ -3306,69 +2583,64 @@
3306
2583
  let name = "";
3307
2584
  if (data.name) {
3308
2585
  name = data.name;
3309
- } else if (data.type) {
3310
- name = data.type;
3311
2586
  } else if (data.items) {
3312
2587
  name = "container";
3313
2588
  }
3314
- return name.indexOf(value) !== -1;
2589
+ return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
3315
2590
  },
3316
2591
  filterTextChangeHandler(val) {
3317
2592
  tree.value?.filter(val);
3318
2593
  }
3319
2594
  });
3320
- const useContentMenu = (editorService) => {
3321
- const menuStyle = vue.ref({
3322
- position: "absolute",
3323
- left: "0",
3324
- top: "0",
3325
- display: "none"
3326
- });
3327
- vue.onMounted(() => {
3328
- document.addEventListener("click", () => {
3329
- menuStyle.value.display = "none";
3330
- }, true);
3331
- });
3332
- return {
3333
- menuStyle,
3334
- contextmenu(event, data) {
3335
- const bodyHeight = globalThis.document.body.clientHeight;
3336
- const left = `${event.clientX + 20}px`;
3337
- let top = `${event.clientY - 10}px`;
3338
- if (event.clientY + 300 > bodyHeight) {
3339
- top = `${bodyHeight - 300}px`;
3340
- }
3341
- menuStyle.value.left = left;
3342
- menuStyle.value.top = top;
3343
- menuStyle.value.display = "";
3344
- select(data, editorService);
3345
- }
3346
- };
3347
- };
3348
- const _sfc_main$7 = vue.defineComponent({
2595
+ const _sfc_main$8 = vue.defineComponent({
3349
2596
  name: "magic-editor-layer-panel",
3350
2597
  components: { LayerMenu },
3351
2598
  setup() {
3352
2599
  const services = vue.inject("services");
3353
2600
  const tree = vue.ref();
2601
+ const menu = vue.ref();
2602
+ const clicked = vue.ref(false);
3354
2603
  const editorService = services?.editorService;
2604
+ const highlightHandler = lodashEs.throttle((data) => {
2605
+ highlight(data, editorService);
2606
+ }, throttleTime);
2607
+ const toggleClickFlag = () => {
2608
+ clicked.value = !clicked.value;
2609
+ };
2610
+ const statusData = useStatus(tree, editorService);
2611
+ const canHighlight = vue.computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
2612
+ editorService?.on("remove", () => {
2613
+ setTimeout(() => {
2614
+ tree.value?.getNode(editorService.get("node").id)?.updateChildren();
2615
+ }, 0);
2616
+ });
3355
2617
  return {
3356
2618
  tree,
2619
+ menu,
2620
+ ...statusData,
3357
2621
  ...useDrop(tree, editorService),
3358
- ...useStatus(tree, editorService),
3359
2622
  ...useFilter(tree),
3360
- ...useContentMenu(editorService),
2623
+ highlightHandler,
2624
+ toggleClickFlag,
2625
+ canHighlight,
3361
2626
  clickHandler(data) {
3362
2627
  if (services?.uiService.get("uiSelectMode")) {
3363
2628
  document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
3364
2629
  return;
3365
2630
  }
2631
+ tree.value?.setCurrentKey(data.id);
3366
2632
  select(data, editorService);
2633
+ },
2634
+ async contextmenu(event, data) {
2635
+ event.preventDefault();
2636
+ await select(data, editorService);
2637
+ menu.value?.show(event);
3367
2638
  }
3368
2639
  };
3369
2640
  }
3370
2641
  });
3371
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2642
+ const _hoisted_1$4 = ["id", "onMouseenter"];
2643
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
3372
2644
  const _component_el_input = vue.resolveComponent("el-input");
3373
2645
  const _component_el_tree = vue.resolveComponent("el-tree");
3374
2646
  const _component_layer_menu = vue.resolveComponent("layer-menu");
@@ -3389,6 +2661,7 @@
3389
2661
  ref: "tree",
3390
2662
  "node-key": "id",
3391
2663
  draggable: "",
2664
+ "default-expanded-keys": _ctx.expandedKeys,
3392
2665
  load: _ctx.loadItems,
3393
2666
  data: _ctx.values,
3394
2667
  "expand-on-click-node": false,
@@ -3404,47 +2677,46 @@
3404
2677
  "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
3405
2678
  }, {
3406
2679
  default: vue.withCtx(({ node, data }) => [
3407
- vue.renderSlot(_ctx.$slots, "layer-node-content", {
3408
- node,
3409
- data
3410
- }, () => [
3411
- vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
3412
- ])
2680
+ vue.createElementVNode("div", {
2681
+ id: data.id,
2682
+ class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
2683
+ onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
2684
+ onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
2685
+ onMouseenter: ($event) => _ctx.highlightHandler(data)
2686
+ }, [
2687
+ vue.renderSlot(_ctx.$slots, "layer-node-content", {
2688
+ node,
2689
+ data
2690
+ }, () => [
2691
+ vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
2692
+ ])
2693
+ ], 42, _hoisted_1$4)
3413
2694
  ]),
3414
2695
  _: 3
3415
- }, 8, ["load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
2696
+ }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
3416
2697
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3417
- vue.createVNode(_component_layer_menu, {
3418
- style: vue.normalizeStyle(_ctx.menuStyle)
3419
- }, null, 8, ["style"])
2698
+ vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
3420
2699
  ]))
3421
2700
  ]),
3422
2701
  _: 3
3423
2702
  });
3424
2703
  }
3425
- var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
2704
+ var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
3426
2705
 
3427
- const _sfc_main$6 = vue.defineComponent({
3428
- name: "m-sidebar",
2706
+ const _sfc_main$7 = vue.defineComponent({
3429
2707
  components: { MIcon },
3430
2708
  props: {
3431
2709
  data: {
3432
- type: Object,
3433
- default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
2710
+ type: [Object, String]
3434
2711
  }
3435
2712
  },
3436
2713
  setup(props) {
3437
- const activeTabName = vue.ref(props.data?.status);
3438
- vue.watch(() => props.data?.status, (status) => {
3439
- activeTabName.value = status || "0";
3440
- });
3441
2714
  return {
3442
- activeTabName,
3443
- items: vue.computed(() => props.data?.items.map((item) => {
3444
- if (typeof item !== "string") {
3445
- return item;
2715
+ config: vue.computed(() => {
2716
+ if (typeof props.data !== "string") {
2717
+ return props.data;
3446
2718
  }
3447
- switch (item) {
2719
+ switch (props.data) {
3448
2720
  case "component-list":
3449
2721
  return {
3450
2722
  type: "component",
@@ -3462,21 +2734,75 @@
3462
2734
  slots: {}
3463
2735
  };
3464
2736
  default:
3465
- return {};
2737
+ return void 0;
3466
2738
  }
3467
- }))
2739
+ })
3468
2740
  };
3469
2741
  }
3470
2742
  });
3471
- const _hoisted_1$4 = {
2743
+ const _hoisted_1$3 = {
3472
2744
  key: 1,
3473
2745
  class: "magic-editor-tab-panel-title"
3474
2746
  };
3475
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2747
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3476
2748
  const _component_m_icon = vue.resolveComponent("m-icon");
3477
2749
  const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
2750
+ return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
2751
+ key: 0,
2752
+ name: _ctx.config.text
2753
+ }, {
2754
+ label: vue.withCtx(() => [
2755
+ (vue.openBlock(), vue.createElementBlock("div", {
2756
+ key: _ctx.config.text
2757
+ }, [
2758
+ _ctx.config.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2759
+ key: 0,
2760
+ icon: _ctx.config.icon
2761
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2762
+ _ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, vue.toDisplayString(_ctx.config.text), 1)) : vue.createCommentVNode("", true)
2763
+ ]))
2764
+ ]),
2765
+ default: vue.withCtx(() => [
2766
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.component), vue.mergeProps(_ctx.config.props || {}, vue.toHandlers(_ctx.config?.listeners || {})), vue.createSlots({ _: 2 }, [
2767
+ _ctx.config.slots?.layerNodeContent ? {
2768
+ name: "layer-node-content",
2769
+ fn: vue.withCtx(({ data, node }) => [
2770
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots?.layerNodeContent), {
2771
+ data,
2772
+ node
2773
+ }, null, 8, ["data", "node"]))
2774
+ ])
2775
+ } : void 0
2776
+ ]), 1040))
2777
+ ]),
2778
+ _: 1
2779
+ }, 8, ["name"])) : vue.createCommentVNode("", true);
2780
+ }
2781
+ var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
2782
+
2783
+ const _sfc_main$6 = vue.defineComponent({
2784
+ components: { TabPane },
2785
+ name: "m-sidebar",
2786
+ props: {
2787
+ data: {
2788
+ type: Object,
2789
+ default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
2790
+ }
2791
+ },
2792
+ setup(props) {
2793
+ const activeTabName = vue.ref(props.data?.status);
2794
+ vue.watch(() => props.data?.status, (status) => {
2795
+ activeTabName.value = status || "0";
2796
+ });
2797
+ return {
2798
+ activeTabName
2799
+ };
2800
+ }
2801
+ });
2802
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2803
+ const _component_tab_pane = vue.resolveComponent("tab-pane");
3478
2804
  const _component_el_tabs = vue.resolveComponent("el-tabs");
3479
- return _ctx.data.type === "tabs" ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
2805
+ return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
3480
2806
  key: 0,
3481
2807
  class: "m-editor-sidebar",
3482
2808
  modelValue: _ctx.activeTabName,
@@ -3485,35 +2811,11 @@
3485
2811
  "tab-position": "left"
3486
2812
  }, {
3487
2813
  default: vue.withCtx(() => [
3488
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.items, (item) => {
3489
- return vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
3490
- key: item.text,
3491
- name: item.text
3492
- }, {
3493
- label: vue.withCtx(() => [
3494
- vue.createElementVNode("span", null, [
3495
- item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
3496
- key: 0,
3497
- icon: item.icon
3498
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
3499
- item.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, vue.toDisplayString(item.text), 1)) : vue.createCommentVNode("", true)
3500
- ])
3501
- ]),
3502
- default: vue.withCtx(() => [
3503
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.component), vue.mergeProps(item.props || {}, vue.toHandlers(item.listeners || {})), vue.createSlots({ _: 2 }, [
3504
- item.slots?.layerNodeContent ? {
3505
- name: "layer-node-content",
3506
- fn: vue.withCtx(({ data, node }) => [
3507
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.slots.layerNodeContent), {
3508
- data,
3509
- node
3510
- }, null, 8, ["data", "node"]))
3511
- ])
3512
- } : void 0
3513
- ]), 1040))
3514
- ]),
3515
- _: 2
3516
- }, 1032, ["name"]);
2814
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data.items, (item, index) => {
2815
+ return vue.openBlock(), vue.createBlock(_component_tab_pane, {
2816
+ key: index,
2817
+ data: item
2818
+ }, null, 8, ["data"]);
3517
2819
  }), 128))
3518
2820
  ]),
3519
2821
  _: 1
@@ -3521,13 +2823,81 @@
3521
2823
  }
3522
2824
  var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
3523
2825
 
2826
+ const useScroll = (root) => {
2827
+ const pageBar = vue.ref();
2828
+ const itemsContainer = vue.ref();
2829
+ const pageBarWidth = vue.ref(0);
2830
+ const canScroll = vue.ref(false);
2831
+ const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
2832
+ let translateLeft = 0;
2833
+ const resizeObserver = new ResizeObserver((entries) => {
2834
+ for (const { contentRect } of entries) {
2835
+ const { width } = contentRect;
2836
+ pageBarWidth.value = width || 0;
2837
+ setCanScroll();
2838
+ }
2839
+ });
2840
+ const setCanScroll = () => {
2841
+ if (itemsContainer.value) {
2842
+ canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
2843
+ }
2844
+ };
2845
+ const scroll = (type) => {
2846
+ if (!itemsContainer.value)
2847
+ return;
2848
+ const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
2849
+ if (type === "left") {
2850
+ translateLeft += 100;
2851
+ if (translateLeft > 0) {
2852
+ translateLeft = 0;
2853
+ }
2854
+ } else if (type === "right") {
2855
+ translateLeft -= 100;
2856
+ if (-translateLeft > maxScrollLeft) {
2857
+ translateLeft = -maxScrollLeft;
2858
+ }
2859
+ } else if (type === "start") {
2860
+ translateLeft = 0;
2861
+ } else if (type === "end") {
2862
+ translateLeft = -maxScrollLeft;
2863
+ }
2864
+ itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
2865
+ };
2866
+ vue.onMounted(() => {
2867
+ pageBar.value && resizeObserver.observe(pageBar.value);
2868
+ });
2869
+ vue.onUnmounted(() => {
2870
+ resizeObserver.disconnect();
2871
+ });
2872
+ vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
2873
+ setTimeout(() => {
2874
+ setCanScroll();
2875
+ if (length < preLength) {
2876
+ scroll("start");
2877
+ } else {
2878
+ scroll("end");
2879
+ }
2880
+ });
2881
+ });
2882
+ return {
2883
+ pageBar,
2884
+ itemsContainer,
2885
+ canScroll,
2886
+ itemsContainerWidth,
2887
+ scroll
2888
+ };
2889
+ };
3524
2890
  const _sfc_main$5 = vue.defineComponent({
3525
- components: { CaretBottom: icons.CaretBottom, Plus: icons.Plus },
2891
+ components: { ArrowLeftBold: icons.ArrowLeftBold, ArrowRightBold: icons.ArrowRightBold, CaretBottom: icons.CaretBottom, Plus: icons.Plus, ToolButton },
3526
2892
  setup() {
3527
2893
  const services = vue.inject("services");
3528
2894
  const editorService = services?.editorService;
2895
+ const root = vue.computed(() => editorService?.get("root"));
3529
2896
  return {
3530
- root: vue.computed(() => editorService?.get("root")),
2897
+ Delete: vue.markRaw(icons.Delete),
2898
+ DocumentCopy: vue.markRaw(icons.DocumentCopy),
2899
+ ...useScroll(root),
2900
+ root,
3531
2901
  page: vue.computed(() => editorService?.get("page")),
3532
2902
  switchPage(page) {
3533
2903
  editorService?.select(page);
@@ -3536,7 +2906,7 @@
3536
2906
  if (!editorService)
3537
2907
  return;
3538
2908
  const pageConfig = {
3539
- type: "page",
2909
+ type: schema.NodeType.PAGE,
3540
2910
  name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
3541
2911
  };
3542
2912
  editorService.add(pageConfig);
@@ -3554,99 +2924,228 @@
3554
2924
  };
3555
2925
  }
3556
2926
  });
3557
- const _hoisted_1$3 = { class: "m-editor-page-bar" };
3558
- const _hoisted_2$1 = ["onClick"];
3559
- const _hoisted_3$1 = ["onClick"];
3560
- const _hoisted_4$1 = ["onClick"];
2927
+ const _hoisted_1$2 = {
2928
+ class: "m-editor-page-bar",
2929
+ ref: "pageBar"
2930
+ };
2931
+ const _hoisted_2 = ["onClick"];
2932
+ const _hoisted_3 = { class: "m-editor-page-bar-title" };
3561
2933
  function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3562
2934
  const _component_plus = vue.resolveComponent("plus");
3563
2935
  const _component_el_icon = vue.resolveComponent("el-icon");
2936
+ const _component_arrow_left_bold = vue.resolveComponent("arrow-left-bold");
2937
+ const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2938
+ const _component_tool_button = vue.resolveComponent("tool-button");
3564
2939
  const _component_caret_bottom = vue.resolveComponent("caret-bottom");
3565
2940
  const _component_el_popover = vue.resolveComponent("el-popover");
3566
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
2941
+ const _component_arrow_right_bold = vue.resolveComponent("arrow-right-bold");
2942
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
3567
2943
  vue.createElementVNode("div", {
3568
- class: "m-editor-page-bar-item",
2944
+ id: "m-editor-page-bar-add-icon",
2945
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3569
2946
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
3570
2947
  }, [
3571
- vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-add-icon" }, {
2948
+ vue.createVNode(_component_el_icon, null, {
3572
2949
  default: vue.withCtx(() => [
3573
2950
  vue.createVNode(_component_plus)
3574
2951
  ]),
3575
2952
  _: 1
3576
2953
  })
3577
2954
  ]),
3578
- _ctx.root ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(_ctx.root.items, (item) => {
3579
- return vue.openBlock(), vue.createElementBlock("div", {
3580
- key: item.key,
3581
- class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
3582
- onClick: ($event) => _ctx.switchPage(item)
3583
- }, [
3584
- vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3585
- vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
2955
+ _ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
2956
+ key: 0,
2957
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
2958
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
2959
+ }, [
2960
+ vue.createVNode(_component_el_icon, null, {
2961
+ default: vue.withCtx(() => [
2962
+ vue.createVNode(_component_arrow_left_bold)
3586
2963
  ]),
3587
- vue.createVNode(_component_el_popover, {
3588
- placement: "top",
3589
- width: 160,
3590
- trigger: "hover"
3591
- }, {
3592
- reference: vue.withCtx(() => [
3593
- vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3594
- default: vue.withCtx(() => [
3595
- vue.createVNode(_component_caret_bottom)
3596
- ]),
3597
- _: 1
3598
- })
3599
- ]),
3600
- default: vue.withCtx(() => [
3601
- vue.createElementVNode("div", null, [
3602
- vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3603
- vue.createElementVNode("div", {
3604
- class: "magic-editor-content-menu-item",
3605
- onClick: () => _ctx.copy(item)
3606
- }, "\u590D\u5236", 8, _hoisted_3$1),
3607
- vue.createElementVNode("div", {
3608
- class: "magic-editor-content-menu-item",
3609
- onClick: () => _ctx.remove(item)
3610
- }, "\u5220\u9664", 8, _hoisted_4$1)
3611
- ])
2964
+ _: 1
2965
+ })
2966
+ ])) : vue.createCommentVNode("", true),
2967
+ _ctx.root ? (vue.openBlock(), vue.createElementBlock("div", {
2968
+ key: 1,
2969
+ class: "m-editor-page-bar-items",
2970
+ ref: "itemsContainer",
2971
+ style: vue.normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
2972
+ }, [
2973
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.root.items, (item) => {
2974
+ return vue.openBlock(), vue.createElementBlock("div", {
2975
+ key: item.key,
2976
+ class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
2977
+ onClick: ($event) => _ctx.switchPage(item)
2978
+ }, [
2979
+ vue.createElementVNode("div", _hoisted_3, [
2980
+ vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
2981
+ vue.createVNode(_component_el_tooltip, {
2982
+ effect: "dark",
2983
+ placement: "top-start",
2984
+ content: item.name
2985
+ }, {
2986
+ default: vue.withCtx(() => [
2987
+ vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
2988
+ ]),
2989
+ _: 2
2990
+ }, 1032, ["content"])
3612
2991
  ])
3613
2992
  ]),
3614
- _: 2
3615
- }, 1024)
3616
- ], 10, _hoisted_2$1);
3617
- }), 128)) : vue.createCommentVNode("", true)
3618
- ]);
2993
+ vue.createVNode(_component_el_popover, {
2994
+ "popper-class": "page-bar-popover",
2995
+ placement: "top",
2996
+ width: 160,
2997
+ trigger: "hover"
2998
+ }, {
2999
+ reference: vue.withCtx(() => [
3000
+ vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3001
+ default: vue.withCtx(() => [
3002
+ vue.createVNode(_component_caret_bottom)
3003
+ ]),
3004
+ _: 1
3005
+ })
3006
+ ]),
3007
+ default: vue.withCtx(() => [
3008
+ vue.createElementVNode("div", null, [
3009
+ vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3010
+ vue.createVNode(_component_tool_button, {
3011
+ data: {
3012
+ type: "button",
3013
+ text: "\u590D\u5236",
3014
+ icon: _ctx.DocumentCopy,
3015
+ handler: () => _ctx.copy(item)
3016
+ }
3017
+ }, null, 8, ["data"]),
3018
+ vue.createVNode(_component_tool_button, {
3019
+ data: {
3020
+ type: "button",
3021
+ text: "\u5220\u9664",
3022
+ icon: _ctx.Delete,
3023
+ handler: () => _ctx.remove(item)
3024
+ }
3025
+ }, null, 8, ["data"])
3026
+ ])
3027
+ ])
3028
+ ]),
3029
+ _: 2
3030
+ }, 1024)
3031
+ ], 10, _hoisted_2);
3032
+ }), 128))
3033
+ ], 4)) : vue.createCommentVNode("", true),
3034
+ _ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
3035
+ key: 2,
3036
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3037
+ onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
3038
+ }, [
3039
+ vue.createVNode(_component_el_icon, null, {
3040
+ default: vue.withCtx(() => [
3041
+ vue.createVNode(_component_arrow_right_bold)
3042
+ ]),
3043
+ _: 1
3044
+ })
3045
+ ])) : vue.createCommentVNode("", true)
3046
+ ], 512);
3619
3047
  }
3620
3048
  var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
3621
3049
 
3622
3050
  class ScrollViewer$1 {
3623
- enter = false;
3624
- targetEnter = false;
3625
- keydown = false;
3626
- container;
3627
- target;
3628
- zoom = 1;
3629
- scrollLeft = 0;
3630
- scrollTop = 0;
3631
- x = 0;
3632
- y = 0;
3633
- resizeObserver = new ResizeObserver((entries) => {
3634
- for (const { contentRect } of entries) {
3635
- const { width, height } = contentRect;
3636
- const targetRect = this.target.getBoundingClientRect();
3637
- const targetWidth = targetRect.width * this.zoom;
3638
- const targetMarginTop = Number(this.target.style.marginTop) || 0;
3639
- const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3640
- if (targetWidth < width) {
3641
- this.target._left = 0;
3642
- }
3643
- if (targetHeight < height) {
3644
- this.target._top = 0;
3051
+ constructor(options) {
3052
+ this.enter = false;
3053
+ this.targetEnter = false;
3054
+ this.keydown = false;
3055
+ this.zoom = 1;
3056
+ this.scrollLeft = 0;
3057
+ this.scrollTop = 0;
3058
+ this.x = 0;
3059
+ this.y = 0;
3060
+ this.resizeObserver = new ResizeObserver((entries) => {
3061
+ for (const { contentRect } of entries) {
3062
+ const { width, height } = contentRect;
3063
+ const targetRect = this.target.getBoundingClientRect();
3064
+ const targetWidth = targetRect.width * this.zoom;
3065
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3066
+ const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3067
+ if (targetWidth < width) {
3068
+ this.target._left = 0;
3069
+ }
3070
+ if (targetHeight < height) {
3071
+ this.target._top = 0;
3072
+ }
3073
+ this.scroll();
3645
3074
  }
3075
+ });
3076
+ this.wheelHandler = (event) => {
3077
+ if (this.targetEnter)
3078
+ return;
3079
+ const { deltaX, deltaY, currentTarget } = event;
3080
+ if (currentTarget !== this.container)
3081
+ return;
3082
+ this.setScrollOffset(deltaX, deltaY);
3646
3083
  this.scroll();
3647
- }
3648
- });
3649
- constructor(options) {
3084
+ this.scrollLeft = this.target._left;
3085
+ this.scrollTop = this.target._top;
3086
+ };
3087
+ this.mouseEnterHandler = () => {
3088
+ this.enter = true;
3089
+ };
3090
+ this.mouseLeaveHandler = () => {
3091
+ this.enter = false;
3092
+ };
3093
+ this.targetMouseEnterHandler = () => {
3094
+ this.targetEnter = true;
3095
+ };
3096
+ this.targetMouseLeaveHandler = () => {
3097
+ this.targetEnter = false;
3098
+ };
3099
+ this.mousedownHandler = (event) => {
3100
+ if (!this.keydown)
3101
+ return;
3102
+ event.stopImmediatePropagation();
3103
+ event.stopPropagation();
3104
+ this.target.style.cursor = "grabbing";
3105
+ this.x = event.clientX;
3106
+ this.y = event.clientY;
3107
+ document.addEventListener("mousemove", this.mousemoveHandler);
3108
+ document.addEventListener("mouseup", this.mouseupHandler);
3109
+ };
3110
+ this.mouseupHandler = () => {
3111
+ this.x = 0;
3112
+ this.y = 0;
3113
+ this.scrollLeft = this.target._left;
3114
+ this.scrollTop = this.target._top;
3115
+ this.removeHandler();
3116
+ };
3117
+ this.mousemoveHandler = (event) => {
3118
+ event.stopImmediatePropagation();
3119
+ event.stopPropagation();
3120
+ const deltaX = event.clientX - this.x;
3121
+ const deltaY = event.clientY - this.y;
3122
+ this.setScrollOffset(deltaX, deltaY);
3123
+ this.scroll();
3124
+ };
3125
+ this.keydownHandler = (event) => {
3126
+ if (event.code === Keys.ESCAPE && this.enter) {
3127
+ event.preventDefault();
3128
+ event.stopImmediatePropagation();
3129
+ event.stopPropagation();
3130
+ }
3131
+ if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3132
+ return;
3133
+ }
3134
+ this.keydown = true;
3135
+ this.target.style.cursor = "grab";
3136
+ this.container.addEventListener("mousedown", this.mousedownHandler);
3137
+ };
3138
+ this.keyupHandler = (event) => {
3139
+ if (event.code !== Keys.ESCAPE || !this.keydown) {
3140
+ return;
3141
+ }
3142
+ event.preventDefault();
3143
+ event.stopImmediatePropagation();
3144
+ event.stopPropagation();
3145
+ this.keydown = false;
3146
+ event.preventDefault();
3147
+ this.removeHandler();
3148
+ };
3650
3149
  this.container = options.container;
3651
3150
  this.target = options.target;
3652
3151
  this.zoom = options.zoom;
@@ -3682,79 +3181,6 @@
3682
3181
  document.removeEventListener("mousemove", this.mousemoveHandler);
3683
3182
  document.removeEventListener("mouseup", this.mouseupHandler);
3684
3183
  }
3685
- wheelHandler = (event) => {
3686
- if (this.targetEnter)
3687
- return;
3688
- const { deltaX, deltaY, currentTarget } = event;
3689
- if (currentTarget !== this.container)
3690
- return;
3691
- this.setScrollOffset(deltaX, deltaY);
3692
- this.scroll();
3693
- this.scrollLeft = this.target._left;
3694
- this.scrollTop = this.target._top;
3695
- };
3696
- mouseEnterHandler = () => {
3697
- this.enter = true;
3698
- };
3699
- mouseLeaveHandler = () => {
3700
- this.enter = false;
3701
- };
3702
- targetMouseEnterHandler = () => {
3703
- this.targetEnter = true;
3704
- };
3705
- targetMouseLeaveHandler = () => {
3706
- this.targetEnter = false;
3707
- };
3708
- mousedownHandler = (event) => {
3709
- if (!this.keydown)
3710
- return;
3711
- event.stopImmediatePropagation();
3712
- event.stopPropagation();
3713
- this.target.style.cursor = "grabbing";
3714
- this.x = event.clientX;
3715
- this.y = event.clientY;
3716
- document.addEventListener("mousemove", this.mousemoveHandler);
3717
- document.addEventListener("mouseup", this.mouseupHandler);
3718
- };
3719
- mouseupHandler = () => {
3720
- this.x = 0;
3721
- this.y = 0;
3722
- this.scrollLeft = this.target._left;
3723
- this.scrollTop = this.target._top;
3724
- this.removeHandler();
3725
- };
3726
- mousemoveHandler = (event) => {
3727
- event.stopImmediatePropagation();
3728
- event.stopPropagation();
3729
- const deltaX = event.clientX - this.x;
3730
- const deltaY = event.clientY - this.y;
3731
- this.setScrollOffset(deltaX, deltaY);
3732
- this.scroll();
3733
- };
3734
- keydownHandler = (event) => {
3735
- if (event.code === Keys.ESCAPE && this.enter) {
3736
- event.preventDefault();
3737
- event.stopImmediatePropagation();
3738
- event.stopPropagation();
3739
- }
3740
- if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3741
- return;
3742
- }
3743
- this.keydown = true;
3744
- this.target.style.cursor = "grab";
3745
- this.container.addEventListener("mousedown", this.mousedownHandler);
3746
- };
3747
- keyupHandler = (event) => {
3748
- if (event.code !== Keys.ESCAPE || !this.keydown) {
3749
- return;
3750
- }
3751
- event.preventDefault();
3752
- event.stopImmediatePropagation();
3753
- event.stopPropagation();
3754
- this.keydown = false;
3755
- event.preventDefault();
3756
- this.removeHandler();
3757
- };
3758
3184
  setScrollOffset(deltaX, deltaY) {
3759
3185
  const { width, height } = this.container.getBoundingClientRect();
3760
3186
  const targetRect = this.target.getBoundingClientRect();
@@ -3815,19 +3241,19 @@
3815
3241
  el,
3816
3242
  style: vue.computed(() => `
3817
3243
  width: ${props.width}px;
3818
- height: ${props.height}px;
3244
+ height: ${(props.height || 0) - 40}px;
3819
3245
  position: absolute;
3820
3246
  margin-top: 30px;
3821
3247
  `)
3822
3248
  };
3823
3249
  }
3824
3250
  });
3825
- const _hoisted_1$2 = {
3251
+ const _hoisted_1$1 = {
3826
3252
  class: "m-editor-scroll-viewer-container",
3827
3253
  ref: "container"
3828
3254
  };
3829
3255
  function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3830
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
3256
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
3831
3257
  vue.createElementVNode("div", {
3832
3258
  ref: "el",
3833
3259
  style: vue.normalizeStyle(_ctx.style)
@@ -3839,7 +3265,7 @@
3839
3265
  var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
3840
3266
 
3841
3267
  const _sfc_main$3 = vue.defineComponent({
3842
- name: "magic-editor-ui-viewer-menu",
3268
+ components: { ContentMenu },
3843
3269
  setup() {
3844
3270
  const services = vue.inject("services");
3845
3271
  const editorService = services?.editorService;
@@ -3848,6 +3274,8 @@
3848
3274
  const canCenter = vue.ref(false);
3849
3275
  const node = vue.computed(() => editorService?.get("node"));
3850
3276
  const parent = vue.computed(() => editorService?.get("parent"));
3277
+ const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
3278
+ const stageContentMenu = vue.inject("stageContentMenu", []);
3851
3279
  vue.onMounted(() => {
3852
3280
  const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
3853
3281
  canPaste.value = data !== "undefined" && !!data;
@@ -3856,169 +3284,145 @@
3856
3284
  if (!parent.value || !editorService)
3857
3285
  return canCenter.value = false;
3858
3286
  const layout = await editorService.getLayout(parent.value);
3859
- canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && !["app", "page", "pop"].includes(`${node.value?.type}`);
3287
+ canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${node.value?.type}`);
3860
3288
  }, { immediate: true });
3861
3289
  return {
3862
3290
  menu,
3863
- canPaste,
3864
- canDelete: vue.computed(() => node.value?.type !== "page"),
3865
- canMoveZPos: vue.computed(() => node.value?.type !== "page"),
3866
- canCenter,
3867
- center() {
3868
- node.value && editorService?.alignCenter(node.value);
3869
- },
3870
- copy() {
3871
- node.value && editorService?.copy(node.value);
3872
- canPaste.value = true;
3873
- },
3874
- paste() {
3875
- const top = menu.value?.offsetTop || 0;
3876
- const left = menu.value?.offsetLeft || 0;
3877
- editorService?.paste({ left, top });
3878
- },
3879
- remove() {
3880
- node.value && editorService?.remove(node.value);
3881
- },
3882
- top() {
3883
- editorService?.moveLayer(LayerOffset.TOP);
3884
- },
3885
- bottom() {
3886
- editorService?.moveLayer(LayerOffset.BOTTOM);
3887
- },
3888
- topItem() {
3889
- editorService?.moveLayer(1);
3890
- },
3891
- bottomItem() {
3892
- editorService?.moveLayer(-1);
3893
- },
3894
- clearGuides() {
3895
- editorService?.get("stage").clearGuides();
3291
+ menuData: vue.reactive([
3292
+ {
3293
+ type: "button",
3294
+ text: "\u6C34\u5E73\u5C45\u4E2D",
3295
+ display: () => canCenter.value,
3296
+ handler: () => {
3297
+ node.value && editorService?.alignCenter(node.value);
3298
+ }
3299
+ },
3300
+ {
3301
+ type: "button",
3302
+ text: "\u590D\u5236",
3303
+ icon: vue.markRaw(icons.DocumentCopy),
3304
+ handler: () => {
3305
+ node.value && editorService?.copy(node.value);
3306
+ canPaste.value = true;
3307
+ }
3308
+ },
3309
+ {
3310
+ type: "button",
3311
+ text: "\u7C98\u8D34",
3312
+ display: () => canPaste.value,
3313
+ handler: () => {
3314
+ const stage = editorService?.get("stage");
3315
+ const rect = menu.value?.$el.getBoundingClientRect();
3316
+ const parentRect = stage?.container?.getBoundingClientRect();
3317
+ let left = (rect?.left || 0) - (parentRect?.left || 0);
3318
+ let top = (rect?.top || 0) - (parentRect?.top || 0);
3319
+ if (node.value?.items && stage) {
3320
+ const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
3321
+ const parentElRect = parentEl?.getBoundingClientRect();
3322
+ left = left - (parentElRect?.left || 0);
3323
+ top = top - (parentElRect?.top || 0);
3324
+ }
3325
+ editorService?.paste({ left, top });
3326
+ }
3327
+ },
3328
+ {
3329
+ type: "divider",
3330
+ direction: "horizontal",
3331
+ display: () => !isPage.value
3332
+ },
3333
+ {
3334
+ type: "button",
3335
+ text: "\u4E0A\u79FB\u4E00\u5C42",
3336
+ icon: vue.markRaw(icons.Top),
3337
+ display: () => !isPage.value,
3338
+ handler: () => {
3339
+ editorService?.moveLayer(1);
3340
+ }
3341
+ },
3342
+ {
3343
+ type: "button",
3344
+ text: "\u4E0B\u79FB\u4E00\u5C42",
3345
+ icon: vue.markRaw(icons.Bottom),
3346
+ display: () => !isPage.value,
3347
+ handler: () => {
3348
+ editorService?.moveLayer(-1);
3349
+ }
3350
+ },
3351
+ {
3352
+ type: "button",
3353
+ text: "\u7F6E\u9876",
3354
+ display: () => !isPage.value,
3355
+ handler: () => {
3356
+ editorService?.moveLayer(LayerOffset.TOP);
3357
+ }
3358
+ },
3359
+ {
3360
+ type: "button",
3361
+ text: "\u7F6E\u5E95",
3362
+ display: () => !isPage.value,
3363
+ handler: () => {
3364
+ editorService?.moveLayer(LayerOffset.BOTTOM);
3365
+ }
3366
+ },
3367
+ {
3368
+ type: "divider",
3369
+ direction: "horizontal",
3370
+ display: () => !isPage.value
3371
+ },
3372
+ {
3373
+ type: "button",
3374
+ text: "\u5220\u9664",
3375
+ icon: icons.Delete,
3376
+ display: () => !isPage.value,
3377
+ handler: () => {
3378
+ node.value && editorService?.remove(node.value);
3379
+ }
3380
+ },
3381
+ {
3382
+ type: "divider",
3383
+ direction: "horizontal"
3384
+ },
3385
+ {
3386
+ type: "button",
3387
+ text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
3388
+ handler: () => {
3389
+ editorService?.get("stage").clearGuides();
3390
+ }
3391
+ },
3392
+ ...stageContentMenu
3393
+ ]),
3394
+ show(e) {
3395
+ menu.value?.show(e);
3896
3396
  }
3897
3397
  };
3898
3398
  }
3899
3399
  });
3900
- const _hoisted_1$1 = {
3901
- class: "magic-editor-content-menu",
3902
- ref: "menu"
3903
- };
3904
- const _hoisted_2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3905
- const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3906
- const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3907
3400
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3908
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
3909
- vue.createElementVNode("div", null, [
3910
- _ctx.canCenter ? (vue.openBlock(), vue.createElementBlock("div", {
3911
- key: 0,
3912
- class: "magic-editor-content-menu-item",
3913
- onClick: _cache[0] || (_cache[0] = () => _ctx.center())
3914
- }, "\u6C34\u5E73\u5C45\u4E2D")) : vue.createCommentVNode("", true),
3915
- vue.createElementVNode("div", {
3916
- class: "magic-editor-content-menu-item",
3917
- onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
3918
- }, "\u590D\u5236"),
3919
- _ctx.canPaste ? (vue.openBlock(), vue.createElementBlock("div", {
3920
- key: 1,
3921
- class: "magic-editor-content-menu-item",
3922
- onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
3923
- }, "\u7C98\u8D34")) : vue.createCommentVNode("", true),
3924
- _ctx.canMoveZPos ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
3925
- _hoisted_2,
3926
- vue.createElementVNode("div", {
3927
- class: "magic-editor-content-menu-item",
3928
- onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
3929
- }, "\u4E0A\u79FB\u4E00\u5C42"),
3930
- vue.createElementVNode("div", {
3931
- class: "magic-editor-content-menu-item",
3932
- onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
3933
- }, "\u4E0B\u79FB\u4E00\u5C42"),
3934
- vue.createElementVNode("div", {
3935
- class: "magic-editor-content-menu-item",
3936
- onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
3937
- }, "\u7F6E\u9876"),
3938
- vue.createElementVNode("div", {
3939
- class: "magic-editor-content-menu-item",
3940
- onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
3941
- }, "\u7F6E\u5E95")
3942
- ], 64)) : vue.createCommentVNode("", true),
3943
- _ctx.canDelete ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
3944
- _hoisted_3,
3945
- vue.createElementVNode("div", {
3946
- class: "magic-editor-content-menu-item",
3947
- onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
3948
- }, "\u5220\u9664")
3949
- ], 64)) : vue.createCommentVNode("", true),
3950
- _hoisted_4,
3951
- vue.createElementVNode("div", {
3952
- class: "magic-editor-content-menu-item",
3953
- onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
3954
- }, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
3955
- ])
3956
- ], 512);
3401
+ const _component_content_menu = vue.resolveComponent("content-menu");
3402
+ return vue.openBlock(), vue.createBlock(_component_content_menu, {
3403
+ "menu-data": _ctx.menuData,
3404
+ ref: "menu"
3405
+ }, null, 8, ["menu-data"]);
3957
3406
  }
3958
3407
  var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
3959
3408
 
3960
- const useMenu = () => {
3961
- const menu = vue.ref();
3962
- const menuStyle = vue.ref({
3963
- display: "none",
3964
- left: "0",
3965
- top: "0"
3966
- });
3967
- vue.onMounted(() => {
3968
- document.addEventListener("click", () => {
3969
- menuStyle.value.display = "none";
3970
- }, true);
3971
- });
3972
- return {
3973
- menu,
3974
- menuStyle,
3975
- contextmenuHandler(e) {
3976
- e.preventDefault();
3977
- const menuHeight = menu.value?.$el.clientHeight;
3978
- let top = e.clientY;
3979
- if (menuHeight + e.clientY > document.body.clientHeight) {
3980
- top = document.body.clientHeight - menuHeight;
3981
- }
3982
- menuStyle.value = {
3983
- display: "block",
3984
- top: `${top}px`,
3985
- left: `${e.clientX}px`
3986
- };
3987
- }
3988
- };
3989
- };
3990
3409
  const _sfc_main$2 = vue.defineComponent({
3991
3410
  name: "magic-stage",
3992
3411
  components: {
3993
3412
  ViewerMenu,
3994
3413
  ScrollViewer
3995
3414
  },
3996
- props: {
3997
- render: {
3998
- type: Function
3999
- },
4000
- runtimeUrl: String,
4001
- canSelect: {
4002
- type: Function,
4003
- default: (el) => Boolean(el.id)
4004
- },
4005
- moveableOptions: {
4006
- type: [Object, Function],
4007
- default: () => (core) => ({
4008
- container: core?.renderer?.contentWindow?.document.getElementById("app")
4009
- })
4010
- }
4011
- },
4012
- emits: ["select", "update", "sort"],
4013
- setup(props, { emit }) {
3415
+ setup() {
4014
3416
  const services = vue.inject("services");
3417
+ const stageOptions = vue.inject("stageOptions");
4015
3418
  const stageWrap = vue.ref();
4016
3419
  const stageContainer = vue.ref();
3420
+ const menu = vue.ref();
4017
3421
  const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
4018
3422
  const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
4019
3423
  const root = vue.computed(() => services?.editorService.get("root"));
4020
3424
  const page = vue.computed(() => services?.editorService.get("page"));
4021
- const zoom = vue.computed(() => services?.uiService.get("zoom"));
3425
+ const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
4022
3426
  const node = vue.computed(() => services?.editorService.get("node"));
4023
3427
  let stage = null;
4024
3428
  let runtime = null;
@@ -4027,30 +3431,37 @@
4027
3431
  return;
4028
3432
  if (!stageContainer.value)
4029
3433
  return;
4030
- if (!(props.runtimeUrl || props.render) || !root.value)
3434
+ if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
4031
3435
  return;
4032
3436
  stage = new StageCore__default["default"]({
4033
- render: props.render,
4034
- runtimeUrl: props.runtimeUrl,
3437
+ render: stageOptions.render,
3438
+ runtimeUrl: stageOptions.runtimeUrl,
4035
3439
  zoom: zoom.value,
4036
- canSelect: (el, stop) => {
4037
- const elCanSelect = props.canSelect(el);
4038
- if (uiSelectMode.value && elCanSelect) {
3440
+ autoScrollIntoView: stageOptions.autoScrollIntoView,
3441
+ canSelect: (el, event, stop) => {
3442
+ const elCanSelect = stageOptions.canSelect(el);
3443
+ if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
4039
3444
  document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
4040
3445
  return stop();
4041
3446
  }
4042
3447
  return elCanSelect;
4043
3448
  },
4044
- moveableOptions: props.moveableOptions
3449
+ moveableOptions: stageOptions.moveableOptions,
3450
+ updateDragEl: stageOptions.updateDragEl
4045
3451
  });
4046
- services?.editorService.set("stage", stage);
3452
+ services?.editorService.set("stage", vue.markRaw(stage));
4047
3453
  stage?.mount(stageContainer.value);
4048
- stage?.on("select", (el) => emit("select", el));
3454
+ stage?.on("select", (el) => {
3455
+ services?.editorService.select(el.id);
3456
+ });
3457
+ stage?.on("highlight", (el) => {
3458
+ services?.editorService.highlight(el.id);
3459
+ });
4049
3460
  stage?.on("update", (ev) => {
4050
- emit("update", { id: ev.el.id, style: ev.style });
3461
+ services?.editorService.update({ id: ev.el.id, style: ev.style });
4051
3462
  });
4052
3463
  stage?.on("sort", (ev) => {
4053
- emit("sort", ev);
3464
+ services?.editorService.sort(ev.src, ev.dist);
4054
3465
  });
4055
3466
  stage?.on("changeGuides", () => {
4056
3467
  services?.uiService.set("showGuides", true);
@@ -4076,11 +3487,6 @@
4076
3487
  runtime.updateRootConfig(lodashEs.cloneDeep(vue.toRaw(root2)));
4077
3488
  }
4078
3489
  });
4079
- vue.watch(() => node.value?.id, (id) => {
4080
- vue.nextTick(() => {
4081
- id && stage?.select(id);
4082
- });
4083
- });
4084
3490
  const resizeObserver = new ResizeObserver((entries) => {
4085
3491
  for (const { contentRect } of entries) {
4086
3492
  services?.uiService.set("stageContainerRect", {
@@ -4100,9 +3506,37 @@
4100
3506
  return {
4101
3507
  stageWrap,
4102
3508
  stageContainer,
3509
+ menu,
4103
3510
  stageRect,
4104
3511
  zoom,
4105
- ...useMenu()
3512
+ contextmenuHandler(e2) {
3513
+ e2.preventDefault();
3514
+ menu.value?.show(e2);
3515
+ },
3516
+ dragoverHandler(e2) {
3517
+ e2.preventDefault();
3518
+ if (e2.dataTransfer) {
3519
+ e2.dataTransfer.dropEffect = "move";
3520
+ }
3521
+ },
3522
+ async dropHandler(e) {
3523
+ e.preventDefault();
3524
+ if (e.dataTransfer && page.value && stageContainer.value && stage) {
3525
+ const config = eval(`(${e.dataTransfer.getData("data")})`);
3526
+ const layout = await services?.editorService.getLayout(page.value);
3527
+ const containerRect = stageContainer.value.getBoundingClientRect();
3528
+ const { scrollTop, scrollLeft } = stage.mask;
3529
+ if (layout === Layout.ABSOLUTE) {
3530
+ config.style = {
3531
+ ...config.style || {},
3532
+ position: "absolute",
3533
+ top: e.clientY - containerRect.top + scrollTop,
3534
+ left: e.clientX - containerRect.left + scrollLeft
3535
+ };
3536
+ }
3537
+ services?.editorService.add(config, page.value);
3538
+ }
3539
+ }
4106
3540
  };
4107
3541
  }
4108
3542
  });
@@ -4120,14 +3554,13 @@
4120
3554
  vue.createElementVNode("div", {
4121
3555
  class: "m-editor-stage-container",
4122
3556
  ref: "stageContainer",
3557
+ style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
4123
3558
  onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
4124
- style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`)
3559
+ onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
3560
+ onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
4125
3561
  }, null, 36),
4126
3562
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
4127
- vue.createVNode(_component_viewer_menu, {
4128
- ref: "menu",
4129
- style: vue.normalizeStyle(_ctx.menuStyle)
4130
- }, null, 8, ["style"])
3563
+ vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
4131
3564
  ]))
4132
3565
  ]),
4133
3566
  _: 1
@@ -4141,49 +3574,118 @@
4141
3574
  PageBar,
4142
3575
  MagicStage
4143
3576
  },
4144
- props: {
4145
- runtimeUrl: String,
4146
- render: {
4147
- type: Function
4148
- },
4149
- moveableOptions: {
4150
- type: [Object, Function]
4151
- },
4152
- canSelect: {
4153
- type: Function
4154
- }
4155
- },
4156
3577
  setup() {
4157
3578
  const services = vue.inject("services");
3579
+ const workspace = vue.ref();
3580
+ const node = vue.computed(() => services?.editorService.get("node"));
3581
+ let keycon;
3582
+ const mouseenterHandler = () => {
3583
+ workspace.value?.focus();
3584
+ };
3585
+ const mouseleaveHandler = () => {
3586
+ workspace.value?.blur();
3587
+ };
3588
+ vue.onMounted(() => {
3589
+ workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3590
+ workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
3591
+ keycon = new KeyController__default["default"](workspace.value);
3592
+ const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
3593
+ const ctrl = isMac ? "meta" : "ctrl";
3594
+ keycon.keyup("delete", (e) => {
3595
+ e.inputEvent.preventDefault();
3596
+ if (!node.value || utils.isPage(node.value))
3597
+ return;
3598
+ services?.editorService.remove(node.value);
3599
+ }).keyup("backspace", (e) => {
3600
+ e.inputEvent.preventDefault();
3601
+ if (!node.value || utils.isPage(node.value))
3602
+ return;
3603
+ services?.editorService.remove(node.value);
3604
+ }).keydown([ctrl, "c"], (e) => {
3605
+ e.inputEvent.preventDefault();
3606
+ node.value && services?.editorService.copy(node.value);
3607
+ }).keydown([ctrl, "v"], (e) => {
3608
+ e.inputEvent.preventDefault();
3609
+ node.value && services?.editorService.paste();
3610
+ }).keydown([ctrl, "x"], (e) => {
3611
+ e.inputEvent.preventDefault();
3612
+ if (!node.value || utils.isPage(node.value))
3613
+ return;
3614
+ services?.editorService.copy(node.value);
3615
+ services?.editorService.remove(node.value);
3616
+ }).keydown([ctrl, "z"], (e) => {
3617
+ e.inputEvent.preventDefault();
3618
+ services?.editorService.undo();
3619
+ }).keydown([ctrl, "shift", "z"], (e) => {
3620
+ e.inputEvent.preventDefault();
3621
+ services?.editorService.redo();
3622
+ }).keydown("up", (e) => {
3623
+ e.inputEvent.preventDefault();
3624
+ services?.editorService.move(0, -1);
3625
+ }).keydown("down", (e) => {
3626
+ e.inputEvent.preventDefault();
3627
+ services?.editorService.move(0, 1);
3628
+ }).keydown("left", (e) => {
3629
+ e.inputEvent.preventDefault();
3630
+ services?.editorService.move(-1, 0);
3631
+ }).keydown("right", (e) => {
3632
+ e.inputEvent.preventDefault();
3633
+ services?.editorService.move(1, 0);
3634
+ }).keydown([ctrl, "up"], (e) => {
3635
+ e.inputEvent.preventDefault();
3636
+ services?.editorService.move(0, -10);
3637
+ }).keydown([ctrl, "down"], (e) => {
3638
+ e.inputEvent.preventDefault();
3639
+ services?.editorService.move(0, 10);
3640
+ }).keydown([ctrl, "left"], (e) => {
3641
+ e.inputEvent.preventDefault();
3642
+ services?.editorService.move(-10, 0);
3643
+ }).keydown([ctrl, "right"], (e) => {
3644
+ e.inputEvent.preventDefault();
3645
+ services?.editorService.move(10, 0);
3646
+ }).keydown("tab", (e) => {
3647
+ e.inputEvent.preventDefault();
3648
+ services?.editorService.selectNextNode();
3649
+ }).keydown([ctrl, "tab"], (e) => {
3650
+ e.inputEvent.preventDefault();
3651
+ services?.editorService.selectNextPage();
3652
+ }).keydown([ctrl, "="], (e) => {
3653
+ e.inputEvent.preventDefault();
3654
+ services?.uiService.zoom(0.1);
3655
+ }).keydown([ctrl, "numpadplus"], (e) => {
3656
+ e.inputEvent.preventDefault();
3657
+ services?.uiService.zoom(0.1);
3658
+ }).keydown([ctrl, "-"], (e) => {
3659
+ e.inputEvent.preventDefault();
3660
+ services?.uiService.zoom(-0.1);
3661
+ }).keydown([ctrl, "numpad-"], (e) => {
3662
+ e.inputEvent.preventDefault();
3663
+ services?.uiService.zoom(-0.1);
3664
+ });
3665
+ });
3666
+ vue.onUnmounted(() => {
3667
+ workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
3668
+ workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
3669
+ keycon.destroy();
3670
+ });
4158
3671
  return {
4159
- page: vue.computed(() => services?.editorService.get("page")),
4160
- selectHandler(el) {
4161
- services?.editorService.select(el.id);
4162
- },
4163
- updateNodeHandler(node) {
4164
- services?.editorService.update(node);
4165
- },
4166
- sortNodeHandler(ev) {
4167
- services?.editorService.sort(ev.src, ev.dist);
4168
- }
3672
+ workspace,
3673
+ page: vue.computed(() => services?.editorService.get("page"))
4169
3674
  };
4170
3675
  }
4171
3676
  });
4172
- const _hoisted_1 = { class: "m-editor-workspace" };
3677
+ const _hoisted_1 = {
3678
+ class: "m-editor-workspace",
3679
+ tabindex: "1",
3680
+ ref: "workspace"
3681
+ };
4173
3682
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4174
3683
  const _component_magic_stage = vue.resolveComponent("magic-stage");
4175
3684
  const _component_page_bar = vue.resolveComponent("page-bar");
4176
3685
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
4177
3686
  (vue.openBlock(), vue.createBlock(_component_magic_stage, {
4178
- key: _ctx.page?.id,
4179
- "runtime-url": _ctx.runtimeUrl,
4180
- render: _ctx.render,
4181
- "moveable-options": _ctx.moveableOptions,
4182
- "can-select": _ctx.canSelect,
4183
- onSelect: _ctx.selectHandler,
4184
- onUpdate: _ctx.updateNodeHandler,
4185
- onSort: _ctx.sortNodeHandler
4186
- }, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
3687
+ key: _ctx.page?.id
3688
+ })),
4187
3689
  vue.renderSlot(_ctx.$slots, "workspace-content"),
4188
3690
  vue.createVNode(_component_page_bar, null, {
4189
3691
  "page-bar-title": vue.withCtx(({ page }) => [
@@ -4194,16 +3696,16 @@
4194
3696
  ]),
4195
3697
  _: 3
4196
3698
  })
4197
- ]);
3699
+ ], 512);
4198
3700
  }
4199
3701
  var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4200
3702
 
4201
3703
  class ComponentList extends BaseService {
4202
- state = vue.reactive({
4203
- list: []
4204
- });
4205
3704
  constructor() {
4206
3705
  super([]);
3706
+ this.state = vue.reactive({
3707
+ list: []
3708
+ });
4207
3709
  }
4208
3710
  setList(componentGroupList) {
4209
3711
  this.state.list = componentGroupList;
@@ -4214,6 +3716,14 @@
4214
3716
  }
4215
3717
  var componentListService = new ComponentList();
4216
3718
 
3719
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3720
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
3721
+ const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
3722
+ const defaultColumnWidth = {
3723
+ left: DEFAULT_LEFT_COLUMN_WIDTH,
3724
+ center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
3725
+ right: DEFAULT_RIGHT_COLUMN_WIDTH
3726
+ };
4217
3727
  const state = vue.reactive({
4218
3728
  uiSelectMode: false,
4219
3729
  showSrc: false,
@@ -4226,13 +3736,10 @@
4226
3736
  width: 375,
4227
3737
  height: 817
4228
3738
  },
4229
- columnWidth: {
4230
- left: 310,
4231
- center: globalThis.document.body.clientWidth - 310 - 400,
4232
- right: 400
4233
- },
3739
+ columnWidth: defaultColumnWidth,
4234
3740
  showGuides: true,
4235
- showRule: true
3741
+ showRule: true,
3742
+ propsPanelSize: "small"
4236
3743
  });
4237
3744
  class Ui extends BaseService {
4238
3745
  constructor() {
@@ -4242,6 +3749,15 @@
4242
3749
  center: "auto"
4243
3750
  });
4244
3751
  });
3752
+ const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
3753
+ if (columnWidthCacheData) {
3754
+ try {
3755
+ const columnWidthCache = JSON.parse(columnWidthCacheData);
3756
+ this.setColumnWidth(columnWidthCache);
3757
+ } catch (e) {
3758
+ console.error(e);
3759
+ }
3760
+ }
4245
3761
  }
4246
3762
  set(name, value) {
4247
3763
  const mask = editorService.get("stage")?.mask;
@@ -4267,6 +3783,11 @@
4267
3783
  get(name) {
4268
3784
  return state[name];
4269
3785
  }
3786
+ zoom(zoom) {
3787
+ this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
3788
+ if (this.get("zoom") < 0.1)
3789
+ this.set("zoom", 0.1);
3790
+ }
4270
3791
  setColumnWidth({ left, center, right }) {
4271
3792
  const columnWidth = {
4272
3793
  ...vue.toRaw(this.get("columnWidth"))
@@ -4280,9 +3801,15 @@
4280
3801
  if (!center || center === "auto") {
4281
3802
  const bodyWidth = globalThis.document.body.clientWidth;
4282
3803
  columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
3804
+ if (columnWidth.center <= 0) {
3805
+ columnWidth.left = defaultColumnWidth.left;
3806
+ columnWidth.center = defaultColumnWidth.center;
3807
+ columnWidth.right = defaultColumnWidth.right;
3808
+ }
4283
3809
  } else {
4284
3810
  columnWidth.center = center;
4285
3811
  }
3812
+ globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
4286
3813
  state.columnWidth = columnWidth;
4287
3814
  }
4288
3815
  setStageRect(value) {
@@ -4327,6 +3854,14 @@
4327
3854
  sidebar: {
4328
3855
  type: Object
4329
3856
  },
3857
+ layerContentMenu: {
3858
+ type: Array,
3859
+ default: () => []
3860
+ },
3861
+ stageContentMenu: {
3862
+ type: Array,
3863
+ default: () => []
3864
+ },
4330
3865
  menu: {
4331
3866
  type: Object,
4332
3867
  default: () => ({ left: [], right: [] })
@@ -4335,6 +3870,7 @@
4335
3870
  type: Function
4336
3871
  },
4337
3872
  runtimeUrl: String,
3873
+ autoScrollIntoView: Boolean,
4338
3874
  propsConfigs: {
4339
3875
  type: Object,
4340
3876
  default: () => ({})
@@ -4348,16 +3884,27 @@
4348
3884
  default: () => ({})
4349
3885
  },
4350
3886
  moveableOptions: {
4351
- type: [Object, Function]
3887
+ type: [Object, Function],
3888
+ default: () => (core) => ({
3889
+ container: core?.renderer?.contentWindow?.document.getElementById("app")
3890
+ })
4352
3891
  },
4353
3892
  defaultSelected: {
4354
3893
  type: [Number, String]
4355
3894
  },
4356
3895
  canSelect: {
4357
- type: Function
3896
+ type: Function,
3897
+ default: (el) => Boolean(el.id)
4358
3898
  },
4359
3899
  stageRect: {
4360
3900
  type: [String, Object]
3901
+ },
3902
+ codeOptions: {
3903
+ type: Object,
3904
+ default: () => ({})
3905
+ },
3906
+ updateDragEl: {
3907
+ type: Function
4361
3908
  }
4362
3909
  },
4363
3910
  emits: ["props-panel-mounted", "update:modelValue"],
@@ -4407,6 +3954,16 @@
4407
3954
  uiService
4408
3955
  };
4409
3956
  vue.provide("services", services);
3957
+ vue.provide("layerContentMenu", props.layerContentMenu);
3958
+ vue.provide("stageContentMenu", props.stageContentMenu);
3959
+ vue.provide("stageOptions", vue.reactive({
3960
+ runtimeUrl: props.runtimeUrl,
3961
+ autoScrollIntoView: props.autoScrollIntoView,
3962
+ render: props.render,
3963
+ moveableOptions: props.moveableOptions,
3964
+ canSelect: props.canSelect,
3965
+ updateDragEl: props.updateDragEl
3966
+ }));
4410
3967
  return services;
4411
3968
  }
4412
3969
  });
@@ -4416,7 +3973,7 @@
4416
3973
  const _component_workspace = vue.resolveComponent("workspace");
4417
3974
  const _component_props_panel = vue.resolveComponent("props-panel");
4418
3975
  const _component_framework = vue.resolveComponent("framework");
4419
- return vue.openBlock(), vue.createBlock(_component_framework, null, {
3976
+ return vue.openBlock(), vue.createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
4420
3977
  nav: vue.withCtx(() => [
4421
3978
  vue.renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
4422
3979
  vue.createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
@@ -4429,12 +3986,7 @@
4429
3986
  ]),
4430
3987
  workspace: vue.withCtx(() => [
4431
3988
  vue.renderSlot(_ctx.$slots, "workspace", {}, () => [
4432
- vue.createVNode(_component_workspace, {
4433
- "runtime-url": _ctx.runtimeUrl,
4434
- render: _ctx.render,
4435
- "moveable-options": _ctx.moveableOptions,
4436
- "can-select": _ctx.canSelect
4437
- }, {
3989
+ vue.createVNode(_component_workspace, null, {
4438
3990
  "workspace-content": vue.withCtx(() => [
4439
3991
  vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
4440
3992
  ]),
@@ -4445,7 +3997,7 @@
4445
3997
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
4446
3998
  ]),
4447
3999
  _: 3
4448
- }, 8, ["runtime-url", "render", "moveable-options", "can-select"])
4000
+ })
4449
4001
  ])
4450
4002
  ]),
4451
4003
  propsPanel: vue.withCtx(() => [
@@ -4460,11 +4012,11 @@
4460
4012
  vue.renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
4461
4013
  ]),
4462
4014
  _: 3
4463
- });
4015
+ }, 8, ["code-options"]);
4464
4016
  }
4465
4017
  var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
4466
4018
 
4467
- var index$1 = '';
4019
+ 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}\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}")();
4468
4020
 
4469
4021
  const defaultInstallOpt = {};
4470
4022
  var index = {
@@ -4491,6 +4043,7 @@
4491
4043
  exports.PropsPanel = PropsPanel;
4492
4044
  exports.TMagicCodeEditor = CodeEditor;
4493
4045
  exports.TMagicEditor = Editor;
4046
+ exports.ToolButton = ToolButton;
4494
4047
  exports.change2Fixed = change2Fixed;
4495
4048
  exports.debug = debug;
4496
4049
  exports["default"] = index;
@@ -4498,7 +4051,6 @@
4498
4051
  exports.error = error;
4499
4052
  exports.eventsService = eventsService;
4500
4053
  exports.fillConfig = fillConfig;
4501
- exports.generateId = generateId;
4502
4054
  exports.generatePageName = generatePageName;
4503
4055
  exports.generatePageNameByApp = generatePageNameByApp;
4504
4056
  exports.getConfig = getConfig;
@@ -4514,13 +4066,11 @@
4514
4066
  exports.propsService = propsService;
4515
4067
  exports.setConfig = setConfig;
4516
4068
  exports.setLayout = setLayout;
4517
- exports.setNewItemId = setNewItemId;
4518
4069
  exports.toRelative = toRelative;
4519
4070
  exports.uiService = uiService;
4520
4071
  exports.warn = warn;
4521
4072
 
4522
- Object.defineProperty(exports, '__esModule', { value: true });
4523
- exports[Symbol.toStringTag] = 'Module';
4073
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4524
4074
 
4525
4075
  }));
4526
4076
  //# sourceMappingURL=tmagic-editor.umd.js.map