@tmagic/editor 1.0.0-beta.9 → 1.0.0-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +1 -0
  2. package/dist/style.css +72 -36
  3. package/dist/tmagic-editor.es.js +1555 -2080
  4. package/dist/tmagic-editor.es.js.map +1 -1
  5. package/dist/tmagic-editor.umd.js +1555 -2082
  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 -32
  18. package/dist/types/src/services/BaseService.d.ts +5 -2
  19. package/dist/types/src/services/editor.d.ts +11 -5
  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 +24 -9
  24. package/dist/types/src/utils/editor.d.ts +4 -9
  25. package/dist/types/src/utils/polyfills.d.ts +0 -0
  26. package/dist/types/src/utils/props.d.ts +10 -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 +69 -30
  32. package/src/fields/UISelect.vue +14 -6
  33. package/src/index.ts +2 -0
  34. package/src/layouts/CodeEditor.vue +20 -13
  35. package/src/layouts/Framework.vue +20 -7
  36. package/src/layouts/PropsPanel.vue +5 -4
  37. package/src/layouts/sidebar/ComponentListPanel.vue +25 -3
  38. package/src/layouts/sidebar/LayerMenu.vue +93 -95
  39. package/src/layouts/sidebar/LayerPanel.vue +31 -54
  40. package/src/layouts/sidebar/Sidebar.vue +13 -52
  41. package/src/layouts/sidebar/TabPane.vue +68 -0
  42. package/src/layouts/workspace/PageBar.vue +136 -13
  43. package/src/layouts/workspace/Stage.vue +62 -104
  44. package/src/layouts/workspace/ViewerMenu.vue +119 -67
  45. package/src/layouts/workspace/Workspace.vue +124 -46
  46. package/src/services/BaseService.ts +71 -23
  47. package/src/services/editor.ts +196 -52
  48. package/src/services/history.ts +7 -0
  49. package/src/services/props.ts +64 -9
  50. package/src/services/ui.ts +35 -5
  51. package/src/theme/common/var.scss +1 -0
  52. package/src/theme/component-list-panel.scss +2 -0
  53. package/src/theme/content-menu.scss +33 -26
  54. package/src/theme/layer-panel.scss +2 -1
  55. package/src/theme/nav-menu.scss +6 -2
  56. package/src/theme/page-bar.scss +36 -3
  57. package/src/theme/props-panel.scss +19 -17
  58. package/src/theme/workspace.scss +4 -0
  59. package/src/type.ts +26 -9
  60. package/src/utils/editor.ts +35 -55
  61. package/src/utils/polyfills.ts +8 -0
  62. package/src/utils/props.ts +51 -8
  63. package/LICENSE +0 -5432
  64. package/dist/types/src/components/ToolButton.vue.d.ts +0 -35
  65. package/dist/types/src/fields/UISelect.vue.d.ts +0 -32
  66. package/dist/types/src/layouts/sidebar/LayerMenu.vue.d.ts +0 -31
  67. package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -979
  68. package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +0 -11
  69. package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -193
  70. package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
  71. package/tsconfig.json +0 -9
  72. 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('@tmagic/schema'), 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', '@tmagic/schema', '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.schema, global.lodashEs, global.utils, global.events, global.core, global.elementPlus, global.StageCore));
5
- })(this, (function (exports, vue, serialize, monaco, icons, schema, 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$e = /* @__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$e
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$d = {
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$d, 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,7 +742,6 @@
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
747
  return app.items.filter((item) => item.type === schema.NodeType.PAGE);
@@ -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 === schema.NodeType.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,16 +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
- highlightNode: null,
785
- modifiedNodeIds: /* @__PURE__ */ new Map()
786
- });
787
882
  constructor() {
788
883
  super([
789
884
  "getLayout",
@@ -796,22 +891,38 @@
796
891
  "paste",
797
892
  "alignCenter",
798
893
  "moveLayer",
894
+ "move",
799
895
  "undo",
800
896
  "redo",
801
897
  "highlight"
802
- ]);
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
+ });
803
910
  }
804
911
  set(name, value) {
805
912
  this.state[name] = value;
806
913
  if (name === "root") {
914
+ this.state.pageLength = value?.items?.length || 0;
807
915
  this.emit("root-change", value);
808
916
  }
809
917
  }
810
918
  get(name) {
811
919
  return this.state[name];
812
920
  }
813
- getNodeInfo(id) {
814
- const root = this.get("root");
921
+ getNodeInfo(id, raw = true) {
922
+ let root = this.get("root");
923
+ if (raw) {
924
+ root = vue.toRaw(root);
925
+ }
815
926
  if (!root)
816
927
  return {};
817
928
  if (id === root.id) {
@@ -832,21 +943,23 @@
832
943
  });
833
944
  return info;
834
945
  }
835
- getNodeById(id) {
836
- const { node } = this.getNodeInfo(id);
946
+ getNodeById(id, raw = true) {
947
+ const { node } = this.getNodeInfo(id, raw);
837
948
  return node;
838
949
  }
839
- getParentById(id) {
950
+ getParentById(id, raw = true) {
840
951
  if (!this.get("root"))
841
952
  return;
842
- const { parent } = this.getNodeInfo(id);
953
+ const { parent } = this.getNodeInfo(id, raw);
843
954
  return parent;
844
955
  }
845
- async getLayout(node) {
846
- if (node.layout) {
847
- return node.layout;
956
+ async getLayout(parent, node) {
957
+ if (node && typeof node !== "function" && isFixed(node))
958
+ return Layout.FIXED;
959
+ if (parent.layout) {
960
+ return parent.layout;
848
961
  }
849
- if (!node.style?.position) {
962
+ if (!parent.style?.position) {
850
963
  return Layout.RELATIVE;
851
964
  }
852
965
  return Layout.ABSOLUTE;
@@ -861,41 +974,79 @@
861
974
  } else {
862
975
  historyService.empty();
863
976
  }
977
+ if (node?.id) {
978
+ this.get("stage")?.renderer.runtime?.getApp?.()?.emit("editor:select", {
979
+ node,
980
+ page,
981
+ parent
982
+ }, utils.getNodePath(node.id, this.get("root").items));
983
+ }
984
+ this.emit("select", node);
864
985
  return node;
865
986
  }
987
+ async selectNextNode() {
988
+ const node = vue.toRaw(this.get("node"));
989
+ if (!node || utils.isPage(node) || node.type === schema.NodeType.ROOT)
990
+ return node;
991
+ const parent = vue.toRaw(this.getParentById(node.id));
992
+ if (!parent)
993
+ return node;
994
+ const index = getNodeIndex(node, parent);
995
+ const nextNode = parent.items[index + 1] || parent.items[0];
996
+ await this.select(nextNode);
997
+ this.get("stage")?.select(nextNode.id);
998
+ return nextNode;
999
+ }
1000
+ async selectNextPage() {
1001
+ const root = vue.toRaw(this.get("root"));
1002
+ const page = vue.toRaw(this.get("page"));
1003
+ const index = getNodeIndex(page, root);
1004
+ const nextPage = root.items[index + 1] || root.items[0];
1005
+ await this.select(nextPage);
1006
+ this.get("stage")?.select(nextPage.id);
1007
+ return nextPage;
1008
+ }
866
1009
  highlight(config2) {
867
1010
  const { node } = this.selectedConfigExceptionHandler(config2);
868
- const currentHighligtNode = this.get("highlightNode");
869
- if (currentHighligtNode === node)
1011
+ const currentHighlightNode = this.get("highlightNode");
1012
+ if (currentHighlightNode === node)
870
1013
  return;
871
1014
  this.set("highlightNode", node);
872
1015
  }
873
- async add({ type, ...config2 }, parent) {
1016
+ async add(addNode, parent) {
1017
+ const { type, ...config2 } = addNode;
874
1018
  const curNode = this.get("node");
875
1019
  let parentNode;
876
- if (type === schema.NodeType.PAGE) {
1020
+ const isPage2 = type === schema.NodeType.PAGE;
1021
+ if (isPage2) {
877
1022
  parentNode = this.get("root");
878
1023
  } else if (parent && typeof parent !== "function") {
879
1024
  parentNode = parent;
880
1025
  } else if (curNode.items) {
881
1026
  parentNode = curNode;
882
1027
  } else {
883
- parentNode = this.getParentById(curNode.id);
1028
+ parentNode = this.getParentById(curNode.id, false);
884
1029
  }
885
1030
  if (!parentNode)
886
1031
  throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
887
- const layout = await this.getLayout(parentNode);
888
- const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type)), ...config2 }, layout);
1032
+ const layout = await this.getLayout(vue.toRaw(parentNode), addNode);
1033
+ const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type, config2)) }, layout, parentNode, this.get("stage"));
889
1034
  if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
890
1035
  throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
891
1036
  }
892
1037
  parentNode?.items?.push(newNode);
893
- await this.get("stage")?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(this.get("root")) });
1038
+ const stage = this.get("stage");
1039
+ await stage?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(this.get("root")) });
894
1040
  await this.select(newNode);
895
1041
  this.addModifiedNodeId(newNode.id);
896
- if (type !== schema.NodeType.PAGE) {
1042
+ if (!isPage2) {
897
1043
  this.pushHistoryState();
898
1044
  }
1045
+ stage?.select(newNode.id);
1046
+ if (isPage2) {
1047
+ this.state.pageLength += 1;
1048
+ }
1049
+ this.emit("add", newNode);
899
1050
  return newNode;
900
1051
  }
901
1052
  async remove(node) {
@@ -904,27 +1055,44 @@
904
1055
  const root = this.get("root");
905
1056
  if (!root)
906
1057
  throw new Error("\u6CA1\u6709root");
907
- const { parent, node: curNode } = this.getNodeInfo(node.id);
1058
+ const { parent, node: curNode } = this.getNodeInfo(node.id, false);
908
1059
  if (!parent || !curNode)
909
1060
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
910
1061
  const index = getNodeIndex(curNode, parent);
911
1062
  if (typeof index !== "number" || index === -1)
912
1063
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
913
1064
  parent.items?.splice(index, 1);
914
- this.get("stage")?.remove({ id: node.id, root: this.get("root") });
1065
+ const stage = this.get("stage");
1066
+ stage?.remove({ id: node.id, root: this.get("root") });
915
1067
  if (node.type === schema.NodeType.PAGE) {
916
- await this.select(root.items[0] || root);
1068
+ this.state.pageLength -= 1;
1069
+ if (root.items[0]) {
1070
+ await this.select(root.items[0]);
1071
+ stage?.select(root.items[0].id);
1072
+ } else {
1073
+ this.set("node", null);
1074
+ this.set("parent", null);
1075
+ this.set("page", null);
1076
+ this.set("stage", null);
1077
+ this.set("highlightNode", null);
1078
+ this.resetModifiedNodeId();
1079
+ historyService.reset();
1080
+ this.emit("remove", node);
1081
+ return node;
1082
+ }
917
1083
  } else {
918
1084
  await this.select(parent);
1085
+ stage?.select(parent.id);
919
1086
  }
920
1087
  this.addModifiedNodeId(parent.id);
921
1088
  this.pushHistoryState();
1089
+ this.emit("remove", node);
922
1090
  return node;
923
1091
  }
924
1092
  async update(config2) {
925
1093
  if (!config2?.id)
926
1094
  throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
927
- const info = this.getNodeInfo(config2.id);
1095
+ const info = this.getNodeInfo(config2.id, false);
928
1096
  if (!info.node)
929
1097
  throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
930
1098
  const node = lodashEs.cloneDeep(vue.toRaw(info.node));
@@ -953,7 +1121,7 @@
953
1121
  newConfig = setLayout(newConfig, newLayout);
954
1122
  }
955
1123
  parentNodeItems[index] = newConfig;
956
- if (newConfig.id === this.get("node").id) {
1124
+ if (`${newConfig.id}` === `${this.get("node").id}`) {
957
1125
  this.set("node", newConfig);
958
1126
  }
959
1127
  this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: this.get("root") });
@@ -962,6 +1130,7 @@
962
1130
  }
963
1131
  this.addModifiedNodeId(newConfig.id);
964
1132
  this.pushHistoryState();
1133
+ this.emit("update", newConfig);
965
1134
  return newConfig;
966
1135
  }
967
1136
  async sort(id1, id2) {
@@ -993,23 +1162,36 @@
993
1162
  console.error(e);
994
1163
  return;
995
1164
  }
996
- setNewItemId(config, this.get("root"));
1165
+ await propsService.setNewItemId(config, this.get("root"));
997
1166
  if (config.style) {
998
1167
  config.style = {
999
1168
  ...config.style,
1000
1169
  ...position
1001
1170
  };
1002
1171
  }
1172
+ if (utils.isPage(config)) {
1173
+ config.name = generatePageNameByApp(this.get("root"));
1174
+ }
1003
1175
  return await this.add(config);
1004
1176
  }
1005
1177
  async alignCenter(config2) {
1006
1178
  const parent = this.get("parent");
1007
1179
  const node = this.get("node");
1008
- const layout = await this.getLayout(parent);
1180
+ const layout = await this.getLayout(vue.toRaw(parent), vue.toRaw(node));
1009
1181
  if (layout === Layout.RELATIVE) {
1010
1182
  return;
1011
1183
  }
1012
- if (parent.style?.width && node.style?.width) {
1184
+ if (!node.style)
1185
+ return;
1186
+ const stage = this.get("stage");
1187
+ const doc = stage?.renderer.contentWindow?.document;
1188
+ if (doc) {
1189
+ const parentEl = doc.getElementById(`${parent.id}`);
1190
+ const el = doc.getElementById(`${node.id}`);
1191
+ if (parentEl && el) {
1192
+ node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
1193
+ }
1194
+ } else if (parent.style && utils.isNumber(parent.style?.width) && utils.isNumber(node.style?.width)) {
1013
1195
  node.style.left = (parent.style.width - node.style.width) / 2;
1014
1196
  }
1015
1197
  await this.update(node);
@@ -1023,9 +1205,9 @@
1023
1205
  const node = this.get("node");
1024
1206
  const brothers = parent?.items || [];
1025
1207
  const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
1026
- if (offset === LayerOffset.BOTTOM) {
1208
+ if (offset === LayerOffset.TOP) {
1027
1209
  brothers.splice(brothers.length - 1, 0, brothers.splice(index, 1)[0]);
1028
- } else if (offset === LayerOffset.TOP) {
1210
+ } else if (offset === LayerOffset.BOTTOM) {
1029
1211
  brothers.splice(0, 0, brothers.splice(index, 1)[0]);
1030
1212
  } else {
1031
1213
  brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
@@ -1042,6 +1224,26 @@
1042
1224
  await this.changeHistoryState(value);
1043
1225
  return value;
1044
1226
  }
1227
+ async move(left, top) {
1228
+ const node = vue.toRaw(this.get("node"));
1229
+ if (!node || utils.isPage(node))
1230
+ return;
1231
+ const { style, id } = node;
1232
+ if (!style || style.position !== "absolute")
1233
+ return;
1234
+ if (top && !utils.isNumber(style.top))
1235
+ return;
1236
+ if (left && !utils.isNumber(style.left))
1237
+ return;
1238
+ this.update({
1239
+ id,
1240
+ style: {
1241
+ ...style,
1242
+ left: Number(style.left) + left,
1243
+ top: Number(style.top) + top
1244
+ }
1245
+ });
1246
+ }
1045
1247
  destroy() {
1046
1248
  this.removeAllListeners();
1047
1249
  this.set("root", null);
@@ -1074,7 +1276,12 @@
1074
1276
  this.isHistoryStateChange = true;
1075
1277
  await this.update(value.data);
1076
1278
  this.set("modifiedNodeIds", value.modifiedNodeIds);
1077
- setTimeout(() => value.nodeId && this.select(value.nodeId), 0);
1279
+ setTimeout(async () => {
1280
+ if (!value.nodeId)
1281
+ return;
1282
+ await this.select(value.nodeId);
1283
+ this.get("stage")?.select(value.nodeId);
1284
+ }, 0);
1078
1285
  }
1079
1286
  async toggleFixedPosition(dist, src, root) {
1080
1287
  let newConfig = lodashEs.cloneDeep(dist);
@@ -1266,6 +1473,40 @@
1266
1473
  defaultValue: "100% 100%"
1267
1474
  }
1268
1475
  ]
1476
+ },
1477
+ {
1478
+ type: "fieldset",
1479
+ legend: "\u5B57\u4F53",
1480
+ items: [
1481
+ {
1482
+ name: "color",
1483
+ text: "\u989C\u8272",
1484
+ type: "colorPicker"
1485
+ },
1486
+ {
1487
+ name: "fontSize",
1488
+ text: "\u5927\u5C0F"
1489
+ },
1490
+ {
1491
+ name: "fontWeight",
1492
+ text: "\u7C97\u7EC6"
1493
+ }
1494
+ ]
1495
+ },
1496
+ {
1497
+ type: "fieldset",
1498
+ legend: "\u53D8\u5F62",
1499
+ name: "transform",
1500
+ items: [
1501
+ {
1502
+ name: "rotate",
1503
+ text: "\u65CB\u8F6C\u89D2\u5EA6"
1504
+ },
1505
+ {
1506
+ name: "scale",
1507
+ text: "\u7F29\u653E"
1508
+ }
1509
+ ]
1269
1510
  }
1270
1511
  ]
1271
1512
  }
@@ -1298,7 +1539,7 @@
1298
1539
  type: "select",
1299
1540
  options: (mForm, { model }) => {
1300
1541
  const node = editorService.getNodeById(model.to);
1301
- if (!node)
1542
+ if (!node?.type)
1302
1543
  return [];
1303
1544
  return eventsService.getMethod(node.type).map((option) => ({
1304
1545
  text: option.label,
@@ -1326,14 +1567,21 @@
1326
1567
  }
1327
1568
  ];
1328
1569
  const DEFAULT_CONFIG = fillConfig([]);
1329
- const getDefaultPropsValue = (type) => ({
1570
+ const getDefaultPropsValue = (type, id) => ["page", "container"].includes(type) ? {
1571
+ type,
1572
+ id,
1573
+ layout: "absolute",
1574
+ style: {},
1575
+ name: type,
1576
+ items: []
1577
+ } : {
1330
1578
  type,
1331
- id: generateId(type),
1579
+ id,
1332
1580
  style: {},
1333
1581
  name: type
1334
- });
1582
+ };
1335
1583
 
1336
- const _sfc_main$g = vue.defineComponent({
1584
+ const _sfc_main$i = vue.defineComponent({
1337
1585
  components: { Plus: icons.Plus },
1338
1586
  setup() {
1339
1587
  const services = vue.inject("services");
@@ -1350,14 +1598,14 @@
1350
1598
  };
1351
1599
  }
1352
1600
  });
1353
- const _hoisted_1$c = { class: "m-editor-empty-panel" };
1354
- const _hoisted_2$6 = { class: "m-editor-empty-content" };
1355
- const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1356
- function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1601
+ const _hoisted_1$a = { class: "m-editor-empty-panel" };
1602
+ const _hoisted_2$4 = { class: "m-editor-empty-content" };
1603
+ const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1604
+ function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
1357
1605
  const _component_plus = vue.resolveComponent("plus");
1358
1606
  const _component_el_icon = vue.resolveComponent("el-icon");
1359
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
1360
- vue.createElementVNode("div", _hoisted_2$6, [
1607
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
1608
+ vue.createElementVNode("div", _hoisted_2$4, [
1361
1609
  vue.createElementVNode("div", {
1362
1610
  class: "m-editor-empty-button",
1363
1611
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
@@ -1370,1249 +1618,88 @@
1370
1618
  _: 1
1371
1619
  })
1372
1620
  ]),
1373
- _hoisted_3$4
1621
+ _hoisted_3$2
1374
1622
  ])
1375
1623
  ])
1376
1624
  ]);
1377
1625
  }
1378
- var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
1379
-
1380
- /*
1381
- Copyright (c) 2018 Daybrush
1382
- @name: @daybrush/utils
1383
- license: MIT
1384
- author: Daybrush
1385
- repository: https://github.com/daybrush/utils
1386
- @version 1.6.0
1387
- */
1388
- /**
1389
- * get string "object"
1390
- * @memberof Consts
1391
- * @example
1392
- import {OBJECT} from "@daybrush/utils";
1393
-
1394
- console.log(OBJECT); // "object"
1395
- */
1396
-
1397
- var OBJECT = "object";
1398
- /**
1399
- * Check the type that the value is object.
1400
- * @memberof Utils
1401
- * @param {string} value - Value to check the type
1402
- * @return {} true if the type is correct, false otherwise
1403
- * @example
1404
- import {isObject} from "@daybrush/utils";
1405
-
1406
- console.log(isObject({})); // true
1407
- console.log(isObject(undefined)); // false
1408
- console.log(isObject("")); // false
1409
- console.log(isObject(null)); // false
1410
- */
1411
-
1412
- function isObject(value) {
1413
- return value && typeof value === OBJECT;
1414
- }
1415
- /**
1416
- * Date.now() method
1417
- * @memberof CrossBrowser
1418
- * @return {number} milliseconds
1419
- * @example
1420
- import {now} from "@daybrush/utils";
1421
-
1422
- console.log(now()); // 12121324241(milliseconds)
1423
- */
1424
-
1425
- function now() {
1426
- return Date.now ? Date.now() : new Date().getTime();
1427
- }
1428
- /**
1429
- * Returns the index of the first element in the array that satisfies the provided testing function.
1430
- * @function
1431
- * @memberof CrossBrowser
1432
- * @param - The array `findIndex` was called upon.
1433
- * @param - A function to execute on each value in the array until the function returns true, indicating that the satisfying element was found.
1434
- * @param - Returns defaultIndex if not found by the function.
1435
- * @example
1436
- import { findIndex } from "@daybrush/utils";
1626
+ var AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$i]]);
1437
1627
 
1438
- findIndex([{a: 1}, {a: 2}, {a: 3}, {a: 4}], ({ a }) => a === 2); // 1
1439
- */
1440
-
1441
- function findIndex(arr, callback, defaultIndex) {
1442
- if (defaultIndex === void 0) {
1443
- defaultIndex = -1;
1444
- }
1445
-
1446
- var length = arr.length;
1447
-
1448
- for (var i = 0; i < length; ++i) {
1449
- if (callback(arr[i], i, arr)) {
1450
- return i;
1628
+ const _sfc_main$h = vue.defineComponent({
1629
+ name: "m-editor-resize",
1630
+ props: {
1631
+ type: {
1632
+ type: String
1451
1633
  }
1634
+ },
1635
+ setup(props) {
1636
+ const services = vue.inject("services");
1637
+ const target = vue.ref();
1638
+ let getso;
1639
+ vue.onMounted(() => {
1640
+ if (!target.value)
1641
+ return;
1642
+ getso = new Gesto__default["default"](target.value, {
1643
+ container: window,
1644
+ pinchOutside: true
1645
+ }).on("drag", (e) => {
1646
+ if (!target.value || !services)
1647
+ return;
1648
+ let { left, right } = {
1649
+ ...vue.toRaw(services.uiService.get("columnWidth"))
1650
+ };
1651
+ if (props.type === "left") {
1652
+ left += e.deltaX;
1653
+ } else if (props.type === "right") {
1654
+ right -= e.deltaX;
1655
+ }
1656
+ services.uiService.set("columnWidth", {
1657
+ left,
1658
+ right
1659
+ });
1660
+ });
1661
+ });
1662
+ vue.onUnmounted(() => {
1663
+ getso?.unset();
1664
+ });
1665
+ return {
1666
+ target
1667
+ };
1452
1668
  }
1453
-
1454
- return defaultIndex;
1455
- }
1456
- /**
1457
- * Sets up a function that will be called whenever the specified event is delivered to the target
1458
- * @memberof DOM
1459
- * @param - event target
1460
- * @param - A case-sensitive string representing the event type to listen for.
1461
- * @param - The object which receives a notification (an object that implements the Event interface) when an event of the specified type occurs
1462
- * @param - An options object that specifies characteristics about the event listener.
1463
- * @example
1464
- import {addEvent} from "@daybrush/utils";
1465
-
1466
- addEvent(el, "click", e => {
1467
- console.log(e);
1468
1669
  });
1469
- */
1470
-
1471
- function addEvent(el, type, listener, options) {
1472
- el.addEventListener(type, listener, options);
1473
- }
1474
- /**
1475
- * removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()
1476
- * @memberof DOM
1477
- * @param - event target
1478
- * @param - A case-sensitive string representing the event type to listen for.
1479
- * @param - The EventListener function of the event handler to remove from the event target.
1480
- * @param - An options object that specifies characteristics about the event listener.
1481
- * @example
1482
- import {addEvent, removeEvent} from "@daybrush/utils";
1483
- const listener = e => {
1484
- console.log(e);
1485
- };
1486
- addEvent(el, "click", listener);
1487
- removeEvent(el, "click", listener);
1488
- */
1489
-
1490
- function removeEvent(el, type, listener, options) {
1491
- el.removeEventListener(type, listener, options);
1492
- }
1493
-
1494
- /*
1495
- Copyright (c) 2019 Daybrush
1496
- name: @scena/event-emitter
1497
- license: MIT
1498
- author: Daybrush
1499
- repository: git+https://github.com/daybrush/gesture.git
1500
- version: 1.0.5
1501
- */
1502
-
1503
- /*! *****************************************************************************
1504
- Copyright (c) Microsoft Corporation.
1505
-
1506
- Permission to use, copy, modify, and/or distribute this software for any
1507
- purpose with or without fee is hereby granted.
1508
-
1509
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1510
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1511
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1512
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1513
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1514
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1515
- PERFORMANCE OF THIS SOFTWARE.
1516
- ***************************************************************************** */
1517
- var __assign$1 = function () {
1518
- __assign$1 = Object.assign || function __assign(t) {
1519
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1520
- s = arguments[i];
1521
-
1522
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1523
- }
1524
-
1525
- return t;
1526
- };
1527
-
1528
- return __assign$1.apply(this, arguments);
1670
+ const _hoisted_1$9 = {
1671
+ ref: "target",
1672
+ class: "m-editor-resizer"
1529
1673
  };
1530
- function __spreadArrays() {
1531
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1532
-
1533
- 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];
1534
-
1535
- return r;
1674
+ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
1675
+ return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$9, [
1676
+ vue.renderSlot(_ctx.$slots, "default")
1677
+ ], 512);
1536
1678
  }
1679
+ var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
1537
1680
 
1538
- /**
1539
- * Implement EventEmitter on object or component.
1540
- */
1541
-
1542
- var EventEmitter =
1543
- /*#__PURE__*/
1544
- function () {
1545
- function EventEmitter() {
1546
- this._events = {};
1547
- }
1548
- /**
1549
- * Add a listener to the registered event.
1550
- * @param - Name of the event to be added
1551
- * @param - listener function of the event to be added
1552
- * @example
1553
- * import EventEmitter from "@scena/event-emitter";
1554
- * cosnt emitter = new EventEmitter();
1555
- *
1556
- * // Add listener in "a" event
1557
- * emitter.on("a", () => {
1558
- * });
1559
- * // Add listeners
1560
- * emitter.on({
1561
- * a: () => {},
1562
- * b: () => {},
1563
- * });
1564
- */
1565
-
1566
-
1567
- var __proto = EventEmitter.prototype;
1568
-
1569
- __proto.on = function (eventName, listener) {
1570
- if (isObject(eventName)) {
1571
- for (var name in eventName) {
1572
- this.on(name, eventName[name]);
1573
- }
1574
- } else {
1575
- this._addEvent(eventName, listener, {});
1681
+ const _sfc_main$g = vue.defineComponent({
1682
+ components: {
1683
+ AddPageBox,
1684
+ Resizer
1685
+ },
1686
+ props: {
1687
+ codeOptions: {
1688
+ type: Object,
1689
+ default: () => ({})
1576
1690
  }
1577
-
1578
- return this;
1579
- };
1580
- /**
1581
- * Remove listeners registered in the event target.
1582
- * @param - Name of the event to be removed
1583
- * @param - listener function of the event to be removed
1584
- * @example
1585
- * import EventEmitter from "@scena/event-emitter";
1586
- * cosnt emitter = new EventEmitter();
1587
- *
1588
- * // Remove all listeners.
1589
- * emitter.off();
1590
- *
1591
- * // Remove all listeners in "A" event.
1592
- * emitter.off("a");
1593
- *
1594
- *
1595
- * // Remove "listener" listener in "a" event.
1596
- * emitter.off("a", listener);
1597
- */
1598
-
1599
-
1600
- __proto.off = function (eventName, listener) {
1601
- if (!eventName) {
1602
- this._events = {};
1603
- } else if (isObject(eventName)) {
1604
- for (var name in eventName) {
1605
- this.off(name);
1606
- }
1607
- } else if (!listener) {
1608
- this._events[eventName] = [];
1609
- } else {
1610
- var events = this._events[eventName];
1611
-
1612
- if (events) {
1613
- var index = findIndex(events, function (e) {
1614
- return e.listener === listener;
1615
- });
1616
-
1617
- if (index > -1) {
1618
- events.splice(index, 1);
1619
- }
1620
- }
1621
- }
1622
-
1623
- return this;
1624
- };
1625
- /**
1626
- * Add a disposable listener and Use promise to the registered event.
1627
- * @param - Name of the event to be added
1628
- * @param - disposable listener function of the event to be added
1629
- * @example
1630
- * import EventEmitter from "@scena/event-emitter";
1631
- * cosnt emitter = new EventEmitter();
1632
- *
1633
- * // Add a disposable listener in "a" event
1634
- * emitter.once("a", () => {
1635
- * });
1636
- *
1637
- * // Use Promise
1638
- * emitter.once("a").then(e => {
1639
- * });
1640
- */
1641
-
1642
-
1643
- __proto.once = function (eventName, listener) {
1644
- var _this = this;
1645
-
1646
- if (listener) {
1647
- this._addEvent(eventName, listener, {
1648
- once: true
1649
- });
1650
- }
1651
-
1652
- return new Promise(function (resolve) {
1653
- _this._addEvent(eventName, resolve, {
1654
- once: true
1655
- });
1656
- });
1657
- };
1658
- /**
1659
- * Fires an event to call listeners.
1660
- * @param - Event name
1661
- * @param - Event parameter
1662
- * @return If false, stop the event.
1663
- * @example
1664
- *
1665
- * import EventEmitter from "@scena/event-emitter";
1666
- *
1667
- *
1668
- * const emitter = new EventEmitter();
1669
- *
1670
- * emitter.on("a", e => {
1671
- * });
1672
- *
1673
- *
1674
- * emitter.emit("a", {
1675
- * a: 1,
1676
- * });
1677
- */
1678
-
1679
-
1680
- __proto.emit = function (eventName, param) {
1681
- var _this = this;
1682
-
1683
- if (param === void 0) {
1684
- param = {};
1685
- }
1686
-
1687
- var events = this._events[eventName];
1688
-
1689
- if (!eventName || !events) {
1690
- return true;
1691
- }
1692
-
1693
- var isStop = false;
1694
- param.eventType = eventName;
1695
-
1696
- param.stop = function () {
1697
- isStop = true;
1698
- };
1699
-
1700
- param.currentTarget = this;
1701
-
1702
- __spreadArrays(events).forEach(function (info) {
1703
- info.listener(param);
1704
-
1705
- if (info.once) {
1706
- _this.off(eventName, info.listener);
1707
- }
1708
- });
1709
-
1710
- return !isStop;
1711
- };
1712
- /**
1713
- * Fires an event to call listeners.
1714
- * @param - Event name
1715
- * @param - Event parameter
1716
- * @return If false, stop the event.
1717
- * @example
1718
- *
1719
- * import EventEmitter from "@scena/event-emitter";
1720
- *
1721
- *
1722
- * const emitter = new EventEmitter();
1723
- *
1724
- * emitter.on("a", e => {
1725
- * });
1726
- *
1727
- *
1728
- * emitter.emit("a", {
1729
- * a: 1,
1730
- * });
1731
- */
1732
-
1733
- /**
1734
- * Fires an event to call listeners.
1735
- * @param - Event name
1736
- * @param - Event parameter
1737
- * @return If false, stop the event.
1738
- * @example
1739
- *
1740
- * import EventEmitter from "@scena/event-emitter";
1741
- *
1742
- *
1743
- * const emitter = new EventEmitter();
1744
- *
1745
- * emitter.on("a", e => {
1746
- * });
1747
- *
1748
- * // emit
1749
- * emitter.trigger("a", {
1750
- * a: 1,
1751
- * });
1752
- */
1753
-
1754
-
1755
- __proto.trigger = function (eventName, param) {
1756
- if (param === void 0) {
1757
- param = {};
1758
- }
1759
-
1760
- return this.emit(eventName, param);
1761
- };
1762
-
1763
- __proto._addEvent = function (eventName, listener, options) {
1764
- var events = this._events;
1765
- events[eventName] = events[eventName] || [];
1766
- var listeners = events[eventName];
1767
- listeners.push(__assign$1({
1768
- listener: listener
1769
- }, options));
1770
- };
1771
-
1772
- return EventEmitter;
1773
- }();
1774
-
1775
- var EventEmitter$1 = EventEmitter;
1776
-
1777
- /*
1778
- Copyright (c) 2019 Daybrush
1779
- name: gesto
1780
- license: MIT
1781
- author: Daybrush
1782
- repository: git+https://github.com/daybrush/gesture.git
1783
- version: 1.5.0
1784
- */
1785
-
1786
- /*! *****************************************************************************
1787
- Copyright (c) Microsoft Corporation. All rights reserved.
1788
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
1789
- this file except in compliance with the License. You may obtain a copy of the
1790
- License at http://www.apache.org/licenses/LICENSE-2.0
1791
-
1792
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1793
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
1794
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
1795
- MERCHANTABLITY OR NON-INFRINGEMENT.
1796
-
1797
- See the Apache Version 2.0 License for specific language governing permissions
1798
- and limitations under the License.
1799
- ***************************************************************************** */
1800
-
1801
- /* global Reflect, Promise */
1802
- var extendStatics = function (d, b) {
1803
- extendStatics = Object.setPrototypeOf || {
1804
- __proto__: []
1805
- } instanceof Array && function (d, b) {
1806
- d.__proto__ = b;
1807
- } || function (d, b) {
1808
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
1809
- };
1810
-
1811
- return extendStatics(d, b);
1812
- };
1813
-
1814
- function __extends(d, b) {
1815
- extendStatics(d, b);
1816
-
1817
- function __() {
1818
- this.constructor = d;
1819
- }
1820
-
1821
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1822
- }
1823
- var __assign = function () {
1824
- __assign = Object.assign || function __assign(t) {
1825
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1826
- s = arguments[i];
1827
-
1828
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1829
- }
1830
-
1831
- return t;
1832
- };
1833
-
1834
- return __assign.apply(this, arguments);
1835
- };
1836
-
1837
- function getRad(pos1, pos2) {
1838
- var distX = pos2[0] - pos1[0];
1839
- var distY = pos2[1] - pos1[1];
1840
- var rad = Math.atan2(distY, distX);
1841
- return rad >= 0 ? rad : rad + Math.PI * 2;
1842
- }
1843
- function getRotatiion(touches) {
1844
- return getRad([touches[0].clientX, touches[0].clientY], [touches[1].clientX, touches[1].clientY]) / Math.PI * 180;
1845
- }
1846
- function isMultiTouch(e) {
1847
- return e.touches && e.touches.length >= 2;
1848
- }
1849
- function getEventClients(e) {
1850
- if (e.touches) {
1851
- return getClients(e.touches);
1852
- } else {
1853
- return [getClient(e)];
1854
- }
1855
- }
1856
- function getPosition(clients, prevClients, startClients) {
1857
- var length = startClients.length;
1858
-
1859
- var _a = getAverageClient(clients, length),
1860
- clientX = _a.clientX,
1861
- clientY = _a.clientY,
1862
- originalClientX = _a.originalClientX,
1863
- originalClientY = _a.originalClientY;
1864
-
1865
- var _b = getAverageClient(prevClients, length),
1866
- prevX = _b.clientX,
1867
- prevY = _b.clientY;
1868
-
1869
- var _c = getAverageClient(startClients, length),
1870
- startX = _c.clientX,
1871
- startY = _c.clientY;
1872
-
1873
- var deltaX = clientX - prevX;
1874
- var deltaY = clientY - prevY;
1875
- var distX = clientX - startX;
1876
- var distY = clientY - startY;
1877
- return {
1878
- clientX: originalClientX,
1879
- clientY: originalClientY,
1880
- deltaX: deltaX,
1881
- deltaY: deltaY,
1882
- distX: distX,
1883
- distY: distY
1884
- };
1885
- }
1886
- function getDist(clients) {
1887
- return Math.sqrt(Math.pow(clients[0].clientX - clients[1].clientX, 2) + Math.pow(clients[0].clientY - clients[1].clientY, 2));
1888
- }
1889
- function getClients(touches) {
1890
- var length = Math.min(touches.length, 2);
1891
- var clients = [];
1892
-
1893
- for (var i = 0; i < length; ++i) {
1894
- clients.push(getClient(touches[i]));
1895
- }
1896
-
1897
- return clients;
1898
- }
1899
- function getClient(e) {
1900
- return {
1901
- clientX: e.clientX,
1902
- clientY: e.clientY
1903
- };
1904
- }
1905
- function getAverageClient(clients, length) {
1906
- if (length === void 0) {
1907
- length = clients.length;
1908
- }
1909
-
1910
- var sumClient = {
1911
- clientX: 0,
1912
- clientY: 0,
1913
- originalClientX: 0,
1914
- originalClientY: 0
1915
- };
1916
-
1917
- for (var i = 0; i < length; ++i) {
1918
- var client = clients[i];
1919
- sumClient.originalClientX += "originalClientX" in client ? client.originalClientX : client.clientX;
1920
- sumClient.originalClientY += "originalClientY" in client ? client.originalClientY : client.clientY;
1921
- sumClient.clientX += client.clientX;
1922
- sumClient.clientY += client.clientY;
1923
- }
1924
-
1925
- if (!length) {
1926
- return sumClient;
1927
- }
1928
-
1929
- return {
1930
- clientX: sumClient.clientX / length,
1931
- clientY: sumClient.clientY / length,
1932
- originalClientX: sumClient.originalClientX / length,
1933
- originalClientY: sumClient.originalClientY / length
1934
- };
1935
- }
1936
-
1937
- var ClientStore =
1938
- /*#__PURE__*/
1939
- function () {
1940
- function ClientStore(clients) {
1941
- this.prevClients = [];
1942
- this.startClients = [];
1943
- this.movement = 0;
1944
- this.length = 0;
1945
- this.startClients = clients;
1946
- this.prevClients = clients;
1947
- this.length = clients.length;
1948
- }
1949
-
1950
- var __proto = ClientStore.prototype;
1951
-
1952
- __proto.addClients = function (clients) {
1953
- if (clients === void 0) {
1954
- clients = this.prevClients;
1955
- }
1956
-
1957
- var position = this.getPosition(clients);
1958
- var deltaX = position.deltaX,
1959
- deltaY = position.deltaY;
1960
- this.movement += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
1961
- this.prevClients = clients;
1962
- return position;
1963
- };
1964
-
1965
- __proto.getAngle = function (clients) {
1966
- if (clients === void 0) {
1967
- clients = this.prevClients;
1968
- }
1969
-
1970
- return getRotatiion(clients);
1971
- };
1972
-
1973
- __proto.getRotation = function (clients) {
1974
- if (clients === void 0) {
1975
- clients = this.prevClients;
1976
- }
1977
-
1978
- return getRotatiion(clients) - getRotatiion(this.startClients);
1979
- };
1980
-
1981
- __proto.getPosition = function (clients) {
1982
- return getPosition(clients || this.prevClients, this.prevClients, this.startClients);
1983
- };
1984
-
1985
- __proto.getPositions = function (clients) {
1986
- if (clients === void 0) {
1987
- clients = this.prevClients;
1988
- }
1989
-
1990
- var prevClients = this.prevClients;
1991
- return this.startClients.map(function (startClient, i) {
1992
- return getPosition([clients[i]], [prevClients[i]], [startClient]);
1993
- });
1994
- };
1995
-
1996
- __proto.getMovement = function (clients) {
1997
- var movement = this.movement;
1998
-
1999
- if (!clients) {
2000
- return movement;
2001
- }
2002
-
2003
- var currentClient = getAverageClient(clients, this.length);
2004
- var prevClient = getAverageClient(this.prevClients, this.length);
2005
- var deltaX = currentClient.clientX - prevClient.clientX;
2006
- var deltaY = currentClient.clientY - prevClient.clientY;
2007
- return Math.sqrt(deltaX * deltaX + deltaY * deltaY) + movement;
2008
- };
2009
-
2010
- __proto.getDistance = function (clients) {
2011
- if (clients === void 0) {
2012
- clients = this.prevClients;
2013
- }
2014
-
2015
- return getDist(clients);
2016
- };
2017
-
2018
- __proto.getScale = function (clients) {
2019
- if (clients === void 0) {
2020
- clients = this.prevClients;
2021
- }
2022
-
2023
- return getDist(clients) / getDist(this.startClients);
2024
- };
2025
-
2026
- __proto.move = function (deltaX, deltaY) {
2027
- this.startClients.forEach(function (client) {
2028
- client.clientX -= deltaX;
2029
- client.clientY -= deltaY;
2030
- });
2031
- this.prevClients.forEach(function (client) {
2032
- client.clientX -= deltaX;
2033
- client.clientY -= deltaY;
2034
- });
2035
- };
2036
-
2037
- return ClientStore;
2038
- }();
2039
-
2040
- var INPUT_TAGNAMES = ["textarea", "input"];
2041
- /**
2042
- * You can set up drag, pinch events in any browser.
2043
- */
2044
-
2045
- var Gesto =
2046
- /*#__PURE__*/
2047
- function (_super) {
2048
- __extends(Gesto, _super);
2049
- /**
2050
- *
2051
- */
2052
-
2053
-
2054
- function Gesto(targets, options) {
2055
- if (options === void 0) {
2056
- options = {};
2057
- }
2058
-
2059
- var _this = _super.call(this) || this;
2060
-
2061
- _this.options = {};
2062
- _this.flag = false;
2063
- _this.pinchFlag = false;
2064
- _this.datas = {};
2065
- _this.isDrag = false;
2066
- _this.isPinch = false;
2067
- _this.isMouse = false;
2068
- _this.isTouch = false;
2069
- _this.clientStores = [];
2070
- _this.targets = [];
2071
- _this.prevTime = 0;
2072
- _this.doubleFlag = false;
2073
-
2074
- _this.onDragStart = function (e, isTrusted) {
2075
- if (isTrusted === void 0) {
2076
- isTrusted = true;
2077
- }
2078
-
2079
- if (!_this.flag && e.cancelable === false) {
2080
- return;
2081
- }
2082
-
2083
- var _a = _this.options,
2084
- container = _a.container,
2085
- pinchOutside = _a.pinchOutside,
2086
- preventRightClick = _a.preventRightClick,
2087
- preventDefault = _a.preventDefault,
2088
- checkInput = _a.checkInput;
2089
- var isTouch = _this.isTouch;
2090
- var isDragStart = !_this.flag;
2091
-
2092
- if (isDragStart) {
2093
- var activeElement = document.activeElement;
2094
- var target = e.target;
2095
- var tagName = target.tagName.toLowerCase();
2096
- var hasInput = INPUT_TAGNAMES.indexOf(tagName) > -1;
2097
- var hasContentEditable = target.isContentEditable;
2098
-
2099
- if (hasInput || hasContentEditable) {
2100
- if (checkInput || activeElement === target) {
2101
- // force false or already focused.
2102
- return false;
2103
- }
2104
-
2105
- if (activeElement && hasContentEditable && activeElement.isContentEditable && activeElement.contains(target)) {
2106
- return false;
2107
- }
2108
- } else if ((preventDefault || e.type === "touchstart") && activeElement) {
2109
- var activeTagName = activeElement.tagName;
2110
-
2111
- if (activeElement.isContentEditable || INPUT_TAGNAMES.indexOf(activeTagName) > -1) {
2112
- activeElement.blur();
2113
- }
2114
- }
2115
-
2116
- _this.clientStores = [new ClientStore(getEventClients(e))];
2117
- _this.flag = true;
2118
- _this.isDrag = false;
2119
- _this.datas = {};
2120
-
2121
- if (preventRightClick && (e.which === 3 || e.button === 2)) {
2122
- _this.initDrag();
2123
-
2124
- return false;
2125
- }
2126
-
2127
- _this.doubleFlag = now() - _this.prevTime < 200;
2128
-
2129
- var result = _this.emit("dragStart", __assign({
2130
- datas: _this.datas,
2131
- inputEvent: e,
2132
- isTrusted: isTrusted,
2133
- isDouble: _this.doubleFlag
2134
- }, _this.getCurrentStore().getPosition()));
2135
-
2136
- if (result === false) {
2137
- _this.initDrag();
2138
- }
2139
-
2140
- _this.flag && preventDefault && e.preventDefault();
2141
- }
2142
-
2143
- if (!_this.flag) {
2144
- return false;
2145
- }
2146
-
2147
- var timer = 0;
2148
-
2149
- if (isDragStart && isTouch && pinchOutside) {
2150
- timer = setTimeout(function () {
2151
- addEvent(container, "touchstart", _this.onDragStart, {
2152
- passive: false
2153
- });
2154
- });
2155
- }
2156
-
2157
- if (!isDragStart && isTouch && pinchOutside) {
2158
- removeEvent(container, "touchstart", _this.onDragStart);
2159
- }
2160
-
2161
- if (_this.flag && isMultiTouch(e)) {
2162
- clearTimeout(timer);
2163
-
2164
- if (isDragStart && e.touches.length !== e.changedTouches.length) {
2165
- return;
2166
- }
2167
-
2168
- if (!_this.pinchFlag) {
2169
- _this.onPinchStart(e);
2170
- }
2171
- }
2172
- };
2173
-
2174
- _this.onDrag = function (e, isScroll) {
2175
- if (!_this.flag) {
2176
- return;
2177
- }
2178
-
2179
- var clients = getEventClients(e);
2180
-
2181
- var result = _this.moveClients(clients, e, false);
2182
-
2183
- if (_this.pinchFlag || result.deltaX || result.deltaY) {
2184
- var dragResult = _this.emit("drag", __assign({}, result, {
2185
- isScroll: !!isScroll,
2186
- inputEvent: e
2187
- }));
2188
-
2189
- if (dragResult === false) {
2190
- _this.stop();
2191
-
2192
- return;
2193
- }
2194
- }
2195
-
2196
- if (_this.pinchFlag) {
2197
- _this.onPinch(e, clients);
2198
- }
2199
-
2200
- _this.getCurrentStore().addClients(clients);
2201
- };
2202
-
2203
- _this.onDragEnd = function (e) {
2204
- if (!_this.flag) {
2205
- return;
2206
- }
2207
-
2208
- var _a = _this.options,
2209
- pinchOutside = _a.pinchOutside,
2210
- container = _a.container;
2211
-
2212
- if (_this.isTouch && pinchOutside) {
2213
- removeEvent(container, "touchstart", _this.onDragStart);
2214
- }
2215
-
2216
- _this.flag = false;
2217
-
2218
- var position = _this.getCurrentStore().getPosition();
2219
-
2220
- var currentTime = now();
2221
- var isDouble = !_this.isDrag && _this.doubleFlag;
2222
- _this.prevTime = _this.isDrag || isDouble ? 0 : currentTime;
2223
-
2224
- _this.emit("dragEnd", __assign({
2225
- datas: _this.datas,
2226
- isDouble: isDouble,
2227
- isDrag: _this.isDrag,
2228
- isClick: !_this.isDrag,
2229
- inputEvent: e
2230
- }, position));
2231
-
2232
- if (_this.pinchFlag) {
2233
- _this.onPinchEnd(e);
2234
- }
2235
-
2236
- _this.clientStores = [];
2237
- };
2238
-
2239
- _this.onBlur = function () {
2240
- _this.onDragEnd();
2241
- };
2242
-
2243
- var elements = [].concat(targets);
2244
- _this.options = __assign({
2245
- checkInput: false,
2246
- container: elements.length > 1 ? window : elements[0],
2247
- preventRightClick: true,
2248
- preventDefault: true,
2249
- checkWindowBlur: false,
2250
- pinchThreshold: 0,
2251
- events: ["touch", "mouse"]
2252
- }, options);
2253
- var _a = _this.options,
2254
- container = _a.container,
2255
- events = _a.events,
2256
- checkWindowBlur = _a.checkWindowBlur;
2257
- _this.isTouch = events.indexOf("touch") > -1;
2258
- _this.isMouse = events.indexOf("mouse") > -1;
2259
- _this.targets = elements;
2260
-
2261
- if (_this.isMouse) {
2262
- elements.forEach(function (el) {
2263
- addEvent(el, "mousedown", _this.onDragStart);
2264
- });
2265
- addEvent(container, "mousemove", _this.onDrag);
2266
- addEvent(container, "mouseup", _this.onDragEnd);
2267
- addEvent(container, "contextmenu", _this.onDragEnd);
2268
- }
2269
-
2270
- if (checkWindowBlur) {
2271
- addEvent(window, "blur", _this.onBlur);
2272
- }
2273
-
2274
- if (_this.isTouch) {
2275
- var passive_1 = {
2276
- passive: false
2277
- };
2278
- elements.forEach(function (el) {
2279
- addEvent(el, "touchstart", _this.onDragStart, passive_1);
2280
- });
2281
- addEvent(container, "touchmove", _this.onDrag, passive_1);
2282
- addEvent(container, "touchend", _this.onDragEnd, passive_1);
2283
- addEvent(container, "touchcancel", _this.onDragEnd, passive_1);
2284
- }
2285
-
2286
- return _this;
2287
- }
2288
- /**
2289
- * Stop Gesto's drag events.
2290
- */
2291
-
2292
-
2293
- var __proto = Gesto.prototype;
2294
-
2295
- __proto.stop = function () {
2296
- this.isDrag = false;
2297
- this.flag = false;
2298
- this.clientStores = [];
2299
- this.datas = {};
2300
- };
2301
- /**
2302
- * The total moved distance
2303
- */
2304
-
2305
-
2306
- __proto.getMovement = function (clients) {
2307
- return this.getCurrentStore().getMovement(clients) + this.clientStores.slice(1).reduce(function (prev, cur) {
2308
- return prev + cur.movement;
2309
- }, 0);
2310
- };
2311
- /**
2312
- * Whether to drag
2313
- */
2314
-
2315
-
2316
- __proto.isDragging = function () {
2317
- return this.isDrag;
2318
- };
2319
- /**
2320
- * Whether to start drag
2321
- */
2322
-
2323
-
2324
- __proto.isFlag = function () {
2325
- return this.flag;
2326
- };
2327
- /**
2328
- * Whether to start pinch
2329
- */
2330
-
2331
-
2332
- __proto.isPinchFlag = function () {
2333
- return this.pinchFlag;
2334
- };
2335
- /**
2336
- * Whether to start double click
2337
- */
2338
-
2339
-
2340
- __proto.isDoubleFlag = function () {
2341
- return this.doubleFlag;
2342
- };
2343
- /**
2344
- * Whether to pinch
2345
- */
2346
-
2347
-
2348
- __proto.isPinching = function () {
2349
- return this.isPinch;
2350
- };
2351
- /**
2352
- * If a scroll event occurs, it is corrected by the scroll distance.
2353
- */
2354
-
2355
-
2356
- __proto.scrollBy = function (deltaX, deltaY, e, isCallDrag) {
2357
- if (isCallDrag === void 0) {
2358
- isCallDrag = true;
2359
- }
2360
-
2361
- if (!this.flag) {
2362
- return;
2363
- }
2364
-
2365
- this.clientStores[0].move(deltaX, deltaY);
2366
- isCallDrag && this.onDrag(e, true);
2367
- };
2368
- /**
2369
- * Create a virtual drag event.
2370
- */
2371
-
2372
-
2373
- __proto.move = function (_a, inputEvent) {
2374
- var deltaX = _a[0],
2375
- deltaY = _a[1];
2376
- var store = this.getCurrentStore();
2377
- var nextClients = store.prevClients;
2378
- return this.moveClients(nextClients.map(function (_a) {
2379
- var clientX = _a.clientX,
2380
- clientY = _a.clientY;
2381
- return {
2382
- clientX: clientX + deltaX,
2383
- clientY: clientY + deltaY,
2384
- originalClientX: clientX,
2385
- originalClientY: clientY
2386
- };
2387
- }), inputEvent, true);
2388
- };
2389
- /**
2390
- * The dragStart event is triggered by an external event.
2391
- */
2392
-
2393
-
2394
- __proto.triggerDragStart = function (e) {
2395
- this.onDragStart(e, false);
2396
- };
2397
- /**
2398
- * Set the event data while dragging.
2399
- */
2400
-
2401
-
2402
- __proto.setEventDatas = function (datas) {
2403
- var currentDatas = this.datas;
2404
-
2405
- for (var name in datas) {
2406
- currentDatas[name] = datas[name];
2407
- }
2408
-
2409
- return this;
2410
- };
2411
- /**
2412
- * Set the event data while dragging.
2413
- */
2414
-
2415
-
2416
- __proto.getEventDatas = function () {
2417
- return this.datas;
2418
- };
2419
- /**
2420
- * Unset Gesto
2421
- */
2422
-
2423
-
2424
- __proto.unset = function () {
2425
- var _this = this;
2426
-
2427
- var targets = this.targets;
2428
- var container = this.options.container;
2429
- this.off();
2430
- removeEvent(window, "blur", this.onBlur);
2431
-
2432
- if (this.isMouse) {
2433
- targets.forEach(function (target) {
2434
- removeEvent(target, "mousedown", _this.onDragStart);
2435
- });
2436
- removeEvent(container, "mousemove", this.onDrag);
2437
- removeEvent(container, "mouseup", this.onDragEnd);
2438
- removeEvent(container, "contextmenu", this.onDragEnd);
2439
- }
2440
-
2441
- if (this.isTouch) {
2442
- targets.forEach(function (target) {
2443
- removeEvent(target, "touchstart", _this.onDragStart);
2444
- });
2445
- removeEvent(container, "touchstart", this.onDragStart);
2446
- removeEvent(container, "touchmove", this.onDrag);
2447
- removeEvent(container, "touchend", this.onDragEnd);
2448
- removeEvent(container, "touchcancel", this.onDragEnd);
2449
- }
2450
- };
2451
-
2452
- __proto.onPinchStart = function (e) {
2453
- var pinchThreshold = this.options.pinchThreshold;
2454
-
2455
- if (this.isDrag && this.getMovement() > pinchThreshold) {
2456
- return;
2457
- }
2458
-
2459
- var store = new ClientStore(getEventClients(e));
2460
- this.pinchFlag = true;
2461
- this.clientStores.splice(0, 0, store);
2462
- var result = this.emit("pinchStart", __assign({
2463
- datas: this.datas,
2464
- angle: store.getAngle(),
2465
- touches: this.getCurrentStore().getPositions()
2466
- }, store.getPosition(), {
2467
- inputEvent: e
2468
- }));
2469
-
2470
- if (result === false) {
2471
- this.pinchFlag = false;
2472
- }
2473
- };
2474
-
2475
- __proto.onPinch = function (e, clients) {
2476
- if (!this.flag || !this.pinchFlag || clients.length < 2) {
2477
- return;
2478
- }
2479
-
2480
- var store = this.getCurrentStore();
2481
- this.isPinch = true;
2482
- this.emit("pinch", __assign({
2483
- datas: this.datas,
2484
- movement: this.getMovement(clients),
2485
- angle: store.getAngle(clients),
2486
- rotation: store.getRotation(clients),
2487
- touches: store.getPositions(clients),
2488
- scale: store.getScale(clients),
2489
- distance: store.getDistance(clients)
2490
- }, store.getPosition(clients), {
2491
- inputEvent: e
2492
- }));
2493
- };
2494
-
2495
- __proto.onPinchEnd = function (e) {
2496
- if (!this.pinchFlag) {
2497
- return;
2498
- }
2499
-
2500
- var isPinch = this.isPinch;
2501
- this.isPinch = false;
2502
- this.pinchFlag = false;
2503
- var store = this.getCurrentStore();
2504
- this.emit("pinchEnd", __assign({
2505
- datas: this.datas,
2506
- isPinch: isPinch,
2507
- touches: store.getPositions()
2508
- }, store.getPosition(), {
2509
- inputEvent: e
2510
- }));
2511
- this.isPinch = false;
2512
- this.pinchFlag = false;
2513
- };
2514
-
2515
- __proto.initDrag = function () {
2516
- this.clientStores = [];
2517
- this.pinchFlag = false;
2518
- this.doubleFlag = false;
2519
- this.prevTime = 0;
2520
- this.flag = false;
2521
- };
2522
-
2523
- __proto.getCurrentStore = function () {
2524
- return this.clientStores[0];
2525
- };
2526
-
2527
- __proto.moveClients = function (clients, inputEvent, isAdd) {
2528
- var store = this.getCurrentStore();
2529
- var position = store[isAdd ? "addClients" : "getPosition"](clients);
2530
- this.isDrag = true;
2531
- return __assign({
2532
- datas: this.datas
2533
- }, position, {
2534
- movement: this.getMovement(clients),
2535
- isDrag: this.isDrag,
2536
- isPinch: this.isPinch,
2537
- isScroll: false,
2538
- inputEvent: inputEvent
2539
- });
2540
- };
2541
-
2542
- return Gesto;
2543
- }(EventEmitter$1);
2544
-
2545
- var Gesto$1 = Gesto;
2546
-
2547
- const _sfc_main$f = vue.defineComponent({
2548
- name: "m-editor-resize",
2549
- props: {
2550
- type: {
2551
- type: String
2552
- }
2553
- },
2554
- setup(props) {
2555
- const services = vue.inject("services");
2556
- const target = vue.ref();
2557
- let getso;
2558
- vue.onMounted(() => {
2559
- if (!target.value)
2560
- return;
2561
- getso = new Gesto$1(target.value, {
2562
- container: window,
2563
- pinchOutside: true
2564
- }).on("drag", (e) => {
2565
- if (!target.value || !services)
2566
- return;
2567
- let { left, right } = {
2568
- ...vue.toRaw(services.uiService.get("columnWidth"))
2569
- };
2570
- if (props.type === "left") {
2571
- left += e.deltaX;
2572
- } else if (props.type === "right") {
2573
- right -= e.deltaX;
2574
- }
2575
- services.uiService.set("columnWidth", {
2576
- left,
2577
- right
2578
- });
2579
- });
2580
- });
2581
- vue.onUnmounted(() => {
2582
- getso?.unset();
2583
- });
2584
- return {
2585
- target
2586
- };
2587
- }
2588
- });
2589
- const _hoisted_1$b = {
2590
- ref: "target",
2591
- class: "m-editor-resizer"
2592
- };
2593
- function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2594
- return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$b, [
2595
- vue.renderSlot(_ctx.$slots, "default")
2596
- ], 512);
2597
- }
2598
- var Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
2599
-
2600
- const _sfc_main$e = vue.defineComponent({
2601
- components: {
2602
- AddPageBox,
2603
- Resizer
2604
1691
  },
2605
1692
  setup() {
2606
- const services = vue.inject("services");
2607
- const root = vue.computed(() => services?.editorService.get("root"));
1693
+ const { editorService, uiService } = vue.inject("services") || {};
1694
+ const root = vue.computed(() => editorService?.get("root"));
2608
1695
  return {
2609
1696
  root,
2610
- pageLength: vue.computed(() => root.value?.items?.length || 0),
2611
- showSrc: vue.computed(() => services?.uiService.get("showSrc")),
2612
- columnWidth: vue.computed(() => services?.uiService.get("columnWidth")),
1697
+ pageLength: vue.computed(() => editorService?.get("pageLength") || 0),
1698
+ showSrc: vue.computed(() => uiService?.get("showSrc")),
1699
+ columnWidth: vue.computed(() => uiService?.get("columnWidth")),
2613
1700
  saveCode(value) {
2614
1701
  try {
2615
- services?.editorService.set("root", eval(value));
1702
+ editorService?.set("root", eval(value));
2616
1703
  } catch (e) {
2617
1704
  console.error(e);
2618
1705
  }
@@ -2620,24 +1707,25 @@
2620
1707
  };
2621
1708
  }
2622
1709
  });
2623
- const _hoisted_1$a = { class: "m-editor" };
2624
- const _hoisted_2$5 = {
1710
+ const _hoisted_1$8 = { class: "m-editor" };
1711
+ const _hoisted_2$3 = {
2625
1712
  key: 1,
2626
1713
  class: "m-editor-content"
2627
1714
  };
2628
- function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
1715
+ function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
2629
1716
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
2630
1717
  const _component_resizer = vue.resolveComponent("resizer");
2631
1718
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
2632
1719
  const _component_add_page_box = vue.resolveComponent("add-page-box");
2633
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
1720
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2634
1721
  vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2635
1722
  _ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
2636
1723
  key: 0,
2637
1724
  class: "m-editor-content",
2638
1725
  "init-values": _ctx.root,
1726
+ options: _ctx.codeOptions,
2639
1727
  onSave: _ctx.saveCode
2640
- }, null, 8, ["init-values", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$5, [
1728
+ }, null, 8, ["init-values", "options", "onSave"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
2641
1729
  vue.createElementVNode("div", {
2642
1730
  class: "m-editor-framework-left",
2643
1731
  style: vue.normalizeStyle(`width: ${_ctx.columnWidth?.left}px`)
@@ -2670,9 +1758,9 @@
2670
1758
  ]))
2671
1759
  ]);
2672
1760
  }
2673
- var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
1761
+ var Framework = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["render", _sfc_render$g]]);
2674
1762
 
2675
- const _sfc_main$d = vue.defineComponent({
1763
+ const _sfc_main$f = vue.defineComponent({
2676
1764
  name: "m-icon",
2677
1765
  components: { Edit: icons.Edit },
2678
1766
  props: {
@@ -2686,8 +1774,8 @@
2686
1774
  };
2687
1775
  }
2688
1776
  });
2689
- const _hoisted_1$9 = ["src"];
2690
- function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
1777
+ const _hoisted_1$7 = ["src"];
1778
+ function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2691
1779
  const _component_edit = vue.resolveComponent("edit");
2692
1780
  const _component_el_icon = vue.resolveComponent("el-icon");
2693
1781
  return !_ctx.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
@@ -2698,7 +1786,7 @@
2698
1786
  })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
2699
1787
  key: 1,
2700
1788
  src: _ctx.icon
2701
- }, null, 8, _hoisted_1$9)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
1789
+ }, null, 8, _hoisted_1$7)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2702
1790
  key: 2,
2703
1791
  class: vue.normalizeClass(_ctx.icon)
2704
1792
  }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
@@ -2708,9 +1796,9 @@
2708
1796
  _: 1
2709
1797
  }));
2710
1798
  }
2711
- var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
1799
+ var MIcon = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["render", _sfc_render$f]]);
2712
1800
 
2713
- const _sfc_main$c = vue.defineComponent({
1801
+ const _sfc_main$e = vue.defineComponent({
2714
1802
  components: { MIcon, ArrowDown: icons.ArrowDown },
2715
1803
  props: {
2716
1804
  data: {
@@ -2720,16 +1808,20 @@
2720
1808
  type: "text",
2721
1809
  display: false
2722
1810
  })
1811
+ },
1812
+ eventType: {
1813
+ type: String,
1814
+ default: "click"
2723
1815
  }
2724
1816
  },
2725
1817
  setup(props) {
2726
1818
  const services = vue.inject("services");
2727
1819
  const uiService = services?.uiService;
2728
- const zoomInHandler = () => uiService?.set("zoom", zoom.value + 0.1);
2729
- const zoomOutHandler = () => uiService?.set("zoom", zoom.value - 0.1);
2730
1820
  const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
2731
1821
  const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
2732
1822
  const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
1823
+ const zoomInHandler = () => uiService?.zoom(0.1);
1824
+ const zoomOutHandler = () => uiService?.zoom(-0.1);
2733
1825
  const item = vue.computed(() => {
2734
1826
  if (typeof props.data !== "string") {
2735
1827
  return props.data;
@@ -2746,7 +1838,7 @@
2746
1838
  case "delete":
2747
1839
  return {
2748
1840
  type: "button",
2749
- icon: icons.Delete,
1841
+ icon: vue.markRaw(icons.Delete),
2750
1842
  tooltip: "\u522A\u9664",
2751
1843
  disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
2752
1844
  handler: () => services?.editorService.remove(services?.editorService.get("node"))
@@ -2754,7 +1846,7 @@
2754
1846
  case "undo":
2755
1847
  return {
2756
1848
  type: "button",
2757
- icon: icons.Back,
1849
+ icon: vue.markRaw(icons.Back),
2758
1850
  tooltip: "\u540E\u9000",
2759
1851
  disabled: () => !services?.historyService.state.canUndo,
2760
1852
  handler: () => services?.editorService.undo()
@@ -2762,7 +1854,7 @@
2762
1854
  case "redo":
2763
1855
  return {
2764
1856
  type: "button",
2765
- icon: icons.Right,
1857
+ icon: vue.markRaw(icons.Right),
2766
1858
  tooltip: "\u524D\u8FDB",
2767
1859
  disabled: () => !services?.historyService.state.canRedo,
2768
1860
  handler: () => services?.editorService.redo()
@@ -2770,28 +1862,28 @@
2770
1862
  case "zoom-in":
2771
1863
  return {
2772
1864
  type: "button",
2773
- icon: icons.ZoomIn,
1865
+ icon: vue.markRaw(icons.ZoomIn),
2774
1866
  tooltip: "\u653E\u5927",
2775
1867
  handler: zoomInHandler
2776
1868
  };
2777
1869
  case "zoom-out":
2778
1870
  return {
2779
1871
  type: "button",
2780
- icon: icons.ZoomOut,
1872
+ icon: vue.markRaw(icons.ZoomOut),
2781
1873
  tooltip: "\u7E2E\u5C0F",
2782
1874
  handler: zoomOutHandler
2783
1875
  };
2784
1876
  case "rule":
2785
1877
  return {
2786
1878
  type: "button",
2787
- icon: icons.ScaleToOriginal,
1879
+ icon: vue.markRaw(icons.ScaleToOriginal),
2788
1880
  tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
2789
1881
  handler: () => uiService?.set("showRule", !showRule.value)
2790
1882
  };
2791
1883
  case "guides":
2792
1884
  return {
2793
1885
  type: "button",
2794
- icon: icons.Grid,
1886
+ icon: vue.markRaw(icons.Grid),
2795
1887
  tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
2796
1888
  handler: () => uiService?.set("showGuides", !showGuides.value)
2797
1889
  };
@@ -2812,9 +1904,16 @@
2812
1904
  }
2813
1905
  return item.value.disabled;
2814
1906
  });
1907
+ const buttonHandler = (item2, event) => {
1908
+ if (disabled.value)
1909
+ return;
1910
+ if (typeof item2.handler === "function" && services) {
1911
+ item2.handler?.(services, event);
1912
+ }
1913
+ };
2815
1914
  return {
2816
- ZoomIn: icons.ZoomIn,
2817
- ZoomOut: icons.ZoomOut,
1915
+ ZoomIn: vue.markRaw(icons.ZoomIn),
1916
+ ZoomOut: vue.markRaw(icons.ZoomOut),
2818
1917
  item,
2819
1918
  zoom,
2820
1919
  disabled,
@@ -2835,31 +1934,42 @@
2835
1934
  command.item.handler(services);
2836
1935
  }
2837
1936
  },
2838
- buttonHandler(item2) {
2839
- if (disabled.value)
1937
+ clickHandler(item2, event) {
1938
+ if (props.eventType !== "click")
1939
+ return;
1940
+ if (item2.type === "button") {
1941
+ buttonHandler(item2, event);
1942
+ }
1943
+ },
1944
+ mousedownHandler(item2, event) {
1945
+ if (props.eventType !== "mousedown")
1946
+ return;
1947
+ if (item2.type === "button") {
1948
+ buttonHandler(item2, event);
1949
+ }
1950
+ },
1951
+ mouseupHandler(item2, event) {
1952
+ if (props.eventType !== "mouseup")
2840
1953
  return;
2841
- if (typeof item2.handler === "function") {
2842
- item2.handler?.(services);
1954
+ if (item2.type === "button") {
1955
+ buttonHandler(item2, event);
2843
1956
  }
2844
1957
  }
2845
1958
  };
2846
1959
  }
2847
1960
  });
2848
- const _hoisted_1$8 = {
2849
- key: 0,
2850
- class: "menu-item"
2851
- };
2852
- const _hoisted_2$4 = {
1961
+ const _hoisted_1$6 = {
2853
1962
  key: 1,
2854
1963
  class: "menu-item-text"
2855
1964
  };
2856
- const _hoisted_3$3 = {
1965
+ const _hoisted_2$2 = {
2857
1966
  class: "menu-item-text",
2858
1967
  style: { "margin": "0 5px" }
2859
1968
  };
2860
- const _hoisted_4$3 = { class: "el-dropdown-link menubar-menu-button" };
2861
- function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
1969
+ const _hoisted_3$1 = { class: "el-dropdown-link menubar-menu-button" };
1970
+ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2862
1971
  const _component_el_divider = vue.resolveComponent("el-divider");
1972
+ const _component_tool_button = vue.resolveComponent("tool-button", true);
2863
1973
  const _component_m_icon = vue.resolveComponent("m-icon");
2864
1974
  const _component_el_button = vue.resolveComponent("el-button");
2865
1975
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -2868,44 +1978,66 @@
2868
1978
  const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
2869
1979
  const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
2870
1980
  const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2871
- return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
1981
+ return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", {
1982
+ key: 0,
1983
+ class: vue.normalizeClass(["menu-item", _ctx.item.type]),
1984
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickHandler(_ctx.item, $event)),
1985
+ onMousedown: _cache[1] || (_cache[1] = ($event) => _ctx.mousedownHandler(_ctx.item, $event)),
1986
+ onMouseup: _cache[2] || (_cache[2] = ($event) => _ctx.mouseupHandler(_ctx.item, $event))
1987
+ }, [
2872
1988
  _ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2873
1989
  key: 0,
2874
- direction: "vertical"
2875
- })) : _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 }, [
2876
- vue.createVNode(_component_m_icon, {
2877
- icon: _ctx.ZoomIn,
2878
- onClick: _ctx.zoomInHandler
2879
- }, null, 8, ["icon", "onClick"]),
2880
- vue.createElementVNode("span", _hoisted_3$3, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
2881
- vue.createVNode(_component_m_icon, {
2882
- icon: _ctx.ZoomOut,
2883
- onClick: _ctx.zoomOutHandler
2884
- }, null, 8, ["icon", "onClick"])
2885
- ], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2886
- key: 3,
2887
- effect: "dark",
2888
- placement: "bottom-start",
2889
- content: _ctx.item.tooltip || _ctx.item.text
2890
- }, {
2891
- default: vue.withCtx(() => [
2892
- vue.createVNode(_component_el_button, {
2893
- size: "small",
2894
- type: "text",
2895
- disabled: _ctx.disabled,
2896
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.buttonHandler(_ctx.item))
2897
- }, {
2898
- default: vue.withCtx(() => [
2899
- vue.createVNode(_component_m_icon, {
2900
- icon: _ctx.item.icon
2901
- }, null, 8, ["icon"]),
2902
- vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2903
- ]),
2904
- _: 1
2905
- }, 8, ["disabled"])
2906
- ]),
2907
- _: 1
2908
- }, 8, ["content"])) : _ctx.item.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
1990
+ direction: _ctx.item.direction || "vertical"
1991
+ }, 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 }, [
1992
+ vue.createVNode(_component_tool_button, {
1993
+ data: { type: "button", icon: _ctx.ZoomOut, handler: _ctx.zoomOutHandler, tooltip: "\u7F29\u5C0F" },
1994
+ "event-type": _ctx.eventType
1995
+ }, null, 8, ["data", "event-type"]),
1996
+ vue.createElementVNode("span", _hoisted_2$2, vue.toDisplayString(parseInt(`${_ctx.zoom * 100}`, 10)) + "%", 1),
1997
+ vue.createVNode(_component_tool_button, {
1998
+ data: { type: "button", icon: _ctx.ZoomIn, handler: _ctx.zoomInHandler, tooltip: "\u653E\u5927" },
1999
+ "event-type": _ctx.eventType
2000
+ }, null, 8, ["data", "event-type"])
2001
+ ], 64)) : _ctx.item.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
2002
+ _ctx.item.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2003
+ key: 0,
2004
+ effect: "dark",
2005
+ placement: "bottom-start",
2006
+ content: _ctx.item.tooltip
2007
+ }, {
2008
+ default: vue.withCtx(() => [
2009
+ vue.createVNode(_component_el_button, {
2010
+ size: "small",
2011
+ text: "",
2012
+ disabled: _ctx.disabled
2013
+ }, {
2014
+ default: vue.withCtx(() => [
2015
+ _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2016
+ key: 0,
2017
+ icon: _ctx.item.icon
2018
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2019
+ vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2020
+ ]),
2021
+ _: 1
2022
+ }, 8, ["disabled"])
2023
+ ]),
2024
+ _: 1
2025
+ }, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
2026
+ key: 1,
2027
+ size: "small",
2028
+ text: "",
2029
+ disabled: _ctx.disabled
2030
+ }, {
2031
+ default: vue.withCtx(() => [
2032
+ _ctx.item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2033
+ key: 0,
2034
+ icon: _ctx.item.icon
2035
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2036
+ vue.createElementVNode("span", null, vue.toDisplayString(_ctx.item.text), 1)
2037
+ ]),
2038
+ _: 1
2039
+ }, 8, ["disabled"]))
2040
+ ], 64)) : _ctx.item.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2909
2041
  key: 4,
2910
2042
  trigger: "click",
2911
2043
  disabled: _ctx.disabled,
@@ -2930,7 +2062,7 @@
2930
2062
  })) : vue.createCommentVNode("", true)
2931
2063
  ]),
2932
2064
  default: vue.withCtx(() => [
2933
- vue.createElementVNode("span", _hoisted_4$3, [
2065
+ vue.createElementVNode("span", _hoisted_3$1, [
2934
2066
  vue.createTextVNode(vue.toDisplayString(_ctx.item.text), 1),
2935
2067
  vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
2936
2068
  default: vue.withCtx(() => [
@@ -2942,11 +2074,11 @@
2942
2074
  ]),
2943
2075
  _: 1
2944
2076
  }, 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)
2945
- ])) : vue.createCommentVNode("", true);
2077
+ ], 34)) : vue.createCommentVNode("", true);
2946
2078
  }
2947
- var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
2079
+ var ToolButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$e]]);
2948
2080
 
2949
- const _sfc_main$b = vue.defineComponent({
2081
+ const _sfc_main$d = vue.defineComponent({
2950
2082
  name: "nav-menu",
2951
2083
  components: { ToolButton },
2952
2084
  props: {
@@ -2966,7 +2098,7 @@
2966
2098
  };
2967
2099
  }
2968
2100
  });
2969
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
2101
+ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2970
2102
  const _component_tool_button = vue.resolveComponent("tool-button");
2971
2103
  return vue.openBlock(), vue.createElementBlock("div", {
2972
2104
  class: "m-editor-nav-menu",
@@ -2988,9 +2120,9 @@
2988
2120
  }), 128))
2989
2121
  ], 4);
2990
2122
  }
2991
- var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
2123
+ var NavMenu = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$d]]);
2992
2124
 
2993
- const _sfc_main$a = vue.defineComponent({
2125
+ const _sfc_main$c = vue.defineComponent({
2994
2126
  name: "m-editor-props-panel",
2995
2127
  emits: ["mounted"],
2996
2128
  setup(props, { emit }) {
@@ -3005,9 +2137,9 @@
3005
2137
  curFormConfig.value = [];
3006
2138
  return;
3007
2139
  }
3008
- values.value = node.value;
3009
2140
  const type = node.value.type || (node.value.items ? "container" : "text");
3010
2141
  curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
2142
+ values.value = node.value;
3011
2143
  };
3012
2144
  vue.watchEffect(init);
3013
2145
  services?.propsService.on("props-configs-change", init);
@@ -3018,6 +2150,7 @@
3018
2150
  values,
3019
2151
  configForm,
3020
2152
  curFormConfig,
2153
+ propsPanelSize: vue.computed(() => services?.uiService.get("propsPanelSize") || "small"),
3021
2154
  async submit() {
3022
2155
  try {
3023
2156
  const values2 = await configForm.value?.submitForm();
@@ -3036,21 +2169,21 @@
3036
2169
  };
3037
2170
  }
3038
2171
  });
3039
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2172
+ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
3040
2173
  const _component_m_form = vue.resolveComponent("m-form");
3041
2174
  return vue.openBlock(), vue.createBlock(_component_m_form, {
3042
- class: "m-editor-props-panel",
3043
- "popper-class": "m-editor-props-panel-popper",
2175
+ class: vue.normalizeClass(`m-editor-props-panel ${_ctx.propsPanelSize}`),
2176
+ "popper-class": `m-editor-props-panel-popper ${_ctx.propsPanelSize}`,
3044
2177
  ref: "configForm",
3045
- size: "small",
2178
+ size: _ctx.propsPanelSize,
3046
2179
  "init-values": _ctx.values,
3047
2180
  config: _ctx.curFormConfig,
3048
2181
  onChange: _ctx.submit
3049
- }, null, 8, ["init-values", "config", "onChange"]);
2182
+ }, null, 8, ["class", "popper-class", "size", "init-values", "config", "onChange"]);
3050
2183
  }
3051
- var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
2184
+ var PropsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);
3052
2185
 
3053
- const _sfc_main$9 = vue.defineComponent({
2186
+ const _sfc_main$b = vue.defineComponent({
3054
2187
  name: "ui-component-panel",
3055
2188
  components: { MIcon },
3056
2189
  setup() {
@@ -3065,19 +2198,29 @@
3065
2198
  searchText,
3066
2199
  collapseValue,
3067
2200
  list,
3068
- appendComponent({ text, type, ...config }) {
2201
+ appendComponent({ text, type, data = {} }) {
3069
2202
  services?.editorService.add({
3070
2203
  name: text,
3071
2204
  type,
3072
- ...config
2205
+ ...data
3073
2206
  });
2207
+ },
2208
+ dragstartHandler({ text, type, data = {} }, e) {
2209
+ if (e.dataTransfer) {
2210
+ e.dataTransfer.effectAllowed = "move";
2211
+ e.dataTransfer.setData("data", serialize__default["default"]({
2212
+ name: text,
2213
+ type,
2214
+ ...data
2215
+ }).replace(/"(\w+)":\s/g, "$1: "));
2216
+ }
3074
2217
  }
3075
2218
  };
3076
2219
  }
3077
2220
  });
3078
- const _hoisted_1$7 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3079
- const _hoisted_2$3 = ["onClick"];
3080
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2221
+ const _hoisted_1$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2222
+ const _hoisted_2$1 = ["onClick", "onDragstart"];
2223
+ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
3081
2224
  const _component_el_input = vue.resolveComponent("el-input");
3082
2225
  const _component_m_icon = vue.resolveComponent("m-icon");
3083
2226
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
@@ -3107,15 +2250,17 @@
3107
2250
  name: index
3108
2251
  }, {
3109
2252
  title: vue.withCtx(() => [
3110
- _hoisted_1$7,
2253
+ _hoisted_1$5,
3111
2254
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
3112
2255
  ]),
3113
2256
  default: vue.withCtx(() => [
3114
2257
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.items, (item) => {
3115
2258
  return vue.openBlock(), vue.createElementBlock("div", {
3116
2259
  class: "component-item",
2260
+ draggable: "true",
3117
2261
  key: item.type,
3118
- onClick: ($event) => _ctx.appendComponent(item)
2262
+ onClick: ($event) => _ctx.appendComponent(item),
2263
+ onDragstart: ($event) => _ctx.dragstartHandler(item, $event)
3119
2264
  }, [
3120
2265
  vue.createVNode(_component_m_icon, {
3121
2266
  icon: item.icon
@@ -3130,7 +2275,7 @@
3130
2275
  ]),
3131
2276
  _: 2
3132
2277
  }, 1032, ["content"])
3133
- ], 8, _hoisted_2$3);
2278
+ ], 40, _hoisted_2$1);
3134
2279
  }), 128))
3135
2280
  ]),
3136
2281
  _: 2
@@ -3144,133 +2289,237 @@
3144
2289
  _: 1
3145
2290
  });
3146
2291
  }
3147
- var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
2292
+ var ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
3148
2293
 
3149
- const _sfc_main$8 = vue.defineComponent({
3150
- name: "magic-editor-content-menu",
2294
+ const _sfc_main$a = vue.defineComponent({
2295
+ components: { ToolButton },
3151
2296
  props: {
3152
- componentGroupList: {
2297
+ menuData: {
3153
2298
  type: Array,
3154
2299
  default: () => []
2300
+ },
2301
+ isSubMenu: {
2302
+ type: Boolean,
2303
+ default: false
3155
2304
  }
3156
2305
  },
3157
- setup(props) {
2306
+ emits: ["hide", "show"],
2307
+ setup(props, { emit }) {
2308
+ const menu = vue.ref();
2309
+ const subMenu = vue.ref();
2310
+ const visible = vue.ref(false);
2311
+ const subMenuData = vue.ref([]);
2312
+ const menuStyle = vue.ref({
2313
+ left: "0",
2314
+ top: "0"
2315
+ });
2316
+ const hide = () => {
2317
+ if (!visible.value)
2318
+ return;
2319
+ visible.value = false;
2320
+ subMenu.value?.hide();
2321
+ emit("hide");
2322
+ };
2323
+ const hideHandler = (e) => {
2324
+ const target = e.target;
2325
+ if (!visible.value || !target) {
2326
+ return;
2327
+ }
2328
+ if (menu.value?.contains(target) || subMenu.value?.$el?.contains(target)) {
2329
+ return;
2330
+ }
2331
+ hide();
2332
+ };
2333
+ vue.onMounted(() => {
2334
+ if (props.isSubMenu)
2335
+ return;
2336
+ globalThis.addEventListener("mousedown", hideHandler, true);
2337
+ });
2338
+ vue.onUnmounted(() => {
2339
+ if (props.isSubMenu)
2340
+ return;
2341
+ globalThis.removeEventListener("mousedown", hideHandler, true);
2342
+ });
2343
+ return {
2344
+ menu,
2345
+ subMenu,
2346
+ visible,
2347
+ menuStyle,
2348
+ subMenuData,
2349
+ hide,
2350
+ show(e) {
2351
+ setTimeout(() => {
2352
+ visible.value = true;
2353
+ vue.nextTick(() => {
2354
+ const menuHeight = menu.value?.clientHeight || 0;
2355
+ let top = e.clientY;
2356
+ if (menuHeight + e.clientY > document.body.clientHeight) {
2357
+ top = document.body.clientHeight - menuHeight;
2358
+ }
2359
+ menuStyle.value = {
2360
+ top: `${top}px`,
2361
+ left: `${e.clientX}px`
2362
+ };
2363
+ emit("show");
2364
+ });
2365
+ }, 300);
2366
+ },
2367
+ showSubMenu(item) {
2368
+ const menuItem = item;
2369
+ if (typeof item !== "object" || !menuItem.items?.length) {
2370
+ return;
2371
+ }
2372
+ subMenuData.value = menuItem.items;
2373
+ if (menu.value) {
2374
+ subMenu.value.show({
2375
+ clientX: menu.value.offsetLeft + menu.value.clientWidth,
2376
+ clientY: menu.value.offsetTop
2377
+ });
2378
+ }
2379
+ }
2380
+ };
2381
+ }
2382
+ });
2383
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
2384
+ const _component_tool_button = vue.resolveComponent("tool-button");
2385
+ const _component_content_menu = vue.resolveComponent("content-menu", true);
2386
+ return _ctx.menuData.length && _ctx.visible ? (vue.openBlock(), vue.createElementBlock("div", {
2387
+ key: 0,
2388
+ class: "magic-editor-content-menu",
2389
+ ref: "menu",
2390
+ style: vue.normalizeStyle(_ctx.menuStyle)
2391
+ }, [
2392
+ vue.createElementVNode("div", null, [
2393
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
2394
+ return vue.openBlock(), vue.createBlock(_component_tool_button, {
2395
+ "event-type": "mouseup",
2396
+ data: item,
2397
+ key: index,
2398
+ onMouseup: _ctx.hide,
2399
+ onMouseenter: ($event) => _ctx.showSubMenu(item)
2400
+ }, null, 8, ["data", "onMouseup", "onMouseenter"]);
2401
+ }), 128))
2402
+ ]),
2403
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
2404
+ vue.createVNode(_component_content_menu, {
2405
+ class: "sub-menu",
2406
+ ref: "subMenu",
2407
+ "menu-data": _ctx.subMenuData,
2408
+ "is-sub-menu": true,
2409
+ onHide: _ctx.hide
2410
+ }, null, 8, ["menu-data", "onHide"])
2411
+ ]))
2412
+ ], 4)) : vue.createCommentVNode("", true);
2413
+ }
2414
+ var ContentMenu = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a]]);
2415
+
2416
+ const _sfc_main$9 = vue.defineComponent({
2417
+ components: { ContentMenu },
2418
+ setup() {
3158
2419
  const services = vue.inject("services");
3159
- const subVisible = vue.ref(false);
2420
+ const menu = vue.ref();
3160
2421
  const node = vue.computed(() => services?.editorService.get("node"));
3161
- return {
3162
- subVisible,
3163
- node,
3164
- menu: vue.computed(() => ({
3165
- app: [
3166
- {
3167
- type: "page",
3168
- text: "\u9875\u9762"
3169
- }
3170
- ],
3171
- component: props.componentGroupList
3172
- })),
3173
- append(config) {
2422
+ const isRoot = vue.computed(() => node.value?.type === schema.NodeType.ROOT);
2423
+ const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
2424
+ const componentList = vue.computed(() => services?.componentListService.getList() || []);
2425
+ const layerContentMenu = vue.inject("layerContentMenu", []);
2426
+ const createMenuItems = (group) => group.items.map((component) => ({
2427
+ text: component.text,
2428
+ type: "button",
2429
+ icon: component.icon,
2430
+ handler: () => {
3174
2431
  services?.editorService.add({
3175
- name: config.text,
3176
- type: config.type
2432
+ name: component.text,
2433
+ type: component.type,
2434
+ ...component.data || {}
3177
2435
  });
3178
- },
3179
- remove() {
3180
- node.value && services?.editorService.remove(node.value);
3181
- },
3182
- copy(node2) {
3183
- services?.editorService.copy(node2);
3184
- },
3185
- setSubVisiable(v) {
3186
- subVisible.value = v;
2436
+ }
2437
+ }));
2438
+ const getSubMenuData = vue.computed(() => {
2439
+ if (node.value?.type === "tabs") {
2440
+ return [
2441
+ {
2442
+ text: "\u6807\u7B7E\u9875",
2443
+ type: "button",
2444
+ icon: icons.Files,
2445
+ handler: () => {
2446
+ services?.editorService.add({
2447
+ type: "tab-pane"
2448
+ });
2449
+ }
2450
+ }
2451
+ ];
2452
+ }
2453
+ if (node.value?.items) {
2454
+ return componentList.value.reduce((subMenuData, group, index) => subMenuData.concat(createMenuItems(group), index < componentList.value.length - 1 ? [
2455
+ {
2456
+ type: "divider",
2457
+ direction: "horizontal"
2458
+ }
2459
+ ] : []), []) || [];
2460
+ }
2461
+ return [];
2462
+ });
2463
+ return {
2464
+ menu,
2465
+ menuData: vue.computed(() => [
2466
+ {
2467
+ type: "button",
2468
+ text: "\u65B0\u589E",
2469
+ icon: vue.markRaw(icons.Plus),
2470
+ display: () => node.value?.items,
2471
+ items: getSubMenuData.value
2472
+ },
2473
+ {
2474
+ type: "button",
2475
+ text: "\u590D\u5236",
2476
+ icon: vue.markRaw(icons.DocumentCopy),
2477
+ display: () => !isRoot.value,
2478
+ handler: () => {
2479
+ node.value && services?.editorService.copy(node.value);
2480
+ }
2481
+ },
2482
+ {
2483
+ type: "button",
2484
+ text: "\u5220\u9664",
2485
+ icon: vue.markRaw(icons.Delete),
2486
+ display: () => !isRoot.value && !isPage.value,
2487
+ handler: () => {
2488
+ node.value && services?.editorService.remove(node.value);
2489
+ }
2490
+ },
2491
+ ...layerContentMenu
2492
+ ]),
2493
+ show(e) {
2494
+ menu.value?.show(e);
3187
2495
  }
3188
2496
  };
3189
2497
  }
3190
2498
  });
3191
- const _hoisted_1$6 = {
3192
- key: 0,
3193
- class: "magic-editor-content-menu"
3194
- };
3195
- const _hoisted_2$2 = ["onClick"];
3196
- const _hoisted_3$2 = ["onClick"];
3197
- const _hoisted_4$2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3198
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
3199
- const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
3200
- return _ctx.node ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
3201
- _ctx.node.items ? (vue.openBlock(), vue.createElementBlock("div", {
3202
- key: 0,
3203
- class: "magic-editor-content-menu-item",
3204
- onMouseenter: _cache[0] || (_cache[0] = ($event) => _ctx.setSubVisiable(true)),
3205
- onMouseleave: _cache[1] || (_cache[1] = ($event) => _ctx.setSubVisiable(false))
3206
- }, " \u65B0\u589E ", 32)) : vue.createCommentVNode("", true),
3207
- _ctx.node.type !== "app" ? (vue.openBlock(), vue.createElementBlock("div", {
3208
- key: 1,
3209
- class: "magic-editor-content-menu-item",
3210
- onClick: _cache[2] || (_cache[2] = () => _ctx.copy(_ctx.node))
3211
- }, "\u590D\u5236")) : vue.createCommentVNode("", true),
3212
- _ctx.node.type !== "app" && _ctx.node.type !== "page" ? (vue.openBlock(), vue.createElementBlock("div", {
3213
- key: 2,
3214
- class: "magic-editor-content-menu-item",
3215
- onClick: _cache[3] || (_cache[3] = () => _ctx.remove())
3216
- }, " \u5220\u9664 ")) : vue.createCommentVNode("", true),
3217
- vue.withDirectives(vue.createElementVNode("div", {
3218
- class: "subMenu",
3219
- onMouseenter: _cache[5] || (_cache[5] = ($event) => _ctx.setSubVisiable(true)),
3220
- onMouseleave: _cache[6] || (_cache[6] = ($event) => _ctx.setSubVisiable(false))
3221
- }, [
3222
- vue.createVNode(_component_el_scrollbar, null, {
3223
- default: vue.withCtx(() => [
3224
- _ctx.node.type === "tabs" ? (vue.openBlock(), vue.createElementBlock("div", {
3225
- key: 0,
3226
- class: "magic-editor-content-menu-item",
3227
- onClick: _cache[4] || (_cache[4] = () => _ctx.append({
3228
- type: "tab-pane"
3229
- }))
3230
- }, " \u6807\u7B7E ")) : _ctx.node.type === "app" ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(_ctx.menu.app, (item) => {
3231
- return vue.openBlock(), vue.createElementBlock("div", {
3232
- class: "magic-editor-content-menu-item",
3233
- key: item.type,
3234
- onClick: () => _ctx.append(item)
3235
- }, vue.toDisplayString(item.text), 9, _hoisted_2$2);
3236
- }), 128)) : _ctx.node.items ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 2 }, vue.renderList(_ctx.menu.component, (list) => {
3237
- return vue.openBlock(), vue.createElementBlock("div", {
3238
- key: list.title
3239
- }, [
3240
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.items, (item) => {
3241
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
3242
- item ? (vue.openBlock(), vue.createElementBlock("div", {
3243
- class: "magic-editor-content-menu-item",
3244
- key: item.type,
3245
- onClick: () => _ctx.append(item)
3246
- }, vue.toDisplayString(item.text), 9, _hoisted_3$2)) : vue.createCommentVNode("", true)
3247
- ], 64);
3248
- }), 256)),
3249
- _hoisted_4$2
3250
- ]);
3251
- }), 128)) : vue.createCommentVNode("", true)
3252
- ]),
3253
- _: 1
3254
- })
3255
- ], 544), [
3256
- [vue.vShow, _ctx.subVisible]
3257
- ])
3258
- ])) : vue.createCommentVNode("", true);
2499
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
2500
+ const _component_content_menu = vue.resolveComponent("content-menu");
2501
+ return vue.openBlock(), vue.createBlock(_component_content_menu, {
2502
+ "menu-data": _ctx.menuData,
2503
+ ref: "menu",
2504
+ style: { "overflow": "initial" }
2505
+ }, null, 8, ["menu-data"]);
3259
2506
  }
3260
- var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
2507
+ var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9]]);
3261
2508
 
3262
2509
  const throttleTime = 150;
3263
- const select = (data, editorService) => {
2510
+ const select = async (data, editorService) => {
3264
2511
  if (!data.id) {
3265
2512
  throw new Error("\u6CA1\u6709id");
3266
2513
  }
3267
- editorService?.select(data);
2514
+ await editorService?.select(data);
2515
+ editorService?.get("stage")?.select(data.id);
3268
2516
  };
3269
2517
  const highlight = (data, editorService) => {
3270
2518
  if (!data?.id) {
3271
2519
  throw new Error("\u6CA1\u6709id");
3272
2520
  }
3273
2521
  editorService?.highlight(data);
2522
+ editorService?.get("stage")?.highlight(data.id);
3274
2523
  };
3275
2524
  const useDrop = (tree, editorService) => ({
3276
2525
  allowDrop: (draggingNode, dropNode, type) => {
@@ -3325,7 +2574,8 @@
3325
2574
  resolve([]);
3326
2575
  },
3327
2576
  highlightNode,
3328
- clickNode: node
2577
+ clickNode: node,
2578
+ expandedKeys: vue.computed(() => node.value ? [node.value.id] : [])
3329
2579
  };
3330
2580
  };
3331
2581
  const useFilter = (tree) => ({
@@ -3337,67 +2587,46 @@
3337
2587
  let name = "";
3338
2588
  if (data.name) {
3339
2589
  name = data.name;
3340
- } else if (data.type) {
3341
- name = data.type;
3342
2590
  } else if (data.items) {
3343
2591
  name = "container";
3344
2592
  }
3345
- return name.indexOf(value) !== -1;
2593
+ return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
3346
2594
  },
3347
2595
  filterTextChangeHandler(val) {
3348
2596
  tree.value?.filter(val);
3349
2597
  }
3350
2598
  });
3351
- const useContentMenu = (editorService) => {
3352
- const menuStyle = vue.ref({
3353
- position: "absolute",
3354
- left: "0",
3355
- top: "0",
3356
- display: "none"
3357
- });
3358
- vue.onMounted(() => {
3359
- document.addEventListener("click", () => {
3360
- menuStyle.value.display = "none";
3361
- }, true);
3362
- });
3363
- return {
3364
- menuStyle,
3365
- contextmenu(event, data) {
3366
- const bodyHeight = globalThis.document.body.clientHeight;
3367
- const left = `${event.clientX + 20}px`;
3368
- let top = `${event.clientY - 10}px`;
3369
- if (event.clientY + 300 > bodyHeight) {
3370
- top = `${bodyHeight - 300}px`;
3371
- }
3372
- menuStyle.value.left = left;
3373
- menuStyle.value.top = top;
3374
- menuStyle.value.display = "";
3375
- select(data, editorService);
3376
- }
3377
- };
3378
- };
3379
- const _sfc_main$7 = vue.defineComponent({
2599
+ const _sfc_main$8 = vue.defineComponent({
3380
2600
  name: "magic-editor-layer-panel",
3381
2601
  components: { LayerMenu },
3382
2602
  setup() {
3383
2603
  const services = vue.inject("services");
3384
2604
  const tree = vue.ref();
2605
+ const menu = vue.ref();
3385
2606
  const clicked = vue.ref(false);
3386
2607
  const editorService = services?.editorService;
3387
2608
  const highlightHandler = lodashEs.throttle((data) => {
3388
2609
  highlight(data, editorService);
3389
2610
  }, throttleTime);
3390
- const toogleClickFlag = () => {
2611
+ const toggleClickFlag = () => {
3391
2612
  clicked.value = !clicked.value;
3392
2613
  };
3393
2614
  const statusData = useStatus(tree, editorService);
3394
2615
  const canHighlight = vue.computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
2616
+ editorService?.on("remove", () => {
2617
+ setTimeout(() => {
2618
+ tree.value?.getNode(editorService.get("node").id)?.updateChildren();
2619
+ }, 0);
2620
+ });
3395
2621
  return {
3396
2622
  tree,
2623
+ menu,
3397
2624
  ...statusData,
3398
2625
  ...useDrop(tree, editorService),
3399
2626
  ...useFilter(tree),
3400
- ...useContentMenu(editorService),
2627
+ highlightHandler,
2628
+ toggleClickFlag,
2629
+ canHighlight,
3401
2630
  clickHandler(data) {
3402
2631
  if (services?.uiService.get("uiSelectMode")) {
3403
2632
  document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
@@ -3406,14 +2635,16 @@
3406
2635
  tree.value?.setCurrentKey(data.id);
3407
2636
  select(data, editorService);
3408
2637
  },
3409
- highlightHandler,
3410
- toogleClickFlag,
3411
- canHighlight
2638
+ async contextmenu(event, data) {
2639
+ event.preventDefault();
2640
+ await select(data, editorService);
2641
+ menu.value?.show(event);
2642
+ }
3412
2643
  };
3413
2644
  }
3414
2645
  });
3415
- const _hoisted_1$5 = ["id", "onMouseenter"];
3416
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2646
+ const _hoisted_1$4 = ["id", "onMouseenter"];
2647
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
3417
2648
  const _component_el_input = vue.resolveComponent("el-input");
3418
2649
  const _component_el_tree = vue.resolveComponent("el-tree");
3419
2650
  const _component_layer_menu = vue.resolveComponent("layer-menu");
@@ -3434,6 +2665,7 @@
3434
2665
  ref: "tree",
3435
2666
  "node-key": "id",
3436
2667
  draggable: "",
2668
+ "default-expanded-keys": _ctx.expandedKeys,
3437
2669
  load: _ctx.loadItems,
3438
2670
  data: _ctx.values,
3439
2671
  "expand-on-click-node": false,
@@ -3452,8 +2684,8 @@
3452
2684
  vue.createElementVNode("div", {
3453
2685
  id: data.id,
3454
2686
  class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
3455
- onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
3456
- onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
2687
+ onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
2688
+ onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
3457
2689
  onMouseenter: ($event) => _ctx.highlightHandler(data)
3458
2690
  }, [
3459
2691
  vue.renderSlot(_ctx.$slots, "layer-node-content", {
@@ -3462,42 +2694,33 @@
3462
2694
  }, () => [
3463
2695
  vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
3464
2696
  ])
3465
- ], 42, _hoisted_1$5)
2697
+ ], 42, _hoisted_1$4)
3466
2698
  ]),
3467
2699
  _: 3
3468
- }, 8, ["load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
2700
+ }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
3469
2701
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3470
- vue.createVNode(_component_layer_menu, {
3471
- style: vue.normalizeStyle(_ctx.menuStyle)
3472
- }, null, 8, ["style"])
2702
+ vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
3473
2703
  ]))
3474
2704
  ]),
3475
2705
  _: 3
3476
2706
  });
3477
2707
  }
3478
- var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
2708
+ var LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
3479
2709
 
3480
- const _sfc_main$6 = vue.defineComponent({
3481
- name: "m-sidebar",
2710
+ const _sfc_main$7 = vue.defineComponent({
3482
2711
  components: { MIcon },
3483
2712
  props: {
3484
2713
  data: {
3485
- type: Object,
3486
- default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
2714
+ type: [Object, String]
3487
2715
  }
3488
2716
  },
3489
2717
  setup(props) {
3490
- const activeTabName = vue.ref(props.data?.status);
3491
- vue.watch(() => props.data?.status, (status) => {
3492
- activeTabName.value = status || "0";
3493
- });
3494
2718
  return {
3495
- activeTabName,
3496
- items: vue.computed(() => props.data?.items.map((item) => {
3497
- if (typeof item !== "string") {
3498
- return item;
2719
+ config: vue.computed(() => {
2720
+ if (typeof props.data !== "string") {
2721
+ return props.data;
3499
2722
  }
3500
- switch (item) {
2723
+ switch (props.data) {
3501
2724
  case "component-list":
3502
2725
  return {
3503
2726
  type: "component",
@@ -3515,21 +2738,75 @@
3515
2738
  slots: {}
3516
2739
  };
3517
2740
  default:
3518
- return {};
2741
+ return void 0;
3519
2742
  }
3520
- }))
2743
+ })
3521
2744
  };
3522
2745
  }
3523
2746
  });
3524
- const _hoisted_1$4 = {
2747
+ const _hoisted_1$3 = {
3525
2748
  key: 1,
3526
2749
  class: "magic-editor-tab-panel-title"
3527
2750
  };
3528
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2751
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3529
2752
  const _component_m_icon = vue.resolveComponent("m-icon");
3530
2753
  const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
2754
+ return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
2755
+ key: 0,
2756
+ name: _ctx.config.text
2757
+ }, {
2758
+ label: vue.withCtx(() => [
2759
+ (vue.openBlock(), vue.createElementBlock("div", {
2760
+ key: _ctx.config.text
2761
+ }, [
2762
+ _ctx.config.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
2763
+ key: 0,
2764
+ icon: _ctx.config.icon
2765
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
2766
+ _ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, vue.toDisplayString(_ctx.config.text), 1)) : vue.createCommentVNode("", true)
2767
+ ]))
2768
+ ]),
2769
+ default: vue.withCtx(() => [
2770
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.component), vue.mergeProps(_ctx.config.props || {}, vue.toHandlers(_ctx.config?.listeners || {})), vue.createSlots({ _: 2 }, [
2771
+ _ctx.config.slots?.layerNodeContent ? {
2772
+ name: "layer-node-content",
2773
+ fn: vue.withCtx(({ data, node }) => [
2774
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots?.layerNodeContent), {
2775
+ data,
2776
+ node
2777
+ }, null, 8, ["data", "node"]))
2778
+ ])
2779
+ } : void 0
2780
+ ]), 1040))
2781
+ ]),
2782
+ _: 1
2783
+ }, 8, ["name"])) : vue.createCommentVNode("", true);
2784
+ }
2785
+ var TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
2786
+
2787
+ const _sfc_main$6 = vue.defineComponent({
2788
+ components: { TabPane },
2789
+ name: "m-sidebar",
2790
+ props: {
2791
+ data: {
2792
+ type: Object,
2793
+ default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
2794
+ }
2795
+ },
2796
+ setup(props) {
2797
+ const activeTabName = vue.ref(props.data?.status);
2798
+ vue.watch(() => props.data?.status, (status) => {
2799
+ activeTabName.value = status || "0";
2800
+ });
2801
+ return {
2802
+ activeTabName
2803
+ };
2804
+ }
2805
+ });
2806
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2807
+ const _component_tab_pane = vue.resolveComponent("tab-pane");
3531
2808
  const _component_el_tabs = vue.resolveComponent("el-tabs");
3532
- return _ctx.data.type === "tabs" ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
2809
+ return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
3533
2810
  key: 0,
3534
2811
  class: "m-editor-sidebar",
3535
2812
  modelValue: _ctx.activeTabName,
@@ -3538,35 +2815,11 @@
3538
2815
  "tab-position": "left"
3539
2816
  }, {
3540
2817
  default: vue.withCtx(() => [
3541
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.items, (item) => {
3542
- return vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
3543
- key: item.text,
3544
- name: item.text
3545
- }, {
3546
- label: vue.withCtx(() => [
3547
- vue.createElementVNode("span", null, [
3548
- item.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
3549
- key: 0,
3550
- icon: item.icon
3551
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
3552
- item.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, vue.toDisplayString(item.text), 1)) : vue.createCommentVNode("", true)
3553
- ])
3554
- ]),
3555
- default: vue.withCtx(() => [
3556
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.component), vue.mergeProps(item.props || {}, vue.toHandlers(item.listeners || {})), vue.createSlots({ _: 2 }, [
3557
- item.slots?.layerNodeContent ? {
3558
- name: "layer-node-content",
3559
- fn: vue.withCtx(({ data, node }) => [
3560
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.slots.layerNodeContent), {
3561
- data,
3562
- node
3563
- }, null, 8, ["data", "node"]))
3564
- ])
3565
- } : void 0
3566
- ]), 1040))
3567
- ]),
3568
- _: 2
3569
- }, 1032, ["name"]);
2818
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data.items, (item, index) => {
2819
+ return vue.openBlock(), vue.createBlock(_component_tab_pane, {
2820
+ key: index,
2821
+ data: item
2822
+ }, null, 8, ["data"]);
3570
2823
  }), 128))
3571
2824
  ]),
3572
2825
  _: 1
@@ -3574,13 +2827,81 @@
3574
2827
  }
3575
2828
  var Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
3576
2829
 
2830
+ const useScroll = (root) => {
2831
+ const pageBar = vue.ref();
2832
+ const itemsContainer = vue.ref();
2833
+ const pageBarWidth = vue.ref(0);
2834
+ const canScroll = vue.ref(false);
2835
+ const itemsContainerWidth = vue.computed(() => pageBarWidth.value - 105);
2836
+ let translateLeft = 0;
2837
+ const resizeObserver = new ResizeObserver((entries) => {
2838
+ for (const { contentRect } of entries) {
2839
+ const { width } = contentRect;
2840
+ pageBarWidth.value = width || 0;
2841
+ setCanScroll();
2842
+ }
2843
+ });
2844
+ const setCanScroll = () => {
2845
+ if (itemsContainer.value) {
2846
+ canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
2847
+ }
2848
+ };
2849
+ const scroll = (type) => {
2850
+ if (!itemsContainer.value)
2851
+ return;
2852
+ const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
2853
+ if (type === "left") {
2854
+ translateLeft += 100;
2855
+ if (translateLeft > 0) {
2856
+ translateLeft = 0;
2857
+ }
2858
+ } else if (type === "right") {
2859
+ translateLeft -= 100;
2860
+ if (-translateLeft > maxScrollLeft) {
2861
+ translateLeft = -maxScrollLeft;
2862
+ }
2863
+ } else if (type === "start") {
2864
+ translateLeft = 0;
2865
+ } else if (type === "end") {
2866
+ translateLeft = -maxScrollLeft;
2867
+ }
2868
+ itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
2869
+ };
2870
+ vue.onMounted(() => {
2871
+ pageBar.value && resizeObserver.observe(pageBar.value);
2872
+ });
2873
+ vue.onUnmounted(() => {
2874
+ resizeObserver.disconnect();
2875
+ });
2876
+ vue.watch(() => root.value?.items.length, (length = 0, preLength = 0) => {
2877
+ setTimeout(() => {
2878
+ setCanScroll();
2879
+ if (length < preLength) {
2880
+ scroll("start");
2881
+ } else {
2882
+ scroll("end");
2883
+ }
2884
+ });
2885
+ });
2886
+ return {
2887
+ pageBar,
2888
+ itemsContainer,
2889
+ canScroll,
2890
+ itemsContainerWidth,
2891
+ scroll
2892
+ };
2893
+ };
3577
2894
  const _sfc_main$5 = vue.defineComponent({
3578
- components: { CaretBottom: icons.CaretBottom, Plus: icons.Plus },
2895
+ components: { ArrowLeftBold: icons.ArrowLeftBold, ArrowRightBold: icons.ArrowRightBold, CaretBottom: icons.CaretBottom, Plus: icons.Plus, ToolButton },
3579
2896
  setup() {
3580
2897
  const services = vue.inject("services");
3581
2898
  const editorService = services?.editorService;
2899
+ const root = vue.computed(() => editorService?.get("root"));
3582
2900
  return {
3583
- root: vue.computed(() => editorService?.get("root")),
2901
+ Delete: vue.markRaw(icons.Delete),
2902
+ DocumentCopy: vue.markRaw(icons.DocumentCopy),
2903
+ ...useScroll(root),
2904
+ root,
3584
2905
  page: vue.computed(() => editorService?.get("page")),
3585
2906
  switchPage(page) {
3586
2907
  editorService?.select(page);
@@ -3607,112 +2928,228 @@
3607
2928
  };
3608
2929
  }
3609
2930
  });
3610
- const _hoisted_1$3 = { class: "m-editor-page-bar" };
3611
- const _hoisted_2$1 = ["onClick"];
3612
- const _hoisted_3$1 = { class: "m-editor-page-bar-title" };
3613
- const _hoisted_4$1 = ["onClick"];
3614
- const _hoisted_5 = ["onClick"];
2931
+ const _hoisted_1$2 = {
2932
+ class: "m-editor-page-bar",
2933
+ ref: "pageBar"
2934
+ };
2935
+ const _hoisted_2 = ["onClick"];
2936
+ const _hoisted_3 = { class: "m-editor-page-bar-title" };
3615
2937
  function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3616
2938
  const _component_plus = vue.resolveComponent("plus");
3617
2939
  const _component_el_icon = vue.resolveComponent("el-icon");
2940
+ const _component_arrow_left_bold = vue.resolveComponent("arrow-left-bold");
3618
2941
  const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2942
+ const _component_tool_button = vue.resolveComponent("tool-button");
3619
2943
  const _component_caret_bottom = vue.resolveComponent("caret-bottom");
3620
2944
  const _component_el_popover = vue.resolveComponent("el-popover");
3621
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
2945
+ const _component_arrow_right_bold = vue.resolveComponent("arrow-right-bold");
2946
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
3622
2947
  vue.createElementVNode("div", {
3623
- class: "m-editor-page-bar-item",
2948
+ id: "m-editor-page-bar-add-icon",
2949
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3624
2950
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.addPage && _ctx.addPage(...args))
3625
2951
  }, [
3626
- vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-add-icon" }, {
2952
+ vue.createVNode(_component_el_icon, null, {
2953
+ default: vue.withCtx(() => [
2954
+ vue.createVNode(_component_plus)
2955
+ ]),
2956
+ _: 1
2957
+ })
2958
+ ]),
2959
+ _ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
2960
+ key: 0,
2961
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
2962
+ onClick: _cache[1] || (_cache[1] = ($event) => _ctx.scroll("left"))
2963
+ }, [
2964
+ vue.createVNode(_component_el_icon, null, {
3627
2965
  default: vue.withCtx(() => [
3628
- vue.createVNode(_component_plus)
2966
+ vue.createVNode(_component_arrow_left_bold)
3629
2967
  ]),
3630
2968
  _: 1
3631
2969
  })
3632
- ]),
3633
- _ctx.root ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(_ctx.root.items, (item) => {
3634
- return vue.openBlock(), vue.createElementBlock("div", {
3635
- key: item.key,
3636
- class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
3637
- onClick: ($event) => _ctx.switchPage(item)
3638
- }, [
3639
- vue.createElementVNode("div", _hoisted_3$1, [
3640
- vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3641
- vue.createVNode(_component_el_tooltip, {
3642
- effect: "dark",
3643
- placement: "top-start",
3644
- content: item.name
3645
- }, {
3646
- default: vue.withCtx(() => [
3647
- vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
3648
- ]),
3649
- _: 2
3650
- }, 1032, ["content"])
3651
- ])
3652
- ]),
3653
- vue.createVNode(_component_el_popover, {
3654
- placement: "top",
3655
- width: 160,
3656
- trigger: "hover"
3657
- }, {
3658
- reference: vue.withCtx(() => [
3659
- vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3660
- default: vue.withCtx(() => [
3661
- vue.createVNode(_component_caret_bottom)
3662
- ]),
3663
- _: 1
3664
- })
3665
- ]),
3666
- default: vue.withCtx(() => [
3667
- vue.createElementVNode("div", null, [
3668
- vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3669
- vue.createElementVNode("div", {
3670
- class: "magic-editor-content-menu-item",
3671
- onClick: () => _ctx.copy(item)
3672
- }, "\u590D\u5236", 8, _hoisted_4$1),
3673
- vue.createElementVNode("div", {
3674
- class: "magic-editor-content-menu-item",
3675
- onClick: () => _ctx.remove(item)
3676
- }, "\u5220\u9664", 8, _hoisted_5)
3677
- ])
2970
+ ])) : vue.createCommentVNode("", true),
2971
+ _ctx.root ? (vue.openBlock(), vue.createElementBlock("div", {
2972
+ key: 1,
2973
+ class: "m-editor-page-bar-items",
2974
+ ref: "itemsContainer",
2975
+ style: vue.normalizeStyle(`width: ${_ctx.itemsContainerWidth}px`)
2976
+ }, [
2977
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.root.items, (item) => {
2978
+ return vue.openBlock(), vue.createElementBlock("div", {
2979
+ key: item.key,
2980
+ class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
2981
+ onClick: ($event) => _ctx.switchPage(item)
2982
+ }, [
2983
+ vue.createElementVNode("div", _hoisted_3, [
2984
+ vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
2985
+ vue.createVNode(_component_el_tooltip, {
2986
+ effect: "dark",
2987
+ placement: "top-start",
2988
+ content: item.name
2989
+ }, {
2990
+ default: vue.withCtx(() => [
2991
+ vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
2992
+ ]),
2993
+ _: 2
2994
+ }, 1032, ["content"])
3678
2995
  ])
3679
2996
  ]),
3680
- _: 2
3681
- }, 1024)
3682
- ], 10, _hoisted_2$1);
3683
- }), 128)) : vue.createCommentVNode("", true)
3684
- ]);
2997
+ vue.createVNode(_component_el_popover, {
2998
+ "popper-class": "page-bar-popover",
2999
+ placement: "top",
3000
+ width: 160,
3001
+ trigger: "hover"
3002
+ }, {
3003
+ reference: vue.withCtx(() => [
3004
+ vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
3005
+ default: vue.withCtx(() => [
3006
+ vue.createVNode(_component_caret_bottom)
3007
+ ]),
3008
+ _: 1
3009
+ })
3010
+ ]),
3011
+ default: vue.withCtx(() => [
3012
+ vue.createElementVNode("div", null, [
3013
+ vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3014
+ vue.createVNode(_component_tool_button, {
3015
+ data: {
3016
+ type: "button",
3017
+ text: "\u590D\u5236",
3018
+ icon: _ctx.DocumentCopy,
3019
+ handler: () => _ctx.copy(item)
3020
+ }
3021
+ }, null, 8, ["data"]),
3022
+ vue.createVNode(_component_tool_button, {
3023
+ data: {
3024
+ type: "button",
3025
+ text: "\u5220\u9664",
3026
+ icon: _ctx.Delete,
3027
+ handler: () => _ctx.remove(item)
3028
+ }
3029
+ }, null, 8, ["data"])
3030
+ ])
3031
+ ])
3032
+ ]),
3033
+ _: 2
3034
+ }, 1024)
3035
+ ], 10, _hoisted_2);
3036
+ }), 128))
3037
+ ], 4)) : vue.createCommentVNode("", true),
3038
+ _ctx.canScroll ? (vue.openBlock(), vue.createElementBlock("div", {
3039
+ key: 2,
3040
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3041
+ onClick: _cache[2] || (_cache[2] = ($event) => _ctx.scroll("right"))
3042
+ }, [
3043
+ vue.createVNode(_component_el_icon, null, {
3044
+ default: vue.withCtx(() => [
3045
+ vue.createVNode(_component_arrow_right_bold)
3046
+ ]),
3047
+ _: 1
3048
+ })
3049
+ ])) : vue.createCommentVNode("", true)
3050
+ ], 512);
3685
3051
  }
3686
3052
  var PageBar = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
3687
3053
 
3688
3054
  class ScrollViewer$1 {
3689
- enter = false;
3690
- targetEnter = false;
3691
- keydown = false;
3692
- container;
3693
- target;
3694
- zoom = 1;
3695
- scrollLeft = 0;
3696
- scrollTop = 0;
3697
- x = 0;
3698
- y = 0;
3699
- resizeObserver = new ResizeObserver((entries) => {
3700
- for (const { contentRect } of entries) {
3701
- const { width, height } = contentRect;
3702
- const targetRect = this.target.getBoundingClientRect();
3703
- const targetWidth = targetRect.width * this.zoom;
3704
- const targetMarginTop = Number(this.target.style.marginTop) || 0;
3705
- const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3706
- if (targetWidth < width) {
3707
- this.target._left = 0;
3708
- }
3709
- if (targetHeight < height) {
3710
- this.target._top = 0;
3055
+ constructor(options) {
3056
+ this.enter = false;
3057
+ this.targetEnter = false;
3058
+ this.keydown = false;
3059
+ this.zoom = 1;
3060
+ this.scrollLeft = 0;
3061
+ this.scrollTop = 0;
3062
+ this.x = 0;
3063
+ this.y = 0;
3064
+ this.resizeObserver = new ResizeObserver((entries) => {
3065
+ for (const { contentRect } of entries) {
3066
+ const { width, height } = contentRect;
3067
+ const targetRect = this.target.getBoundingClientRect();
3068
+ const targetWidth = targetRect.width * this.zoom;
3069
+ const targetMarginTop = Number(this.target.style.marginTop) || 0;
3070
+ const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
3071
+ if (targetWidth < width) {
3072
+ this.target._left = 0;
3073
+ }
3074
+ if (targetHeight < height) {
3075
+ this.target._top = 0;
3076
+ }
3077
+ this.scroll();
3711
3078
  }
3079
+ });
3080
+ this.wheelHandler = (event) => {
3081
+ if (this.targetEnter)
3082
+ return;
3083
+ const { deltaX, deltaY, currentTarget } = event;
3084
+ if (currentTarget !== this.container)
3085
+ return;
3086
+ this.setScrollOffset(deltaX, deltaY);
3712
3087
  this.scroll();
3713
- }
3714
- });
3715
- constructor(options) {
3088
+ this.scrollLeft = this.target._left;
3089
+ this.scrollTop = this.target._top;
3090
+ };
3091
+ this.mouseEnterHandler = () => {
3092
+ this.enter = true;
3093
+ };
3094
+ this.mouseLeaveHandler = () => {
3095
+ this.enter = false;
3096
+ };
3097
+ this.targetMouseEnterHandler = () => {
3098
+ this.targetEnter = true;
3099
+ };
3100
+ this.targetMouseLeaveHandler = () => {
3101
+ this.targetEnter = false;
3102
+ };
3103
+ this.mousedownHandler = (event) => {
3104
+ if (!this.keydown)
3105
+ return;
3106
+ event.stopImmediatePropagation();
3107
+ event.stopPropagation();
3108
+ this.target.style.cursor = "grabbing";
3109
+ this.x = event.clientX;
3110
+ this.y = event.clientY;
3111
+ document.addEventListener("mousemove", this.mousemoveHandler);
3112
+ document.addEventListener("mouseup", this.mouseupHandler);
3113
+ };
3114
+ this.mouseupHandler = () => {
3115
+ this.x = 0;
3116
+ this.y = 0;
3117
+ this.scrollLeft = this.target._left;
3118
+ this.scrollTop = this.target._top;
3119
+ this.removeHandler();
3120
+ };
3121
+ this.mousemoveHandler = (event) => {
3122
+ event.stopImmediatePropagation();
3123
+ event.stopPropagation();
3124
+ const deltaX = event.clientX - this.x;
3125
+ const deltaY = event.clientY - this.y;
3126
+ this.setScrollOffset(deltaX, deltaY);
3127
+ this.scroll();
3128
+ };
3129
+ this.keydownHandler = (event) => {
3130
+ if (event.code === Keys.ESCAPE && this.enter) {
3131
+ event.preventDefault();
3132
+ event.stopImmediatePropagation();
3133
+ event.stopPropagation();
3134
+ }
3135
+ if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3136
+ return;
3137
+ }
3138
+ this.keydown = true;
3139
+ this.target.style.cursor = "grab";
3140
+ this.container.addEventListener("mousedown", this.mousedownHandler);
3141
+ };
3142
+ this.keyupHandler = (event) => {
3143
+ if (event.code !== Keys.ESCAPE || !this.keydown) {
3144
+ return;
3145
+ }
3146
+ event.preventDefault();
3147
+ event.stopImmediatePropagation();
3148
+ event.stopPropagation();
3149
+ this.keydown = false;
3150
+ event.preventDefault();
3151
+ this.removeHandler();
3152
+ };
3716
3153
  this.container = options.container;
3717
3154
  this.target = options.target;
3718
3155
  this.zoom = options.zoom;
@@ -3748,79 +3185,6 @@
3748
3185
  document.removeEventListener("mousemove", this.mousemoveHandler);
3749
3186
  document.removeEventListener("mouseup", this.mouseupHandler);
3750
3187
  }
3751
- wheelHandler = (event) => {
3752
- if (this.targetEnter)
3753
- return;
3754
- const { deltaX, deltaY, currentTarget } = event;
3755
- if (currentTarget !== this.container)
3756
- return;
3757
- this.setScrollOffset(deltaX, deltaY);
3758
- this.scroll();
3759
- this.scrollLeft = this.target._left;
3760
- this.scrollTop = this.target._top;
3761
- };
3762
- mouseEnterHandler = () => {
3763
- this.enter = true;
3764
- };
3765
- mouseLeaveHandler = () => {
3766
- this.enter = false;
3767
- };
3768
- targetMouseEnterHandler = () => {
3769
- this.targetEnter = true;
3770
- };
3771
- targetMouseLeaveHandler = () => {
3772
- this.targetEnter = false;
3773
- };
3774
- mousedownHandler = (event) => {
3775
- if (!this.keydown)
3776
- return;
3777
- event.stopImmediatePropagation();
3778
- event.stopPropagation();
3779
- this.target.style.cursor = "grabbing";
3780
- this.x = event.clientX;
3781
- this.y = event.clientY;
3782
- document.addEventListener("mousemove", this.mousemoveHandler);
3783
- document.addEventListener("mouseup", this.mouseupHandler);
3784
- };
3785
- mouseupHandler = () => {
3786
- this.x = 0;
3787
- this.y = 0;
3788
- this.scrollLeft = this.target._left;
3789
- this.scrollTop = this.target._top;
3790
- this.removeHandler();
3791
- };
3792
- mousemoveHandler = (event) => {
3793
- event.stopImmediatePropagation();
3794
- event.stopPropagation();
3795
- const deltaX = event.clientX - this.x;
3796
- const deltaY = event.clientY - this.y;
3797
- this.setScrollOffset(deltaX, deltaY);
3798
- this.scroll();
3799
- };
3800
- keydownHandler = (event) => {
3801
- if (event.code === Keys.ESCAPE && this.enter) {
3802
- event.preventDefault();
3803
- event.stopImmediatePropagation();
3804
- event.stopPropagation();
3805
- }
3806
- if (event.code !== Keys.ESCAPE || !this.enter || this.keydown) {
3807
- return;
3808
- }
3809
- this.keydown = true;
3810
- this.target.style.cursor = "grab";
3811
- this.container.addEventListener("mousedown", this.mousedownHandler);
3812
- };
3813
- keyupHandler = (event) => {
3814
- if (event.code !== Keys.ESCAPE || !this.keydown) {
3815
- return;
3816
- }
3817
- event.preventDefault();
3818
- event.stopImmediatePropagation();
3819
- event.stopPropagation();
3820
- this.keydown = false;
3821
- event.preventDefault();
3822
- this.removeHandler();
3823
- };
3824
3188
  setScrollOffset(deltaX, deltaY) {
3825
3189
  const { width, height } = this.container.getBoundingClientRect();
3826
3190
  const targetRect = this.target.getBoundingClientRect();
@@ -3881,19 +3245,19 @@
3881
3245
  el,
3882
3246
  style: vue.computed(() => `
3883
3247
  width: ${props.width}px;
3884
- height: ${props.height}px;
3248
+ height: ${(props.height || 0) - 40}px;
3885
3249
  position: absolute;
3886
3250
  margin-top: 30px;
3887
3251
  `)
3888
3252
  };
3889
3253
  }
3890
3254
  });
3891
- const _hoisted_1$2 = {
3255
+ const _hoisted_1$1 = {
3892
3256
  class: "m-editor-scroll-viewer-container",
3893
3257
  ref: "container"
3894
3258
  };
3895
3259
  function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3896
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
3260
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
3897
3261
  vue.createElementVNode("div", {
3898
3262
  ref: "el",
3899
3263
  style: vue.normalizeStyle(_ctx.style)
@@ -3905,7 +3269,7 @@
3905
3269
  var ScrollViewer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
3906
3270
 
3907
3271
  const _sfc_main$3 = vue.defineComponent({
3908
- name: "magic-editor-ui-viewer-menu",
3272
+ components: { ContentMenu },
3909
3273
  setup() {
3910
3274
  const services = vue.inject("services");
3911
3275
  const editorService = services?.editorService;
@@ -3914,6 +3278,8 @@
3914
3278
  const canCenter = vue.ref(false);
3915
3279
  const node = vue.computed(() => editorService?.get("node"));
3916
3280
  const parent = vue.computed(() => editorService?.get("parent"));
3281
+ const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
3282
+ const stageContentMenu = vue.inject("stageContentMenu", []);
3917
3283
  vue.onMounted(() => {
3918
3284
  const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
3919
3285
  canPaste.value = data !== "undefined" && !!data;
@@ -3926,167 +3292,142 @@
3926
3292
  }, { immediate: true });
3927
3293
  return {
3928
3294
  menu,
3929
- canPaste,
3930
- canDelete: vue.computed(() => node.value?.type !== schema.NodeType.PAGE),
3931
- canMoveZPos: vue.computed(() => node.value?.type !== schema.NodeType.PAGE),
3932
- canCenter,
3933
- center() {
3934
- node.value && editorService?.alignCenter(node.value);
3935
- },
3936
- copy() {
3937
- node.value && editorService?.copy(node.value);
3938
- canPaste.value = true;
3939
- },
3940
- paste() {
3941
- const top = menu.value?.offsetTop || 0;
3942
- const left = menu.value?.offsetLeft || 0;
3943
- editorService?.paste({ left, top });
3944
- },
3945
- remove() {
3946
- node.value && editorService?.remove(node.value);
3947
- },
3948
- top() {
3949
- editorService?.moveLayer(LayerOffset.TOP);
3950
- },
3951
- bottom() {
3952
- editorService?.moveLayer(LayerOffset.BOTTOM);
3953
- },
3954
- topItem() {
3955
- editorService?.moveLayer(1);
3956
- },
3957
- bottomItem() {
3958
- editorService?.moveLayer(-1);
3959
- },
3960
- clearGuides() {
3961
- editorService?.get("stage").clearGuides();
3295
+ menuData: vue.reactive([
3296
+ {
3297
+ type: "button",
3298
+ text: "\u6C34\u5E73\u5C45\u4E2D",
3299
+ display: () => canCenter.value,
3300
+ handler: () => {
3301
+ node.value && editorService?.alignCenter(node.value);
3302
+ }
3303
+ },
3304
+ {
3305
+ type: "button",
3306
+ text: "\u590D\u5236",
3307
+ icon: vue.markRaw(icons.DocumentCopy),
3308
+ handler: () => {
3309
+ node.value && editorService?.copy(node.value);
3310
+ canPaste.value = true;
3311
+ }
3312
+ },
3313
+ {
3314
+ type: "button",
3315
+ text: "\u7C98\u8D34",
3316
+ display: () => canPaste.value,
3317
+ handler: () => {
3318
+ const stage = editorService?.get("stage");
3319
+ const rect = menu.value?.$el.getBoundingClientRect();
3320
+ const parentRect = stage?.container?.getBoundingClientRect();
3321
+ let left = (rect?.left || 0) - (parentRect?.left || 0);
3322
+ let top = (rect?.top || 0) - (parentRect?.top || 0);
3323
+ if (node.value?.items && stage) {
3324
+ const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
3325
+ const parentElRect = parentEl?.getBoundingClientRect();
3326
+ left = left - (parentElRect?.left || 0);
3327
+ top = top - (parentElRect?.top || 0);
3328
+ }
3329
+ editorService?.paste({ left, top });
3330
+ }
3331
+ },
3332
+ {
3333
+ type: "divider",
3334
+ direction: "horizontal",
3335
+ display: () => !isPage.value
3336
+ },
3337
+ {
3338
+ type: "button",
3339
+ text: "\u4E0A\u79FB\u4E00\u5C42",
3340
+ icon: vue.markRaw(icons.Top),
3341
+ display: () => !isPage.value,
3342
+ handler: () => {
3343
+ editorService?.moveLayer(1);
3344
+ }
3345
+ },
3346
+ {
3347
+ type: "button",
3348
+ text: "\u4E0B\u79FB\u4E00\u5C42",
3349
+ icon: vue.markRaw(icons.Bottom),
3350
+ display: () => !isPage.value,
3351
+ handler: () => {
3352
+ editorService?.moveLayer(-1);
3353
+ }
3354
+ },
3355
+ {
3356
+ type: "button",
3357
+ text: "\u7F6E\u9876",
3358
+ display: () => !isPage.value,
3359
+ handler: () => {
3360
+ editorService?.moveLayer(LayerOffset.TOP);
3361
+ }
3362
+ },
3363
+ {
3364
+ type: "button",
3365
+ text: "\u7F6E\u5E95",
3366
+ display: () => !isPage.value,
3367
+ handler: () => {
3368
+ editorService?.moveLayer(LayerOffset.BOTTOM);
3369
+ }
3370
+ },
3371
+ {
3372
+ type: "divider",
3373
+ direction: "horizontal",
3374
+ display: () => !isPage.value
3375
+ },
3376
+ {
3377
+ type: "button",
3378
+ text: "\u5220\u9664",
3379
+ icon: icons.Delete,
3380
+ display: () => !isPage.value,
3381
+ handler: () => {
3382
+ node.value && editorService?.remove(node.value);
3383
+ }
3384
+ },
3385
+ {
3386
+ type: "divider",
3387
+ direction: "horizontal"
3388
+ },
3389
+ {
3390
+ type: "button",
3391
+ text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
3392
+ handler: () => {
3393
+ editorService?.get("stage").clearGuides();
3394
+ }
3395
+ },
3396
+ ...stageContentMenu
3397
+ ]),
3398
+ show(e) {
3399
+ menu.value?.show(e);
3962
3400
  }
3963
3401
  };
3964
3402
  }
3965
3403
  });
3966
- const _hoisted_1$1 = {
3967
- class: "magic-editor-content-menu",
3968
- ref: "menu"
3969
- };
3970
- const _hoisted_2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3971
- const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3972
- const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3973
3404
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3974
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
3975
- vue.createElementVNode("div", null, [
3976
- _ctx.canCenter ? (vue.openBlock(), vue.createElementBlock("div", {
3977
- key: 0,
3978
- class: "magic-editor-content-menu-item",
3979
- onClick: _cache[0] || (_cache[0] = () => _ctx.center())
3980
- }, "\u6C34\u5E73\u5C45\u4E2D")) : vue.createCommentVNode("", true),
3981
- vue.createElementVNode("div", {
3982
- class: "magic-editor-content-menu-item",
3983
- onClick: _cache[1] || (_cache[1] = () => _ctx.copy())
3984
- }, "\u590D\u5236"),
3985
- _ctx.canPaste ? (vue.openBlock(), vue.createElementBlock("div", {
3986
- key: 1,
3987
- class: "magic-editor-content-menu-item",
3988
- onClick: _cache[2] || (_cache[2] = (...args) => _ctx.paste && _ctx.paste(...args))
3989
- }, "\u7C98\u8D34")) : vue.createCommentVNode("", true),
3990
- _ctx.canMoveZPos ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
3991
- _hoisted_2,
3992
- vue.createElementVNode("div", {
3993
- class: "magic-editor-content-menu-item",
3994
- onClick: _cache[3] || (_cache[3] = (...args) => _ctx.topItem && _ctx.topItem(...args))
3995
- }, "\u4E0A\u79FB\u4E00\u5C42"),
3996
- vue.createElementVNode("div", {
3997
- class: "magic-editor-content-menu-item",
3998
- onClick: _cache[4] || (_cache[4] = (...args) => _ctx.bottomItem && _ctx.bottomItem(...args))
3999
- }, "\u4E0B\u79FB\u4E00\u5C42"),
4000
- vue.createElementVNode("div", {
4001
- class: "magic-editor-content-menu-item",
4002
- onClick: _cache[5] || (_cache[5] = (...args) => _ctx.top && _ctx.top(...args))
4003
- }, "\u7F6E\u9876"),
4004
- vue.createElementVNode("div", {
4005
- class: "magic-editor-content-menu-item",
4006
- onClick: _cache[6] || (_cache[6] = (...args) => _ctx.bottom && _ctx.bottom(...args))
4007
- }, "\u7F6E\u5E95")
4008
- ], 64)) : vue.createCommentVNode("", true),
4009
- _ctx.canDelete ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
4010
- _hoisted_3,
4011
- vue.createElementVNode("div", {
4012
- class: "magic-editor-content-menu-item",
4013
- onClick: _cache[7] || (_cache[7] = () => _ctx.remove())
4014
- }, "\u5220\u9664")
4015
- ], 64)) : vue.createCommentVNode("", true),
4016
- _hoisted_4,
4017
- vue.createElementVNode("div", {
4018
- class: "magic-editor-content-menu-item",
4019
- onClick: _cache[8] || (_cache[8] = (...args) => _ctx.clearGuides && _ctx.clearGuides(...args))
4020
- }, "\u6E05\u7A7A\u53C2\u8003\u7EBF")
4021
- ])
4022
- ], 512);
3405
+ const _component_content_menu = vue.resolveComponent("content-menu");
3406
+ return vue.openBlock(), vue.createBlock(_component_content_menu, {
3407
+ "menu-data": _ctx.menuData,
3408
+ ref: "menu"
3409
+ }, null, 8, ["menu-data"]);
4023
3410
  }
4024
3411
  var ViewerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
4025
3412
 
4026
- const useMenu = () => {
4027
- const menu = vue.ref();
4028
- const menuStyle = vue.ref({
4029
- display: "none",
4030
- left: "0",
4031
- top: "0"
4032
- });
4033
- vue.onMounted(() => {
4034
- document.addEventListener("click", () => {
4035
- menuStyle.value.display = "none";
4036
- }, true);
4037
- });
4038
- return {
4039
- menu,
4040
- menuStyle,
4041
- contextmenuHandler(e) {
4042
- e.preventDefault();
4043
- const menuHeight = menu.value?.$el.clientHeight;
4044
- let top = e.clientY;
4045
- if (menuHeight + e.clientY > document.body.clientHeight) {
4046
- top = document.body.clientHeight - menuHeight;
4047
- }
4048
- menuStyle.value = {
4049
- display: "block",
4050
- top: `${top}px`,
4051
- left: `${e.clientX}px`
4052
- };
4053
- }
4054
- };
4055
- };
4056
3413
  const _sfc_main$2 = vue.defineComponent({
4057
3414
  name: "magic-stage",
4058
3415
  components: {
4059
3416
  ViewerMenu,
4060
3417
  ScrollViewer
4061
3418
  },
4062
- props: {
4063
- render: {
4064
- type: Function
4065
- },
4066
- runtimeUrl: String,
4067
- canSelect: {
4068
- type: Function,
4069
- default: (el) => Boolean(el.id)
4070
- },
4071
- moveableOptions: {
4072
- type: [Object, Function],
4073
- default: () => (core) => ({
4074
- container: core?.renderer?.contentWindow?.document.getElementById("app")
4075
- })
4076
- }
4077
- },
4078
- emits: ["select", "update", "sort", "highlight"],
4079
- setup(props, { emit }) {
3419
+ setup() {
4080
3420
  const services = vue.inject("services");
3421
+ const stageOptions = vue.inject("stageOptions");
4081
3422
  const stageWrap = vue.ref();
4082
3423
  const stageContainer = vue.ref();
3424
+ const menu = vue.ref();
4083
3425
  const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
4084
3426
  const uiSelectMode = vue.computed(() => services?.uiService.get("uiSelectMode"));
4085
3427
  const root = vue.computed(() => services?.editorService.get("root"));
4086
3428
  const page = vue.computed(() => services?.editorService.get("page"));
4087
- const zoom = vue.computed(() => services?.uiService.get("zoom"));
3429
+ const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
4088
3430
  const node = vue.computed(() => services?.editorService.get("node"));
4089
- const highlightNode = vue.computed(() => services?.editorService.get("highlightNode"));
4090
3431
  let stage = null;
4091
3432
  let runtime = null;
4092
3433
  vue.watchEffect(() => {
@@ -4094,35 +3435,37 @@
4094
3435
  return;
4095
3436
  if (!stageContainer.value)
4096
3437
  return;
4097
- if (!(props.runtimeUrl || props.render) || !root.value)
3438
+ if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
4098
3439
  return;
4099
3440
  stage = new StageCore__default["default"]({
4100
- render: props.render,
4101
- runtimeUrl: props.runtimeUrl,
3441
+ render: stageOptions.render,
3442
+ runtimeUrl: stageOptions.runtimeUrl,
4102
3443
  zoom: zoom.value,
4103
- canSelect: (el, stop) => {
4104
- const elCanSelect = props.canSelect(el);
4105
- if (uiSelectMode.value && elCanSelect) {
3444
+ autoScrollIntoView: stageOptions.autoScrollIntoView,
3445
+ canSelect: (el, event, stop) => {
3446
+ const elCanSelect = stageOptions.canSelect(el);
3447
+ if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
4106
3448
  document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
4107
3449
  return stop();
4108
3450
  }
4109
3451
  return elCanSelect;
4110
3452
  },
4111
- moveableOptions: props.moveableOptions
3453
+ moveableOptions: stageOptions.moveableOptions,
3454
+ updateDragEl: stageOptions.updateDragEl
4112
3455
  });
4113
- services?.editorService.set("stage", stage);
3456
+ services?.editorService.set("stage", vue.markRaw(stage));
4114
3457
  stage?.mount(stageContainer.value);
4115
3458
  stage?.on("select", (el) => {
4116
- emit("select", el);
3459
+ services?.editorService.select(el.id);
4117
3460
  });
4118
3461
  stage?.on("highlight", (el) => {
4119
- emit("highlight", el);
3462
+ services?.editorService.highlight(el.id);
4120
3463
  });
4121
3464
  stage?.on("update", (ev) => {
4122
- emit("update", { id: ev.el.id, style: ev.style });
3465
+ services?.editorService.update({ id: ev.el.id, style: ev.style });
4123
3466
  });
4124
3467
  stage?.on("sort", (ev) => {
4125
- emit("sort", ev);
3468
+ services?.editorService.sort(ev.src, ev.dist);
4126
3469
  });
4127
3470
  stage?.on("changeGuides", () => {
4128
3471
  services?.uiService.set("showGuides", true);
@@ -4131,7 +3474,7 @@
4131
3474
  return;
4132
3475
  stage?.on("runtime-ready", (rt) => {
4133
3476
  runtime = rt;
4134
- root.value && runtime?.updateRootConfig(lodashEs.cloneDeep(vue.toRaw(root.value)));
3477
+ root.value && runtime?.updateRootConfig?.(lodashEs.cloneDeep(vue.toRaw(root.value)));
4135
3478
  page.value?.id && runtime?.updatePageId?.(page.value.id);
4136
3479
  setTimeout(() => {
4137
3480
  node.value && stage?.select(vue.toRaw(node.value.id));
@@ -4145,19 +3488,9 @@
4145
3488
  });
4146
3489
  vue.watch(root, (root2) => {
4147
3490
  if (runtime && root2) {
4148
- runtime.updateRootConfig(lodashEs.cloneDeep(vue.toRaw(root2)));
3491
+ runtime.updateRootConfig?.(lodashEs.cloneDeep(vue.toRaw(root2)));
4149
3492
  }
4150
3493
  });
4151
- vue.watch(() => node.value?.id, (id) => {
4152
- vue.nextTick(() => {
4153
- id && stage?.select(id);
4154
- });
4155
- });
4156
- vue.watch(() => highlightNode.value?.id, (id) => {
4157
- vue.nextTick(() => {
4158
- id && stage?.highlight(id);
4159
- });
4160
- });
4161
3494
  const resizeObserver = new ResizeObserver((entries) => {
4162
3495
  for (const { contentRect } of entries) {
4163
3496
  services?.uiService.set("stageContainerRect", {
@@ -4177,9 +3510,37 @@
4177
3510
  return {
4178
3511
  stageWrap,
4179
3512
  stageContainer,
3513
+ menu,
4180
3514
  stageRect,
4181
3515
  zoom,
4182
- ...useMenu()
3516
+ contextmenuHandler(e2) {
3517
+ e2.preventDefault();
3518
+ menu.value?.show(e2);
3519
+ },
3520
+ dragoverHandler(e2) {
3521
+ e2.preventDefault();
3522
+ if (e2.dataTransfer) {
3523
+ e2.dataTransfer.dropEffect = "move";
3524
+ }
3525
+ },
3526
+ async dropHandler(e) {
3527
+ e.preventDefault();
3528
+ if (e.dataTransfer && page.value && stageContainer.value && stage) {
3529
+ const config = eval(`(${e.dataTransfer.getData("data")})`);
3530
+ const layout = await services?.editorService.getLayout(page.value);
3531
+ const containerRect = stageContainer.value.getBoundingClientRect();
3532
+ const { scrollTop, scrollLeft } = stage.mask;
3533
+ if (layout === Layout.ABSOLUTE) {
3534
+ config.style = {
3535
+ ...config.style || {},
3536
+ position: "absolute",
3537
+ top: e.clientY - containerRect.top + scrollTop,
3538
+ left: e.clientX - containerRect.left + scrollLeft
3539
+ };
3540
+ }
3541
+ services?.editorService.add(config, page.value);
3542
+ }
3543
+ }
4183
3544
  };
4184
3545
  }
4185
3546
  });
@@ -4197,14 +3558,13 @@
4197
3558
  vue.createElementVNode("div", {
4198
3559
  class: "m-editor-stage-container",
4199
3560
  ref: "stageContainer",
3561
+ style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`),
4200
3562
  onContextmenu: _cache[0] || (_cache[0] = (...args) => _ctx.contextmenuHandler && _ctx.contextmenuHandler(...args)),
4201
- style: vue.normalizeStyle(`transform: scale(${_ctx.zoom})`)
3563
+ onDrop: _cache[1] || (_cache[1] = (...args) => _ctx.dropHandler && _ctx.dropHandler(...args)),
3564
+ onDragover: _cache[2] || (_cache[2] = (...args) => _ctx.dragoverHandler && _ctx.dragoverHandler(...args))
4202
3565
  }, null, 36),
4203
3566
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
4204
- vue.createVNode(_component_viewer_menu, {
4205
- ref: "menu",
4206
- style: vue.normalizeStyle(_ctx.menuStyle)
4207
- }, null, 8, ["style"])
3567
+ vue.createVNode(_component_viewer_menu, { ref: "menu" }, null, 512)
4208
3568
  ]))
4209
3569
  ]),
4210
3570
  _: 1
@@ -4218,53 +3578,118 @@
4218
3578
  PageBar,
4219
3579
  MagicStage
4220
3580
  },
4221
- props: {
4222
- runtimeUrl: String,
4223
- render: {
4224
- type: Function
4225
- },
4226
- moveableOptions: {
4227
- type: [Object, Function]
4228
- },
4229
- canSelect: {
4230
- type: Function
4231
- }
4232
- },
4233
3581
  setup() {
4234
3582
  const services = vue.inject("services");
3583
+ const workspace = vue.ref();
3584
+ const node = vue.computed(() => services?.editorService.get("node"));
3585
+ let keycon;
3586
+ const mouseenterHandler = () => {
3587
+ workspace.value?.focus();
3588
+ };
3589
+ const mouseleaveHandler = () => {
3590
+ workspace.value?.blur();
3591
+ };
3592
+ vue.onMounted(() => {
3593
+ workspace.value?.addEventListener("mouseenter", mouseenterHandler);
3594
+ workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
3595
+ keycon = new KeyController__default["default"](workspace.value);
3596
+ const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
3597
+ const ctrl = isMac ? "meta" : "ctrl";
3598
+ keycon.keyup("delete", (e) => {
3599
+ e.inputEvent.preventDefault();
3600
+ if (!node.value || utils.isPage(node.value))
3601
+ return;
3602
+ services?.editorService.remove(node.value);
3603
+ }).keyup("backspace", (e) => {
3604
+ e.inputEvent.preventDefault();
3605
+ if (!node.value || utils.isPage(node.value))
3606
+ return;
3607
+ services?.editorService.remove(node.value);
3608
+ }).keydown([ctrl, "c"], (e) => {
3609
+ e.inputEvent.preventDefault();
3610
+ node.value && services?.editorService.copy(node.value);
3611
+ }).keydown([ctrl, "v"], (e) => {
3612
+ e.inputEvent.preventDefault();
3613
+ node.value && services?.editorService.paste();
3614
+ }).keydown([ctrl, "x"], (e) => {
3615
+ e.inputEvent.preventDefault();
3616
+ if (!node.value || utils.isPage(node.value))
3617
+ return;
3618
+ services?.editorService.copy(node.value);
3619
+ services?.editorService.remove(node.value);
3620
+ }).keydown([ctrl, "z"], (e) => {
3621
+ e.inputEvent.preventDefault();
3622
+ services?.editorService.undo();
3623
+ }).keydown([ctrl, "shift", "z"], (e) => {
3624
+ e.inputEvent.preventDefault();
3625
+ services?.editorService.redo();
3626
+ }).keydown("up", (e) => {
3627
+ e.inputEvent.preventDefault();
3628
+ services?.editorService.move(0, -1);
3629
+ }).keydown("down", (e) => {
3630
+ e.inputEvent.preventDefault();
3631
+ services?.editorService.move(0, 1);
3632
+ }).keydown("left", (e) => {
3633
+ e.inputEvent.preventDefault();
3634
+ services?.editorService.move(-1, 0);
3635
+ }).keydown("right", (e) => {
3636
+ e.inputEvent.preventDefault();
3637
+ services?.editorService.move(1, 0);
3638
+ }).keydown([ctrl, "up"], (e) => {
3639
+ e.inputEvent.preventDefault();
3640
+ services?.editorService.move(0, -10);
3641
+ }).keydown([ctrl, "down"], (e) => {
3642
+ e.inputEvent.preventDefault();
3643
+ services?.editorService.move(0, 10);
3644
+ }).keydown([ctrl, "left"], (e) => {
3645
+ e.inputEvent.preventDefault();
3646
+ services?.editorService.move(-10, 0);
3647
+ }).keydown([ctrl, "right"], (e) => {
3648
+ e.inputEvent.preventDefault();
3649
+ services?.editorService.move(10, 0);
3650
+ }).keydown("tab", (e) => {
3651
+ e.inputEvent.preventDefault();
3652
+ services?.editorService.selectNextNode();
3653
+ }).keydown([ctrl, "tab"], (e) => {
3654
+ e.inputEvent.preventDefault();
3655
+ services?.editorService.selectNextPage();
3656
+ }).keydown([ctrl, "="], (e) => {
3657
+ e.inputEvent.preventDefault();
3658
+ services?.uiService.zoom(0.1);
3659
+ }).keydown([ctrl, "numpadplus"], (e) => {
3660
+ e.inputEvent.preventDefault();
3661
+ services?.uiService.zoom(0.1);
3662
+ }).keydown([ctrl, "-"], (e) => {
3663
+ e.inputEvent.preventDefault();
3664
+ services?.uiService.zoom(-0.1);
3665
+ }).keydown([ctrl, "numpad-"], (e) => {
3666
+ e.inputEvent.preventDefault();
3667
+ services?.uiService.zoom(-0.1);
3668
+ });
3669
+ });
3670
+ vue.onUnmounted(() => {
3671
+ workspace.value?.removeEventListener("mouseenter", mouseenterHandler);
3672
+ workspace.value?.removeEventListener("mouseleave", mouseleaveHandler);
3673
+ keycon.destroy();
3674
+ });
4235
3675
  return {
4236
- page: vue.computed(() => services?.editorService.get("page")),
4237
- selectHandler(el) {
4238
- services?.editorService.select(el.id);
4239
- },
4240
- updateNodeHandler(node) {
4241
- services?.editorService.update(node);
4242
- },
4243
- sortNodeHandler(ev) {
4244
- services?.editorService.sort(ev.src, ev.dist);
4245
- },
4246
- highlightHandler(el) {
4247
- services?.editorService.highlight(el.id);
4248
- }
3676
+ workspace,
3677
+ page: vue.computed(() => services?.editorService.get("page"))
4249
3678
  };
4250
3679
  }
4251
3680
  });
4252
- const _hoisted_1 = { class: "m-editor-workspace" };
3681
+ const _hoisted_1 = {
3682
+ class: "m-editor-workspace",
3683
+ tabindex: "1",
3684
+ ref: "workspace"
3685
+ };
4253
3686
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4254
3687
  const _component_magic_stage = vue.resolveComponent("magic-stage");
4255
3688
  const _component_page_bar = vue.resolveComponent("page-bar");
4256
3689
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
4257
3690
  (vue.openBlock(), vue.createBlock(_component_magic_stage, {
4258
- key: _ctx.page?.id,
4259
- "runtime-url": _ctx.runtimeUrl,
4260
- render: _ctx.render,
4261
- "moveable-options": _ctx.moveableOptions,
4262
- "can-select": _ctx.canSelect,
4263
- onSelect: _ctx.selectHandler,
4264
- onHighlight: _ctx.highlightHandler,
4265
- onUpdate: _ctx.updateNodeHandler,
4266
- onSort: _ctx.sortNodeHandler
4267
- }, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onHighlight", "onUpdate", "onSort"])),
3691
+ key: _ctx.page?.id
3692
+ })),
4268
3693
  vue.renderSlot(_ctx.$slots, "workspace-content"),
4269
3694
  vue.createVNode(_component_page_bar, null, {
4270
3695
  "page-bar-title": vue.withCtx(({ page }) => [
@@ -4275,16 +3700,16 @@
4275
3700
  ]),
4276
3701
  _: 3
4277
3702
  })
4278
- ]);
3703
+ ], 512);
4279
3704
  }
4280
3705
  var Workspace = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
4281
3706
 
4282
3707
  class ComponentList extends BaseService {
4283
- state = vue.reactive({
4284
- list: []
4285
- });
4286
3708
  constructor() {
4287
3709
  super([]);
3710
+ this.state = vue.reactive({
3711
+ list: []
3712
+ });
4288
3713
  }
4289
3714
  setList(componentGroupList) {
4290
3715
  this.state.list = componentGroupList;
@@ -4295,6 +3720,14 @@
4295
3720
  }
4296
3721
  var componentListService = new ComponentList();
4297
3722
 
3723
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3724
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
3725
+ const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
3726
+ const defaultColumnWidth = {
3727
+ left: DEFAULT_LEFT_COLUMN_WIDTH,
3728
+ center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
3729
+ right: DEFAULT_RIGHT_COLUMN_WIDTH
3730
+ };
4298
3731
  const state = vue.reactive({
4299
3732
  uiSelectMode: false,
4300
3733
  showSrc: false,
@@ -4307,13 +3740,10 @@
4307
3740
  width: 375,
4308
3741
  height: 817
4309
3742
  },
4310
- columnWidth: {
4311
- left: 310,
4312
- center: globalThis.document.body.clientWidth - 310 - 400,
4313
- right: 400
4314
- },
3743
+ columnWidth: defaultColumnWidth,
4315
3744
  showGuides: true,
4316
- showRule: true
3745
+ showRule: true,
3746
+ propsPanelSize: "small"
4317
3747
  });
4318
3748
  class Ui extends BaseService {
4319
3749
  constructor() {
@@ -4323,6 +3753,15 @@
4323
3753
  center: "auto"
4324
3754
  });
4325
3755
  });
3756
+ const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
3757
+ if (columnWidthCacheData) {
3758
+ try {
3759
+ const columnWidthCache = JSON.parse(columnWidthCacheData);
3760
+ this.setColumnWidth(columnWidthCache);
3761
+ } catch (e) {
3762
+ console.error(e);
3763
+ }
3764
+ }
4326
3765
  }
4327
3766
  set(name, value) {
4328
3767
  const mask = editorService.get("stage")?.mask;
@@ -4348,6 +3787,11 @@
4348
3787
  get(name) {
4349
3788
  return state[name];
4350
3789
  }
3790
+ zoom(zoom) {
3791
+ this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
3792
+ if (this.get("zoom") < 0.1)
3793
+ this.set("zoom", 0.1);
3794
+ }
4351
3795
  setColumnWidth({ left, center, right }) {
4352
3796
  const columnWidth = {
4353
3797
  ...vue.toRaw(this.get("columnWidth"))
@@ -4361,9 +3805,15 @@
4361
3805
  if (!center || center === "auto") {
4362
3806
  const bodyWidth = globalThis.document.body.clientWidth;
4363
3807
  columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
3808
+ if (columnWidth.center <= 0) {
3809
+ columnWidth.left = defaultColumnWidth.left;
3810
+ columnWidth.center = defaultColumnWidth.center;
3811
+ columnWidth.right = defaultColumnWidth.right;
3812
+ }
4364
3813
  } else {
4365
3814
  columnWidth.center = center;
4366
3815
  }
3816
+ globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
4367
3817
  state.columnWidth = columnWidth;
4368
3818
  }
4369
3819
  setStageRect(value) {
@@ -4408,6 +3858,14 @@
4408
3858
  sidebar: {
4409
3859
  type: Object
4410
3860
  },
3861
+ layerContentMenu: {
3862
+ type: Array,
3863
+ default: () => []
3864
+ },
3865
+ stageContentMenu: {
3866
+ type: Array,
3867
+ default: () => []
3868
+ },
4411
3869
  menu: {
4412
3870
  type: Object,
4413
3871
  default: () => ({ left: [], right: [] })
@@ -4416,6 +3874,7 @@
4416
3874
  type: Function
4417
3875
  },
4418
3876
  runtimeUrl: String,
3877
+ autoScrollIntoView: Boolean,
4419
3878
  propsConfigs: {
4420
3879
  type: Object,
4421
3880
  default: () => ({})
@@ -4429,16 +3888,27 @@
4429
3888
  default: () => ({})
4430
3889
  },
4431
3890
  moveableOptions: {
4432
- type: [Object, Function]
3891
+ type: [Object, Function],
3892
+ default: () => (core) => ({
3893
+ container: core?.renderer?.contentWindow?.document.getElementById("app")
3894
+ })
4433
3895
  },
4434
3896
  defaultSelected: {
4435
3897
  type: [Number, String]
4436
3898
  },
4437
3899
  canSelect: {
4438
- type: Function
3900
+ type: Function,
3901
+ default: (el) => Boolean(el.id)
4439
3902
  },
4440
3903
  stageRect: {
4441
3904
  type: [String, Object]
3905
+ },
3906
+ codeOptions: {
3907
+ type: Object,
3908
+ default: () => ({})
3909
+ },
3910
+ updateDragEl: {
3911
+ type: Function
4442
3912
  }
4443
3913
  },
4444
3914
  emits: ["props-panel-mounted", "update:modelValue"],
@@ -4488,6 +3958,16 @@
4488
3958
  uiService
4489
3959
  };
4490
3960
  vue.provide("services", services);
3961
+ vue.provide("layerContentMenu", props.layerContentMenu);
3962
+ vue.provide("stageContentMenu", props.stageContentMenu);
3963
+ vue.provide("stageOptions", vue.reactive({
3964
+ runtimeUrl: props.runtimeUrl,
3965
+ autoScrollIntoView: props.autoScrollIntoView,
3966
+ render: props.render,
3967
+ moveableOptions: props.moveableOptions,
3968
+ canSelect: props.canSelect,
3969
+ updateDragEl: props.updateDragEl
3970
+ }));
4491
3971
  return services;
4492
3972
  }
4493
3973
  });
@@ -4497,7 +3977,7 @@
4497
3977
  const _component_workspace = vue.resolveComponent("workspace");
4498
3978
  const _component_props_panel = vue.resolveComponent("props-panel");
4499
3979
  const _component_framework = vue.resolveComponent("framework");
4500
- return vue.openBlock(), vue.createBlock(_component_framework, null, {
3980
+ return vue.openBlock(), vue.createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
4501
3981
  nav: vue.withCtx(() => [
4502
3982
  vue.renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
4503
3983
  vue.createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
@@ -4510,12 +3990,7 @@
4510
3990
  ]),
4511
3991
  workspace: vue.withCtx(() => [
4512
3992
  vue.renderSlot(_ctx.$slots, "workspace", {}, () => [
4513
- vue.createVNode(_component_workspace, {
4514
- "runtime-url": _ctx.runtimeUrl,
4515
- render: _ctx.render,
4516
- "moveable-options": _ctx.moveableOptions,
4517
- "can-select": _ctx.canSelect
4518
- }, {
3993
+ vue.createVNode(_component_workspace, null, {
4519
3994
  "workspace-content": vue.withCtx(() => [
4520
3995
  vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
4521
3996
  ]),
@@ -4526,7 +4001,7 @@
4526
4001
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
4527
4002
  ]),
4528
4003
  _: 3
4529
- }, 8, ["runtime-url", "render", "moveable-options", "can-select"])
4004
+ })
4530
4005
  ])
4531
4006
  ]),
4532
4007
  propsPanel: vue.withCtx(() => [
@@ -4541,11 +4016,11 @@
4541
4016
  vue.renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
4542
4017
  ]),
4543
4018
  _: 3
4544
- });
4019
+ }, 8, ["code-options"]);
4545
4020
  }
4546
4021
  var Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
4547
4022
 
4548
- var index$1 = '';
4023
+ var index$1 = /* #__PURE__ */ (() => ".m-editor-nav-menu {\n display: flex;\n z-index: 5;\n -webkit-box-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n align-items: center;\n background-color: #ffffff;\n font-size: 19.2px;\n color: #070303;\n font-weight: 400;\n box-sizing: border-box;\n margin: 0px;\n flex: 0 0 35px;\n border-bottom: 1px solid #d8dee8;\n}\n.m-editor-nav-menu > div {\n display: flex;\n height: 100%;\n z-index: 1;\n align-items: center;\n}\n.m-editor-nav-menu .menu-center {\n justify-content: center;\n}\n.m-editor-nav-menu .menu-right {\n justify-content: flex-end;\n}\n.m-editor-nav-menu .menu-item {\n flex-direction: row;\n -webkit-box-align: center;\n align-items: center;\n vertical-align: middle;\n font-size: 14px;\n line-height: 1;\n height: 100%;\n color: rgba(255, 255, 255, 0.7);\n box-sizing: inherit;\n z-index: 1;\n display: flex !important;\n transition: all 0.3s ease 0s;\n border-bottom: 2px solid transparent;\n margin: 0;\n}\n.m-editor-nav-menu .menu-item .is-disabled {\n opacity: 0.5;\n}\n.m-editor-nav-menu .menu-item .is-text {\n padding: 5px;\n}\n.m-editor-nav-menu .menu-item .is-text,\n.m-editor-nav-menu .menu-item i {\n color: #070303;\n}\n.m-editor-nav-menu .menu-item .icon {\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n height: 100%;\n padding: 0px 8px;\n}\n.m-editor-nav-menu .menu-item .menu-item-text {\n color: #070303;\n}\n.m-editor {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.m-editor-content {\n width: 100%;\n height: calc(100% - 35px);\n display: flex;\n justify-self: space-between;\n}\n.m-editor-framework-center {\n position: relative;\n transform: translateZ(0);\n flex: 1;\n}\n.m-editor-framework-left {\n background-color: #ffffff;\n}\n.m-editor-framework-center .el-scrollbar__view {\n height: 100%;\n min-height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-empty-panel {\n display: flex;\n flex: 1;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n height: calc(100% - 32px);\n}\n.m-editor-empty-content {\n display: flex;\n justify-content: space-evenly;\n flex-direction: row;\n width: 100%;\n}\n.m-editor-empty-button {\n border: 3px solid rgba(0, 0, 0, 0.2);\n padding: 10px 40px;\n color: rgba(0, 0, 0, 0.6);\n cursor: pointer;\n}\n.m-editor-empty-button i {\n height: 180px;\n line-height: 180px;\n font-size: 100px;\n}\n.m-editor-empty-button p {\n text-align: center;\n font-size: 20px;\n margin-top: 5px;\n}\n.m-editor-empty-button:hover {\n border-color: #2882e0;\n color: #2882e0;\n}\n.m-editor-sidebar {\n height: 100%;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header {\n background: #2882e0;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header.is-left {\n width: 40px;\n margin-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav-wrap {\n margin: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__nav {\n border: 0;\n border-radius: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .tab-label {\n margin-left: 2px;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left {\n line-height: 15px;\n border: 0;\n height: auto;\n padding: 8px;\n color: rgb(255, 255, 255);\n box-sizing: border-box;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active {\n background: #ffffff;\n border: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active i {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left.is-active .magic-editor-tab-panel-title {\n color: #353140;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .el-tabs__item.is-left.is-left:first-child {\n border-right: 0;\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i {\n font-size: 25px;\n color: rgba(255, 255, 255, 0.6);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header i:hover {\n color: rgb(255, 255, 255);\n}\n.m-editor-sidebar.el-tabs--left .el-tabs__header .magic-editor-tab-panel-title {\n font-size: 12px;\n white-space: normal;\n}\n.m-editor-sidebar .el-scrollbar {\n height: 100%;\n}\n.m-editor-sidebar .el-tree {\n min-height: 100%;\n}\n.m-editor-sidebar .fold-icon {\n position: absolute;\n bottom: 8px;\n left: 0px;\n width: 45px;\n padding-left: 8px;\n color: #fff;\n font-size: 32px;\n opacity: 0.8;\n cursor: pointer;\n}\n.m-editor-sidebar .fold-icon:hover {\n background: rgba(0, 0, 0, 0.2);\n}\n.m-editor-sidebar .el-tabs__content,\n.m-editor-sidebar .el-tab-pane {\n height: 100%;\n}\n.magic-editor-layer-panel {\n background: #ffffff;\n}\n.magic-editor-layer-panel .search-input {\n background: #ffffff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1;\n}\n.magic-editor-layer-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.magic-editor-layer-panel .node-content {\n flex: 1;\n display: flex;\n width: 100%;\n}\n.magic-editor-layer-panel .node-content > div {\n width: 8px;\n}\n.magic-editor-layer-panel .node-content > span {\n width: calc(100% - 68px);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.magic-editor-layer-panel .node-content > i {\n margin-right: 10px;\n font-size: 20px;\n}\n.magic-editor-layer-panel .node-content > i.lock {\n color: #bbb;\n}\n.magic-editor-layer-panel,\n.magic-editor-layer-panel .el-tree {\n background-color: #ffffff;\n color: #313a40;\n}\n.magic-editor-layer-panel .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.magic-editor-layer-panel .cus-tree-node {\n width: 100%;\n overflow: hidden;\n}\n.magic-editor-layer-panel .cus-tree-node-hover {\n background-color: #f3f5f9;\n width: 100%;\n}\n.magic-editor-layer-panel .el-tree-node:focus > .el-tree-node__content {\n background-color: #2882e0;\n color: #fff;\n}\n.ui-tree-tip {\n width: 100%;\n height: 25px;\n margin-left: 10px;\n background: #ffffff;\n font-style: italic;\n color: #555554;\n position: absolute;\n top: 40px;\n left: 0;\n z-index: 1;\n}\n.ui-component-panel {\n height: 100%;\n border-top: 0 !important;\n margin-top: 50px;\n background-color: #ffffff;\n}\n.ui-component-panel .search-input {\n background: #f8fbff;\n color: #bbbbbb;\n padding: 10px;\n position: absolute;\n top: 0;\n left: 0;\n box-sizing: border-box;\n z-index: 1;\n}\n.ui-component-panel .search-input .el-input__prefix {\n padding: 10px;\n}\n.ui-component-panel .search-input .el-input__suffix {\n padding: 10px 5px;\n}\n.ui-component-panel .el-collapse-item > div:first-of-type {\n border-bottom: 1px solid #d9dbdd;\n margin-bottom: 10px;\n}\n.ui-component-panel .el-collapse-item__header {\n background: #ffffff;\n color: #070303;\n height: 25px;\n line-height: 25px;\n padding-left: 10px;\n font-size: 12px;\n}\n.ui-component-panel .el-collapse-item__header i {\n margin-right: 5px;\n font-size: 14px;\n}\n.ui-component-panel .el-collapse-item__wrap {\n background: #ffffff;\n border-bottom: 0;\n}\n.ui-component-panel .el-collapse-item__wrap .el-collapse-item__content {\n padding: 10px;\n display: flex;\n flex-wrap: wrap;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item {\n display: flex;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 5px 10px;\n box-sizing: border-box;\n color: #070303;\n flex-direction: column;\n width: 42px;\n cursor: pointer;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i {\n font-size: 20px;\n background: #fff;\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 5px;\n color: #909090;\n border: 1px solid #d9dbdd;\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n margin-bottom: 5px;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item i:hover {\n background: #2882e0;\n color: #fff;\n border-color: #4e8be1;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item span {\n font-size: 12px;\n text-align: center;\n}\n.ui-component-panel .el-collapse-item__wrap .component-item .el-tooltip {\n width: 50px;\n height: 30px;\n line-height: 15px;\n display: block;\n white-space: normal;\n margin: 0;\n}\n.m-editor-resizer {\n border-left: 1px solid transparent;\n border-right: 1px solid transparent;\n width: 8px;\n margin: 0 -5px;\n height: 100%;\n opacity: 0.9;\n background: padding-box #d8dee8;\n box-sizing: border-box;\n cursor: col-resize;\n z-index: 1;\n}\n.m-editor-resizer:hover {\n border-color: #d8dee8;\n}\n.m-editor-resizer .icon-container {\n visibility: hidden;\n opacity: 0;\n transition: opacity 0.4s;\n width: 20px;\n height: 120px;\n line-height: 120px;\n text-align: center;\n background: #d8dee8;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n cursor: pointer;\n}\n.m-editor-resizer .icon-container.position-left {\n transform: translate(calc(-100% - 4px), -50%);\n}\n.m-editor-resizer .icon-container.position-right {\n transform: translate(calc(100% + 4px), -50%);\n}\n.m-editor-resizer .icon {\n color: #fff;\n font-size: 18px;\n}\n.magic-editor-resizer:hover .icon-container {\n visibility: visible;\n opacity: 1;\n}\n.m-editor-workspace {\n height: 100%;\n width: 100%;\n user-select: none;\n}\n.m-editor-workspace:focus-visible {\n outline: 0;\n}\n.m-editor-page-bar {\n position: fixed;\n bottom: 0;\n left: 0;\n display: flex;\n width: 100%;\n height: 32px;\n line-height: 32px;\n color: #070303;\n background-color: #f3f3f3;\n border-top: 1px solid #d9dbdd;\n z-index: 2;\n overflow: hidden;\n}\n.m-editor-page-bar-items {\n display: flex;\n transition: transform 0.3s;\n}\n.m-editor-page-bar-item {\n padding: 0 10px;\n cursor: pointer;\n border-right: 1px solid #d9dbdd;\n display: flex;\n justify-items: center;\n align-items: center;\n background-color: #f3f3f3;\n white-space: nowrap;\n}\n.m-editor-page-bar-item.active {\n background-color: #fff;\n cursor: text;\n}\n.m-editor-page-bar-item.active .m-editor-page-bar-menu-icon {\n cursor: pointer;\n}\n.m-editor-page-bar-item-icon {\n position: relative;\n z-index: 1;\n}\n.m-editor-page-bar-item-title {\n max-width: 150px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n}\n.page-bar-popover.el-popper.el-popover {\n padding: 10px 0;\n}\n.page-bar-popover .menu-item {\n cursor: pointer;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n}\n.page-bar-popover .menu-item .el-button--text,\n.page-bar-popover .menu-item i {\n color: #070303;\n}\n.page-bar-popover .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-props-panel {\n padding: 0 10px;\n}\n.m-editor-props-panel.small .el-form-item__label {\n font-size: 12px;\n}\n.m-editor-props-panel.small .m-fieldset legend {\n font-size: 12px;\n}\n.m-editor-props-panel.small .el-tabs__item {\n font-size: 12px;\n}\n.m-editor-props-panel .el-input__wrapper {\n border-radius: 0;\n}\n.m-editor-props-panel-popper.small span,\n.m-editor-props-panel-popper.small a,\n.m-editor-props-panel-popper.small p {\n font-size: 12px;\n}\n.magic-editor-content-menu {\n position: fixed;\n font-size: 12px;\n background: #fff;\n box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);\n z-index: 9999;\n transform-origin: 0% 0%;\n font-weight: 600;\n padding: 4px 0px;\n overflow: auto;\n max-height: 100%;\n}\n.magic-editor-content-menu .menu-item {\n color: #333;\n display: flex;\n -webkit-box-align: center;\n align-items: center;\n cursor: pointer;\n min-width: 140px;\n transition: all 0.2s ease 0s;\n padding: 5px 14px;\n border-left: 2px solid transparent;\n}\n.magic-editor-content-menu .menu-item .el-button {\n width: 100%;\n justify-content: flex-start;\n}\n.magic-editor-content-menu .menu-item .el-button--text,\n.magic-editor-content-menu .menu-item i {\n color: #070303;\n}\n.magic-editor-content-menu .menu-item.divider {\n padding: 0 14px;\n}\n.magic-editor-content-menu .menu-item.divider .el-divider {\n margin: 0;\n}\n.magic-editor-content-menu .menu-item:hover {\n background-color: #f3f5f9;\n}\n.m-editor-stage {\n position: relative;\n width: 100%;\n height: calc(100% - 32px);\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.m-editor-stage-container {\n width: 100%;\n height: 100%;\n z-index: 0;\n position: relative;\n border: 1px solid #d9dbdd;\n transition: transform 0.3s;\n box-sizing: content-box;\n}\n.m-editor-stage-container::-webkit-scrollbar {\n width: 0 !important;\n}\n.magic-code-editor {\n width: 100%;\n}\n.magic-code-editor .margin {\n margin: 0;\n}")();
4549
4024
 
4550
4025
  const defaultInstallOpt = {};
4551
4026
  var index = {
@@ -4572,6 +4047,7 @@
4572
4047
  exports.PropsPanel = PropsPanel;
4573
4048
  exports.TMagicCodeEditor = CodeEditor;
4574
4049
  exports.TMagicEditor = Editor;
4050
+ exports.ToolButton = ToolButton;
4575
4051
  exports.change2Fixed = change2Fixed;
4576
4052
  exports.debug = debug;
4577
4053
  exports["default"] = index;
@@ -4579,7 +4055,6 @@
4579
4055
  exports.error = error;
4580
4056
  exports.eventsService = eventsService;
4581
4057
  exports.fillConfig = fillConfig;
4582
- exports.generateId = generateId;
4583
4058
  exports.generatePageName = generatePageName;
4584
4059
  exports.generatePageNameByApp = generatePageNameByApp;
4585
4060
  exports.getConfig = getConfig;
@@ -4595,13 +4070,11 @@
4595
4070
  exports.propsService = propsService;
4596
4071
  exports.setConfig = setConfig;
4597
4072
  exports.setLayout = setLayout;
4598
- exports.setNewItemId = setNewItemId;
4599
4073
  exports.toRelative = toRelative;
4600
4074
  exports.uiService = uiService;
4601
4075
  exports.warn = warn;
4602
4076
 
4603
- Object.defineProperty(exports, '__esModule', { value: true });
4604
- exports[Symbol.toStringTag] = 'Module';
4077
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4605
4078
 
4606
4079
  }));
4607
4080
  //# sourceMappingURL=tmagic-editor.umd.js.map