@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,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('@tmagic/design'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/form'), require('@tmagic/schema'), require('moveable'), require('@tmagic/table'), require('@tmagic/utils'), require('@tmagic/dep'), require('gesto'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', '@tmagic/design', 'emmet-monaco-es', 'monaco-editor', '@tmagic/form', '@tmagic/schema', 'moveable', '@tmagic/table', '@tmagic/utils', '@tmagic/dep', 'gesto', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.design, global.emmetMonacoEs, global.monaco, global.form, global.schema, global.VanillaMoveable, global.table, global.utils, global.dep, global.Gesto, global.StageCore, global.events, global.core, global.KeyController));
5
- })(this, (function (exports, vue, iconsVue, lodashEs, serialize, design, emmetMonacoEs, monaco, form, schema, VanillaMoveable, table, utils, dep, Gesto, StageCore, events, core, KeyController) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('@tmagic/design'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/form'), require('@tmagic/schema'), require('@tmagic/table'), require('@tmagic/utils'), require('moveable'), require('@tmagic/dep'), require('events'), require('gesto'), require('@tmagic/stage'), require('@tmagic/core'), require('keycon')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', '@tmagic/design', 'emmet-monaco-es', 'monaco-editor', '@tmagic/form', '@tmagic/schema', '@tmagic/table', '@tmagic/utils', 'moveable', '@tmagic/dep', 'events', 'gesto', '@tmagic/stage', '@tmagic/core', 'keycon'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.design, global.emmetMonacoEs, global.monaco, global.form, global.schema, global.table, global.utils, global.VanillaMoveable, global.dep, global.events, global.Gesto, global.StageCore, global.core, global.KeyController));
5
+ })(this, (function (exports, vue, iconsVue, lodashEs, serialize, design, emmetMonacoEs, monaco, form, schema, table, utils, VanillaMoveable, dep, events, Gesto, StageCore, core, KeyController) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -23,7 +23,7 @@
23
23
 
24
24
  const monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
25
25
 
26
- const _hoisted_1$t = ["src"];
26
+ const _hoisted_1$u = ["src"];
27
27
  const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
28
28
  ...{
29
29
  name: "MEditorIcon"
@@ -48,7 +48,7 @@
48
48
  class: "magic-editor-icon"
49
49
  }, {
50
50
  default: vue.withCtx(() => [
51
- vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$t)
51
+ vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$u)
52
52
  ]),
53
53
  _: 1
54
54
  })) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
@@ -76,7 +76,7 @@
76
76
  emmetMonacoEs.emmetHTML(monaco__namespace);
77
77
  emmetMonacoEs.emmetCSS(monaco__namespace, ["css", "scss"]);
78
78
 
79
- const _hoisted_1$s = {
79
+ const _hoisted_1$t = {
80
80
  class: /* @__PURE__ */ vue.normalizeClass(`magic-code-editor`)
81
81
  };
82
82
  const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
@@ -237,7 +237,7 @@
237
237
  }
238
238
  });
239
239
  return (_ctx, _cache) => {
240
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
240
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$t, [
241
241
  (vue.openBlock(), vue.createBlock(vue.Teleport, {
242
242
  to: "body",
243
243
  disabled: !fullScreen.value
@@ -510,689 +510,164 @@
510
510
  }
511
511
  });
512
512
 
513
- const _sfc_main$P = /* @__PURE__ */ vue.defineComponent({
514
- __name: "FloatingBox",
515
- props: /* @__PURE__ */ vue.mergeModels({
516
- position: { default: () => ({ left: 0, top: 0 }) },
517
- title: { default: "" },
518
- beforeClose: {}
519
- }, {
520
- "width": { default: 0 },
521
- "widthModifiers": {},
522
- "height": { default: 0 },
523
- "heightModifiers": {},
524
- "visible": { type: Boolean, ...{ default: false } },
525
- "visibleModifiers": {}
526
- }),
527
- emits: ["update:width", "update:height", "update:visible"],
528
- setup(__props, { expose: __expose }) {
529
- const width = vue.useModel(__props, "width");
530
- const height = vue.useModel(__props, "height");
531
- const visible = vue.useModel(__props, "visible");
532
- const props = __props;
533
- const target = vue.ref();
534
- const titleEl = vue.ref();
535
- const zIndex = design.useZIndex();
536
- const curZIndex = vue.ref(0);
537
- const titleHeight = vue.ref(0);
538
- const bodyHeight = vue.computed(() => {
539
- if (height.value) {
540
- return height.value - titleHeight.value;
541
- }
542
- if (target.value) {
543
- return target.value.clientHeight - titleHeight.value;
513
+ function BaseFormConfig() {
514
+ return [
515
+ {
516
+ name: "id",
517
+ type: "hidden"
518
+ },
519
+ {
520
+ name: "type",
521
+ text: "类型",
522
+ type: "hidden",
523
+ defaultValue: "base"
524
+ },
525
+ {
526
+ name: "title",
527
+ text: "名称",
528
+ rules: [
529
+ {
530
+ required: true,
531
+ message: "请输入名称"
532
+ }
533
+ ]
534
+ },
535
+ {
536
+ name: "description",
537
+ text: "描述"
538
+ }
539
+ ];
540
+ }
541
+
542
+ const HttpFormConfig = [
543
+ {
544
+ name: "autoFetch",
545
+ text: "自动请求",
546
+ type: "switch",
547
+ defaultValue: true
548
+ },
549
+ {
550
+ name: "responseOptions",
551
+ items: [
552
+ {
553
+ name: "dataPath",
554
+ text: "数据路径"
544
555
  }
545
- return "auto";
546
- });
547
- const services = vue.inject("services");
548
- const frameworkWidth = vue.computed(() => services?.uiService.get("frameworkRect").width || 0);
549
- const style = vue.computed(() => {
550
- let { left } = props.position;
551
- if (width.value) {
552
- left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
556
+ ]
557
+ },
558
+ {
559
+ type: "fieldset",
560
+ name: "options",
561
+ legend: "HTTP 配置",
562
+ items: [
563
+ {
564
+ name: "url",
565
+ text: "URL"
566
+ },
567
+ {
568
+ name: "method",
569
+ text: "Method",
570
+ type: "select",
571
+ options: [
572
+ { text: "GET", value: "GET" },
573
+ { text: "POST", value: "POST" },
574
+ { text: "PUT", value: "PUT" },
575
+ { text: "DELETE", value: "DELETE" }
576
+ ]
577
+ },
578
+ {
579
+ name: "params",
580
+ type: "key-value",
581
+ defaultValue: {},
582
+ text: "参数"
583
+ },
584
+ {
585
+ name: "data",
586
+ type: "key-value",
587
+ defaultValue: {},
588
+ advanced: true,
589
+ text: "请求体"
590
+ },
591
+ {
592
+ name: "headers",
593
+ type: "key-value",
594
+ defaultValue: {},
595
+ text: "请求头"
553
596
  }
554
- return {
555
- left: `${left}px`,
556
- top: `${props.position.top}px`,
557
- width: width.value ? `${width.value}px` : "auto",
558
- height: height.value ? `${height.value}px` : "auto"
559
- };
560
- });
561
- let moveable = null;
562
- const initMoveable = () => {
563
- moveable = new VanillaMoveable(globalThis.document.body, {
564
- className: "m-editor-floating-box-moveable",
565
- target: target.value,
566
- draggable: true,
567
- resizable: true,
568
- edge: true,
569
- keepRatio: false,
570
- origin: false,
571
- snappable: true,
572
- dragTarget: titleEl.value,
573
- dragTargetSelf: false,
574
- linePadding: 10,
575
- controlPadding: 10,
576
- bounds: { left: 0, top: 0, right: 0, bottom: 0, position: "css" }
577
- });
578
- moveable.on("drag", (e) => {
579
- e.target.style.transform = e.transform;
580
- });
581
- moveable.on("resize", (e) => {
582
- width.value = e.width;
583
- height.value = e.height;
584
- e.target.style.width = `${e.width}px`;
585
- e.target.style.height = `${e.height}px`;
586
- e.target.style.transform = e.drag.transform;
587
- });
588
- };
589
- const destroyMoveable = () => {
590
- moveable?.destroy();
591
- moveable = null;
592
- };
593
- vue.watch(
594
- visible,
595
- async (visible2) => {
596
- if (visible2) {
597
- await vue.nextTick();
598
- curZIndex.value = zIndex.nextZIndex();
599
- const targetRect = target.value?.getBoundingClientRect();
600
- if (targetRect) {
601
- width.value = targetRect.width;
602
- height.value = targetRect.height;
603
- initMoveable();
597
+ ]
598
+ }
599
+ ];
600
+
601
+ const fillConfig$1 = (config) => [
602
+ ...BaseFormConfig(),
603
+ ...config,
604
+ {
605
+ type: "tab",
606
+ items: [
607
+ {
608
+ title: "数据定义",
609
+ items: [
610
+ {
611
+ name: "fields",
612
+ type: "data-source-fields",
613
+ defaultValue: () => []
604
614
  }
605
- if (titleEl.value) {
606
- const titleRect = titleEl.value.getBoundingClientRect();
607
- titleHeight.value = titleRect.height;
615
+ ]
616
+ },
617
+ {
618
+ title: "方法定义",
619
+ items: [
620
+ {
621
+ name: "methods",
622
+ type: "data-source-methods",
623
+ defaultValue: () => []
608
624
  }
609
- } else {
610
- destroyMoveable();
611
- }
625
+ ]
612
626
  },
613
627
  {
614
- immediate: true
615
- }
616
- );
617
- vue.onBeforeUnmount(() => {
618
- destroyMoveable();
619
- });
620
- const hide = (cancel) => {
621
- if (cancel !== false) {
622
- visible.value = false;
623
- }
624
- };
625
- const closeHandler = () => {
626
- if (typeof props.beforeClose === "function") {
627
- props.beforeClose(hide);
628
- } else {
629
- hide();
630
- }
631
- };
632
- const nextZIndex = () => {
633
- curZIndex.value = zIndex.nextZIndex();
634
- };
635
- vue.provide("parentFloating", target);
636
- __expose({
637
- bodyHeight,
638
- target,
639
- titleEl
640
- });
641
- return (_ctx, _cache) => {
642
- return visible.value ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
643
- key: 0,
644
- to: "body"
645
- }, [
646
- vue.createElementVNode("div", {
647
- ref_key: "target",
648
- ref: target,
649
- class: "m-editor-float-box",
650
- style: vue.normalizeStyle({ ...style.value, zIndex: curZIndex.value }),
651
- onMousedown: nextZIndex
652
- }, [
653
- vue.createElementVNode("div", {
654
- ref_key: "titleEl",
655
- ref: titleEl,
656
- class: "m-editor-float-box-title"
657
- }, [
658
- vue.renderSlot(_ctx.$slots, "title", {}, () => [
659
- vue.createElementVNode("span", null, vue.toDisplayString(_ctx.title), 1)
660
- ]),
661
- vue.createElementVNode("div", null, [
662
- vue.createVNode(vue.unref(design.TMagicButton), {
663
- link: "",
664
- size: "small",
665
- onClick: closeHandler
666
- }, {
667
- default: vue.withCtx(() => [
668
- vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Close) }, null, 8, ["icon"])
669
- ]),
670
- _: 1
671
- })
672
- ])
673
- ], 512),
674
- vue.createElementVNode("div", {
675
- class: "m-editor-float-box-body",
676
- style: vue.normalizeStyle({ height: `${bodyHeight.value}px` })
677
- }, [
678
- vue.renderSlot(_ctx.$slots, "body")
679
- ], 4)
680
- ], 36)
681
- ])) : vue.createCommentVNode("", true);
682
- };
683
- }
684
- });
685
-
686
- const useEditorContentHeight = () => {
687
- const services = vue.inject("services");
688
- const frameworkHeight = vue.computed(() => services?.uiService.get("frameworkRect").height || 0);
689
- const navMenuHeight = vue.computed(() => services?.uiService.get("navMenuRect").height || 0);
690
- const editorContentHeight = vue.computed(() => frameworkHeight.value - navMenuHeight.value);
691
- const height = vue.ref(0);
692
- vue.watchEffect(() => {
693
- if (height.value > 0 && height.value === editorContentHeight.value)
694
- return;
695
- height.value = editorContentHeight.value;
696
- });
697
- return {
698
- height
699
- };
700
- };
701
-
702
- const useNextFloatBoxPosition = (uiService, parent) => {
703
- const boxPosition = vue.ref({
704
- left: 0,
705
- top: 0
706
- });
707
- const calcBoxPosition = () => {
708
- const columnWidth = uiService?.get("columnWidth");
709
- const navMenuRect = uiService?.get("navMenuRect");
710
- let left = columnWidth?.left ?? 0;
711
- if (parent?.value) {
712
- const rect = parent?.value?.getBoundingClientRect();
713
- left = (rect?.left ?? 0) + (rect?.width ?? 0);
714
- }
715
- boxPosition.value = {
716
- left,
717
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
718
- };
719
- };
720
- return {
721
- boxPosition,
722
- calcBoxPosition
723
- };
724
- };
725
-
726
- const useWindowRect = () => {
727
- const rect = vue.reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
728
- const windowResizeHandler = () => {
729
- rect.width = globalThis.innerWidth;
730
- rect.height = globalThis.innerHeight;
731
- };
732
- globalThis.addEventListener("resize", windowResizeHandler);
733
- vue.onBeforeUnmount(() => {
734
- globalThis.removeEventListener("resize", windowResizeHandler);
735
- });
736
- return {
737
- rect
738
- };
739
- };
740
-
741
- const _hoisted_1$r = { style: { "display": "flex", "margin-bottom": "10px" } };
742
- const _hoisted_2$k = { style: { "flex": "1" } };
743
- const _hoisted_3$8 = { style: { "flex": "1" } };
744
- const _hoisted_4$7 = { class: "dialog-footer" };
745
- const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
746
- ...{
747
- name: "MEditorCodeBlockEditor"
748
- },
749
- __name: "CodeBlockEditor",
750
- props: /* @__PURE__ */ vue.mergeModels({
751
- content: {},
752
- disabled: { type: Boolean },
753
- isDataSource: { type: Boolean },
754
- dataSourceType: {}
755
- }, {
756
- "width": { default: 670 },
757
- "widthModifiers": {},
758
- "visible": { type: Boolean, ...{ default: false } },
759
- "visibleModifiers": {}
760
- }),
761
- emits: /* @__PURE__ */ vue.mergeModels(["submit"], ["update:width", "update:visible"]),
762
- setup(__props, { expose: __expose, emit: __emit }) {
763
- const width = vue.useModel(__props, "width");
764
- const boxVisible = vue.useModel(__props, "visible");
765
- const props = __props;
766
- const emit = __emit;
767
- const services = vue.inject("services");
768
- const { height: codeBlockEditorHeight } = useEditorContentHeight();
769
- const difVisible = vue.ref(false);
770
- const { rect: windowRect } = useWindowRect();
771
- const magicVsEditor = vue.ref();
772
- const diffChange = () => {
773
- if (!magicVsEditor.value || !formBox.value?.form) {
774
- return;
775
- }
776
- formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
777
- difVisible.value = false;
778
- };
779
- const defaultParamColConfig = {
780
- type: "row",
781
- label: "参数类型",
782
- items: [
783
- {
784
- text: "参数类型",
785
- labelWidth: "70px",
786
- type: "select",
787
- name: "type",
788
- options: [
789
- {
790
- text: "数字",
791
- label: "数字",
792
- value: "number"
793
- },
794
- {
795
- text: "字符串",
796
- label: "字符串",
797
- value: "text"
798
- },
799
- {
800
- text: "组件",
801
- label: "组件",
802
- value: "ui-select"
803
- }
804
- ]
805
- }
806
- ]
807
- };
808
- const functionConfig = vue.computed(() => [
809
- {
810
- text: "名称",
811
- name: "name",
812
- rules: [{ required: true, message: "请输入名称", trigger: "blur" }]
813
- },
814
- {
815
- text: "描述",
816
- name: "desc"
817
- },
818
- {
819
- text: "执行时机",
820
- name: "timing",
821
- type: "select",
822
- options: () => {
823
- const options = [
824
- { text: "初始化前", value: "beforeInit" },
825
- { text: "初始化后", value: "afterInit" }
826
- ];
827
- if (props.dataSourceType !== "base") {
828
- options.push({ text: "请求前", value: "beforeRequest" });
829
- options.push({ text: "请求后", value: "afterRequest" });
830
- }
831
- return options;
832
- },
833
- display: () => props.isDataSource
834
- },
835
- {
836
- type: "table",
837
- border: true,
838
- text: "参数",
839
- enableFullscreen: false,
840
- enableToggleMode: false,
841
- name: "params",
842
- dropSort: false,
843
- items: [
844
- {
845
- type: "text",
846
- label: "参数名",
847
- name: "name"
848
- },
849
- {
850
- type: "text",
851
- label: "描述",
852
- name: "extra"
853
- },
854
- services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
855
- ]
856
- },
857
- {
858
- name: "content",
859
- type: "vs-code",
860
- options: vue.inject("codeOptions", {}),
861
- height: "500px",
862
- onChange: (formState, code) => {
863
- try {
864
- getConfig("parseDSL")(code);
865
- return code;
866
- } catch (error) {
867
- design.tMagicMessage.error(error.message);
868
- throw error;
869
- }
870
- }
871
- }
872
- ]);
873
- const submitForm = (values) => {
874
- changedValue.value = void 0;
875
- emit("submit", values);
876
- };
877
- const errorHandler = (error) => {
878
- design.tMagicMessage.error(error.message);
879
- };
880
- const formBox = vue.ref();
881
- const changedValue = vue.ref();
882
- const changeHandler = (values) => {
883
- changedValue.value = values;
884
- };
885
- const beforeClose = (done) => {
886
- if (!changedValue.value) {
887
- done();
888
- return;
889
- }
890
- design.tMagicMessageBox.confirm("当前代码块已修改,是否保存?", "提示", {
891
- confirmButtonText: "保存并关闭",
892
- cancelButtonText: "不保存并关闭",
893
- type: "warning",
894
- distinguishCancelAndClose: true
895
- }).then(() => {
896
- changedValue.value && submitForm(changedValue.value);
897
- done();
898
- }).catch((action) => {
899
- done(action === "cancel");
900
- });
901
- };
902
- const closedHandler = () => {
903
- changedValue.value = void 0;
904
- };
905
- const parentFloating = vue.inject("parentFloating", vue.ref(null));
906
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
907
- __expose({
908
- async show() {
909
- calcBoxPosition();
910
- boxVisible.value = true;
911
- },
912
- async hide() {
913
- boxVisible.value = false;
914
- }
915
- });
916
- return (_ctx, _cache) => {
917
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
918
- vue.createVNode(_sfc_main$P, {
919
- visible: boxVisible.value,
920
- "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
921
- width: width.value,
922
- "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
923
- height: vue.unref(codeBlockEditorHeight),
924
- "onUpdate:height": _cache[3] || (_cache[3] = ($event) => vue.isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
925
- title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
926
- position: vue.unref(boxPosition),
927
- "before-close": beforeClose
928
- }, {
929
- body: vue.withCtx(() => [
930
- vue.createVNode(vue.unref(form.MFormBox), {
931
- class: "m-editor-code-block-editor",
932
- ref_key: "formBox",
933
- ref: formBox,
934
- "label-width": "80px",
935
- "close-on-press-escape": false,
936
- title: _ctx.content.name,
937
- config: functionConfig.value,
938
- values: _ctx.content,
939
- disabled: _ctx.disabled,
940
- style: { "height": "100%" },
941
- onChange: changeHandler,
942
- onSubmit: submitForm,
943
- onError: errorHandler,
944
- onClosed: closedHandler
945
- }, {
946
- left: vue.withCtx(() => [
947
- !_ctx.disabled ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
948
- key: 0,
949
- type: "primary",
950
- link: "",
951
- onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
952
- }, {
953
- default: vue.withCtx(() => [
954
- vue.createTextVNode("查看修改")
955
- ]),
956
- _: 1
957
- })) : vue.createCommentVNode("", true)
958
- ]),
959
- _: 1
960
- }, 8, ["title", "config", "values", "disabled"])
961
- ]),
962
- _: 1
963
- }, 8, ["visible", "width", "height", "title", "position"]),
964
- (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
965
- vue.createVNode(vue.unref(design.TMagicDialog), {
966
- title: "查看修改",
967
- modelValue: difVisible.value,
968
- "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
969
- fullscreen: ""
970
- }, {
971
- footer: vue.withCtx(() => [
972
- vue.createElementVNode("span", _hoisted_4$7, [
973
- vue.createVNode(vue.unref(design.TMagicButton), {
974
- size: "small",
975
- onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
976
- }, {
977
- default: vue.withCtx(() => [
978
- vue.createTextVNode("取消")
979
- ]),
980
- _: 1
981
- }),
982
- vue.createVNode(vue.unref(design.TMagicButton), {
983
- size: "small",
984
- type: "primary",
985
- onClick: diffChange
986
- }, {
987
- default: vue.withCtx(() => [
988
- vue.createTextVNode("确定")
989
- ]),
990
- _: 1
991
- })
992
- ])
993
- ]),
994
- default: vue.withCtx(() => [
995
- vue.createElementVNode("div", _hoisted_1$r, [
996
- vue.createElementVNode("div", _hoisted_2$k, [
997
- vue.createVNode(vue.unref(design.TMagicTag), {
998
- size: "small",
999
- type: "info"
1000
- }, {
1001
- default: vue.withCtx(() => [
1002
- vue.createTextVNode("修改前")
1003
- ]),
1004
- _: 1
1005
- })
1006
- ]),
1007
- vue.createElementVNode("div", _hoisted_3$8, [
1008
- vue.createVNode(vue.unref(design.TMagicTag), {
1009
- size: "small",
1010
- type: "success"
1011
- }, {
1012
- default: vue.withCtx(() => [
1013
- vue.createTextVNode("修改后")
1014
- ]),
1015
- _: 1
1016
- })
1017
- ])
1018
- ]),
1019
- difVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
1020
- key: 0,
1021
- ref_key: "magicVsEditor",
1022
- ref: magicVsEditor,
1023
- type: "diff",
1024
- language: "json",
1025
- initValues: _ctx.content.content,
1026
- modifiedValues: formBox.value?.form?.values.content,
1027
- style: vue.normalizeStyle(`height: ${vue.unref(windowRect).height - 150}px`)
1028
- }, null, 8, ["initValues", "modifiedValues", "style"])) : vue.createCommentVNode("", true)
1029
- ]),
1030
- _: 1
1031
- }, 8, ["modelValue"])
1032
- ]))
1033
- ], 64);
1034
- };
1035
- }
1036
- });
1037
-
1038
- function BaseFormConfig() {
1039
- return [
1040
- {
1041
- name: "id",
1042
- type: "hidden"
1043
- },
1044
- {
1045
- name: "type",
1046
- text: "类型",
1047
- type: "hidden",
1048
- defaultValue: "base"
1049
- },
1050
- {
1051
- name: "title",
1052
- text: "名称",
1053
- rules: [
1054
- {
1055
- required: true,
1056
- message: "请输入名称"
1057
- }
1058
- ]
1059
- },
1060
- {
1061
- name: "description",
1062
- text: "描述"
1063
- }
1064
- ];
1065
- }
1066
-
1067
- const HttpFormConfig = [
1068
- {
1069
- name: "autoFetch",
1070
- text: "自动请求",
1071
- type: "switch",
1072
- defaultValue: true
1073
- },
1074
- {
1075
- name: "responseOptions",
1076
- items: [
1077
- {
1078
- name: "dataPath",
1079
- text: "数据路径"
1080
- }
1081
- ]
1082
- },
1083
- {
1084
- type: "fieldset",
1085
- name: "options",
1086
- legend: "HTTP 配置",
1087
- items: [
1088
- {
1089
- name: "url",
1090
- text: "URL"
1091
- },
1092
- {
1093
- name: "method",
1094
- text: "Method",
1095
- type: "select",
1096
- options: [
1097
- { text: "GET", value: "GET" },
1098
- { text: "POST", value: "POST" },
1099
- { text: "PUT", value: "PUT" },
1100
- { text: "DELETE", value: "DELETE" }
1101
- ]
1102
- },
1103
- {
1104
- name: "params",
1105
- type: "key-value",
1106
- defaultValue: {},
1107
- text: "参数"
1108
- },
1109
- {
1110
- name: "data",
1111
- type: "key-value",
1112
- defaultValue: {},
1113
- advanced: true,
1114
- text: "请求体"
1115
- },
1116
- {
1117
- name: "headers",
1118
- type: "key-value",
1119
- defaultValue: {},
1120
- text: "请求头"
1121
- }
1122
- ]
1123
- }
1124
- ];
1125
-
1126
- const fillConfig$1 = (config) => [
1127
- ...BaseFormConfig(),
1128
- ...config,
1129
- {
1130
- type: "tab",
1131
- items: [
1132
- {
1133
- title: "数据定义",
1134
- items: [
1135
- {
1136
- name: "fields",
1137
- type: "data-source-fields",
1138
- defaultValue: () => []
1139
- }
1140
- ]
1141
- },
1142
- {
1143
- title: "方法定义",
1144
- items: [
1145
- {
1146
- name: "methods",
1147
- type: "data-source-methods",
1148
- defaultValue: () => []
1149
- }
1150
- ]
1151
- },
1152
- {
1153
- title: "事件配置",
1154
- display: false,
1155
- items: [
1156
- {
1157
- name: "events",
1158
- src: "datasource",
1159
- type: "event-select"
1160
- }
1161
- ]
1162
- },
1163
- {
1164
- title: "mock数据",
1165
- items: [
1166
- {
1167
- name: "mocks",
1168
- type: "data-source-mocks",
1169
- defaultValue: () => []
1170
- }
1171
- ]
1172
- },
1173
- {
1174
- title: "请求参数裁剪",
1175
- display: (formState, { model }) => model.type === "http",
1176
- items: [
1177
- {
1178
- name: "beforeRequest",
1179
- type: "vs-code",
1180
- parse: true,
1181
- height: "600px"
1182
- }
1183
- ]
1184
- },
1185
- {
1186
- title: "响应数据裁剪",
1187
- display: (formState, { model }) => model.type === "http",
1188
- items: [
1189
- {
1190
- name: "afterResponse",
1191
- type: "vs-code",
1192
- parse: true,
1193
- height: "600px"
1194
- }
1195
- ]
628
+ title: "事件配置",
629
+ display: false,
630
+ items: [
631
+ {
632
+ name: "events",
633
+ src: "datasource",
634
+ type: "event-select"
635
+ }
636
+ ]
637
+ },
638
+ {
639
+ title: "mock数据",
640
+ items: [
641
+ {
642
+ name: "mocks",
643
+ type: "data-source-mocks",
644
+ defaultValue: () => []
645
+ }
646
+ ]
647
+ },
648
+ {
649
+ title: "请求参数裁剪",
650
+ display: (formState, { model }) => model.type === "http",
651
+ items: [
652
+ {
653
+ name: "beforeRequest",
654
+ type: "vs-code",
655
+ parse: true,
656
+ height: "600px"
657
+ }
658
+ ]
659
+ },
660
+ {
661
+ title: "响应数据裁剪",
662
+ display: (formState, { model }) => model.type === "http",
663
+ items: [
664
+ {
665
+ name: "afterResponse",
666
+ type: "vs-code",
667
+ parse: true,
668
+ height: "600px"
669
+ }
670
+ ]
1196
671
  }
1197
672
  ]
1198
673
  }
@@ -2057,6 +1532,13 @@
2057
1532
  ColumnLayout2["RIGHT"] = "right";
2058
1533
  return ColumnLayout2;
2059
1534
  })(ColumnLayout || {});
1535
+ var SideItemKey = /* @__PURE__ */ ((SideItemKey2) => {
1536
+ SideItemKey2["COMPONENT_LIST"] = "component-list";
1537
+ SideItemKey2["LAYER"] = "layer";
1538
+ SideItemKey2["CODE_BLOCK"] = "code-block";
1539
+ SideItemKey2["DATA_SOURCE"] = "data-source";
1540
+ return SideItemKey2;
1541
+ })(SideItemKey || {});
2060
1542
  var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
2061
1543
  LayerOffset2["TOP"] = "top";
2062
1544
  LayerOffset2["BOTTOM"] = "bottom";
@@ -3708,7 +3190,7 @@
3708
3190
  return newNode;
3709
3191
  };
3710
3192
 
3711
- const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
3193
+ const _sfc_main$P = /* @__PURE__ */ vue.defineComponent({
3712
3194
  ...{
3713
3195
  name: "MEditorCodeParams"
3714
3196
  },
@@ -3758,68 +3240,9 @@
3758
3240
  }
3759
3241
  });
3760
3242
 
3761
- const useCodeBlockEdit = (codeBlockService) => {
3762
- const codeConfig = vue.ref();
3763
- const codeId = vue.ref();
3764
- const codeBlockEditor = vue.ref();
3765
- const createCodeBlock = async () => {
3766
- if (!codeBlockService) {
3767
- design.tMagicMessage.error("新增代码块失败");
3768
- return;
3769
- }
3770
- codeConfig.value = {
3771
- name: "",
3772
- content: `({app, params}) => {
3773
- // place your code here
3774
- }`,
3775
- params: []
3776
- };
3777
- codeId.value = await codeBlockService.getUniqueId();
3778
- await vue.nextTick();
3779
- codeBlockEditor.value?.show();
3780
- };
3781
- const editCode = async (id) => {
3782
- const codeBlock = await codeBlockService?.getCodeContentById(id);
3783
- if (!codeBlock) {
3784
- design.tMagicMessage.error("获取代码块内容失败");
3785
- return;
3786
- }
3787
- let codeContent = codeBlock.content;
3788
- if (typeof codeContent !== "string") {
3789
- codeContent = codeContent.toString();
3790
- }
3791
- codeConfig.value = {
3792
- ...lodashEs.cloneDeep(codeBlock),
3793
- content: codeContent
3794
- };
3795
- codeId.value = id;
3796
- await vue.nextTick();
3797
- codeBlockEditor.value?.show();
3798
- };
3799
- const deleteCode = async (key) => {
3800
- codeBlockService?.deleteCodeDslByIds([key]);
3801
- };
3802
- const submitCodeBlockHandler = async (values) => {
3803
- if (!codeId.value)
3804
- return;
3805
- await codeBlockService?.setCodeDslById(codeId.value, values);
3806
- design.tMagicMessage.success("代码块保存成功");
3807
- codeBlockEditor.value?.hide();
3808
- };
3809
- return {
3810
- codeId,
3811
- codeConfig,
3812
- codeBlockEditor,
3813
- createCodeBlock,
3814
- editCode,
3815
- deleteCode,
3816
- submitCodeBlockHandler
3817
- };
3818
- };
3819
-
3820
- const _hoisted_1$q = { class: "m-fields-code-select-col" };
3821
- const _hoisted_2$j = { class: "code-select-container" };
3822
- const _sfc_main$M = /* @__PURE__ */ vue.defineComponent({
3243
+ const _hoisted_1$s = { class: "m-fields-code-select-col" };
3244
+ const _hoisted_2$k = { class: "code-select-container" };
3245
+ const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
3823
3246
  ...{
3824
3247
  name: "MFieldsCodeSelectCol"
3825
3248
  },
@@ -3839,9 +3262,13 @@
3839
3262
  setup(__props, { emit: __emit }) {
3840
3263
  const mForm = vue.inject("mForm");
3841
3264
  const services = vue.inject("services");
3265
+ const eventBus = vue.inject("eventBus");
3842
3266
  const emit = __emit;
3843
- const notEditable = vue.computed(() => form.filterFunction(mForm, props.config.notEditable, props));
3844
3267
  const props = __props;
3268
+ const notEditable = vue.computed(() => form.filterFunction(mForm, props.config.notEditable, props));
3269
+ const hasCodeBlockSidePanel = vue.computed(
3270
+ () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
3271
+ );
3845
3272
  const getParamItemsConfig = (codeId) => {
3846
3273
  if (!codeDsl.value || !codeId)
3847
3274
  return [];
@@ -3892,46 +3319,278 @@
3892
3319
  props.model.params = value.params;
3893
3320
  emit("change", props.model);
3894
3321
  };
3895
- const { codeBlockEditor, codeConfig, editCode, submitCodeBlockHandler } = useCodeBlockEdit(services?.codeBlockService);
3322
+ const editCode = (id) => {
3323
+ eventBus?.emit("edit-code", id);
3324
+ };
3896
3325
  return (_ctx, _cache) => {
3897
- const _component_m_form_container = vue.resolveComponent("m-form-container");
3898
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$q, [
3899
- vue.createElementVNode("div", _hoisted_2$j, [
3900
- vue.createVNode(_component_m_form_container, {
3326
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
3327
+ vue.createElementVNode("div", _hoisted_2$k, [
3328
+ vue.createVNode(vue.unref(form.MContainer), {
3901
3329
  class: "select",
3902
3330
  config: selectConfig,
3903
3331
  model: _ctx.model,
3904
3332
  size: _ctx.size,
3905
3333
  onChange: onParamsChangeHandler
3906
3334
  }, null, 8, ["model", "size"]),
3907
- _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
3335
+ _ctx.model[_ctx.name] && hasCodeBlockSidePanel.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
3908
3336
  key: 0,
3909
- class: "icon",
3910
- icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
3911
- onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(editCode)(_ctx.model[_ctx.name]))
3912
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
3337
+ class: "m-fields-select-action-button",
3338
+ size: _ctx.size,
3339
+ onClick: _cache[0] || (_cache[0] = ($event) => editCode(_ctx.model[_ctx.name]))
3340
+ }, {
3341
+ default: vue.withCtx(() => [
3342
+ vue.createVNode(_sfc_main$U, {
3343
+ icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View)
3344
+ }, null, 8, ["icon"])
3345
+ ]),
3346
+ _: 1
3347
+ }, 8, ["size"])) : vue.createCommentVNode("", true)
3913
3348
  ]),
3914
- paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
3349
+ paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
3915
3350
  name: "params",
3916
3351
  key: _ctx.model[_ctx.name],
3917
3352
  model: _ctx.model,
3918
3353
  size: _ctx.size,
3919
3354
  "params-config": paramsConfig.value,
3920
3355
  onChange: onParamsChangeHandler
3921
- }, null, 8, ["model", "size", "params-config"])) : vue.createCommentVNode("", true),
3922
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
3923
- key: 1,
3924
- ref_key: "codeBlockEditor",
3925
- ref: codeBlockEditor,
3926
- disabled: notEditable.value,
3927
- content: vue.unref(codeConfig),
3928
- onSubmit: vue.unref(submitCodeBlockHandler)
3929
- }, null, 8, ["disabled", "content", "onSubmit"])) : vue.createCommentVNode("", true)
3356
+ }, null, 8, ["model", "size", "params-config"])) : vue.createCommentVNode("", true)
3930
3357
  ]);
3931
3358
  };
3932
3359
  }
3933
3360
  });
3934
3361
 
3362
+ const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
3363
+ __name: "FloatingBox",
3364
+ props: /* @__PURE__ */ vue.mergeModels({
3365
+ position: { default: () => ({ left: 0, top: 0 }) },
3366
+ title: { default: "" },
3367
+ beforeClose: {}
3368
+ }, {
3369
+ "width": { default: 0 },
3370
+ "widthModifiers": {},
3371
+ "height": { default: 0 },
3372
+ "heightModifiers": {},
3373
+ "visible": { type: Boolean, ...{ default: false } },
3374
+ "visibleModifiers": {}
3375
+ }),
3376
+ emits: ["update:width", "update:height", "update:visible"],
3377
+ setup(__props, { expose: __expose }) {
3378
+ const width = vue.useModel(__props, "width");
3379
+ const height = vue.useModel(__props, "height");
3380
+ const visible = vue.useModel(__props, "visible");
3381
+ const props = __props;
3382
+ const target = vue.ref();
3383
+ const titleEl = vue.ref();
3384
+ const zIndex = design.useZIndex();
3385
+ const curZIndex = vue.ref(0);
3386
+ const titleHeight = vue.ref(0);
3387
+ const bodyHeight = vue.computed(() => {
3388
+ if (height.value) {
3389
+ return height.value - titleHeight.value;
3390
+ }
3391
+ if (target.value) {
3392
+ return target.value.clientHeight - titleHeight.value;
3393
+ }
3394
+ return "auto";
3395
+ });
3396
+ const services = vue.inject("services");
3397
+ const frameworkWidth = vue.computed(() => services?.uiService.get("frameworkRect").width || 0);
3398
+ const style = vue.computed(() => {
3399
+ let { left } = props.position;
3400
+ if (width.value) {
3401
+ left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
3402
+ }
3403
+ return {
3404
+ left: `${left}px`,
3405
+ top: `${props.position.top}px`,
3406
+ width: width.value ? `${width.value}px` : "auto",
3407
+ height: height.value ? `${height.value}px` : "auto"
3408
+ };
3409
+ });
3410
+ let moveable = null;
3411
+ const initMoveable = () => {
3412
+ moveable = new VanillaMoveable(globalThis.document.body, {
3413
+ className: "m-editor-floating-box-moveable",
3414
+ target: target.value,
3415
+ draggable: true,
3416
+ resizable: true,
3417
+ edge: true,
3418
+ keepRatio: false,
3419
+ origin: false,
3420
+ snappable: true,
3421
+ dragTarget: titleEl.value,
3422
+ dragTargetSelf: false,
3423
+ linePadding: 10,
3424
+ controlPadding: 10,
3425
+ bounds: { left: 0, top: 0, right: 0, bottom: 0, position: "css" }
3426
+ });
3427
+ moveable.on("drag", (e) => {
3428
+ e.target.style.transform = e.transform;
3429
+ });
3430
+ moveable.on("resize", (e) => {
3431
+ width.value = e.width;
3432
+ height.value = e.height;
3433
+ e.target.style.width = `${e.width}px`;
3434
+ e.target.style.height = `${e.height}px`;
3435
+ e.target.style.transform = e.drag.transform;
3436
+ });
3437
+ };
3438
+ const destroyMoveable = () => {
3439
+ moveable?.destroy();
3440
+ moveable = null;
3441
+ };
3442
+ vue.watch(
3443
+ visible,
3444
+ async (visible2) => {
3445
+ if (visible2) {
3446
+ await vue.nextTick();
3447
+ curZIndex.value = zIndex.nextZIndex();
3448
+ const targetRect = target.value?.getBoundingClientRect();
3449
+ if (targetRect) {
3450
+ width.value = targetRect.width;
3451
+ height.value = targetRect.height;
3452
+ initMoveable();
3453
+ }
3454
+ if (titleEl.value) {
3455
+ const titleRect = titleEl.value.getBoundingClientRect();
3456
+ titleHeight.value = titleRect.height;
3457
+ }
3458
+ } else {
3459
+ destroyMoveable();
3460
+ }
3461
+ },
3462
+ {
3463
+ immediate: true
3464
+ }
3465
+ );
3466
+ vue.onBeforeUnmount(() => {
3467
+ destroyMoveable();
3468
+ });
3469
+ const hide = (cancel) => {
3470
+ if (cancel !== false) {
3471
+ visible.value = false;
3472
+ }
3473
+ };
3474
+ const closeHandler = () => {
3475
+ if (typeof props.beforeClose === "function") {
3476
+ props.beforeClose(hide);
3477
+ } else {
3478
+ hide();
3479
+ }
3480
+ };
3481
+ const nextZIndex = () => {
3482
+ curZIndex.value = zIndex.nextZIndex();
3483
+ };
3484
+ vue.provide("parentFloating", target);
3485
+ __expose({
3486
+ bodyHeight,
3487
+ target,
3488
+ titleEl
3489
+ });
3490
+ return (_ctx, _cache) => {
3491
+ return visible.value ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
3492
+ key: 0,
3493
+ to: "body"
3494
+ }, [
3495
+ vue.createElementVNode("div", {
3496
+ ref_key: "target",
3497
+ ref: target,
3498
+ class: "m-editor-float-box",
3499
+ style: vue.normalizeStyle({ ...style.value, zIndex: curZIndex.value }),
3500
+ onMousedown: nextZIndex
3501
+ }, [
3502
+ vue.createElementVNode("div", {
3503
+ ref_key: "titleEl",
3504
+ ref: titleEl,
3505
+ class: "m-editor-float-box-title"
3506
+ }, [
3507
+ vue.renderSlot(_ctx.$slots, "title", {}, () => [
3508
+ vue.createElementVNode("span", null, vue.toDisplayString(_ctx.title), 1)
3509
+ ]),
3510
+ vue.createElementVNode("div", null, [
3511
+ vue.createVNode(vue.unref(design.TMagicButton), {
3512
+ link: "",
3513
+ size: "small",
3514
+ onClick: closeHandler
3515
+ }, {
3516
+ default: vue.withCtx(() => [
3517
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Close) }, null, 8, ["icon"])
3518
+ ]),
3519
+ _: 1
3520
+ })
3521
+ ])
3522
+ ], 512),
3523
+ vue.createElementVNode("div", {
3524
+ class: "m-editor-float-box-body",
3525
+ style: vue.normalizeStyle({ height: `${bodyHeight.value}px` })
3526
+ }, [
3527
+ vue.renderSlot(_ctx.$slots, "body")
3528
+ ], 4)
3529
+ ], 36)
3530
+ ])) : vue.createCommentVNode("", true);
3531
+ };
3532
+ }
3533
+ });
3534
+
3535
+ const useCodeBlockEdit = (codeBlockService) => {
3536
+ const codeConfig = vue.ref();
3537
+ const codeId = vue.ref();
3538
+ const codeBlockEditor = vue.ref();
3539
+ const createCodeBlock = async () => {
3540
+ if (!codeBlockService) {
3541
+ design.tMagicMessage.error("新增代码块失败");
3542
+ return;
3543
+ }
3544
+ codeConfig.value = {
3545
+ name: "",
3546
+ content: `({app, params}) => {
3547
+ // place your code here
3548
+ }`,
3549
+ params: []
3550
+ };
3551
+ codeId.value = await codeBlockService.getUniqueId();
3552
+ await vue.nextTick();
3553
+ codeBlockEditor.value?.show();
3554
+ };
3555
+ const editCode = async (id) => {
3556
+ const codeBlock = await codeBlockService?.getCodeContentById(id);
3557
+ if (!codeBlock) {
3558
+ design.tMagicMessage.error("获取代码块内容失败");
3559
+ return;
3560
+ }
3561
+ let codeContent = codeBlock.content;
3562
+ if (typeof codeContent !== "string") {
3563
+ codeContent = codeContent.toString();
3564
+ }
3565
+ codeConfig.value = {
3566
+ ...lodashEs.cloneDeep(codeBlock),
3567
+ content: codeContent
3568
+ };
3569
+ codeId.value = id;
3570
+ await vue.nextTick();
3571
+ codeBlockEditor.value?.show();
3572
+ };
3573
+ const deleteCode = async (key) => {
3574
+ codeBlockService?.deleteCodeDslByIds([key]);
3575
+ };
3576
+ const submitCodeBlockHandler = async (values) => {
3577
+ if (!codeId.value)
3578
+ return;
3579
+ await codeBlockService?.setCodeDslById(codeId.value, values);
3580
+ design.tMagicMessage.success("代码块保存成功");
3581
+ codeBlockEditor.value?.hide();
3582
+ };
3583
+ return {
3584
+ codeId,
3585
+ codeConfig,
3586
+ codeBlockEditor,
3587
+ createCodeBlock,
3588
+ editCode,
3589
+ deleteCode,
3590
+ submitCodeBlockHandler
3591
+ };
3592
+ };
3593
+
3935
3594
  const useDataSourceMethod = () => {
3936
3595
  const codeConfig = vue.ref();
3937
3596
  const codeBlockEditor = vue.ref();
@@ -4026,6 +3685,7 @@
4026
3685
  propsPanelSize: "small",
4027
3686
  showAddPageButton: true,
4028
3687
  hideSlideBar: false,
3688
+ sideBarItems: [],
4029
3689
  navMenuRect: {
4030
3690
  left: 0,
4031
3691
  top: 0,
@@ -4269,9 +3929,70 @@
4269
3929
  };
4270
3930
  };
4271
3931
 
4272
- const _hoisted_1$p = { class: "m-editor-data-source-fields" };
4273
- const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
4274
- const _sfc_main$L = /* @__PURE__ */ vue.defineComponent({
3932
+ const useWindowRect = () => {
3933
+ const rect = vue.reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
3934
+ const windowResizeHandler = () => {
3935
+ rect.width = globalThis.innerWidth;
3936
+ rect.height = globalThis.innerHeight;
3937
+ };
3938
+ globalThis.addEventListener("resize", windowResizeHandler);
3939
+ vue.onBeforeUnmount(() => {
3940
+ globalThis.removeEventListener("resize", windowResizeHandler);
3941
+ });
3942
+ return {
3943
+ rect
3944
+ };
3945
+ };
3946
+
3947
+ const useEditorContentHeight = () => {
3948
+ const services = vue.inject("services");
3949
+ const frameworkHeight = vue.computed(() => services?.uiService.get("frameworkRect").height || 0);
3950
+ const navMenuHeight = vue.computed(() => services?.uiService.get("navMenuRect").height || 0);
3951
+ const editorContentHeight = vue.computed(() => frameworkHeight.value - navMenuHeight.value);
3952
+ const height = vue.ref(0);
3953
+ vue.watch(
3954
+ editorContentHeight,
3955
+ () => {
3956
+ if (height.value > 0 && height.value === editorContentHeight.value)
3957
+ return;
3958
+ height.value = editorContentHeight.value;
3959
+ },
3960
+ {
3961
+ immediate: true
3962
+ }
3963
+ );
3964
+ return {
3965
+ height
3966
+ };
3967
+ };
3968
+
3969
+ const useNextFloatBoxPosition = (uiService, parent) => {
3970
+ const boxPosition = vue.ref({
3971
+ left: 0,
3972
+ top: 0
3973
+ });
3974
+ const calcBoxPosition = () => {
3975
+ const columnWidth = uiService?.get("columnWidth");
3976
+ const navMenuRect = uiService?.get("navMenuRect");
3977
+ let left = columnWidth?.left ?? 0;
3978
+ if (parent?.value) {
3979
+ const rect = parent?.value?.getBoundingClientRect();
3980
+ left = (rect?.left ?? 0) + (rect?.width ?? 0);
3981
+ }
3982
+ boxPosition.value = {
3983
+ left,
3984
+ top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
3985
+ };
3986
+ };
3987
+ return {
3988
+ boxPosition,
3989
+ calcBoxPosition
3990
+ };
3991
+ };
3992
+
3993
+ const _hoisted_1$r = { class: "m-editor-data-source-fields" };
3994
+ const _hoisted_2$j = { class: "m-editor-data-source-fields-footer" };
3995
+ const _sfc_main$M = /* @__PURE__ */ vue.defineComponent({
4275
3996
  ...{
4276
3997
  name: "MFieldsDataSourceFields"
4277
3998
  },
@@ -4526,12 +4247,12 @@
4526
4247
  const parentFloating = vue.inject("parentFloating", vue.ref(null));
4527
4248
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4528
4249
  return (_ctx, _cache) => {
4529
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$p, [
4250
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$r, [
4530
4251
  vue.createVNode(vue.unref(table.MagicTable), {
4531
4252
  data: _ctx.model[_ctx.name],
4532
4253
  columns: fieldColumns
4533
4254
  }, null, 8, ["data"]),
4534
- vue.createElementVNode("div", _hoisted_2$i, [
4255
+ vue.createElementVNode("div", _hoisted_2$j, [
4535
4256
  vue.createVNode(vue.unref(design.TMagicButton), {
4536
4257
  size: "small",
4537
4258
  disabled: _ctx.disabled,
@@ -4556,7 +4277,7 @@
4556
4277
  _: 1
4557
4278
  }, 8, ["disabled"])
4558
4279
  ]),
4559
- vue.createVNode(_sfc_main$P, {
4280
+ vue.createVNode(_sfc_main$N, {
4560
4281
  visible: addDialogVisible.value,
4561
4282
  "onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
4562
4283
  width: width.value,
@@ -4579,7 +4300,7 @@
4579
4300
  ]),
4580
4301
  _: 1
4581
4302
  }, 8, ["visible", "width", "height", "title", "position"]),
4582
- vue.createVNode(_sfc_main$P, {
4303
+ vue.createVNode(_sfc_main$N, {
4583
4304
  visible: addFromJsonDialogVisible.value,
4584
4305
  "onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
4585
4306
  width: width.value,
@@ -4594,125 +4315,18 @@
4594
4315
  config: jsonFromConfig,
4595
4316
  values: jsonFromValues.value,
4596
4317
  disabled: _ctx.disabled,
4597
- onSubmit: addFromJsonFromChange
4598
- }, null, 8, ["values", "disabled"])
4599
- ]),
4600
- _: 1
4601
- }, 8, ["visible", "width", "height", "position"])
4602
- ]);
4603
- };
4604
- }
4605
- });
4606
-
4607
- const useDataSourceEdit = (dataSourceService) => {
4608
- const dialogTitle = vue.ref("");
4609
- const editDialog = vue.ref();
4610
- const dataSourceValues = vue.ref({});
4611
- const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
4612
- const editHandler = (id) => {
4613
- if (!editDialog.value)
4614
- return;
4615
- dataSourceValues.value = {
4616
- ...dataSourceService?.getDataSourceById(id)
4617
- };
4618
- dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
4619
- editDialog.value.show();
4620
- };
4621
- const submitDataSourceHandler = (value) => {
4622
- if (value.id) {
4623
- dataSourceService?.update(value);
4624
- } else {
4625
- dataSourceService?.add(value);
4626
- }
4627
- editDialog.value?.hide();
4628
- };
4629
- return {
4630
- dialogTitle,
4631
- editDialog,
4632
- dataSourceValues,
4633
- editable,
4634
- editHandler,
4635
- submitDataSourceHandler
4636
- };
4637
- };
4638
-
4639
- const _sfc_main$K = /* @__PURE__ */ vue.defineComponent({
4640
- ...{
4641
- name: "MEditorDataSourceConfigPanel"
4642
- },
4643
- __name: "DataSourceConfigPanel",
4644
- props: /* @__PURE__ */ vue.mergeModels({
4645
- title: {},
4646
- values: {},
4647
- disabled: { type: Boolean }
4648
- }, {
4649
- "visible": { type: Boolean, ...{ default: false } },
4650
- "visibleModifiers": {},
4651
- "width": { default: 670 },
4652
- "widthModifiers": {}
4653
- }),
4654
- emits: /* @__PURE__ */ vue.mergeModels(["submit"], ["update:visible", "update:width"]),
4655
- setup(__props, { expose: __expose, emit: __emit }) {
4656
- const props = __props;
4657
- const boxVisible = vue.useModel(__props, "visible");
4658
- const width = vue.useModel(__props, "width");
4659
- const emit = __emit;
4660
- const services = vue.inject("services");
4661
- const initValues = vue.ref({});
4662
- const dataSourceConfig = vue.ref([]);
4663
- const { height: editorHeight } = useEditorContentHeight();
4664
- const parentFloating = vue.inject("parentFloating", vue.ref(null));
4665
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4666
- vue.watchEffect(() => {
4667
- initValues.value = props.values;
4668
- dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
4669
- });
4670
- const submitHandler = (values) => {
4671
- emit("submit", values);
4672
- };
4673
- const errorHandler = (error) => {
4674
- design.tMagicMessage.error(error.message);
4675
- };
4676
- __expose({
4677
- show() {
4678
- calcBoxPosition();
4679
- boxVisible.value = true;
4680
- },
4681
- hide() {
4682
- boxVisible.value = false;
4683
- }
4684
- });
4685
- return (_ctx, _cache) => {
4686
- return vue.openBlock(), vue.createBlock(_sfc_main$P, {
4687
- visible: boxVisible.value,
4688
- "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
4689
- width: width.value,
4690
- "onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
4691
- height: vue.unref(editorHeight),
4692
- "onUpdate:height": _cache[2] || (_cache[2] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
4693
- title: _ctx.title,
4694
- position: vue.unref(boxPosition)
4695
- }, {
4696
- body: vue.withCtx(() => [
4697
- vue.createVNode(vue.unref(form.MFormBox), {
4698
- "label-width": "80px",
4699
- title: _ctx.title,
4700
- config: dataSourceConfig.value,
4701
- values: initValues.value,
4702
- disabled: _ctx.disabled,
4703
- style: { "height": "100%" },
4704
- onSubmit: submitHandler,
4705
- onError: errorHandler
4706
- }, null, 8, ["title", "config", "values", "disabled"])
4707
- ]),
4708
- _: 1
4709
- }, 8, ["visible", "width", "height", "title", "position"]);
4318
+ onSubmit: addFromJsonFromChange
4319
+ }, null, 8, ["values", "disabled"])
4320
+ ]),
4321
+ _: 1
4322
+ }, 8, ["visible", "width", "height", "position"])
4323
+ ]);
4710
4324
  };
4711
4325
  }
4712
4326
  });
4713
4327
 
4714
- const _hoisted_1$o = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
4715
- const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
4328
+ const _hoisted_1$q = { class: "m-fields-data-source-field-select" };
4329
+ const _sfc_main$L = /* @__PURE__ */ vue.defineComponent({
4716
4330
  ...{
4717
4331
  name: "MFieldsDataSourceFieldSelect"
4718
4332
  },
@@ -4731,8 +4345,13 @@
4731
4345
  emits: ["change"],
4732
4346
  setup(__props, { emit: __emit }) {
4733
4347
  const services = vue.inject("services");
4348
+ const eventBus = vue.inject("eventBus");
4734
4349
  const emit = __emit;
4735
4350
  const props = __props;
4351
+ const notEditable = vue.computed(() => form.filterFunction(mForm, props.config.notEditable, props));
4352
+ const hasDataSourceSidePanel = vue.computed(
4353
+ () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
4354
+ );
4736
4355
  const selectedDataSourceId = vue.computed(() => {
4737
4356
  const value = props.model[props.name];
4738
4357
  if (!Array.isArray(value) || !value.length) {
@@ -4824,11 +4443,11 @@
4824
4443
  const onChangeHandler = (value) => {
4825
4444
  emit("change", value);
4826
4445
  };
4827
- const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(
4828
- services?.dataSourceService
4829
- );
4446
+ const editHandler = (id) => {
4447
+ eventBus?.emit("edit-data-source", id);
4448
+ };
4830
4449
  return (_ctx, _cache) => {
4831
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$o, [
4450
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$q, [
4832
4451
  (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(tagName.value), {
4833
4452
  style: { "width": "100%" },
4834
4453
  config: showDataSourceFieldSelect.value || !_ctx.config.fieldConfig ? cascaderConfig.value : _ctx.config.fieldConfig,
@@ -4842,14 +4461,16 @@
4842
4461
  prop: `${_ctx.prop}${_ctx.prop ? "." : ""}${_ctx.name}`,
4843
4462
  onChange: onChangeHandler
4844
4463
  }, null, 40, ["config", "model", "name", "disabled", "size", "last-values", "init-values", "values", "prop"])),
4845
- (showDataSourceFieldSelect.value || !_ctx.config.fieldConfig) && selectedDataSourceId.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
4464
+ (showDataSourceFieldSelect.value || !_ctx.config.fieldConfig) && selectedDataSourceId.value && hasDataSourceSidePanel.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
4846
4465
  key: 0,
4847
- style: { "margin-left": "5px" },
4466
+ class: "m-fields-select-action-button",
4848
4467
  size: _ctx.size,
4849
- onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(editHandler)(selectedDataSourceId.value))
4468
+ onClick: _cache[0] || (_cache[0] = ($event) => editHandler(selectedDataSourceId.value))
4850
4469
  }, {
4851
4470
  default: vue.withCtx(() => [
4852
- vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Edit) }, null, 8, ["icon"])
4471
+ vue.createVNode(_sfc_main$U, {
4472
+ icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View)
4473
+ }, null, 8, ["icon"])
4853
4474
  ]),
4854
4475
  _: 1
4855
4476
  }, 8, ["size"])) : vue.createCommentVNode("", true),
@@ -4864,24 +4485,16 @@
4864
4485
  vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
4865
4486
  ]),
4866
4487
  _: 1
4867
- }, 8, ["type", "size"])) : vue.createCommentVNode("", true),
4868
- vue.createVNode(_sfc_main$K, {
4869
- ref_key: "editDialog",
4870
- ref: editDialog,
4871
- disabled: !vue.unref(editable),
4872
- values: vue.unref(dataSourceValues),
4873
- title: vue.unref(dialogTitle),
4874
- onSubmit: vue.unref(submitDataSourceHandler)
4875
- }, null, 8, ["disabled", "values", "title", "onSubmit"])
4488
+ }, 8, ["type", "size"])) : vue.createCommentVNode("", true)
4876
4489
  ]);
4877
4490
  };
4878
4491
  }
4879
4492
  });
4880
4493
 
4881
- const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4882
- const _hoisted_2$h = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4883
- const _hoisted_3$7 = { class: "el-input__inner t-input__inner" };
4884
- const _sfc_main$I = /* @__PURE__ */ vue.defineComponent({
4494
+ const _hoisted_1$p = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4495
+ const _hoisted_2$i = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4496
+ const _hoisted_3$8 = { class: "el-input__inner t-input__inner" };
4497
+ const _sfc_main$K = /* @__PURE__ */ vue.defineComponent({
4885
4498
  ...{
4886
4499
  name: "MFieldsDataSourceInput"
4887
4500
  },
@@ -4988,138 +4601,435 @@
4988
4601
  }
4989
4602
  }
4990
4603
  }
4991
- if (curCharIsDot(dotIndex)) {
4992
- result = fields || [];
4993
- } else if (dotIndex > -1) {
4994
- const queryName = queryString.substring(dotIndex + 1).toLowerCase();
4995
- result = fields.filter(
4996
- (field) => field.name?.toLowerCase().includes(queryName) || field.title?.toLowerCase().includes(queryName)
4997
- ) || [];
4998
- }
4999
- cb(
5000
- result.map((field) => ({
5001
- value: field.name,
5002
- text: field.title,
5003
- type: "field"
5004
- }))
5005
- );
4604
+ if (curCharIsDot(dotIndex)) {
4605
+ result = fields || [];
4606
+ } else if (dotIndex > -1) {
4607
+ const queryName = queryString.substring(dotIndex + 1).toLowerCase();
4608
+ result = fields.filter(
4609
+ (field) => field.name?.toLowerCase().includes(queryName) || field.title?.toLowerCase().includes(queryName)
4610
+ ) || [];
4611
+ }
4612
+ cb(
4613
+ result.map((field) => ({
4614
+ value: field.name,
4615
+ text: field.title,
4616
+ type: "field"
4617
+ }))
4618
+ );
4619
+ };
4620
+ const querySearch = (queryString, cb) => {
4621
+ inputText = queryString;
4622
+ const selectionStart = getSelectionStart();
4623
+ const curQueryString = queryString.substring(0, selectionStart);
4624
+ const fieldKeyStringLastIndex = curQueryString.lastIndexOf(".");
4625
+ const dsKeyStringLastIndex = curQueryString.lastIndexOf("${") + 1;
4626
+ const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
4627
+ if (isFieldTip) {
4628
+ fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
4629
+ } else {
4630
+ dsQuerySearch(curQueryString, dsKeyStringLastIndex, cb);
4631
+ }
4632
+ };
4633
+ const selectHandler = async ({ value, type }) => {
4634
+ const isDataSource = type === "dataSource";
4635
+ const selectionStart = input.value?.selectionStart || 0;
4636
+ let startText = inputText.substring(0, selectionStart);
4637
+ const dotIndex = startText.lastIndexOf(".");
4638
+ const leftCurlyBracketIndex = startText.lastIndexOf("${") + 1;
4639
+ const endText = inputText.substring(selectionStart);
4640
+ let suggestText = value;
4641
+ if (isDataSource) {
4642
+ if (!curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
4643
+ startText = startText.substring(0, leftCurlyBracketIndex + 1);
4644
+ }
4645
+ if (!isRightCurlyBracket(selectionStart + 1)) {
4646
+ suggestText = `${suggestText}}`;
4647
+ }
4648
+ } else if (!curCharIsDot(dotIndex)) {
4649
+ startText = startText.substring(0, dotIndex + 1);
4650
+ }
4651
+ state.value = `${startText}${suggestText}${endText}`;
4652
+ await vue.nextTick();
4653
+ let newSelectionStart = 0;
4654
+ if (isDataSource) {
4655
+ newSelectionStart = leftCurlyBracketIndex + suggestText.length;
4656
+ } else {
4657
+ newSelectionStart = dotIndex + suggestText.length + 1;
4658
+ }
4659
+ input.value?.setSelectionRange(newSelectionStart, newSelectionStart);
4660
+ changeHandler(state.value);
4661
+ };
4662
+ return (_ctx, _cache) => {
4663
+ return _ctx.disabled || isFocused.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(design.getConfig)("components")?.autocomplete.component || "el-autocomplete"), vue.mergeProps(
4664
+ {
4665
+ key: 0,
4666
+ class: "tmagic-design-auto-complete",
4667
+ ref_key: "autocomplete",
4668
+ ref: autocomplete,
4669
+ modelValue: state.value,
4670
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
4671
+ },
4672
+ vue.unref(design.getConfig)("components")?.autocomplete.props({
4673
+ disabled: _ctx.disabled,
4674
+ size: _ctx.size,
4675
+ fetchSuggestions: querySearch,
4676
+ triggerOnFocus: false,
4677
+ clearable: true
4678
+ }) || {},
4679
+ {
4680
+ style: { "width": "100%" },
4681
+ onBlur: blurHandler,
4682
+ onInput: inputHandler,
4683
+ onSelect: selectHandler
4684
+ }
4685
+ ), {
4686
+ suffix: vue.withCtx(() => [
4687
+ vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
4688
+ ]),
4689
+ default: vue.withCtx(({ item }) => [
4690
+ vue.createElementVNode("div", _hoisted_1$p, [
4691
+ vue.createElementVNode("div", null, vue.toDisplayString(item.text), 1),
4692
+ vue.createElementVNode("span", _hoisted_2$i, vue.toDisplayString(item.value), 1)
4693
+ ])
4694
+ ]),
4695
+ _: 1
4696
+ }, 16, ["modelValue"])) : (vue.openBlock(), vue.createElementBlock("div", {
4697
+ key: 1,
4698
+ class: vue.normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
4699
+ onMouseup: mouseupHandler
4700
+ }, [
4701
+ vue.createElementVNode("div", {
4702
+ class: vue.normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
4703
+ }, [
4704
+ vue.createElementVNode("div", _hoisted_3$8, [
4705
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(displayState.value, (item, index) => {
4706
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
4707
+ item.type === "text" ? (vue.openBlock(), vue.createElementBlock("span", {
4708
+ key: index,
4709
+ style: { "margin-right": "2px" }
4710
+ }, vue.toDisplayString(item.value), 1)) : vue.createCommentVNode("", true),
4711
+ item.type === "var" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTag), {
4712
+ key: index,
4713
+ size: _ctx.size
4714
+ }, {
4715
+ default: vue.withCtx(() => [
4716
+ vue.createTextVNode(vue.toDisplayString(item.value), 1)
4717
+ ]),
4718
+ _: 2
4719
+ }, 1032, ["size"])) : vue.createCommentVNode("", true)
4720
+ ], 64);
4721
+ }), 256)),
4722
+ vue.createVNode(_sfc_main$U, {
4723
+ class: "tmagic-data-source-input-icon",
4724
+ icon: vue.unref(iconsVue.Coin)
4725
+ }, null, 8, ["icon"])
4726
+ ])
4727
+ ], 2)
4728
+ ], 34));
4729
+ };
4730
+ }
4731
+ });
4732
+
4733
+ const _hoisted_1$o = { style: { "display": "flex", "margin-bottom": "10px" } };
4734
+ const _hoisted_2$h = { style: { "flex": "1" } };
4735
+ const _hoisted_3$7 = { style: { "flex": "1" } };
4736
+ const _hoisted_4$7 = { class: "dialog-footer" };
4737
+ const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
4738
+ ...{
4739
+ name: "MEditorCodeBlockEditor"
4740
+ },
4741
+ __name: "CodeBlockEditor",
4742
+ props: /* @__PURE__ */ vue.mergeModels({
4743
+ content: {},
4744
+ disabled: { type: Boolean },
4745
+ isDataSource: { type: Boolean },
4746
+ dataSourceType: {}
4747
+ }, {
4748
+ "width": { default: 670 },
4749
+ "widthModifiers": {},
4750
+ "visible": { type: Boolean, ...{ default: false } },
4751
+ "visibleModifiers": {}
4752
+ }),
4753
+ emits: /* @__PURE__ */ vue.mergeModels(["submit"], ["update:width", "update:visible"]),
4754
+ setup(__props, { expose: __expose, emit: __emit }) {
4755
+ const width = vue.useModel(__props, "width");
4756
+ const boxVisible = vue.useModel(__props, "visible");
4757
+ const props = __props;
4758
+ const emit = __emit;
4759
+ const services = vue.inject("services");
4760
+ const { height: codeBlockEditorHeight } = useEditorContentHeight();
4761
+ const difVisible = vue.ref(false);
4762
+ const { rect: windowRect } = useWindowRect();
4763
+ const magicVsEditor = vue.ref();
4764
+ const diffChange = () => {
4765
+ if (!magicVsEditor.value || !formBox.value?.form) {
4766
+ return;
4767
+ }
4768
+ formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
4769
+ difVisible.value = false;
4770
+ };
4771
+ const defaultParamColConfig = {
4772
+ type: "row",
4773
+ label: "参数类型",
4774
+ items: [
4775
+ {
4776
+ text: "参数类型",
4777
+ labelWidth: "70px",
4778
+ type: "select",
4779
+ name: "type",
4780
+ options: [
4781
+ {
4782
+ text: "数字",
4783
+ label: "数字",
4784
+ value: "number"
4785
+ },
4786
+ {
4787
+ text: "字符串",
4788
+ label: "字符串",
4789
+ value: "text"
4790
+ },
4791
+ {
4792
+ text: "组件",
4793
+ label: "组件",
4794
+ value: "ui-select"
4795
+ }
4796
+ ]
4797
+ }
4798
+ ]
4799
+ };
4800
+ const functionConfig = vue.computed(() => [
4801
+ {
4802
+ text: "名称",
4803
+ name: "name",
4804
+ rules: [{ required: true, message: "请输入名称", trigger: "blur" }]
4805
+ },
4806
+ {
4807
+ text: "描述",
4808
+ name: "desc"
4809
+ },
4810
+ {
4811
+ text: "执行时机",
4812
+ name: "timing",
4813
+ type: "select",
4814
+ options: () => {
4815
+ const options = [
4816
+ { text: "初始化前", value: "beforeInit" },
4817
+ { text: "初始化后", value: "afterInit" }
4818
+ ];
4819
+ if (props.dataSourceType !== "base") {
4820
+ options.push({ text: "请求前", value: "beforeRequest" });
4821
+ options.push({ text: "请求后", value: "afterRequest" });
4822
+ }
4823
+ return options;
4824
+ },
4825
+ display: () => props.isDataSource
4826
+ },
4827
+ {
4828
+ type: "table",
4829
+ border: true,
4830
+ text: "参数",
4831
+ enableFullscreen: false,
4832
+ enableToggleMode: false,
4833
+ name: "params",
4834
+ dropSort: false,
4835
+ items: [
4836
+ {
4837
+ type: "text",
4838
+ label: "参数名",
4839
+ name: "name"
4840
+ },
4841
+ {
4842
+ type: "text",
4843
+ label: "描述",
4844
+ name: "extra"
4845
+ },
4846
+ services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
4847
+ ]
4848
+ },
4849
+ {
4850
+ name: "content",
4851
+ type: "vs-code",
4852
+ options: vue.inject("codeOptions", {}),
4853
+ height: "500px",
4854
+ onChange: (formState, code) => {
4855
+ try {
4856
+ getConfig("parseDSL")(code);
4857
+ return code;
4858
+ } catch (error) {
4859
+ design.tMagicMessage.error(error.message);
4860
+ throw error;
4861
+ }
4862
+ }
4863
+ }
4864
+ ]);
4865
+ const submitForm = (values) => {
4866
+ changedValue.value = void 0;
4867
+ emit("submit", values);
5006
4868
  };
5007
- const querySearch = (queryString, cb) => {
5008
- inputText = queryString;
5009
- const selectionStart = getSelectionStart();
5010
- const curQueryString = queryString.substring(0, selectionStart);
5011
- const fieldKeyStringLastIndex = curQueryString.lastIndexOf(".");
5012
- const dsKeyStringLastIndex = curQueryString.lastIndexOf("${") + 1;
5013
- const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
5014
- if (isFieldTip) {
5015
- fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
5016
- } else {
5017
- dsQuerySearch(curQueryString, dsKeyStringLastIndex, cb);
5018
- }
4869
+ const errorHandler = (error) => {
4870
+ design.tMagicMessage.error(error.message);
5019
4871
  };
5020
- const selectHandler = async ({ value, type }) => {
5021
- const isDataSource = type === "dataSource";
5022
- const selectionStart = input.value?.selectionStart || 0;
5023
- let startText = inputText.substring(0, selectionStart);
5024
- const dotIndex = startText.lastIndexOf(".");
5025
- const leftCurlyBracketIndex = startText.lastIndexOf("${") + 1;
5026
- const endText = inputText.substring(selectionStart);
5027
- let suggestText = value;
5028
- if (isDataSource) {
5029
- if (!curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
5030
- startText = startText.substring(0, leftCurlyBracketIndex + 1);
5031
- }
5032
- if (!isRightCurlyBracket(selectionStart + 1)) {
5033
- suggestText = `${suggestText}}`;
5034
- }
5035
- } else if (!curCharIsDot(dotIndex)) {
5036
- startText = startText.substring(0, dotIndex + 1);
5037
- }
5038
- state.value = `${startText}${suggestText}${endText}`;
5039
- await vue.nextTick();
5040
- let newSelectionStart = 0;
5041
- if (isDataSource) {
5042
- newSelectionStart = leftCurlyBracketIndex + suggestText.length;
5043
- } else {
5044
- newSelectionStart = dotIndex + suggestText.length + 1;
4872
+ const formBox = vue.ref();
4873
+ const changedValue = vue.ref();
4874
+ const changeHandler = (values) => {
4875
+ changedValue.value = values;
4876
+ };
4877
+ const beforeClose = (done) => {
4878
+ if (!changedValue.value) {
4879
+ done();
4880
+ return;
5045
4881
  }
5046
- input.value?.setSelectionRange(newSelectionStart, newSelectionStart);
5047
- changeHandler(state.value);
4882
+ design.tMagicMessageBox.confirm("当前代码块已修改,是否保存?", "提示", {
4883
+ confirmButtonText: "保存并关闭",
4884
+ cancelButtonText: "不保存并关闭",
4885
+ type: "warning",
4886
+ distinguishCancelAndClose: true
4887
+ }).then(() => {
4888
+ changedValue.value && submitForm(changedValue.value);
4889
+ done();
4890
+ }).catch((action) => {
4891
+ done(action === "cancel");
4892
+ });
5048
4893
  };
4894
+ const closedHandler = () => {
4895
+ changedValue.value = void 0;
4896
+ };
4897
+ const parentFloating = vue.inject("parentFloating", vue.ref(null));
4898
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4899
+ __expose({
4900
+ async show() {
4901
+ calcBoxPosition();
4902
+ boxVisible.value = true;
4903
+ },
4904
+ async hide() {
4905
+ boxVisible.value = false;
4906
+ }
4907
+ });
5049
4908
  return (_ctx, _cache) => {
5050
- return _ctx.disabled || isFocused.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(design.getConfig)("components")?.autocomplete.component || "el-autocomplete"), vue.mergeProps(
5051
- {
5052
- key: 0,
5053
- class: "tmagic-design-auto-complete",
5054
- ref_key: "autocomplete",
5055
- ref: autocomplete,
5056
- modelValue: state.value,
5057
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
5058
- },
5059
- vue.unref(design.getConfig)("components")?.autocomplete.props({
5060
- disabled: _ctx.disabled,
5061
- size: _ctx.size,
5062
- fetchSuggestions: querySearch,
5063
- triggerOnFocus: false,
5064
- clearable: true
5065
- }) || {},
5066
- {
5067
- style: { "width": "100%" },
5068
- onBlur: blurHandler,
5069
- onInput: inputHandler,
5070
- onSelect: selectHandler
5071
- }
5072
- ), {
5073
- suffix: vue.withCtx(() => [
5074
- vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
5075
- ]),
5076
- default: vue.withCtx(({ item }) => [
5077
- vue.createElementVNode("div", _hoisted_1$n, [
5078
- vue.createElementVNode("div", null, vue.toDisplayString(item.text), 1),
5079
- vue.createElementVNode("span", _hoisted_2$h, vue.toDisplayString(item.value), 1)
5080
- ])
5081
- ]),
5082
- _: 1
5083
- }, 16, ["modelValue"])) : (vue.openBlock(), vue.createElementBlock("div", {
5084
- key: 1,
5085
- class: vue.normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
5086
- onMouseup: mouseupHandler
5087
- }, [
5088
- vue.createElementVNode("div", {
5089
- class: vue.normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
5090
- }, [
5091
- vue.createElementVNode("div", _hoisted_3$7, [
5092
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(displayState.value, (item, index) => {
5093
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
5094
- item.type === "text" ? (vue.openBlock(), vue.createElementBlock("span", {
5095
- key: index,
5096
- style: { "margin-right": "2px" }
5097
- }, vue.toDisplayString(item.value), 1)) : vue.createCommentVNode("", true),
5098
- item.type === "var" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTag), {
5099
- key: index,
5100
- size: _ctx.size
4909
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
4910
+ vue.createVNode(_sfc_main$N, {
4911
+ visible: boxVisible.value,
4912
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
4913
+ width: width.value,
4914
+ "onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
4915
+ height: vue.unref(codeBlockEditorHeight),
4916
+ "onUpdate:height": _cache[3] || (_cache[3] = ($event) => vue.isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
4917
+ title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
4918
+ position: vue.unref(boxPosition),
4919
+ "before-close": beforeClose
4920
+ }, {
4921
+ body: vue.withCtx(() => [
4922
+ vue.createVNode(vue.unref(form.MFormBox), {
4923
+ class: "m-editor-code-block-editor",
4924
+ ref_key: "formBox",
4925
+ ref: formBox,
4926
+ "label-width": "80px",
4927
+ "close-on-press-escape": false,
4928
+ title: _ctx.content.name,
4929
+ config: functionConfig.value,
4930
+ values: _ctx.content,
4931
+ disabled: _ctx.disabled,
4932
+ style: { "height": "100%" },
4933
+ onChange: changeHandler,
4934
+ onSubmit: submitForm,
4935
+ onError: errorHandler,
4936
+ onClosed: closedHandler
4937
+ }, {
4938
+ left: vue.withCtx(() => [
4939
+ !_ctx.disabled ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
4940
+ key: 0,
4941
+ type: "primary",
4942
+ link: "",
4943
+ onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
5101
4944
  }, {
5102
4945
  default: vue.withCtx(() => [
5103
- vue.createTextVNode(vue.toDisplayString(item.value), 1)
4946
+ vue.createTextVNode("查看修改")
5104
4947
  ]),
5105
- _: 2
5106
- }, 1032, ["size"])) : vue.createCommentVNode("", true)
5107
- ], 64);
5108
- }), 256)),
5109
- vue.createVNode(_sfc_main$U, {
5110
- class: "tmagic-data-source-input-icon",
5111
- icon: vue.unref(iconsVue.Coin)
5112
- }, null, 8, ["icon"])
5113
- ])
5114
- ], 2)
5115
- ], 34));
4948
+ _: 1
4949
+ })) : vue.createCommentVNode("", true)
4950
+ ]),
4951
+ _: 1
4952
+ }, 8, ["title", "config", "values", "disabled"])
4953
+ ]),
4954
+ _: 1
4955
+ }, 8, ["visible", "width", "height", "title", "position"]),
4956
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
4957
+ vue.createVNode(vue.unref(design.TMagicDialog), {
4958
+ title: "查看修改",
4959
+ modelValue: difVisible.value,
4960
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
4961
+ fullscreen: ""
4962
+ }, {
4963
+ footer: vue.withCtx(() => [
4964
+ vue.createElementVNode("span", _hoisted_4$7, [
4965
+ vue.createVNode(vue.unref(design.TMagicButton), {
4966
+ size: "small",
4967
+ onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
4968
+ }, {
4969
+ default: vue.withCtx(() => [
4970
+ vue.createTextVNode("取消")
4971
+ ]),
4972
+ _: 1
4973
+ }),
4974
+ vue.createVNode(vue.unref(design.TMagicButton), {
4975
+ size: "small",
4976
+ type: "primary",
4977
+ onClick: diffChange
4978
+ }, {
4979
+ default: vue.withCtx(() => [
4980
+ vue.createTextVNode("确定")
4981
+ ]),
4982
+ _: 1
4983
+ })
4984
+ ])
4985
+ ]),
4986
+ default: vue.withCtx(() => [
4987
+ vue.createElementVNode("div", _hoisted_1$o, [
4988
+ vue.createElementVNode("div", _hoisted_2$h, [
4989
+ vue.createVNode(vue.unref(design.TMagicTag), {
4990
+ size: "small",
4991
+ type: "info"
4992
+ }, {
4993
+ default: vue.withCtx(() => [
4994
+ vue.createTextVNode("修改前")
4995
+ ]),
4996
+ _: 1
4997
+ })
4998
+ ]),
4999
+ vue.createElementVNode("div", _hoisted_3$7, [
5000
+ vue.createVNode(vue.unref(design.TMagicTag), {
5001
+ size: "small",
5002
+ type: "success"
5003
+ }, {
5004
+ default: vue.withCtx(() => [
5005
+ vue.createTextVNode("修改后")
5006
+ ]),
5007
+ _: 1
5008
+ })
5009
+ ])
5010
+ ]),
5011
+ difVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
5012
+ key: 0,
5013
+ ref_key: "magicVsEditor",
5014
+ ref: magicVsEditor,
5015
+ type: "diff",
5016
+ language: "json",
5017
+ initValues: _ctx.content.content,
5018
+ modifiedValues: formBox.value?.form?.values.content,
5019
+ style: vue.normalizeStyle(`height: ${vue.unref(windowRect).height - 150}px`)
5020
+ }, null, 8, ["initValues", "modifiedValues", "style"])) : vue.createCommentVNode("", true)
5021
+ ]),
5022
+ _: 1
5023
+ }, 8, ["modelValue"])
5024
+ ]))
5025
+ ], 64);
5116
5026
  };
5117
5027
  }
5118
5028
  });
5119
5029
 
5120
- const _hoisted_1$m = { class: "m-editor-data-source-methods" };
5030
+ const _hoisted_1$n = { class: "m-editor-data-source-methods" };
5121
5031
  const _hoisted_2$g = { class: "m-editor-data-source-methods-footer" };
5122
- const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
5032
+ const _sfc_main$I = /* @__PURE__ */ vue.defineComponent({
5123
5033
  ...{
5124
5034
  name: "MFieldsDataSourceMethods"
5125
5035
  },
@@ -5189,7 +5099,7 @@
5189
5099
  emit("change", props.model[props.name]);
5190
5100
  };
5191
5101
  return (_ctx, _cache) => {
5192
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
5102
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$n, [
5193
5103
  vue.createVNode(vue.unref(table.MagicTable), {
5194
5104
  data: _ctx.model[_ctx.name],
5195
5105
  columns: methodColumns
@@ -5208,7 +5118,7 @@
5208
5118
  _: 1
5209
5119
  }, 8, ["disabled"])
5210
5120
  ]),
5211
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
5121
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$J, {
5212
5122
  key: 0,
5213
5123
  ref_key: "codeBlockEditor",
5214
5124
  ref: codeBlockEditor,
@@ -5223,9 +5133,9 @@
5223
5133
  }
5224
5134
  });
5225
5135
 
5226
- const _hoisted_1$l = { class: "m-fields-data-source-method-select" };
5136
+ const _hoisted_1$m = { class: "m-fields-data-source-method-select" };
5227
5137
  const _hoisted_2$f = { class: "data-source-method-select-container" };
5228
- const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
5138
+ const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
5229
5139
  ...{
5230
5140
  name: "MFieldsDataSourceMethodSelect"
5231
5141
  },
@@ -5245,9 +5155,13 @@
5245
5155
  setup(__props, { emit: __emit }) {
5246
5156
  const mForm = vue.inject("mForm");
5247
5157
  const services = vue.inject("services");
5158
+ const eventBus = vue.inject("eventBus");
5248
5159
  const emit = __emit;
5249
5160
  const dataSourceService = services?.dataSourceService;
5250
5161
  const props = __props;
5162
+ const hasDataSourceSidePanel = vue.computed(
5163
+ () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
5164
+ );
5251
5165
  const notEditable = vue.computed(() => form.filterFunction(mForm, props.config.notEditable, props));
5252
5166
  const dataSources = vue.computed(() => dataSourceService?.get("dataSources"));
5253
5167
  const isCustomMethod = vue.computed(() => {
@@ -5302,36 +5216,38 @@
5302
5216
  props.model.params = value.params;
5303
5217
  emit("change", props.model);
5304
5218
  };
5305
- const { codeBlockEditor, codeConfig, editCode, submitCode } = useDataSourceMethod();
5306
5219
  const editCodeHandler = () => {
5307
- const [id, name] = props.model[props.name];
5220
+ const [id] = props.model[props.name];
5308
5221
  const dataSource = dataSourceService?.getDataSourceById(id);
5309
5222
  if (!dataSource)
5310
5223
  return;
5311
- editCode(dataSource, name);
5312
- setParamsConfig([id, name]);
5313
- };
5314
- const submitCodeBlockHandler = (value) => {
5315
- submitCode(value);
5224
+ eventBus?.emit("edit-data-source", id);
5316
5225
  };
5317
5226
  return (_ctx, _cache) => {
5318
- const _component_m_form_container = vue.resolveComponent("m-form-container");
5319
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
5227
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
5320
5228
  vue.createElementVNode("div", _hoisted_2$f, [
5321
- vue.createVNode(_component_m_form_container, {
5229
+ vue.createVNode(vue.unref(form.MContainer), {
5322
5230
  class: "select",
5323
5231
  config: cascaderConfig.value,
5324
5232
  model: _ctx.model,
5233
+ size: _ctx.size,
5325
5234
  onChange: onChangeHandler
5326
- }, null, 8, ["config", "model"]),
5327
- _ctx.model[_ctx.name] && isCustomMethod.value ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
5235
+ }, null, 8, ["config", "model", "size"]),
5236
+ _ctx.model[_ctx.name] && isCustomMethod.value && hasDataSourceSidePanel.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5328
5237
  key: 0,
5329
- class: "icon",
5330
- icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
5238
+ class: "m-fields-select-action-button",
5239
+ size: _ctx.size,
5331
5240
  onClick: editCodeHandler
5332
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
5241
+ }, {
5242
+ default: vue.withCtx(() => [
5243
+ vue.createVNode(_sfc_main$U, {
5244
+ icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View)
5245
+ }, null, 8, ["icon"])
5246
+ ]),
5247
+ _: 1
5248
+ }, 8, ["size"])) : vue.createCommentVNode("", true)
5333
5249
  ]),
5334
- paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
5250
+ paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
5335
5251
  key: 0,
5336
5252
  name: "params",
5337
5253
  model: _ctx.model,
@@ -5339,23 +5255,15 @@
5339
5255
  disabled: _ctx.disabled,
5340
5256
  "params-config": paramsConfig.value,
5341
5257
  onChange: onChangeHandler
5342
- }, null, 8, ["model", "size", "disabled", "params-config"])) : vue.createCommentVNode("", true),
5343
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
5344
- key: 1,
5345
- ref_key: "codeBlockEditor",
5346
- ref: codeBlockEditor,
5347
- disabled: notEditable.value,
5348
- content: vue.unref(codeConfig),
5349
- onSubmit: submitCodeBlockHandler
5350
- }, null, 8, ["disabled", "content"])) : vue.createCommentVNode("", true)
5258
+ }, null, 8, ["model", "size", "disabled", "params-config"])) : vue.createCommentVNode("", true)
5351
5259
  ]);
5352
5260
  };
5353
5261
  }
5354
5262
  });
5355
5263
 
5356
- const _hoisted_1$k = { class: "m-editor-data-source-fields" };
5264
+ const _hoisted_1$l = { class: "m-editor-data-source-fields" };
5357
5265
  const _hoisted_2$e = { class: "m-editor-data-source-fields-footer" };
5358
- const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
5266
+ const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
5359
5267
  ...{
5360
5268
  name: "MFieldsDataSourceMocks"
5361
5269
  },
@@ -5561,7 +5469,7 @@
5561
5469
  const parentFloating = vue.inject("parentFloating", vue.ref(null));
5562
5470
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
5563
5471
  return (_ctx, _cache) => {
5564
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, [
5472
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
5565
5473
  vue.createVNode(vue.unref(table.MagicTable), {
5566
5474
  data: _ctx.model[_ctx.name],
5567
5475
  columns
@@ -5580,7 +5488,7 @@
5580
5488
  _: 1
5581
5489
  }, 8, ["disabled"])
5582
5490
  ]),
5583
- vue.createVNode(_sfc_main$P, {
5491
+ vue.createVNode(_sfc_main$N, {
5584
5492
  visible: addDialogVisible.value,
5585
5493
  "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
5586
5494
  width: width.value,
@@ -5608,7 +5516,8 @@
5608
5516
  }
5609
5517
  });
5610
5518
 
5611
- const _sfc_main$E = /* @__PURE__ */ vue.defineComponent({
5519
+ const _hoisted_1$k = { class: "m-fields-data-source-select" };
5520
+ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
5612
5521
  ...{
5613
5522
  name: "MFieldsDataSourceSelect"
5614
5523
  },
@@ -5628,8 +5537,14 @@
5628
5537
  setup(__props, { emit: __emit }) {
5629
5538
  const emit = __emit;
5630
5539
  const props = __props;
5631
- const { dataSourceService } = vue.inject("services") || {};
5540
+ const mForm = vue.inject("mForm");
5541
+ const { dataSourceService, uiService } = vue.inject("services") || {};
5542
+ const eventBus = vue.inject("eventBus");
5632
5543
  const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
5544
+ const notEditable = vue.computed(() => form.filterFunction(mForm, props.config.notEditable, props));
5545
+ const hasDataSourceSidePanel = vue.computed(
5546
+ () => (uiService?.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
5547
+ );
5633
5548
  const selectConfig = vue.computed(() => {
5634
5549
  const { type, dataSourceType, value, ...config } = props.config;
5635
5550
  const valueIsId = props.config.value === "id";
@@ -5650,17 +5565,42 @@
5650
5565
  const changeHandler = (value) => {
5651
5566
  emit("change", value);
5652
5567
  };
5568
+ const editHandler = () => {
5569
+ const value = props.model[props.name];
5570
+ if (!value)
5571
+ return;
5572
+ const id = typeof value === "string" ? value : value.dataSourceId;
5573
+ const dataSource = dataSourceService?.getDataSourceById(id);
5574
+ if (!dataSource)
5575
+ return;
5576
+ eventBus?.emit("edit-data-source", id);
5577
+ };
5653
5578
  return (_ctx, _cache) => {
5654
- return vue.openBlock(), vue.createBlock(vue.unref(form.MSelect), {
5655
- model: _ctx.model,
5656
- name: _ctx.name,
5657
- size: _ctx.size,
5658
- prop: _ctx.prop,
5659
- disabled: _ctx.disabled,
5660
- config: selectConfig.value,
5661
- "last-values": _ctx.lastValues,
5662
- onChange: changeHandler
5663
- }, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]);
5579
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, [
5580
+ vue.createVNode(vue.unref(form.MSelect), {
5581
+ model: _ctx.model,
5582
+ name: _ctx.name,
5583
+ size: _ctx.size,
5584
+ prop: _ctx.prop,
5585
+ disabled: _ctx.disabled,
5586
+ config: selectConfig.value,
5587
+ "last-values": _ctx.lastValues,
5588
+ onChange: changeHandler
5589
+ }, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]),
5590
+ _ctx.model[_ctx.name] && hasDataSourceSidePanel.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5591
+ key: 0,
5592
+ class: "m-fields-select-action-button",
5593
+ size: _ctx.size,
5594
+ onClick: editHandler
5595
+ }, {
5596
+ default: vue.withCtx(() => [
5597
+ vue.createVNode(_sfc_main$U, {
5598
+ icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View)
5599
+ }, null, 8, ["icon"])
5600
+ ]),
5601
+ _: 1
5602
+ }, 8, ["size"])) : vue.createCommentVNode("", true)
5603
+ ]);
5664
5604
  };
5665
5605
  }
5666
5606
  });
@@ -5670,7 +5610,7 @@
5670
5610
  key: 1,
5671
5611
  class: "fullWidth"
5672
5612
  };
5673
- const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
5613
+ const _sfc_main$E = /* @__PURE__ */ vue.defineComponent({
5674
5614
  ...{
5675
5615
  name: "MFieldsEventSelect"
5676
5616
  },
@@ -5828,6 +5768,7 @@
5828
5768
  ]
5829
5769
  }));
5830
5770
  const actionsConfig = vue.computed(() => ({
5771
+ type: "panel",
5831
5772
  items: [
5832
5773
  {
5833
5774
  type: "group-list",
@@ -5872,8 +5813,6 @@
5872
5813
  };
5873
5814
  return (_ctx, _cache) => {
5874
5815
  const _component_m_form_table = vue.resolveComponent("m-form-table");
5875
- const _component_m_form_container = vue.resolveComponent("m-form-container");
5876
- const _component_m_form_panel = vue.resolveComponent("m-form-panel");
5877
5816
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$j, [
5878
5817
  isOldVersion.value ? (vue.openBlock(), vue.createBlock(_component_m_form_table, {
5879
5818
  key: 0,
@@ -5898,7 +5837,7 @@
5898
5837
  _: 1
5899
5838
  }, 8, ["size", "disabled"]),
5900
5839
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.model[_ctx.name], (cardItem, index) => {
5901
- return vue.openBlock(), vue.createBlock(_component_m_form_panel, {
5840
+ return vue.openBlock(), vue.createBlock(vue.unref(form.MPanel), {
5902
5841
  key: index,
5903
5842
  disabled: _ctx.disabled,
5904
5843
  size: _ctx.size,
@@ -5908,7 +5847,7 @@
5908
5847
  onChange: onChangeHandler
5909
5848
  }, {
5910
5849
  header: vue.withCtx(() => [
5911
- vue.createVNode(_component_m_form_container, {
5850
+ vue.createVNode(vue.unref(form.MContainer), {
5912
5851
  class: "fullWidth",
5913
5852
  config: eventNameConfig.value,
5914
5853
  model: cardItem,
@@ -5944,7 +5883,7 @@
5944
5883
  const _hoisted_4$6 = [
5945
5884
  _hoisted_2$c
5946
5885
  ];
5947
- const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
5886
+ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
5948
5887
  ...{
5949
5888
  name: "MEditorCodeIcon"
5950
5889
  },
@@ -5959,7 +5898,7 @@
5959
5898
  const _hoisted_1$h = { class: "m-fields-key-value" };
5960
5899
  const _hoisted_2$b = { key: 0 };
5961
5900
  const _hoisted_3$6 = /* @__PURE__ */ vue.createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
5962
- const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
5901
+ const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
5963
5902
  ...{
5964
5903
  name: "MFieldsKeyValue"
5965
5904
  },
@@ -6083,7 +6022,7 @@
6083
6022
  size: "default",
6084
6023
  disabled: _ctx.disabled,
6085
6024
  link: "",
6086
- icon: _sfc_main$C,
6025
+ icon: _sfc_main$D,
6087
6026
  onClick: _cache[0] || (_cache[0] = ($event) => showCode.value = !showCode.value)
6088
6027
  }, null, 8, ["disabled"])) : vue.createCommentVNode("", true)
6089
6028
  ]);
@@ -6093,7 +6032,7 @@
6093
6032
 
6094
6033
  const _hoisted_1$g = { class: "m-fields-page-fragment-select" };
6095
6034
  const _hoisted_2$a = { class: "page-fragment-select-container" };
6096
- const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
6035
+ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
6097
6036
  ...{
6098
6037
  name: "MFieldsPageFragmentSelect"
6099
6038
  },
@@ -6165,7 +6104,7 @@
6165
6104
  class: "m-fields-ui-select",
6166
6105
  style: { "display": "flex" }
6167
6106
  };
6168
- const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
6107
+ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
6169
6108
  ...{
6170
6109
  name: "MFieldsUISelect"
6171
6110
  },
@@ -6353,7 +6292,7 @@
6353
6292
  };
6354
6293
  };
6355
6294
 
6356
- const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
6295
+ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
6357
6296
  ...{
6358
6297
  name: "MEditorResizer"
6359
6298
  },
@@ -6375,7 +6314,7 @@
6375
6314
  }
6376
6315
  });
6377
6316
 
6378
- const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
6317
+ const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
6379
6318
  ...{
6380
6319
  name: "MEditorSplitView"
6381
6320
  },
@@ -6516,7 +6455,7 @@
6516
6455
  }, [
6517
6456
  vue.renderSlot(_ctx.$slots, "left")
6518
6457
  ], 6),
6519
- vue.createVNode(_sfc_main$y, { onChange: changeLeft })
6458
+ vue.createVNode(_sfc_main$z, { onChange: changeLeft })
6520
6459
  ], 64)) : vue.createCommentVNode("", true),
6521
6460
  vue.createElementVNode("div", {
6522
6461
  class: vue.normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
@@ -6525,7 +6464,7 @@
6525
6464
  vue.renderSlot(_ctx.$slots, "center")
6526
6465
  ], 6),
6527
6466
  hasRight.value && _ctx.$slots.right ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
6528
- vue.createVNode(_sfc_main$y, { onChange: changeRight }),
6467
+ vue.createVNode(_sfc_main$z, { onChange: changeRight }),
6529
6468
  vue.createElementVNode("div", {
6530
6469
  class: vue.normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
6531
6470
  style: vue.normalizeStyle(`width: ${_ctx.right}px`)
@@ -6543,7 +6482,7 @@
6543
6482
  class: "menu-item-text"
6544
6483
  };
6545
6484
  const _hoisted_2$9 = { class: "el-dropdown-link menubar-menu-button" };
6546
- const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
6485
+ const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
6547
6486
  ...{
6548
6487
  name: "MEditorToolButton"
6549
6488
  },
@@ -6708,7 +6647,7 @@
6708
6647
  key: 1,
6709
6648
  style: { "width": "21px" }
6710
6649
  };
6711
- const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
6650
+ const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
6712
6651
  ...{
6713
6652
  name: "MEditorPageBarAddButton"
6714
6653
  },
@@ -6748,7 +6687,7 @@
6748
6687
  }
6749
6688
  });
6750
6689
 
6751
- const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
6690
+ const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
6752
6691
  ...{
6753
6692
  name: "MEditorPageBarScrollContainer"
6754
6693
  },
@@ -6877,7 +6816,7 @@
6877
6816
  }
6878
6817
  });
6879
6818
 
6880
- const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
6819
+ const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
6881
6820
  ...{
6882
6821
  name: "MEditorPageBarSwitchTypeButton"
6883
6822
  },
@@ -6925,7 +6864,7 @@
6925
6864
  const _hoisted_2$8 = ["onClick"];
6926
6865
  const _hoisted_3$5 = { class: "m-editor-page-bar-title" };
6927
6866
  const _hoisted_4$5 = ["title"];
6928
- const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
6867
+ const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
6929
6868
  ...{
6930
6869
  name: "MEditorPageBar"
6931
6870
  },
@@ -7004,14 +6943,14 @@
7004
6943
  };
7005
6944
  return (_ctx, _cache) => {
7006
6945
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
7007
- !_ctx.disabledPageFragment ? (vue.openBlock(), vue.createBlock(_sfc_main$t, {
6946
+ !_ctx.disabledPageFragment ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
7008
6947
  key: 0,
7009
6948
  modelValue: active.value,
7010
6949
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => active.value = $event)
7011
6950
  }, null, 8, ["modelValue"])) : vue.createCommentVNode("", true),
7012
- vue.createVNode(_sfc_main$u, { type: active.value }, {
6951
+ vue.createVNode(_sfc_main$v, { type: active.value }, {
7013
6952
  prepend: vue.withCtx(() => [
7014
- vue.createVNode(_sfc_main$v, { type: active.value }, null, 8, ["type"])
6953
+ vue.createVNode(_sfc_main$w, { type: active.value }, null, 8, ["type"])
7015
6954
  ]),
7016
6955
  default: vue.withCtx(() => [
7017
6956
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.value, (item) => {
@@ -7044,7 +6983,7 @@
7044
6983
  default: vue.withCtx(() => [
7045
6984
  vue.createElementVNode("div", null, [
7046
6985
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
7047
- vue.createVNode(_sfc_main$w, {
6986
+ vue.createVNode(_sfc_main$x, {
7048
6987
  data: {
7049
6988
  type: "button",
7050
6989
  text: "复制",
@@ -7052,7 +6991,7 @@
7052
6991
  handler: () => copy(item)
7053
6992
  }
7054
6993
  }, null, 8, ["data"]),
7055
- vue.createVNode(_sfc_main$w, {
6994
+ vue.createVNode(_sfc_main$x, {
7056
6995
  data: {
7057
6996
  type: "button",
7058
6997
  text: "删除",
@@ -7079,7 +7018,7 @@
7079
7018
  const _hoisted_2$7 = { class: "m-editor-empty-content" };
7080
7019
  const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "新增页面", -1);
7081
7020
  const _hoisted_4$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "新增页面片", -1);
7082
- const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
7021
+ const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
7083
7022
  ...{
7084
7023
  name: "MEditorAddPageBox"
7085
7024
  },
@@ -7134,7 +7073,7 @@
7134
7073
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
7135
7074
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
7136
7075
  const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
7137
- const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
7076
+ const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
7138
7077
  ...{
7139
7078
  name: "MEditorFramework"
7140
7079
  },
@@ -7218,7 +7157,7 @@
7218
7157
  options: vue.unref(codeOptions),
7219
7158
  onSave: saveCode
7220
7159
  }, null, 8, ["init-values", "options"])
7221
- ]) : vue.withDirectives((vue.openBlock(), vue.createBlock(_sfc_main$x, {
7160
+ ]) : vue.withDirectives((vue.openBlock(), vue.createBlock(_sfc_main$y, {
7222
7161
  key: 1,
7223
7162
  "element-loading-text": "Runtime 加载中...",
7224
7163
  ref_key: "splitView",
@@ -7242,10 +7181,10 @@
7242
7181
  ]),
7243
7182
  center: vue.withCtx(() => [
7244
7183
  page.value ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
7245
- vue.createVNode(_sfc_main$r, { "disabled-page-fragment": _ctx.disabledPageFragment }, null, 8, ["disabled-page-fragment"])
7184
+ vue.createVNode(_sfc_main$s, { "disabled-page-fragment": _ctx.disabledPageFragment }, null, 8, ["disabled-page-fragment"])
7246
7185
  ]),
7247
7186
  vue.renderSlot(_ctx.$slots, "page-bar", {}, () => [
7248
- vue.createVNode(_sfc_main$s, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
7187
+ vue.createVNode(_sfc_main$t, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
7249
7188
  "page-bar-title": vue.withCtx(({ page: page2 }) => [
7250
7189
  vue.renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
7251
7190
  ]),
@@ -7280,7 +7219,7 @@
7280
7219
  }
7281
7220
  });
7282
7221
 
7283
- const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
7222
+ const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
7284
7223
  ...{
7285
7224
  name: "MEditorNavMenu"
7286
7225
  },
@@ -7462,7 +7401,7 @@
7462
7401
  style: vue.normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
7463
7402
  }, [
7464
7403
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(buttons.value[key], (item, index) => {
7465
- return vue.openBlock(), vue.createBlock(_sfc_main$w, {
7404
+ return vue.openBlock(), vue.createBlock(_sfc_main$x, {
7466
7405
  data: item,
7467
7406
  key: index
7468
7407
  }, null, 8, ["data"]);
@@ -7475,12 +7414,13 @@
7475
7414
  });
7476
7415
 
7477
7416
  const _hoisted_1$a = { class: "m-editor-props-panel" };
7478
- const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
7417
+ const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
7479
7418
  ...{
7480
7419
  name: "MEditorPropsPanel"
7481
7420
  },
7482
7421
  __name: "PropsPanel",
7483
7422
  props: {
7423
+ disabledShowSrc: { type: Boolean },
7484
7424
  extendState: { type: Function }
7485
7425
  },
7486
7426
  emits: ["mounted", "submit-error", "form-error"],
@@ -7541,7 +7481,7 @@
7541
7481
  vue.createVNode(vue.unref(form.MForm), {
7542
7482
  ref_key: "configForm",
7543
7483
  ref: configForm,
7544
- class: vue.normalizeClass(`m-editor-props-panel ${propsPanelSize.value}`),
7484
+ class: vue.normalizeClass(propsPanelSize.value),
7545
7485
  "popper-class": `m-editor-props-panel-popper ${propsPanelSize.value}`,
7546
7486
  size: propsPanelSize.value,
7547
7487
  "init-values": values.value,
@@ -7550,7 +7490,8 @@
7550
7490
  onChange: submit,
7551
7491
  onError: errorHandler
7552
7492
  }, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"]),
7553
- vue.createVNode(vue.unref(design.TMagicButton), {
7493
+ !_ctx.disabledShowSrc ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
7494
+ key: 0,
7554
7495
  class: "m-editor-props-panel-src-icon",
7555
7496
  circle: "",
7556
7497
  size: "large",
@@ -7562,9 +7503,9 @@
7562
7503
  vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Document) }, null, 8, ["icon"])
7563
7504
  ]),
7564
7505
  _: 1
7565
- }, 8, ["type"]),
7506
+ }, 8, ["type"])) : vue.createCommentVNode("", true),
7566
7507
  showSrc.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
7567
- key: 0,
7508
+ key: 1,
7568
7509
  height: `${vue.unref(editorContentHeight)}px`,
7569
7510
  "init-values": values.value,
7570
7511
  options: vue.unref(codeOptions),
@@ -7578,7 +7519,7 @@
7578
7519
  }
7579
7520
  });
7580
7521
 
7581
- const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
7522
+ const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
7582
7523
  ...{
7583
7524
  name: "MEditorSearchInput"
7584
7525
  },
@@ -7636,7 +7577,7 @@
7636
7577
  key: 0,
7637
7578
  class: "m-editor-tree-node-children"
7638
7579
  };
7639
- const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
7580
+ const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
7640
7581
  ...{
7641
7582
  name: "MEditorTreeNode"
7642
7583
  },
@@ -7757,7 +7698,7 @@
7757
7698
  key: 1,
7758
7699
  class: "m-editor-tree-empty"
7759
7700
  };
7760
- const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
7701
+ const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
7761
7702
  ...{
7762
7703
  name: "MEditorTree"
7763
7704
  },
@@ -7781,7 +7722,7 @@
7781
7722
  onDragover: handleDragOver
7782
7723
  }, [
7783
7724
  _ctx.data?.length ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(_ctx.data, (item) => {
7784
- return vue.openBlock(), vue.createBlock(_sfc_main$m, {
7725
+ return vue.openBlock(), vue.createBlock(_sfc_main$n, {
7785
7726
  key: item.id,
7786
7727
  data: item,
7787
7728
  indent: _ctx.indent,
@@ -7878,7 +7819,7 @@
7878
7819
  };
7879
7820
  };
7880
7821
 
7881
- const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
7822
+ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
7882
7823
  ...{
7883
7824
  name: "MEditorCodeBlockList"
7884
7825
  },
@@ -7960,7 +7901,7 @@
7960
7901
  filter: filterTextChangeHandler
7961
7902
  });
7962
7903
  return (_ctx, _cache) => {
7963
- return vue.openBlock(), vue.createBlock(_sfc_main$l, {
7904
+ return vue.openBlock(), vue.createBlock(_sfc_main$m, {
7964
7905
  data: codeList.value,
7965
7906
  "node-status-map": vue.unref(nodeStatusMap),
7966
7907
  onNodeClick: clickHandler
@@ -8017,7 +7958,7 @@
8017
7958
  });
8018
7959
 
8019
7960
  const _hoisted_1$7 = { class: "search-wrapper" };
8020
- const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
7961
+ const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
8021
7962
  ...{
8022
7963
  name: "MEditorCodeBlockListPanel"
8023
7964
  },
@@ -8026,6 +7967,7 @@
8026
7967
  customError: { type: Function }
8027
7968
  },
8028
7969
  setup(__props) {
7970
+ const eventBus = vue.inject("eventBus");
8029
7971
  const { codeBlockService } = vue.inject("services") || {};
8030
7972
  const editable = vue.computed(() => codeBlockService?.getEditStatus());
8031
7973
  const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
@@ -8033,13 +7975,16 @@
8033
7975
  const filterTextChangeHandler = (val) => {
8034
7976
  codeBlockList.value?.filter(val);
8035
7977
  };
7978
+ eventBus?.on("edit-code", (id) => {
7979
+ editCode(id);
7980
+ });
8036
7981
  return (_ctx, _cache) => {
8037
7982
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
8038
7983
  vue.createVNode(vue.unref(design.TMagicScrollbar), { class: "m-editor-code-block-list m-editor-layer-panel" }, {
8039
7984
  default: vue.withCtx(() => [
8040
7985
  vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
8041
7986
  vue.createElementVNode("div", _hoisted_1$7, [
8042
- vue.createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
7987
+ vue.createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
8043
7988
  editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
8044
7989
  key: 0,
8045
7990
  class: "create-code-button",
@@ -8055,7 +8000,7 @@
8055
8000
  vue.renderSlot(_ctx.$slots, "code-block-panel-search")
8056
8001
  ])
8057
8002
  ]),
8058
- vue.createVNode(_sfc_main$k, {
8003
+ vue.createVNode(_sfc_main$l, {
8059
8004
  ref_key: "codeBlockList",
8060
8005
  ref: codeBlockList,
8061
8006
  "custom-error": _ctx.customError,
@@ -8073,7 +8018,7 @@
8073
8018
  ]),
8074
8019
  _: 3
8075
8020
  }),
8076
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
8021
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$J, {
8077
8022
  key: 0,
8078
8023
  ref_key: "codeBlockEditor",
8079
8024
  ref: codeBlockEditor,
@@ -8086,6 +8031,113 @@
8086
8031
  }
8087
8032
  });
8088
8033
 
8034
+ const useDataSourceEdit = (dataSourceService) => {
8035
+ const dialogTitle = vue.ref("");
8036
+ const editDialog = vue.ref();
8037
+ const dataSourceValues = vue.ref({});
8038
+ const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
8039
+ const editHandler = (id) => {
8040
+ if (!editDialog.value)
8041
+ return;
8042
+ dataSourceValues.value = {
8043
+ ...dataSourceService?.getDataSourceById(id)
8044
+ };
8045
+ dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
8046
+ editDialog.value.show();
8047
+ };
8048
+ const submitDataSourceHandler = (value) => {
8049
+ if (value.id) {
8050
+ dataSourceService?.update(value);
8051
+ } else {
8052
+ dataSourceService?.add(value);
8053
+ }
8054
+ editDialog.value?.hide();
8055
+ };
8056
+ return {
8057
+ dialogTitle,
8058
+ editDialog,
8059
+ dataSourceValues,
8060
+ editable,
8061
+ editHandler,
8062
+ submitDataSourceHandler
8063
+ };
8064
+ };
8065
+
8066
+ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
8067
+ ...{
8068
+ name: "MEditorDataSourceConfigPanel"
8069
+ },
8070
+ __name: "DataSourceConfigPanel",
8071
+ props: /* @__PURE__ */ vue.mergeModels({
8072
+ title: {},
8073
+ values: {},
8074
+ disabled: { type: Boolean }
8075
+ }, {
8076
+ "visible": { type: Boolean, ...{ default: false } },
8077
+ "visibleModifiers": {},
8078
+ "width": { default: 670 },
8079
+ "widthModifiers": {}
8080
+ }),
8081
+ emits: /* @__PURE__ */ vue.mergeModels(["submit"], ["update:visible", "update:width"]),
8082
+ setup(__props, { expose: __expose, emit: __emit }) {
8083
+ const props = __props;
8084
+ const boxVisible = vue.useModel(__props, "visible");
8085
+ const width = vue.useModel(__props, "width");
8086
+ const emit = __emit;
8087
+ const services = vue.inject("services");
8088
+ const initValues = vue.ref({});
8089
+ const dataSourceConfig = vue.ref([]);
8090
+ const { height: editorHeight } = useEditorContentHeight();
8091
+ const parentFloating = vue.inject("parentFloating", vue.ref(null));
8092
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
8093
+ vue.watchEffect(() => {
8094
+ initValues.value = props.values;
8095
+ dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
8096
+ });
8097
+ const submitHandler = (values) => {
8098
+ emit("submit", values);
8099
+ };
8100
+ const errorHandler = (error) => {
8101
+ design.tMagicMessage.error(error.message);
8102
+ };
8103
+ __expose({
8104
+ show() {
8105
+ calcBoxPosition();
8106
+ boxVisible.value = true;
8107
+ },
8108
+ hide() {
8109
+ boxVisible.value = false;
8110
+ }
8111
+ });
8112
+ return (_ctx, _cache) => {
8113
+ return vue.openBlock(), vue.createBlock(_sfc_main$N, {
8114
+ visible: boxVisible.value,
8115
+ "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
8116
+ width: width.value,
8117
+ "onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
8118
+ height: vue.unref(editorHeight),
8119
+ "onUpdate:height": _cache[2] || (_cache[2] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
8120
+ title: _ctx.title,
8121
+ position: vue.unref(boxPosition)
8122
+ }, {
8123
+ body: vue.withCtx(() => [
8124
+ vue.createVNode(vue.unref(form.MFormBox), {
8125
+ "label-width": "80px",
8126
+ title: _ctx.title,
8127
+ config: dataSourceConfig.value,
8128
+ values: initValues.value,
8129
+ disabled: _ctx.disabled,
8130
+ style: { "height": "100%" },
8131
+ onSubmit: submitHandler,
8132
+ onError: errorHandler
8133
+ }, null, 8, ["title", "config", "values", "disabled"])
8134
+ ]),
8135
+ _: 1
8136
+ }, 8, ["visible", "width", "height", "title", "position"]);
8137
+ };
8138
+ }
8139
+ });
8140
+
8089
8141
  const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
8090
8142
  ...{
8091
8143
  name: "MEditorDataSourceList"
@@ -8175,7 +8227,7 @@
8175
8227
  filter: filterTextChangeHandler
8176
8228
  });
8177
8229
  return (_ctx, _cache) => {
8178
- return vue.openBlock(), vue.createBlock(_sfc_main$l, {
8230
+ return vue.openBlock(), vue.createBlock(_sfc_main$m, {
8179
8231
  data: list.value,
8180
8232
  "node-status-map": vue.unref(nodeStatusMap),
8181
8233
  onNodeClick: clickHandler
@@ -8236,6 +8288,7 @@
8236
8288
  },
8237
8289
  __name: "DataSourceListPanel",
8238
8290
  setup(__props) {
8291
+ const eventBus = vue.inject("eventBus");
8239
8292
  const { dataSourceService } = vue.inject("services") || {};
8240
8293
  const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
8241
8294
  const datasourceTypeList = vue.computed(
@@ -8267,12 +8320,15 @@
8267
8320
  const filterTextChangeHandler = (val) => {
8268
8321
  dataSourceList.value?.filter(val);
8269
8322
  };
8323
+ eventBus?.on("edit-data-source", (id) => {
8324
+ editHandler(id);
8325
+ });
8270
8326
  return (_ctx, _cache) => {
8271
8327
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
8272
8328
  vue.createVNode(vue.unref(design.TMagicScrollbar), { class: "data-source-list-panel m-editor-layer-panel" }, {
8273
8329
  default: vue.withCtx(() => [
8274
8330
  vue.createElementVNode("div", _hoisted_1$6, [
8275
- vue.createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
8331
+ vue.createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
8276
8332
  vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicPopover), {
8277
8333
  key: 0,
8278
8334
  placement: "right"
@@ -8291,7 +8347,7 @@
8291
8347
  default: vue.withCtx(() => [
8292
8348
  vue.createElementVNode("div", _hoisted_2$5, [
8293
8349
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(datasourceTypeList.value, (item, index) => {
8294
- return vue.openBlock(), vue.createBlock(_sfc_main$w, {
8350
+ return vue.openBlock(), vue.createBlock(_sfc_main$x, {
8295
8351
  data: {
8296
8352
  type: "button",
8297
8353
  text: item.text,
@@ -8317,7 +8373,7 @@
8317
8373
  ]),
8318
8374
  _: 3
8319
8375
  }),
8320
- vue.createVNode(_sfc_main$K, {
8376
+ vue.createVNode(_sfc_main$j, {
8321
8377
  ref_key: "editDialog",
8322
8378
  ref: editDialog,
8323
8379
  disabled: !vue.unref(editable),
@@ -8461,7 +8517,7 @@
8461
8517
  vue.renderSlot(_ctx.$slots, "title"),
8462
8518
  vue.createElementVNode("div", null, [
8463
8519
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
8464
- return vue.openBlock(), vue.createBlock(_sfc_main$w, {
8520
+ return vue.openBlock(), vue.createBlock(_sfc_main$x, {
8465
8521
  "event-type": "mouseup",
8466
8522
  ref_for: true,
8467
8523
  ref_key: "buttons",
@@ -9237,8 +9293,8 @@
9237
9293
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "m-editor-layer-panel" }, {
9238
9294
  default: vue.withCtx(() => [
9239
9295
  vue.renderSlot(_ctx.$slots, "layer-panel-header"),
9240
- vue.createVNode(_sfc_main$n, { onSearch: vue.unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
9241
- page.value && vue.unref(nodeStatusMap) ? (vue.openBlock(), vue.createBlock(_sfc_main$l, {
9296
+ vue.createVNode(_sfc_main$o, { onSearch: vue.unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
9297
+ page.value && vue.unref(nodeStatusMap) ? (vue.openBlock(), vue.createBlock(_sfc_main$m, {
9242
9298
  key: 0,
9243
9299
  tabindex: "-1",
9244
9300
  ref_key: "tree",
@@ -9364,7 +9420,7 @@
9364
9420
  "model-value": collapseValue.value
9365
9421
  }, {
9366
9422
  default: vue.withCtx(() => [
9367
- vue.createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
9423
+ vue.createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
9368
9424
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.value, (group, index) => {
9369
9425
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
9370
9426
  group.items && group.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCollapseItem), {
@@ -9437,7 +9493,11 @@
9437
9493
  },
9438
9494
  __name: "Sidebar",
9439
9495
  props: {
9440
- data: { default: () => ({ type: "tabs", status: "组件", items: ["component-list", "layer", "code-block", "data-source"] }) },
9496
+ data: { default: () => ({
9497
+ type: "tabs",
9498
+ status: "组件",
9499
+ items: [SideItemKey.COMPONENT_LIST, SideItemKey.LAYER, SideItemKey.CODE_BLOCK, SideItemKey.DATA_SOURCE]
9500
+ }) },
9441
9501
  layerContentMenu: {},
9442
9502
  customContentMenu: {}
9443
9503
  },
@@ -9449,8 +9509,8 @@
9449
9509
  const activeTabName = vue.ref(props.data?.status);
9450
9510
  const getItemConfig = (data) => {
9451
9511
  const map = {
9452
- "component-list": {
9453
- $key: "component-list",
9512
+ [SideItemKey.COMPONENT_LIST]: {
9513
+ $key: SideItemKey.COMPONENT_LIST,
9454
9514
  type: "component",
9455
9515
  icon: iconsVue.Goods,
9456
9516
  text: "组件",
@@ -9469,16 +9529,16 @@
9469
9529
  component: _sfc_main$c,
9470
9530
  slots: {}
9471
9531
  },
9472
- "code-block": {
9532
+ [SideItemKey.CODE_BLOCK]: {
9473
9533
  $key: "code-block",
9474
9534
  type: "component",
9475
9535
  icon: iconsVue.EditPen,
9476
9536
  text: "代码编辑",
9477
- component: _sfc_main$j,
9537
+ component: _sfc_main$k,
9478
9538
  slots: {}
9479
9539
  },
9480
- "data-source": {
9481
- $key: "data-source",
9540
+ [SideItemKey.DATA_SOURCE]: {
9541
+ $key: SideItemKey.DATA_SOURCE,
9482
9542
  type: "component",
9483
9543
  icon: iconsVue.Coin,
9484
9544
  text: "数据源",
@@ -9489,6 +9549,15 @@
9489
9549
  return typeof data === "string" ? map[data] : data;
9490
9550
  };
9491
9551
  const sideBarItems = vue.computed(() => props.data.items.map((item) => getItemConfig(item)));
9552
+ vue.watch(
9553
+ sideBarItems,
9554
+ (items) => {
9555
+ services?.uiService.set("sideBarItems", items);
9556
+ },
9557
+ {
9558
+ immediate: true
9559
+ }
9560
+ );
9492
9561
  vue.watch(
9493
9562
  () => props.data.status,
9494
9563
  (status) => {
@@ -9527,7 +9596,8 @@
9527
9596
  class: vue.normalizeClass(["m-editor-sidebar-header-item", { "is-active": activeTabName.value === config.text }]),
9528
9597
  draggable: "true",
9529
9598
  key: config.$key ?? index,
9530
- onClick: ($event) => activeTabName.value = config.text || `${index}`,
9599
+ style: vue.normalizeStyle(config.tabStyle || {}),
9600
+ onClick: ($event) => activeTabName.value = config.text || config.$key || `${index}`,
9531
9601
  onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
9532
9602
  (...args) => vue.unref(dragstartHandler) && vue.unref(dragstartHandler)(...args)),
9533
9603
  onDragend: ($event) => vue.unref(dragendHandler)(config.$key, $event)
@@ -9537,7 +9607,7 @@
9537
9607
  icon: config.icon
9538
9608
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
9539
9609
  config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$1, vue.toDisplayString(config.text), 1)) : vue.createCommentVNode("", true)
9540
- ], 42, _hoisted_3$1)), [
9610
+ ], 46, _hoisted_3$1)), [
9541
9611
  [vue.vShow, !vue.unref(floatBoxStates)[config.$key]?.status]
9542
9612
  ]);
9543
9613
  }), 128))
@@ -9658,14 +9728,14 @@
9658
9728
  } : void 0
9659
9729
  ]), 1040)) : vue.createCommentVNode("", true)
9660
9730
  ])), [
9661
- [vue.vShow, activeTabName.value === config.text]
9731
+ [vue.vShow, [config.text, config.$key, `${index}`].includes(activeTabName.value)]
9662
9732
  ]);
9663
9733
  }), 128))
9664
9734
  ])) : vue.createCommentVNode("", true),
9665
9735
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
9666
9736
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
9667
9737
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
9668
- vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
9738
+ vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
9669
9739
  key: config.$key ?? index,
9670
9740
  visible: vue.unref(floatBoxStates)[config.$key].status,
9671
9741
  "onUpdate:visible": ($event) => vue.unref(floatBoxStates)[config.$key].status = $event,
@@ -10098,7 +10168,7 @@
10098
10168
  ]),
10099
10169
  _: 1
10100
10170
  })) : vue.createCommentVNode("", true),
10101
- page.value && vue.unref(nodeStatusMap) && buttonVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
10171
+ page.value && vue.unref(nodeStatusMap) && buttonVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
10102
10172
  key: 1,
10103
10173
  ref_key: "box",
10104
10174
  ref: box,
@@ -10108,7 +10178,7 @@
10108
10178
  position: menuPosition.value
10109
10179
  }, {
10110
10180
  body: vue.withCtx(() => [
10111
- vue.createVNode(_sfc_main$l, {
10181
+ vue.createVNode(_sfc_main$m, {
10112
10182
  class: "m-editor-node-list-menu magic-editor-layer-tree",
10113
10183
  data: nodeData.value,
10114
10184
  "node-status-map": vue.unref(nodeStatusMap),
@@ -11258,6 +11328,7 @@
11258
11328
  containerHighlightClassName: StageCore.CONTAINER_HIGHLIGHT_CLASS_NAME,
11259
11329
  containerHighlightDuration: 800,
11260
11330
  containerHighlightType: StageCore.ContainerHighlightType.DEFAULT,
11331
+ disabledShowSrc: false,
11261
11332
  componentGroupList: () => [],
11262
11333
  datasourceList: () => [],
11263
11334
  menu: () => ({ left: [], right: [] }),
@@ -11639,6 +11710,7 @@
11639
11710
  disabledMultiSelect: { type: Boolean },
11640
11711
  disabledPageFragment: { type: Boolean },
11641
11712
  disabledStageOverlay: { type: Boolean },
11713
+ disabledShowSrc: { type: Boolean },
11642
11714
  render: { type: Function },
11643
11715
  updateDragEl: { type: Function },
11644
11716
  canSelect: { type: Function },
@@ -11688,15 +11760,16 @@
11688
11760
  vue.provide("services", services);
11689
11761
  vue.provide("codeOptions", props.codeOptions);
11690
11762
  vue.provide("stageOptions", stageOptions);
11763
+ vue.provide("eventBus", new events.EventEmitter());
11691
11764
  __expose(services);
11692
11765
  return (_ctx, _cache) => {
11693
- return vue.openBlock(), vue.createBlock(_sfc_main$q, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
11766
+ return vue.openBlock(), vue.createBlock(_sfc_main$r, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
11694
11767
  header: vue.withCtx(() => [
11695
11768
  vue.renderSlot(_ctx.$slots, "header")
11696
11769
  ]),
11697
11770
  nav: vue.withCtx(() => [
11698
11771
  vue.renderSlot(_ctx.$slots, "nav", { editorService: vue.unref(editorService) }, () => [
11699
- vue.createVNode(_sfc_main$p, { data: _ctx.menu }, null, 8, ["data"])
11772
+ vue.createVNode(_sfc_main$q, { data: _ctx.menu }, null, 8, ["data"])
11700
11773
  ])
11701
11774
  ]),
11702
11775
  "content-before": vue.withCtx(() => [
@@ -11771,8 +11844,9 @@
11771
11844
  ]),
11772
11845
  "props-panel": vue.withCtx(() => [
11773
11846
  vue.renderSlot(_ctx.$slots, "props-panel", {}, () => [
11774
- vue.createVNode(_sfc_main$o, {
11847
+ vue.createVNode(_sfc_main$p, {
11775
11848
  "extend-state": _ctx.extendFormState,
11849
+ "disabled-show-src": _ctx.disabledShowSrc,
11776
11850
  onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance)),
11777
11851
  onFormError: _cache[1] || (_cache[1] = (e) => _ctx.$emit("props-form-error", e)),
11778
11852
  onSubmitError: _cache[2] || (_cache[2] = (e) => _ctx.$emit("props-submit-error", e))
@@ -11781,7 +11855,7 @@
11781
11855
  vue.renderSlot(_ctx.$slots, "props-panel-header")
11782
11856
  ]),
11783
11857
  _: 3
11784
- }, 8, ["extend-state"])
11858
+ }, 8, ["extend-state", "disabled-show-src"])
11785
11859
  ])
11786
11860
  ]),
11787
11861
  empty: vue.withCtx(() => [
@@ -11819,21 +11893,21 @@
11819
11893
  setConfig(option);
11820
11894
  app.component(`${_sfc_main.name || "MEditor"}`, _sfc_main);
11821
11895
  app.component("magic-code-editor", _sfc_main$T);
11822
- app.component("m-fields-ui-select", _sfc_main$z);
11896
+ app.component("m-fields-ui-select", _sfc_main$A);
11823
11897
  app.component("m-fields-code-link", _sfc_main$R);
11824
11898
  app.component("m-fields-vs-code", _sfc_main$S);
11825
11899
  app.component("m-fields-code-select", _sfc_main$Q);
11826
- app.component("m-fields-code-select-col", _sfc_main$M);
11827
- app.component("m-fields-event-select", _sfc_main$D);
11828
- app.component("m-fields-data-source-fields", _sfc_main$L);
11829
- app.component("m-fields-data-source-mocks", _sfc_main$F);
11830
- app.component("m-fields-key-value", _sfc_main$B);
11831
- app.component("m-fields-data-source-input", _sfc_main$I);
11832
- app.component("m-fields-data-source-select", _sfc_main$E);
11833
- app.component("m-fields-data-source-methods", _sfc_main$H);
11834
- app.component("m-fields-data-source-method-select", _sfc_main$G);
11835
- app.component("m-fields-data-source-field-select", _sfc_main$J);
11836
- app.component("m-fields-page-fragment-select", _sfc_main$A);
11900
+ app.component("m-fields-code-select-col", _sfc_main$O);
11901
+ app.component("m-fields-event-select", _sfc_main$E);
11902
+ app.component("m-fields-data-source-fields", _sfc_main$M);
11903
+ app.component("m-fields-data-source-mocks", _sfc_main$G);
11904
+ app.component("m-fields-key-value", _sfc_main$C);
11905
+ app.component("m-fields-data-source-input", _sfc_main$K);
11906
+ app.component("m-fields-data-source-select", _sfc_main$F);
11907
+ app.component("m-fields-data-source-methods", _sfc_main$I);
11908
+ app.component("m-fields-data-source-method-select", _sfc_main$H);
11909
+ app.component("m-fields-data-source-field-select", _sfc_main$L);
11910
+ app.component("m-fields-page-fragment-select", _sfc_main$B);
11837
11911
  }
11838
11912
  };
11839
11913
 
@@ -11843,42 +11917,43 @@
11843
11917
  });
11844
11918
  exports.CODE_DRAFT_STORAGE_KEY = CODE_DRAFT_STORAGE_KEY;
11845
11919
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
11846
- exports.CodeBlockEditor = _sfc_main$O;
11847
- exports.CodeBlockList = _sfc_main$k;
11848
- exports.CodeBlockListPanel = _sfc_main$j;
11920
+ exports.CodeBlockEditor = _sfc_main$J;
11921
+ exports.CodeBlockList = _sfc_main$l;
11922
+ exports.CodeBlockListPanel = _sfc_main$k;
11849
11923
  exports.CodeDeleteErrorType = CodeDeleteErrorType;
11850
11924
  exports.CodeSelect = _sfc_main$Q;
11851
- exports.CodeSelectCol = _sfc_main$M;
11925
+ exports.CodeSelectCol = _sfc_main$O;
11852
11926
  exports.ColumnLayout = ColumnLayout;
11853
11927
  exports.ComponentListPanel = _sfc_main$b;
11854
11928
  exports.ContentMenu = _sfc_main$g;
11855
- exports.DataSourceConfigPanel = _sfc_main$K;
11856
- exports.DataSourceFieldSelect = _sfc_main$J;
11857
- exports.DataSourceFields = _sfc_main$L;
11858
- exports.DataSourceInput = _sfc_main$I;
11859
- exports.DataSourceMethodSelect = _sfc_main$G;
11860
- exports.DataSourceMethods = _sfc_main$H;
11861
- exports.DataSourceMocks = _sfc_main$F;
11862
- exports.DataSourceSelect = _sfc_main$E;
11929
+ exports.DataSourceConfigPanel = _sfc_main$j;
11930
+ exports.DataSourceFieldSelect = _sfc_main$L;
11931
+ exports.DataSourceFields = _sfc_main$M;
11932
+ exports.DataSourceInput = _sfc_main$K;
11933
+ exports.DataSourceMethodSelect = _sfc_main$H;
11934
+ exports.DataSourceMethods = _sfc_main$I;
11935
+ exports.DataSourceMocks = _sfc_main$G;
11936
+ exports.DataSourceSelect = _sfc_main$F;
11863
11937
  exports.DragType = DragType;
11864
- exports.EventSelect = _sfc_main$D;
11938
+ exports.EventSelect = _sfc_main$E;
11865
11939
  exports.Fixed2Other = Fixed2Other;
11866
11940
  exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
11867
11941
  exports.Icon = _sfc_main$U;
11868
11942
  exports.KeyBindingCommand = KeyBindingCommand;
11869
- exports.KeyValue = _sfc_main$B;
11943
+ exports.KeyValue = _sfc_main$C;
11870
11944
  exports.Keys = Keys;
11871
11945
  exports.LayerOffset = LayerOffset;
11872
11946
  exports.LayerPanel = _sfc_main$c;
11873
11947
  exports.Layout = Layout;
11874
- exports.LayoutContainer = _sfc_main$x;
11875
- exports.PageFragmentSelect = _sfc_main$A;
11876
- exports.PropsPanel = _sfc_main$o;
11877
- exports.Resizer = _sfc_main$y;
11878
- exports.SplitView = _sfc_main$x;
11948
+ exports.LayoutContainer = _sfc_main$y;
11949
+ exports.PageFragmentSelect = _sfc_main$B;
11950
+ exports.PropsPanel = _sfc_main$p;
11951
+ exports.Resizer = _sfc_main$z;
11952
+ exports.SideItemKey = SideItemKey;
11953
+ exports.SplitView = _sfc_main$y;
11879
11954
  exports.TMagicCodeEditor = _sfc_main$T;
11880
11955
  exports.TMagicEditor = _sfc_main;
11881
- exports.ToolButton = _sfc_main$w;
11956
+ exports.ToolButton = _sfc_main$x;
11882
11957
  exports.UI_SELECT_MODE_EVENT_NAME = UI_SELECT_MODE_EVENT_NAME;
11883
11958
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
11884
11959
  exports.advancedTabConfig = advancedTabConfig;