@tmagic/editor 1.4.0-beta.2 → 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 (36) hide show
  1. package/dist/style.css +8 -20
  2. package/dist/tmagic-editor.js +829 -742
  3. package/dist/tmagic-editor.umd.cjs +832 -745
  4. package/package.json +11 -11
  5. package/src/components/CodeBlockEditor.vue +50 -73
  6. package/src/components/FloatingBox.vue +24 -9
  7. package/src/fields/DataSourceFieldSelect.vue +2 -1
  8. package/src/fields/DataSourceFields.vue +55 -30
  9. package/src/fields/DataSourceInput.vue +6 -2
  10. package/src/fields/DataSourceMocks.vue +35 -17
  11. package/src/hooks/use-editor-content-height.ts +1 -1
  12. package/src/hooks/use-float-box.ts +14 -8
  13. package/src/hooks/use-next-float-box-position.ts +29 -0
  14. package/src/layouts/CodeEditor.vue +3 -6
  15. package/src/layouts/PropsPanel.vue +4 -2
  16. package/src/layouts/sidebar/Sidebar.vue +7 -10
  17. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +1 -3
  18. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +36 -22
  19. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +1 -6
  20. package/src/layouts/workspace/viewer/StageOverlay.vue +3 -1
  21. package/src/theme/code-block.scss +0 -14
  22. package/src/theme/component-list-panel.scss +0 -1
  23. package/src/theme/icon.scss +7 -1
  24. package/src/theme/layer-panel.scss +0 -1
  25. package/src/theme/sidebar.scss +0 -7
  26. package/src/type.ts +0 -6
  27. package/types/components/CodeBlockEditor.vue.d.ts +0 -7
  28. package/types/fields/DataSourceFields.vue.d.ts +84 -28
  29. package/types/fields/DataSourceMocks.vue.d.ts +80 -28
  30. package/types/hooks/use-code-block-edit.d.ts +0 -9
  31. package/types/hooks/use-data-source-method.d.ts +0 -9
  32. package/types/hooks/use-next-float-box-position.d.ts +9 -0
  33. package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +1 -3
  34. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +34 -22
  35. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +2 -15
  36. package/types/type.d.ts +0 -5
@@ -1,23 +1,67 @@
1
- import { defineComponent, ref, watch, onMounted, onBeforeUnmount, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, mergeModels, useModel, nextTick, renderSlot, toDisplayString, createCommentVNode, watchEffect, Fragment, isRef, createTextVNode, toRaw, resolveDynamicComponent, mergeProps, renderList, createStaticVNode, withModifiers, toHandlers, resolveDirective, withDirectives, createSlots, markRaw, getCurrentInstance, vShow, provide, Transition, mergeDefaults } from 'vue';
2
- import { FullScreen, Close, Edit, View, Coin, Delete, Plus, ArrowDown, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Document, Search, ArrowRight, CopyDocument, Files, Hide, Goods, List, EditPen, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
1
+ import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, ref, watch, onMounted, onBeforeUnmount, Teleport, normalizeStyle, computed, reactive, resolveComponent, inject, mergeModels, useModel, nextTick, provide, renderSlot, toDisplayString, createCommentVNode, watchEffect, Fragment, isRef, createTextVNode, mergeProps, renderList, createStaticVNode, withModifiers, toHandlers, resolveDirective, withDirectives, createSlots, markRaw, getCurrentInstance, vShow, Transition, mergeDefaults } from 'vue';
2
+ import { Edit, FullScreen, Close, View, Coin, Delete, Plus, ArrowDown, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Document, Search, ArrowRight, CopyDocument, Files, Hide, Goods, List, EditPen, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
3
3
  import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, get, map, has, pick, keys } from 'lodash-es';
4
4
  import serialize from 'serialize-javascript';
5
- import { TMagicButton, TMagicCard, useZIndex, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox, TMagicIcon, getConfig as getConfig$1, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
5
+ import { TMagicIcon, TMagicButton, TMagicCard, useZIndex, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox, getConfig as getConfig$1, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
6
6
  import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
7
7
  import * as monaco from 'monaco-editor';
8
8
  import { HookCodeType, HookType, NodeType, ActionType } from '@tmagic/schema';
9
- import { MFormBox, MForm, filterFunction, createValues, MFormDrawer, MCascader, MSelect } from '@tmagic/form';
9
+ import { MFormBox, MForm, filterFunction, createValues, MCascader, MSelect } from '@tmagic/form';
10
10
  import VanillaMoveable from 'moveable';
11
11
  import { MagicTable } from '@tmagic/table';
12
- import { toLine, guid, isPage, isPageFragment, isPop, getNodePath, isNumber, getValueByKeyPath, setValueByKeyPath, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, convertToNumber, getNodes } from '@tmagic/utils';
13
- import Gesto from 'gesto';
12
+ import { toLine, guid, isPage, isPageFragment, isPop, getNodePath, isNumber, getValueByKeyPath, setValueByKeyPath, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
14
13
  import { Watcher, DepTargetType, createRelatedCompTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
15
14
  export { DepTargetType } from '@tmagic/dep';
15
+ import Gesto from 'gesto';
16
16
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, RenderType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
17
17
  import { EventEmitter } from 'events';
18
18
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
19
19
  import KeyController from 'keycon';
20
20
 
21
+ const _hoisted_1$t = ["src"];
22
+ const _sfc_main$U = /* @__PURE__ */ defineComponent({
23
+ ...{
24
+ name: "MEditorIcon"
25
+ },
26
+ __name: "Icon",
27
+ props: {
28
+ icon: {}
29
+ },
30
+ setup(__props) {
31
+ const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
32
+ return (_ctx, _cache) => {
33
+ return !_ctx.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
34
+ key: 0,
35
+ class: "magic-editor-icon"
36
+ }, {
37
+ default: withCtx(() => [
38
+ createVNode(unref(Edit))
39
+ ]),
40
+ _: 1
41
+ })) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (openBlock(), createBlock(unref(TMagicIcon), {
42
+ key: 1,
43
+ class: "magic-editor-icon"
44
+ }, {
45
+ default: withCtx(() => [
46
+ createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$t)
47
+ ]),
48
+ _: 1
49
+ })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
50
+ key: 2,
51
+ class: normalizeClass(["magic-editor-icon", _ctx.icon])
52
+ }, null, 2)) : (openBlock(), createBlock(unref(TMagicIcon), {
53
+ key: 3,
54
+ class: "magic-editor-icon"
55
+ }, {
56
+ default: withCtx(() => [
57
+ (openBlock(), createBlock(resolveDynamicComponent(toRaw(_ctx.icon))))
58
+ ]),
59
+ _: 1
60
+ }));
61
+ };
62
+ }
63
+ });
64
+
21
65
  let $TMAGIC_EDITOR = {};
22
66
  const setConfig = (option) => {
23
67
  $TMAGIC_EDITOR = option;
@@ -27,10 +71,10 @@ const getConfig = (key) => $TMAGIC_EDITOR[key];
27
71
  emmetHTML(monaco);
28
72
  emmetCSS(monaco, ["css", "scss"]);
29
73
 
30
- const _hoisted_1$t = {
74
+ const _hoisted_1$s = {
31
75
  class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
32
76
  };
33
- const _sfc_main$U = /* @__PURE__ */ defineComponent({
77
+ const _sfc_main$T = /* @__PURE__ */ defineComponent({
34
78
  ...{
35
79
  name: "MEditorCodeEditor"
36
80
  },
@@ -188,7 +232,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
188
232
  }
189
233
  });
190
234
  return (_ctx, _cache) => {
191
- return openBlock(), createElementBlock("div", _hoisted_1$t, [
235
+ return openBlock(), createElementBlock("div", _hoisted_1$s, [
192
236
  (openBlock(), createBlock(Teleport, {
193
237
  to: "body",
194
238
  disabled: !fullScreen.value
@@ -201,9 +245,13 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
201
245
  class: "magic-code-editor-full-screen-icon",
202
246
  circle: "",
203
247
  size: "small",
204
- icon: unref(FullScreen),
205
248
  onClick: fullScreenHandler
206
- }, null, 8, ["icon"]),
249
+ }, {
250
+ default: withCtx(() => [
251
+ createVNode(_sfc_main$U, { icon: unref(FullScreen) }, null, 8, ["icon"])
252
+ ]),
253
+ _: 1
254
+ }),
207
255
  createElementVNode("div", {
208
256
  ref_key: "codeEditor",
209
257
  ref: codeEditor,
@@ -216,7 +264,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
216
264
  }
217
265
  });
218
266
 
219
- const _sfc_main$T = /* @__PURE__ */ defineComponent({
267
+ const _sfc_main$S = /* @__PURE__ */ defineComponent({
220
268
  ...{
221
269
  name: "MFieldsVsCode"
222
270
  },
@@ -241,7 +289,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
241
289
  emit("change", v);
242
290
  };
243
291
  return (_ctx, _cache) => {
244
- return openBlock(), createBlock(_sfc_main$U, {
292
+ return openBlock(), createBlock(_sfc_main$T, {
245
293
  height: _ctx.config.height,
246
294
  "init-values": _ctx.model[_ctx.name],
247
295
  language: _ctx.config.language,
@@ -256,7 +304,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
256
304
  }
257
305
  });
258
306
 
259
- const _sfc_main$S = /* @__PURE__ */ defineComponent({
307
+ const _sfc_main$R = /* @__PURE__ */ defineComponent({
260
308
  ...{
261
309
  name: "MFieldsCodeLink"
262
310
  },
@@ -336,7 +384,7 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
336
384
  }
337
385
  });
338
386
 
339
- const _sfc_main$R = /* @__PURE__ */ defineComponent({
387
+ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
340
388
  ...{
341
389
  name: "MFieldsCodeSelect"
342
390
  },
@@ -454,7 +502,7 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
454
502
  }
455
503
  });
456
504
 
457
- const _sfc_main$Q = /* @__PURE__ */ defineComponent({
505
+ const _sfc_main$P = /* @__PURE__ */ defineComponent({
458
506
  __name: "FloatingBox",
459
507
  props: /* @__PURE__ */ mergeModels({
460
508
  position: { default: () => ({ left: 0, top: 0 }) },
@@ -477,7 +525,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
477
525
  const target = ref();
478
526
  const titleEl = ref();
479
527
  const zIndex = useZIndex();
480
- const curZIndex = ref(zIndex.nextZIndex());
528
+ const curZIndex = ref(0);
481
529
  const titleHeight = ref(0);
482
530
  const bodyHeight = computed(() => {
483
531
  if (height.value) {
@@ -488,12 +536,20 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
488
536
  }
489
537
  return "auto";
490
538
  });
491
- const style = computed(() => ({
492
- left: `${props.position.left}px`,
493
- top: `${props.position.top}px`,
494
- width: width.value ? `${width.value}px` : "auto",
495
- height: height.value ? `${height.value}px` : "auto"
496
- }));
539
+ const services = inject("services");
540
+ const frameworkWidth = computed(() => services?.uiService.get("frameworkRect").width || 0);
541
+ const style = computed(() => {
542
+ let { left } = props.position;
543
+ if (width.value) {
544
+ left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
545
+ }
546
+ return {
547
+ left: `${left}px`,
548
+ top: `${props.position.top}px`,
549
+ width: width.value ? `${width.value}px` : "auto",
550
+ height: height.value ? `${height.value}px` : "auto"
551
+ };
552
+ });
497
553
  let moveable = null;
498
554
  const initMoveable = () => {
499
555
  moveable = new VanillaMoveable(globalThis.document.body, {
@@ -531,6 +587,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
531
587
  async (visible2) => {
532
588
  if (visible2) {
533
589
  await nextTick();
590
+ curZIndex.value = zIndex.nextZIndex();
534
591
  const targetRect = target.value?.getBoundingClientRect();
535
592
  if (targetRect) {
536
593
  width.value = targetRect.width;
@@ -567,6 +624,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
567
624
  const nextZIndex = () => {
568
625
  curZIndex.value = zIndex.nextZIndex();
569
626
  };
627
+ provide("parentFloating", target);
570
628
  __expose({
571
629
  bodyHeight,
572
630
  target,
@@ -596,9 +654,13 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
596
654
  createVNode(unref(TMagicButton), {
597
655
  link: "",
598
656
  size: "small",
599
- icon: unref(Close),
600
657
  onClick: closeHandler
601
- }, null, 8, ["icon"])
658
+ }, {
659
+ default: withCtx(() => [
660
+ createVNode(_sfc_main$U, { icon: unref(Close) }, null, 8, ["icon"])
661
+ ]),
662
+ _: 1
663
+ })
602
664
  ])
603
665
  ], 512),
604
666
  createElementVNode("div", {
@@ -620,7 +682,7 @@ const useEditorContentHeight = () => {
620
682
  const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
621
683
  const height = ref(0);
622
684
  watchEffect(() => {
623
- if (height.value > 0)
685
+ if (height.value > 0 && height.value === editorContentHeight.value)
624
686
  return;
625
687
  height.value = editorContentHeight.value;
626
688
  });
@@ -629,6 +691,30 @@ const useEditorContentHeight = () => {
629
691
  };
630
692
  };
631
693
 
694
+ const useNextFloatBoxPosition = (uiService, parent) => {
695
+ const boxPosition = ref({
696
+ left: 0,
697
+ top: 0
698
+ });
699
+ const calcBoxPosition = () => {
700
+ const columnWidth = uiService?.get("columnWidth");
701
+ const navMenuRect = uiService?.get("navMenuRect");
702
+ let left = columnWidth?.left ?? 0;
703
+ if (parent?.value) {
704
+ const rect = parent?.value?.getBoundingClientRect();
705
+ left = (rect?.left ?? 0) + (rect?.width ?? 0);
706
+ }
707
+ boxPosition.value = {
708
+ left,
709
+ top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
710
+ };
711
+ };
712
+ return {
713
+ boxPosition,
714
+ calcBoxPosition
715
+ };
716
+ };
717
+
632
718
  const useWindowRect = () => {
633
719
  const rect = reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
634
720
  const windowResizeHandler = () => {
@@ -644,11 +730,11 @@ const useWindowRect = () => {
644
730
  };
645
731
  };
646
732
 
647
- const _hoisted_1$s = { style: { "display": "flex", "margin-bottom": "10px" } };
733
+ const _hoisted_1$r = { style: { "display": "flex", "margin-bottom": "10px" } };
648
734
  const _hoisted_2$k = { style: { "flex": "1" } };
649
735
  const _hoisted_3$8 = { style: { "flex": "1" } };
650
736
  const _hoisted_4$7 = { class: "dialog-footer" };
651
- const _sfc_main$P = /* @__PURE__ */ defineComponent({
737
+ const _sfc_main$O = /* @__PURE__ */ defineComponent({
652
738
  ...{
653
739
  name: "MEditorCodeBlockEditor"
654
740
  },
@@ -657,8 +743,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
657
743
  content: {},
658
744
  disabled: { type: Boolean },
659
745
  isDataSource: { type: Boolean },
660
- dataSourceType: {},
661
- slideType: {}
746
+ dataSourceType: {}
662
747
  }, {
663
748
  "width": { default: 670 },
664
749
  "widthModifiers": {},
@@ -791,7 +876,6 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
791
876
  };
792
877
  const beforeClose = (done) => {
793
878
  if (!changedValue.value) {
794
- editVisible.value = false;
795
879
  done();
796
880
  return;
797
881
  }
@@ -802,170 +886,142 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
802
886
  distinguishCancelAndClose: true
803
887
  }).then(() => {
804
888
  changedValue.value && submitForm(changedValue.value);
805
- editVisible.value = false;
806
889
  done();
807
890
  }).catch((action) => {
808
- if (action === "cancel") {
809
- editVisible.value = false;
810
- }
811
891
  done(action === "cancel");
812
892
  });
813
893
  };
814
894
  const closedHandler = () => {
815
895
  changedValue.value = void 0;
816
896
  };
817
- const editVisible = ref(false);
818
- const floatingBoxBody = ref();
819
- const boxPosition = computed(() => {
820
- const columnWidth = services?.uiService?.get("columnWidth");
821
- const navMenuRect = services?.uiService?.get("navMenuRect");
822
- return {
823
- left: columnWidth?.left ?? 0,
824
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
825
- };
826
- });
897
+ const parentFloating = inject("parentFloating", ref(null));
898
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
827
899
  __expose({
828
900
  async show() {
829
- if (props.slideType !== "box") {
830
- boxVisible.value = true;
831
- await nextTick();
832
- }
833
- editVisible.value = true;
901
+ calcBoxPosition();
902
+ boxVisible.value = true;
834
903
  },
835
904
  async hide() {
836
- editVisible.value = false;
837
- if (props.slideType !== "box") {
838
- await nextTick();
839
- boxVisible.value = false;
840
- }
905
+ boxVisible.value = false;
841
906
  }
842
907
  });
843
908
  return (_ctx, _cache) => {
844
909
  return openBlock(), createElementBlock(Fragment, null, [
845
- createVNode(_sfc_main$Q, {
910
+ createVNode(_sfc_main$P, {
846
911
  visible: boxVisible.value,
847
- "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
912
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
848
913
  width: width.value,
849
- "onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
914
+ "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
850
915
  height: unref(codeBlockEditorHeight),
851
- "onUpdate:height": _cache[2] || (_cache[2] = ($event) => isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
916
+ "onUpdate:height": _cache[3] || (_cache[3] = ($event) => isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
852
917
  title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
853
- position: boxPosition.value,
918
+ position: unref(boxPosition),
854
919
  "before-close": beforeClose
855
920
  }, {
856
921
  body: withCtx(() => [
857
- createElementVNode("div", {
858
- ref_key: "floatingBoxBody",
859
- ref: floatingBoxBody,
860
- style: { "height": "100%" }
861
- }, null, 512)
922
+ createVNode(unref(MFormBox), {
923
+ class: "m-editor-code-block-editor",
924
+ ref_key: "formBox",
925
+ ref: formBox,
926
+ "label-width": "80px",
927
+ "close-on-press-escape": false,
928
+ title: _ctx.content.name,
929
+ config: functionConfig.value,
930
+ values: _ctx.content,
931
+ disabled: _ctx.disabled,
932
+ style: { "height": "100%" },
933
+ onChange: changeHandler,
934
+ onSubmit: submitForm,
935
+ onError: errorHandler,
936
+ onClosed: closedHandler
937
+ }, {
938
+ left: withCtx(() => [
939
+ !_ctx.disabled ? (openBlock(), createBlock(unref(TMagicButton), {
940
+ key: 0,
941
+ type: "primary",
942
+ link: "",
943
+ onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
944
+ }, {
945
+ default: withCtx(() => [
946
+ createTextVNode("查看修改")
947
+ ]),
948
+ _: 1
949
+ })) : createCommentVNode("", true)
950
+ ]),
951
+ _: 1
952
+ }, 8, ["title", "config", "values", "disabled"])
862
953
  ]),
863
954
  _: 1
864
955
  }, 8, ["visible", "width", "height", "title", "position"]),
865
- editVisible.value ? (openBlock(), createBlock(Teleport, {
866
- key: 0,
867
- to: floatingBoxBody.value,
868
- disabled: _ctx.slideType === "box"
869
- }, [
870
- createVNode(unref(MFormBox), {
871
- class: "m-editor-code-block-editor",
872
- ref_key: "formBox",
873
- ref: formBox,
874
- "label-width": "80px",
875
- "close-on-press-escape": false,
876
- title: _ctx.content.name,
877
- config: functionConfig.value,
878
- values: _ctx.content,
879
- disabled: _ctx.disabled,
880
- height: floatingBoxBody.value?.clientHeight,
881
- onChange: changeHandler,
882
- onSubmit: submitForm,
883
- onError: errorHandler,
884
- onClosed: closedHandler
956
+ (openBlock(), createBlock(Teleport, { to: "body" }, [
957
+ createVNode(unref(TMagicDialog), {
958
+ title: "查看修改",
959
+ modelValue: difVisible.value,
960
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
961
+ fullscreen: ""
885
962
  }, {
886
- left: withCtx(() => [
887
- !_ctx.disabled ? (openBlock(), createBlock(unref(TMagicButton), {
888
- key: 0,
889
- type: "primary",
890
- link: "",
891
- onClick: _cache[3] || (_cache[3] = ($event) => difVisible.value = true)
892
- }, {
893
- default: withCtx(() => [
894
- createTextVNode("查看修改")
895
- ]),
896
- _: 1
897
- })) : createCommentVNode("", true)
898
- ]),
899
- _: 1
900
- }, 8, ["title", "config", "values", "disabled", "height"])
901
- ], 8, ["to", "disabled"])) : createCommentVNode("", true),
902
- createVNode(unref(TMagicDialog), {
903
- modelValue: difVisible.value,
904
- "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
905
- title: "查看修改",
906
- fullscreen: ""
907
- }, {
908
- footer: withCtx(() => [
909
- createElementVNode("span", _hoisted_4$7, [
910
- createVNode(unref(TMagicButton), {
911
- size: "small",
912
- onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
913
- }, {
914
- default: withCtx(() => [
915
- createTextVNode("取消")
916
- ]),
917
- _: 1
918
- }),
919
- createVNode(unref(TMagicButton), {
920
- size: "small",
921
- type: "primary",
922
- onClick: diffChange
923
- }, {
924
- default: withCtx(() => [
925
- createTextVNode("确定")
926
- ]),
927
- _: 1
928
- })
929
- ])
930
- ]),
931
- default: withCtx(() => [
932
- createElementVNode("div", _hoisted_1$s, [
933
- createElementVNode("div", _hoisted_2$k, [
934
- createVNode(unref(TMagicTag), {
963
+ footer: withCtx(() => [
964
+ createElementVNode("span", _hoisted_4$7, [
965
+ createVNode(unref(TMagicButton), {
935
966
  size: "small",
936
- type: "info"
967
+ onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
937
968
  }, {
938
969
  default: withCtx(() => [
939
- createTextVNode("修改前")
970
+ createTextVNode("取消")
940
971
  ]),
941
972
  _: 1
942
- })
943
- ]),
944
- createElementVNode("div", _hoisted_3$8, [
945
- createVNode(unref(TMagicTag), {
973
+ }),
974
+ createVNode(unref(TMagicButton), {
946
975
  size: "small",
947
- type: "success"
976
+ type: "primary",
977
+ onClick: diffChange
948
978
  }, {
949
979
  default: withCtx(() => [
950
- createTextVNode("修改后")
980
+ createTextVNode("确定")
951
981
  ]),
952
982
  _: 1
953
983
  })
954
984
  ])
955
985
  ]),
956
- difVisible.value ? (openBlock(), createBlock(_sfc_main$U, {
957
- key: 0,
958
- ref_key: "magicVsEditor",
959
- ref: magicVsEditor,
960
- type: "diff",
961
- language: "json",
962
- initValues: _ctx.content.content,
963
- modifiedValues: formBox.value?.form?.values.content,
964
- style: normalizeStyle(`height: ${unref(windowRect).height - 150}px`)
965
- }, null, 8, ["initValues", "modifiedValues", "style"])) : createCommentVNode("", true)
966
- ]),
967
- _: 1
968
- }, 8, ["modelValue"])
986
+ default: withCtx(() => [
987
+ createElementVNode("div", _hoisted_1$r, [
988
+ createElementVNode("div", _hoisted_2$k, [
989
+ createVNode(unref(TMagicTag), {
990
+ size: "small",
991
+ type: "info"
992
+ }, {
993
+ default: withCtx(() => [
994
+ createTextVNode("修改前")
995
+ ]),
996
+ _: 1
997
+ })
998
+ ]),
999
+ createElementVNode("div", _hoisted_3$8, [
1000
+ createVNode(unref(TMagicTag), {
1001
+ size: "small",
1002
+ type: "success"
1003
+ }, {
1004
+ default: withCtx(() => [
1005
+ createTextVNode("修改后")
1006
+ ]),
1007
+ _: 1
1008
+ })
1009
+ ])
1010
+ ]),
1011
+ difVisible.value ? (openBlock(), createBlock(_sfc_main$T, {
1012
+ key: 0,
1013
+ ref_key: "magicVsEditor",
1014
+ ref: magicVsEditor,
1015
+ type: "diff",
1016
+ language: "json",
1017
+ initValues: _ctx.content.content,
1018
+ modifiedValues: formBox.value?.form?.values.content,
1019
+ style: normalizeStyle(`height: ${unref(windowRect).height - 150}px`)
1020
+ }, null, 8, ["initValues", "modifiedValues", "style"])) : createCommentVNode("", true)
1021
+ ]),
1022
+ _: 1
1023
+ }, 8, ["modelValue"])
1024
+ ]))
969
1025
  ], 64);
970
1026
  };
971
1027
  }
@@ -3641,7 +3697,7 @@ const getDefaultConfig = async (addNode, parentNode) => {
3641
3697
  return newNode;
3642
3698
  };
3643
3699
 
3644
- const _sfc_main$O = /* @__PURE__ */ defineComponent({
3700
+ const _sfc_main$N = /* @__PURE__ */ defineComponent({
3645
3701
  ...{
3646
3702
  name: "MEditorCodeParams"
3647
3703
  },
@@ -3691,50 +3747,6 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
3691
3747
  }
3692
3748
  });
3693
3749
 
3694
- const _hoisted_1$r = ["src"];
3695
- const _sfc_main$N = /* @__PURE__ */ defineComponent({
3696
- ...{
3697
- name: "MEditorIcon"
3698
- },
3699
- __name: "Icon",
3700
- props: {
3701
- icon: {}
3702
- },
3703
- setup(__props) {
3704
- const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
3705
- return (_ctx, _cache) => {
3706
- return !_ctx.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
3707
- key: 0,
3708
- class: "magic-editor-icon"
3709
- }, {
3710
- default: withCtx(() => [
3711
- createVNode(unref(Edit))
3712
- ]),
3713
- _: 1
3714
- })) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (openBlock(), createBlock(unref(TMagicIcon), {
3715
- key: 1,
3716
- class: "magic-editor-icon"
3717
- }, {
3718
- default: withCtx(() => [
3719
- createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$r)
3720
- ]),
3721
- _: 1
3722
- })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
3723
- key: 2,
3724
- class: normalizeClass(["magic-editor-icon", _ctx.icon])
3725
- }, null, 2)) : (openBlock(), createBlock(unref(TMagicIcon), {
3726
- key: 3,
3727
- class: "magic-editor-icon"
3728
- }, {
3729
- default: withCtx(() => [
3730
- (openBlock(), createBlock(resolveDynamicComponent(toRaw(_ctx.icon))))
3731
- ]),
3732
- _: 1
3733
- }));
3734
- };
3735
- }
3736
- });
3737
-
3738
3750
  const useCodeBlockEdit = (codeBlockService) => {
3739
3751
  const codeConfig = ref();
3740
3752
  const codeId = ref();
@@ -3881,14 +3893,14 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
3881
3893
  size: _ctx.size,
3882
3894
  onChange: onParamsChangeHandler
3883
3895
  }, null, 8, ["model", "size"]),
3884
- _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$N, {
3896
+ _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$U, {
3885
3897
  key: 0,
3886
3898
  class: "icon",
3887
3899
  icon: !notEditable.value ? unref(Edit) : unref(View),
3888
3900
  onClick: _cache[0] || (_cache[0] = ($event) => unref(editCode)(_ctx.model[_ctx.name]))
3889
3901
  }, null, 8, ["icon"])) : createCommentVNode("", true)
3890
3902
  ]),
3891
- paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$O, {
3903
+ paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$N, {
3892
3904
  name: "params",
3893
3905
  key: _ctx.model[_ctx.name],
3894
3906
  model: _ctx.model,
@@ -3896,7 +3908,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
3896
3908
  "params-config": paramsConfig.value,
3897
3909
  onChange: onParamsChangeHandler
3898
3910
  }, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true),
3899
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$P, {
3911
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
3900
3912
  key: 1,
3901
3913
  ref_key: "codeBlockEditor",
3902
3914
  ref: codeBlockEditor,
@@ -3909,62 +3921,406 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
3909
3921
  }
3910
3922
  });
3911
3923
 
3912
- const _hoisted_1$p = { class: "m-editor-data-source-fields" };
3913
- const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
3914
- const _sfc_main$L = /* @__PURE__ */ defineComponent({
3915
- ...{
3916
- name: "MFieldsDataSourceFields"
3917
- },
3918
- __name: "DataSourceFields",
3919
- props: {
3920
- config: {},
3921
- model: {},
3922
- initValues: {},
3923
- values: {},
3924
- name: {},
3925
- prop: {},
3926
- disabled: { type: Boolean, default: false },
3927
- size: {},
3928
- lastValues: {}
3929
- },
3930
- emits: ["change"],
3931
- setup(__props, { emit: __emit }) {
3932
- const props = __props;
3933
- const emit = __emit;
3934
- const services = inject("services");
3935
- const addDialog = ref();
3936
- const fieldValues = ref({});
3937
- const fieldTitle = ref("");
3938
- const width = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
3939
- const newHandler = () => {
3940
- fieldValues.value = {};
3941
- fieldTitle.value = "新增属性";
3942
- addDialog.value?.show();
3943
- };
3944
- const fieldChange = ({ index, ...value }) => {
3945
- if (index > -1) {
3946
- props.model[props.name][index] = value;
3947
- } else {
3948
- props.model[props.name].push(value);
3949
- }
3950
- addDialog.value?.hide();
3951
- emit("change", props.model[props.name]);
3952
- };
3953
- const fieldColumns = [
3954
- {
3955
- label: "属性名称",
3956
- prop: "title"
3957
- },
3958
- {
3959
- label: "属性key",
3960
- prop: "name"
3961
- },
3962
- {
3963
- label: "属性描述",
3964
- prop: "description"
3965
- },
3966
- {
3967
- label: "默认值",
3924
+ const useDataSourceMethod = () => {
3925
+ const codeConfig = ref();
3926
+ const codeBlockEditor = ref();
3927
+ const dataSource = ref();
3928
+ const dataSourceMethod = ref("");
3929
+ return {
3930
+ codeConfig,
3931
+ codeBlockEditor,
3932
+ createCode: async (model) => {
3933
+ codeConfig.value = {
3934
+ name: "",
3935
+ content: `({ params, dataSource, app }) => {
3936
+ // place your code here
3937
+ }`,
3938
+ params: []
3939
+ };
3940
+ await nextTick();
3941
+ dataSource.value = model;
3942
+ dataSourceMethod.value = "";
3943
+ codeBlockEditor.value?.show();
3944
+ },
3945
+ editCode: async (model, methodName) => {
3946
+ const method = model.methods?.find((method2) => method2.name === methodName);
3947
+ if (!method) {
3948
+ tMagicMessage.error("获取数据源方法失败");
3949
+ return;
3950
+ }
3951
+ let codeContent = method.content;
3952
+ if (typeof codeContent !== "string") {
3953
+ codeContent = codeContent.toString();
3954
+ }
3955
+ codeConfig.value = {
3956
+ ...cloneDeep(method),
3957
+ content: codeContent
3958
+ };
3959
+ await nextTick();
3960
+ dataSource.value = model;
3961
+ dataSourceMethod.value = methodName;
3962
+ codeBlockEditor.value?.show();
3963
+ },
3964
+ deleteCode: async (model, methodName) => {
3965
+ if (!model.methods)
3966
+ return;
3967
+ const index = model.methods.findIndex((method) => method.name === methodName);
3968
+ if (index === -1) {
3969
+ return;
3970
+ }
3971
+ model.methods.splice(index, 1);
3972
+ },
3973
+ submitCode: (values) => {
3974
+ if (!dataSource.value)
3975
+ return;
3976
+ if (!dataSource.value.methods) {
3977
+ dataSource.value.methods = [];
3978
+ }
3979
+ if (values.content) {
3980
+ const parseDSL = getConfig("parseDSL");
3981
+ if (typeof values.content === "string") {
3982
+ values.content = parseDSL(values.content);
3983
+ }
3984
+ }
3985
+ if (dataSourceMethod.value) {
3986
+ const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
3987
+ dataSource.value.methods.splice(index, 1, values);
3988
+ } else {
3989
+ dataSource.value.methods.push(values);
3990
+ }
3991
+ codeBlockEditor.value?.hide();
3992
+ }
3993
+ };
3994
+ };
3995
+
3996
+ const state = reactive({
3997
+ uiSelectMode: false,
3998
+ showSrc: false,
3999
+ zoom: 1,
4000
+ stageContainerRect: {
4001
+ width: 0,
4002
+ height: 0
4003
+ },
4004
+ stageRect: {
4005
+ width: 375,
4006
+ height: 817
4007
+ },
4008
+ columnWidth: {
4009
+ left: 0,
4010
+ right: 0,
4011
+ center: 0
4012
+ },
4013
+ showGuides: true,
4014
+ showRule: true,
4015
+ propsPanelSize: "small",
4016
+ showAddPageButton: true,
4017
+ hideSlideBar: false,
4018
+ navMenuRect: {
4019
+ left: 0,
4020
+ top: 0,
4021
+ width: 0,
4022
+ height: 0
4023
+ },
4024
+ frameworkRect: {
4025
+ width: 0,
4026
+ height: 0,
4027
+ left: 0,
4028
+ top: 0
4029
+ }
4030
+ });
4031
+ const canUsePluginMethods$2 = {
4032
+ async: ["zoom", "calcZoom"],
4033
+ sync: []
4034
+ };
4035
+ class Ui extends BaseService {
4036
+ constructor() {
4037
+ super(canUsePluginMethods$2.async.map((methodName) => ({ name: methodName, isAsync: true })));
4038
+ }
4039
+ set(name, value) {
4040
+ const mask = editorService.get("stage")?.mask;
4041
+ if (name === "stageRect") {
4042
+ this.setStageRect(value);
4043
+ return;
4044
+ }
4045
+ if (name === "showGuides") {
4046
+ mask?.showGuides(value);
4047
+ }
4048
+ if (name === "showRule") {
4049
+ mask?.showRule(value);
4050
+ }
4051
+ state[name] = value;
4052
+ }
4053
+ get(name) {
4054
+ return state[name];
4055
+ }
4056
+ async zoom(zoom) {
4057
+ this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
4058
+ if (this.get("zoom") < 0.1)
4059
+ this.set("zoom", 0.1);
4060
+ }
4061
+ async calcZoom() {
4062
+ const { stageRect, stageContainerRect } = state;
4063
+ const { height, width } = stageContainerRect;
4064
+ if (!width || !height)
4065
+ return 1;
4066
+ let stageWidth = convertToNumber(stageRect.width, width);
4067
+ let stageHeight = convertToNumber(stageRect.height, height);
4068
+ stageWidth = stageWidth + 30;
4069
+ stageHeight = stageHeight + 30;
4070
+ if (width > stageWidth && height > stageHeight) {
4071
+ return 1;
4072
+ }
4073
+ return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
4074
+ }
4075
+ resetState() {
4076
+ this.set("showSrc", false);
4077
+ this.set("uiSelectMode", false);
4078
+ this.set("zoom", 1);
4079
+ this.set("stageContainerRect", {
4080
+ width: 0,
4081
+ height: 0
4082
+ });
4083
+ }
4084
+ destroy() {
4085
+ this.resetState();
4086
+ this.removeAllListeners();
4087
+ this.removeAllPlugins();
4088
+ }
4089
+ usePlugin(options) {
4090
+ super.usePlugin(options);
4091
+ }
4092
+ async setStageRect(value) {
4093
+ state.stageRect = {
4094
+ ...state.stageRect,
4095
+ ...value
4096
+ };
4097
+ state.zoom = await this.calcZoom();
4098
+ }
4099
+ }
4100
+ const uiService = new Ui();
4101
+
4102
+ const root = computed(() => editorService.get("root"));
4103
+ const page = computed(() => editorService.get("page"));
4104
+ const zoom = computed(() => uiService.get("zoom") || 1);
4105
+ const uiSelectMode = computed(() => uiService.get("uiSelectMode"));
4106
+ const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
4107
+ const useStage = (stageOptions) => {
4108
+ const stage = new StageCore({
4109
+ render: stageOptions.render,
4110
+ runtimeUrl: stageOptions.runtimeUrl,
4111
+ zoom: zoom.value,
4112
+ autoScrollIntoView: stageOptions.autoScrollIntoView,
4113
+ isContainer: stageOptions.isContainer,
4114
+ containerHighlightClassName: stageOptions.containerHighlightClassName,
4115
+ containerHighlightDuration: stageOptions.containerHighlightDuration,
4116
+ containerHighlightType: stageOptions.containerHighlightType,
4117
+ disabledDragStart: stageOptions.disabledDragStart,
4118
+ renderType: stageOptions.renderType,
4119
+ canSelect: (el, event, stop) => {
4120
+ if (!stageOptions.canSelect)
4121
+ return true;
4122
+ const elCanSelect = stageOptions.canSelect?.(el);
4123
+ if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
4124
+ document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
4125
+ return stop();
4126
+ }
4127
+ return elCanSelect;
4128
+ },
4129
+ moveableOptions: stageOptions.moveableOptions,
4130
+ updateDragEl: stageOptions.updateDragEl,
4131
+ guidesOptions: stageOptions.guidesOptions,
4132
+ disabledMultiSelect: stageOptions.disabledMultiSelect
4133
+ });
4134
+ watch(
4135
+ () => editorService.get("disabledMultiSelect"),
4136
+ (disabledMultiSelect) => {
4137
+ if (disabledMultiSelect) {
4138
+ stage.disableMultiSelect();
4139
+ } else {
4140
+ stage.enableMultiSelect();
4141
+ }
4142
+ }
4143
+ );
4144
+ stage.mask.setGuides([
4145
+ getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
4146
+ getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
4147
+ ]);
4148
+ stage.on("page-el-update", () => {
4149
+ editorService.set("stageLoading", false);
4150
+ });
4151
+ stage.on("select", (el) => {
4152
+ if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
4153
+ return;
4154
+ editorService.select(el.id);
4155
+ });
4156
+ stage.on("highlight", (el) => {
4157
+ editorService.highlight(el.id);
4158
+ });
4159
+ stage.on("multi-select", (els) => {
4160
+ editorService.multiSelect(els.map((el) => el.id));
4161
+ });
4162
+ stage.on("update", (ev) => {
4163
+ if (ev.parentEl) {
4164
+ for (const data of ev.data) {
4165
+ editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
4166
+ }
4167
+ return;
4168
+ }
4169
+ editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
4170
+ });
4171
+ stage.on("sort", (ev) => {
4172
+ editorService.sort(ev.src, ev.dist);
4173
+ });
4174
+ stage.on("remove", (ev) => {
4175
+ const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
4176
+ editorService.remove(nodes.filter((node) => Boolean(node)));
4177
+ });
4178
+ stage.on("select-parent", () => {
4179
+ const parent = editorService.get("parent");
4180
+ if (!parent)
4181
+ throw new Error("父节点为空");
4182
+ editorService.select(parent);
4183
+ editorService.get("stage")?.select(parent.id);
4184
+ });
4185
+ stage.on("change-guides", (e) => {
4186
+ uiService.set("showGuides", true);
4187
+ if (!root.value || !page.value)
4188
+ return;
4189
+ const storageKey = getGuideLineKey(
4190
+ e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
4191
+ );
4192
+ if (e.guides.length) {
4193
+ globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
4194
+ } else {
4195
+ globalThis.localStorage.removeItem(storageKey);
4196
+ }
4197
+ });
4198
+ return stage;
4199
+ };
4200
+
4201
+ const useFloatBox = (slideKeys) => {
4202
+ const services = inject("services");
4203
+ const floatBoxStates = ref(
4204
+ slideKeys.value.reduce(
4205
+ (total, cur) => ({
4206
+ ...total,
4207
+ [cur]: {
4208
+ status: false,
4209
+ top: 0,
4210
+ left: 0
4211
+ }
4212
+ }),
4213
+ {}
4214
+ )
4215
+ );
4216
+ const showingBoxKeys = computed(
4217
+ () => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
4218
+ );
4219
+ const isDragging = ref(false);
4220
+ const dragstartHandler = () => isDragging.value = true;
4221
+ const dragendHandler = (key, e) => {
4222
+ const navMenuRect = services?.uiService?.get("navMenuRect");
4223
+ floatBoxStates.value[key] = {
4224
+ left: e.clientX,
4225
+ top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0),
4226
+ status: true
4227
+ };
4228
+ isDragging.value = false;
4229
+ };
4230
+ document.body.addEventListener("dragover", (e) => {
4231
+ if (!isDragging.value)
4232
+ return;
4233
+ e.preventDefault();
4234
+ });
4235
+ watch(
4236
+ () => slideKeys.value,
4237
+ (slideKeys2) => {
4238
+ slideKeys2.forEach((key) => {
4239
+ if (!floatBoxStates.value[key]) {
4240
+ floatBoxStates.value[key] = {
4241
+ status: false,
4242
+ top: 0,
4243
+ left: 0
4244
+ };
4245
+ }
4246
+ });
4247
+ },
4248
+ {
4249
+ deep: true,
4250
+ immediate: true
4251
+ }
4252
+ );
4253
+ return {
4254
+ dragstartHandler,
4255
+ dragendHandler,
4256
+ floatBoxStates,
4257
+ showingBoxKeys
4258
+ };
4259
+ };
4260
+
4261
+ const _hoisted_1$p = { class: "m-editor-data-source-fields" };
4262
+ const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
4263
+ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4264
+ ...{
4265
+ name: "MFieldsDataSourceFields"
4266
+ },
4267
+ __name: "DataSourceFields",
4268
+ props: /* @__PURE__ */ mergeModels({
4269
+ config: {},
4270
+ model: {},
4271
+ initValues: {},
4272
+ values: {},
4273
+ name: {},
4274
+ prop: {},
4275
+ disabled: { type: Boolean, default: false },
4276
+ size: {},
4277
+ lastValues: {}
4278
+ }, {
4279
+ "width": { default: 670 },
4280
+ "widthModifiers": {},
4281
+ "visible": { type: Boolean, ...{ default: false } },
4282
+ "visibleModifiers": {},
4283
+ "visible1": { type: Boolean, ...{ default: false } },
4284
+ "visible1Modifiers": {}
4285
+ }),
4286
+ emits: /* @__PURE__ */ mergeModels(["change"], ["update:width", "update:visible", "update:visible1"]),
4287
+ setup(__props, { emit: __emit }) {
4288
+ const props = __props;
4289
+ const emit = __emit;
4290
+ const services = inject("services");
4291
+ const fieldValues = ref({});
4292
+ const fieldTitle = ref("");
4293
+ const width = useModel(__props, "width");
4294
+ const newHandler = () => {
4295
+ fieldValues.value = {};
4296
+ fieldTitle.value = "新增属性";
4297
+ calcBoxPosition();
4298
+ addDialogVisible.value = true;
4299
+ };
4300
+ const fieldChange = ({ index, ...value }) => {
4301
+ if (index > -1) {
4302
+ props.model[props.name][index] = value;
4303
+ } else {
4304
+ props.model[props.name].push(value);
4305
+ }
4306
+ addDialogVisible.value = false;
4307
+ emit("change", props.model[props.name]);
4308
+ };
4309
+ const fieldColumns = [
4310
+ {
4311
+ label: "属性名称",
4312
+ prop: "title"
4313
+ },
4314
+ {
4315
+ label: "属性key",
4316
+ prop: "name"
4317
+ },
4318
+ {
4319
+ label: "属性描述",
4320
+ prop: "description"
4321
+ },
4322
+ {
4323
+ label: "默认值",
3968
4324
  prop: "defaultValue",
3969
4325
  formatter(item, row) {
3970
4326
  try {
@@ -3986,7 +4342,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
3986
4342
  index
3987
4343
  };
3988
4344
  fieldTitle.value = `编辑${row.title}`;
3989
- addDialog.value?.show();
4345
+ calcBoxPosition();
4346
+ addDialogVisible.value = true;
3990
4347
  }
3991
4348
  },
3992
4349
  {
@@ -4084,7 +4441,6 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4084
4441
  display: (formState, { model }) => model.type === "object" || model.type === "array"
4085
4442
  }
4086
4443
  ];
4087
- const addFromJsonDialog = ref();
4088
4444
  const jsonFromConfig = [
4089
4445
  {
4090
4446
  name: "data",
@@ -4100,7 +4456,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4100
4456
  });
4101
4457
  const newFromJsonHandler = () => {
4102
4458
  jsonFromValues.value.data = getDefaultValueFromFields(props.model[props.name]);
4103
- addFromJsonDialog.value?.show();
4459
+ calcBoxPosition();
4460
+ addFromJsonDialogVisible.value = true;
4104
4461
  };
4105
4462
  const getValueType = (value) => {
4106
4463
  if (Array.isArray(value))
@@ -4146,12 +4503,17 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4146
4503
  try {
4147
4504
  const value = JSON.parse(data);
4148
4505
  props.model[props.name] = getFieldsConfig(value, props.model[props.name]);
4149
- addFromJsonDialog.value?.hide();
4506
+ addFromJsonDialogVisible.value = false;
4150
4507
  emit("change", props.model[props.name]);
4151
4508
  } catch (e) {
4152
4509
  tMagicMessage.error(e.message);
4153
4510
  }
4154
4511
  };
4512
+ const addDialogVisible = useModel(__props, "visible");
4513
+ const addFromJsonDialogVisible = useModel(__props, "visible1");
4514
+ const { height: editorHeight } = useEditorContentHeight();
4515
+ const parentFloating = inject("parentFloating", ref(null));
4516
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4155
4517
  return (_ctx, _cache) => {
4156
4518
  return openBlock(), createElementBlock("div", _hoisted_1$p, [
4157
4519
  createVNode(unref(MagicTable), {
@@ -4183,28 +4545,49 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4183
4545
  _: 1
4184
4546
  }, 8, ["disabled"])
4185
4547
  ]),
4186
- createVNode(unref(MFormDrawer), {
4187
- ref_key: "addDialog",
4188
- ref: addDialog,
4189
- "label-width": "80px",
4548
+ createVNode(_sfc_main$P, {
4549
+ visible: addDialogVisible.value,
4550
+ "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
4551
+ width: width.value,
4552
+ "onUpdate:width": _cache[3] || (_cache[3] = ($event) => width.value = $event),
4553
+ height: unref(editorHeight),
4554
+ "onUpdate:height": _cache[4] || (_cache[4] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
4190
4555
  title: fieldTitle.value,
4191
- config: dataSourceFieldsConfig,
4192
- values: fieldValues.value,
4193
- parentValues: _ctx.model[_ctx.name],
4194
- disabled: _ctx.disabled,
4556
+ position: unref(boxPosition)
4557
+ }, {
4558
+ body: withCtx(() => [
4559
+ createVNode(unref(MFormBox), {
4560
+ "label-width": "80px",
4561
+ title: fieldTitle.value,
4562
+ config: dataSourceFieldsConfig,
4563
+ values: fieldValues.value,
4564
+ parentValues: _ctx.model[_ctx.name],
4565
+ disabled: _ctx.disabled,
4566
+ onSubmit: fieldChange
4567
+ }, null, 8, ["title", "values", "parentValues", "disabled"])
4568
+ ]),
4569
+ _: 1
4570
+ }, 8, ["visible", "width", "height", "title", "position"]),
4571
+ createVNode(_sfc_main$P, {
4572
+ visible: addFromJsonDialogVisible.value,
4573
+ "onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
4195
4574
  width: width.value,
4196
- onSubmit: fieldChange
4197
- }, null, 8, ["title", "values", "parentValues", "disabled", "width"]),
4198
- createVNode(unref(MFormDrawer), {
4199
- ref_key: "addFromJsonDialog",
4200
- ref: addFromJsonDialog,
4575
+ "onUpdate:width": _cache[6] || (_cache[6] = ($event) => width.value = $event),
4576
+ height: unref(editorHeight),
4577
+ "onUpdate:height": _cache[7] || (_cache[7] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
4201
4578
  title: "快速添加数据定义",
4202
- config: jsonFromConfig,
4203
- values: jsonFromValues.value,
4204
- disabled: _ctx.disabled,
4205
- width: width.value,
4206
- onSubmit: addFromJsonFromChange
4207
- }, null, 8, ["values", "disabled", "width"])
4579
+ position: unref(boxPosition)
4580
+ }, {
4581
+ body: withCtx(() => [
4582
+ createVNode(unref(MFormBox), {
4583
+ config: jsonFromConfig,
4584
+ values: jsonFromValues.value,
4585
+ disabled: _ctx.disabled,
4586
+ onSubmit: addFromJsonFromChange
4587
+ }, null, 8, ["values", "disabled"])
4588
+ ]),
4589
+ _: 1
4590
+ }, 8, ["visible", "width", "height", "position"])
4208
4591
  ]);
4209
4592
  };
4210
4593
  }
@@ -4329,10 +4712,14 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
4329
4712
  style: { "margin-left": "5px" },
4330
4713
  link: "",
4331
4714
  type: showDataSourceFieldSelect.value ? "primary" : "default",
4332
- icon: unref(Coin),
4333
4715
  size: _ctx.size,
4334
4716
  onClick: _cache[0] || (_cache[0] = ($event) => showDataSourceFieldSelect.value = !showDataSourceFieldSelect.value)
4335
- }, null, 8, ["type", "icon", "size"])) : createCommentVNode("", true)
4717
+ }, {
4718
+ default: withCtx(() => [
4719
+ createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
4720
+ ]),
4721
+ _: 1
4722
+ }, 8, ["type", "size"])) : createCommentVNode("", true)
4336
4723
  ]);
4337
4724
  };
4338
4725
  }
@@ -4340,7 +4727,7 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
4340
4727
 
4341
4728
  const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4342
4729
  const _hoisted_2$h = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4343
- const _hoisted_3$7 = { class: "el-input__inner" };
4730
+ const _hoisted_3$7 = { class: "el-input__inner t-input__inner" };
4344
4731
  const _sfc_main$J = /* @__PURE__ */ defineComponent({
4345
4732
  ...{
4346
4733
  name: "MFieldsDataSourceInput"
@@ -4531,7 +4918,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4531
4918
  }
4532
4919
  ), {
4533
4920
  suffix: withCtx(() => [
4534
- createVNode(_sfc_main$N, { icon: unref(Coin) }, null, 8, ["icon"])
4921
+ createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
4535
4922
  ]),
4536
4923
  default: withCtx(({ item }) => [
4537
4924
  createElementVNode("div", _hoisted_1$n, [
@@ -4542,7 +4929,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4542
4929
  _: 1
4543
4930
  }, 16, ["modelValue"])) : (openBlock(), createElementBlock("div", {
4544
4931
  key: 1,
4545
- class: normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
4932
+ class: normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
4546
4933
  onMouseup: mouseupHandler
4547
4934
  }, [
4548
4935
  createElementVNode("div", {
@@ -4566,7 +4953,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4566
4953
  }, 1032, ["size"])) : createCommentVNode("", true)
4567
4954
  ], 64);
4568
4955
  }), 256)),
4569
- createVNode(_sfc_main$N, {
4956
+ createVNode(_sfc_main$U, {
4570
4957
  class: "tmagic-data-source-input-icon",
4571
4958
  icon: unref(Coin)
4572
4959
  }, null, 8, ["icon"])
@@ -4577,78 +4964,6 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4577
4964
  }
4578
4965
  });
4579
4966
 
4580
- const useDataSourceMethod = () => {
4581
- const codeConfig = ref();
4582
- const codeBlockEditor = ref();
4583
- const dataSource = ref();
4584
- const dataSourceMethod = ref("");
4585
- return {
4586
- codeConfig,
4587
- codeBlockEditor,
4588
- createCode: async (model) => {
4589
- codeConfig.value = {
4590
- name: "",
4591
- content: `({ params, dataSource, app }) => {
4592
- // place your code here
4593
- }`,
4594
- params: []
4595
- };
4596
- await nextTick();
4597
- dataSource.value = model;
4598
- dataSourceMethod.value = "";
4599
- codeBlockEditor.value?.show();
4600
- },
4601
- editCode: async (model, methodName) => {
4602
- const method = model.methods?.find((method2) => method2.name === methodName);
4603
- if (!method) {
4604
- tMagicMessage.error("获取数据源方法失败");
4605
- return;
4606
- }
4607
- let codeContent = method.content;
4608
- if (typeof codeContent !== "string") {
4609
- codeContent = codeContent.toString();
4610
- }
4611
- codeConfig.value = {
4612
- ...cloneDeep(method),
4613
- content: codeContent
4614
- };
4615
- await nextTick();
4616
- dataSource.value = model;
4617
- dataSourceMethod.value = methodName;
4618
- codeBlockEditor.value?.show();
4619
- },
4620
- deleteCode: async (model, methodName) => {
4621
- if (!model.methods)
4622
- return;
4623
- const index = model.methods.findIndex((method) => method.name === methodName);
4624
- if (index === -1) {
4625
- return;
4626
- }
4627
- model.methods.splice(index, 1);
4628
- },
4629
- submitCode: (values) => {
4630
- if (!dataSource.value)
4631
- return;
4632
- if (!dataSource.value.methods) {
4633
- dataSource.value.methods = [];
4634
- }
4635
- if (values.content) {
4636
- const parseDSL = getConfig("parseDSL");
4637
- if (typeof values.content === "string") {
4638
- values.content = parseDSL(values.content);
4639
- }
4640
- }
4641
- if (dataSourceMethod.value) {
4642
- const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
4643
- dataSource.value.methods.splice(index, 1, values);
4644
- } else {
4645
- dataSource.value.methods.push(values);
4646
- }
4647
- codeBlockEditor.value?.hide();
4648
- }
4649
- };
4650
- };
4651
-
4652
4967
  const _hoisted_1$m = { class: "m-editor-data-source-methods" };
4653
4968
  const _hoisted_2$g = { class: "m-editor-data-source-methods-footer" };
4654
4969
  const _sfc_main$I = /* @__PURE__ */ defineComponent({
@@ -4740,7 +5055,7 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
4740
5055
  _: 1
4741
5056
  }, 8, ["disabled"])
4742
5057
  ]),
4743
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$P, {
5058
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
4744
5059
  key: 0,
4745
5060
  ref_key: "codeBlockEditor",
4746
5061
  ref: codeBlockEditor,
@@ -4856,14 +5171,14 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
4856
5171
  model: _ctx.model,
4857
5172
  onChange: onChangeHandler
4858
5173
  }, null, 8, ["config", "model"]),
4859
- _ctx.model[_ctx.name] && isCustomMethod.value ? (openBlock(), createBlock(_sfc_main$N, {
5174
+ _ctx.model[_ctx.name] && isCustomMethod.value ? (openBlock(), createBlock(_sfc_main$U, {
4860
5175
  key: 0,
4861
5176
  class: "icon",
4862
5177
  icon: !notEditable.value ? unref(Edit) : unref(View),
4863
5178
  onClick: editCodeHandler
4864
5179
  }, null, 8, ["icon"])) : createCommentVNode("", true)
4865
5180
  ]),
4866
- paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$O, {
5181
+ paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$N, {
4867
5182
  key: 0,
4868
5183
  name: "params",
4869
5184
  model: _ctx.model,
@@ -4872,7 +5187,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
4872
5187
  "params-config": paramsConfig.value,
4873
5188
  onChange: onChangeHandler
4874
5189
  }, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true),
4875
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$P, {
5190
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
4876
5191
  key: 1,
4877
5192
  ref_key: "codeBlockEditor",
4878
5193
  ref: codeBlockEditor,
@@ -4892,7 +5207,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
4892
5207
  name: "MFieldsDataSourceMocks"
4893
5208
  },
4894
5209
  __name: "DataSourceMocks",
4895
- props: {
5210
+ props: /* @__PURE__ */ mergeModels({
4896
5211
  config: {},
4897
5212
  model: {},
4898
5213
  initValues: {},
@@ -4902,14 +5217,18 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
4902
5217
  disabled: { type: Boolean, default: false },
4903
5218
  size: {},
4904
5219
  lastValues: {}
4905
- },
4906
- emits: ["change"],
5220
+ }, {
5221
+ "width": { default: 670 },
5222
+ "widthModifiers": {},
5223
+ "visible": { type: Boolean, ...{ default: false } },
5224
+ "visibleModifiers": {}
5225
+ }),
5226
+ emits: /* @__PURE__ */ mergeModels(["change"], ["update:width", "update:visible"]),
4907
5227
  setup(__props, { emit: __emit }) {
4908
5228
  const props = __props;
4909
5229
  const emit = __emit;
4910
5230
  const services = inject("services");
4911
- const width = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
4912
- const addDialog = ref();
5231
+ const width = useModel(__props, "width");
4913
5232
  const drawerTitle = ref("");
4914
5233
  const formValues = ref({});
4915
5234
  const formConfig = [
@@ -4974,7 +5293,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
4974
5293
  const columns = [
4975
5294
  {
4976
5295
  type: "expand",
4977
- component: _sfc_main$U,
5296
+ component: _sfc_main$T,
4978
5297
  props: (row) => ({
4979
5298
  initValues: row.data,
4980
5299
  language: "json",
@@ -5036,7 +5355,8 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5036
5355
  index
5037
5356
  };
5038
5357
  drawerTitle.value = `编辑${row.title}`;
5039
- addDialog.value?.show();
5358
+ calcBoxPosition();
5359
+ addDialogVisible.value = true;
5040
5360
  }
5041
5361
  },
5042
5362
  {
@@ -5059,7 +5379,8 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5059
5379
  enable: isFirstRow
5060
5380
  };
5061
5381
  drawerTitle.value = "新增Mock";
5062
- addDialog.value?.show();
5382
+ calcBoxPosition();
5383
+ addDialogVisible.value = true;
5063
5384
  };
5064
5385
  const formChangeHandler = ({ index, ...value }) => {
5065
5386
  if (index > -1) {
@@ -5067,7 +5388,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5067
5388
  } else {
5068
5389
  props.model[props.name].push(value);
5069
5390
  }
5070
- addDialog.value?.hide();
5391
+ addDialogVisible.value = false;
5071
5392
  emit("change", props.model[props.name]);
5072
5393
  };
5073
5394
  const toggleValue = (row, key, value, index) => {
@@ -5082,6 +5403,10 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5082
5403
  index
5083
5404
  });
5084
5405
  };
5406
+ const addDialogVisible = useModel(__props, "visible");
5407
+ const { height: editorHeight } = useEditorContentHeight();
5408
+ const parentFloating = inject("parentFloating", ref(null));
5409
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
5085
5410
  return (_ctx, _cache) => {
5086
5411
  return openBlock(), createElementBlock("div", _hoisted_1$k, [
5087
5412
  createVNode(unref(MagicTable), {
@@ -5102,18 +5427,29 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5102
5427
  _: 1
5103
5428
  }, 8, ["disabled"])
5104
5429
  ]),
5105
- createVNode(unref(MFormDrawer), {
5106
- ref_key: "addDialog",
5107
- ref: addDialog,
5108
- "label-width": "120px",
5109
- title: drawerTitle.value,
5110
- config: formConfig,
5111
- values: formValues.value,
5112
- parentValues: _ctx.model[_ctx.name],
5113
- disabled: _ctx.disabled,
5430
+ createVNode(_sfc_main$P, {
5431
+ visible: addDialogVisible.value,
5432
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
5114
5433
  width: width.value,
5115
- onSubmit: formChangeHandler
5116
- }, null, 8, ["title", "values", "parentValues", "disabled", "width"])
5434
+ "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
5435
+ height: unref(editorHeight),
5436
+ "onUpdate:height": _cache[3] || (_cache[3] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
5437
+ title: drawerTitle.value,
5438
+ position: unref(boxPosition)
5439
+ }, {
5440
+ body: withCtx(() => [
5441
+ createVNode(unref(MFormBox), {
5442
+ ref: "addDialog",
5443
+ "label-width": "120px",
5444
+ config: formConfig,
5445
+ values: formValues.value,
5446
+ parentValues: _ctx.model[_ctx.name],
5447
+ disabled: _ctx.disabled,
5448
+ onSubmit: formChangeHandler
5449
+ }, null, 8, ["values", "parentValues", "disabled"])
5450
+ ]),
5451
+ _: 1
5452
+ }, 8, ["visible", "width", "height", "title", "position"])
5117
5453
  ]);
5118
5454
  };
5119
5455
  }
@@ -5578,7 +5914,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
5578
5914
  _: 1
5579
5915
  }, 8, ["size", "disabled", "icon"])
5580
5916
  ])) : createCommentVNode("", true),
5581
- _ctx.config.advanced && showCode.value ? (openBlock(), createBlock(_sfc_main$U, {
5917
+ _ctx.config.advanced && showCode.value ? (openBlock(), createBlock(_sfc_main$T, {
5582
5918
  key: 1,
5583
5919
  height: "200px",
5584
5920
  "init-values": _ctx.model[_ctx.name],
@@ -5659,7 +5995,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
5659
5995
  size: _ctx.size,
5660
5996
  onChange: changeHandler
5661
5997
  }, null, 8, ["model", "size"]),
5662
- _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$N, {
5998
+ _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$U, {
5663
5999
  key: 0,
5664
6000
  class: "icon",
5665
6001
  icon: unref(Edit),
@@ -6144,7 +6480,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
6144
6480
  disabled: disabled.value
6145
6481
  }, {
6146
6482
  default: withCtx(() => [
6147
- _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$N, {
6483
+ _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$U, {
6148
6484
  key: 0,
6149
6485
  icon: _ctx.data.icon
6150
6486
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -6162,7 +6498,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
6162
6498
  title: _ctx.data.text
6163
6499
  }, {
6164
6500
  default: withCtx(() => [
6165
- _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$N, {
6501
+ _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$U, {
6166
6502
  key: 0,
6167
6503
  icon: _ctx.data.icon
6168
6504
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -6250,7 +6586,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
6250
6586
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
6251
6587
  onClick: addPage
6252
6588
  }, [
6253
- createVNode(_sfc_main$N, { icon: unref(Plus) }, null, 8, ["icon"])
6589
+ createVNode(_sfc_main$U, { icon: unref(Plus) }, null, 8, ["icon"])
6254
6590
  ])) : (openBlock(), createElementBlock("div", _hoisted_1$d));
6255
6591
  };
6256
6592
  }
@@ -6362,7 +6698,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
6362
6698
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
6363
6699
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
6364
6700
  }, [
6365
- createVNode(_sfc_main$N, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
6701
+ createVNode(_sfc_main$U, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
6366
6702
  ])) : createCommentVNode("", true),
6367
6703
  _ctx.type === unref(NodeType).PAGE && pageLength.value || _ctx.type === unref(NodeType).PAGE_FRAGMENT && pageFragmentLength.value ? (openBlock(), createElementBlock("div", {
6368
6704
  key: 1,
@@ -6378,7 +6714,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
6378
6714
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
6379
6715
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
6380
6716
  }, [
6381
- createVNode(_sfc_main$N, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
6717
+ createVNode(_sfc_main$U, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
6382
6718
  ])) : createCommentVNode("", true)
6383
6719
  ], 512);
6384
6720
  };
@@ -6618,7 +6954,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6618
6954
  onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(NodeType).PAGE))
6619
6955
  }, [
6620
6956
  createElementVNode("div", null, [
6621
- createVNode(_sfc_main$N, { icon: unref(Plus) }, null, 8, ["icon"])
6957
+ createVNode(_sfc_main$U, { icon: unref(Plus) }, null, 8, ["icon"])
6622
6958
  ]),
6623
6959
  _hoisted_3$4
6624
6960
  ]),
@@ -6628,7 +6964,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6628
6964
  onClick: _cache[1] || (_cache[1] = ($event) => clickHandler(unref(NodeType).PAGE_FRAGMENT))
6629
6965
  }, [
6630
6966
  createElementVNode("div", null, [
6631
- createVNode(_sfc_main$N, { icon: unref(Plus) }, null, 8, ["icon"])
6967
+ createVNode(_sfc_main$U, { icon: unref(Plus) }, null, 8, ["icon"])
6632
6968
  ]),
6633
6969
  _hoisted_4$4
6634
6970
  ])) : createCommentVNode("", true)
@@ -6719,7 +7055,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6719
7055
  renderSlot(_ctx.$slots, "nav"),
6720
7056
  renderSlot(_ctx.$slots, "content-before"),
6721
7057
  showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
6722
- createVNode(_sfc_main$U, {
7058
+ createVNode(_sfc_main$T, {
6723
7059
  class: "m-editor-content",
6724
7060
  "init-values": root.value,
6725
7061
  options: unref(codeOptions),
@@ -7055,89 +7391,35 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
7055
7391
  config: curFormConfig.value,
7056
7392
  "extend-state": _ctx.extendState,
7057
7393
  onChange: submit,
7058
- onError: errorHandler
7059
- }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"]),
7060
- createVNode(unref(TMagicButton), {
7061
- class: "m-editor-props-panel-src-icon",
7062
- circle: "",
7063
- size: "large",
7064
- title: "源码",
7065
- icon: unref(Document),
7066
- type: showSrc.value ? "primary" : "",
7067
- onClick: _cache[0] || (_cache[0] = ($event) => showSrc.value = !showSrc.value)
7068
- }, null, 8, ["icon", "type"]),
7069
- showSrc.value ? (openBlock(), createBlock(_sfc_main$U, {
7070
- key: 0,
7071
- height: `${unref(editorContentHeight)}px`,
7072
- "init-values": values.value,
7073
- options: unref(codeOptions),
7074
- parse: true,
7075
- onSave: saveCode
7076
- }, null, 8, ["height", "init-values", "options"])) : createCommentVNode("", true)
7077
- ], 512)), [
7078
- [vShow, nodes.value.length === 1]
7079
- ]);
7080
- };
7081
- }
7082
- });
7083
-
7084
- const useFloatBox = (slideKeys) => {
7085
- const floatBoxStates = ref(
7086
- slideKeys.value.reduce(
7087
- (total, cur) => ({
7088
- ...total,
7089
- [cur]: {
7090
- status: false,
7091
- top: 0,
7092
- left: 0
7093
- }
7094
- }),
7095
- {}
7096
- )
7097
- );
7098
- const showingBoxKeys = computed(
7099
- () => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
7100
- );
7101
- const isDragging = ref(false);
7102
- const dragstartHandler = () => isDragging.value = true;
7103
- const dragendHandler = (key, e) => {
7104
- floatBoxStates.value[key] = {
7105
- left: e.clientX,
7106
- top: e.clientY,
7107
- status: true
7108
- };
7109
- isDragging.value = false;
7110
- };
7111
- document.body.addEventListener("dragover", (e) => {
7112
- if (!isDragging.value)
7113
- return;
7114
- e.preventDefault();
7115
- });
7116
- watch(
7117
- () => slideKeys.value,
7118
- (slideKeys2) => {
7119
- slideKeys2.forEach((key) => {
7120
- if (floatBoxStates.value[key])
7121
- return;
7122
- floatBoxStates.value[key] = {
7123
- status: false,
7124
- top: 0,
7125
- left: 0
7126
- };
7127
- });
7128
- },
7129
- {
7130
- deep: true,
7131
- immediate: true
7132
- }
7133
- );
7134
- return {
7135
- dragstartHandler,
7136
- dragendHandler,
7137
- floatBoxStates,
7138
- showingBoxKeys
7139
- };
7140
- };
7394
+ onError: errorHandler
7395
+ }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"]),
7396
+ createVNode(unref(TMagicButton), {
7397
+ class: "m-editor-props-panel-src-icon",
7398
+ circle: "",
7399
+ size: "large",
7400
+ title: "源码",
7401
+ type: showSrc.value ? "primary" : "",
7402
+ onClick: _cache[0] || (_cache[0] = ($event) => showSrc.value = !showSrc.value)
7403
+ }, {
7404
+ default: withCtx(() => [
7405
+ createVNode(_sfc_main$U, { icon: unref(Document) }, null, 8, ["icon"])
7406
+ ]),
7407
+ _: 1
7408
+ }, 8, ["type"]),
7409
+ showSrc.value ? (openBlock(), createBlock(_sfc_main$T, {
7410
+ key: 0,
7411
+ height: `${unref(editorContentHeight)}px`,
7412
+ "init-values": values.value,
7413
+ options: unref(codeOptions),
7414
+ parse: true,
7415
+ onSave: saveCode
7416
+ }, null, 8, ["height", "init-values", "options"])) : createCommentVNode("", true)
7417
+ ], 512)), [
7418
+ [vShow, nodes.value.length === 1]
7419
+ ]);
7420
+ };
7421
+ }
7422
+ });
7141
7423
 
7142
7424
  const _sfc_main$o = /* @__PURE__ */ defineComponent({
7143
7425
  ...{
@@ -7264,7 +7546,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
7264
7546
  onContextmenu: nodeContentmenuHandler,
7265
7547
  onMouseenter: mouseenterHandler
7266
7548
  }, [
7267
- createVNode(_sfc_main$N, {
7549
+ createVNode(_sfc_main$U, {
7268
7550
  class: "expand-icon",
7269
7551
  style: normalizeStyle(hasChildren.value ? "" : "color: transparent; cursor: default"),
7270
7552
  icon: expanded.value ? unref(ArrowDown) : unref(ArrowRight),
@@ -7543,7 +7825,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
7543
7825
  placement: "bottom"
7544
7826
  }, {
7545
7827
  default: withCtx(() => [
7546
- createVNode(_sfc_main$N, {
7828
+ createVNode(_sfc_main$U, {
7547
7829
  icon: editable.value ? unref(Edit) : unref(View),
7548
7830
  class: "edit-icon",
7549
7831
  onClick: withModifiers(($event) => editCode(`${data.key}`), ["stop"])
@@ -7558,7 +7840,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
7558
7840
  placement: "bottom"
7559
7841
  }, {
7560
7842
  default: withCtx(() => [
7561
- createVNode(_sfc_main$N, {
7843
+ createVNode(_sfc_main$U, {
7562
7844
  icon: unref(Close),
7563
7845
  class: "edit-icon",
7564
7846
  onClick: withModifiers(($event) => deleteCode(`${data.key}`), ["stop"])
@@ -7584,8 +7866,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
7584
7866
  },
7585
7867
  __name: "CodeBlockListPanel",
7586
7868
  props: {
7587
- customError: { type: Function },
7588
- slideType: {}
7869
+ customError: { type: Function }
7589
7870
  },
7590
7871
  setup(__props) {
7591
7872
  const { codeBlockService } = inject("services") || {};
@@ -7635,15 +7916,14 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
7635
7916
  ]),
7636
7917
  _: 3
7637
7918
  }),
7638
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$P, {
7919
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
7639
7920
  key: 0,
7640
7921
  ref_key: "codeBlockEditor",
7641
7922
  ref: codeBlockEditor,
7642
7923
  disabled: !editable.value,
7643
7924
  content: unref(codeConfig),
7644
- slideType: _ctx.slideType,
7645
7925
  onSubmit: unref(submitCodeBlockHandler)
7646
- }, null, 8, ["disabled", "content", "slideType", "onSubmit"])) : createCommentVNode("", true)
7926
+ }, null, 8, ["disabled", "content", "onSubmit"])) : createCommentVNode("", true)
7647
7927
  ], 64);
7648
7928
  };
7649
7929
  }
@@ -7654,21 +7934,28 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
7654
7934
  name: "MEditorDataSourceConfigPanel"
7655
7935
  },
7656
7936
  __name: "DataSourceConfigPanel",
7657
- props: {
7937
+ props: /* @__PURE__ */ mergeModels({
7658
7938
  title: {},
7659
7939
  values: {},
7660
- disabled: { type: Boolean },
7661
- slideType: {}
7662
- },
7663
- emits: ["submit"],
7940
+ disabled: { type: Boolean }
7941
+ }, {
7942
+ "visible": { type: Boolean, ...{ default: false } },
7943
+ "visibleModifiers": {},
7944
+ "width": { default: 670 },
7945
+ "widthModifiers": {}
7946
+ }),
7947
+ emits: /* @__PURE__ */ mergeModels(["submit"], ["update:visible", "update:width"]),
7664
7948
  setup(__props, { expose: __expose, emit: __emit }) {
7665
7949
  const props = __props;
7950
+ const boxVisible = useModel(__props, "visible");
7951
+ const width = useModel(__props, "width");
7666
7952
  const emit = __emit;
7667
7953
  const services = inject("services");
7668
- const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
7669
- const fomDrawer = ref();
7670
7954
  const initValues = ref({});
7671
7955
  const dataSourceConfig = ref([]);
7956
+ const { height: editorHeight } = useEditorContentHeight();
7957
+ const parentFloating = inject("parentFloating", ref(null));
7958
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
7672
7959
  watchEffect(() => {
7673
7960
  initValues.value = props.values;
7674
7961
  dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
@@ -7681,26 +7968,38 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
7681
7968
  };
7682
7969
  __expose({
7683
7970
  show() {
7684
- fomDrawer.value?.show();
7971
+ calcBoxPosition();
7972
+ boxVisible.value = true;
7685
7973
  },
7686
7974
  hide() {
7687
- fomDrawer.value?.hide();
7975
+ boxVisible.value = false;
7688
7976
  }
7689
7977
  });
7690
7978
  return (_ctx, _cache) => {
7691
- return openBlock(), createBlock(resolveDynamicComponent(_ctx.slideType === "box" ? unref(MFormBox) : unref(MFormDrawer)), {
7692
- ref_key: "fomDrawer",
7693
- ref: fomDrawer,
7694
- "label-width": "80px",
7695
- "close-on-press-escape": false,
7979
+ return openBlock(), createBlock(_sfc_main$P, {
7980
+ visible: boxVisible.value,
7981
+ "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
7982
+ width: width.value,
7983
+ "onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
7984
+ height: unref(editorHeight),
7985
+ "onUpdate:height": _cache[2] || (_cache[2] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
7696
7986
  title: _ctx.title,
7697
- width: size.value,
7698
- config: dataSourceConfig.value,
7699
- values: initValues.value,
7700
- disabled: _ctx.disabled,
7701
- onSubmit: submitHandler,
7702
- onError: errorHandler
7703
- }, null, 40, ["title", "width", "config", "values", "disabled"]);
7987
+ position: unref(boxPosition)
7988
+ }, {
7989
+ body: withCtx(() => [
7990
+ createVNode(unref(MFormBox), {
7991
+ "label-width": "80px",
7992
+ title: _ctx.title,
7993
+ config: dataSourceConfig.value,
7994
+ values: initValues.value,
7995
+ disabled: _ctx.disabled,
7996
+ style: { "height": "100%" },
7997
+ onSubmit: submitHandler,
7998
+ onError: errorHandler
7999
+ }, null, 8, ["title", "config", "values", "disabled"])
8000
+ ]),
8001
+ _: 1
8002
+ }, 8, ["visible", "width", "height", "title", "position"]);
7704
8003
  };
7705
8004
  }
7706
8005
  });
@@ -7816,7 +8115,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7816
8115
  placement: "bottom"
7817
8116
  }, {
7818
8117
  default: withCtx(() => [
7819
- createVNode(_sfc_main$N, {
8118
+ createVNode(_sfc_main$U, {
7820
8119
  icon: editable.value ? unref(Edit) : unref(View),
7821
8120
  class: "edit-icon",
7822
8121
  onClick: withModifiers(($event) => editHandler(`${data.key}`), ["stop"])
@@ -7831,7 +8130,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
7831
8130
  placement: "bottom"
7832
8131
  }, {
7833
8132
  default: withCtx(() => [
7834
- createVNode(_sfc_main$N, {
8133
+ createVNode(_sfc_main$U, {
7835
8134
  icon: unref(Close),
7836
8135
  class: "edit-icon",
7837
8136
  onClick: withModifiers(($event) => removeHandler(`${data.key}`), ["stop"])
@@ -7854,9 +8153,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
7854
8153
  name: "MEditorDataSourceListPanel"
7855
8154
  },
7856
8155
  __name: "DataSourceListPanel",
7857
- props: {
7858
- slideType: {}
7859
- },
7860
8156
  setup(__props) {
7861
8157
  const { dataSourceService } = inject("services") || {};
7862
8158
  const editDialog = ref();
@@ -7963,9 +8259,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
7963
8259
  disabled: !editable.value,
7964
8260
  values: dataSourceValues.value,
7965
8261
  title: dialogTitle.value,
7966
- slideType: _ctx.slideType,
7967
8262
  onSubmit: submitDataSourceHandler
7968
- }, null, 8, ["disabled", "values", "title", "slideType"])
8263
+ }, null, 8, ["disabled", "values", "title"])
7969
8264
  ], 64);
7970
8265
  };
7971
8266
  }
@@ -8367,12 +8662,12 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
8367
8662
  };
8368
8663
  return (_ctx, _cache) => {
8369
8664
  return _ctx.data.type !== "page" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
8370
- _ctx.data.visible === false ? (openBlock(), createBlock(_sfc_main$N, {
8665
+ _ctx.data.visible === false ? (openBlock(), createBlock(_sfc_main$U, {
8371
8666
  key: 0,
8372
8667
  icon: unref(Hide),
8373
8668
  onClick: _cache[0] || (_cache[0] = withModifiers(($event) => setNodeVisible(true), ["stop"])),
8374
8669
  title: "点击显示"
8375
- }, null, 8, ["icon"])) : (openBlock(), createBlock(_sfc_main$N, {
8670
+ }, null, 8, ["icon"])) : (openBlock(), createBlock(_sfc_main$U, {
8376
8671
  key: 1,
8377
8672
  icon: unref(View),
8378
8673
  onClick: _cache[1] || (_cache[1] = withModifiers(($event) => setNodeVisible(false), ["stop"])),
@@ -9013,7 +9308,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
9013
9308
  name: `${index}`
9014
9309
  }, {
9015
9310
  title: withCtx(() => [
9016
- createVNode(_sfc_main$N, { icon: unref(Grid) }, null, 8, ["icon"]),
9311
+ createVNode(_sfc_main$U, { icon: unref(Grid) }, null, 8, ["icon"]),
9017
9312
  createTextVNode(toDisplayString(group.title), 1)
9018
9313
  ]),
9019
9314
  default: withCtx(() => [
@@ -9034,7 +9329,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
9034
9329
  content: item.desc
9035
9330
  }, {
9036
9331
  default: withCtx(() => [
9037
- createVNode(_sfc_main$N, {
9332
+ createVNode(_sfc_main$U, {
9038
9333
  icon: item.icon
9039
9334
  }, null, 8, ["icon"])
9040
9335
  ]),
@@ -9085,7 +9380,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9085
9380
  setup(__props, { expose: __expose }) {
9086
9381
  const props = __props;
9087
9382
  const services = inject("services");
9088
- const columnLeftWitch = computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
9383
+ const columnLeftWidth = computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
9384
+ const { height: columnLeftHeight } = useEditorContentHeight();
9089
9385
  const activeTabName = ref(props.data?.status);
9090
9386
  const getItemConfig = (data) => {
9091
9387
  const map = {
@@ -9115,12 +9411,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9115
9411
  icon: EditPen,
9116
9412
  text: "代码编辑",
9117
9413
  component: _sfc_main$k,
9118
- slots: {},
9119
- boxComponentConfig: {
9120
- props: {
9121
- slideType: "box"
9122
- }
9123
- }
9414
+ slots: {}
9124
9415
  },
9125
9416
  "data-source": {
9126
9417
  $key: "data-source",
@@ -9177,7 +9468,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9177
9468
  (...args) => unref(dragstartHandler) && unref(dragstartHandler)(...args)),
9178
9469
  onDragend: ($event) => unref(dragendHandler)(config.$key, $event)
9179
9470
  }, [
9180
- config.icon ? (openBlock(), createBlock(_sfc_main$N, {
9471
+ config.icon ? (openBlock(), createBlock(_sfc_main$U, {
9181
9472
  key: 0,
9182
9473
  icon: config.icon
9183
9474
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -9310,12 +9601,13 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9310
9601
  (openBlock(), createBlock(Teleport, { to: "body" }, [
9311
9602
  (openBlock(true), createElementBlock(Fragment, null, renderList(sideBarItems.value, (config, index) => {
9312
9603
  return openBlock(), createElementBlock(Fragment, null, [
9313
- unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(_sfc_main$Q, {
9604
+ unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(_sfc_main$P, {
9314
9605
  key: config.$key ?? index,
9315
9606
  visible: unref(floatBoxStates)[config.$key].status,
9316
9607
  "onUpdate:visible": ($event) => unref(floatBoxStates)[config.$key].status = $event,
9317
- width: columnLeftWitch.value,
9318
- height: 600,
9608
+ height: unref(columnLeftHeight),
9609
+ "onUpdate:height": _cache[1] || (_cache[1] = ($event) => isRef(columnLeftHeight) ? columnLeftHeight.value = $event : null),
9610
+ width: columnLeftWidth.value,
9319
9611
  title: config.text,
9320
9612
  position: {
9321
9613
  left: unref(floatBoxStates)[config.$key].left,
@@ -9324,11 +9616,11 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9324
9616
  }, {
9325
9617
  body: withCtx(() => [
9326
9618
  createElementVNode("div", _hoisted_5$1, [
9327
- config && unref(floatBoxStates)[config.$key].status ? (openBlock(), createBlock(resolveDynamicComponent(config.boxComponentConfig?.component || config.component), mergeProps({ key: 0 }, config.boxComponentConfig?.props || config.props || {}, toHandlers(config?.listeners || {})), null, 16)) : createCommentVNode("", true)
9619
+ config && unref(floatBoxStates)[config.$key].status ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({ key: 0 }, config.props || {}, toHandlers(config?.listeners || {})), null, 16)) : createCommentVNode("", true)
9328
9620
  ])
9329
9621
  ]),
9330
9622
  _: 2
9331
- }, 1032, ["visible", "onUpdate:visible", "width", "title", "position"])) : createCommentVNode("", true)
9623
+ }, 1032, ["visible", "onUpdate:visible", "height", "width", "title", "position"])) : createCommentVNode("", true)
9332
9624
  ], 64);
9333
9625
  }), 256))
9334
9626
  ]))
@@ -9660,211 +9952,6 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
9660
9952
  }
9661
9953
  });
9662
9954
 
9663
- const state = reactive({
9664
- uiSelectMode: false,
9665
- showSrc: false,
9666
- zoom: 1,
9667
- stageContainerRect: {
9668
- width: 0,
9669
- height: 0
9670
- },
9671
- stageRect: {
9672
- width: 375,
9673
- height: 817
9674
- },
9675
- columnWidth: {
9676
- left: 0,
9677
- right: 0,
9678
- center: 0
9679
- },
9680
- showGuides: true,
9681
- showRule: true,
9682
- propsPanelSize: "small",
9683
- showAddPageButton: true,
9684
- hideSlideBar: false,
9685
- navMenuRect: {
9686
- left: 0,
9687
- top: 0,
9688
- width: 0,
9689
- height: 0
9690
- },
9691
- frameworkRect: {
9692
- width: 0,
9693
- height: 0,
9694
- left: 0,
9695
- top: 0
9696
- }
9697
- });
9698
- const canUsePluginMethods$2 = {
9699
- async: ["zoom", "calcZoom"],
9700
- sync: []
9701
- };
9702
- class Ui extends BaseService {
9703
- constructor() {
9704
- super(canUsePluginMethods$2.async.map((methodName) => ({ name: methodName, isAsync: true })));
9705
- }
9706
- set(name, value) {
9707
- const mask = editorService.get("stage")?.mask;
9708
- if (name === "stageRect") {
9709
- this.setStageRect(value);
9710
- return;
9711
- }
9712
- if (name === "showGuides") {
9713
- mask?.showGuides(value);
9714
- }
9715
- if (name === "showRule") {
9716
- mask?.showRule(value);
9717
- }
9718
- state[name] = value;
9719
- }
9720
- get(name) {
9721
- return state[name];
9722
- }
9723
- async zoom(zoom) {
9724
- this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
9725
- if (this.get("zoom") < 0.1)
9726
- this.set("zoom", 0.1);
9727
- }
9728
- async calcZoom() {
9729
- const { stageRect, stageContainerRect } = state;
9730
- const { height, width } = stageContainerRect;
9731
- if (!width || !height)
9732
- return 1;
9733
- let stageWidth = convertToNumber(stageRect.width, width);
9734
- let stageHeight = convertToNumber(stageRect.height, height);
9735
- stageWidth = stageWidth + 30;
9736
- stageHeight = stageHeight + 30;
9737
- if (width > stageWidth && height > stageHeight) {
9738
- return 1;
9739
- }
9740
- return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
9741
- }
9742
- resetState() {
9743
- this.set("showSrc", false);
9744
- this.set("uiSelectMode", false);
9745
- this.set("zoom", 1);
9746
- this.set("stageContainerRect", {
9747
- width: 0,
9748
- height: 0
9749
- });
9750
- }
9751
- destroy() {
9752
- this.resetState();
9753
- this.removeAllListeners();
9754
- this.removeAllPlugins();
9755
- }
9756
- usePlugin(options) {
9757
- super.usePlugin(options);
9758
- }
9759
- async setStageRect(value) {
9760
- state.stageRect = {
9761
- ...state.stageRect,
9762
- ...value
9763
- };
9764
- state.zoom = await this.calcZoom();
9765
- }
9766
- }
9767
- const uiService = new Ui();
9768
-
9769
- const root = computed(() => editorService.get("root"));
9770
- const page = computed(() => editorService.get("page"));
9771
- const zoom = computed(() => uiService.get("zoom") || 1);
9772
- const uiSelectMode = computed(() => uiService.get("uiSelectMode"));
9773
- const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
9774
- const useStage = (stageOptions) => {
9775
- const stage = new StageCore({
9776
- render: stageOptions.render,
9777
- runtimeUrl: stageOptions.runtimeUrl,
9778
- zoom: zoom.value,
9779
- autoScrollIntoView: stageOptions.autoScrollIntoView,
9780
- isContainer: stageOptions.isContainer,
9781
- containerHighlightClassName: stageOptions.containerHighlightClassName,
9782
- containerHighlightDuration: stageOptions.containerHighlightDuration,
9783
- containerHighlightType: stageOptions.containerHighlightType,
9784
- disabledDragStart: stageOptions.disabledDragStart,
9785
- renderType: stageOptions.renderType,
9786
- canSelect: (el, event, stop) => {
9787
- if (!stageOptions.canSelect)
9788
- return true;
9789
- const elCanSelect = stageOptions.canSelect?.(el);
9790
- if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
9791
- document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
9792
- return stop();
9793
- }
9794
- return elCanSelect;
9795
- },
9796
- moveableOptions: stageOptions.moveableOptions,
9797
- updateDragEl: stageOptions.updateDragEl,
9798
- guidesOptions: stageOptions.guidesOptions,
9799
- disabledMultiSelect: stageOptions.disabledMultiSelect
9800
- });
9801
- watch(
9802
- () => editorService.get("disabledMultiSelect"),
9803
- (disabledMultiSelect) => {
9804
- if (disabledMultiSelect) {
9805
- stage.disableMultiSelect();
9806
- } else {
9807
- stage.enableMultiSelect();
9808
- }
9809
- }
9810
- );
9811
- stage.mask.setGuides([
9812
- getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
9813
- getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
9814
- ]);
9815
- stage.on("page-el-update", () => {
9816
- editorService.set("stageLoading", false);
9817
- });
9818
- stage.on("select", (el) => {
9819
- if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
9820
- return;
9821
- editorService.select(el.id);
9822
- });
9823
- stage.on("highlight", (el) => {
9824
- editorService.highlight(el.id);
9825
- });
9826
- stage.on("multi-select", (els) => {
9827
- editorService.multiSelect(els.map((el) => el.id));
9828
- });
9829
- stage.on("update", (ev) => {
9830
- if (ev.parentEl) {
9831
- for (const data of ev.data) {
9832
- editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
9833
- }
9834
- return;
9835
- }
9836
- editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
9837
- });
9838
- stage.on("sort", (ev) => {
9839
- editorService.sort(ev.src, ev.dist);
9840
- });
9841
- stage.on("remove", (ev) => {
9842
- const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
9843
- editorService.remove(nodes.filter((node) => Boolean(node)));
9844
- });
9845
- stage.on("select-parent", () => {
9846
- const parent = editorService.get("parent");
9847
- if (!parent)
9848
- throw new Error("父节点为空");
9849
- editorService.select(parent);
9850
- editorService.get("stage")?.select(parent.id);
9851
- });
9852
- stage.on("change-guides", (e) => {
9853
- uiService.set("showGuides", true);
9854
- if (!root.value || !page.value)
9855
- return;
9856
- const storageKey = getGuideLineKey(
9857
- e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
9858
- );
9859
- if (e.guides.length) {
9860
- globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
9861
- } else {
9862
- globalThis.localStorage.removeItem(storageKey);
9863
- }
9864
- });
9865
- return stage;
9866
- };
9867
-
9868
9955
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
9869
9956
  __name: "NodeListMenu",
9870
9957
  setup(__props) {
@@ -9947,7 +10034,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
9947
10034
  ]),
9948
10035
  _: 1
9949
10036
  })) : createCommentVNode("", true),
9950
- page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$Q, {
10037
+ page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$P, {
9951
10038
  key: 1,
9952
10039
  ref_key: "box",
9953
10040
  ref: box,
@@ -10020,7 +10107,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
10020
10107
  }, [
10021
10108
  createVNode(unref(TMagicIcon), {
10022
10109
  class: "m-editor-stage-overlay-close",
10023
- size: 20,
10110
+ size: "20",
10024
10111
  onClick: closeOverlayHandler
10025
10112
  }, {
10026
10113
  default: withCtx(() => [
@@ -11667,11 +11754,11 @@ const index = {
11667
11754
  app.config.globalProperties.$TMAGIC_EDITOR = option;
11668
11755
  setConfig(option);
11669
11756
  app.component(`${_sfc_main.name || "MEditor"}`, _sfc_main);
11670
- app.component("magic-code-editor", _sfc_main$U);
11757
+ app.component("magic-code-editor", _sfc_main$T);
11671
11758
  app.component("m-fields-ui-select", _sfc_main$A);
11672
- app.component("m-fields-code-link", _sfc_main$S);
11673
- app.component("m-fields-vs-code", _sfc_main$T);
11674
- app.component("m-fields-code-select", _sfc_main$R);
11759
+ app.component("m-fields-code-link", _sfc_main$R);
11760
+ app.component("m-fields-vs-code", _sfc_main$S);
11761
+ app.component("m-fields-code-select", _sfc_main$Q);
11675
11762
  app.component("m-fields-code-select-col", _sfc_main$M);
11676
11763
  app.component("m-fields-event-select", _sfc_main$E);
11677
11764
  app.component("m-fields-data-source-fields", _sfc_main$L);
@@ -11686,4 +11773,4 @@ const index = {
11686
11773
  }
11687
11774
  };
11688
11775
 
11689
- export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$P as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$R as CodeSelect, _sfc_main$M as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$K as DataSourceFieldSelect, _sfc_main$L as DataSourceFields, _sfc_main$J as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$N as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, _sfc_main$y as SplitView, _sfc_main$U as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useEditorContentHeight, useFloatBox, useStage, useWindowRect, warn };
11776
+ export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$O as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$M as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$K as DataSourceFieldSelect, _sfc_main$L as DataSourceFields, _sfc_main$J as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$U as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, _sfc_main$y as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useEditorContentHeight, useFloatBox, useStage, useWindowRect, warn };