@tmagic/editor 1.4.0-beta.1 → 1.4.0-beta.2

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 (34) hide show
  1. package/dist/style.css +14 -6
  2. package/dist/tmagic-editor.js +259 -167
  3. package/dist/tmagic-editor.umd.cjs +258 -164
  4. package/package.json +11 -11
  5. package/src/components/CodeBlockEditor.vue +43 -46
  6. package/src/components/FloatingBox.vue +38 -33
  7. package/src/components/SplitView.vue +46 -35
  8. package/src/hooks/index.ts +2 -0
  9. package/src/hooks/use-code-block-edit.ts +1 -1
  10. package/src/hooks/use-editor-content-height.ts +20 -0
  11. package/src/hooks/use-float-box.ts +8 -8
  12. package/src/hooks/use-window-rect.ts +20 -0
  13. package/src/layouts/Framework.vue +33 -34
  14. package/src/layouts/PropsPanel.vue +35 -0
  15. package/src/layouts/sidebar/Sidebar.vue +13 -8
  16. package/src/layouts/workspace/viewer/NodeListMenu.vue +1 -0
  17. package/src/services/stageOverlay.ts +2 -2
  18. package/src/services/ui.ts +6 -0
  19. package/src/theme/code-block.scss +0 -5
  20. package/src/theme/floating-box.scss +2 -2
  21. package/src/theme/props-panel.scss +14 -0
  22. package/src/type.ts +6 -0
  23. package/types/components/CodeBlockEditor.vue.d.ts +45 -24
  24. package/types/components/FloatingBox.vue.d.ts +42 -57
  25. package/types/components/SplitView.vue.d.ts +2 -0
  26. package/types/hooks/index.d.ts +2 -0
  27. package/types/hooks/use-code-block-edit.d.ts +16 -2
  28. package/types/hooks/use-data-source-method.d.ts +16 -2
  29. package/types/hooks/use-editor-content-height.d.ts +3 -0
  30. package/types/hooks/use-window-rect.d.ts +6 -0
  31. package/types/layouts/sidebar/Sidebar.vue.d.ts +1 -1
  32. package/types/services/stageOverlay.d.ts +1 -1
  33. package/types/services/ui.d.ts +6 -0
  34. package/types/type.d.ts +6 -0
@@ -1,5 +1,5 @@
1
- import { defineComponent, ref, watch, onMounted, onBeforeUnmount, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, watchEffect, nextTick, renderSlot, toDisplayString, createCommentVNode, Fragment, 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, Search, ArrowRight, CopyDocument, Files, Hide, Goods, List, EditPen, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
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';
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
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';
@@ -27,7 +27,7 @@ const getConfig = (key) => $TMAGIC_EDITOR[key];
27
27
  emmetHTML(monaco);
28
28
  emmetCSS(monaco, ["css", "scss"]);
29
29
 
30
- const _hoisted_1$u = {
30
+ const _hoisted_1$t = {
31
31
  class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
32
32
  };
33
33
  const _sfc_main$U = /* @__PURE__ */ defineComponent({
@@ -188,7 +188,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
188
188
  }
189
189
  });
190
190
  return (_ctx, _cache) => {
191
- return openBlock(), createElementBlock("div", _hoisted_1$u, [
191
+ return openBlock(), createElementBlock("div", _hoisted_1$t, [
192
192
  (openBlock(), createBlock(Teleport, {
193
193
  to: "body",
194
194
  disabled: !fullScreen.value
@@ -454,39 +454,45 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
454
454
  }
455
455
  });
456
456
 
457
- const _hoisted_1$t = { class: "m-editor-float-box-body" };
458
457
  const _sfc_main$Q = /* @__PURE__ */ defineComponent({
459
458
  __name: "FloatingBox",
460
- props: {
461
- visible: { type: Boolean, default: false },
459
+ props: /* @__PURE__ */ mergeModels({
462
460
  position: { default: () => ({ left: 0, top: 0 }) },
463
- rect: { default: () => ({ width: "auto", height: "auto" }) },
464
461
  title: { default: "" },
465
462
  beforeClose: {}
466
- },
467
- emits: ["update:visible"],
468
- setup(__props, { expose: __expose, emit: __emit }) {
463
+ }, {
464
+ "width": { default: 0 },
465
+ "widthModifiers": {},
466
+ "height": { default: 0 },
467
+ "heightModifiers": {},
468
+ "visible": { type: Boolean, ...{ default: false } },
469
+ "visibleModifiers": {}
470
+ }),
471
+ emits: ["update:width", "update:height", "update:visible"],
472
+ setup(__props, { expose: __expose }) {
473
+ const width = useModel(__props, "width");
474
+ const height = useModel(__props, "height");
475
+ const visible = useModel(__props, "visible");
469
476
  const props = __props;
470
- const emit = __emit;
471
477
  const target = ref();
472
- const dragTarget = ref();
478
+ const titleEl = ref();
473
479
  const zIndex = useZIndex();
474
480
  const curZIndex = ref(zIndex.nextZIndex());
475
- const rect = ref({
476
- width: props.rect.width,
477
- height: props.rect.height
478
- });
479
- watchEffect(() => {
480
- rect.value = {
481
- width: props.rect.width,
482
- height: props.rect.height
483
- };
481
+ const titleHeight = ref(0);
482
+ const bodyHeight = computed(() => {
483
+ if (height.value) {
484
+ return height.value - titleHeight.value;
485
+ }
486
+ if (target.value) {
487
+ return target.value.clientHeight - titleHeight.value;
488
+ }
489
+ return "auto";
484
490
  });
485
491
  const style = computed(() => ({
486
492
  left: `${props.position.left}px`,
487
493
  top: `${props.position.top}px`,
488
- width: typeof rect.value.width === "string" ? rect.value.width : `${rect.value.width}px`,
489
- height: typeof rect.value.height === "string" ? rect.value.height : `${rect.value.height}px`
494
+ width: width.value ? `${width.value}px` : "auto",
495
+ height: height.value ? `${height.value}px` : "auto"
490
496
  }));
491
497
  let moveable = null;
492
498
  const initMoveable = () => {
@@ -499,7 +505,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
499
505
  keepRatio: false,
500
506
  origin: false,
501
507
  snappable: true,
502
- dragTarget: dragTarget.value,
508
+ dragTarget: titleEl.value,
503
509
  dragTargetSelf: false,
504
510
  linePadding: 10,
505
511
  controlPadding: 10,
@@ -509,8 +515,8 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
509
515
  e.target.style.transform = e.transform;
510
516
  });
511
517
  moveable.on("resize", (e) => {
512
- rect.value.width = e.width;
513
- rect.value.height = e.height;
518
+ width.value = e.width;
519
+ height.value = e.height;
514
520
  e.target.style.width = `${e.width}px`;
515
521
  e.target.style.height = `${e.height}px`;
516
522
  e.target.style.transform = e.drag.transform;
@@ -521,11 +527,20 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
521
527
  moveable = null;
522
528
  };
523
529
  watch(
524
- () => props.visible,
525
- async (visible) => {
526
- if (visible) {
530
+ visible,
531
+ async (visible2) => {
532
+ if (visible2) {
527
533
  await nextTick();
528
- initMoveable();
534
+ const targetRect = target.value?.getBoundingClientRect();
535
+ if (targetRect) {
536
+ width.value = targetRect.width;
537
+ height.value = targetRect.height;
538
+ initMoveable();
539
+ }
540
+ if (titleEl.value) {
541
+ const titleRect = titleEl.value.getBoundingClientRect();
542
+ titleHeight.value = titleRect.height;
543
+ }
529
544
  } else {
530
545
  destroyMoveable();
531
546
  }
@@ -539,7 +554,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
539
554
  });
540
555
  const hide = (cancel) => {
541
556
  if (cancel !== false) {
542
- emit("update:visible", false);
557
+ visible.value = false;
543
558
  }
544
559
  };
545
560
  const closeHandler = () => {
@@ -553,10 +568,12 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
553
568
  curZIndex.value = zIndex.nextZIndex();
554
569
  };
555
570
  __expose({
556
- target
571
+ bodyHeight,
572
+ target,
573
+ titleEl
557
574
  });
558
575
  return (_ctx, _cache) => {
559
- return _ctx.visible ? (openBlock(), createBlock(Teleport, {
576
+ return visible.value ? (openBlock(), createBlock(Teleport, {
560
577
  key: 0,
561
578
  to: "body"
562
579
  }, [
@@ -568,8 +585,8 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
568
585
  onMousedown: nextZIndex
569
586
  }, [
570
587
  createElementVNode("div", {
571
- ref_key: "dragTarget",
572
- ref: dragTarget,
588
+ ref_key: "titleEl",
589
+ ref: titleEl,
573
590
  class: "m-editor-float-box-title"
574
591
  }, [
575
592
  renderSlot(_ctx.$slots, "title", {}, () => [
@@ -584,15 +601,49 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
584
601
  }, null, 8, ["icon"])
585
602
  ])
586
603
  ], 512),
587
- createElementVNode("div", _hoisted_1$t, [
604
+ createElementVNode("div", {
605
+ class: "m-editor-float-box-body",
606
+ style: normalizeStyle({ height: `${bodyHeight.value}px` })
607
+ }, [
588
608
  renderSlot(_ctx.$slots, "body")
589
- ])
609
+ ], 4)
590
610
  ], 36)
591
611
  ])) : createCommentVNode("", true);
592
612
  };
593
613
  }
594
614
  });
595
615
 
616
+ const useEditorContentHeight = () => {
617
+ const services = inject("services");
618
+ const frameworkHeight = computed(() => services?.uiService.get("frameworkRect").height || 0);
619
+ const navMenuHeight = computed(() => services?.uiService.get("navMenuRect").height || 0);
620
+ const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
621
+ const height = ref(0);
622
+ watchEffect(() => {
623
+ if (height.value > 0)
624
+ return;
625
+ height.value = editorContentHeight.value;
626
+ });
627
+ return {
628
+ height
629
+ };
630
+ };
631
+
632
+ const useWindowRect = () => {
633
+ const rect = reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
634
+ const windowResizeHandler = () => {
635
+ rect.width = globalThis.innerWidth;
636
+ rect.height = globalThis.innerHeight;
637
+ };
638
+ globalThis.addEventListener("resize", windowResizeHandler);
639
+ onBeforeUnmount(() => {
640
+ globalThis.removeEventListener("resize", windowResizeHandler);
641
+ });
642
+ return {
643
+ rect
644
+ };
645
+ };
646
+
596
647
  const _hoisted_1$s = { style: { "display": "flex", "margin-bottom": "10px" } };
597
648
  const _hoisted_2$k = { style: { "flex": "1" } };
598
649
  const _hoisted_3$8 = { style: { "flex": "1" } };
@@ -602,40 +653,36 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
602
653
  name: "MEditorCodeBlockEditor"
603
654
  },
604
655
  __name: "CodeBlockEditor",
605
- props: {
656
+ props: /* @__PURE__ */ mergeModels({
606
657
  content: {},
607
658
  disabled: { type: Boolean },
608
659
  isDataSource: { type: Boolean },
609
660
  dataSourceType: {},
610
661
  slideType: {}
611
- },
612
- emits: ["submit"],
662
+ }, {
663
+ "width": { default: 670 },
664
+ "widthModifiers": {},
665
+ "visible": { type: Boolean, ...{ default: false } },
666
+ "visibleModifiers": {}
667
+ }),
668
+ emits: /* @__PURE__ */ mergeModels(["submit"], ["update:width", "update:visible"]),
613
669
  setup(__props, { expose: __expose, emit: __emit }) {
670
+ const width = useModel(__props, "width");
671
+ const boxVisible = useModel(__props, "visible");
614
672
  const props = __props;
615
673
  const emit = __emit;
616
674
  const services = inject("services");
675
+ const { height: codeBlockEditorHeight } = useEditorContentHeight();
617
676
  const difVisible = ref(false);
618
- const height = ref(globalThis.innerHeight);
619
- const windowReizehandler = () => {
620
- height.value = globalThis.innerHeight;
621
- };
622
- globalThis.addEventListener("resize", windowReizehandler);
623
- onBeforeUnmount(() => {
624
- globalThis.removeEventListener("resize", windowReizehandler);
625
- });
677
+ const { rect: windowRect } = useWindowRect();
626
678
  const magicVsEditor = ref();
627
679
  const diffChange = () => {
628
- if (!magicVsEditor.value || !fomDrawer.value?.form) {
680
+ if (!magicVsEditor.value || !formBox.value?.form) {
629
681
  return;
630
682
  }
631
- fomDrawer.value.form.values.content = magicVsEditor.value.getEditorValue();
683
+ formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
632
684
  difVisible.value = false;
633
685
  };
634
- const columnWidth = computed(() => services?.uiService.get("columnWidth"));
635
- const size = computed(
636
- () => columnWidth.value ? columnWidth.value.center + columnWidth.value.right - (props.isDataSource ? 100 : 0) : 600
637
- );
638
- const codeEditorHeight = ref("600px");
639
686
  const defaultParamColConfig = {
640
687
  type: "row",
641
688
  label: "参数类型",
@@ -718,7 +765,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
718
765
  name: "content",
719
766
  type: "vs-code",
720
767
  options: inject("codeOptions", {}),
721
- height: codeEditorHeight.value,
768
+ height: "500px",
722
769
  onChange: (formState, code) => {
723
770
  try {
724
771
  getConfig("parseDSL")(code);
@@ -731,26 +778,20 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
731
778
  }
732
779
  ]);
733
780
  const submitForm = (values) => {
781
+ changedValue.value = void 0;
734
782
  emit("submit", values);
735
783
  };
736
784
  const errorHandler = (error) => {
737
785
  tMagicMessage.error(error.message);
738
786
  };
739
- const fomDrawer = ref();
740
- const openHandler = () => {
741
- setTimeout(() => {
742
- if (fomDrawer.value) {
743
- const height2 = fomDrawer.value?.bodyHeight - 348 - (props.isDataSource ? 50 : 0);
744
- codeEditorHeight.value = `${height2 > 100 ? height2 : 600}px`;
745
- }
746
- });
747
- };
787
+ const formBox = ref();
748
788
  const changedValue = ref();
749
789
  const changeHandler = (values) => {
750
790
  changedValue.value = values;
751
791
  };
752
792
  const beforeClose = (done) => {
753
793
  if (!changedValue.value) {
794
+ editVisible.value = false;
754
795
  done();
755
796
  return;
756
797
  }
@@ -761,22 +802,25 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
761
802
  distinguishCancelAndClose: true
762
803
  }).then(() => {
763
804
  changedValue.value && submitForm(changedValue.value);
805
+ editVisible.value = false;
764
806
  done();
765
807
  }).catch((action) => {
808
+ if (action === "cancel") {
809
+ editVisible.value = false;
810
+ }
766
811
  done(action === "cancel");
767
812
  });
768
813
  };
769
814
  const closedHandler = () => {
770
815
  changedValue.value = void 0;
771
816
  };
772
- const boxVisible = ref(false);
773
817
  const editVisible = ref(false);
774
818
  const floatingBoxBody = ref();
775
819
  const boxPosition = computed(() => {
776
- const columnWidth2 = services?.uiService?.get("columnWidth");
820
+ const columnWidth = services?.uiService?.get("columnWidth");
777
821
  const navMenuRect = services?.uiService?.get("navMenuRect");
778
822
  return {
779
- left: columnWidth2?.left ?? 0,
823
+ left: columnWidth?.left ?? 0,
780
824
  top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
781
825
  };
782
826
  });
@@ -784,13 +828,16 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
784
828
  async show() {
785
829
  if (props.slideType !== "box") {
786
830
  boxVisible.value = true;
831
+ await nextTick();
787
832
  }
788
- await nextTick();
789
833
  editVisible.value = true;
790
- fomDrawer.value?.show();
791
834
  },
792
- hide() {
793
- fomDrawer.value?.hide();
835
+ async hide() {
836
+ editVisible.value = false;
837
+ if (props.slideType !== "box") {
838
+ await nextTick();
839
+ boxVisible.value = false;
840
+ }
794
841
  }
795
842
  });
796
843
  return (_ctx, _cache) => {
@@ -798,18 +845,23 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
798
845
  createVNode(_sfc_main$Q, {
799
846
  visible: boxVisible.value,
800
847
  "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
801
- title: "代码编辑",
848
+ width: width.value,
849
+ "onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
850
+ height: unref(codeBlockEditorHeight),
851
+ "onUpdate:height": _cache[2] || (_cache[2] = ($event) => isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
852
+ title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
802
853
  position: boxPosition.value,
803
854
  "before-close": beforeClose
804
855
  }, {
805
856
  body: withCtx(() => [
806
857
  createElementVNode("div", {
807
858
  ref_key: "floatingBoxBody",
808
- ref: floatingBoxBody
859
+ ref: floatingBoxBody,
860
+ style: { "height": "100%" }
809
861
  }, null, 512)
810
862
  ]),
811
863
  _: 1
812
- }, 8, ["visible", "position"]),
864
+ }, 8, ["visible", "width", "height", "title", "position"]),
813
865
  editVisible.value ? (openBlock(), createBlock(Teleport, {
814
866
  key: 0,
815
867
  to: floatingBoxBody.value,
@@ -817,39 +869,39 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
817
869
  }, [
818
870
  createVNode(unref(MFormBox), {
819
871
  class: "m-editor-code-block-editor",
820
- ref_key: "fomDrawer",
821
- ref: fomDrawer,
872
+ ref_key: "formBox",
873
+ ref: formBox,
822
874
  "label-width": "80px",
823
875
  "close-on-press-escape": false,
824
876
  title: _ctx.content.name,
825
- width: size.value,
826
877
  config: functionConfig.value,
827
878
  values: _ctx.content,
828
879
  disabled: _ctx.disabled,
880
+ height: floatingBoxBody.value?.clientHeight,
829
881
  onChange: changeHandler,
830
882
  onSubmit: submitForm,
831
883
  onError: errorHandler,
832
- onOpen: openHandler,
833
884
  onClosed: closedHandler
834
885
  }, {
835
886
  left: withCtx(() => [
836
- createVNode(unref(TMagicButton), {
887
+ !_ctx.disabled ? (openBlock(), createBlock(unref(TMagicButton), {
888
+ key: 0,
837
889
  type: "primary",
838
890
  link: "",
839
- onClick: _cache[1] || (_cache[1] = ($event) => difVisible.value = true)
891
+ onClick: _cache[3] || (_cache[3] = ($event) => difVisible.value = true)
840
892
  }, {
841
893
  default: withCtx(() => [
842
894
  createTextVNode("查看修改")
843
895
  ]),
844
896
  _: 1
845
- })
897
+ })) : createCommentVNode("", true)
846
898
  ]),
847
899
  _: 1
848
- }, 8, ["title", "width", "config", "values", "disabled"])
900
+ }, 8, ["title", "config", "values", "disabled", "height"])
849
901
  ], 8, ["to", "disabled"])) : createCommentVNode("", true),
850
902
  createVNode(unref(TMagicDialog), {
851
903
  modelValue: difVisible.value,
852
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => difVisible.value = $event),
904
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
853
905
  title: "查看修改",
854
906
  fullscreen: ""
855
907
  }, {
@@ -857,7 +909,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
857
909
  createElementVNode("span", _hoisted_4$7, [
858
910
  createVNode(unref(TMagicButton), {
859
911
  size: "small",
860
- onClick: _cache[2] || (_cache[2] = ($event) => difVisible.value = false)
912
+ onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
861
913
  }, {
862
914
  default: withCtx(() => [
863
915
  createTextVNode("取消")
@@ -908,8 +960,8 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
908
960
  type: "diff",
909
961
  language: "json",
910
962
  initValues: _ctx.content.content,
911
- modifiedValues: fomDrawer.value?.form?.values.content,
912
- style: normalizeStyle(`height: ${height.value - 200}px`)
963
+ modifiedValues: formBox.value?.form?.values.content,
964
+ style: normalizeStyle(`height: ${unref(windowRect).height - 150}px`)
913
965
  }, null, 8, ["initValues", "modifiedValues", "style"])) : createCommentVNode("", true)
914
966
  ]),
915
967
  _: 1
@@ -3693,7 +3745,7 @@ const useCodeBlockEdit = (codeBlockService) => {
3693
3745
  return;
3694
3746
  }
3695
3747
  codeConfig.value = {
3696
- name: "代码块",
3748
+ name: "",
3697
3749
  content: `({app, params}) => {
3698
3750
  // place your code here
3699
3751
  }`,
@@ -5840,6 +5892,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5840
5892
  },
5841
5893
  __name: "SplitView",
5842
5894
  props: {
5895
+ width: {},
5843
5896
  left: {},
5844
5897
  right: {},
5845
5898
  minLeft: { default: 46 },
@@ -5856,17 +5909,19 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5856
5909
  const el = ref();
5857
5910
  const hasLeft = computed(() => typeof props.left !== "undefined");
5858
5911
  const hasRight = computed(() => typeof props.right !== "undefined");
5859
- const getCenterWidth = (clientWidth2, l = 0, r = 0) => {
5912
+ const center = ref(0);
5913
+ let clientWidth = 0;
5914
+ const getCenterWidth = (l = 0, r = 0) => {
5860
5915
  let right = r > 0 ? r : 0;
5861
5916
  let left = l > 0 ? l : 0;
5862
- let center2 = clientWidth2 - left - right;
5917
+ let center2 = clientWidth - left - right;
5863
5918
  if (center2 < props.minCenter) {
5864
5919
  center2 = props.minCenter;
5865
5920
  if (right > center2 + props.minRight) {
5866
- right = clientWidth2 - left - center2;
5921
+ right = clientWidth - left - center2;
5867
5922
  } else {
5868
5923
  right = props.minRight;
5869
- left = clientWidth2 - right - center2;
5924
+ left = clientWidth - right - center2;
5870
5925
  }
5871
5926
  }
5872
5927
  return {
@@ -5875,36 +5930,43 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5875
5930
  right
5876
5931
  };
5877
5932
  };
5878
- let clientWidth = 0;
5879
- const resizerObserver = new ResizeObserver((entries) => {
5880
- for (const { contentRect } of entries) {
5881
- clientWidth = contentRect.width;
5882
- let left = props.left || 0;
5883
- let right = props.right || 0;
5884
- if (left > clientWidth) {
5885
- left = clientWidth / 3;
5886
- }
5887
- if (right > clientWidth) {
5888
- right = clientWidth / 3;
5889
- }
5890
- const columnWidth = getCenterWidth(clientWidth, left, right);
5891
- center.value = columnWidth.center;
5892
- emit("change", {
5893
- left: columnWidth.left,
5894
- center: center.value,
5895
- right: columnWidth.right
5896
- });
5933
+ const widthChange = (width) => {
5934
+ if (width <= 0) {
5935
+ return;
5897
5936
  }
5898
- });
5899
- onMounted(() => {
5900
- if (el.value) {
5901
- resizerObserver.observe(el.value);
5937
+ clientWidth = width;
5938
+ let left = props.left || 0;
5939
+ let right = props.right || 0;
5940
+ if (left > clientWidth) {
5941
+ left = clientWidth / 3;
5902
5942
  }
5903
- });
5904
- onBeforeUnmount(() => {
5905
- resizerObserver.disconnect();
5906
- });
5907
- const center = ref(0);
5943
+ if (right > clientWidth) {
5944
+ right = clientWidth / 3;
5945
+ }
5946
+ const columnWidth = getCenterWidth(left, right);
5947
+ center.value = columnWidth.center;
5948
+ emit("change", columnWidth);
5949
+ };
5950
+ if (typeof props.width !== "number") {
5951
+ const resizerObserver = new ResizeObserver((entries) => {
5952
+ for (const { contentRect } of entries) {
5953
+ widthChange(contentRect.width);
5954
+ }
5955
+ });
5956
+ onMounted(() => {
5957
+ if (el.value) {
5958
+ resizerObserver.observe(el.value);
5959
+ }
5960
+ });
5961
+ onBeforeUnmount(() => {
5962
+ resizerObserver.disconnect();
5963
+ });
5964
+ } else {
5965
+ watchEffect(() => {
5966
+ if (typeof props.width === "number")
5967
+ widthChange(props.width);
5968
+ });
5969
+ }
5908
5970
  const changeLeft = ({ deltaX }) => {
5909
5971
  if (typeof props.left === "undefined")
5910
5972
  return;
@@ -5913,7 +5975,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5913
5975
  if (clientWidth - left - (props.right || 0) <= 0) {
5914
5976
  left = props.left;
5915
5977
  }
5916
- const columnWidth = getCenterWidth(clientWidth, left, props.right || 0);
5978
+ const columnWidth = getCenterWidth(left, props.right || 0);
5917
5979
  center.value = columnWidth.center;
5918
5980
  emit("change", {
5919
5981
  left: columnWidth.left,
@@ -5929,7 +5991,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5929
5991
  if (clientWidth - (props.left || 0) - right <= 0) {
5930
5992
  right = props.right;
5931
5993
  }
5932
- const columnWidth = getCenterWidth(clientWidth, props.left, right);
5994
+ const columnWidth = getCenterWidth(props.left, right);
5933
5995
  center.value = columnWidth.center;
5934
5996
  emit("change", {
5935
5997
  left: columnWidth.left,
@@ -5939,7 +6001,8 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
5939
6001
  };
5940
6002
  __expose({
5941
6003
  updateWidth() {
5942
- const columnWidth = getCenterWidth(el.value?.clientWidth || clientWidth, props.left, props.right);
6004
+ clientWidth = props.width ?? el.value?.clientWidth ?? clientWidth;
6005
+ const columnWidth = getCenterWidth(props.left, props.right);
5943
6006
  emit("change", {
5944
6007
  left: columnWidth.left,
5945
6008
  center: center.value,
@@ -6598,36 +6661,14 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6598
6661
  const stageLoading = computed(() => editorService?.get("stageLoading") || false);
6599
6662
  const showSrc = computed(() => uiService?.get("showSrc"));
6600
6663
  const getLeftColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
6601
- const leftColumnWidthCacheData = getLeftColumnWidthCacheData();
6602
- const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
6603
6664
  const columnWidth = ref({
6604
- left: leftColumnWidthCacheData,
6665
+ left: getLeftColumnWidthCacheData(),
6605
6666
  center: 0,
6606
- right: RightColumnWidthCacheData
6667
+ right: Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH
6668
+ });
6669
+ watch(pageLength, () => {
6670
+ splitView.value?.updateWidth();
6607
6671
  });
6608
- watch(
6609
- [pageLength, splitView],
6610
- () => {
6611
- splitView.value?.updateWidth();
6612
- },
6613
- {
6614
- immediate: true
6615
- }
6616
- );
6617
- watch(
6618
- () => columnWidth.value.right,
6619
- (right) => {
6620
- if (typeof right === "undefined")
6621
- return;
6622
- globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
6623
- }
6624
- );
6625
- watch(
6626
- () => columnWidth.value.left,
6627
- (left) => {
6628
- globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
6629
- }
6630
- );
6631
6672
  watch(
6632
6673
  () => uiService?.get("hideSlideBar"),
6633
6674
  (hideSlideBar) => {
@@ -6635,11 +6676,29 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6635
6676
  }
6636
6677
  );
6637
6678
  const columnWidthChange = (columnW) => {
6638
- columnWidth.value.left = columnW.left;
6639
- columnWidth.value.center = columnW.center;
6640
- columnWidth.value.right = columnW.right;
6679
+ columnWidth.value = columnW;
6680
+ globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.left}`);
6681
+ globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.right}`);
6641
6682
  uiService?.set("columnWidth", columnW);
6642
6683
  };
6684
+ const frameworkRect = computed(() => uiService?.get("frameworkRect"));
6685
+ const resizerObserver = new ResizeObserver((entries) => {
6686
+ const { contentRect } = entries[0];
6687
+ uiService?.set("frameworkRect", {
6688
+ width: contentRect.width,
6689
+ height: contentRect.height,
6690
+ left: contentRect.left,
6691
+ top: contentRect.top
6692
+ });
6693
+ });
6694
+ onMounted(() => {
6695
+ if (content.value) {
6696
+ resizerObserver.observe(content.value);
6697
+ }
6698
+ });
6699
+ onBeforeUnmount(() => {
6700
+ resizerObserver.disconnect();
6701
+ });
6643
6702
  const saveCode = (value) => {
6644
6703
  try {
6645
6704
  const parseDSL = getConfig("parseDSL");
@@ -6682,6 +6741,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6682
6741
  "min-left": 65,
6683
6742
  "min-right": 20,
6684
6743
  "min-center": 100,
6744
+ width: frameworkRect.value?.width || 0,
6685
6745
  onChange: columnWidthChange
6686
6746
  }, createSlots({
6687
6747
  left: withCtx(() => [
@@ -6717,7 +6777,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
6717
6777
  ]),
6718
6778
  key: "0"
6719
6779
  } : void 0
6720
- ]), 1032, ["left", "right"])), [
6780
+ ]), 1032, ["left", "right", "width"])), [
6721
6781
  [_directive_loading, stageLoading.value]
6722
6782
  ]),
6723
6783
  renderSlot(_ctx.$slots, "content-after"),
@@ -6932,7 +6992,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6932
6992
  },
6933
6993
  emits: ["mounted", "submit-error", "form-error"],
6934
6994
  setup(__props, { expose: __expose, emit: __emit }) {
6995
+ const codeOptions = inject("codeOptions", {});
6935
6996
  const emit = __emit;
6997
+ const showSrc = ref(false);
6936
6998
  const internalInstance = getCurrentInstance();
6937
6999
  const values = ref({});
6938
7000
  const configForm = ref();
@@ -6942,6 +7004,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6942
7004
  const nodes = computed(() => services?.editorService.get("nodes") || []);
6943
7005
  const propsPanelSize = computed(() => services?.uiService.get("propsPanelSize") || "small");
6944
7006
  const stage = computed(() => services?.editorService.get("stage"));
7007
+ const { height: editorContentHeight } = useEditorContentHeight();
6945
7008
  const init = async () => {
6946
7009
  if (!node.value) {
6947
7010
  curFormConfig.value = [];
@@ -6975,6 +7038,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6975
7038
  const errorHandler = (e) => {
6976
7039
  emit("form-error", e);
6977
7040
  };
7041
+ const saveCode = (values2) => {
7042
+ services?.editorService.update(values2);
7043
+ };
6978
7044
  __expose({ configForm, submit });
6979
7045
  return (_ctx, _cache) => {
6980
7046
  return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$a, [
@@ -6990,7 +7056,24 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
6990
7056
  "extend-state": _ctx.extendState,
6991
7057
  onChange: submit,
6992
7058
  onError: errorHandler
6993
- }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"])
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)
6994
7077
  ], 512)), [
6995
7078
  [vShow, nodes.value.length === 1]
6996
7079
  ]);
@@ -7015,33 +7098,33 @@ const useFloatBox = (slideKeys) => {
7015
7098
  const showingBoxKeys = computed(
7016
7099
  () => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
7017
7100
  );
7018
- const isDraging = ref(false);
7019
- const dragstartHandler = () => isDraging.value = true;
7101
+ const isDragging = ref(false);
7102
+ const dragstartHandler = () => isDragging.value = true;
7020
7103
  const dragendHandler = (key, e) => {
7021
7104
  floatBoxStates.value[key] = {
7022
7105
  left: e.clientX,
7023
7106
  top: e.clientY,
7024
7107
  status: true
7025
7108
  };
7026
- isDraging.value = false;
7109
+ isDragging.value = false;
7027
7110
  };
7028
7111
  document.body.addEventListener("dragover", (e) => {
7029
- if (!isDraging.value)
7112
+ if (!isDragging.value)
7030
7113
  return;
7031
7114
  e.preventDefault();
7032
7115
  });
7033
7116
  watch(
7034
7117
  () => slideKeys.value,
7035
- () => {
7036
- for (const key in slideKeys.value) {
7118
+ (slideKeys2) => {
7119
+ slideKeys2.forEach((key) => {
7037
7120
  if (floatBoxStates.value[key])
7038
- continue;
7121
+ return;
7039
7122
  floatBoxStates.value[key] = {
7040
7123
  status: false,
7041
7124
  top: 0,
7042
7125
  left: 0
7043
7126
  };
7044
- }
7127
+ });
7045
7128
  },
7046
7129
  {
7047
7130
  deep: true,
@@ -9002,6 +9085,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9002
9085
  setup(__props, { expose: __expose }) {
9003
9086
  const props = __props;
9004
9087
  const services = inject("services");
9088
+ const columnLeftWitch = computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
9005
9089
  const activeTabName = ref(props.data?.status);
9006
9090
  const getItemConfig = (data) => {
9007
9091
  const map = {
@@ -9230,6 +9314,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9230
9314
  key: config.$key ?? index,
9231
9315
  visible: unref(floatBoxStates)[config.$key].status,
9232
9316
  "onUpdate:visible": ($event) => unref(floatBoxStates)[config.$key].status = $event,
9317
+ width: columnLeftWitch.value,
9318
+ height: 600,
9233
9319
  title: config.text,
9234
9320
  position: {
9235
9321
  left: unref(floatBoxStates)[config.$key].left,
@@ -9242,7 +9328,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9242
9328
  ])
9243
9329
  ]),
9244
9330
  _: 2
9245
- }, 1032, ["visible", "onUpdate:visible", "title", "position"])) : createCommentVNode("", true)
9331
+ }, 1032, ["visible", "onUpdate:visible", "width", "title", "position"])) : createCommentVNode("", true)
9246
9332
  ], 64);
9247
9333
  }), 256))
9248
9334
  ]))
@@ -9601,6 +9687,12 @@ const state = reactive({
9601
9687
  top: 0,
9602
9688
  width: 0,
9603
9689
  height: 0
9690
+ },
9691
+ frameworkRect: {
9692
+ width: 0,
9693
+ height: 0,
9694
+ left: 0,
9695
+ top: 0
9604
9696
  }
9605
9697
  });
9606
9698
  const canUsePluginMethods$2 = {
@@ -10975,7 +11067,7 @@ class StageOverlay extends BaseService {
10975
11067
  subStage?.renderer.contentWindow?.magic.onPageElUpdate(wrapDiv);
10976
11068
  });
10977
11069
  if (await stageOptions?.canSelect?.(contentEl)) {
10978
- subStage?.select(contentEl);
11070
+ subStage?.select(contentEl.id);
10979
11071
  }
10980
11072
  }
10981
11073
  updateHandler = () => {
@@ -11594,4 +11686,4 @@ const index = {
11594
11686
  }
11595
11687
  };
11596
11688
 
11597
- 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, useFloatBox, useStage, warn };
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 };