@tmagic/editor 1.4.0-beta.1 → 1.4.0

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 (54) hide show
  1. package/dist/style.css +22 -26
  2. package/dist/tmagic-editor.js +977 -798
  3. package/dist/tmagic-editor.umd.cjs +981 -800
  4. package/package.json +11 -11
  5. package/src/components/CodeBlockEditor.vue +75 -101
  6. package/src/components/FloatingBox.vue +58 -38
  7. package/src/components/SplitView.vue +46 -35
  8. package/src/fields/DataSourceFieldSelect.vue +2 -1
  9. package/src/fields/DataSourceFields.vue +55 -30
  10. package/src/fields/DataSourceInput.vue +6 -2
  11. package/src/fields/DataSourceMocks.vue +35 -17
  12. package/src/hooks/index.ts +2 -0
  13. package/src/hooks/use-code-block-edit.ts +1 -1
  14. package/src/hooks/use-editor-content-height.ts +20 -0
  15. package/src/hooks/use-float-box.ts +21 -15
  16. package/src/hooks/use-next-float-box-position.ts +29 -0
  17. package/src/hooks/use-window-rect.ts +20 -0
  18. package/src/layouts/CodeEditor.vue +3 -6
  19. package/src/layouts/Framework.vue +33 -34
  20. package/src/layouts/PropsPanel.vue +37 -0
  21. package/src/layouts/sidebar/Sidebar.vue +17 -15
  22. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +1 -3
  23. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +36 -22
  24. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +1 -6
  25. package/src/layouts/workspace/viewer/NodeListMenu.vue +1 -0
  26. package/src/layouts/workspace/viewer/StageOverlay.vue +3 -1
  27. package/src/services/stageOverlay.ts +2 -2
  28. package/src/services/ui.ts +6 -0
  29. package/src/theme/code-block.scss +0 -19
  30. package/src/theme/component-list-panel.scss +0 -1
  31. package/src/theme/floating-box.scss +2 -2
  32. package/src/theme/icon.scss +7 -1
  33. package/src/theme/layer-panel.scss +0 -1
  34. package/src/theme/props-panel.scss +14 -0
  35. package/src/theme/sidebar.scss +0 -7
  36. package/src/type.ts +6 -6
  37. package/types/components/CodeBlockEditor.vue.d.ts +39 -25
  38. package/types/components/FloatingBox.vue.d.ts +42 -57
  39. package/types/components/SplitView.vue.d.ts +2 -0
  40. package/types/fields/DataSourceFields.vue.d.ts +84 -28
  41. package/types/fields/DataSourceMocks.vue.d.ts +80 -28
  42. package/types/hooks/index.d.ts +2 -0
  43. package/types/hooks/use-code-block-edit.d.ts +16 -11
  44. package/types/hooks/use-data-source-method.d.ts +16 -11
  45. package/types/hooks/use-editor-content-height.d.ts +3 -0
  46. package/types/hooks/use-next-float-box-position.d.ts +9 -0
  47. package/types/hooks/use-window-rect.d.ts +6 -0
  48. package/types/layouts/sidebar/Sidebar.vue.d.ts +1 -1
  49. package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +1 -3
  50. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +34 -22
  51. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +2 -15
  52. package/types/services/stageOverlay.d.ts +1 -1
  53. package/types/services/ui.d.ts +6 -0
  54. package/types/type.d.ts +6 -5
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('@tmagic/design'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/form'), require('moveable'), require('@tmagic/table'), require('@tmagic/utils'), require('gesto'), require('@tmagic/dep'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', '@tmagic/design', 'emmet-monaco-es', 'monaco-editor', '@tmagic/schema', '@tmagic/form', 'moveable', '@tmagic/table', '@tmagic/utils', 'gesto', '@tmagic/dep', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.design, global.emmetMonacoEs, global.monaco, global.schema, global.form, global.VanillaMoveable, global.table, global.utils, global.Gesto, global.dep, global.StageCore, global.events, global.core, global.KeyController));
5
- })(this, (function (exports, vue, iconsVue, lodashEs, serialize, design, emmetMonacoEs, monaco, schema, form, VanillaMoveable, table, utils, Gesto, dep, StageCore, events, core, KeyController) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('@tmagic/design'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/form'), require('moveable'), require('@tmagic/table'), require('@tmagic/utils'), require('@tmagic/dep'), require('gesto'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', '@tmagic/design', 'emmet-monaco-es', 'monaco-editor', '@tmagic/schema', '@tmagic/form', 'moveable', '@tmagic/table', '@tmagic/utils', '@tmagic/dep', 'gesto', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.design, global.emmetMonacoEs, global.monaco, global.schema, global.form, global.VanillaMoveable, global.table, global.utils, global.dep, global.Gesto, global.StageCore, global.events, global.core, global.KeyController));
5
+ })(this, (function (exports, vue, iconsVue, lodashEs, serialize, design, emmetMonacoEs, monaco, schema, form, VanillaMoveable, table, utils, dep, Gesto, StageCore, events, core, KeyController) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -23,6 +23,50 @@
23
23
 
24
24
  const monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
25
25
 
26
+ const _hoisted_1$t = ["src"];
27
+ const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
28
+ ...{
29
+ name: "MEditorIcon"
30
+ },
31
+ __name: "Icon",
32
+ props: {
33
+ icon: {}
34
+ },
35
+ setup(__props) {
36
+ const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
37
+ return (_ctx, _cache) => {
38
+ return !_ctx.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
39
+ key: 0,
40
+ class: "magic-editor-icon"
41
+ }, {
42
+ default: vue.withCtx(() => [
43
+ vue.createVNode(vue.unref(iconsVue.Edit))
44
+ ]),
45
+ _: 1
46
+ })) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
47
+ key: 1,
48
+ class: "magic-editor-icon"
49
+ }, {
50
+ default: vue.withCtx(() => [
51
+ vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$t)
52
+ ]),
53
+ _: 1
54
+ })) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
55
+ key: 2,
56
+ class: vue.normalizeClass(["magic-editor-icon", _ctx.icon])
57
+ }, null, 2)) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
58
+ key: 3,
59
+ class: "magic-editor-icon"
60
+ }, {
61
+ default: vue.withCtx(() => [
62
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(_ctx.icon))))
63
+ ]),
64
+ _: 1
65
+ }));
66
+ };
67
+ }
68
+ });
69
+
26
70
  let $TMAGIC_EDITOR = {};
27
71
  const setConfig = (option) => {
28
72
  $TMAGIC_EDITOR = option;
@@ -32,10 +76,10 @@
32
76
  emmetMonacoEs.emmetHTML(monaco__namespace);
33
77
  emmetMonacoEs.emmetCSS(monaco__namespace, ["css", "scss"]);
34
78
 
35
- const _hoisted_1$u = {
79
+ const _hoisted_1$s = {
36
80
  class: /* @__PURE__ */ vue.normalizeClass(`magic-code-editor`)
37
81
  };
38
- const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
82
+ const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
39
83
  ...{
40
84
  name: "MEditorCodeEditor"
41
85
  },
@@ -193,7 +237,7 @@
193
237
  }
194
238
  });
195
239
  return (_ctx, _cache) => {
196
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$u, [
240
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
197
241
  (vue.openBlock(), vue.createBlock(vue.Teleport, {
198
242
  to: "body",
199
243
  disabled: !fullScreen.value
@@ -206,9 +250,13 @@
206
250
  class: "magic-code-editor-full-screen-icon",
207
251
  circle: "",
208
252
  size: "small",
209
- icon: vue.unref(iconsVue.FullScreen),
210
253
  onClick: fullScreenHandler
211
- }, null, 8, ["icon"]),
254
+ }, {
255
+ default: vue.withCtx(() => [
256
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.FullScreen) }, null, 8, ["icon"])
257
+ ]),
258
+ _: 1
259
+ }),
212
260
  vue.createElementVNode("div", {
213
261
  ref_key: "codeEditor",
214
262
  ref: codeEditor,
@@ -221,7 +269,7 @@
221
269
  }
222
270
  });
223
271
 
224
- const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
272
+ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
225
273
  ...{
226
274
  name: "MFieldsVsCode"
227
275
  },
@@ -246,7 +294,7 @@
246
294
  emit("change", v);
247
295
  };
248
296
  return (_ctx, _cache) => {
249
- return vue.openBlock(), vue.createBlock(_sfc_main$U, {
297
+ return vue.openBlock(), vue.createBlock(_sfc_main$T, {
250
298
  height: _ctx.config.height,
251
299
  "init-values": _ctx.model[_ctx.name],
252
300
  language: _ctx.config.language,
@@ -261,7 +309,7 @@
261
309
  }
262
310
  });
263
311
 
264
- const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
312
+ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
265
313
  ...{
266
314
  name: "MFieldsCodeLink"
267
315
  },
@@ -341,7 +389,7 @@
341
389
  }
342
390
  });
343
391
 
344
- const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
392
+ const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
345
393
  ...{
346
394
  name: "MFieldsCodeSelect"
347
395
  },
@@ -459,40 +507,54 @@
459
507
  }
460
508
  });
461
509
 
462
- const _hoisted_1$t = { class: "m-editor-float-box-body" };
463
- const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
510
+ const _sfc_main$P = /* @__PURE__ */ vue.defineComponent({
464
511
  __name: "FloatingBox",
465
- props: {
466
- visible: { type: Boolean, default: false },
512
+ props: /* @__PURE__ */ vue.mergeModels({
467
513
  position: { default: () => ({ left: 0, top: 0 }) },
468
- rect: { default: () => ({ width: "auto", height: "auto" }) },
469
514
  title: { default: "" },
470
515
  beforeClose: {}
471
- },
472
- emits: ["update:visible"],
473
- setup(__props, { expose: __expose, emit: __emit }) {
516
+ }, {
517
+ "width": { default: 0 },
518
+ "widthModifiers": {},
519
+ "height": { default: 0 },
520
+ "heightModifiers": {},
521
+ "visible": { type: Boolean, ...{ default: false } },
522
+ "visibleModifiers": {}
523
+ }),
524
+ emits: ["update:width", "update:height", "update:visible"],
525
+ setup(__props, { expose: __expose }) {
526
+ const width = vue.useModel(__props, "width");
527
+ const height = vue.useModel(__props, "height");
528
+ const visible = vue.useModel(__props, "visible");
474
529
  const props = __props;
475
- const emit = __emit;
476
530
  const target = vue.ref();
477
- const dragTarget = vue.ref();
531
+ const titleEl = vue.ref();
478
532
  const zIndex = design.useZIndex();
479
- const curZIndex = vue.ref(zIndex.nextZIndex());
480
- const rect = vue.ref({
481
- width: props.rect.width,
482
- height: props.rect.height
533
+ const curZIndex = vue.ref(0);
534
+ const titleHeight = vue.ref(0);
535
+ const bodyHeight = vue.computed(() => {
536
+ if (height.value) {
537
+ return height.value - titleHeight.value;
538
+ }
539
+ if (target.value) {
540
+ return target.value.clientHeight - titleHeight.value;
541
+ }
542
+ return "auto";
483
543
  });
484
- vue.watchEffect(() => {
485
- rect.value = {
486
- width: props.rect.width,
487
- height: props.rect.height
544
+ const services = vue.inject("services");
545
+ const frameworkWidth = vue.computed(() => services?.uiService.get("frameworkRect").width || 0);
546
+ const style = vue.computed(() => {
547
+ let { left } = props.position;
548
+ if (width.value) {
549
+ left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
550
+ }
551
+ return {
552
+ left: `${left}px`,
553
+ top: `${props.position.top}px`,
554
+ width: width.value ? `${width.value}px` : "auto",
555
+ height: height.value ? `${height.value}px` : "auto"
488
556
  };
489
557
  });
490
- const style = vue.computed(() => ({
491
- left: `${props.position.left}px`,
492
- top: `${props.position.top}px`,
493
- width: typeof rect.value.width === "string" ? rect.value.width : `${rect.value.width}px`,
494
- height: typeof rect.value.height === "string" ? rect.value.height : `${rect.value.height}px`
495
- }));
496
558
  let moveable = null;
497
559
  const initMoveable = () => {
498
560
  moveable = new VanillaMoveable(globalThis.document.body, {
@@ -504,7 +566,7 @@
504
566
  keepRatio: false,
505
567
  origin: false,
506
568
  snappable: true,
507
- dragTarget: dragTarget.value,
569
+ dragTarget: titleEl.value,
508
570
  dragTargetSelf: false,
509
571
  linePadding: 10,
510
572
  controlPadding: 10,
@@ -514,8 +576,8 @@
514
576
  e.target.style.transform = e.transform;
515
577
  });
516
578
  moveable.on("resize", (e) => {
517
- rect.value.width = e.width;
518
- rect.value.height = e.height;
579
+ width.value = e.width;
580
+ height.value = e.height;
519
581
  e.target.style.width = `${e.width}px`;
520
582
  e.target.style.height = `${e.height}px`;
521
583
  e.target.style.transform = e.drag.transform;
@@ -526,11 +588,21 @@
526
588
  moveable = null;
527
589
  };
528
590
  vue.watch(
529
- () => props.visible,
530
- async (visible) => {
531
- if (visible) {
591
+ visible,
592
+ async (visible2) => {
593
+ if (visible2) {
532
594
  await vue.nextTick();
533
- initMoveable();
595
+ curZIndex.value = zIndex.nextZIndex();
596
+ const targetRect = target.value?.getBoundingClientRect();
597
+ if (targetRect) {
598
+ width.value = targetRect.width;
599
+ height.value = targetRect.height;
600
+ initMoveable();
601
+ }
602
+ if (titleEl.value) {
603
+ const titleRect = titleEl.value.getBoundingClientRect();
604
+ titleHeight.value = titleRect.height;
605
+ }
534
606
  } else {
535
607
  destroyMoveable();
536
608
  }
@@ -544,7 +616,7 @@
544
616
  });
545
617
  const hide = (cancel) => {
546
618
  if (cancel !== false) {
547
- emit("update:visible", false);
619
+ visible.value = false;
548
620
  }
549
621
  };
550
622
  const closeHandler = () => {
@@ -557,11 +629,14 @@
557
629
  const nextZIndex = () => {
558
630
  curZIndex.value = zIndex.nextZIndex();
559
631
  };
632
+ vue.provide("parentFloating", target);
560
633
  __expose({
561
- target
634
+ bodyHeight,
635
+ target,
636
+ titleEl
562
637
  });
563
638
  return (_ctx, _cache) => {
564
- return _ctx.visible ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
639
+ return visible.value ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
565
640
  key: 0,
566
641
  to: "body"
567
642
  }, [
@@ -573,8 +648,8 @@
573
648
  onMousedown: nextZIndex
574
649
  }, [
575
650
  vue.createElementVNode("div", {
576
- ref_key: "dragTarget",
577
- ref: dragTarget,
651
+ ref_key: "titleEl",
652
+ ref: titleEl,
578
653
  class: "m-editor-float-box-title"
579
654
  }, [
580
655
  vue.renderSlot(_ctx.$slots, "title", {}, () => [
@@ -584,63 +659,120 @@
584
659
  vue.createVNode(vue.unref(design.TMagicButton), {
585
660
  link: "",
586
661
  size: "small",
587
- icon: vue.unref(iconsVue.Close),
588
662
  onClick: closeHandler
589
- }, null, 8, ["icon"])
663
+ }, {
664
+ default: vue.withCtx(() => [
665
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Close) }, null, 8, ["icon"])
666
+ ]),
667
+ _: 1
668
+ })
590
669
  ])
591
670
  ], 512),
592
- vue.createElementVNode("div", _hoisted_1$t, [
671
+ vue.createElementVNode("div", {
672
+ class: "m-editor-float-box-body",
673
+ style: vue.normalizeStyle({ height: `${bodyHeight.value}px` })
674
+ }, [
593
675
  vue.renderSlot(_ctx.$slots, "body")
594
- ])
676
+ ], 4)
595
677
  ], 36)
596
678
  ])) : vue.createCommentVNode("", true);
597
679
  };
598
680
  }
599
681
  });
600
682
 
601
- const _hoisted_1$s = { style: { "display": "flex", "margin-bottom": "10px" } };
683
+ const useEditorContentHeight = () => {
684
+ const services = vue.inject("services");
685
+ const frameworkHeight = vue.computed(() => services?.uiService.get("frameworkRect").height || 0);
686
+ const navMenuHeight = vue.computed(() => services?.uiService.get("navMenuRect").height || 0);
687
+ const editorContentHeight = vue.computed(() => frameworkHeight.value - navMenuHeight.value);
688
+ const height = vue.ref(0);
689
+ vue.watchEffect(() => {
690
+ if (height.value > 0 && height.value === editorContentHeight.value)
691
+ return;
692
+ height.value = editorContentHeight.value;
693
+ });
694
+ return {
695
+ height
696
+ };
697
+ };
698
+
699
+ const useNextFloatBoxPosition = (uiService, parent) => {
700
+ const boxPosition = vue.ref({
701
+ left: 0,
702
+ top: 0
703
+ });
704
+ const calcBoxPosition = () => {
705
+ const columnWidth = uiService?.get("columnWidth");
706
+ const navMenuRect = uiService?.get("navMenuRect");
707
+ let left = columnWidth?.left ?? 0;
708
+ if (parent?.value) {
709
+ const rect = parent?.value?.getBoundingClientRect();
710
+ left = (rect?.left ?? 0) + (rect?.width ?? 0);
711
+ }
712
+ boxPosition.value = {
713
+ left,
714
+ top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
715
+ };
716
+ };
717
+ return {
718
+ boxPosition,
719
+ calcBoxPosition
720
+ };
721
+ };
722
+
723
+ const useWindowRect = () => {
724
+ const rect = vue.reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
725
+ const windowResizeHandler = () => {
726
+ rect.width = globalThis.innerWidth;
727
+ rect.height = globalThis.innerHeight;
728
+ };
729
+ globalThis.addEventListener("resize", windowResizeHandler);
730
+ vue.onBeforeUnmount(() => {
731
+ globalThis.removeEventListener("resize", windowResizeHandler);
732
+ });
733
+ return {
734
+ rect
735
+ };
736
+ };
737
+
738
+ const _hoisted_1$r = { style: { "display": "flex", "margin-bottom": "10px" } };
602
739
  const _hoisted_2$k = { style: { "flex": "1" } };
603
740
  const _hoisted_3$8 = { style: { "flex": "1" } };
604
741
  const _hoisted_4$7 = { class: "dialog-footer" };
605
- const _sfc_main$P = /* @__PURE__ */ vue.defineComponent({
742
+ const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
606
743
  ...{
607
744
  name: "MEditorCodeBlockEditor"
608
745
  },
609
746
  __name: "CodeBlockEditor",
610
- props: {
747
+ props: /* @__PURE__ */ vue.mergeModels({
611
748
  content: {},
612
749
  disabled: { type: Boolean },
613
750
  isDataSource: { type: Boolean },
614
- dataSourceType: {},
615
- slideType: {}
616
- },
617
- emits: ["submit"],
751
+ dataSourceType: {}
752
+ }, {
753
+ "width": { default: 670 },
754
+ "widthModifiers": {},
755
+ "visible": { type: Boolean, ...{ default: false } },
756
+ "visibleModifiers": {}
757
+ }),
758
+ emits: /* @__PURE__ */ vue.mergeModels(["submit"], ["update:width", "update:visible"]),
618
759
  setup(__props, { expose: __expose, emit: __emit }) {
760
+ const width = vue.useModel(__props, "width");
761
+ const boxVisible = vue.useModel(__props, "visible");
619
762
  const props = __props;
620
763
  const emit = __emit;
621
764
  const services = vue.inject("services");
765
+ const { height: codeBlockEditorHeight } = useEditorContentHeight();
622
766
  const difVisible = vue.ref(false);
623
- const height = vue.ref(globalThis.innerHeight);
624
- const windowReizehandler = () => {
625
- height.value = globalThis.innerHeight;
626
- };
627
- globalThis.addEventListener("resize", windowReizehandler);
628
- vue.onBeforeUnmount(() => {
629
- globalThis.removeEventListener("resize", windowReizehandler);
630
- });
767
+ const { rect: windowRect } = useWindowRect();
631
768
  const magicVsEditor = vue.ref();
632
769
  const diffChange = () => {
633
- if (!magicVsEditor.value || !fomDrawer.value?.form) {
770
+ if (!magicVsEditor.value || !formBox.value?.form) {
634
771
  return;
635
772
  }
636
- fomDrawer.value.form.values.content = magicVsEditor.value.getEditorValue();
773
+ formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
637
774
  difVisible.value = false;
638
775
  };
639
- const columnWidth = vue.computed(() => services?.uiService.get("columnWidth"));
640
- const size = vue.computed(
641
- () => columnWidth.value ? columnWidth.value.center + columnWidth.value.right - (props.isDataSource ? 100 : 0) : 600
642
- );
643
- const codeEditorHeight = vue.ref("600px");
644
776
  const defaultParamColConfig = {
645
777
  type: "row",
646
778
  label: "参数类型",
@@ -723,7 +855,7 @@
723
855
  name: "content",
724
856
  type: "vs-code",
725
857
  options: vue.inject("codeOptions", {}),
726
- height: codeEditorHeight.value,
858
+ height: "500px",
727
859
  onChange: (formState, code) => {
728
860
  try {
729
861
  getConfig("parseDSL")(code);
@@ -736,20 +868,13 @@
736
868
  }
737
869
  ]);
738
870
  const submitForm = (values) => {
871
+ changedValue.value = void 0;
739
872
  emit("submit", values);
740
873
  };
741
874
  const errorHandler = (error) => {
742
875
  design.tMagicMessage.error(error.message);
743
876
  };
744
- const fomDrawer = vue.ref();
745
- const openHandler = () => {
746
- setTimeout(() => {
747
- if (fomDrawer.value) {
748
- const height2 = fomDrawer.value?.bodyHeight - 348 - (props.isDataSource ? 50 : 0);
749
- codeEditorHeight.value = `${height2 > 100 ? height2 : 600}px`;
750
- }
751
- });
752
- };
877
+ const formBox = vue.ref();
753
878
  const changedValue = vue.ref();
754
879
  const changeHandler = (values) => {
755
880
  changedValue.value = values;
@@ -774,151 +899,134 @@
774
899
  const closedHandler = () => {
775
900
  changedValue.value = void 0;
776
901
  };
777
- const boxVisible = vue.ref(false);
778
- const editVisible = vue.ref(false);
779
- const floatingBoxBody = vue.ref();
780
- const boxPosition = vue.computed(() => {
781
- const columnWidth2 = services?.uiService?.get("columnWidth");
782
- const navMenuRect = services?.uiService?.get("navMenuRect");
783
- return {
784
- left: columnWidth2?.left ?? 0,
785
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
786
- };
787
- });
902
+ const parentFloating = vue.inject("parentFloating", vue.ref(null));
903
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
788
904
  __expose({
789
905
  async show() {
790
- if (props.slideType !== "box") {
791
- boxVisible.value = true;
792
- }
793
- await vue.nextTick();
794
- editVisible.value = true;
795
- fomDrawer.value?.show();
906
+ calcBoxPosition();
907
+ boxVisible.value = true;
796
908
  },
797
- hide() {
798
- fomDrawer.value?.hide();
909
+ async hide() {
910
+ boxVisible.value = false;
799
911
  }
800
912
  });
801
913
  return (_ctx, _cache) => {
802
914
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
803
- vue.createVNode(_sfc_main$Q, {
915
+ vue.createVNode(_sfc_main$P, {
804
916
  visible: boxVisible.value,
805
- "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
806
- title: "代码编辑",
807
- position: boxPosition.value,
917
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
918
+ width: width.value,
919
+ "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
920
+ height: vue.unref(codeBlockEditorHeight),
921
+ "onUpdate:height": _cache[3] || (_cache[3] = ($event) => vue.isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
922
+ title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
923
+ position: vue.unref(boxPosition),
808
924
  "before-close": beforeClose
809
925
  }, {
810
926
  body: vue.withCtx(() => [
811
- vue.createElementVNode("div", {
812
- ref_key: "floatingBoxBody",
813
- ref: floatingBoxBody
814
- }, null, 512)
927
+ vue.createVNode(vue.unref(form.MFormBox), {
928
+ class: "m-editor-code-block-editor",
929
+ ref_key: "formBox",
930
+ ref: formBox,
931
+ "label-width": "80px",
932
+ "close-on-press-escape": false,
933
+ title: _ctx.content.name,
934
+ config: functionConfig.value,
935
+ values: _ctx.content,
936
+ disabled: _ctx.disabled,
937
+ style: { "height": "100%" },
938
+ onChange: changeHandler,
939
+ onSubmit: submitForm,
940
+ onError: errorHandler,
941
+ onClosed: closedHandler
942
+ }, {
943
+ left: vue.withCtx(() => [
944
+ !_ctx.disabled ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
945
+ key: 0,
946
+ type: "primary",
947
+ link: "",
948
+ onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
949
+ }, {
950
+ default: vue.withCtx(() => [
951
+ vue.createTextVNode("查看修改")
952
+ ]),
953
+ _: 1
954
+ })) : vue.createCommentVNode("", true)
955
+ ]),
956
+ _: 1
957
+ }, 8, ["title", "config", "values", "disabled"])
815
958
  ]),
816
959
  _: 1
817
- }, 8, ["visible", "position"]),
818
- editVisible.value ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
819
- key: 0,
820
- to: floatingBoxBody.value,
821
- disabled: _ctx.slideType === "box"
822
- }, [
823
- vue.createVNode(vue.unref(form.MFormBox), {
824
- class: "m-editor-code-block-editor",
825
- ref_key: "fomDrawer",
826
- ref: fomDrawer,
827
- "label-width": "80px",
828
- "close-on-press-escape": false,
829
- title: _ctx.content.name,
830
- width: size.value,
831
- config: functionConfig.value,
832
- values: _ctx.content,
833
- disabled: _ctx.disabled,
834
- onChange: changeHandler,
835
- onSubmit: submitForm,
836
- onError: errorHandler,
837
- onOpen: openHandler,
838
- onClosed: closedHandler
960
+ }, 8, ["visible", "width", "height", "title", "position"]),
961
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
962
+ vue.createVNode(vue.unref(design.TMagicDialog), {
963
+ title: "查看修改",
964
+ modelValue: difVisible.value,
965
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
966
+ fullscreen: ""
839
967
  }, {
840
- left: vue.withCtx(() => [
841
- vue.createVNode(vue.unref(design.TMagicButton), {
842
- type: "primary",
843
- link: "",
844
- onClick: _cache[1] || (_cache[1] = ($event) => difVisible.value = true)
845
- }, {
846
- default: vue.withCtx(() => [
847
- vue.createTextVNode("查看修改")
848
- ]),
849
- _: 1
850
- })
851
- ]),
852
- _: 1
853
- }, 8, ["title", "width", "config", "values", "disabled"])
854
- ], 8, ["to", "disabled"])) : vue.createCommentVNode("", true),
855
- vue.createVNode(vue.unref(design.TMagicDialog), {
856
- modelValue: difVisible.value,
857
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => difVisible.value = $event),
858
- title: "查看修改",
859
- fullscreen: ""
860
- }, {
861
- footer: vue.withCtx(() => [
862
- vue.createElementVNode("span", _hoisted_4$7, [
863
- vue.createVNode(vue.unref(design.TMagicButton), {
864
- size: "small",
865
- onClick: _cache[2] || (_cache[2] = ($event) => difVisible.value = false)
866
- }, {
867
- default: vue.withCtx(() => [
868
- vue.createTextVNode("取消")
869
- ]),
870
- _: 1
871
- }),
872
- vue.createVNode(vue.unref(design.TMagicButton), {
873
- size: "small",
874
- type: "primary",
875
- onClick: diffChange
876
- }, {
877
- default: vue.withCtx(() => [
878
- vue.createTextVNode("确定")
879
- ]),
880
- _: 1
881
- })
882
- ])
883
- ]),
884
- default: vue.withCtx(() => [
885
- vue.createElementVNode("div", _hoisted_1$s, [
886
- vue.createElementVNode("div", _hoisted_2$k, [
887
- vue.createVNode(vue.unref(design.TMagicTag), {
968
+ footer: vue.withCtx(() => [
969
+ vue.createElementVNode("span", _hoisted_4$7, [
970
+ vue.createVNode(vue.unref(design.TMagicButton), {
888
971
  size: "small",
889
- type: "info"
972
+ onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
890
973
  }, {
891
974
  default: vue.withCtx(() => [
892
- vue.createTextVNode("修改前")
975
+ vue.createTextVNode("取消")
893
976
  ]),
894
977
  _: 1
895
- })
896
- ]),
897
- vue.createElementVNode("div", _hoisted_3$8, [
898
- vue.createVNode(vue.unref(design.TMagicTag), {
978
+ }),
979
+ vue.createVNode(vue.unref(design.TMagicButton), {
899
980
  size: "small",
900
- type: "success"
981
+ type: "primary",
982
+ onClick: diffChange
901
983
  }, {
902
984
  default: vue.withCtx(() => [
903
- vue.createTextVNode("修改后")
985
+ vue.createTextVNode("确定")
904
986
  ]),
905
987
  _: 1
906
988
  })
907
989
  ])
908
990
  ]),
909
- difVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
910
- key: 0,
911
- ref_key: "magicVsEditor",
912
- ref: magicVsEditor,
913
- type: "diff",
914
- language: "json",
915
- initValues: _ctx.content.content,
916
- modifiedValues: fomDrawer.value?.form?.values.content,
917
- style: vue.normalizeStyle(`height: ${height.value - 200}px`)
918
- }, null, 8, ["initValues", "modifiedValues", "style"])) : vue.createCommentVNode("", true)
919
- ]),
920
- _: 1
921
- }, 8, ["modelValue"])
991
+ default: vue.withCtx(() => [
992
+ vue.createElementVNode("div", _hoisted_1$r, [
993
+ vue.createElementVNode("div", _hoisted_2$k, [
994
+ vue.createVNode(vue.unref(design.TMagicTag), {
995
+ size: "small",
996
+ type: "info"
997
+ }, {
998
+ default: vue.withCtx(() => [
999
+ vue.createTextVNode("修改前")
1000
+ ]),
1001
+ _: 1
1002
+ })
1003
+ ]),
1004
+ vue.createElementVNode("div", _hoisted_3$8, [
1005
+ vue.createVNode(vue.unref(design.TMagicTag), {
1006
+ size: "small",
1007
+ type: "success"
1008
+ }, {
1009
+ default: vue.withCtx(() => [
1010
+ vue.createTextVNode("修改后")
1011
+ ]),
1012
+ _: 1
1013
+ })
1014
+ ])
1015
+ ]),
1016
+ difVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
1017
+ key: 0,
1018
+ ref_key: "magicVsEditor",
1019
+ ref: magicVsEditor,
1020
+ type: "diff",
1021
+ language: "json",
1022
+ initValues: _ctx.content.content,
1023
+ modifiedValues: formBox.value?.form?.values.content,
1024
+ style: vue.normalizeStyle(`height: ${vue.unref(windowRect).height - 150}px`)
1025
+ }, null, 8, ["initValues", "modifiedValues", "style"])) : vue.createCommentVNode("", true)
1026
+ ]),
1027
+ _: 1
1028
+ }, 8, ["modelValue"])
1029
+ ]))
922
1030
  ], 64);
923
1031
  };
924
1032
  }
@@ -3594,7 +3702,7 @@
3594
3702
  return newNode;
3595
3703
  };
3596
3704
 
3597
- const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
3705
+ const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
3598
3706
  ...{
3599
3707
  name: "MEditorCodeParams"
3600
3708
  },
@@ -3644,50 +3752,6 @@
3644
3752
  }
3645
3753
  });
3646
3754
 
3647
- const _hoisted_1$r = ["src"];
3648
- const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
3649
- ...{
3650
- name: "MEditorIcon"
3651
- },
3652
- __name: "Icon",
3653
- props: {
3654
- icon: {}
3655
- },
3656
- setup(__props) {
3657
- const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
3658
- return (_ctx, _cache) => {
3659
- return !_ctx.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
3660
- key: 0,
3661
- class: "magic-editor-icon"
3662
- }, {
3663
- default: vue.withCtx(() => [
3664
- vue.createVNode(vue.unref(iconsVue.Edit))
3665
- ]),
3666
- _: 1
3667
- })) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
3668
- key: 1,
3669
- class: "magic-editor-icon"
3670
- }, {
3671
- default: vue.withCtx(() => [
3672
- vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$r)
3673
- ]),
3674
- _: 1
3675
- })) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
3676
- key: 2,
3677
- class: vue.normalizeClass(["magic-editor-icon", _ctx.icon])
3678
- }, null, 2)) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
3679
- key: 3,
3680
- class: "magic-editor-icon"
3681
- }, {
3682
- default: vue.withCtx(() => [
3683
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(_ctx.icon))))
3684
- ]),
3685
- _: 1
3686
- }));
3687
- };
3688
- }
3689
- });
3690
-
3691
3755
  const useCodeBlockEdit = (codeBlockService) => {
3692
3756
  const codeConfig = vue.ref();
3693
3757
  const codeId = vue.ref();
@@ -3698,7 +3762,7 @@
3698
3762
  return;
3699
3763
  }
3700
3764
  codeConfig.value = {
3701
- name: "代码块",
3765
+ name: "",
3702
3766
  content: `({app, params}) => {
3703
3767
  // place your code here
3704
3768
  }`,
@@ -3834,14 +3898,14 @@
3834
3898
  size: _ctx.size,
3835
3899
  onChange: onParamsChangeHandler
3836
3900
  }, null, 8, ["model", "size"]),
3837
- _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
3901
+ _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
3838
3902
  key: 0,
3839
3903
  class: "icon",
3840
3904
  icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
3841
3905
  onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(editCode)(_ctx.model[_ctx.name]))
3842
3906
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
3843
3907
  ]),
3844
- paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
3908
+ paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
3845
3909
  name: "params",
3846
3910
  key: _ctx.model[_ctx.name],
3847
3911
  model: _ctx.model,
@@ -3849,7 +3913,7 @@
3849
3913
  "params-config": paramsConfig.value,
3850
3914
  onChange: onParamsChangeHandler
3851
3915
  }, null, 8, ["model", "size", "params-config"])) : vue.createCommentVNode("", true),
3852
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
3916
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
3853
3917
  key: 1,
3854
3918
  ref_key: "codeBlockEditor",
3855
3919
  ref: codeBlockEditor,
@@ -3862,37 +3926,381 @@
3862
3926
  }
3863
3927
  });
3864
3928
 
3865
- const _hoisted_1$p = { class: "m-editor-data-source-fields" };
3866
- const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
3867
- const _sfc_main$L = /* @__PURE__ */ vue.defineComponent({
3868
- ...{
3869
- name: "MFieldsDataSourceFields"
3870
- },
3871
- __name: "DataSourceFields",
3872
- props: {
3873
- config: {},
3874
- model: {},
3875
- initValues: {},
3876
- values: {},
3877
- name: {},
3878
- prop: {},
3879
- disabled: { type: Boolean, default: false },
3880
- size: {},
3881
- lastValues: {}
3882
- },
3883
- emits: ["change"],
3929
+ const useDataSourceMethod = () => {
3930
+ const codeConfig = vue.ref();
3931
+ const codeBlockEditor = vue.ref();
3932
+ const dataSource = vue.ref();
3933
+ const dataSourceMethod = vue.ref("");
3934
+ return {
3935
+ codeConfig,
3936
+ codeBlockEditor,
3937
+ createCode: async (model) => {
3938
+ codeConfig.value = {
3939
+ name: "",
3940
+ content: `({ params, dataSource, app }) => {
3941
+ // place your code here
3942
+ }`,
3943
+ params: []
3944
+ };
3945
+ await vue.nextTick();
3946
+ dataSource.value = model;
3947
+ dataSourceMethod.value = "";
3948
+ codeBlockEditor.value?.show();
3949
+ },
3950
+ editCode: async (model, methodName) => {
3951
+ const method = model.methods?.find((method2) => method2.name === methodName);
3952
+ if (!method) {
3953
+ design.tMagicMessage.error("获取数据源方法失败");
3954
+ return;
3955
+ }
3956
+ let codeContent = method.content;
3957
+ if (typeof codeContent !== "string") {
3958
+ codeContent = codeContent.toString();
3959
+ }
3960
+ codeConfig.value = {
3961
+ ...lodashEs.cloneDeep(method),
3962
+ content: codeContent
3963
+ };
3964
+ await vue.nextTick();
3965
+ dataSource.value = model;
3966
+ dataSourceMethod.value = methodName;
3967
+ codeBlockEditor.value?.show();
3968
+ },
3969
+ deleteCode: async (model, methodName) => {
3970
+ if (!model.methods)
3971
+ return;
3972
+ const index = model.methods.findIndex((method) => method.name === methodName);
3973
+ if (index === -1) {
3974
+ return;
3975
+ }
3976
+ model.methods.splice(index, 1);
3977
+ },
3978
+ submitCode: (values) => {
3979
+ if (!dataSource.value)
3980
+ return;
3981
+ if (!dataSource.value.methods) {
3982
+ dataSource.value.methods = [];
3983
+ }
3984
+ if (values.content) {
3985
+ const parseDSL = getConfig("parseDSL");
3986
+ if (typeof values.content === "string") {
3987
+ values.content = parseDSL(values.content);
3988
+ }
3989
+ }
3990
+ if (dataSourceMethod.value) {
3991
+ const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
3992
+ dataSource.value.methods.splice(index, 1, values);
3993
+ } else {
3994
+ dataSource.value.methods.push(values);
3995
+ }
3996
+ codeBlockEditor.value?.hide();
3997
+ }
3998
+ };
3999
+ };
4000
+
4001
+ const state = vue.reactive({
4002
+ uiSelectMode: false,
4003
+ showSrc: false,
4004
+ zoom: 1,
4005
+ stageContainerRect: {
4006
+ width: 0,
4007
+ height: 0
4008
+ },
4009
+ stageRect: {
4010
+ width: 375,
4011
+ height: 817
4012
+ },
4013
+ columnWidth: {
4014
+ left: 0,
4015
+ right: 0,
4016
+ center: 0
4017
+ },
4018
+ showGuides: true,
4019
+ showRule: true,
4020
+ propsPanelSize: "small",
4021
+ showAddPageButton: true,
4022
+ hideSlideBar: false,
4023
+ navMenuRect: {
4024
+ left: 0,
4025
+ top: 0,
4026
+ width: 0,
4027
+ height: 0
4028
+ },
4029
+ frameworkRect: {
4030
+ width: 0,
4031
+ height: 0,
4032
+ left: 0,
4033
+ top: 0
4034
+ }
4035
+ });
4036
+ const canUsePluginMethods$2 = {
4037
+ async: ["zoom", "calcZoom"],
4038
+ sync: []
4039
+ };
4040
+ class Ui extends BaseService {
4041
+ constructor() {
4042
+ super(canUsePluginMethods$2.async.map((methodName) => ({ name: methodName, isAsync: true })));
4043
+ }
4044
+ set(name, value) {
4045
+ const mask = editorService.get("stage")?.mask;
4046
+ if (name === "stageRect") {
4047
+ this.setStageRect(value);
4048
+ return;
4049
+ }
4050
+ if (name === "showGuides") {
4051
+ mask?.showGuides(value);
4052
+ }
4053
+ if (name === "showRule") {
4054
+ mask?.showRule(value);
4055
+ }
4056
+ state[name] = value;
4057
+ }
4058
+ get(name) {
4059
+ return state[name];
4060
+ }
4061
+ async zoom(zoom) {
4062
+ this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
4063
+ if (this.get("zoom") < 0.1)
4064
+ this.set("zoom", 0.1);
4065
+ }
4066
+ async calcZoom() {
4067
+ const { stageRect, stageContainerRect } = state;
4068
+ const { height, width } = stageContainerRect;
4069
+ if (!width || !height)
4070
+ return 1;
4071
+ let stageWidth = utils.convertToNumber(stageRect.width, width);
4072
+ let stageHeight = utils.convertToNumber(stageRect.height, height);
4073
+ stageWidth = stageWidth + 30;
4074
+ stageHeight = stageHeight + 30;
4075
+ if (width > stageWidth && height > stageHeight) {
4076
+ return 1;
4077
+ }
4078
+ return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
4079
+ }
4080
+ resetState() {
4081
+ this.set("showSrc", false);
4082
+ this.set("uiSelectMode", false);
4083
+ this.set("zoom", 1);
4084
+ this.set("stageContainerRect", {
4085
+ width: 0,
4086
+ height: 0
4087
+ });
4088
+ }
4089
+ destroy() {
4090
+ this.resetState();
4091
+ this.removeAllListeners();
4092
+ this.removeAllPlugins();
4093
+ }
4094
+ usePlugin(options) {
4095
+ super.usePlugin(options);
4096
+ }
4097
+ async setStageRect(value) {
4098
+ state.stageRect = {
4099
+ ...state.stageRect,
4100
+ ...value
4101
+ };
4102
+ state.zoom = await this.calcZoom();
4103
+ }
4104
+ }
4105
+ const uiService = new Ui();
4106
+
4107
+ const root = vue.computed(() => editorService.get("root"));
4108
+ const page = vue.computed(() => editorService.get("page"));
4109
+ const zoom = vue.computed(() => uiService.get("zoom") || 1);
4110
+ const uiSelectMode = vue.computed(() => uiService.get("uiSelectMode"));
4111
+ const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
4112
+ const useStage = (stageOptions) => {
4113
+ const stage = new StageCore({
4114
+ render: stageOptions.render,
4115
+ runtimeUrl: stageOptions.runtimeUrl,
4116
+ zoom: zoom.value,
4117
+ autoScrollIntoView: stageOptions.autoScrollIntoView,
4118
+ isContainer: stageOptions.isContainer,
4119
+ containerHighlightClassName: stageOptions.containerHighlightClassName,
4120
+ containerHighlightDuration: stageOptions.containerHighlightDuration,
4121
+ containerHighlightType: stageOptions.containerHighlightType,
4122
+ disabledDragStart: stageOptions.disabledDragStart,
4123
+ renderType: stageOptions.renderType,
4124
+ canSelect: (el, event, stop) => {
4125
+ if (!stageOptions.canSelect)
4126
+ return true;
4127
+ const elCanSelect = stageOptions.canSelect?.(el);
4128
+ if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
4129
+ document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
4130
+ return stop();
4131
+ }
4132
+ return elCanSelect;
4133
+ },
4134
+ moveableOptions: stageOptions.moveableOptions,
4135
+ updateDragEl: stageOptions.updateDragEl,
4136
+ guidesOptions: stageOptions.guidesOptions,
4137
+ disabledMultiSelect: stageOptions.disabledMultiSelect
4138
+ });
4139
+ vue.watch(
4140
+ () => editorService.get("disabledMultiSelect"),
4141
+ (disabledMultiSelect) => {
4142
+ if (disabledMultiSelect) {
4143
+ stage.disableMultiSelect();
4144
+ } else {
4145
+ stage.enableMultiSelect();
4146
+ }
4147
+ }
4148
+ );
4149
+ stage.mask.setGuides([
4150
+ getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
4151
+ getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
4152
+ ]);
4153
+ stage.on("page-el-update", () => {
4154
+ editorService.set("stageLoading", false);
4155
+ });
4156
+ stage.on("select", (el) => {
4157
+ if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
4158
+ return;
4159
+ editorService.select(el.id);
4160
+ });
4161
+ stage.on("highlight", (el) => {
4162
+ editorService.highlight(el.id);
4163
+ });
4164
+ stage.on("multi-select", (els) => {
4165
+ editorService.multiSelect(els.map((el) => el.id));
4166
+ });
4167
+ stage.on("update", (ev) => {
4168
+ if (ev.parentEl) {
4169
+ for (const data of ev.data) {
4170
+ editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
4171
+ }
4172
+ return;
4173
+ }
4174
+ editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
4175
+ });
4176
+ stage.on("sort", (ev) => {
4177
+ editorService.sort(ev.src, ev.dist);
4178
+ });
4179
+ stage.on("remove", (ev) => {
4180
+ const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
4181
+ editorService.remove(nodes.filter((node) => Boolean(node)));
4182
+ });
4183
+ stage.on("select-parent", () => {
4184
+ const parent = editorService.get("parent");
4185
+ if (!parent)
4186
+ throw new Error("父节点为空");
4187
+ editorService.select(parent);
4188
+ editorService.get("stage")?.select(parent.id);
4189
+ });
4190
+ stage.on("change-guides", (e) => {
4191
+ uiService.set("showGuides", true);
4192
+ if (!root.value || !page.value)
4193
+ return;
4194
+ const storageKey = getGuideLineKey(
4195
+ e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
4196
+ );
4197
+ if (e.guides.length) {
4198
+ globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
4199
+ } else {
4200
+ globalThis.localStorage.removeItem(storageKey);
4201
+ }
4202
+ });
4203
+ return stage;
4204
+ };
4205
+
4206
+ const useFloatBox = (slideKeys) => {
4207
+ const services = vue.inject("services");
4208
+ const floatBoxStates = vue.ref(
4209
+ slideKeys.value.reduce(
4210
+ (total, cur) => ({
4211
+ ...total,
4212
+ [cur]: {
4213
+ status: false,
4214
+ top: 0,
4215
+ left: 0
4216
+ }
4217
+ }),
4218
+ {}
4219
+ )
4220
+ );
4221
+ const showingBoxKeys = vue.computed(
4222
+ () => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
4223
+ );
4224
+ const isDragging = vue.ref(false);
4225
+ const dragstartHandler = () => isDragging.value = true;
4226
+ const dragendHandler = (key, e) => {
4227
+ const navMenuRect = services?.uiService?.get("navMenuRect");
4228
+ floatBoxStates.value[key] = {
4229
+ left: e.clientX,
4230
+ top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0),
4231
+ status: true
4232
+ };
4233
+ isDragging.value = false;
4234
+ };
4235
+ document.body.addEventListener("dragover", (e) => {
4236
+ if (!isDragging.value)
4237
+ return;
4238
+ e.preventDefault();
4239
+ });
4240
+ vue.watch(
4241
+ () => slideKeys.value,
4242
+ (slideKeys2) => {
4243
+ slideKeys2.forEach((key) => {
4244
+ if (!floatBoxStates.value[key]) {
4245
+ floatBoxStates.value[key] = {
4246
+ status: false,
4247
+ top: 0,
4248
+ left: 0
4249
+ };
4250
+ }
4251
+ });
4252
+ },
4253
+ {
4254
+ deep: true,
4255
+ immediate: true
4256
+ }
4257
+ );
4258
+ return {
4259
+ dragstartHandler,
4260
+ dragendHandler,
4261
+ floatBoxStates,
4262
+ showingBoxKeys
4263
+ };
4264
+ };
4265
+
4266
+ const _hoisted_1$p = { class: "m-editor-data-source-fields" };
4267
+ const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
4268
+ const _sfc_main$L = /* @__PURE__ */ vue.defineComponent({
4269
+ ...{
4270
+ name: "MFieldsDataSourceFields"
4271
+ },
4272
+ __name: "DataSourceFields",
4273
+ props: /* @__PURE__ */ vue.mergeModels({
4274
+ config: {},
4275
+ model: {},
4276
+ initValues: {},
4277
+ values: {},
4278
+ name: {},
4279
+ prop: {},
4280
+ disabled: { type: Boolean, default: false },
4281
+ size: {},
4282
+ lastValues: {}
4283
+ }, {
4284
+ "width": { default: 670 },
4285
+ "widthModifiers": {},
4286
+ "visible": { type: Boolean, ...{ default: false } },
4287
+ "visibleModifiers": {},
4288
+ "visible1": { type: Boolean, ...{ default: false } },
4289
+ "visible1Modifiers": {}
4290
+ }),
4291
+ emits: /* @__PURE__ */ vue.mergeModels(["change"], ["update:width", "update:visible", "update:visible1"]),
3884
4292
  setup(__props, { emit: __emit }) {
3885
4293
  const props = __props;
3886
4294
  const emit = __emit;
3887
4295
  const services = vue.inject("services");
3888
- const addDialog = vue.ref();
3889
4296
  const fieldValues = vue.ref({});
3890
4297
  const fieldTitle = vue.ref("");
3891
- const width = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
4298
+ const width = vue.useModel(__props, "width");
3892
4299
  const newHandler = () => {
3893
4300
  fieldValues.value = {};
3894
4301
  fieldTitle.value = "新增属性";
3895
- addDialog.value?.show();
4302
+ calcBoxPosition();
4303
+ addDialogVisible.value = true;
3896
4304
  };
3897
4305
  const fieldChange = ({ index, ...value }) => {
3898
4306
  if (index > -1) {
@@ -3900,7 +4308,7 @@
3900
4308
  } else {
3901
4309
  props.model[props.name].push(value);
3902
4310
  }
3903
- addDialog.value?.hide();
4311
+ addDialogVisible.value = false;
3904
4312
  emit("change", props.model[props.name]);
3905
4313
  };
3906
4314
  const fieldColumns = [
@@ -3939,7 +4347,8 @@
3939
4347
  index
3940
4348
  };
3941
4349
  fieldTitle.value = `编辑${row.title}`;
3942
- addDialog.value?.show();
4350
+ calcBoxPosition();
4351
+ addDialogVisible.value = true;
3943
4352
  }
3944
4353
  },
3945
4354
  {
@@ -4037,7 +4446,6 @@
4037
4446
  display: (formState, { model }) => model.type === "object" || model.type === "array"
4038
4447
  }
4039
4448
  ];
4040
- const addFromJsonDialog = vue.ref();
4041
4449
  const jsonFromConfig = [
4042
4450
  {
4043
4451
  name: "data",
@@ -4053,7 +4461,8 @@
4053
4461
  });
4054
4462
  const newFromJsonHandler = () => {
4055
4463
  jsonFromValues.value.data = utils.getDefaultValueFromFields(props.model[props.name]);
4056
- addFromJsonDialog.value?.show();
4464
+ calcBoxPosition();
4465
+ addFromJsonDialogVisible.value = true;
4057
4466
  };
4058
4467
  const getValueType = (value) => {
4059
4468
  if (Array.isArray(value))
@@ -4099,12 +4508,17 @@
4099
4508
  try {
4100
4509
  const value = JSON.parse(data);
4101
4510
  props.model[props.name] = getFieldsConfig(value, props.model[props.name]);
4102
- addFromJsonDialog.value?.hide();
4511
+ addFromJsonDialogVisible.value = false;
4103
4512
  emit("change", props.model[props.name]);
4104
4513
  } catch (e) {
4105
4514
  design.tMagicMessage.error(e.message);
4106
4515
  }
4107
4516
  };
4517
+ const addDialogVisible = vue.useModel(__props, "visible");
4518
+ const addFromJsonDialogVisible = vue.useModel(__props, "visible1");
4519
+ const { height: editorHeight } = useEditorContentHeight();
4520
+ const parentFloating = vue.inject("parentFloating", vue.ref(null));
4521
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4108
4522
  return (_ctx, _cache) => {
4109
4523
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$p, [
4110
4524
  vue.createVNode(vue.unref(table.MagicTable), {
@@ -4136,28 +4550,49 @@
4136
4550
  _: 1
4137
4551
  }, 8, ["disabled"])
4138
4552
  ]),
4139
- vue.createVNode(vue.unref(form.MFormDrawer), {
4140
- ref_key: "addDialog",
4141
- ref: addDialog,
4142
- "label-width": "80px",
4553
+ vue.createVNode(_sfc_main$P, {
4554
+ visible: addDialogVisible.value,
4555
+ "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
4556
+ width: width.value,
4557
+ "onUpdate:width": _cache[3] || (_cache[3] = ($event) => width.value = $event),
4558
+ height: vue.unref(editorHeight),
4559
+ "onUpdate:height": _cache[4] || (_cache[4] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
4143
4560
  title: fieldTitle.value,
4144
- config: dataSourceFieldsConfig,
4145
- values: fieldValues.value,
4146
- parentValues: _ctx.model[_ctx.name],
4147
- disabled: _ctx.disabled,
4561
+ position: vue.unref(boxPosition)
4562
+ }, {
4563
+ body: vue.withCtx(() => [
4564
+ vue.createVNode(vue.unref(form.MFormBox), {
4565
+ "label-width": "80px",
4566
+ title: fieldTitle.value,
4567
+ config: dataSourceFieldsConfig,
4568
+ values: fieldValues.value,
4569
+ parentValues: _ctx.model[_ctx.name],
4570
+ disabled: _ctx.disabled,
4571
+ onSubmit: fieldChange
4572
+ }, null, 8, ["title", "values", "parentValues", "disabled"])
4573
+ ]),
4574
+ _: 1
4575
+ }, 8, ["visible", "width", "height", "title", "position"]),
4576
+ vue.createVNode(_sfc_main$P, {
4577
+ visible: addFromJsonDialogVisible.value,
4578
+ "onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
4148
4579
  width: width.value,
4149
- onSubmit: fieldChange
4150
- }, null, 8, ["title", "values", "parentValues", "disabled", "width"]),
4151
- vue.createVNode(vue.unref(form.MFormDrawer), {
4152
- ref_key: "addFromJsonDialog",
4153
- ref: addFromJsonDialog,
4580
+ "onUpdate:width": _cache[6] || (_cache[6] = ($event) => width.value = $event),
4581
+ height: vue.unref(editorHeight),
4582
+ "onUpdate:height": _cache[7] || (_cache[7] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
4154
4583
  title: "快速添加数据定义",
4155
- config: jsonFromConfig,
4156
- values: jsonFromValues.value,
4157
- disabled: _ctx.disabled,
4158
- width: width.value,
4159
- onSubmit: addFromJsonFromChange
4160
- }, null, 8, ["values", "disabled", "width"])
4584
+ position: vue.unref(boxPosition)
4585
+ }, {
4586
+ body: vue.withCtx(() => [
4587
+ vue.createVNode(vue.unref(form.MFormBox), {
4588
+ config: jsonFromConfig,
4589
+ values: jsonFromValues.value,
4590
+ disabled: _ctx.disabled,
4591
+ onSubmit: addFromJsonFromChange
4592
+ }, null, 8, ["values", "disabled"])
4593
+ ]),
4594
+ _: 1
4595
+ }, 8, ["visible", "width", "height", "position"])
4161
4596
  ]);
4162
4597
  };
4163
4598
  }
@@ -4282,10 +4717,14 @@
4282
4717
  style: { "margin-left": "5px" },
4283
4718
  link: "",
4284
4719
  type: showDataSourceFieldSelect.value ? "primary" : "default",
4285
- icon: vue.unref(iconsVue.Coin),
4286
4720
  size: _ctx.size,
4287
4721
  onClick: _cache[0] || (_cache[0] = ($event) => showDataSourceFieldSelect.value = !showDataSourceFieldSelect.value)
4288
- }, null, 8, ["type", "icon", "size"])) : vue.createCommentVNode("", true)
4722
+ }, {
4723
+ default: vue.withCtx(() => [
4724
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
4725
+ ]),
4726
+ _: 1
4727
+ }, 8, ["type", "size"])) : vue.createCommentVNode("", true)
4289
4728
  ]);
4290
4729
  };
4291
4730
  }
@@ -4293,7 +4732,7 @@
4293
4732
 
4294
4733
  const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4295
4734
  const _hoisted_2$h = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4296
- const _hoisted_3$7 = { class: "el-input__inner" };
4735
+ const _hoisted_3$7 = { class: "el-input__inner t-input__inner" };
4297
4736
  const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
4298
4737
  ...{
4299
4738
  name: "MFieldsDataSourceInput"
@@ -4484,7 +4923,7 @@
4484
4923
  }
4485
4924
  ), {
4486
4925
  suffix: vue.withCtx(() => [
4487
- vue.createVNode(_sfc_main$N, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
4926
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
4488
4927
  ]),
4489
4928
  default: vue.withCtx(({ item }) => [
4490
4929
  vue.createElementVNode("div", _hoisted_1$n, [
@@ -4495,7 +4934,7 @@
4495
4934
  _: 1
4496
4935
  }, 16, ["modelValue"])) : (vue.openBlock(), vue.createElementBlock("div", {
4497
4936
  key: 1,
4498
- class: vue.normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
4937
+ class: vue.normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
4499
4938
  onMouseup: mouseupHandler
4500
4939
  }, [
4501
4940
  vue.createElementVNode("div", {
@@ -4519,7 +4958,7 @@
4519
4958
  }, 1032, ["size"])) : vue.createCommentVNode("", true)
4520
4959
  ], 64);
4521
4960
  }), 256)),
4522
- vue.createVNode(_sfc_main$N, {
4961
+ vue.createVNode(_sfc_main$U, {
4523
4962
  class: "tmagic-data-source-input-icon",
4524
4963
  icon: vue.unref(iconsVue.Coin)
4525
4964
  }, null, 8, ["icon"])
@@ -4530,78 +4969,6 @@
4530
4969
  }
4531
4970
  });
4532
4971
 
4533
- const useDataSourceMethod = () => {
4534
- const codeConfig = vue.ref();
4535
- const codeBlockEditor = vue.ref();
4536
- const dataSource = vue.ref();
4537
- const dataSourceMethod = vue.ref("");
4538
- return {
4539
- codeConfig,
4540
- codeBlockEditor,
4541
- createCode: async (model) => {
4542
- codeConfig.value = {
4543
- name: "",
4544
- content: `({ params, dataSource, app }) => {
4545
- // place your code here
4546
- }`,
4547
- params: []
4548
- };
4549
- await vue.nextTick();
4550
- dataSource.value = model;
4551
- dataSourceMethod.value = "";
4552
- codeBlockEditor.value?.show();
4553
- },
4554
- editCode: async (model, methodName) => {
4555
- const method = model.methods?.find((method2) => method2.name === methodName);
4556
- if (!method) {
4557
- design.tMagicMessage.error("获取数据源方法失败");
4558
- return;
4559
- }
4560
- let codeContent = method.content;
4561
- if (typeof codeContent !== "string") {
4562
- codeContent = codeContent.toString();
4563
- }
4564
- codeConfig.value = {
4565
- ...lodashEs.cloneDeep(method),
4566
- content: codeContent
4567
- };
4568
- await vue.nextTick();
4569
- dataSource.value = model;
4570
- dataSourceMethod.value = methodName;
4571
- codeBlockEditor.value?.show();
4572
- },
4573
- deleteCode: async (model, methodName) => {
4574
- if (!model.methods)
4575
- return;
4576
- const index = model.methods.findIndex((method) => method.name === methodName);
4577
- if (index === -1) {
4578
- return;
4579
- }
4580
- model.methods.splice(index, 1);
4581
- },
4582
- submitCode: (values) => {
4583
- if (!dataSource.value)
4584
- return;
4585
- if (!dataSource.value.methods) {
4586
- dataSource.value.methods = [];
4587
- }
4588
- if (values.content) {
4589
- const parseDSL = getConfig("parseDSL");
4590
- if (typeof values.content === "string") {
4591
- values.content = parseDSL(values.content);
4592
- }
4593
- }
4594
- if (dataSourceMethod.value) {
4595
- const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
4596
- dataSource.value.methods.splice(index, 1, values);
4597
- } else {
4598
- dataSource.value.methods.push(values);
4599
- }
4600
- codeBlockEditor.value?.hide();
4601
- }
4602
- };
4603
- };
4604
-
4605
4972
  const _hoisted_1$m = { class: "m-editor-data-source-methods" };
4606
4973
  const _hoisted_2$g = { class: "m-editor-data-source-methods-footer" };
4607
4974
  const _sfc_main$I = /* @__PURE__ */ vue.defineComponent({
@@ -4693,7 +5060,7 @@
4693
5060
  _: 1
4694
5061
  }, 8, ["disabled"])
4695
5062
  ]),
4696
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
5063
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
4697
5064
  key: 0,
4698
5065
  ref_key: "codeBlockEditor",
4699
5066
  ref: codeBlockEditor,
@@ -4809,14 +5176,14 @@
4809
5176
  model: _ctx.model,
4810
5177
  onChange: onChangeHandler
4811
5178
  }, null, 8, ["config", "model"]),
4812
- _ctx.model[_ctx.name] && isCustomMethod.value ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
5179
+ _ctx.model[_ctx.name] && isCustomMethod.value ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
4813
5180
  key: 0,
4814
5181
  class: "icon",
4815
5182
  icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
4816
5183
  onClick: editCodeHandler
4817
5184
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
4818
5185
  ]),
4819
- paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
5186
+ paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
4820
5187
  key: 0,
4821
5188
  name: "params",
4822
5189
  model: _ctx.model,
@@ -4825,7 +5192,7 @@
4825
5192
  "params-config": paramsConfig.value,
4826
5193
  onChange: onChangeHandler
4827
5194
  }, null, 8, ["model", "size", "disabled", "params-config"])) : vue.createCommentVNode("", true),
4828
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
5195
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
4829
5196
  key: 1,
4830
5197
  ref_key: "codeBlockEditor",
4831
5198
  ref: codeBlockEditor,
@@ -4845,7 +5212,7 @@
4845
5212
  name: "MFieldsDataSourceMocks"
4846
5213
  },
4847
5214
  __name: "DataSourceMocks",
4848
- props: {
5215
+ props: /* @__PURE__ */ vue.mergeModels({
4849
5216
  config: {},
4850
5217
  model: {},
4851
5218
  initValues: {},
@@ -4855,14 +5222,18 @@
4855
5222
  disabled: { type: Boolean, default: false },
4856
5223
  size: {},
4857
5224
  lastValues: {}
4858
- },
4859
- emits: ["change"],
5225
+ }, {
5226
+ "width": { default: 670 },
5227
+ "widthModifiers": {},
5228
+ "visible": { type: Boolean, ...{ default: false } },
5229
+ "visibleModifiers": {}
5230
+ }),
5231
+ emits: /* @__PURE__ */ vue.mergeModels(["change"], ["update:width", "update:visible"]),
4860
5232
  setup(__props, { emit: __emit }) {
4861
5233
  const props = __props;
4862
5234
  const emit = __emit;
4863
5235
  const services = vue.inject("services");
4864
- const width = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
4865
- const addDialog = vue.ref();
5236
+ const width = vue.useModel(__props, "width");
4866
5237
  const drawerTitle = vue.ref("");
4867
5238
  const formValues = vue.ref({});
4868
5239
  const formConfig = [
@@ -4927,7 +5298,7 @@
4927
5298
  const columns = [
4928
5299
  {
4929
5300
  type: "expand",
4930
- component: _sfc_main$U,
5301
+ component: _sfc_main$T,
4931
5302
  props: (row) => ({
4932
5303
  initValues: row.data,
4933
5304
  language: "json",
@@ -4989,7 +5360,8 @@
4989
5360
  index
4990
5361
  };
4991
5362
  drawerTitle.value = `编辑${row.title}`;
4992
- addDialog.value?.show();
5363
+ calcBoxPosition();
5364
+ addDialogVisible.value = true;
4993
5365
  }
4994
5366
  },
4995
5367
  {
@@ -5012,7 +5384,8 @@
5012
5384
  enable: isFirstRow
5013
5385
  };
5014
5386
  drawerTitle.value = "新增Mock";
5015
- addDialog.value?.show();
5387
+ calcBoxPosition();
5388
+ addDialogVisible.value = true;
5016
5389
  };
5017
5390
  const formChangeHandler = ({ index, ...value }) => {
5018
5391
  if (index > -1) {
@@ -5020,7 +5393,7 @@
5020
5393
  } else {
5021
5394
  props.model[props.name].push(value);
5022
5395
  }
5023
- addDialog.value?.hide();
5396
+ addDialogVisible.value = false;
5024
5397
  emit("change", props.model[props.name]);
5025
5398
  };
5026
5399
  const toggleValue = (row, key, value, index) => {
@@ -5035,6 +5408,10 @@
5035
5408
  index
5036
5409
  });
5037
5410
  };
5411
+ const addDialogVisible = vue.useModel(__props, "visible");
5412
+ const { height: editorHeight } = useEditorContentHeight();
5413
+ const parentFloating = vue.inject("parentFloating", vue.ref(null));
5414
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
5038
5415
  return (_ctx, _cache) => {
5039
5416
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, [
5040
5417
  vue.createVNode(vue.unref(table.MagicTable), {
@@ -5055,18 +5432,29 @@
5055
5432
  _: 1
5056
5433
  }, 8, ["disabled"])
5057
5434
  ]),
5058
- vue.createVNode(vue.unref(form.MFormDrawer), {
5059
- ref_key: "addDialog",
5060
- ref: addDialog,
5061
- "label-width": "120px",
5062
- title: drawerTitle.value,
5063
- config: formConfig,
5064
- values: formValues.value,
5065
- parentValues: _ctx.model[_ctx.name],
5066
- disabled: _ctx.disabled,
5435
+ vue.createVNode(_sfc_main$P, {
5436
+ visible: addDialogVisible.value,
5437
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
5067
5438
  width: width.value,
5068
- onSubmit: formChangeHandler
5069
- }, null, 8, ["title", "values", "parentValues", "disabled", "width"])
5439
+ "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
5440
+ height: vue.unref(editorHeight),
5441
+ "onUpdate:height": _cache[3] || (_cache[3] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
5442
+ title: drawerTitle.value,
5443
+ position: vue.unref(boxPosition)
5444
+ }, {
5445
+ body: vue.withCtx(() => [
5446
+ vue.createVNode(vue.unref(form.MFormBox), {
5447
+ ref: "addDialog",
5448
+ "label-width": "120px",
5449
+ config: formConfig,
5450
+ values: formValues.value,
5451
+ parentValues: _ctx.model[_ctx.name],
5452
+ disabled: _ctx.disabled,
5453
+ onSubmit: formChangeHandler
5454
+ }, null, 8, ["values", "parentValues", "disabled"])
5455
+ ]),
5456
+ _: 1
5457
+ }, 8, ["visible", "width", "height", "title", "position"])
5070
5458
  ]);
5071
5459
  };
5072
5460
  }
@@ -5531,7 +5919,7 @@
5531
5919
  _: 1
5532
5920
  }, 8, ["size", "disabled", "icon"])
5533
5921
  ])) : vue.createCommentVNode("", true),
5534
- _ctx.config.advanced && showCode.value ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
5922
+ _ctx.config.advanced && showCode.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
5535
5923
  key: 1,
5536
5924
  height: "200px",
5537
5925
  "init-values": _ctx.model[_ctx.name],
@@ -5612,7 +6000,7 @@
5612
6000
  size: _ctx.size,
5613
6001
  onChange: changeHandler
5614
6002
  }, null, 8, ["model", "size"]),
5615
- _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
6003
+ _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
5616
6004
  key: 0,
5617
6005
  class: "icon",
5618
6006
  icon: vue.unref(iconsVue.Edit),
@@ -5845,6 +6233,7 @@
5845
6233
  },
5846
6234
  __name: "SplitView",
5847
6235
  props: {
6236
+ width: {},
5848
6237
  left: {},
5849
6238
  right: {},
5850
6239
  minLeft: { default: 46 },
@@ -5861,17 +6250,19 @@
5861
6250
  const el = vue.ref();
5862
6251
  const hasLeft = vue.computed(() => typeof props.left !== "undefined");
5863
6252
  const hasRight = vue.computed(() => typeof props.right !== "undefined");
5864
- const getCenterWidth = (clientWidth2, l = 0, r = 0) => {
6253
+ const center = vue.ref(0);
6254
+ let clientWidth = 0;
6255
+ const getCenterWidth = (l = 0, r = 0) => {
5865
6256
  let right = r > 0 ? r : 0;
5866
6257
  let left = l > 0 ? l : 0;
5867
- let center2 = clientWidth2 - left - right;
6258
+ let center2 = clientWidth - left - right;
5868
6259
  if (center2 < props.minCenter) {
5869
6260
  center2 = props.minCenter;
5870
6261
  if (right > center2 + props.minRight) {
5871
- right = clientWidth2 - left - center2;
6262
+ right = clientWidth - left - center2;
5872
6263
  } else {
5873
6264
  right = props.minRight;
5874
- left = clientWidth2 - right - center2;
6265
+ left = clientWidth - right - center2;
5875
6266
  }
5876
6267
  }
5877
6268
  return {
@@ -5880,36 +6271,43 @@
5880
6271
  right
5881
6272
  };
5882
6273
  };
5883
- let clientWidth = 0;
5884
- const resizerObserver = new ResizeObserver((entries) => {
5885
- for (const { contentRect } of entries) {
5886
- clientWidth = contentRect.width;
5887
- let left = props.left || 0;
5888
- let right = props.right || 0;
5889
- if (left > clientWidth) {
5890
- left = clientWidth / 3;
5891
- }
5892
- if (right > clientWidth) {
5893
- right = clientWidth / 3;
5894
- }
5895
- const columnWidth = getCenterWidth(clientWidth, left, right);
5896
- center.value = columnWidth.center;
5897
- emit("change", {
5898
- left: columnWidth.left,
5899
- center: center.value,
5900
- right: columnWidth.right
5901
- });
6274
+ const widthChange = (width) => {
6275
+ if (width <= 0) {
6276
+ return;
5902
6277
  }
5903
- });
5904
- vue.onMounted(() => {
5905
- if (el.value) {
5906
- resizerObserver.observe(el.value);
6278
+ clientWidth = width;
6279
+ let left = props.left || 0;
6280
+ let right = props.right || 0;
6281
+ if (left > clientWidth) {
6282
+ left = clientWidth / 3;
5907
6283
  }
5908
- });
5909
- vue.onBeforeUnmount(() => {
5910
- resizerObserver.disconnect();
5911
- });
5912
- const center = vue.ref(0);
6284
+ if (right > clientWidth) {
6285
+ right = clientWidth / 3;
6286
+ }
6287
+ const columnWidth = getCenterWidth(left, right);
6288
+ center.value = columnWidth.center;
6289
+ emit("change", columnWidth);
6290
+ };
6291
+ if (typeof props.width !== "number") {
6292
+ const resizerObserver = new ResizeObserver((entries) => {
6293
+ for (const { contentRect } of entries) {
6294
+ widthChange(contentRect.width);
6295
+ }
6296
+ });
6297
+ vue.onMounted(() => {
6298
+ if (el.value) {
6299
+ resizerObserver.observe(el.value);
6300
+ }
6301
+ });
6302
+ vue.onBeforeUnmount(() => {
6303
+ resizerObserver.disconnect();
6304
+ });
6305
+ } else {
6306
+ vue.watchEffect(() => {
6307
+ if (typeof props.width === "number")
6308
+ widthChange(props.width);
6309
+ });
6310
+ }
5913
6311
  const changeLeft = ({ deltaX }) => {
5914
6312
  if (typeof props.left === "undefined")
5915
6313
  return;
@@ -5918,7 +6316,7 @@
5918
6316
  if (clientWidth - left - (props.right || 0) <= 0) {
5919
6317
  left = props.left;
5920
6318
  }
5921
- const columnWidth = getCenterWidth(clientWidth, left, props.right || 0);
6319
+ const columnWidth = getCenterWidth(left, props.right || 0);
5922
6320
  center.value = columnWidth.center;
5923
6321
  emit("change", {
5924
6322
  left: columnWidth.left,
@@ -5934,7 +6332,7 @@
5934
6332
  if (clientWidth - (props.left || 0) - right <= 0) {
5935
6333
  right = props.right;
5936
6334
  }
5937
- const columnWidth = getCenterWidth(clientWidth, props.left, right);
6335
+ const columnWidth = getCenterWidth(props.left, right);
5938
6336
  center.value = columnWidth.center;
5939
6337
  emit("change", {
5940
6338
  left: columnWidth.left,
@@ -5944,7 +6342,8 @@
5944
6342
  };
5945
6343
  __expose({
5946
6344
  updateWidth() {
5947
- const columnWidth = getCenterWidth(el.value?.clientWidth || clientWidth, props.left, props.right);
6345
+ clientWidth = props.width ?? el.value?.clientWidth ?? clientWidth;
6346
+ const columnWidth = getCenterWidth(props.left, props.right);
5948
6347
  emit("change", {
5949
6348
  left: columnWidth.left,
5950
6349
  center: center.value,
@@ -6086,7 +6485,7 @@
6086
6485
  disabled: disabled.value
6087
6486
  }, {
6088
6487
  default: vue.withCtx(() => [
6089
- _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
6488
+ _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
6090
6489
  key: 0,
6091
6490
  icon: _ctx.data.icon
6092
6491
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -6104,7 +6503,7 @@
6104
6503
  title: _ctx.data.text
6105
6504
  }, {
6106
6505
  default: vue.withCtx(() => [
6107
- _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
6506
+ _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
6108
6507
  key: 0,
6109
6508
  icon: _ctx.data.icon
6110
6509
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -6192,7 +6591,7 @@
6192
6591
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
6193
6592
  onClick: addPage
6194
6593
  }, [
6195
- vue.createVNode(_sfc_main$N, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
6594
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
6196
6595
  ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d));
6197
6596
  };
6198
6597
  }
@@ -6304,7 +6703,7 @@
6304
6703
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
6305
6704
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
6306
6705
  }, [
6307
- vue.createVNode(_sfc_main$N, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
6706
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
6308
6707
  ])) : vue.createCommentVNode("", true),
6309
6708
  _ctx.type === vue.unref(schema.NodeType).PAGE && pageLength.value || _ctx.type === vue.unref(schema.NodeType).PAGE_FRAGMENT && pageFragmentLength.value ? (vue.openBlock(), vue.createElementBlock("div", {
6310
6709
  key: 1,
@@ -6320,7 +6719,7 @@
6320
6719
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
6321
6720
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
6322
6721
  }, [
6323
- vue.createVNode(_sfc_main$N, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
6722
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
6324
6723
  ])) : vue.createCommentVNode("", true)
6325
6724
  ], 512);
6326
6725
  };
@@ -6560,7 +6959,7 @@
6560
6959
  onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(vue.unref(schema.NodeType).PAGE))
6561
6960
  }, [
6562
6961
  vue.createElementVNode("div", null, [
6563
- vue.createVNode(_sfc_main$N, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
6962
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
6564
6963
  ]),
6565
6964
  _hoisted_3$4
6566
6965
  ]),
@@ -6570,7 +6969,7 @@
6570
6969
  onClick: _cache[1] || (_cache[1] = ($event) => clickHandler(vue.unref(schema.NodeType).PAGE_FRAGMENT))
6571
6970
  }, [
6572
6971
  vue.createElementVNode("div", null, [
6573
- vue.createVNode(_sfc_main$N, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
6972
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
6574
6973
  ]),
6575
6974
  _hoisted_4$4
6576
6975
  ])) : vue.createCommentVNode("", true)
@@ -6603,36 +7002,14 @@
6603
7002
  const stageLoading = vue.computed(() => editorService?.get("stageLoading") || false);
6604
7003
  const showSrc = vue.computed(() => uiService?.get("showSrc"));
6605
7004
  const getLeftColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
6606
- const leftColumnWidthCacheData = getLeftColumnWidthCacheData();
6607
- const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
6608
7005
  const columnWidth = vue.ref({
6609
- left: leftColumnWidthCacheData,
7006
+ left: getLeftColumnWidthCacheData(),
6610
7007
  center: 0,
6611
- right: RightColumnWidthCacheData
7008
+ right: Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH
7009
+ });
7010
+ vue.watch(pageLength, () => {
7011
+ splitView.value?.updateWidth();
6612
7012
  });
6613
- vue.watch(
6614
- [pageLength, splitView],
6615
- () => {
6616
- splitView.value?.updateWidth();
6617
- },
6618
- {
6619
- immediate: true
6620
- }
6621
- );
6622
- vue.watch(
6623
- () => columnWidth.value.right,
6624
- (right) => {
6625
- if (typeof right === "undefined")
6626
- return;
6627
- globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
6628
- }
6629
- );
6630
- vue.watch(
6631
- () => columnWidth.value.left,
6632
- (left) => {
6633
- globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
6634
- }
6635
- );
6636
7013
  vue.watch(
6637
7014
  () => uiService?.get("hideSlideBar"),
6638
7015
  (hideSlideBar) => {
@@ -6640,11 +7017,29 @@
6640
7017
  }
6641
7018
  );
6642
7019
  const columnWidthChange = (columnW) => {
6643
- columnWidth.value.left = columnW.left;
6644
- columnWidth.value.center = columnW.center;
6645
- columnWidth.value.right = columnW.right;
7020
+ columnWidth.value = columnW;
7021
+ globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.left}`);
7022
+ globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.right}`);
6646
7023
  uiService?.set("columnWidth", columnW);
6647
7024
  };
7025
+ const frameworkRect = vue.computed(() => uiService?.get("frameworkRect"));
7026
+ const resizerObserver = new ResizeObserver((entries) => {
7027
+ const { contentRect } = entries[0];
7028
+ uiService?.set("frameworkRect", {
7029
+ width: contentRect.width,
7030
+ height: contentRect.height,
7031
+ left: contentRect.left,
7032
+ top: contentRect.top
7033
+ });
7034
+ });
7035
+ vue.onMounted(() => {
7036
+ if (content.value) {
7037
+ resizerObserver.observe(content.value);
7038
+ }
7039
+ });
7040
+ vue.onBeforeUnmount(() => {
7041
+ resizerObserver.disconnect();
7042
+ });
6648
7043
  const saveCode = (value) => {
6649
7044
  try {
6650
7045
  const parseDSL = getConfig("parseDSL");
@@ -6665,7 +7060,7 @@
6665
7060
  vue.renderSlot(_ctx.$slots, "nav"),
6666
7061
  vue.renderSlot(_ctx.$slots, "content-before"),
6667
7062
  showSrc.value ? vue.renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
6668
- vue.createVNode(_sfc_main$U, {
7063
+ vue.createVNode(_sfc_main$T, {
6669
7064
  class: "m-editor-content",
6670
7065
  "init-values": root.value,
6671
7066
  options: vue.unref(codeOptions),
@@ -6687,6 +7082,7 @@
6687
7082
  "min-left": 65,
6688
7083
  "min-right": 20,
6689
7084
  "min-center": 100,
7085
+ width: frameworkRect.value?.width || 0,
6690
7086
  onChange: columnWidthChange
6691
7087
  }, vue.createSlots({
6692
7088
  left: vue.withCtx(() => [
@@ -6722,7 +7118,7 @@
6722
7118
  ]),
6723
7119
  key: "0"
6724
7120
  } : void 0
6725
- ]), 1032, ["left", "right"])), [
7121
+ ]), 1032, ["left", "right", "width"])), [
6726
7122
  [_directive_loading, stageLoading.value]
6727
7123
  ]),
6728
7124
  vue.renderSlot(_ctx.$slots, "content-after"),
@@ -6937,7 +7333,9 @@
6937
7333
  },
6938
7334
  emits: ["mounted", "submit-error", "form-error"],
6939
7335
  setup(__props, { expose: __expose, emit: __emit }) {
7336
+ const codeOptions = vue.inject("codeOptions", {});
6940
7337
  const emit = __emit;
7338
+ const showSrc = vue.ref(false);
6941
7339
  const internalInstance = vue.getCurrentInstance();
6942
7340
  const values = vue.ref({});
6943
7341
  const configForm = vue.ref();
@@ -6947,6 +7345,7 @@
6947
7345
  const nodes = vue.computed(() => services?.editorService.get("nodes") || []);
6948
7346
  const propsPanelSize = vue.computed(() => services?.uiService.get("propsPanelSize") || "small");
6949
7347
  const stage = vue.computed(() => services?.editorService.get("stage"));
7348
+ const { height: editorContentHeight } = useEditorContentHeight();
6950
7349
  const init = async () => {
6951
7350
  if (!node.value) {
6952
7351
  curFormConfig.value = [];
@@ -6980,6 +7379,9 @@
6980
7379
  const errorHandler = (e) => {
6981
7380
  emit("form-error", e);
6982
7381
  };
7382
+ const saveCode = (values2) => {
7383
+ services?.editorService.update(values2);
7384
+ };
6983
7385
  __expose({ configForm, submit });
6984
7386
  return (_ctx, _cache) => {
6985
7387
  return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
@@ -6995,71 +7397,34 @@
6995
7397
  "extend-state": _ctx.extendState,
6996
7398
  onChange: submit,
6997
7399
  onError: errorHandler
6998
- }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"])
6999
- ], 512)), [
7000
- [vue.vShow, nodes.value.length === 1]
7001
- ]);
7002
- };
7003
- }
7004
- });
7005
-
7006
- const useFloatBox = (slideKeys) => {
7007
- const floatBoxStates = vue.ref(
7008
- slideKeys.value.reduce(
7009
- (total, cur) => ({
7010
- ...total,
7011
- [cur]: {
7012
- status: false,
7013
- top: 0,
7014
- left: 0
7015
- }
7016
- }),
7017
- {}
7018
- )
7019
- );
7020
- const showingBoxKeys = vue.computed(
7021
- () => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
7022
- );
7023
- const isDraging = vue.ref(false);
7024
- const dragstartHandler = () => isDraging.value = true;
7025
- const dragendHandler = (key, e) => {
7026
- floatBoxStates.value[key] = {
7027
- left: e.clientX,
7028
- top: e.clientY,
7029
- status: true
7400
+ }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"]),
7401
+ vue.createVNode(vue.unref(design.TMagicButton), {
7402
+ class: "m-editor-props-panel-src-icon",
7403
+ circle: "",
7404
+ size: "large",
7405
+ title: "源码",
7406
+ type: showSrc.value ? "primary" : "",
7407
+ onClick: _cache[0] || (_cache[0] = ($event) => showSrc.value = !showSrc.value)
7408
+ }, {
7409
+ default: vue.withCtx(() => [
7410
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Document) }, null, 8, ["icon"])
7411
+ ]),
7412
+ _: 1
7413
+ }, 8, ["type"]),
7414
+ showSrc.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
7415
+ key: 0,
7416
+ height: `${vue.unref(editorContentHeight)}px`,
7417
+ "init-values": values.value,
7418
+ options: vue.unref(codeOptions),
7419
+ parse: true,
7420
+ onSave: saveCode
7421
+ }, null, 8, ["height", "init-values", "options"])) : vue.createCommentVNode("", true)
7422
+ ], 512)), [
7423
+ [vue.vShow, nodes.value.length === 1]
7424
+ ]);
7030
7425
  };
7031
- isDraging.value = false;
7032
- };
7033
- document.body.addEventListener("dragover", (e) => {
7034
- if (!isDraging.value)
7035
- return;
7036
- e.preventDefault();
7037
- });
7038
- vue.watch(
7039
- () => slideKeys.value,
7040
- () => {
7041
- for (const key in slideKeys.value) {
7042
- if (floatBoxStates.value[key])
7043
- continue;
7044
- floatBoxStates.value[key] = {
7045
- status: false,
7046
- top: 0,
7047
- left: 0
7048
- };
7049
- }
7050
- },
7051
- {
7052
- deep: true,
7053
- immediate: true
7054
- }
7055
- );
7056
- return {
7057
- dragstartHandler,
7058
- dragendHandler,
7059
- floatBoxStates,
7060
- showingBoxKeys
7061
- };
7062
- };
7426
+ }
7427
+ });
7063
7428
 
7064
7429
  const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
7065
7430
  ...{
@@ -7186,7 +7551,7 @@
7186
7551
  onContextmenu: nodeContentmenuHandler,
7187
7552
  onMouseenter: mouseenterHandler
7188
7553
  }, [
7189
- vue.createVNode(_sfc_main$N, {
7554
+ vue.createVNode(_sfc_main$U, {
7190
7555
  class: "expand-icon",
7191
7556
  style: vue.normalizeStyle(hasChildren.value ? "" : "color: transparent; cursor: default"),
7192
7557
  icon: expanded.value ? vue.unref(iconsVue.ArrowDown) : vue.unref(iconsVue.ArrowRight),
@@ -7465,7 +7830,7 @@
7465
7830
  placement: "bottom"
7466
7831
  }, {
7467
7832
  default: vue.withCtx(() => [
7468
- vue.createVNode(_sfc_main$N, {
7833
+ vue.createVNode(_sfc_main$U, {
7469
7834
  icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
7470
7835
  class: "edit-icon",
7471
7836
  onClick: vue.withModifiers(($event) => editCode(`${data.key}`), ["stop"])
@@ -7480,7 +7845,7 @@
7480
7845
  placement: "bottom"
7481
7846
  }, {
7482
7847
  default: vue.withCtx(() => [
7483
- vue.createVNode(_sfc_main$N, {
7848
+ vue.createVNode(_sfc_main$U, {
7484
7849
  icon: vue.unref(iconsVue.Close),
7485
7850
  class: "edit-icon",
7486
7851
  onClick: vue.withModifiers(($event) => deleteCode(`${data.key}`), ["stop"])
@@ -7506,8 +7871,7 @@
7506
7871
  },
7507
7872
  __name: "CodeBlockListPanel",
7508
7873
  props: {
7509
- customError: { type: Function },
7510
- slideType: {}
7874
+ customError: { type: Function }
7511
7875
  },
7512
7876
  setup(__props) {
7513
7877
  const { codeBlockService } = vue.inject("services") || {};
@@ -7557,15 +7921,14 @@
7557
7921
  ]),
7558
7922
  _: 3
7559
7923
  }),
7560
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
7924
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
7561
7925
  key: 0,
7562
7926
  ref_key: "codeBlockEditor",
7563
7927
  ref: codeBlockEditor,
7564
7928
  disabled: !editable.value,
7565
7929
  content: vue.unref(codeConfig),
7566
- slideType: _ctx.slideType,
7567
7930
  onSubmit: vue.unref(submitCodeBlockHandler)
7568
- }, null, 8, ["disabled", "content", "slideType", "onSubmit"])) : vue.createCommentVNode("", true)
7931
+ }, null, 8, ["disabled", "content", "onSubmit"])) : vue.createCommentVNode("", true)
7569
7932
  ], 64);
7570
7933
  };
7571
7934
  }
@@ -7576,21 +7939,28 @@
7576
7939
  name: "MEditorDataSourceConfigPanel"
7577
7940
  },
7578
7941
  __name: "DataSourceConfigPanel",
7579
- props: {
7942
+ props: /* @__PURE__ */ vue.mergeModels({
7580
7943
  title: {},
7581
7944
  values: {},
7582
- disabled: { type: Boolean },
7583
- slideType: {}
7584
- },
7585
- emits: ["submit"],
7945
+ disabled: { type: Boolean }
7946
+ }, {
7947
+ "visible": { type: Boolean, ...{ default: false } },
7948
+ "visibleModifiers": {},
7949
+ "width": { default: 670 },
7950
+ "widthModifiers": {}
7951
+ }),
7952
+ emits: /* @__PURE__ */ vue.mergeModels(["submit"], ["update:visible", "update:width"]),
7586
7953
  setup(__props, { expose: __expose, emit: __emit }) {
7587
7954
  const props = __props;
7955
+ const boxVisible = vue.useModel(__props, "visible");
7956
+ const width = vue.useModel(__props, "width");
7588
7957
  const emit = __emit;
7589
7958
  const services = vue.inject("services");
7590
- const size = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
7591
- const fomDrawer = vue.ref();
7592
7959
  const initValues = vue.ref({});
7593
7960
  const dataSourceConfig = vue.ref([]);
7961
+ const { height: editorHeight } = useEditorContentHeight();
7962
+ const parentFloating = vue.inject("parentFloating", vue.ref(null));
7963
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
7594
7964
  vue.watchEffect(() => {
7595
7965
  initValues.value = props.values;
7596
7966
  dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
@@ -7603,26 +7973,38 @@
7603
7973
  };
7604
7974
  __expose({
7605
7975
  show() {
7606
- fomDrawer.value?.show();
7976
+ calcBoxPosition();
7977
+ boxVisible.value = true;
7607
7978
  },
7608
7979
  hide() {
7609
- fomDrawer.value?.hide();
7980
+ boxVisible.value = false;
7610
7981
  }
7611
7982
  });
7612
7983
  return (_ctx, _cache) => {
7613
- return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.slideType === "box" ? vue.unref(form.MFormBox) : vue.unref(form.MFormDrawer)), {
7614
- ref_key: "fomDrawer",
7615
- ref: fomDrawer,
7616
- "label-width": "80px",
7617
- "close-on-press-escape": false,
7984
+ return vue.openBlock(), vue.createBlock(_sfc_main$P, {
7985
+ visible: boxVisible.value,
7986
+ "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
7987
+ width: width.value,
7988
+ "onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
7989
+ height: vue.unref(editorHeight),
7990
+ "onUpdate:height": _cache[2] || (_cache[2] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
7618
7991
  title: _ctx.title,
7619
- width: size.value,
7620
- config: dataSourceConfig.value,
7621
- values: initValues.value,
7622
- disabled: _ctx.disabled,
7623
- onSubmit: submitHandler,
7624
- onError: errorHandler
7625
- }, null, 40, ["title", "width", "config", "values", "disabled"]);
7992
+ position: vue.unref(boxPosition)
7993
+ }, {
7994
+ body: vue.withCtx(() => [
7995
+ vue.createVNode(vue.unref(form.MFormBox), {
7996
+ "label-width": "80px",
7997
+ title: _ctx.title,
7998
+ config: dataSourceConfig.value,
7999
+ values: initValues.value,
8000
+ disabled: _ctx.disabled,
8001
+ style: { "height": "100%" },
8002
+ onSubmit: submitHandler,
8003
+ onError: errorHandler
8004
+ }, null, 8, ["title", "config", "values", "disabled"])
8005
+ ]),
8006
+ _: 1
8007
+ }, 8, ["visible", "width", "height", "title", "position"]);
7626
8008
  };
7627
8009
  }
7628
8010
  });
@@ -7738,7 +8120,7 @@
7738
8120
  placement: "bottom"
7739
8121
  }, {
7740
8122
  default: vue.withCtx(() => [
7741
- vue.createVNode(_sfc_main$N, {
8123
+ vue.createVNode(_sfc_main$U, {
7742
8124
  icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
7743
8125
  class: "edit-icon",
7744
8126
  onClick: vue.withModifiers(($event) => editHandler(`${data.key}`), ["stop"])
@@ -7753,7 +8135,7 @@
7753
8135
  placement: "bottom"
7754
8136
  }, {
7755
8137
  default: vue.withCtx(() => [
7756
- vue.createVNode(_sfc_main$N, {
8138
+ vue.createVNode(_sfc_main$U, {
7757
8139
  icon: vue.unref(iconsVue.Close),
7758
8140
  class: "edit-icon",
7759
8141
  onClick: vue.withModifiers(($event) => removeHandler(`${data.key}`), ["stop"])
@@ -7776,9 +8158,6 @@
7776
8158
  name: "MEditorDataSourceListPanel"
7777
8159
  },
7778
8160
  __name: "DataSourceListPanel",
7779
- props: {
7780
- slideType: {}
7781
- },
7782
8161
  setup(__props) {
7783
8162
  const { dataSourceService } = vue.inject("services") || {};
7784
8163
  const editDialog = vue.ref();
@@ -7885,9 +8264,8 @@
7885
8264
  disabled: !editable.value,
7886
8265
  values: dataSourceValues.value,
7887
8266
  title: dialogTitle.value,
7888
- slideType: _ctx.slideType,
7889
8267
  onSubmit: submitDataSourceHandler
7890
- }, null, 8, ["disabled", "values", "title", "slideType"])
8268
+ }, null, 8, ["disabled", "values", "title"])
7891
8269
  ], 64);
7892
8270
  };
7893
8271
  }
@@ -8289,12 +8667,12 @@
8289
8667
  };
8290
8668
  return (_ctx, _cache) => {
8291
8669
  return _ctx.data.type !== "page" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
8292
- _ctx.data.visible === false ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
8670
+ _ctx.data.visible === false ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
8293
8671
  key: 0,
8294
8672
  icon: vue.unref(iconsVue.Hide),
8295
8673
  onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => setNodeVisible(true), ["stop"])),
8296
8674
  title: "点击显示"
8297
- }, null, 8, ["icon"])) : (vue.openBlock(), vue.createBlock(_sfc_main$N, {
8675
+ }, null, 8, ["icon"])) : (vue.openBlock(), vue.createBlock(_sfc_main$U, {
8298
8676
  key: 1,
8299
8677
  icon: vue.unref(iconsVue.View),
8300
8678
  onClick: _cache[1] || (_cache[1] = vue.withModifiers(($event) => setNodeVisible(false), ["stop"])),
@@ -8935,7 +9313,7 @@
8935
9313
  name: `${index}`
8936
9314
  }, {
8937
9315
  title: vue.withCtx(() => [
8938
- vue.createVNode(_sfc_main$N, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
9316
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
8939
9317
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
8940
9318
  ]),
8941
9319
  default: vue.withCtx(() => [
@@ -8956,7 +9334,7 @@
8956
9334
  content: item.desc
8957
9335
  }, {
8958
9336
  default: vue.withCtx(() => [
8959
- vue.createVNode(_sfc_main$N, {
9337
+ vue.createVNode(_sfc_main$U, {
8960
9338
  icon: item.icon
8961
9339
  }, null, 8, ["icon"])
8962
9340
  ]),
@@ -9007,6 +9385,8 @@
9007
9385
  setup(__props, { expose: __expose }) {
9008
9386
  const props = __props;
9009
9387
  const services = vue.inject("services");
9388
+ const columnLeftWidth = vue.computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
9389
+ const { height: columnLeftHeight } = useEditorContentHeight();
9010
9390
  const activeTabName = vue.ref(props.data?.status);
9011
9391
  const getItemConfig = (data) => {
9012
9392
  const map = {
@@ -9036,12 +9416,7 @@
9036
9416
  icon: iconsVue.EditPen,
9037
9417
  text: "代码编辑",
9038
9418
  component: _sfc_main$k,
9039
- slots: {},
9040
- boxComponentConfig: {
9041
- props: {
9042
- slideType: "box"
9043
- }
9044
- }
9419
+ slots: {}
9045
9420
  },
9046
9421
  "data-source": {
9047
9422
  $key: "data-source",
@@ -9098,7 +9473,7 @@
9098
9473
  (...args) => vue.unref(dragstartHandler) && vue.unref(dragstartHandler)(...args)),
9099
9474
  onDragend: ($event) => vue.unref(dragendHandler)(config.$key, $event)
9100
9475
  }, [
9101
- config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
9476
+ config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
9102
9477
  key: 0,
9103
9478
  icon: config.icon
9104
9479
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -9231,10 +9606,13 @@
9231
9606
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
9232
9607
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
9233
9608
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
9234
- vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(_sfc_main$Q, {
9609
+ vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
9235
9610
  key: config.$key ?? index,
9236
9611
  visible: vue.unref(floatBoxStates)[config.$key].status,
9237
9612
  "onUpdate:visible": ($event) => vue.unref(floatBoxStates)[config.$key].status = $event,
9613
+ height: vue.unref(columnLeftHeight),
9614
+ "onUpdate:height": _cache[1] || (_cache[1] = ($event) => vue.isRef(columnLeftHeight) ? columnLeftHeight.value = $event : null),
9615
+ width: columnLeftWidth.value,
9238
9616
  title: config.text,
9239
9617
  position: {
9240
9618
  left: vue.unref(floatBoxStates)[config.$key].left,
@@ -9243,11 +9621,11 @@
9243
9621
  }, {
9244
9622
  body: vue.withCtx(() => [
9245
9623
  vue.createElementVNode("div", _hoisted_5$1, [
9246
- config && vue.unref(floatBoxStates)[config.$key].status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.boxComponentConfig?.component || config.component), vue.mergeProps({ key: 0 }, config.boxComponentConfig?.props || config.props || {}, vue.toHandlers(config?.listeners || {})), null, 16)) : vue.createCommentVNode("", true)
9624
+ config && vue.unref(floatBoxStates)[config.$key].status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({ key: 0 }, config.props || {}, vue.toHandlers(config?.listeners || {})), null, 16)) : vue.createCommentVNode("", true)
9247
9625
  ])
9248
9626
  ]),
9249
9627
  _: 2
9250
- }, 1032, ["visible", "onUpdate:visible", "title", "position"])) : vue.createCommentVNode("", true)
9628
+ }, 1032, ["visible", "onUpdate:visible", "height", "width", "title", "position"])) : vue.createCommentVNode("", true)
9251
9629
  ], 64);
9252
9630
  }), 256))
9253
9631
  ]))
@@ -9579,205 +9957,6 @@
9579
9957
  }
9580
9958
  });
9581
9959
 
9582
- const state = vue.reactive({
9583
- uiSelectMode: false,
9584
- showSrc: false,
9585
- zoom: 1,
9586
- stageContainerRect: {
9587
- width: 0,
9588
- height: 0
9589
- },
9590
- stageRect: {
9591
- width: 375,
9592
- height: 817
9593
- },
9594
- columnWidth: {
9595
- left: 0,
9596
- right: 0,
9597
- center: 0
9598
- },
9599
- showGuides: true,
9600
- showRule: true,
9601
- propsPanelSize: "small",
9602
- showAddPageButton: true,
9603
- hideSlideBar: false,
9604
- navMenuRect: {
9605
- left: 0,
9606
- top: 0,
9607
- width: 0,
9608
- height: 0
9609
- }
9610
- });
9611
- const canUsePluginMethods$2 = {
9612
- async: ["zoom", "calcZoom"],
9613
- sync: []
9614
- };
9615
- class Ui extends BaseService {
9616
- constructor() {
9617
- super(canUsePluginMethods$2.async.map((methodName) => ({ name: methodName, isAsync: true })));
9618
- }
9619
- set(name, value) {
9620
- const mask = editorService.get("stage")?.mask;
9621
- if (name === "stageRect") {
9622
- this.setStageRect(value);
9623
- return;
9624
- }
9625
- if (name === "showGuides") {
9626
- mask?.showGuides(value);
9627
- }
9628
- if (name === "showRule") {
9629
- mask?.showRule(value);
9630
- }
9631
- state[name] = value;
9632
- }
9633
- get(name) {
9634
- return state[name];
9635
- }
9636
- async zoom(zoom) {
9637
- this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
9638
- if (this.get("zoom") < 0.1)
9639
- this.set("zoom", 0.1);
9640
- }
9641
- async calcZoom() {
9642
- const { stageRect, stageContainerRect } = state;
9643
- const { height, width } = stageContainerRect;
9644
- if (!width || !height)
9645
- return 1;
9646
- let stageWidth = utils.convertToNumber(stageRect.width, width);
9647
- let stageHeight = utils.convertToNumber(stageRect.height, height);
9648
- stageWidth = stageWidth + 30;
9649
- stageHeight = stageHeight + 30;
9650
- if (width > stageWidth && height > stageHeight) {
9651
- return 1;
9652
- }
9653
- return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
9654
- }
9655
- resetState() {
9656
- this.set("showSrc", false);
9657
- this.set("uiSelectMode", false);
9658
- this.set("zoom", 1);
9659
- this.set("stageContainerRect", {
9660
- width: 0,
9661
- height: 0
9662
- });
9663
- }
9664
- destroy() {
9665
- this.resetState();
9666
- this.removeAllListeners();
9667
- this.removeAllPlugins();
9668
- }
9669
- usePlugin(options) {
9670
- super.usePlugin(options);
9671
- }
9672
- async setStageRect(value) {
9673
- state.stageRect = {
9674
- ...state.stageRect,
9675
- ...value
9676
- };
9677
- state.zoom = await this.calcZoom();
9678
- }
9679
- }
9680
- const uiService = new Ui();
9681
-
9682
- const root = vue.computed(() => editorService.get("root"));
9683
- const page = vue.computed(() => editorService.get("page"));
9684
- const zoom = vue.computed(() => uiService.get("zoom") || 1);
9685
- const uiSelectMode = vue.computed(() => uiService.get("uiSelectMode"));
9686
- const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
9687
- const useStage = (stageOptions) => {
9688
- const stage = new StageCore({
9689
- render: stageOptions.render,
9690
- runtimeUrl: stageOptions.runtimeUrl,
9691
- zoom: zoom.value,
9692
- autoScrollIntoView: stageOptions.autoScrollIntoView,
9693
- isContainer: stageOptions.isContainer,
9694
- containerHighlightClassName: stageOptions.containerHighlightClassName,
9695
- containerHighlightDuration: stageOptions.containerHighlightDuration,
9696
- containerHighlightType: stageOptions.containerHighlightType,
9697
- disabledDragStart: stageOptions.disabledDragStart,
9698
- renderType: stageOptions.renderType,
9699
- canSelect: (el, event, stop) => {
9700
- if (!stageOptions.canSelect)
9701
- return true;
9702
- const elCanSelect = stageOptions.canSelect?.(el);
9703
- if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
9704
- document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
9705
- return stop();
9706
- }
9707
- return elCanSelect;
9708
- },
9709
- moveableOptions: stageOptions.moveableOptions,
9710
- updateDragEl: stageOptions.updateDragEl,
9711
- guidesOptions: stageOptions.guidesOptions,
9712
- disabledMultiSelect: stageOptions.disabledMultiSelect
9713
- });
9714
- vue.watch(
9715
- () => editorService.get("disabledMultiSelect"),
9716
- (disabledMultiSelect) => {
9717
- if (disabledMultiSelect) {
9718
- stage.disableMultiSelect();
9719
- } else {
9720
- stage.enableMultiSelect();
9721
- }
9722
- }
9723
- );
9724
- stage.mask.setGuides([
9725
- getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
9726
- getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
9727
- ]);
9728
- stage.on("page-el-update", () => {
9729
- editorService.set("stageLoading", false);
9730
- });
9731
- stage.on("select", (el) => {
9732
- if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
9733
- return;
9734
- editorService.select(el.id);
9735
- });
9736
- stage.on("highlight", (el) => {
9737
- editorService.highlight(el.id);
9738
- });
9739
- stage.on("multi-select", (els) => {
9740
- editorService.multiSelect(els.map((el) => el.id));
9741
- });
9742
- stage.on("update", (ev) => {
9743
- if (ev.parentEl) {
9744
- for (const data of ev.data) {
9745
- editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
9746
- }
9747
- return;
9748
- }
9749
- editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
9750
- });
9751
- stage.on("sort", (ev) => {
9752
- editorService.sort(ev.src, ev.dist);
9753
- });
9754
- stage.on("remove", (ev) => {
9755
- const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
9756
- editorService.remove(nodes.filter((node) => Boolean(node)));
9757
- });
9758
- stage.on("select-parent", () => {
9759
- const parent = editorService.get("parent");
9760
- if (!parent)
9761
- throw new Error("父节点为空");
9762
- editorService.select(parent);
9763
- editorService.get("stage")?.select(parent.id);
9764
- });
9765
- stage.on("change-guides", (e) => {
9766
- uiService.set("showGuides", true);
9767
- if (!root.value || !page.value)
9768
- return;
9769
- const storageKey = getGuideLineKey(
9770
- e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
9771
- );
9772
- if (e.guides.length) {
9773
- globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
9774
- } else {
9775
- globalThis.localStorage.removeItem(storageKey);
9776
- }
9777
- });
9778
- return stage;
9779
- };
9780
-
9781
9960
  const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
9782
9961
  __name: "NodeListMenu",
9783
9962
  setup(__props) {
@@ -9860,7 +10039,7 @@
9860
10039
  ]),
9861
10040
  _: 1
9862
10041
  })) : vue.createCommentVNode("", true),
9863
- page.value && vue.unref(nodeStatusMap) && buttonVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$Q, {
10042
+ page.value && vue.unref(nodeStatusMap) && buttonVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
9864
10043
  key: 1,
9865
10044
  ref_key: "box",
9866
10045
  ref: box,
@@ -9933,7 +10112,7 @@
9933
10112
  }, [
9934
10113
  vue.createVNode(vue.unref(design.TMagicIcon), {
9935
10114
  class: "m-editor-stage-overlay-close",
9936
- size: 20,
10115
+ size: "20",
9937
10116
  onClick: closeOverlayHandler
9938
10117
  }, {
9939
10118
  default: vue.withCtx(() => [
@@ -10980,7 +11159,7 @@
10980
11159
  subStage?.renderer.contentWindow?.magic.onPageElUpdate(wrapDiv);
10981
11160
  });
10982
11161
  if (await stageOptions?.canSelect?.(contentEl)) {
10983
- subStage?.select(contentEl);
11162
+ subStage?.select(contentEl.id);
10984
11163
  }
10985
11164
  }
10986
11165
  updateHandler = () => {
@@ -11580,11 +11759,11 @@
11580
11759
  app.config.globalProperties.$TMAGIC_EDITOR = option;
11581
11760
  setConfig(option);
11582
11761
  app.component(`${_sfc_main.name || "MEditor"}`, _sfc_main);
11583
- app.component("magic-code-editor", _sfc_main$U);
11762
+ app.component("magic-code-editor", _sfc_main$T);
11584
11763
  app.component("m-fields-ui-select", _sfc_main$A);
11585
- app.component("m-fields-code-link", _sfc_main$S);
11586
- app.component("m-fields-vs-code", _sfc_main$T);
11587
- app.component("m-fields-code-select", _sfc_main$R);
11764
+ app.component("m-fields-code-link", _sfc_main$R);
11765
+ app.component("m-fields-vs-code", _sfc_main$S);
11766
+ app.component("m-fields-code-select", _sfc_main$Q);
11588
11767
  app.component("m-fields-code-select-col", _sfc_main$M);
11589
11768
  app.component("m-fields-event-select", _sfc_main$E);
11590
11769
  app.component("m-fields-data-source-fields", _sfc_main$L);
@@ -11605,11 +11784,11 @@
11605
11784
  });
11606
11785
  exports.CODE_DRAFT_STORAGE_KEY = CODE_DRAFT_STORAGE_KEY;
11607
11786
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
11608
- exports.CodeBlockEditor = _sfc_main$P;
11787
+ exports.CodeBlockEditor = _sfc_main$O;
11609
11788
  exports.CodeBlockList = _sfc_main$l;
11610
11789
  exports.CodeBlockListPanel = _sfc_main$k;
11611
11790
  exports.CodeDeleteErrorType = CodeDeleteErrorType;
11612
- exports.CodeSelect = _sfc_main$R;
11791
+ exports.CodeSelect = _sfc_main$Q;
11613
11792
  exports.CodeSelectCol = _sfc_main$M;
11614
11793
  exports.ColumnLayout = ColumnLayout;
11615
11794
  exports.ComponentListPanel = _sfc_main$b;
@@ -11626,7 +11805,7 @@
11626
11805
  exports.EventSelect = _sfc_main$E;
11627
11806
  exports.Fixed2Other = Fixed2Other;
11628
11807
  exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
11629
- exports.Icon = _sfc_main$N;
11808
+ exports.Icon = _sfc_main$U;
11630
11809
  exports.KeyBindingCommand = KeyBindingCommand;
11631
11810
  exports.KeyValue = _sfc_main$C;
11632
11811
  exports.Keys = Keys;
@@ -11638,7 +11817,7 @@
11638
11817
  exports.PropsPanel = _sfc_main$p;
11639
11818
  exports.Resizer = _sfc_main$z;
11640
11819
  exports.SplitView = _sfc_main$y;
11641
- exports.TMagicCodeEditor = _sfc_main$U;
11820
+ exports.TMagicCodeEditor = _sfc_main$T;
11642
11821
  exports.TMagicEditor = _sfc_main;
11643
11822
  exports.ToolButton = _sfc_main$x;
11644
11823
  exports.UI_SELECT_MODE_EVENT_NAME = UI_SELECT_MODE_EVENT_NAME;
@@ -11691,8 +11870,10 @@
11691
11870
  exports.uiService = uiService;
11692
11871
  exports.useCodeBlockEdit = useCodeBlockEdit;
11693
11872
  exports.useDataSourceMethod = useDataSourceMethod;
11873
+ exports.useEditorContentHeight = useEditorContentHeight;
11694
11874
  exports.useFloatBox = useFloatBox;
11695
11875
  exports.useStage = useStage;
11876
+ exports.useWindowRect = useWindowRect;
11696
11877
  exports.warn = warn;
11697
11878
 
11698
11879
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });