@tmagic/editor 1.4.3 → 1.4.4

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 (33) hide show
  1. package/dist/style.css +15 -1
  2. package/dist/tmagic-editor.js +1236 -1162
  3. package/dist/tmagic-editor.umd.cjs +1254 -1179
  4. package/package.json +11 -11
  5. package/src/Editor.vue +6 -1
  6. package/src/editorProps.ts +3 -0
  7. package/src/fields/CodeSelectCol.vue +26 -18
  8. package/src/fields/DataSourceFieldSelect.vue +20 -20
  9. package/src/fields/DataSourceMethodSelect.vue +25 -31
  10. package/src/fields/DataSourceSelect.vue +49 -13
  11. package/src/fields/EventSelect.vue +8 -6
  12. package/src/hooks/use-editor-content-height.ts +11 -5
  13. package/src/layouts/PropsPanel.vue +3 -1
  14. package/src/layouts/sidebar/Sidebar.vue +24 -8
  15. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +6 -1
  16. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +6 -1
  17. package/src/services/ui.ts +1 -0
  18. package/src/theme/data-source-field.scss +12 -0
  19. package/src/theme/props-panel.scss +1 -1
  20. package/src/theme/theme.scss +1 -0
  21. package/src/type.ts +31 -2
  22. package/types/components/ContentMenu.vue.d.ts +3 -3
  23. package/types/components/ToolButton.vue.d.ts +2 -2
  24. package/types/editorProps.d.ts +3 -0
  25. package/types/layouts/PropsPanel.vue.d.ts +2 -0
  26. package/types/layouts/sidebar/Sidebar.vue.d.ts +7 -7
  27. package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +2 -2
  28. package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +4 -4
  29. package/types/layouts/sidebar/layer/use-click.d.ts +13 -13
  30. package/types/layouts/workspace/Workspace.vue.d.ts +4 -4
  31. package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +2 -2
  32. package/types/services/ui.d.ts +18 -0
  33. package/types/type.d.ts +26 -2
@@ -1,24 +1,24 @@
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';
1
+ import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, ref, watch, onMounted, onBeforeUnmount, Teleport, normalizeStyle, computed, reactive, resolveComponent, inject, createCommentVNode, mergeModels, useModel, nextTick, provide, renderSlot, toDisplayString, createTextVNode, isRef, mergeProps, Fragment, renderList, createStaticVNode, watchEffect, withModifiers, toHandlers, resolveDirective, withDirectives, createSlots, markRaw, getCurrentInstance, vShow, Transition, mergeDefaults } from 'vue';
2
+ import { Edit, FullScreen, View, Close, 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 { 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';
5
+ import { TMagicIcon, TMagicButton, TMagicCard, useZIndex, tMagicMessage, tMagicMessageBox, getConfig as getConfig$1, TMagicTag, TMagicDialog, 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
- import { MContainer, MFormBox, MForm, filterFunction, createValues, MCascader, MSelect } from '@tmagic/form';
8
+ import { MContainer, MForm, filterFunction, createValues, MFormBox, MCascader, MSelect, MPanel } from '@tmagic/form';
9
9
  import { HookCodeType, HookType, NodeType, ActionType } from '@tmagic/schema';
10
- import VanillaMoveable from 'moveable';
11
10
  import { MagicTable } from '@tmagic/table';
12
11
  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';
12
+ import VanillaMoveable from 'moveable';
13
13
  import { Watcher, DepTargetType, createRelatedCompTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
14
14
  export { DepTargetType } from '@tmagic/dep';
15
+ import { EventEmitter } from 'events';
15
16
  import Gesto from 'gesto';
16
17
  import StageCore, { GuidesType, getOffset, calcValueByFontsize, RenderType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
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"];
21
+ const _hoisted_1$u = ["src"];
22
22
  const _sfc_main$U = /* @__PURE__ */ defineComponent({
23
23
  ...{
24
24
  name: "MEditorIcon"
@@ -43,7 +43,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
43
43
  class: "magic-editor-icon"
44
44
  }, {
45
45
  default: withCtx(() => [
46
- createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$t)
46
+ createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$u)
47
47
  ]),
48
48
  _: 1
49
49
  })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
@@ -71,7 +71,7 @@ const getConfig = (key) => $TMAGIC_EDITOR[key];
71
71
  emmetHTML(monaco);
72
72
  emmetCSS(monaco, ["css", "scss"]);
73
73
 
74
- const _hoisted_1$s = {
74
+ const _hoisted_1$t = {
75
75
  class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
76
76
  };
77
77
  const _sfc_main$T = /* @__PURE__ */ defineComponent({
@@ -232,7 +232,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
232
232
  }
233
233
  });
234
234
  return (_ctx, _cache) => {
235
- return openBlock(), createElementBlock("div", _hoisted_1$s, [
235
+ return openBlock(), createElementBlock("div", _hoisted_1$t, [
236
236
  (openBlock(), createBlock(Teleport, {
237
237
  to: "body",
238
238
  disabled: !fullScreen.value
@@ -505,689 +505,164 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
505
505
  }
506
506
  });
507
507
 
508
- const _sfc_main$P = /* @__PURE__ */ defineComponent({
509
- __name: "FloatingBox",
510
- props: /* @__PURE__ */ mergeModels({
511
- position: { default: () => ({ left: 0, top: 0 }) },
512
- title: { default: "" },
513
- beforeClose: {}
514
- }, {
515
- "width": { default: 0 },
516
- "widthModifiers": {},
517
- "height": { default: 0 },
518
- "heightModifiers": {},
519
- "visible": { type: Boolean, ...{ default: false } },
520
- "visibleModifiers": {}
521
- }),
522
- emits: ["update:width", "update:height", "update:visible"],
523
- setup(__props, { expose: __expose }) {
524
- const width = useModel(__props, "width");
525
- const height = useModel(__props, "height");
526
- const visible = useModel(__props, "visible");
527
- const props = __props;
528
- const target = ref();
529
- const titleEl = ref();
530
- const zIndex = useZIndex();
531
- const curZIndex = ref(0);
532
- const titleHeight = ref(0);
533
- const bodyHeight = computed(() => {
534
- if (height.value) {
535
- return height.value - titleHeight.value;
536
- }
537
- if (target.value) {
538
- return target.value.clientHeight - titleHeight.value;
508
+ function BaseFormConfig() {
509
+ return [
510
+ {
511
+ name: "id",
512
+ type: "hidden"
513
+ },
514
+ {
515
+ name: "type",
516
+ text: "类型",
517
+ type: "hidden",
518
+ defaultValue: "base"
519
+ },
520
+ {
521
+ name: "title",
522
+ text: "名称",
523
+ rules: [
524
+ {
525
+ required: true,
526
+ message: "请输入名称"
527
+ }
528
+ ]
529
+ },
530
+ {
531
+ name: "description",
532
+ text: "描述"
533
+ }
534
+ ];
535
+ }
536
+
537
+ const HttpFormConfig = [
538
+ {
539
+ name: "autoFetch",
540
+ text: "自动请求",
541
+ type: "switch",
542
+ defaultValue: true
543
+ },
544
+ {
545
+ name: "responseOptions",
546
+ items: [
547
+ {
548
+ name: "dataPath",
549
+ text: "数据路径"
539
550
  }
540
- return "auto";
541
- });
542
- const services = inject("services");
543
- const frameworkWidth = computed(() => services?.uiService.get("frameworkRect").width || 0);
544
- const style = computed(() => {
545
- let { left } = props.position;
546
- if (width.value) {
547
- left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
551
+ ]
552
+ },
553
+ {
554
+ type: "fieldset",
555
+ name: "options",
556
+ legend: "HTTP 配置",
557
+ items: [
558
+ {
559
+ name: "url",
560
+ text: "URL"
561
+ },
562
+ {
563
+ name: "method",
564
+ text: "Method",
565
+ type: "select",
566
+ options: [
567
+ { text: "GET", value: "GET" },
568
+ { text: "POST", value: "POST" },
569
+ { text: "PUT", value: "PUT" },
570
+ { text: "DELETE", value: "DELETE" }
571
+ ]
572
+ },
573
+ {
574
+ name: "params",
575
+ type: "key-value",
576
+ defaultValue: {},
577
+ text: "参数"
578
+ },
579
+ {
580
+ name: "data",
581
+ type: "key-value",
582
+ defaultValue: {},
583
+ advanced: true,
584
+ text: "请求体"
585
+ },
586
+ {
587
+ name: "headers",
588
+ type: "key-value",
589
+ defaultValue: {},
590
+ text: "请求头"
548
591
  }
549
- return {
550
- left: `${left}px`,
551
- top: `${props.position.top}px`,
552
- width: width.value ? `${width.value}px` : "auto",
553
- height: height.value ? `${height.value}px` : "auto"
554
- };
555
- });
556
- let moveable = null;
557
- const initMoveable = () => {
558
- moveable = new VanillaMoveable(globalThis.document.body, {
559
- className: "m-editor-floating-box-moveable",
560
- target: target.value,
561
- draggable: true,
562
- resizable: true,
563
- edge: true,
564
- keepRatio: false,
565
- origin: false,
566
- snappable: true,
567
- dragTarget: titleEl.value,
568
- dragTargetSelf: false,
569
- linePadding: 10,
570
- controlPadding: 10,
571
- bounds: { left: 0, top: 0, right: 0, bottom: 0, position: "css" }
572
- });
573
- moveable.on("drag", (e) => {
574
- e.target.style.transform = e.transform;
575
- });
576
- moveable.on("resize", (e) => {
577
- width.value = e.width;
578
- height.value = e.height;
579
- e.target.style.width = `${e.width}px`;
580
- e.target.style.height = `${e.height}px`;
581
- e.target.style.transform = e.drag.transform;
582
- });
583
- };
584
- const destroyMoveable = () => {
585
- moveable?.destroy();
586
- moveable = null;
587
- };
588
- watch(
589
- visible,
590
- async (visible2) => {
591
- if (visible2) {
592
- await nextTick();
593
- curZIndex.value = zIndex.nextZIndex();
594
- const targetRect = target.value?.getBoundingClientRect();
595
- if (targetRect) {
596
- width.value = targetRect.width;
597
- height.value = targetRect.height;
598
- initMoveable();
592
+ ]
593
+ }
594
+ ];
595
+
596
+ const fillConfig$1 = (config) => [
597
+ ...BaseFormConfig(),
598
+ ...config,
599
+ {
600
+ type: "tab",
601
+ items: [
602
+ {
603
+ title: "数据定义",
604
+ items: [
605
+ {
606
+ name: "fields",
607
+ type: "data-source-fields",
608
+ defaultValue: () => []
599
609
  }
600
- if (titleEl.value) {
601
- const titleRect = titleEl.value.getBoundingClientRect();
602
- titleHeight.value = titleRect.height;
610
+ ]
611
+ },
612
+ {
613
+ title: "方法定义",
614
+ items: [
615
+ {
616
+ name: "methods",
617
+ type: "data-source-methods",
618
+ defaultValue: () => []
603
619
  }
604
- } else {
605
- destroyMoveable();
606
- }
620
+ ]
607
621
  },
608
622
  {
609
- immediate: true
610
- }
611
- );
612
- onBeforeUnmount(() => {
613
- destroyMoveable();
614
- });
615
- const hide = (cancel) => {
616
- if (cancel !== false) {
617
- visible.value = false;
618
- }
619
- };
620
- const closeHandler = () => {
621
- if (typeof props.beforeClose === "function") {
622
- props.beforeClose(hide);
623
- } else {
624
- hide();
625
- }
626
- };
627
- const nextZIndex = () => {
628
- curZIndex.value = zIndex.nextZIndex();
629
- };
630
- provide("parentFloating", target);
631
- __expose({
632
- bodyHeight,
633
- target,
634
- titleEl
635
- });
636
- return (_ctx, _cache) => {
637
- return visible.value ? (openBlock(), createBlock(Teleport, {
638
- key: 0,
639
- to: "body"
640
- }, [
641
- createElementVNode("div", {
642
- ref_key: "target",
643
- ref: target,
644
- class: "m-editor-float-box",
645
- style: normalizeStyle({ ...style.value, zIndex: curZIndex.value }),
646
- onMousedown: nextZIndex
647
- }, [
648
- createElementVNode("div", {
649
- ref_key: "titleEl",
650
- ref: titleEl,
651
- class: "m-editor-float-box-title"
652
- }, [
653
- renderSlot(_ctx.$slots, "title", {}, () => [
654
- createElementVNode("span", null, toDisplayString(_ctx.title), 1)
655
- ]),
656
- createElementVNode("div", null, [
657
- createVNode(unref(TMagicButton), {
658
- link: "",
659
- size: "small",
660
- onClick: closeHandler
661
- }, {
662
- default: withCtx(() => [
663
- createVNode(_sfc_main$U, { icon: unref(Close) }, null, 8, ["icon"])
664
- ]),
665
- _: 1
666
- })
667
- ])
668
- ], 512),
669
- createElementVNode("div", {
670
- class: "m-editor-float-box-body",
671
- style: normalizeStyle({ height: `${bodyHeight.value}px` })
672
- }, [
673
- renderSlot(_ctx.$slots, "body")
674
- ], 4)
675
- ], 36)
676
- ])) : createCommentVNode("", true);
677
- };
678
- }
679
- });
680
-
681
- const useEditorContentHeight = () => {
682
- const services = inject("services");
683
- const frameworkHeight = computed(() => services?.uiService.get("frameworkRect").height || 0);
684
- const navMenuHeight = computed(() => services?.uiService.get("navMenuRect").height || 0);
685
- const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
686
- const height = ref(0);
687
- watchEffect(() => {
688
- if (height.value > 0 && height.value === editorContentHeight.value)
689
- return;
690
- height.value = editorContentHeight.value;
691
- });
692
- return {
693
- height
694
- };
695
- };
696
-
697
- const useNextFloatBoxPosition = (uiService, parent) => {
698
- const boxPosition = ref({
699
- left: 0,
700
- top: 0
701
- });
702
- const calcBoxPosition = () => {
703
- const columnWidth = uiService?.get("columnWidth");
704
- const navMenuRect = uiService?.get("navMenuRect");
705
- let left = columnWidth?.left ?? 0;
706
- if (parent?.value) {
707
- const rect = parent?.value?.getBoundingClientRect();
708
- left = (rect?.left ?? 0) + (rect?.width ?? 0);
709
- }
710
- boxPosition.value = {
711
- left,
712
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
713
- };
714
- };
715
- return {
716
- boxPosition,
717
- calcBoxPosition
718
- };
719
- };
720
-
721
- const useWindowRect = () => {
722
- const rect = reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
723
- const windowResizeHandler = () => {
724
- rect.width = globalThis.innerWidth;
725
- rect.height = globalThis.innerHeight;
726
- };
727
- globalThis.addEventListener("resize", windowResizeHandler);
728
- onBeforeUnmount(() => {
729
- globalThis.removeEventListener("resize", windowResizeHandler);
730
- });
731
- return {
732
- rect
733
- };
734
- };
735
-
736
- const _hoisted_1$r = { style: { "display": "flex", "margin-bottom": "10px" } };
737
- const _hoisted_2$k = { style: { "flex": "1" } };
738
- const _hoisted_3$8 = { style: { "flex": "1" } };
739
- const _hoisted_4$7 = { class: "dialog-footer" };
740
- const _sfc_main$O = /* @__PURE__ */ defineComponent({
741
- ...{
742
- name: "MEditorCodeBlockEditor"
743
- },
744
- __name: "CodeBlockEditor",
745
- props: /* @__PURE__ */ mergeModels({
746
- content: {},
747
- disabled: { type: Boolean },
748
- isDataSource: { type: Boolean },
749
- dataSourceType: {}
750
- }, {
751
- "width": { default: 670 },
752
- "widthModifiers": {},
753
- "visible": { type: Boolean, ...{ default: false } },
754
- "visibleModifiers": {}
755
- }),
756
- emits: /* @__PURE__ */ mergeModels(["submit"], ["update:width", "update:visible"]),
757
- setup(__props, { expose: __expose, emit: __emit }) {
758
- const width = useModel(__props, "width");
759
- const boxVisible = useModel(__props, "visible");
760
- const props = __props;
761
- const emit = __emit;
762
- const services = inject("services");
763
- const { height: codeBlockEditorHeight } = useEditorContentHeight();
764
- const difVisible = ref(false);
765
- const { rect: windowRect } = useWindowRect();
766
- const magicVsEditor = ref();
767
- const diffChange = () => {
768
- if (!magicVsEditor.value || !formBox.value?.form) {
769
- return;
770
- }
771
- formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
772
- difVisible.value = false;
773
- };
774
- const defaultParamColConfig = {
775
- type: "row",
776
- label: "参数类型",
777
- items: [
778
- {
779
- text: "参数类型",
780
- labelWidth: "70px",
781
- type: "select",
782
- name: "type",
783
- options: [
784
- {
785
- text: "数字",
786
- label: "数字",
787
- value: "number"
788
- },
789
- {
790
- text: "字符串",
791
- label: "字符串",
792
- value: "text"
793
- },
794
- {
795
- text: "组件",
796
- label: "组件",
797
- value: "ui-select"
798
- }
799
- ]
800
- }
801
- ]
802
- };
803
- const functionConfig = computed(() => [
804
- {
805
- text: "名称",
806
- name: "name",
807
- rules: [{ required: true, message: "请输入名称", trigger: "blur" }]
808
- },
809
- {
810
- text: "描述",
811
- name: "desc"
812
- },
813
- {
814
- text: "执行时机",
815
- name: "timing",
816
- type: "select",
817
- options: () => {
818
- const options = [
819
- { text: "初始化前", value: "beforeInit" },
820
- { text: "初始化后", value: "afterInit" }
821
- ];
822
- if (props.dataSourceType !== "base") {
823
- options.push({ text: "请求前", value: "beforeRequest" });
824
- options.push({ text: "请求后", value: "afterRequest" });
825
- }
826
- return options;
827
- },
828
- display: () => props.isDataSource
829
- },
830
- {
831
- type: "table",
832
- border: true,
833
- text: "参数",
834
- enableFullscreen: false,
835
- enableToggleMode: false,
836
- name: "params",
837
- dropSort: false,
838
- items: [
839
- {
840
- type: "text",
841
- label: "参数名",
842
- name: "name"
843
- },
844
- {
845
- type: "text",
846
- label: "描述",
847
- name: "extra"
848
- },
849
- services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
850
- ]
851
- },
852
- {
853
- name: "content",
854
- type: "vs-code",
855
- options: inject("codeOptions", {}),
856
- height: "500px",
857
- onChange: (formState, code) => {
858
- try {
859
- getConfig("parseDSL")(code);
860
- return code;
861
- } catch (error) {
862
- tMagicMessage.error(error.message);
863
- throw error;
864
- }
865
- }
866
- }
867
- ]);
868
- const submitForm = (values) => {
869
- changedValue.value = void 0;
870
- emit("submit", values);
871
- };
872
- const errorHandler = (error) => {
873
- tMagicMessage.error(error.message);
874
- };
875
- const formBox = ref();
876
- const changedValue = ref();
877
- const changeHandler = (values) => {
878
- changedValue.value = values;
879
- };
880
- const beforeClose = (done) => {
881
- if (!changedValue.value) {
882
- done();
883
- return;
884
- }
885
- tMagicMessageBox.confirm("当前代码块已修改,是否保存?", "提示", {
886
- confirmButtonText: "保存并关闭",
887
- cancelButtonText: "不保存并关闭",
888
- type: "warning",
889
- distinguishCancelAndClose: true
890
- }).then(() => {
891
- changedValue.value && submitForm(changedValue.value);
892
- done();
893
- }).catch((action) => {
894
- done(action === "cancel");
895
- });
896
- };
897
- const closedHandler = () => {
898
- changedValue.value = void 0;
899
- };
900
- const parentFloating = inject("parentFloating", ref(null));
901
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
902
- __expose({
903
- async show() {
904
- calcBoxPosition();
905
- boxVisible.value = true;
906
- },
907
- async hide() {
908
- boxVisible.value = false;
909
- }
910
- });
911
- return (_ctx, _cache) => {
912
- return openBlock(), createElementBlock(Fragment, null, [
913
- createVNode(_sfc_main$P, {
914
- visible: boxVisible.value,
915
- "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
916
- width: width.value,
917
- "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
918
- height: unref(codeBlockEditorHeight),
919
- "onUpdate:height": _cache[3] || (_cache[3] = ($event) => isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
920
- title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
921
- position: unref(boxPosition),
922
- "before-close": beforeClose
923
- }, {
924
- body: withCtx(() => [
925
- createVNode(unref(MFormBox), {
926
- class: "m-editor-code-block-editor",
927
- ref_key: "formBox",
928
- ref: formBox,
929
- "label-width": "80px",
930
- "close-on-press-escape": false,
931
- title: _ctx.content.name,
932
- config: functionConfig.value,
933
- values: _ctx.content,
934
- disabled: _ctx.disabled,
935
- style: { "height": "100%" },
936
- onChange: changeHandler,
937
- onSubmit: submitForm,
938
- onError: errorHandler,
939
- onClosed: closedHandler
940
- }, {
941
- left: withCtx(() => [
942
- !_ctx.disabled ? (openBlock(), createBlock(unref(TMagicButton), {
943
- key: 0,
944
- type: "primary",
945
- link: "",
946
- onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
947
- }, {
948
- default: withCtx(() => [
949
- createTextVNode("查看修改")
950
- ]),
951
- _: 1
952
- })) : createCommentVNode("", true)
953
- ]),
954
- _: 1
955
- }, 8, ["title", "config", "values", "disabled"])
956
- ]),
957
- _: 1
958
- }, 8, ["visible", "width", "height", "title", "position"]),
959
- (openBlock(), createBlock(Teleport, { to: "body" }, [
960
- createVNode(unref(TMagicDialog), {
961
- title: "查看修改",
962
- modelValue: difVisible.value,
963
- "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
964
- fullscreen: ""
965
- }, {
966
- footer: withCtx(() => [
967
- createElementVNode("span", _hoisted_4$7, [
968
- createVNode(unref(TMagicButton), {
969
- size: "small",
970
- onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
971
- }, {
972
- default: withCtx(() => [
973
- createTextVNode("取消")
974
- ]),
975
- _: 1
976
- }),
977
- createVNode(unref(TMagicButton), {
978
- size: "small",
979
- type: "primary",
980
- onClick: diffChange
981
- }, {
982
- default: withCtx(() => [
983
- createTextVNode("确定")
984
- ]),
985
- _: 1
986
- })
987
- ])
988
- ]),
989
- default: withCtx(() => [
990
- createElementVNode("div", _hoisted_1$r, [
991
- createElementVNode("div", _hoisted_2$k, [
992
- createVNode(unref(TMagicTag), {
993
- size: "small",
994
- type: "info"
995
- }, {
996
- default: withCtx(() => [
997
- createTextVNode("修改前")
998
- ]),
999
- _: 1
1000
- })
1001
- ]),
1002
- createElementVNode("div", _hoisted_3$8, [
1003
- createVNode(unref(TMagicTag), {
1004
- size: "small",
1005
- type: "success"
1006
- }, {
1007
- default: withCtx(() => [
1008
- createTextVNode("修改后")
1009
- ]),
1010
- _: 1
1011
- })
1012
- ])
1013
- ]),
1014
- difVisible.value ? (openBlock(), createBlock(_sfc_main$T, {
1015
- key: 0,
1016
- ref_key: "magicVsEditor",
1017
- ref: magicVsEditor,
1018
- type: "diff",
1019
- language: "json",
1020
- initValues: _ctx.content.content,
1021
- modifiedValues: formBox.value?.form?.values.content,
1022
- style: normalizeStyle(`height: ${unref(windowRect).height - 150}px`)
1023
- }, null, 8, ["initValues", "modifiedValues", "style"])) : createCommentVNode("", true)
1024
- ]),
1025
- _: 1
1026
- }, 8, ["modelValue"])
1027
- ]))
1028
- ], 64);
1029
- };
1030
- }
1031
- });
1032
-
1033
- function BaseFormConfig() {
1034
- return [
1035
- {
1036
- name: "id",
1037
- type: "hidden"
1038
- },
1039
- {
1040
- name: "type",
1041
- text: "类型",
1042
- type: "hidden",
1043
- defaultValue: "base"
1044
- },
1045
- {
1046
- name: "title",
1047
- text: "名称",
1048
- rules: [
1049
- {
1050
- required: true,
1051
- message: "请输入名称"
1052
- }
1053
- ]
1054
- },
1055
- {
1056
- name: "description",
1057
- text: "描述"
1058
- }
1059
- ];
1060
- }
1061
-
1062
- const HttpFormConfig = [
1063
- {
1064
- name: "autoFetch",
1065
- text: "自动请求",
1066
- type: "switch",
1067
- defaultValue: true
1068
- },
1069
- {
1070
- name: "responseOptions",
1071
- items: [
1072
- {
1073
- name: "dataPath",
1074
- text: "数据路径"
1075
- }
1076
- ]
1077
- },
1078
- {
1079
- type: "fieldset",
1080
- name: "options",
1081
- legend: "HTTP 配置",
1082
- items: [
1083
- {
1084
- name: "url",
1085
- text: "URL"
1086
- },
1087
- {
1088
- name: "method",
1089
- text: "Method",
1090
- type: "select",
1091
- options: [
1092
- { text: "GET", value: "GET" },
1093
- { text: "POST", value: "POST" },
1094
- { text: "PUT", value: "PUT" },
1095
- { text: "DELETE", value: "DELETE" }
1096
- ]
1097
- },
1098
- {
1099
- name: "params",
1100
- type: "key-value",
1101
- defaultValue: {},
1102
- text: "参数"
1103
- },
1104
- {
1105
- name: "data",
1106
- type: "key-value",
1107
- defaultValue: {},
1108
- advanced: true,
1109
- text: "请求体"
1110
- },
1111
- {
1112
- name: "headers",
1113
- type: "key-value",
1114
- defaultValue: {},
1115
- text: "请求头"
1116
- }
1117
- ]
1118
- }
1119
- ];
1120
-
1121
- const fillConfig$1 = (config) => [
1122
- ...BaseFormConfig(),
1123
- ...config,
1124
- {
1125
- type: "tab",
1126
- items: [
1127
- {
1128
- title: "数据定义",
1129
- items: [
1130
- {
1131
- name: "fields",
1132
- type: "data-source-fields",
1133
- defaultValue: () => []
1134
- }
1135
- ]
1136
- },
1137
- {
1138
- title: "方法定义",
1139
- items: [
1140
- {
1141
- name: "methods",
1142
- type: "data-source-methods",
1143
- defaultValue: () => []
1144
- }
1145
- ]
1146
- },
1147
- {
1148
- title: "事件配置",
1149
- display: false,
1150
- items: [
1151
- {
1152
- name: "events",
1153
- src: "datasource",
1154
- type: "event-select"
1155
- }
1156
- ]
1157
- },
1158
- {
1159
- title: "mock数据",
1160
- items: [
1161
- {
1162
- name: "mocks",
1163
- type: "data-source-mocks",
1164
- defaultValue: () => []
1165
- }
1166
- ]
1167
- },
1168
- {
1169
- title: "请求参数裁剪",
1170
- display: (formState, { model }) => model.type === "http",
1171
- items: [
1172
- {
1173
- name: "beforeRequest",
1174
- type: "vs-code",
1175
- parse: true,
1176
- height: "600px"
1177
- }
1178
- ]
1179
- },
1180
- {
1181
- title: "响应数据裁剪",
1182
- display: (formState, { model }) => model.type === "http",
1183
- items: [
1184
- {
1185
- name: "afterResponse",
1186
- type: "vs-code",
1187
- parse: true,
1188
- height: "600px"
1189
- }
1190
- ]
623
+ title: "事件配置",
624
+ display: false,
625
+ items: [
626
+ {
627
+ name: "events",
628
+ src: "datasource",
629
+ type: "event-select"
630
+ }
631
+ ]
632
+ },
633
+ {
634
+ title: "mock数据",
635
+ items: [
636
+ {
637
+ name: "mocks",
638
+ type: "data-source-mocks",
639
+ defaultValue: () => []
640
+ }
641
+ ]
642
+ },
643
+ {
644
+ title: "请求参数裁剪",
645
+ display: (formState, { model }) => model.type === "http",
646
+ items: [
647
+ {
648
+ name: "beforeRequest",
649
+ type: "vs-code",
650
+ parse: true,
651
+ height: "600px"
652
+ }
653
+ ]
654
+ },
655
+ {
656
+ title: "响应数据裁剪",
657
+ display: (formState, { model }) => model.type === "http",
658
+ items: [
659
+ {
660
+ name: "afterResponse",
661
+ type: "vs-code",
662
+ parse: true,
663
+ height: "600px"
664
+ }
665
+ ]
1191
666
  }
1192
667
  ]
1193
668
  }
@@ -2052,6 +1527,13 @@ var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
2052
1527
  ColumnLayout2["RIGHT"] = "right";
2053
1528
  return ColumnLayout2;
2054
1529
  })(ColumnLayout || {});
1530
+ var SideItemKey = /* @__PURE__ */ ((SideItemKey2) => {
1531
+ SideItemKey2["COMPONENT_LIST"] = "component-list";
1532
+ SideItemKey2["LAYER"] = "layer";
1533
+ SideItemKey2["CODE_BLOCK"] = "code-block";
1534
+ SideItemKey2["DATA_SOURCE"] = "data-source";
1535
+ return SideItemKey2;
1536
+ })(SideItemKey || {});
2055
1537
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
2056
1538
  LayerOffset2["TOP"] = "top";
2057
1539
  LayerOffset2["BOTTOM"] = "bottom";
@@ -3703,7 +3185,7 @@ const getDefaultConfig = async (addNode, parentNode) => {
3703
3185
  return newNode;
3704
3186
  };
3705
3187
 
3706
- const _sfc_main$N = /* @__PURE__ */ defineComponent({
3188
+ const _sfc_main$P = /* @__PURE__ */ defineComponent({
3707
3189
  ...{
3708
3190
  name: "MEditorCodeParams"
3709
3191
  },
@@ -3753,68 +3235,9 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
3753
3235
  }
3754
3236
  });
3755
3237
 
3756
- const useCodeBlockEdit = (codeBlockService) => {
3757
- const codeConfig = ref();
3758
- const codeId = ref();
3759
- const codeBlockEditor = ref();
3760
- const createCodeBlock = async () => {
3761
- if (!codeBlockService) {
3762
- tMagicMessage.error("新增代码块失败");
3763
- return;
3764
- }
3765
- codeConfig.value = {
3766
- name: "",
3767
- content: `({app, params}) => {
3768
- // place your code here
3769
- }`,
3770
- params: []
3771
- };
3772
- codeId.value = await codeBlockService.getUniqueId();
3773
- await nextTick();
3774
- codeBlockEditor.value?.show();
3775
- };
3776
- const editCode = async (id) => {
3777
- const codeBlock = await codeBlockService?.getCodeContentById(id);
3778
- if (!codeBlock) {
3779
- tMagicMessage.error("获取代码块内容失败");
3780
- return;
3781
- }
3782
- let codeContent = codeBlock.content;
3783
- if (typeof codeContent !== "string") {
3784
- codeContent = codeContent.toString();
3785
- }
3786
- codeConfig.value = {
3787
- ...cloneDeep(codeBlock),
3788
- content: codeContent
3789
- };
3790
- codeId.value = id;
3791
- await nextTick();
3792
- codeBlockEditor.value?.show();
3793
- };
3794
- const deleteCode = async (key) => {
3795
- codeBlockService?.deleteCodeDslByIds([key]);
3796
- };
3797
- const submitCodeBlockHandler = async (values) => {
3798
- if (!codeId.value)
3799
- return;
3800
- await codeBlockService?.setCodeDslById(codeId.value, values);
3801
- tMagicMessage.success("代码块保存成功");
3802
- codeBlockEditor.value?.hide();
3803
- };
3804
- return {
3805
- codeId,
3806
- codeConfig,
3807
- codeBlockEditor,
3808
- createCodeBlock,
3809
- editCode,
3810
- deleteCode,
3811
- submitCodeBlockHandler
3812
- };
3813
- };
3814
-
3815
- const _hoisted_1$q = { class: "m-fields-code-select-col" };
3816
- const _hoisted_2$j = { class: "code-select-container" };
3817
- const _sfc_main$M = /* @__PURE__ */ defineComponent({
3238
+ const _hoisted_1$s = { class: "m-fields-code-select-col" };
3239
+ const _hoisted_2$k = { class: "code-select-container" };
3240
+ const _sfc_main$O = /* @__PURE__ */ defineComponent({
3818
3241
  ...{
3819
3242
  name: "MFieldsCodeSelectCol"
3820
3243
  },
@@ -3834,9 +3257,13 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
3834
3257
  setup(__props, { emit: __emit }) {
3835
3258
  const mForm = inject("mForm");
3836
3259
  const services = inject("services");
3260
+ const eventBus = inject("eventBus");
3837
3261
  const emit = __emit;
3838
- const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
3839
3262
  const props = __props;
3263
+ const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
3264
+ const hasCodeBlockSidePanel = computed(
3265
+ () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
3266
+ );
3840
3267
  const getParamItemsConfig = (codeId) => {
3841
3268
  if (!codeDsl.value || !codeId)
3842
3269
  return [];
@@ -3887,46 +3314,278 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
3887
3314
  props.model.params = value.params;
3888
3315
  emit("change", props.model);
3889
3316
  };
3890
- const { codeBlockEditor, codeConfig, editCode, submitCodeBlockHandler } = useCodeBlockEdit(services?.codeBlockService);
3317
+ const editCode = (id) => {
3318
+ eventBus?.emit("edit-code", id);
3319
+ };
3891
3320
  return (_ctx, _cache) => {
3892
- const _component_m_form_container = resolveComponent("m-form-container");
3893
- return openBlock(), createElementBlock("div", _hoisted_1$q, [
3894
- createElementVNode("div", _hoisted_2$j, [
3895
- createVNode(_component_m_form_container, {
3321
+ return openBlock(), createElementBlock("div", _hoisted_1$s, [
3322
+ createElementVNode("div", _hoisted_2$k, [
3323
+ createVNode(unref(MContainer), {
3896
3324
  class: "select",
3897
3325
  config: selectConfig,
3898
3326
  model: _ctx.model,
3899
3327
  size: _ctx.size,
3900
3328
  onChange: onParamsChangeHandler
3901
3329
  }, null, 8, ["model", "size"]),
3902
- _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$U, {
3330
+ _ctx.model[_ctx.name] && hasCodeBlockSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
3903
3331
  key: 0,
3904
- class: "icon",
3905
- icon: !notEditable.value ? unref(Edit) : unref(View),
3906
- onClick: _cache[0] || (_cache[0] = ($event) => unref(editCode)(_ctx.model[_ctx.name]))
3907
- }, null, 8, ["icon"])) : createCommentVNode("", true)
3332
+ class: "m-fields-select-action-button",
3333
+ size: _ctx.size,
3334
+ onClick: _cache[0] || (_cache[0] = ($event) => editCode(_ctx.model[_ctx.name]))
3335
+ }, {
3336
+ default: withCtx(() => [
3337
+ createVNode(_sfc_main$U, {
3338
+ icon: !notEditable.value ? unref(Edit) : unref(View)
3339
+ }, null, 8, ["icon"])
3340
+ ]),
3341
+ _: 1
3342
+ }, 8, ["size"])) : createCommentVNode("", true)
3908
3343
  ]),
3909
- paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$N, {
3344
+ paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$P, {
3910
3345
  name: "params",
3911
3346
  key: _ctx.model[_ctx.name],
3912
3347
  model: _ctx.model,
3913
3348
  size: _ctx.size,
3914
3349
  "params-config": paramsConfig.value,
3915
3350
  onChange: onParamsChangeHandler
3916
- }, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true),
3917
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
3918
- key: 1,
3919
- ref_key: "codeBlockEditor",
3920
- ref: codeBlockEditor,
3921
- disabled: notEditable.value,
3922
- content: unref(codeConfig),
3923
- onSubmit: unref(submitCodeBlockHandler)
3924
- }, null, 8, ["disabled", "content", "onSubmit"])) : createCommentVNode("", true)
3351
+ }, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true)
3925
3352
  ]);
3926
3353
  };
3927
3354
  }
3928
3355
  });
3929
3356
 
3357
+ const _sfc_main$N = /* @__PURE__ */ defineComponent({
3358
+ __name: "FloatingBox",
3359
+ props: /* @__PURE__ */ mergeModels({
3360
+ position: { default: () => ({ left: 0, top: 0 }) },
3361
+ title: { default: "" },
3362
+ beforeClose: {}
3363
+ }, {
3364
+ "width": { default: 0 },
3365
+ "widthModifiers": {},
3366
+ "height": { default: 0 },
3367
+ "heightModifiers": {},
3368
+ "visible": { type: Boolean, ...{ default: false } },
3369
+ "visibleModifiers": {}
3370
+ }),
3371
+ emits: ["update:width", "update:height", "update:visible"],
3372
+ setup(__props, { expose: __expose }) {
3373
+ const width = useModel(__props, "width");
3374
+ const height = useModel(__props, "height");
3375
+ const visible = useModel(__props, "visible");
3376
+ const props = __props;
3377
+ const target = ref();
3378
+ const titleEl = ref();
3379
+ const zIndex = useZIndex();
3380
+ const curZIndex = ref(0);
3381
+ const titleHeight = ref(0);
3382
+ const bodyHeight = computed(() => {
3383
+ if (height.value) {
3384
+ return height.value - titleHeight.value;
3385
+ }
3386
+ if (target.value) {
3387
+ return target.value.clientHeight - titleHeight.value;
3388
+ }
3389
+ return "auto";
3390
+ });
3391
+ const services = inject("services");
3392
+ const frameworkWidth = computed(() => services?.uiService.get("frameworkRect").width || 0);
3393
+ const style = computed(() => {
3394
+ let { left } = props.position;
3395
+ if (width.value) {
3396
+ left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
3397
+ }
3398
+ return {
3399
+ left: `${left}px`,
3400
+ top: `${props.position.top}px`,
3401
+ width: width.value ? `${width.value}px` : "auto",
3402
+ height: height.value ? `${height.value}px` : "auto"
3403
+ };
3404
+ });
3405
+ let moveable = null;
3406
+ const initMoveable = () => {
3407
+ moveable = new VanillaMoveable(globalThis.document.body, {
3408
+ className: "m-editor-floating-box-moveable",
3409
+ target: target.value,
3410
+ draggable: true,
3411
+ resizable: true,
3412
+ edge: true,
3413
+ keepRatio: false,
3414
+ origin: false,
3415
+ snappable: true,
3416
+ dragTarget: titleEl.value,
3417
+ dragTargetSelf: false,
3418
+ linePadding: 10,
3419
+ controlPadding: 10,
3420
+ bounds: { left: 0, top: 0, right: 0, bottom: 0, position: "css" }
3421
+ });
3422
+ moveable.on("drag", (e) => {
3423
+ e.target.style.transform = e.transform;
3424
+ });
3425
+ moveable.on("resize", (e) => {
3426
+ width.value = e.width;
3427
+ height.value = e.height;
3428
+ e.target.style.width = `${e.width}px`;
3429
+ e.target.style.height = `${e.height}px`;
3430
+ e.target.style.transform = e.drag.transform;
3431
+ });
3432
+ };
3433
+ const destroyMoveable = () => {
3434
+ moveable?.destroy();
3435
+ moveable = null;
3436
+ };
3437
+ watch(
3438
+ visible,
3439
+ async (visible2) => {
3440
+ if (visible2) {
3441
+ await nextTick();
3442
+ curZIndex.value = zIndex.nextZIndex();
3443
+ const targetRect = target.value?.getBoundingClientRect();
3444
+ if (targetRect) {
3445
+ width.value = targetRect.width;
3446
+ height.value = targetRect.height;
3447
+ initMoveable();
3448
+ }
3449
+ if (titleEl.value) {
3450
+ const titleRect = titleEl.value.getBoundingClientRect();
3451
+ titleHeight.value = titleRect.height;
3452
+ }
3453
+ } else {
3454
+ destroyMoveable();
3455
+ }
3456
+ },
3457
+ {
3458
+ immediate: true
3459
+ }
3460
+ );
3461
+ onBeforeUnmount(() => {
3462
+ destroyMoveable();
3463
+ });
3464
+ const hide = (cancel) => {
3465
+ if (cancel !== false) {
3466
+ visible.value = false;
3467
+ }
3468
+ };
3469
+ const closeHandler = () => {
3470
+ if (typeof props.beforeClose === "function") {
3471
+ props.beforeClose(hide);
3472
+ } else {
3473
+ hide();
3474
+ }
3475
+ };
3476
+ const nextZIndex = () => {
3477
+ curZIndex.value = zIndex.nextZIndex();
3478
+ };
3479
+ provide("parentFloating", target);
3480
+ __expose({
3481
+ bodyHeight,
3482
+ target,
3483
+ titleEl
3484
+ });
3485
+ return (_ctx, _cache) => {
3486
+ return visible.value ? (openBlock(), createBlock(Teleport, {
3487
+ key: 0,
3488
+ to: "body"
3489
+ }, [
3490
+ createElementVNode("div", {
3491
+ ref_key: "target",
3492
+ ref: target,
3493
+ class: "m-editor-float-box",
3494
+ style: normalizeStyle({ ...style.value, zIndex: curZIndex.value }),
3495
+ onMousedown: nextZIndex
3496
+ }, [
3497
+ createElementVNode("div", {
3498
+ ref_key: "titleEl",
3499
+ ref: titleEl,
3500
+ class: "m-editor-float-box-title"
3501
+ }, [
3502
+ renderSlot(_ctx.$slots, "title", {}, () => [
3503
+ createElementVNode("span", null, toDisplayString(_ctx.title), 1)
3504
+ ]),
3505
+ createElementVNode("div", null, [
3506
+ createVNode(unref(TMagicButton), {
3507
+ link: "",
3508
+ size: "small",
3509
+ onClick: closeHandler
3510
+ }, {
3511
+ default: withCtx(() => [
3512
+ createVNode(_sfc_main$U, { icon: unref(Close) }, null, 8, ["icon"])
3513
+ ]),
3514
+ _: 1
3515
+ })
3516
+ ])
3517
+ ], 512),
3518
+ createElementVNode("div", {
3519
+ class: "m-editor-float-box-body",
3520
+ style: normalizeStyle({ height: `${bodyHeight.value}px` })
3521
+ }, [
3522
+ renderSlot(_ctx.$slots, "body")
3523
+ ], 4)
3524
+ ], 36)
3525
+ ])) : createCommentVNode("", true);
3526
+ };
3527
+ }
3528
+ });
3529
+
3530
+ const useCodeBlockEdit = (codeBlockService) => {
3531
+ const codeConfig = ref();
3532
+ const codeId = ref();
3533
+ const codeBlockEditor = ref();
3534
+ const createCodeBlock = async () => {
3535
+ if (!codeBlockService) {
3536
+ tMagicMessage.error("新增代码块失败");
3537
+ return;
3538
+ }
3539
+ codeConfig.value = {
3540
+ name: "",
3541
+ content: `({app, params}) => {
3542
+ // place your code here
3543
+ }`,
3544
+ params: []
3545
+ };
3546
+ codeId.value = await codeBlockService.getUniqueId();
3547
+ await nextTick();
3548
+ codeBlockEditor.value?.show();
3549
+ };
3550
+ const editCode = async (id) => {
3551
+ const codeBlock = await codeBlockService?.getCodeContentById(id);
3552
+ if (!codeBlock) {
3553
+ tMagicMessage.error("获取代码块内容失败");
3554
+ return;
3555
+ }
3556
+ let codeContent = codeBlock.content;
3557
+ if (typeof codeContent !== "string") {
3558
+ codeContent = codeContent.toString();
3559
+ }
3560
+ codeConfig.value = {
3561
+ ...cloneDeep(codeBlock),
3562
+ content: codeContent
3563
+ };
3564
+ codeId.value = id;
3565
+ await nextTick();
3566
+ codeBlockEditor.value?.show();
3567
+ };
3568
+ const deleteCode = async (key) => {
3569
+ codeBlockService?.deleteCodeDslByIds([key]);
3570
+ };
3571
+ const submitCodeBlockHandler = async (values) => {
3572
+ if (!codeId.value)
3573
+ return;
3574
+ await codeBlockService?.setCodeDslById(codeId.value, values);
3575
+ tMagicMessage.success("代码块保存成功");
3576
+ codeBlockEditor.value?.hide();
3577
+ };
3578
+ return {
3579
+ codeId,
3580
+ codeConfig,
3581
+ codeBlockEditor,
3582
+ createCodeBlock,
3583
+ editCode,
3584
+ deleteCode,
3585
+ submitCodeBlockHandler
3586
+ };
3587
+ };
3588
+
3930
3589
  const useDataSourceMethod = () => {
3931
3590
  const codeConfig = ref();
3932
3591
  const codeBlockEditor = ref();
@@ -4021,6 +3680,7 @@ const state = reactive({
4021
3680
  propsPanelSize: "small",
4022
3681
  showAddPageButton: true,
4023
3682
  hideSlideBar: false,
3683
+ sideBarItems: [],
4024
3684
  navMenuRect: {
4025
3685
  left: 0,
4026
3686
  top: 0,
@@ -4264,9 +3924,70 @@ const useFloatBox = (slideKeys) => {
4264
3924
  };
4265
3925
  };
4266
3926
 
4267
- const _hoisted_1$p = { class: "m-editor-data-source-fields" };
4268
- const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
4269
- const _sfc_main$L = /* @__PURE__ */ defineComponent({
3927
+ const useWindowRect = () => {
3928
+ const rect = reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
3929
+ const windowResizeHandler = () => {
3930
+ rect.width = globalThis.innerWidth;
3931
+ rect.height = globalThis.innerHeight;
3932
+ };
3933
+ globalThis.addEventListener("resize", windowResizeHandler);
3934
+ onBeforeUnmount(() => {
3935
+ globalThis.removeEventListener("resize", windowResizeHandler);
3936
+ });
3937
+ return {
3938
+ rect
3939
+ };
3940
+ };
3941
+
3942
+ const useEditorContentHeight = () => {
3943
+ const services = inject("services");
3944
+ const frameworkHeight = computed(() => services?.uiService.get("frameworkRect").height || 0);
3945
+ const navMenuHeight = computed(() => services?.uiService.get("navMenuRect").height || 0);
3946
+ const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
3947
+ const height = ref(0);
3948
+ watch(
3949
+ editorContentHeight,
3950
+ () => {
3951
+ if (height.value > 0 && height.value === editorContentHeight.value)
3952
+ return;
3953
+ height.value = editorContentHeight.value;
3954
+ },
3955
+ {
3956
+ immediate: true
3957
+ }
3958
+ );
3959
+ return {
3960
+ height
3961
+ };
3962
+ };
3963
+
3964
+ const useNextFloatBoxPosition = (uiService, parent) => {
3965
+ const boxPosition = ref({
3966
+ left: 0,
3967
+ top: 0
3968
+ });
3969
+ const calcBoxPosition = () => {
3970
+ const columnWidth = uiService?.get("columnWidth");
3971
+ const navMenuRect = uiService?.get("navMenuRect");
3972
+ let left = columnWidth?.left ?? 0;
3973
+ if (parent?.value) {
3974
+ const rect = parent?.value?.getBoundingClientRect();
3975
+ left = (rect?.left ?? 0) + (rect?.width ?? 0);
3976
+ }
3977
+ boxPosition.value = {
3978
+ left,
3979
+ top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
3980
+ };
3981
+ };
3982
+ return {
3983
+ boxPosition,
3984
+ calcBoxPosition
3985
+ };
3986
+ };
3987
+
3988
+ const _hoisted_1$r = { class: "m-editor-data-source-fields" };
3989
+ const _hoisted_2$j = { class: "m-editor-data-source-fields-footer" };
3990
+ const _sfc_main$M = /* @__PURE__ */ defineComponent({
4270
3991
  ...{
4271
3992
  name: "MFieldsDataSourceFields"
4272
3993
  },
@@ -4521,12 +4242,12 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4521
4242
  const parentFloating = inject("parentFloating", ref(null));
4522
4243
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4523
4244
  return (_ctx, _cache) => {
4524
- return openBlock(), createElementBlock("div", _hoisted_1$p, [
4245
+ return openBlock(), createElementBlock("div", _hoisted_1$r, [
4525
4246
  createVNode(unref(MagicTable), {
4526
4247
  data: _ctx.model[_ctx.name],
4527
4248
  columns: fieldColumns
4528
4249
  }, null, 8, ["data"]),
4529
- createElementVNode("div", _hoisted_2$i, [
4250
+ createElementVNode("div", _hoisted_2$j, [
4530
4251
  createVNode(unref(TMagicButton), {
4531
4252
  size: "small",
4532
4253
  disabled: _ctx.disabled,
@@ -4551,7 +4272,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4551
4272
  _: 1
4552
4273
  }, 8, ["disabled"])
4553
4274
  ]),
4554
- createVNode(_sfc_main$P, {
4275
+ createVNode(_sfc_main$N, {
4555
4276
  visible: addDialogVisible.value,
4556
4277
  "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
4557
4278
  width: width.value,
@@ -4574,7 +4295,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4574
4295
  ]),
4575
4296
  _: 1
4576
4297
  }, 8, ["visible", "width", "height", "title", "position"]),
4577
- createVNode(_sfc_main$P, {
4298
+ createVNode(_sfc_main$N, {
4578
4299
  visible: addFromJsonDialogVisible.value,
4579
4300
  "onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
4580
4301
  width: width.value,
@@ -4589,125 +4310,18 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4589
4310
  config: jsonFromConfig,
4590
4311
  values: jsonFromValues.value,
4591
4312
  disabled: _ctx.disabled,
4592
- onSubmit: addFromJsonFromChange
4593
- }, null, 8, ["values", "disabled"])
4594
- ]),
4595
- _: 1
4596
- }, 8, ["visible", "width", "height", "position"])
4597
- ]);
4598
- };
4599
- }
4600
- });
4601
-
4602
- const useDataSourceEdit = (dataSourceService) => {
4603
- const dialogTitle = ref("");
4604
- const editDialog = ref();
4605
- const dataSourceValues = ref({});
4606
- const editable = computed(() => dataSourceService?.get("editable") ?? true);
4607
- const editHandler = (id) => {
4608
- if (!editDialog.value)
4609
- return;
4610
- dataSourceValues.value = {
4611
- ...dataSourceService?.getDataSourceById(id)
4612
- };
4613
- dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
4614
- editDialog.value.show();
4615
- };
4616
- const submitDataSourceHandler = (value) => {
4617
- if (value.id) {
4618
- dataSourceService?.update(value);
4619
- } else {
4620
- dataSourceService?.add(value);
4621
- }
4622
- editDialog.value?.hide();
4623
- };
4624
- return {
4625
- dialogTitle,
4626
- editDialog,
4627
- dataSourceValues,
4628
- editable,
4629
- editHandler,
4630
- submitDataSourceHandler
4631
- };
4632
- };
4633
-
4634
- const _sfc_main$K = /* @__PURE__ */ defineComponent({
4635
- ...{
4636
- name: "MEditorDataSourceConfigPanel"
4637
- },
4638
- __name: "DataSourceConfigPanel",
4639
- props: /* @__PURE__ */ mergeModels({
4640
- title: {},
4641
- values: {},
4642
- disabled: { type: Boolean }
4643
- }, {
4644
- "visible": { type: Boolean, ...{ default: false } },
4645
- "visibleModifiers": {},
4646
- "width": { default: 670 },
4647
- "widthModifiers": {}
4648
- }),
4649
- emits: /* @__PURE__ */ mergeModels(["submit"], ["update:visible", "update:width"]),
4650
- setup(__props, { expose: __expose, emit: __emit }) {
4651
- const props = __props;
4652
- const boxVisible = useModel(__props, "visible");
4653
- const width = useModel(__props, "width");
4654
- const emit = __emit;
4655
- const services = inject("services");
4656
- const initValues = ref({});
4657
- const dataSourceConfig = ref([]);
4658
- const { height: editorHeight } = useEditorContentHeight();
4659
- const parentFloating = inject("parentFloating", ref(null));
4660
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4661
- watchEffect(() => {
4662
- initValues.value = props.values;
4663
- dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
4664
- });
4665
- const submitHandler = (values) => {
4666
- emit("submit", values);
4667
- };
4668
- const errorHandler = (error) => {
4669
- tMagicMessage.error(error.message);
4670
- };
4671
- __expose({
4672
- show() {
4673
- calcBoxPosition();
4674
- boxVisible.value = true;
4675
- },
4676
- hide() {
4677
- boxVisible.value = false;
4678
- }
4679
- });
4680
- return (_ctx, _cache) => {
4681
- return openBlock(), createBlock(_sfc_main$P, {
4682
- visible: boxVisible.value,
4683
- "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
4684
- width: width.value,
4685
- "onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
4686
- height: unref(editorHeight),
4687
- "onUpdate:height": _cache[2] || (_cache[2] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
4688
- title: _ctx.title,
4689
- position: unref(boxPosition)
4690
- }, {
4691
- body: withCtx(() => [
4692
- createVNode(unref(MFormBox), {
4693
- "label-width": "80px",
4694
- title: _ctx.title,
4695
- config: dataSourceConfig.value,
4696
- values: initValues.value,
4697
- disabled: _ctx.disabled,
4698
- style: { "height": "100%" },
4699
- onSubmit: submitHandler,
4700
- onError: errorHandler
4701
- }, null, 8, ["title", "config", "values", "disabled"])
4702
- ]),
4703
- _: 1
4704
- }, 8, ["visible", "width", "height", "title", "position"]);
4313
+ onSubmit: addFromJsonFromChange
4314
+ }, null, 8, ["values", "disabled"])
4315
+ ]),
4316
+ _: 1
4317
+ }, 8, ["visible", "width", "height", "position"])
4318
+ ]);
4705
4319
  };
4706
4320
  }
4707
4321
  });
4708
4322
 
4709
- const _hoisted_1$o = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
4710
- const _sfc_main$J = /* @__PURE__ */ defineComponent({
4323
+ const _hoisted_1$q = { class: "m-fields-data-source-field-select" };
4324
+ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4711
4325
  ...{
4712
4326
  name: "MFieldsDataSourceFieldSelect"
4713
4327
  },
@@ -4726,8 +4340,13 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4726
4340
  emits: ["change"],
4727
4341
  setup(__props, { emit: __emit }) {
4728
4342
  const services = inject("services");
4343
+ const eventBus = inject("eventBus");
4729
4344
  const emit = __emit;
4730
4345
  const props = __props;
4346
+ const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
4347
+ const hasDataSourceSidePanel = computed(
4348
+ () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
4349
+ );
4731
4350
  const selectedDataSourceId = computed(() => {
4732
4351
  const value = props.model[props.name];
4733
4352
  if (!Array.isArray(value) || !value.length) {
@@ -4819,11 +4438,11 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4819
4438
  const onChangeHandler = (value) => {
4820
4439
  emit("change", value);
4821
4440
  };
4822
- const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(
4823
- services?.dataSourceService
4824
- );
4441
+ const editHandler = (id) => {
4442
+ eventBus?.emit("edit-data-source", id);
4443
+ };
4825
4444
  return (_ctx, _cache) => {
4826
- return openBlock(), createElementBlock("div", _hoisted_1$o, [
4445
+ return openBlock(), createElementBlock("div", _hoisted_1$q, [
4827
4446
  (openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
4828
4447
  style: { "width": "100%" },
4829
4448
  config: showDataSourceFieldSelect.value || !_ctx.config.fieldConfig ? cascaderConfig.value : _ctx.config.fieldConfig,
@@ -4837,14 +4456,16 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4837
4456
  prop: `${_ctx.prop}${_ctx.prop ? "." : ""}${_ctx.name}`,
4838
4457
  onChange: onChangeHandler
4839
4458
  }, null, 40, ["config", "model", "name", "disabled", "size", "last-values", "init-values", "values", "prop"])),
4840
- (showDataSourceFieldSelect.value || !_ctx.config.fieldConfig) && selectedDataSourceId.value ? (openBlock(), createBlock(unref(TMagicButton), {
4459
+ (showDataSourceFieldSelect.value || !_ctx.config.fieldConfig) && selectedDataSourceId.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
4841
4460
  key: 0,
4842
- style: { "margin-left": "5px" },
4461
+ class: "m-fields-select-action-button",
4843
4462
  size: _ctx.size,
4844
- onClick: _cache[0] || (_cache[0] = ($event) => unref(editHandler)(selectedDataSourceId.value))
4463
+ onClick: _cache[0] || (_cache[0] = ($event) => editHandler(selectedDataSourceId.value))
4845
4464
  }, {
4846
4465
  default: withCtx(() => [
4847
- createVNode(_sfc_main$U, { icon: unref(Edit) }, null, 8, ["icon"])
4466
+ createVNode(_sfc_main$U, {
4467
+ icon: !notEditable.value ? unref(Edit) : unref(View)
4468
+ }, null, 8, ["icon"])
4848
4469
  ]),
4849
4470
  _: 1
4850
4471
  }, 8, ["size"])) : createCommentVNode("", true),
@@ -4859,24 +4480,16 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4859
4480
  createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
4860
4481
  ]),
4861
4482
  _: 1
4862
- }, 8, ["type", "size"])) : createCommentVNode("", true),
4863
- createVNode(_sfc_main$K, {
4864
- ref_key: "editDialog",
4865
- ref: editDialog,
4866
- disabled: !unref(editable),
4867
- values: unref(dataSourceValues),
4868
- title: unref(dialogTitle),
4869
- onSubmit: unref(submitDataSourceHandler)
4870
- }, null, 8, ["disabled", "values", "title", "onSubmit"])
4483
+ }, 8, ["type", "size"])) : createCommentVNode("", true)
4871
4484
  ]);
4872
4485
  };
4873
4486
  }
4874
4487
  });
4875
4488
 
4876
- const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4877
- const _hoisted_2$h = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4878
- const _hoisted_3$7 = { class: "el-input__inner t-input__inner" };
4879
- const _sfc_main$I = /* @__PURE__ */ defineComponent({
4489
+ const _hoisted_1$p = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4490
+ const _hoisted_2$i = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4491
+ const _hoisted_3$8 = { class: "el-input__inner t-input__inner" };
4492
+ const _sfc_main$K = /* @__PURE__ */ defineComponent({
4880
4493
  ...{
4881
4494
  name: "MFieldsDataSourceInput"
4882
4495
  },
@@ -4983,138 +4596,435 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
4983
4596
  }
4984
4597
  }
4985
4598
  }
4986
- if (curCharIsDot(dotIndex)) {
4987
- result = fields || [];
4988
- } else if (dotIndex > -1) {
4989
- const queryName = queryString.substring(dotIndex + 1).toLowerCase();
4990
- result = fields.filter(
4991
- (field) => field.name?.toLowerCase().includes(queryName) || field.title?.toLowerCase().includes(queryName)
4992
- ) || [];
4993
- }
4994
- cb(
4995
- result.map((field) => ({
4996
- value: field.name,
4997
- text: field.title,
4998
- type: "field"
4999
- }))
5000
- );
4599
+ if (curCharIsDot(dotIndex)) {
4600
+ result = fields || [];
4601
+ } else if (dotIndex > -1) {
4602
+ const queryName = queryString.substring(dotIndex + 1).toLowerCase();
4603
+ result = fields.filter(
4604
+ (field) => field.name?.toLowerCase().includes(queryName) || field.title?.toLowerCase().includes(queryName)
4605
+ ) || [];
4606
+ }
4607
+ cb(
4608
+ result.map((field) => ({
4609
+ value: field.name,
4610
+ text: field.title,
4611
+ type: "field"
4612
+ }))
4613
+ );
4614
+ };
4615
+ const querySearch = (queryString, cb) => {
4616
+ inputText = queryString;
4617
+ const selectionStart = getSelectionStart();
4618
+ const curQueryString = queryString.substring(0, selectionStart);
4619
+ const fieldKeyStringLastIndex = curQueryString.lastIndexOf(".");
4620
+ const dsKeyStringLastIndex = curQueryString.lastIndexOf("${") + 1;
4621
+ const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
4622
+ if (isFieldTip) {
4623
+ fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
4624
+ } else {
4625
+ dsQuerySearch(curQueryString, dsKeyStringLastIndex, cb);
4626
+ }
4627
+ };
4628
+ const selectHandler = async ({ value, type }) => {
4629
+ const isDataSource = type === "dataSource";
4630
+ const selectionStart = input.value?.selectionStart || 0;
4631
+ let startText = inputText.substring(0, selectionStart);
4632
+ const dotIndex = startText.lastIndexOf(".");
4633
+ const leftCurlyBracketIndex = startText.lastIndexOf("${") + 1;
4634
+ const endText = inputText.substring(selectionStart);
4635
+ let suggestText = value;
4636
+ if (isDataSource) {
4637
+ if (!curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
4638
+ startText = startText.substring(0, leftCurlyBracketIndex + 1);
4639
+ }
4640
+ if (!isRightCurlyBracket(selectionStart + 1)) {
4641
+ suggestText = `${suggestText}}`;
4642
+ }
4643
+ } else if (!curCharIsDot(dotIndex)) {
4644
+ startText = startText.substring(0, dotIndex + 1);
4645
+ }
4646
+ state.value = `${startText}${suggestText}${endText}`;
4647
+ await nextTick();
4648
+ let newSelectionStart = 0;
4649
+ if (isDataSource) {
4650
+ newSelectionStart = leftCurlyBracketIndex + suggestText.length;
4651
+ } else {
4652
+ newSelectionStart = dotIndex + suggestText.length + 1;
4653
+ }
4654
+ input.value?.setSelectionRange(newSelectionStart, newSelectionStart);
4655
+ changeHandler(state.value);
4656
+ };
4657
+ return (_ctx, _cache) => {
4658
+ return _ctx.disabled || isFocused.value ? (openBlock(), createBlock(resolveDynamicComponent(unref(getConfig$1)("components")?.autocomplete.component || "el-autocomplete"), mergeProps(
4659
+ {
4660
+ key: 0,
4661
+ class: "tmagic-design-auto-complete",
4662
+ ref_key: "autocomplete",
4663
+ ref: autocomplete,
4664
+ modelValue: state.value,
4665
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
4666
+ },
4667
+ unref(getConfig$1)("components")?.autocomplete.props({
4668
+ disabled: _ctx.disabled,
4669
+ size: _ctx.size,
4670
+ fetchSuggestions: querySearch,
4671
+ triggerOnFocus: false,
4672
+ clearable: true
4673
+ }) || {},
4674
+ {
4675
+ style: { "width": "100%" },
4676
+ onBlur: blurHandler,
4677
+ onInput: inputHandler,
4678
+ onSelect: selectHandler
4679
+ }
4680
+ ), {
4681
+ suffix: withCtx(() => [
4682
+ createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
4683
+ ]),
4684
+ default: withCtx(({ item }) => [
4685
+ createElementVNode("div", _hoisted_1$p, [
4686
+ createElementVNode("div", null, toDisplayString(item.text), 1),
4687
+ createElementVNode("span", _hoisted_2$i, toDisplayString(item.value), 1)
4688
+ ])
4689
+ ]),
4690
+ _: 1
4691
+ }, 16, ["modelValue"])) : (openBlock(), createElementBlock("div", {
4692
+ key: 1,
4693
+ class: normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
4694
+ onMouseup: mouseupHandler
4695
+ }, [
4696
+ createElementVNode("div", {
4697
+ class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
4698
+ }, [
4699
+ createElementVNode("div", _hoisted_3$8, [
4700
+ (openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
4701
+ return openBlock(), createElementBlock(Fragment, null, [
4702
+ item.type === "text" ? (openBlock(), createElementBlock("span", {
4703
+ key: index,
4704
+ style: { "margin-right": "2px" }
4705
+ }, toDisplayString(item.value), 1)) : createCommentVNode("", true),
4706
+ item.type === "var" ? (openBlock(), createBlock(unref(TMagicTag), {
4707
+ key: index,
4708
+ size: _ctx.size
4709
+ }, {
4710
+ default: withCtx(() => [
4711
+ createTextVNode(toDisplayString(item.value), 1)
4712
+ ]),
4713
+ _: 2
4714
+ }, 1032, ["size"])) : createCommentVNode("", true)
4715
+ ], 64);
4716
+ }), 256)),
4717
+ createVNode(_sfc_main$U, {
4718
+ class: "tmagic-data-source-input-icon",
4719
+ icon: unref(Coin)
4720
+ }, null, 8, ["icon"])
4721
+ ])
4722
+ ], 2)
4723
+ ], 34));
4724
+ };
4725
+ }
4726
+ });
4727
+
4728
+ const _hoisted_1$o = { style: { "display": "flex", "margin-bottom": "10px" } };
4729
+ const _hoisted_2$h = { style: { "flex": "1" } };
4730
+ const _hoisted_3$7 = { style: { "flex": "1" } };
4731
+ const _hoisted_4$7 = { class: "dialog-footer" };
4732
+ const _sfc_main$J = /* @__PURE__ */ defineComponent({
4733
+ ...{
4734
+ name: "MEditorCodeBlockEditor"
4735
+ },
4736
+ __name: "CodeBlockEditor",
4737
+ props: /* @__PURE__ */ mergeModels({
4738
+ content: {},
4739
+ disabled: { type: Boolean },
4740
+ isDataSource: { type: Boolean },
4741
+ dataSourceType: {}
4742
+ }, {
4743
+ "width": { default: 670 },
4744
+ "widthModifiers": {},
4745
+ "visible": { type: Boolean, ...{ default: false } },
4746
+ "visibleModifiers": {}
4747
+ }),
4748
+ emits: /* @__PURE__ */ mergeModels(["submit"], ["update:width", "update:visible"]),
4749
+ setup(__props, { expose: __expose, emit: __emit }) {
4750
+ const width = useModel(__props, "width");
4751
+ const boxVisible = useModel(__props, "visible");
4752
+ const props = __props;
4753
+ const emit = __emit;
4754
+ const services = inject("services");
4755
+ const { height: codeBlockEditorHeight } = useEditorContentHeight();
4756
+ const difVisible = ref(false);
4757
+ const { rect: windowRect } = useWindowRect();
4758
+ const magicVsEditor = ref();
4759
+ const diffChange = () => {
4760
+ if (!magicVsEditor.value || !formBox.value?.form) {
4761
+ return;
4762
+ }
4763
+ formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
4764
+ difVisible.value = false;
4765
+ };
4766
+ const defaultParamColConfig = {
4767
+ type: "row",
4768
+ label: "参数类型",
4769
+ items: [
4770
+ {
4771
+ text: "参数类型",
4772
+ labelWidth: "70px",
4773
+ type: "select",
4774
+ name: "type",
4775
+ options: [
4776
+ {
4777
+ text: "数字",
4778
+ label: "数字",
4779
+ value: "number"
4780
+ },
4781
+ {
4782
+ text: "字符串",
4783
+ label: "字符串",
4784
+ value: "text"
4785
+ },
4786
+ {
4787
+ text: "组件",
4788
+ label: "组件",
4789
+ value: "ui-select"
4790
+ }
4791
+ ]
4792
+ }
4793
+ ]
4794
+ };
4795
+ const functionConfig = computed(() => [
4796
+ {
4797
+ text: "名称",
4798
+ name: "name",
4799
+ rules: [{ required: true, message: "请输入名称", trigger: "blur" }]
4800
+ },
4801
+ {
4802
+ text: "描述",
4803
+ name: "desc"
4804
+ },
4805
+ {
4806
+ text: "执行时机",
4807
+ name: "timing",
4808
+ type: "select",
4809
+ options: () => {
4810
+ const options = [
4811
+ { text: "初始化前", value: "beforeInit" },
4812
+ { text: "初始化后", value: "afterInit" }
4813
+ ];
4814
+ if (props.dataSourceType !== "base") {
4815
+ options.push({ text: "请求前", value: "beforeRequest" });
4816
+ options.push({ text: "请求后", value: "afterRequest" });
4817
+ }
4818
+ return options;
4819
+ },
4820
+ display: () => props.isDataSource
4821
+ },
4822
+ {
4823
+ type: "table",
4824
+ border: true,
4825
+ text: "参数",
4826
+ enableFullscreen: false,
4827
+ enableToggleMode: false,
4828
+ name: "params",
4829
+ dropSort: false,
4830
+ items: [
4831
+ {
4832
+ type: "text",
4833
+ label: "参数名",
4834
+ name: "name"
4835
+ },
4836
+ {
4837
+ type: "text",
4838
+ label: "描述",
4839
+ name: "extra"
4840
+ },
4841
+ services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
4842
+ ]
4843
+ },
4844
+ {
4845
+ name: "content",
4846
+ type: "vs-code",
4847
+ options: inject("codeOptions", {}),
4848
+ height: "500px",
4849
+ onChange: (formState, code) => {
4850
+ try {
4851
+ getConfig("parseDSL")(code);
4852
+ return code;
4853
+ } catch (error) {
4854
+ tMagicMessage.error(error.message);
4855
+ throw error;
4856
+ }
4857
+ }
4858
+ }
4859
+ ]);
4860
+ const submitForm = (values) => {
4861
+ changedValue.value = void 0;
4862
+ emit("submit", values);
5001
4863
  };
5002
- const querySearch = (queryString, cb) => {
5003
- inputText = queryString;
5004
- const selectionStart = getSelectionStart();
5005
- const curQueryString = queryString.substring(0, selectionStart);
5006
- const fieldKeyStringLastIndex = curQueryString.lastIndexOf(".");
5007
- const dsKeyStringLastIndex = curQueryString.lastIndexOf("${") + 1;
5008
- const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
5009
- if (isFieldTip) {
5010
- fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
5011
- } else {
5012
- dsQuerySearch(curQueryString, dsKeyStringLastIndex, cb);
5013
- }
4864
+ const errorHandler = (error) => {
4865
+ tMagicMessage.error(error.message);
5014
4866
  };
5015
- const selectHandler = async ({ value, type }) => {
5016
- const isDataSource = type === "dataSource";
5017
- const selectionStart = input.value?.selectionStart || 0;
5018
- let startText = inputText.substring(0, selectionStart);
5019
- const dotIndex = startText.lastIndexOf(".");
5020
- const leftCurlyBracketIndex = startText.lastIndexOf("${") + 1;
5021
- const endText = inputText.substring(selectionStart);
5022
- let suggestText = value;
5023
- if (isDataSource) {
5024
- if (!curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
5025
- startText = startText.substring(0, leftCurlyBracketIndex + 1);
5026
- }
5027
- if (!isRightCurlyBracket(selectionStart + 1)) {
5028
- suggestText = `${suggestText}}`;
5029
- }
5030
- } else if (!curCharIsDot(dotIndex)) {
5031
- startText = startText.substring(0, dotIndex + 1);
5032
- }
5033
- state.value = `${startText}${suggestText}${endText}`;
5034
- await nextTick();
5035
- let newSelectionStart = 0;
5036
- if (isDataSource) {
5037
- newSelectionStart = leftCurlyBracketIndex + suggestText.length;
5038
- } else {
5039
- newSelectionStart = dotIndex + suggestText.length + 1;
4867
+ const formBox = ref();
4868
+ const changedValue = ref();
4869
+ const changeHandler = (values) => {
4870
+ changedValue.value = values;
4871
+ };
4872
+ const beforeClose = (done) => {
4873
+ if (!changedValue.value) {
4874
+ done();
4875
+ return;
5040
4876
  }
5041
- input.value?.setSelectionRange(newSelectionStart, newSelectionStart);
5042
- changeHandler(state.value);
4877
+ tMagicMessageBox.confirm("当前代码块已修改,是否保存?", "提示", {
4878
+ confirmButtonText: "保存并关闭",
4879
+ cancelButtonText: "不保存并关闭",
4880
+ type: "warning",
4881
+ distinguishCancelAndClose: true
4882
+ }).then(() => {
4883
+ changedValue.value && submitForm(changedValue.value);
4884
+ done();
4885
+ }).catch((action) => {
4886
+ done(action === "cancel");
4887
+ });
5043
4888
  };
4889
+ const closedHandler = () => {
4890
+ changedValue.value = void 0;
4891
+ };
4892
+ const parentFloating = inject("parentFloating", ref(null));
4893
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4894
+ __expose({
4895
+ async show() {
4896
+ calcBoxPosition();
4897
+ boxVisible.value = true;
4898
+ },
4899
+ async hide() {
4900
+ boxVisible.value = false;
4901
+ }
4902
+ });
5044
4903
  return (_ctx, _cache) => {
5045
- return _ctx.disabled || isFocused.value ? (openBlock(), createBlock(resolveDynamicComponent(unref(getConfig$1)("components")?.autocomplete.component || "el-autocomplete"), mergeProps(
5046
- {
5047
- key: 0,
5048
- class: "tmagic-design-auto-complete",
5049
- ref_key: "autocomplete",
5050
- ref: autocomplete,
5051
- modelValue: state.value,
5052
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
5053
- },
5054
- unref(getConfig$1)("components")?.autocomplete.props({
5055
- disabled: _ctx.disabled,
5056
- size: _ctx.size,
5057
- fetchSuggestions: querySearch,
5058
- triggerOnFocus: false,
5059
- clearable: true
5060
- }) || {},
5061
- {
5062
- style: { "width": "100%" },
5063
- onBlur: blurHandler,
5064
- onInput: inputHandler,
5065
- onSelect: selectHandler
5066
- }
5067
- ), {
5068
- suffix: withCtx(() => [
5069
- createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
5070
- ]),
5071
- default: withCtx(({ item }) => [
5072
- createElementVNode("div", _hoisted_1$n, [
5073
- createElementVNode("div", null, toDisplayString(item.text), 1),
5074
- createElementVNode("span", _hoisted_2$h, toDisplayString(item.value), 1)
5075
- ])
5076
- ]),
5077
- _: 1
5078
- }, 16, ["modelValue"])) : (openBlock(), createElementBlock("div", {
5079
- key: 1,
5080
- class: normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
5081
- onMouseup: mouseupHandler
5082
- }, [
5083
- createElementVNode("div", {
5084
- class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
5085
- }, [
5086
- createElementVNode("div", _hoisted_3$7, [
5087
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
5088
- return openBlock(), createElementBlock(Fragment, null, [
5089
- item.type === "text" ? (openBlock(), createElementBlock("span", {
5090
- key: index,
5091
- style: { "margin-right": "2px" }
5092
- }, toDisplayString(item.value), 1)) : createCommentVNode("", true),
5093
- item.type === "var" ? (openBlock(), createBlock(unref(TMagicTag), {
5094
- key: index,
5095
- size: _ctx.size
4904
+ return openBlock(), createElementBlock(Fragment, null, [
4905
+ createVNode(_sfc_main$N, {
4906
+ visible: boxVisible.value,
4907
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
4908
+ width: width.value,
4909
+ "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
4910
+ height: unref(codeBlockEditorHeight),
4911
+ "onUpdate:height": _cache[3] || (_cache[3] = ($event) => isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
4912
+ title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
4913
+ position: unref(boxPosition),
4914
+ "before-close": beforeClose
4915
+ }, {
4916
+ body: withCtx(() => [
4917
+ createVNode(unref(MFormBox), {
4918
+ class: "m-editor-code-block-editor",
4919
+ ref_key: "formBox",
4920
+ ref: formBox,
4921
+ "label-width": "80px",
4922
+ "close-on-press-escape": false,
4923
+ title: _ctx.content.name,
4924
+ config: functionConfig.value,
4925
+ values: _ctx.content,
4926
+ disabled: _ctx.disabled,
4927
+ style: { "height": "100%" },
4928
+ onChange: changeHandler,
4929
+ onSubmit: submitForm,
4930
+ onError: errorHandler,
4931
+ onClosed: closedHandler
4932
+ }, {
4933
+ left: withCtx(() => [
4934
+ !_ctx.disabled ? (openBlock(), createBlock(unref(TMagicButton), {
4935
+ key: 0,
4936
+ type: "primary",
4937
+ link: "",
4938
+ onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
5096
4939
  }, {
5097
4940
  default: withCtx(() => [
5098
- createTextVNode(toDisplayString(item.value), 1)
4941
+ createTextVNode("查看修改")
5099
4942
  ]),
5100
- _: 2
5101
- }, 1032, ["size"])) : createCommentVNode("", true)
5102
- ], 64);
5103
- }), 256)),
5104
- createVNode(_sfc_main$U, {
5105
- class: "tmagic-data-source-input-icon",
5106
- icon: unref(Coin)
5107
- }, null, 8, ["icon"])
5108
- ])
5109
- ], 2)
5110
- ], 34));
4943
+ _: 1
4944
+ })) : createCommentVNode("", true)
4945
+ ]),
4946
+ _: 1
4947
+ }, 8, ["title", "config", "values", "disabled"])
4948
+ ]),
4949
+ _: 1
4950
+ }, 8, ["visible", "width", "height", "title", "position"]),
4951
+ (openBlock(), createBlock(Teleport, { to: "body" }, [
4952
+ createVNode(unref(TMagicDialog), {
4953
+ title: "查看修改",
4954
+ modelValue: difVisible.value,
4955
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
4956
+ fullscreen: ""
4957
+ }, {
4958
+ footer: withCtx(() => [
4959
+ createElementVNode("span", _hoisted_4$7, [
4960
+ createVNode(unref(TMagicButton), {
4961
+ size: "small",
4962
+ onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
4963
+ }, {
4964
+ default: withCtx(() => [
4965
+ createTextVNode("取消")
4966
+ ]),
4967
+ _: 1
4968
+ }),
4969
+ createVNode(unref(TMagicButton), {
4970
+ size: "small",
4971
+ type: "primary",
4972
+ onClick: diffChange
4973
+ }, {
4974
+ default: withCtx(() => [
4975
+ createTextVNode("确定")
4976
+ ]),
4977
+ _: 1
4978
+ })
4979
+ ])
4980
+ ]),
4981
+ default: withCtx(() => [
4982
+ createElementVNode("div", _hoisted_1$o, [
4983
+ createElementVNode("div", _hoisted_2$h, [
4984
+ createVNode(unref(TMagicTag), {
4985
+ size: "small",
4986
+ type: "info"
4987
+ }, {
4988
+ default: withCtx(() => [
4989
+ createTextVNode("修改前")
4990
+ ]),
4991
+ _: 1
4992
+ })
4993
+ ]),
4994
+ createElementVNode("div", _hoisted_3$7, [
4995
+ createVNode(unref(TMagicTag), {
4996
+ size: "small",
4997
+ type: "success"
4998
+ }, {
4999
+ default: withCtx(() => [
5000
+ createTextVNode("修改后")
5001
+ ]),
5002
+ _: 1
5003
+ })
5004
+ ])
5005
+ ]),
5006
+ difVisible.value ? (openBlock(), createBlock(_sfc_main$T, {
5007
+ key: 0,
5008
+ ref_key: "magicVsEditor",
5009
+ ref: magicVsEditor,
5010
+ type: "diff",
5011
+ language: "json",
5012
+ initValues: _ctx.content.content,
5013
+ modifiedValues: formBox.value?.form?.values.content,
5014
+ style: normalizeStyle(`height: ${unref(windowRect).height - 150}px`)
5015
+ }, null, 8, ["initValues", "modifiedValues", "style"])) : createCommentVNode("", true)
5016
+ ]),
5017
+ _: 1
5018
+ }, 8, ["modelValue"])
5019
+ ]))
5020
+ ], 64);
5111
5021
  };
5112
5022
  }
5113
5023
  });
5114
5024
 
5115
- const _hoisted_1$m = { class: "m-editor-data-source-methods" };
5025
+ const _hoisted_1$n = { class: "m-editor-data-source-methods" };
5116
5026
  const _hoisted_2$g = { class: "m-editor-data-source-methods-footer" };
5117
- const _sfc_main$H = /* @__PURE__ */ defineComponent({
5027
+ const _sfc_main$I = /* @__PURE__ */ defineComponent({
5118
5028
  ...{
5119
5029
  name: "MFieldsDataSourceMethods"
5120
5030
  },
@@ -5184,7 +5094,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
5184
5094
  emit("change", props.model[props.name]);
5185
5095
  };
5186
5096
  return (_ctx, _cache) => {
5187
- return openBlock(), createElementBlock("div", _hoisted_1$m, [
5097
+ return openBlock(), createElementBlock("div", _hoisted_1$n, [
5188
5098
  createVNode(unref(MagicTable), {
5189
5099
  data: _ctx.model[_ctx.name],
5190
5100
  columns: methodColumns
@@ -5203,7 +5113,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
5203
5113
  _: 1
5204
5114
  }, 8, ["disabled"])
5205
5115
  ]),
5206
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
5116
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$J, {
5207
5117
  key: 0,
5208
5118
  ref_key: "codeBlockEditor",
5209
5119
  ref: codeBlockEditor,
@@ -5218,9 +5128,9 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
5218
5128
  }
5219
5129
  });
5220
5130
 
5221
- const _hoisted_1$l = { class: "m-fields-data-source-method-select" };
5131
+ const _hoisted_1$m = { class: "m-fields-data-source-method-select" };
5222
5132
  const _hoisted_2$f = { class: "data-source-method-select-container" };
5223
- const _sfc_main$G = /* @__PURE__ */ defineComponent({
5133
+ const _sfc_main$H = /* @__PURE__ */ defineComponent({
5224
5134
  ...{
5225
5135
  name: "MFieldsDataSourceMethodSelect"
5226
5136
  },
@@ -5240,9 +5150,13 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5240
5150
  setup(__props, { emit: __emit }) {
5241
5151
  const mForm = inject("mForm");
5242
5152
  const services = inject("services");
5153
+ const eventBus = inject("eventBus");
5243
5154
  const emit = __emit;
5244
5155
  const dataSourceService = services?.dataSourceService;
5245
5156
  const props = __props;
5157
+ const hasDataSourceSidePanel = computed(
5158
+ () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
5159
+ );
5246
5160
  const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
5247
5161
  const dataSources = computed(() => dataSourceService?.get("dataSources"));
5248
5162
  const isCustomMethod = computed(() => {
@@ -5297,36 +5211,38 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5297
5211
  props.model.params = value.params;
5298
5212
  emit("change", props.model);
5299
5213
  };
5300
- const { codeBlockEditor, codeConfig, editCode, submitCode } = useDataSourceMethod();
5301
5214
  const editCodeHandler = () => {
5302
- const [id, name] = props.model[props.name];
5215
+ const [id] = props.model[props.name];
5303
5216
  const dataSource = dataSourceService?.getDataSourceById(id);
5304
5217
  if (!dataSource)
5305
5218
  return;
5306
- editCode(dataSource, name);
5307
- setParamsConfig([id, name]);
5308
- };
5309
- const submitCodeBlockHandler = (value) => {
5310
- submitCode(value);
5219
+ eventBus?.emit("edit-data-source", id);
5311
5220
  };
5312
5221
  return (_ctx, _cache) => {
5313
- const _component_m_form_container = resolveComponent("m-form-container");
5314
- return openBlock(), createElementBlock("div", _hoisted_1$l, [
5222
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
5315
5223
  createElementVNode("div", _hoisted_2$f, [
5316
- createVNode(_component_m_form_container, {
5224
+ createVNode(unref(MContainer), {
5317
5225
  class: "select",
5318
5226
  config: cascaderConfig.value,
5319
5227
  model: _ctx.model,
5228
+ size: _ctx.size,
5320
5229
  onChange: onChangeHandler
5321
- }, null, 8, ["config", "model"]),
5322
- _ctx.model[_ctx.name] && isCustomMethod.value ? (openBlock(), createBlock(_sfc_main$U, {
5230
+ }, null, 8, ["config", "model", "size"]),
5231
+ _ctx.model[_ctx.name] && isCustomMethod.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
5323
5232
  key: 0,
5324
- class: "icon",
5325
- icon: !notEditable.value ? unref(Edit) : unref(View),
5233
+ class: "m-fields-select-action-button",
5234
+ size: _ctx.size,
5326
5235
  onClick: editCodeHandler
5327
- }, null, 8, ["icon"])) : createCommentVNode("", true)
5236
+ }, {
5237
+ default: withCtx(() => [
5238
+ createVNode(_sfc_main$U, {
5239
+ icon: !notEditable.value ? unref(Edit) : unref(View)
5240
+ }, null, 8, ["icon"])
5241
+ ]),
5242
+ _: 1
5243
+ }, 8, ["size"])) : createCommentVNode("", true)
5328
5244
  ]),
5329
- paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$N, {
5245
+ paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$P, {
5330
5246
  key: 0,
5331
5247
  name: "params",
5332
5248
  model: _ctx.model,
@@ -5334,23 +5250,15 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5334
5250
  disabled: _ctx.disabled,
5335
5251
  "params-config": paramsConfig.value,
5336
5252
  onChange: onChangeHandler
5337
- }, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true),
5338
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
5339
- key: 1,
5340
- ref_key: "codeBlockEditor",
5341
- ref: codeBlockEditor,
5342
- disabled: notEditable.value,
5343
- content: unref(codeConfig),
5344
- onSubmit: submitCodeBlockHandler
5345
- }, null, 8, ["disabled", "content"])) : createCommentVNode("", true)
5253
+ }, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true)
5346
5254
  ]);
5347
5255
  };
5348
5256
  }
5349
5257
  });
5350
5258
 
5351
- const _hoisted_1$k = { class: "m-editor-data-source-fields" };
5259
+ const _hoisted_1$l = { class: "m-editor-data-source-fields" };
5352
5260
  const _hoisted_2$e = { class: "m-editor-data-source-fields-footer" };
5353
- const _sfc_main$F = /* @__PURE__ */ defineComponent({
5261
+ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5354
5262
  ...{
5355
5263
  name: "MFieldsDataSourceMocks"
5356
5264
  },
@@ -5556,7 +5464,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
5556
5464
  const parentFloating = inject("parentFloating", ref(null));
5557
5465
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
5558
5466
  return (_ctx, _cache) => {
5559
- return openBlock(), createElementBlock("div", _hoisted_1$k, [
5467
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
5560
5468
  createVNode(unref(MagicTable), {
5561
5469
  data: _ctx.model[_ctx.name],
5562
5470
  columns
@@ -5575,7 +5483,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
5575
5483
  _: 1
5576
5484
  }, 8, ["disabled"])
5577
5485
  ]),
5578
- createVNode(_sfc_main$P, {
5486
+ createVNode(_sfc_main$N, {
5579
5487
  visible: addDialogVisible.value,
5580
5488
  "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
5581
5489
  width: width.value,
@@ -5603,7 +5511,8 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
5603
5511
  }
5604
5512
  });
5605
5513
 
5606
- const _sfc_main$E = /* @__PURE__ */ defineComponent({
5514
+ const _hoisted_1$k = { class: "m-fields-data-source-select" };
5515
+ const _sfc_main$F = /* @__PURE__ */ defineComponent({
5607
5516
  ...{
5608
5517
  name: "MFieldsDataSourceSelect"
5609
5518
  },
@@ -5623,8 +5532,14 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
5623
5532
  setup(__props, { emit: __emit }) {
5624
5533
  const emit = __emit;
5625
5534
  const props = __props;
5626
- const { dataSourceService } = inject("services") || {};
5535
+ const mForm = inject("mForm");
5536
+ const { dataSourceService, uiService } = inject("services") || {};
5537
+ const eventBus = inject("eventBus");
5627
5538
  const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
5539
+ const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
5540
+ const hasDataSourceSidePanel = computed(
5541
+ () => (uiService?.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
5542
+ );
5628
5543
  const selectConfig = computed(() => {
5629
5544
  const { type, dataSourceType, value, ...config } = props.config;
5630
5545
  const valueIsId = props.config.value === "id";
@@ -5645,17 +5560,42 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
5645
5560
  const changeHandler = (value) => {
5646
5561
  emit("change", value);
5647
5562
  };
5563
+ const editHandler = () => {
5564
+ const value = props.model[props.name];
5565
+ if (!value)
5566
+ return;
5567
+ const id = typeof value === "string" ? value : value.dataSourceId;
5568
+ const dataSource = dataSourceService?.getDataSourceById(id);
5569
+ if (!dataSource)
5570
+ return;
5571
+ eventBus?.emit("edit-data-source", id);
5572
+ };
5648
5573
  return (_ctx, _cache) => {
5649
- return openBlock(), createBlock(unref(MSelect), {
5650
- model: _ctx.model,
5651
- name: _ctx.name,
5652
- size: _ctx.size,
5653
- prop: _ctx.prop,
5654
- disabled: _ctx.disabled,
5655
- config: selectConfig.value,
5656
- "last-values": _ctx.lastValues,
5657
- onChange: changeHandler
5658
- }, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]);
5574
+ return openBlock(), createElementBlock("div", _hoisted_1$k, [
5575
+ createVNode(unref(MSelect), {
5576
+ model: _ctx.model,
5577
+ name: _ctx.name,
5578
+ size: _ctx.size,
5579
+ prop: _ctx.prop,
5580
+ disabled: _ctx.disabled,
5581
+ config: selectConfig.value,
5582
+ "last-values": _ctx.lastValues,
5583
+ onChange: changeHandler
5584
+ }, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]),
5585
+ _ctx.model[_ctx.name] && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
5586
+ key: 0,
5587
+ class: "m-fields-select-action-button",
5588
+ size: _ctx.size,
5589
+ onClick: editHandler
5590
+ }, {
5591
+ default: withCtx(() => [
5592
+ createVNode(_sfc_main$U, {
5593
+ icon: !notEditable.value ? unref(Edit) : unref(View)
5594
+ }, null, 8, ["icon"])
5595
+ ]),
5596
+ _: 1
5597
+ }, 8, ["size"])) : createCommentVNode("", true)
5598
+ ]);
5659
5599
  };
5660
5600
  }
5661
5601
  });
@@ -5665,7 +5605,7 @@ const _hoisted_2$d = {
5665
5605
  key: 1,
5666
5606
  class: "fullWidth"
5667
5607
  };
5668
- const _sfc_main$D = /* @__PURE__ */ defineComponent({
5608
+ const _sfc_main$E = /* @__PURE__ */ defineComponent({
5669
5609
  ...{
5670
5610
  name: "MFieldsEventSelect"
5671
5611
  },
@@ -5823,6 +5763,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
5823
5763
  ]
5824
5764
  }));
5825
5765
  const actionsConfig = computed(() => ({
5766
+ type: "panel",
5826
5767
  items: [
5827
5768
  {
5828
5769
  type: "group-list",
@@ -5867,8 +5808,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
5867
5808
  };
5868
5809
  return (_ctx, _cache) => {
5869
5810
  const _component_m_form_table = resolveComponent("m-form-table");
5870
- const _component_m_form_container = resolveComponent("m-form-container");
5871
- const _component_m_form_panel = resolveComponent("m-form-panel");
5872
5811
  return openBlock(), createElementBlock("div", _hoisted_1$j, [
5873
5812
  isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
5874
5813
  key: 0,
@@ -5893,7 +5832,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
5893
5832
  _: 1
5894
5833
  }, 8, ["size", "disabled"]),
5895
5834
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.model[_ctx.name], (cardItem, index) => {
5896
- return openBlock(), createBlock(_component_m_form_panel, {
5835
+ return openBlock(), createBlock(unref(MPanel), {
5897
5836
  key: index,
5898
5837
  disabled: _ctx.disabled,
5899
5838
  size: _ctx.size,
@@ -5903,7 +5842,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
5903
5842
  onChange: onChangeHandler
5904
5843
  }, {
5905
5844
  header: withCtx(() => [
5906
- createVNode(_component_m_form_container, {
5845
+ createVNode(unref(MContainer), {
5907
5846
  class: "fullWidth",
5908
5847
  config: eventNameConfig.value,
5909
5848
  model: cardItem,
@@ -5939,7 +5878,7 @@ const _hoisted_2$c = /* @__PURE__ */ createStaticVNode('<defs><rect id="path-1"
5939
5878
  const _hoisted_4$6 = [
5940
5879
  _hoisted_2$c
5941
5880
  ];
5942
- const _sfc_main$C = /* @__PURE__ */ defineComponent({
5881
+ const _sfc_main$D = /* @__PURE__ */ defineComponent({
5943
5882
  ...{
5944
5883
  name: "MEditorCodeIcon"
5945
5884
  },
@@ -5954,7 +5893,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
5954
5893
  const _hoisted_1$h = { class: "m-fields-key-value" };
5955
5894
  const _hoisted_2$b = { key: 0 };
5956
5895
  const _hoisted_3$6 = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
5957
- const _sfc_main$B = /* @__PURE__ */ defineComponent({
5896
+ const _sfc_main$C = /* @__PURE__ */ defineComponent({
5958
5897
  ...{
5959
5898
  name: "MFieldsKeyValue"
5960
5899
  },
@@ -6078,7 +6017,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
6078
6017
  size: "default",
6079
6018
  disabled: _ctx.disabled,
6080
6019
  link: "",
6081
- icon: _sfc_main$C,
6020
+ icon: _sfc_main$D,
6082
6021
  onClick: _cache[0] || (_cache[0] = ($event) => showCode.value = !showCode.value)
6083
6022
  }, null, 8, ["disabled"])) : createCommentVNode("", true)
6084
6023
  ]);
@@ -6088,7 +6027,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
6088
6027
 
6089
6028
  const _hoisted_1$g = { class: "m-fields-page-fragment-select" };
6090
6029
  const _hoisted_2$a = { class: "page-fragment-select-container" };
6091
- const _sfc_main$A = /* @__PURE__ */ defineComponent({
6030
+ const _sfc_main$B = /* @__PURE__ */ defineComponent({
6092
6031
  ...{
6093
6032
  name: "MFieldsPageFragmentSelect"
6094
6033
  },
@@ -6160,7 +6099,7 @@ const _hoisted_1$f = {
6160
6099
  class: "m-fields-ui-select",
6161
6100
  style: { "display": "flex" }
6162
6101
  };
6163
- const _sfc_main$z = /* @__PURE__ */ defineComponent({
6102
+ const _sfc_main$A = /* @__PURE__ */ defineComponent({
6164
6103
  ...{
6165
6104
  name: "MFieldsUISelect"
6166
6105
  },
@@ -6348,7 +6287,7 @@ const useGetSo = (target, emit) => {
6348
6287
  };
6349
6288
  };
6350
6289
 
6351
- const _sfc_main$y = /* @__PURE__ */ defineComponent({
6290
+ const _sfc_main$z = /* @__PURE__ */ defineComponent({
6352
6291
  ...{
6353
6292
  name: "MEditorResizer"
6354
6293
  },
@@ -6370,7 +6309,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6370
6309
  }
6371
6310
  });
6372
6311
 
6373
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
6312
+ const _sfc_main$y = /* @__PURE__ */ defineComponent({
6374
6313
  ...{
6375
6314
  name: "MEditorSplitView"
6376
6315
  },
@@ -6511,7 +6450,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
6511
6450
  }, [
6512
6451
  renderSlot(_ctx.$slots, "left")
6513
6452
  ], 6),
6514
- createVNode(_sfc_main$y, { onChange: changeLeft })
6453
+ createVNode(_sfc_main$z, { onChange: changeLeft })
6515
6454
  ], 64)) : createCommentVNode("", true),
6516
6455
  createElementVNode("div", {
6517
6456
  class: normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
@@ -6520,7 +6459,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
6520
6459
  renderSlot(_ctx.$slots, "center")
6521
6460
  ], 6),
6522
6461
  hasRight.value && _ctx.$slots.right ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
6523
- createVNode(_sfc_main$y, { onChange: changeRight }),
6462
+ createVNode(_sfc_main$z, { onChange: changeRight }),
6524
6463
  createElementVNode("div", {
6525
6464
  class: normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
6526
6465
  style: normalizeStyle(`width: ${_ctx.right}px`)
@@ -6538,7 +6477,7 @@ const _hoisted_1$e = {
6538
6477
  class: "menu-item-text"
6539
6478
  };
6540
6479
  const _hoisted_2$9 = { class: "el-dropdown-link menubar-menu-button" };
6541
- const _sfc_main$w = /* @__PURE__ */ defineComponent({
6480
+ const _sfc_main$x = /* @__PURE__ */ defineComponent({
6542
6481
  ...{
6543
6482
  name: "MEditorToolButton"
6544
6483
  },
@@ -6703,7 +6642,7 @@ const _hoisted_1$d = {
6703
6642
  key: 1,
6704
6643
  style: { "width": "21px" }
6705
6644
  };
6706
- const _sfc_main$v = /* @__PURE__ */ defineComponent({
6645
+ const _sfc_main$w = /* @__PURE__ */ defineComponent({
6707
6646
  ...{
6708
6647
  name: "MEditorPageBarAddButton"
6709
6648
  },
@@ -6743,7 +6682,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
6743
6682
  }
6744
6683
  });
6745
6684
 
6746
- const _sfc_main$u = /* @__PURE__ */ defineComponent({
6685
+ const _sfc_main$v = /* @__PURE__ */ defineComponent({
6747
6686
  ...{
6748
6687
  name: "MEditorPageBarScrollContainer"
6749
6688
  },
@@ -6872,7 +6811,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6872
6811
  }
6873
6812
  });
6874
6813
 
6875
- const _sfc_main$t = /* @__PURE__ */ defineComponent({
6814
+ const _sfc_main$u = /* @__PURE__ */ defineComponent({
6876
6815
  ...{
6877
6816
  name: "MEditorPageBarSwitchTypeButton"
6878
6817
  },
@@ -6920,7 +6859,7 @@ const _hoisted_1$c = { class: "m-editor-page-bar-tabs" };
6920
6859
  const _hoisted_2$8 = ["onClick"];
6921
6860
  const _hoisted_3$5 = { class: "m-editor-page-bar-title" };
6922
6861
  const _hoisted_4$5 = ["title"];
6923
- const _sfc_main$s = /* @__PURE__ */ defineComponent({
6862
+ const _sfc_main$t = /* @__PURE__ */ defineComponent({
6924
6863
  ...{
6925
6864
  name: "MEditorPageBar"
6926
6865
  },
@@ -6999,14 +6938,14 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
6999
6938
  };
7000
6939
  return (_ctx, _cache) => {
7001
6940
  return openBlock(), createElementBlock("div", _hoisted_1$c, [
7002
- !_ctx.disabledPageFragment ? (openBlock(), createBlock(_sfc_main$t, {
6941
+ !_ctx.disabledPageFragment ? (openBlock(), createBlock(_sfc_main$u, {
7003
6942
  key: 0,
7004
6943
  modelValue: active.value,
7005
6944
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => active.value = $event)
7006
6945
  }, null, 8, ["modelValue"])) : createCommentVNode("", true),
7007
- createVNode(_sfc_main$u, { type: active.value }, {
6946
+ createVNode(_sfc_main$v, { type: active.value }, {
7008
6947
  prepend: withCtx(() => [
7009
- createVNode(_sfc_main$v, { type: active.value }, null, 8, ["type"])
6948
+ createVNode(_sfc_main$w, { type: active.value }, null, 8, ["type"])
7010
6949
  ]),
7011
6950
  default: withCtx(() => [
7012
6951
  (openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (item) => {
@@ -7039,7 +6978,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
7039
6978
  default: withCtx(() => [
7040
6979
  createElementVNode("div", null, [
7041
6980
  renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
7042
- createVNode(_sfc_main$w, {
6981
+ createVNode(_sfc_main$x, {
7043
6982
  data: {
7044
6983
  type: "button",
7045
6984
  text: "复制",
@@ -7047,7 +6986,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
7047
6986
  handler: () => copy(item)
7048
6987
  }
7049
6988
  }, null, 8, ["data"]),
7050
- createVNode(_sfc_main$w, {
6989
+ createVNode(_sfc_main$x, {
7051
6990
  data: {
7052
6991
  type: "button",
7053
6992
  text: "删除",
@@ -7074,7 +7013,7 @@ const _hoisted_1$b = { class: "m-editor-empty-panel" };
7074
7013
  const _hoisted_2$7 = { class: "m-editor-empty-content" };
7075
7014
  const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
7076
7015
  const _hoisted_4$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面片", -1);
7077
- const _sfc_main$r = /* @__PURE__ */ defineComponent({
7016
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
7078
7017
  ...{
7079
7018
  name: "MEditorAddPageBox"
7080
7019
  },
@@ -7129,7 +7068,7 @@ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
7129
7068
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
7130
7069
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
7131
7070
  const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
7132
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
7071
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
7133
7072
  ...{
7134
7073
  name: "MEditorFramework"
7135
7074
  },
@@ -7213,7 +7152,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7213
7152
  options: unref(codeOptions),
7214
7153
  onSave: saveCode
7215
7154
  }, null, 8, ["init-values", "options"])
7216
- ]) : withDirectives((openBlock(), createBlock(_sfc_main$x, {
7155
+ ]) : withDirectives((openBlock(), createBlock(_sfc_main$y, {
7217
7156
  key: 1,
7218
7157
  "element-loading-text": "Runtime 加载中...",
7219
7158
  ref_key: "splitView",
@@ -7237,10 +7176,10 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7237
7176
  ]),
7238
7177
  center: withCtx(() => [
7239
7178
  page.value ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
7240
- createVNode(_sfc_main$r, { "disabled-page-fragment": _ctx.disabledPageFragment }, null, 8, ["disabled-page-fragment"])
7179
+ createVNode(_sfc_main$s, { "disabled-page-fragment": _ctx.disabledPageFragment }, null, 8, ["disabled-page-fragment"])
7241
7180
  ]),
7242
7181
  renderSlot(_ctx.$slots, "page-bar", {}, () => [
7243
- createVNode(_sfc_main$s, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
7182
+ createVNode(_sfc_main$t, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
7244
7183
  "page-bar-title": withCtx(({ page: page2 }) => [
7245
7184
  renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
7246
7185
  ]),
@@ -7275,7 +7214,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7275
7214
  }
7276
7215
  });
7277
7216
 
7278
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
7217
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
7279
7218
  ...{
7280
7219
  name: "MEditorNavMenu"
7281
7220
  },
@@ -7457,7 +7396,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
7457
7396
  style: normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
7458
7397
  }, [
7459
7398
  (openBlock(true), createElementBlock(Fragment, null, renderList(buttons.value[key], (item, index) => {
7460
- return openBlock(), createBlock(_sfc_main$w, {
7399
+ return openBlock(), createBlock(_sfc_main$x, {
7461
7400
  data: item,
7462
7401
  key: index
7463
7402
  }, null, 8, ["data"]);
@@ -7470,12 +7409,13 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
7470
7409
  });
7471
7410
 
7472
7411
  const _hoisted_1$a = { class: "m-editor-props-panel" };
7473
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
7412
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
7474
7413
  ...{
7475
7414
  name: "MEditorPropsPanel"
7476
7415
  },
7477
7416
  __name: "PropsPanel",
7478
7417
  props: {
7418
+ disabledShowSrc: { type: Boolean },
7479
7419
  extendState: { type: Function }
7480
7420
  },
7481
7421
  emits: ["mounted", "submit-error", "form-error"],
@@ -7536,7 +7476,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
7536
7476
  createVNode(unref(MForm), {
7537
7477
  ref_key: "configForm",
7538
7478
  ref: configForm,
7539
- class: normalizeClass(`m-editor-props-panel ${propsPanelSize.value}`),
7479
+ class: normalizeClass(propsPanelSize.value),
7540
7480
  "popper-class": `m-editor-props-panel-popper ${propsPanelSize.value}`,
7541
7481
  size: propsPanelSize.value,
7542
7482
  "init-values": values.value,
@@ -7545,7 +7485,8 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
7545
7485
  onChange: submit,
7546
7486
  onError: errorHandler
7547
7487
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"]),
7548
- createVNode(unref(TMagicButton), {
7488
+ !_ctx.disabledShowSrc ? (openBlock(), createBlock(unref(TMagicButton), {
7489
+ key: 0,
7549
7490
  class: "m-editor-props-panel-src-icon",
7550
7491
  circle: "",
7551
7492
  size: "large",
@@ -7557,9 +7498,9 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
7557
7498
  createVNode(_sfc_main$U, { icon: unref(Document) }, null, 8, ["icon"])
7558
7499
  ]),
7559
7500
  _: 1
7560
- }, 8, ["type"]),
7501
+ }, 8, ["type"])) : createCommentVNode("", true),
7561
7502
  showSrc.value ? (openBlock(), createBlock(_sfc_main$T, {
7562
- key: 0,
7503
+ key: 1,
7563
7504
  height: `${unref(editorContentHeight)}px`,
7564
7505
  "init-values": values.value,
7565
7506
  options: unref(codeOptions),
@@ -7573,7 +7514,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
7573
7514
  }
7574
7515
  });
7575
7516
 
7576
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
7517
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
7577
7518
  ...{
7578
7519
  name: "MEditorSearchInput"
7579
7520
  },
@@ -7631,7 +7572,7 @@ const _hoisted_4$3 = {
7631
7572
  key: 0,
7632
7573
  class: "m-editor-tree-node-children"
7633
7574
  };
7634
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
7575
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
7635
7576
  ...{
7636
7577
  name: "MEditorTreeNode"
7637
7578
  },
@@ -7752,7 +7693,7 @@ const _hoisted_1$8 = {
7752
7693
  key: 1,
7753
7694
  class: "m-editor-tree-empty"
7754
7695
  };
7755
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
7696
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
7756
7697
  ...{
7757
7698
  name: "MEditorTree"
7758
7699
  },
@@ -7776,7 +7717,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
7776
7717
  onDragover: handleDragOver
7777
7718
  }, [
7778
7719
  _ctx.data?.length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.data, (item) => {
7779
- return openBlock(), createBlock(_sfc_main$m, {
7720
+ return openBlock(), createBlock(_sfc_main$n, {
7780
7721
  key: item.id,
7781
7722
  data: item,
7782
7723
  indent: _ctx.indent,
@@ -7873,7 +7814,7 @@ const useNodeStatus$1 = (nodeData) => {
7873
7814
  };
7874
7815
  };
7875
7816
 
7876
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
7817
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
7877
7818
  ...{
7878
7819
  name: "MEditorCodeBlockList"
7879
7820
  },
@@ -7955,7 +7896,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
7955
7896
  filter: filterTextChangeHandler
7956
7897
  });
7957
7898
  return (_ctx, _cache) => {
7958
- return openBlock(), createBlock(_sfc_main$l, {
7899
+ return openBlock(), createBlock(_sfc_main$m, {
7959
7900
  data: codeList.value,
7960
7901
  "node-status-map": unref(nodeStatusMap),
7961
7902
  onNodeClick: clickHandler
@@ -8012,7 +7953,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
8012
7953
  });
8013
7954
 
8014
7955
  const _hoisted_1$7 = { class: "search-wrapper" };
8015
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
7956
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
8016
7957
  ...{
8017
7958
  name: "MEditorCodeBlockListPanel"
8018
7959
  },
@@ -8021,6 +7962,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
8021
7962
  customError: { type: Function }
8022
7963
  },
8023
7964
  setup(__props) {
7965
+ const eventBus = inject("eventBus");
8024
7966
  const { codeBlockService } = inject("services") || {};
8025
7967
  const editable = computed(() => codeBlockService?.getEditStatus());
8026
7968
  const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
@@ -8028,13 +7970,16 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
8028
7970
  const filterTextChangeHandler = (val) => {
8029
7971
  codeBlockList.value?.filter(val);
8030
7972
  };
7973
+ eventBus?.on("edit-code", (id) => {
7974
+ editCode(id);
7975
+ });
8031
7976
  return (_ctx, _cache) => {
8032
7977
  return openBlock(), createElementBlock(Fragment, null, [
8033
7978
  createVNode(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-layer-panel" }, {
8034
7979
  default: withCtx(() => [
8035
7980
  renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
8036
7981
  createElementVNode("div", _hoisted_1$7, [
8037
- createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
7982
+ createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
8038
7983
  editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
8039
7984
  key: 0,
8040
7985
  class: "create-code-button",
@@ -8050,7 +7995,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
8050
7995
  renderSlot(_ctx.$slots, "code-block-panel-search")
8051
7996
  ])
8052
7997
  ]),
8053
- createVNode(_sfc_main$k, {
7998
+ createVNode(_sfc_main$l, {
8054
7999
  ref_key: "codeBlockList",
8055
8000
  ref: codeBlockList,
8056
8001
  "custom-error": _ctx.customError,
@@ -8068,7 +8013,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
8068
8013
  ]),
8069
8014
  _: 3
8070
8015
  }),
8071
- unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
8016
+ unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$J, {
8072
8017
  key: 0,
8073
8018
  ref_key: "codeBlockEditor",
8074
8019
  ref: codeBlockEditor,
@@ -8081,6 +8026,113 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
8081
8026
  }
8082
8027
  });
8083
8028
 
8029
+ const useDataSourceEdit = (dataSourceService) => {
8030
+ const dialogTitle = ref("");
8031
+ const editDialog = ref();
8032
+ const dataSourceValues = ref({});
8033
+ const editable = computed(() => dataSourceService?.get("editable") ?? true);
8034
+ const editHandler = (id) => {
8035
+ if (!editDialog.value)
8036
+ return;
8037
+ dataSourceValues.value = {
8038
+ ...dataSourceService?.getDataSourceById(id)
8039
+ };
8040
+ dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
8041
+ editDialog.value.show();
8042
+ };
8043
+ const submitDataSourceHandler = (value) => {
8044
+ if (value.id) {
8045
+ dataSourceService?.update(value);
8046
+ } else {
8047
+ dataSourceService?.add(value);
8048
+ }
8049
+ editDialog.value?.hide();
8050
+ };
8051
+ return {
8052
+ dialogTitle,
8053
+ editDialog,
8054
+ dataSourceValues,
8055
+ editable,
8056
+ editHandler,
8057
+ submitDataSourceHandler
8058
+ };
8059
+ };
8060
+
8061
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
8062
+ ...{
8063
+ name: "MEditorDataSourceConfigPanel"
8064
+ },
8065
+ __name: "DataSourceConfigPanel",
8066
+ props: /* @__PURE__ */ mergeModels({
8067
+ title: {},
8068
+ values: {},
8069
+ disabled: { type: Boolean }
8070
+ }, {
8071
+ "visible": { type: Boolean, ...{ default: false } },
8072
+ "visibleModifiers": {},
8073
+ "width": { default: 670 },
8074
+ "widthModifiers": {}
8075
+ }),
8076
+ emits: /* @__PURE__ */ mergeModels(["submit"], ["update:visible", "update:width"]),
8077
+ setup(__props, { expose: __expose, emit: __emit }) {
8078
+ const props = __props;
8079
+ const boxVisible = useModel(__props, "visible");
8080
+ const width = useModel(__props, "width");
8081
+ const emit = __emit;
8082
+ const services = inject("services");
8083
+ const initValues = ref({});
8084
+ const dataSourceConfig = ref([]);
8085
+ const { height: editorHeight } = useEditorContentHeight();
8086
+ const parentFloating = inject("parentFloating", ref(null));
8087
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
8088
+ watchEffect(() => {
8089
+ initValues.value = props.values;
8090
+ dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
8091
+ });
8092
+ const submitHandler = (values) => {
8093
+ emit("submit", values);
8094
+ };
8095
+ const errorHandler = (error) => {
8096
+ tMagicMessage.error(error.message);
8097
+ };
8098
+ __expose({
8099
+ show() {
8100
+ calcBoxPosition();
8101
+ boxVisible.value = true;
8102
+ },
8103
+ hide() {
8104
+ boxVisible.value = false;
8105
+ }
8106
+ });
8107
+ return (_ctx, _cache) => {
8108
+ return openBlock(), createBlock(_sfc_main$N, {
8109
+ visible: boxVisible.value,
8110
+ "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
8111
+ width: width.value,
8112
+ "onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
8113
+ height: unref(editorHeight),
8114
+ "onUpdate:height": _cache[2] || (_cache[2] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
8115
+ title: _ctx.title,
8116
+ position: unref(boxPosition)
8117
+ }, {
8118
+ body: withCtx(() => [
8119
+ createVNode(unref(MFormBox), {
8120
+ "label-width": "80px",
8121
+ title: _ctx.title,
8122
+ config: dataSourceConfig.value,
8123
+ values: initValues.value,
8124
+ disabled: _ctx.disabled,
8125
+ style: { "height": "100%" },
8126
+ onSubmit: submitHandler,
8127
+ onError: errorHandler
8128
+ }, null, 8, ["title", "config", "values", "disabled"])
8129
+ ]),
8130
+ _: 1
8131
+ }, 8, ["visible", "width", "height", "title", "position"]);
8132
+ };
8133
+ }
8134
+ });
8135
+
8084
8136
  const _sfc_main$i = /* @__PURE__ */ defineComponent({
8085
8137
  ...{
8086
8138
  name: "MEditorDataSourceList"
@@ -8170,7 +8222,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
8170
8222
  filter: filterTextChangeHandler
8171
8223
  });
8172
8224
  return (_ctx, _cache) => {
8173
- return openBlock(), createBlock(_sfc_main$l, {
8225
+ return openBlock(), createBlock(_sfc_main$m, {
8174
8226
  data: list.value,
8175
8227
  "node-status-map": unref(nodeStatusMap),
8176
8228
  onNodeClick: clickHandler
@@ -8231,6 +8283,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8231
8283
  },
8232
8284
  __name: "DataSourceListPanel",
8233
8285
  setup(__props) {
8286
+ const eventBus = inject("eventBus");
8234
8287
  const { dataSourceService } = inject("services") || {};
8235
8288
  const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
8236
8289
  const datasourceTypeList = computed(
@@ -8262,12 +8315,15 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8262
8315
  const filterTextChangeHandler = (val) => {
8263
8316
  dataSourceList.value?.filter(val);
8264
8317
  };
8318
+ eventBus?.on("edit-data-source", (id) => {
8319
+ editHandler(id);
8320
+ });
8265
8321
  return (_ctx, _cache) => {
8266
8322
  return openBlock(), createElementBlock(Fragment, null, [
8267
8323
  createVNode(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-layer-panel" }, {
8268
8324
  default: withCtx(() => [
8269
8325
  createElementVNode("div", _hoisted_1$6, [
8270
- createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
8326
+ createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
8271
8327
  unref(editable) ? (openBlock(), createBlock(unref(TMagicPopover), {
8272
8328
  key: 0,
8273
8329
  placement: "right"
@@ -8286,7 +8342,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8286
8342
  default: withCtx(() => [
8287
8343
  createElementVNode("div", _hoisted_2$5, [
8288
8344
  (openBlock(true), createElementBlock(Fragment, null, renderList(datasourceTypeList.value, (item, index) => {
8289
- return openBlock(), createBlock(_sfc_main$w, {
8345
+ return openBlock(), createBlock(_sfc_main$x, {
8290
8346
  data: {
8291
8347
  type: "button",
8292
8348
  text: item.text,
@@ -8312,7 +8368,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
8312
8368
  ]),
8313
8369
  _: 3
8314
8370
  }),
8315
- createVNode(_sfc_main$K, {
8371
+ createVNode(_sfc_main$j, {
8316
8372
  ref_key: "editDialog",
8317
8373
  ref: editDialog,
8318
8374
  disabled: !unref(editable),
@@ -8456,7 +8512,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8456
8512
  renderSlot(_ctx.$slots, "title"),
8457
8513
  createElementVNode("div", null, [
8458
8514
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
8459
- return openBlock(), createBlock(_sfc_main$w, {
8515
+ return openBlock(), createBlock(_sfc_main$x, {
8460
8516
  "event-type": "mouseup",
8461
8517
  ref_for: true,
8462
8518
  ref_key: "buttons",
@@ -9232,8 +9288,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
9232
9288
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-layer-panel" }, {
9233
9289
  default: withCtx(() => [
9234
9290
  renderSlot(_ctx.$slots, "layer-panel-header"),
9235
- createVNode(_sfc_main$n, { onSearch: unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
9236
- page.value && unref(nodeStatusMap) ? (openBlock(), createBlock(_sfc_main$l, {
9291
+ createVNode(_sfc_main$o, { onSearch: unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
9292
+ page.value && unref(nodeStatusMap) ? (openBlock(), createBlock(_sfc_main$m, {
9237
9293
  key: 0,
9238
9294
  tabindex: "-1",
9239
9295
  ref_key: "tree",
@@ -9359,7 +9415,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
9359
9415
  "model-value": collapseValue.value
9360
9416
  }, {
9361
9417
  default: withCtx(() => [
9362
- createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
9418
+ createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
9363
9419
  (openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
9364
9420
  return openBlock(), createElementBlock(Fragment, null, [
9365
9421
  group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
@@ -9432,7 +9488,11 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9432
9488
  },
9433
9489
  __name: "Sidebar",
9434
9490
  props: {
9435
- data: { default: () => ({ type: "tabs", status: "组件", items: ["component-list", "layer", "code-block", "data-source"] }) },
9491
+ data: { default: () => ({
9492
+ type: "tabs",
9493
+ status: "组件",
9494
+ items: [SideItemKey.COMPONENT_LIST, SideItemKey.LAYER, SideItemKey.CODE_BLOCK, SideItemKey.DATA_SOURCE]
9495
+ }) },
9436
9496
  layerContentMenu: {},
9437
9497
  customContentMenu: {}
9438
9498
  },
@@ -9444,8 +9504,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9444
9504
  const activeTabName = ref(props.data?.status);
9445
9505
  const getItemConfig = (data) => {
9446
9506
  const map = {
9447
- "component-list": {
9448
- $key: "component-list",
9507
+ [SideItemKey.COMPONENT_LIST]: {
9508
+ $key: SideItemKey.COMPONENT_LIST,
9449
9509
  type: "component",
9450
9510
  icon: Goods,
9451
9511
  text: "组件",
@@ -9464,16 +9524,16 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9464
9524
  component: _sfc_main$c,
9465
9525
  slots: {}
9466
9526
  },
9467
- "code-block": {
9527
+ [SideItemKey.CODE_BLOCK]: {
9468
9528
  $key: "code-block",
9469
9529
  type: "component",
9470
9530
  icon: EditPen,
9471
9531
  text: "代码编辑",
9472
- component: _sfc_main$j,
9532
+ component: _sfc_main$k,
9473
9533
  slots: {}
9474
9534
  },
9475
- "data-source": {
9476
- $key: "data-source",
9535
+ [SideItemKey.DATA_SOURCE]: {
9536
+ $key: SideItemKey.DATA_SOURCE,
9477
9537
  type: "component",
9478
9538
  icon: Coin,
9479
9539
  text: "数据源",
@@ -9484,6 +9544,15 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9484
9544
  return typeof data === "string" ? map[data] : data;
9485
9545
  };
9486
9546
  const sideBarItems = computed(() => props.data.items.map((item) => getItemConfig(item)));
9547
+ watch(
9548
+ sideBarItems,
9549
+ (items) => {
9550
+ services?.uiService.set("sideBarItems", items);
9551
+ },
9552
+ {
9553
+ immediate: true
9554
+ }
9555
+ );
9487
9556
  watch(
9488
9557
  () => props.data.status,
9489
9558
  (status) => {
@@ -9522,7 +9591,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9522
9591
  class: normalizeClass(["m-editor-sidebar-header-item", { "is-active": activeTabName.value === config.text }]),
9523
9592
  draggable: "true",
9524
9593
  key: config.$key ?? index,
9525
- onClick: ($event) => activeTabName.value = config.text || `${index}`,
9594
+ style: normalizeStyle(config.tabStyle || {}),
9595
+ onClick: ($event) => activeTabName.value = config.text || config.$key || `${index}`,
9526
9596
  onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
9527
9597
  (...args) => unref(dragstartHandler) && unref(dragstartHandler)(...args)),
9528
9598
  onDragend: ($event) => unref(dragendHandler)(config.$key, $event)
@@ -9532,7 +9602,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9532
9602
  icon: config.icon
9533
9603
  }, null, 8, ["icon"])) : createCommentVNode("", true),
9534
9604
  config.text ? (openBlock(), createElementBlock("div", _hoisted_4$1, toDisplayString(config.text), 1)) : createCommentVNode("", true)
9535
- ], 42, _hoisted_3$1)), [
9605
+ ], 46, _hoisted_3$1)), [
9536
9606
  [vShow, !unref(floatBoxStates)[config.$key]?.status]
9537
9607
  ]);
9538
9608
  }), 128))
@@ -9653,14 +9723,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9653
9723
  } : void 0
9654
9724
  ]), 1040)) : createCommentVNode("", true)
9655
9725
  ])), [
9656
- [vShow, activeTabName.value === config.text]
9726
+ [vShow, [config.text, config.$key, `${index}`].includes(activeTabName.value)]
9657
9727
  ]);
9658
9728
  }), 128))
9659
9729
  ])) : createCommentVNode("", true),
9660
9730
  (openBlock(), createBlock(Teleport, { to: "body" }, [
9661
9731
  (openBlock(true), createElementBlock(Fragment, null, renderList(sideBarItems.value, (config, index) => {
9662
9732
  return openBlock(), createElementBlock(Fragment, null, [
9663
- unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(_sfc_main$P, {
9733
+ unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(_sfc_main$N, {
9664
9734
  key: config.$key ?? index,
9665
9735
  visible: unref(floatBoxStates)[config.$key].status,
9666
9736
  "onUpdate:visible": ($event) => unref(floatBoxStates)[config.$key].status = $event,
@@ -10093,7 +10163,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
10093
10163
  ]),
10094
10164
  _: 1
10095
10165
  })) : createCommentVNode("", true),
10096
- page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$P, {
10166
+ page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$N, {
10097
10167
  key: 1,
10098
10168
  ref_key: "box",
10099
10169
  ref: box,
@@ -10103,7 +10173,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
10103
10173
  position: menuPosition.value
10104
10174
  }, {
10105
10175
  body: withCtx(() => [
10106
- createVNode(_sfc_main$l, {
10176
+ createVNode(_sfc_main$m, {
10107
10177
  class: "m-editor-node-list-menu magic-editor-layer-tree",
10108
10178
  data: nodeData.value,
10109
10179
  "node-status-map": unref(nodeStatusMap),
@@ -11253,6 +11323,7 @@ const defaultEditorProps = {
11253
11323
  containerHighlightClassName: CONTAINER_HIGHLIGHT_CLASS_NAME,
11254
11324
  containerHighlightDuration: 800,
11255
11325
  containerHighlightType: ContainerHighlightType.DEFAULT,
11326
+ disabledShowSrc: false,
11256
11327
  componentGroupList: () => [],
11257
11328
  datasourceList: () => [],
11258
11329
  menu: () => ({ left: [], right: [] }),
@@ -11634,6 +11705,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
11634
11705
  disabledMultiSelect: { type: Boolean },
11635
11706
  disabledPageFragment: { type: Boolean },
11636
11707
  disabledStageOverlay: { type: Boolean },
11708
+ disabledShowSrc: { type: Boolean },
11637
11709
  render: { type: Function },
11638
11710
  updateDragEl: { type: Function },
11639
11711
  canSelect: { type: Function },
@@ -11683,15 +11755,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
11683
11755
  provide("services", services);
11684
11756
  provide("codeOptions", props.codeOptions);
11685
11757
  provide("stageOptions", stageOptions);
11758
+ provide("eventBus", new EventEmitter());
11686
11759
  __expose(services);
11687
11760
  return (_ctx, _cache) => {
11688
- return openBlock(), createBlock(_sfc_main$q, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
11761
+ return openBlock(), createBlock(_sfc_main$r, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
11689
11762
  header: withCtx(() => [
11690
11763
  renderSlot(_ctx.$slots, "header")
11691
11764
  ]),
11692
11765
  nav: withCtx(() => [
11693
11766
  renderSlot(_ctx.$slots, "nav", { editorService: unref(editorService) }, () => [
11694
- createVNode(_sfc_main$p, { data: _ctx.menu }, null, 8, ["data"])
11767
+ createVNode(_sfc_main$q, { data: _ctx.menu }, null, 8, ["data"])
11695
11768
  ])
11696
11769
  ]),
11697
11770
  "content-before": withCtx(() => [
@@ -11766,8 +11839,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
11766
11839
  ]),
11767
11840
  "props-panel": withCtx(() => [
11768
11841
  renderSlot(_ctx.$slots, "props-panel", {}, () => [
11769
- createVNode(_sfc_main$o, {
11842
+ createVNode(_sfc_main$p, {
11770
11843
  "extend-state": _ctx.extendFormState,
11844
+ "disabled-show-src": _ctx.disabledShowSrc,
11771
11845
  onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance)),
11772
11846
  onFormError: _cache[1] || (_cache[1] = (e) => _ctx.$emit("props-form-error", e)),
11773
11847
  onSubmitError: _cache[2] || (_cache[2] = (e) => _ctx.$emit("props-submit-error", e))
@@ -11776,7 +11850,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
11776
11850
  renderSlot(_ctx.$slots, "props-panel-header")
11777
11851
  ]),
11778
11852
  _: 3
11779
- }, 8, ["extend-state"])
11853
+ }, 8, ["extend-state", "disabled-show-src"])
11780
11854
  ])
11781
11855
  ]),
11782
11856
  empty: withCtx(() => [
@@ -11814,22 +11888,22 @@ const index = {
11814
11888
  setConfig(option);
11815
11889
  app.component(`${_sfc_main.name || "MEditor"}`, _sfc_main);
11816
11890
  app.component("magic-code-editor", _sfc_main$T);
11817
- app.component("m-fields-ui-select", _sfc_main$z);
11891
+ app.component("m-fields-ui-select", _sfc_main$A);
11818
11892
  app.component("m-fields-code-link", _sfc_main$R);
11819
11893
  app.component("m-fields-vs-code", _sfc_main$S);
11820
11894
  app.component("m-fields-code-select", _sfc_main$Q);
11821
- app.component("m-fields-code-select-col", _sfc_main$M);
11822
- app.component("m-fields-event-select", _sfc_main$D);
11823
- app.component("m-fields-data-source-fields", _sfc_main$L);
11824
- app.component("m-fields-data-source-mocks", _sfc_main$F);
11825
- app.component("m-fields-key-value", _sfc_main$B);
11826
- app.component("m-fields-data-source-input", _sfc_main$I);
11827
- app.component("m-fields-data-source-select", _sfc_main$E);
11828
- app.component("m-fields-data-source-methods", _sfc_main$H);
11829
- app.component("m-fields-data-source-method-select", _sfc_main$G);
11830
- app.component("m-fields-data-source-field-select", _sfc_main$J);
11831
- app.component("m-fields-page-fragment-select", _sfc_main$A);
11895
+ app.component("m-fields-code-select-col", _sfc_main$O);
11896
+ app.component("m-fields-event-select", _sfc_main$E);
11897
+ app.component("m-fields-data-source-fields", _sfc_main$M);
11898
+ app.component("m-fields-data-source-mocks", _sfc_main$G);
11899
+ app.component("m-fields-key-value", _sfc_main$C);
11900
+ app.component("m-fields-data-source-input", _sfc_main$K);
11901
+ app.component("m-fields-data-source-select", _sfc_main$F);
11902
+ app.component("m-fields-data-source-methods", _sfc_main$I);
11903
+ app.component("m-fields-data-source-method-select", _sfc_main$H);
11904
+ app.component("m-fields-data-source-field-select", _sfc_main$L);
11905
+ app.component("m-fields-page-fragment-select", _sfc_main$B);
11832
11906
  }
11833
11907
  };
11834
11908
 
11835
- export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$O as CodeBlockEditor, _sfc_main$k as CodeBlockList, _sfc_main$j 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$K as DataSourceConfigPanel, _sfc_main$J as DataSourceFieldSelect, _sfc_main$L as DataSourceFields, _sfc_main$I as DataSourceInput, _sfc_main$G as DataSourceMethodSelect, _sfc_main$H as DataSourceMethods, _sfc_main$F as DataSourceMocks, _sfc_main$E as DataSourceSelect, DragType, _sfc_main$D as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$U as Icon, KeyBindingCommand, _sfc_main$B as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$x as LayoutContainer, _sfc_main$A as PageFragmentSelect, _sfc_main$o as PropsPanel, _sfc_main$y as Resizer, _sfc_main$x as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$w 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 };
11909
+ export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$J as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$O as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$L as DataSourceFieldSelect, _sfc_main$M as DataSourceFields, _sfc_main$K 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, SideItemKey, _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 };