@tmagic/editor 1.4.0-beta.2 → 1.4.1
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.
- package/dist/style.css +8 -20
- package/dist/tmagic-editor.js +830 -741
- package/dist/tmagic-editor.umd.cjs +833 -744
- package/package.json +11 -11
- package/src/components/CodeBlockEditor.vue +50 -73
- package/src/components/FloatingBox.vue +24 -9
- package/src/fields/DataSourceFieldSelect.vue +2 -1
- package/src/fields/DataSourceFields.vue +55 -30
- package/src/fields/DataSourceInput.vue +6 -2
- package/src/fields/DataSourceMocks.vue +35 -17
- package/src/hooks/use-editor-content-height.ts +1 -1
- package/src/hooks/use-float-box.ts +14 -8
- package/src/hooks/use-next-float-box-position.ts +29 -0
- package/src/layouts/CodeEditor.vue +3 -6
- package/src/layouts/PropsPanel.vue +4 -2
- package/src/layouts/sidebar/Sidebar.vue +7 -10
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +1 -3
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +36 -22
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +2 -7
- package/src/layouts/workspace/viewer/StageOverlay.vue +3 -1
- package/src/theme/code-block.scss +0 -14
- package/src/theme/component-list-panel.scss +0 -1
- package/src/theme/icon.scss +7 -1
- package/src/theme/layer-panel.scss +0 -1
- package/src/theme/sidebar.scss +0 -7
- package/src/type.ts +0 -6
- package/types/components/CodeBlockEditor.vue.d.ts +0 -7
- package/types/fields/DataSourceFields.vue.d.ts +84 -28
- package/types/fields/DataSourceMocks.vue.d.ts +80 -28
- package/types/hooks/use-code-block-edit.d.ts +0 -9
- package/types/hooks/use-data-source-method.d.ts +0 -9
- package/types/hooks/use-next-float-box-position.d.ts +9 -0
- package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +1 -3
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +34 -22
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +2 -15
- package/types/type.d.ts +0 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('@tmagic/design'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/form'), require('moveable'), require('@tmagic/table'), require('@tmagic/utils'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', '@tmagic/design', 'emmet-monaco-es', 'monaco-editor', '@tmagic/schema', '@tmagic/form', 'moveable', '@tmagic/table', '@tmagic/utils', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.design, global.emmetMonacoEs, global.monaco, global.schema, global.form, global.VanillaMoveable, global.table, global.utils, global.
|
|
5
|
-
})(this, (function (exports, vue, iconsVue, lodashEs, serialize, design, emmetMonacoEs, monaco, schema, form, VanillaMoveable, table, utils,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('@tmagic/design'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/schema'), require('@tmagic/form'), require('moveable'), require('@tmagic/table'), require('@tmagic/utils'), require('@tmagic/dep'), require('gesto'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', '@tmagic/design', 'emmet-monaco-es', 'monaco-editor', '@tmagic/schema', '@tmagic/form', 'moveable', '@tmagic/table', '@tmagic/utils', '@tmagic/dep', 'gesto', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.design, global.emmetMonacoEs, global.monaco, global.schema, global.form, global.VanillaMoveable, global.table, global.utils, global.dep, global.Gesto, global.StageCore, global.events, global.core, global.KeyController));
|
|
5
|
+
})(this, (function (exports, vue, iconsVue, lodashEs, serialize, design, emmetMonacoEs, monaco, schema, form, VanillaMoveable, table, utils, dep, Gesto, StageCore, events, core, KeyController) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -23,6 +23,50 @@
|
|
|
23
23
|
|
|
24
24
|
const monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
|
|
25
25
|
|
|
26
|
+
const _hoisted_1$t = ["src"];
|
|
27
|
+
const _sfc_main$U = /* @__PURE__ */ vue.defineComponent({
|
|
28
|
+
...{
|
|
29
|
+
name: "MEditorIcon"
|
|
30
|
+
},
|
|
31
|
+
__name: "Icon",
|
|
32
|
+
props: {
|
|
33
|
+
icon: {}
|
|
34
|
+
},
|
|
35
|
+
setup(__props) {
|
|
36
|
+
const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
|
|
37
|
+
return (_ctx, _cache) => {
|
|
38
|
+
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
|
|
39
|
+
key: 0,
|
|
40
|
+
class: "magic-editor-icon"
|
|
41
|
+
}, {
|
|
42
|
+
default: vue.withCtx(() => [
|
|
43
|
+
vue.createVNode(vue.unref(iconsVue.Edit))
|
|
44
|
+
]),
|
|
45
|
+
_: 1
|
|
46
|
+
})) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
|
|
47
|
+
key: 1,
|
|
48
|
+
class: "magic-editor-icon"
|
|
49
|
+
}, {
|
|
50
|
+
default: vue.withCtx(() => [
|
|
51
|
+
vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$t)
|
|
52
|
+
]),
|
|
53
|
+
_: 1
|
|
54
|
+
})) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
55
|
+
key: 2,
|
|
56
|
+
class: vue.normalizeClass(["magic-editor-icon", _ctx.icon])
|
|
57
|
+
}, null, 2)) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
|
|
58
|
+
key: 3,
|
|
59
|
+
class: "magic-editor-icon"
|
|
60
|
+
}, {
|
|
61
|
+
default: vue.withCtx(() => [
|
|
62
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(_ctx.icon))))
|
|
63
|
+
]),
|
|
64
|
+
_: 1
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
26
70
|
let $TMAGIC_EDITOR = {};
|
|
27
71
|
const setConfig = (option) => {
|
|
28
72
|
$TMAGIC_EDITOR = option;
|
|
@@ -32,10 +76,10 @@
|
|
|
32
76
|
emmetMonacoEs.emmetHTML(monaco__namespace);
|
|
33
77
|
emmetMonacoEs.emmetCSS(monaco__namespace, ["css", "scss"]);
|
|
34
78
|
|
|
35
|
-
const _hoisted_1$
|
|
79
|
+
const _hoisted_1$s = {
|
|
36
80
|
class: /* @__PURE__ */ vue.normalizeClass(`magic-code-editor`)
|
|
37
81
|
};
|
|
38
|
-
const _sfc_main$
|
|
82
|
+
const _sfc_main$T = /* @__PURE__ */ vue.defineComponent({
|
|
39
83
|
...{
|
|
40
84
|
name: "MEditorCodeEditor"
|
|
41
85
|
},
|
|
@@ -193,7 +237,7 @@
|
|
|
193
237
|
}
|
|
194
238
|
});
|
|
195
239
|
return (_ctx, _cache) => {
|
|
196
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$
|
|
240
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
|
|
197
241
|
(vue.openBlock(), vue.createBlock(vue.Teleport, {
|
|
198
242
|
to: "body",
|
|
199
243
|
disabled: !fullScreen.value
|
|
@@ -206,9 +250,13 @@
|
|
|
206
250
|
class: "magic-code-editor-full-screen-icon",
|
|
207
251
|
circle: "",
|
|
208
252
|
size: "small",
|
|
209
|
-
icon: vue.unref(iconsVue.FullScreen),
|
|
210
253
|
onClick: fullScreenHandler
|
|
211
|
-
},
|
|
254
|
+
}, {
|
|
255
|
+
default: vue.withCtx(() => [
|
|
256
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.FullScreen) }, null, 8, ["icon"])
|
|
257
|
+
]),
|
|
258
|
+
_: 1
|
|
259
|
+
}),
|
|
212
260
|
vue.createElementVNode("div", {
|
|
213
261
|
ref_key: "codeEditor",
|
|
214
262
|
ref: codeEditor,
|
|
@@ -221,7 +269,7 @@
|
|
|
221
269
|
}
|
|
222
270
|
});
|
|
223
271
|
|
|
224
|
-
const _sfc_main$
|
|
272
|
+
const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
|
|
225
273
|
...{
|
|
226
274
|
name: "MFieldsVsCode"
|
|
227
275
|
},
|
|
@@ -246,7 +294,7 @@
|
|
|
246
294
|
emit("change", v);
|
|
247
295
|
};
|
|
248
296
|
return (_ctx, _cache) => {
|
|
249
|
-
return vue.openBlock(), vue.createBlock(_sfc_main$
|
|
297
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$T, {
|
|
250
298
|
height: _ctx.config.height,
|
|
251
299
|
"init-values": _ctx.model[_ctx.name],
|
|
252
300
|
language: _ctx.config.language,
|
|
@@ -261,7 +309,7 @@
|
|
|
261
309
|
}
|
|
262
310
|
});
|
|
263
311
|
|
|
264
|
-
const _sfc_main$
|
|
312
|
+
const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
|
|
265
313
|
...{
|
|
266
314
|
name: "MFieldsCodeLink"
|
|
267
315
|
},
|
|
@@ -341,7 +389,7 @@
|
|
|
341
389
|
}
|
|
342
390
|
});
|
|
343
391
|
|
|
344
|
-
const _sfc_main$
|
|
392
|
+
const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
|
|
345
393
|
...{
|
|
346
394
|
name: "MFieldsCodeSelect"
|
|
347
395
|
},
|
|
@@ -459,7 +507,7 @@
|
|
|
459
507
|
}
|
|
460
508
|
});
|
|
461
509
|
|
|
462
|
-
const _sfc_main$
|
|
510
|
+
const _sfc_main$P = /* @__PURE__ */ vue.defineComponent({
|
|
463
511
|
__name: "FloatingBox",
|
|
464
512
|
props: /* @__PURE__ */ vue.mergeModels({
|
|
465
513
|
position: { default: () => ({ left: 0, top: 0 }) },
|
|
@@ -482,7 +530,7 @@
|
|
|
482
530
|
const target = vue.ref();
|
|
483
531
|
const titleEl = vue.ref();
|
|
484
532
|
const zIndex = design.useZIndex();
|
|
485
|
-
const curZIndex = vue.ref(
|
|
533
|
+
const curZIndex = vue.ref(0);
|
|
486
534
|
const titleHeight = vue.ref(0);
|
|
487
535
|
const bodyHeight = vue.computed(() => {
|
|
488
536
|
if (height.value) {
|
|
@@ -493,12 +541,20 @@
|
|
|
493
541
|
}
|
|
494
542
|
return "auto";
|
|
495
543
|
});
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
544
|
+
const services = vue.inject("services");
|
|
545
|
+
const frameworkWidth = vue.computed(() => services?.uiService.get("frameworkRect").width || 0);
|
|
546
|
+
const style = vue.computed(() => {
|
|
547
|
+
let { left } = props.position;
|
|
548
|
+
if (width.value) {
|
|
549
|
+
left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
left: `${left}px`,
|
|
553
|
+
top: `${props.position.top}px`,
|
|
554
|
+
width: width.value ? `${width.value}px` : "auto",
|
|
555
|
+
height: height.value ? `${height.value}px` : "auto"
|
|
556
|
+
};
|
|
557
|
+
});
|
|
502
558
|
let moveable = null;
|
|
503
559
|
const initMoveable = () => {
|
|
504
560
|
moveable = new VanillaMoveable(globalThis.document.body, {
|
|
@@ -536,6 +592,7 @@
|
|
|
536
592
|
async (visible2) => {
|
|
537
593
|
if (visible2) {
|
|
538
594
|
await vue.nextTick();
|
|
595
|
+
curZIndex.value = zIndex.nextZIndex();
|
|
539
596
|
const targetRect = target.value?.getBoundingClientRect();
|
|
540
597
|
if (targetRect) {
|
|
541
598
|
width.value = targetRect.width;
|
|
@@ -572,6 +629,7 @@
|
|
|
572
629
|
const nextZIndex = () => {
|
|
573
630
|
curZIndex.value = zIndex.nextZIndex();
|
|
574
631
|
};
|
|
632
|
+
vue.provide("parentFloating", target);
|
|
575
633
|
__expose({
|
|
576
634
|
bodyHeight,
|
|
577
635
|
target,
|
|
@@ -601,9 +659,13 @@
|
|
|
601
659
|
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
602
660
|
link: "",
|
|
603
661
|
size: "small",
|
|
604
|
-
icon: vue.unref(iconsVue.Close),
|
|
605
662
|
onClick: closeHandler
|
|
606
|
-
},
|
|
663
|
+
}, {
|
|
664
|
+
default: vue.withCtx(() => [
|
|
665
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Close) }, null, 8, ["icon"])
|
|
666
|
+
]),
|
|
667
|
+
_: 1
|
|
668
|
+
})
|
|
607
669
|
])
|
|
608
670
|
], 512),
|
|
609
671
|
vue.createElementVNode("div", {
|
|
@@ -625,7 +687,7 @@
|
|
|
625
687
|
const editorContentHeight = vue.computed(() => frameworkHeight.value - navMenuHeight.value);
|
|
626
688
|
const height = vue.ref(0);
|
|
627
689
|
vue.watchEffect(() => {
|
|
628
|
-
if (height.value > 0)
|
|
690
|
+
if (height.value > 0 && height.value === editorContentHeight.value)
|
|
629
691
|
return;
|
|
630
692
|
height.value = editorContentHeight.value;
|
|
631
693
|
});
|
|
@@ -634,6 +696,30 @@
|
|
|
634
696
|
};
|
|
635
697
|
};
|
|
636
698
|
|
|
699
|
+
const useNextFloatBoxPosition = (uiService, parent) => {
|
|
700
|
+
const boxPosition = vue.ref({
|
|
701
|
+
left: 0,
|
|
702
|
+
top: 0
|
|
703
|
+
});
|
|
704
|
+
const calcBoxPosition = () => {
|
|
705
|
+
const columnWidth = uiService?.get("columnWidth");
|
|
706
|
+
const navMenuRect = uiService?.get("navMenuRect");
|
|
707
|
+
let left = columnWidth?.left ?? 0;
|
|
708
|
+
if (parent?.value) {
|
|
709
|
+
const rect = parent?.value?.getBoundingClientRect();
|
|
710
|
+
left = (rect?.left ?? 0) + (rect?.width ?? 0);
|
|
711
|
+
}
|
|
712
|
+
boxPosition.value = {
|
|
713
|
+
left,
|
|
714
|
+
top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
|
|
715
|
+
};
|
|
716
|
+
};
|
|
717
|
+
return {
|
|
718
|
+
boxPosition,
|
|
719
|
+
calcBoxPosition
|
|
720
|
+
};
|
|
721
|
+
};
|
|
722
|
+
|
|
637
723
|
const useWindowRect = () => {
|
|
638
724
|
const rect = vue.reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
|
|
639
725
|
const windowResizeHandler = () => {
|
|
@@ -649,11 +735,11 @@
|
|
|
649
735
|
};
|
|
650
736
|
};
|
|
651
737
|
|
|
652
|
-
const _hoisted_1$
|
|
738
|
+
const _hoisted_1$r = { style: { "display": "flex", "margin-bottom": "10px" } };
|
|
653
739
|
const _hoisted_2$k = { style: { "flex": "1" } };
|
|
654
740
|
const _hoisted_3$8 = { style: { "flex": "1" } };
|
|
655
741
|
const _hoisted_4$7 = { class: "dialog-footer" };
|
|
656
|
-
const _sfc_main$
|
|
742
|
+
const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
|
|
657
743
|
...{
|
|
658
744
|
name: "MEditorCodeBlockEditor"
|
|
659
745
|
},
|
|
@@ -662,8 +748,7 @@
|
|
|
662
748
|
content: {},
|
|
663
749
|
disabled: { type: Boolean },
|
|
664
750
|
isDataSource: { type: Boolean },
|
|
665
|
-
dataSourceType: {}
|
|
666
|
-
slideType: {}
|
|
751
|
+
dataSourceType: {}
|
|
667
752
|
}, {
|
|
668
753
|
"width": { default: 670 },
|
|
669
754
|
"widthModifiers": {},
|
|
@@ -796,7 +881,6 @@
|
|
|
796
881
|
};
|
|
797
882
|
const beforeClose = (done) => {
|
|
798
883
|
if (!changedValue.value) {
|
|
799
|
-
editVisible.value = false;
|
|
800
884
|
done();
|
|
801
885
|
return;
|
|
802
886
|
}
|
|
@@ -807,170 +891,142 @@
|
|
|
807
891
|
distinguishCancelAndClose: true
|
|
808
892
|
}).then(() => {
|
|
809
893
|
changedValue.value && submitForm(changedValue.value);
|
|
810
|
-
editVisible.value = false;
|
|
811
894
|
done();
|
|
812
895
|
}).catch((action) => {
|
|
813
|
-
if (action === "cancel") {
|
|
814
|
-
editVisible.value = false;
|
|
815
|
-
}
|
|
816
896
|
done(action === "cancel");
|
|
817
897
|
});
|
|
818
898
|
};
|
|
819
899
|
const closedHandler = () => {
|
|
820
900
|
changedValue.value = void 0;
|
|
821
901
|
};
|
|
822
|
-
const
|
|
823
|
-
const
|
|
824
|
-
const boxPosition = vue.computed(() => {
|
|
825
|
-
const columnWidth = services?.uiService?.get("columnWidth");
|
|
826
|
-
const navMenuRect = services?.uiService?.get("navMenuRect");
|
|
827
|
-
return {
|
|
828
|
-
left: columnWidth?.left ?? 0,
|
|
829
|
-
top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
|
|
830
|
-
};
|
|
831
|
-
});
|
|
902
|
+
const parentFloating = vue.inject("parentFloating", vue.ref(null));
|
|
903
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
832
904
|
__expose({
|
|
833
905
|
async show() {
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
await vue.nextTick();
|
|
837
|
-
}
|
|
838
|
-
editVisible.value = true;
|
|
906
|
+
calcBoxPosition();
|
|
907
|
+
boxVisible.value = true;
|
|
839
908
|
},
|
|
840
909
|
async hide() {
|
|
841
|
-
|
|
842
|
-
if (props.slideType !== "box") {
|
|
843
|
-
await vue.nextTick();
|
|
844
|
-
boxVisible.value = false;
|
|
845
|
-
}
|
|
910
|
+
boxVisible.value = false;
|
|
846
911
|
}
|
|
847
912
|
});
|
|
848
913
|
return (_ctx, _cache) => {
|
|
849
914
|
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
850
|
-
vue.createVNode(_sfc_main$
|
|
915
|
+
vue.createVNode(_sfc_main$P, {
|
|
851
916
|
visible: boxVisible.value,
|
|
852
|
-
"onUpdate:visible": _cache[
|
|
917
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
|
|
853
918
|
width: width.value,
|
|
854
|
-
"onUpdate:width": _cache[
|
|
919
|
+
"onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
|
|
855
920
|
height: vue.unref(codeBlockEditorHeight),
|
|
856
|
-
"onUpdate:height": _cache[
|
|
921
|
+
"onUpdate:height": _cache[3] || (_cache[3] = ($event) => vue.isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
|
|
857
922
|
title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
|
|
858
|
-
position: boxPosition
|
|
923
|
+
position: vue.unref(boxPosition),
|
|
859
924
|
"before-close": beforeClose
|
|
860
925
|
}, {
|
|
861
926
|
body: vue.withCtx(() => [
|
|
862
|
-
vue.
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
927
|
+
vue.createVNode(vue.unref(form.MFormBox), {
|
|
928
|
+
class: "m-editor-code-block-editor",
|
|
929
|
+
ref_key: "formBox",
|
|
930
|
+
ref: formBox,
|
|
931
|
+
"label-width": "80px",
|
|
932
|
+
"close-on-press-escape": false,
|
|
933
|
+
title: _ctx.content.name,
|
|
934
|
+
config: functionConfig.value,
|
|
935
|
+
values: _ctx.content,
|
|
936
|
+
disabled: _ctx.disabled,
|
|
937
|
+
style: { "height": "100%" },
|
|
938
|
+
onChange: changeHandler,
|
|
939
|
+
onSubmit: submitForm,
|
|
940
|
+
onError: errorHandler,
|
|
941
|
+
onClosed: closedHandler
|
|
942
|
+
}, {
|
|
943
|
+
left: vue.withCtx(() => [
|
|
944
|
+
!_ctx.disabled ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
945
|
+
key: 0,
|
|
946
|
+
type: "primary",
|
|
947
|
+
link: "",
|
|
948
|
+
onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
|
|
949
|
+
}, {
|
|
950
|
+
default: vue.withCtx(() => [
|
|
951
|
+
vue.createTextVNode("查看修改")
|
|
952
|
+
]),
|
|
953
|
+
_: 1
|
|
954
|
+
})) : vue.createCommentVNode("", true)
|
|
955
|
+
]),
|
|
956
|
+
_: 1
|
|
957
|
+
}, 8, ["title", "config", "values", "disabled"])
|
|
867
958
|
]),
|
|
868
959
|
_: 1
|
|
869
960
|
}, 8, ["visible", "width", "height", "title", "position"]),
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
class: "m-editor-code-block-editor",
|
|
877
|
-
ref_key: "formBox",
|
|
878
|
-
ref: formBox,
|
|
879
|
-
"label-width": "80px",
|
|
880
|
-
"close-on-press-escape": false,
|
|
881
|
-
title: _ctx.content.name,
|
|
882
|
-
config: functionConfig.value,
|
|
883
|
-
values: _ctx.content,
|
|
884
|
-
disabled: _ctx.disabled,
|
|
885
|
-
height: floatingBoxBody.value?.clientHeight,
|
|
886
|
-
onChange: changeHandler,
|
|
887
|
-
onSubmit: submitForm,
|
|
888
|
-
onError: errorHandler,
|
|
889
|
-
onClosed: closedHandler
|
|
961
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
962
|
+
vue.createVNode(vue.unref(design.TMagicDialog), {
|
|
963
|
+
title: "查看修改",
|
|
964
|
+
modelValue: difVisible.value,
|
|
965
|
+
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
|
|
966
|
+
fullscreen: ""
|
|
890
967
|
}, {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
type: "primary",
|
|
895
|
-
link: "",
|
|
896
|
-
onClick: _cache[3] || (_cache[3] = ($event) => difVisible.value = true)
|
|
897
|
-
}, {
|
|
898
|
-
default: vue.withCtx(() => [
|
|
899
|
-
vue.createTextVNode("查看修改")
|
|
900
|
-
]),
|
|
901
|
-
_: 1
|
|
902
|
-
})) : vue.createCommentVNode("", true)
|
|
903
|
-
]),
|
|
904
|
-
_: 1
|
|
905
|
-
}, 8, ["title", "config", "values", "disabled", "height"])
|
|
906
|
-
], 8, ["to", "disabled"])) : vue.createCommentVNode("", true),
|
|
907
|
-
vue.createVNode(vue.unref(design.TMagicDialog), {
|
|
908
|
-
modelValue: difVisible.value,
|
|
909
|
-
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
|
|
910
|
-
title: "查看修改",
|
|
911
|
-
fullscreen: ""
|
|
912
|
-
}, {
|
|
913
|
-
footer: vue.withCtx(() => [
|
|
914
|
-
vue.createElementVNode("span", _hoisted_4$7, [
|
|
915
|
-
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
916
|
-
size: "small",
|
|
917
|
-
onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
|
|
918
|
-
}, {
|
|
919
|
-
default: vue.withCtx(() => [
|
|
920
|
-
vue.createTextVNode("取消")
|
|
921
|
-
]),
|
|
922
|
-
_: 1
|
|
923
|
-
}),
|
|
924
|
-
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
925
|
-
size: "small",
|
|
926
|
-
type: "primary",
|
|
927
|
-
onClick: diffChange
|
|
928
|
-
}, {
|
|
929
|
-
default: vue.withCtx(() => [
|
|
930
|
-
vue.createTextVNode("确定")
|
|
931
|
-
]),
|
|
932
|
-
_: 1
|
|
933
|
-
})
|
|
934
|
-
])
|
|
935
|
-
]),
|
|
936
|
-
default: vue.withCtx(() => [
|
|
937
|
-
vue.createElementVNode("div", _hoisted_1$s, [
|
|
938
|
-
vue.createElementVNode("div", _hoisted_2$k, [
|
|
939
|
-
vue.createVNode(vue.unref(design.TMagicTag), {
|
|
968
|
+
footer: vue.withCtx(() => [
|
|
969
|
+
vue.createElementVNode("span", _hoisted_4$7, [
|
|
970
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
940
971
|
size: "small",
|
|
941
|
-
|
|
972
|
+
onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
|
|
942
973
|
}, {
|
|
943
974
|
default: vue.withCtx(() => [
|
|
944
|
-
vue.createTextVNode("
|
|
975
|
+
vue.createTextVNode("取消")
|
|
945
976
|
]),
|
|
946
977
|
_: 1
|
|
947
|
-
})
|
|
948
|
-
|
|
949
|
-
vue.createElementVNode("div", _hoisted_3$8, [
|
|
950
|
-
vue.createVNode(vue.unref(design.TMagicTag), {
|
|
978
|
+
}),
|
|
979
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
951
980
|
size: "small",
|
|
952
|
-
type: "
|
|
981
|
+
type: "primary",
|
|
982
|
+
onClick: diffChange
|
|
953
983
|
}, {
|
|
954
984
|
default: vue.withCtx(() => [
|
|
955
|
-
vue.createTextVNode("
|
|
985
|
+
vue.createTextVNode("确定")
|
|
956
986
|
]),
|
|
957
987
|
_: 1
|
|
958
988
|
})
|
|
959
989
|
])
|
|
960
990
|
]),
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
991
|
+
default: vue.withCtx(() => [
|
|
992
|
+
vue.createElementVNode("div", _hoisted_1$r, [
|
|
993
|
+
vue.createElementVNode("div", _hoisted_2$k, [
|
|
994
|
+
vue.createVNode(vue.unref(design.TMagicTag), {
|
|
995
|
+
size: "small",
|
|
996
|
+
type: "info"
|
|
997
|
+
}, {
|
|
998
|
+
default: vue.withCtx(() => [
|
|
999
|
+
vue.createTextVNode("修改前")
|
|
1000
|
+
]),
|
|
1001
|
+
_: 1
|
|
1002
|
+
})
|
|
1003
|
+
]),
|
|
1004
|
+
vue.createElementVNode("div", _hoisted_3$8, [
|
|
1005
|
+
vue.createVNode(vue.unref(design.TMagicTag), {
|
|
1006
|
+
size: "small",
|
|
1007
|
+
type: "success"
|
|
1008
|
+
}, {
|
|
1009
|
+
default: vue.withCtx(() => [
|
|
1010
|
+
vue.createTextVNode("修改后")
|
|
1011
|
+
]),
|
|
1012
|
+
_: 1
|
|
1013
|
+
})
|
|
1014
|
+
])
|
|
1015
|
+
]),
|
|
1016
|
+
difVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
|
|
1017
|
+
key: 0,
|
|
1018
|
+
ref_key: "magicVsEditor",
|
|
1019
|
+
ref: magicVsEditor,
|
|
1020
|
+
type: "diff",
|
|
1021
|
+
language: "json",
|
|
1022
|
+
initValues: _ctx.content.content,
|
|
1023
|
+
modifiedValues: formBox.value?.form?.values.content,
|
|
1024
|
+
style: vue.normalizeStyle(`height: ${vue.unref(windowRect).height - 150}px`)
|
|
1025
|
+
}, null, 8, ["initValues", "modifiedValues", "style"])) : vue.createCommentVNode("", true)
|
|
1026
|
+
]),
|
|
1027
|
+
_: 1
|
|
1028
|
+
}, 8, ["modelValue"])
|
|
1029
|
+
]))
|
|
974
1030
|
], 64);
|
|
975
1031
|
};
|
|
976
1032
|
}
|
|
@@ -3646,7 +3702,7 @@
|
|
|
3646
3702
|
return newNode;
|
|
3647
3703
|
};
|
|
3648
3704
|
|
|
3649
|
-
const _sfc_main$
|
|
3705
|
+
const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
|
|
3650
3706
|
...{
|
|
3651
3707
|
name: "MEditorCodeParams"
|
|
3652
3708
|
},
|
|
@@ -3696,50 +3752,6 @@
|
|
|
3696
3752
|
}
|
|
3697
3753
|
});
|
|
3698
3754
|
|
|
3699
|
-
const _hoisted_1$r = ["src"];
|
|
3700
|
-
const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
|
|
3701
|
-
...{
|
|
3702
|
-
name: "MEditorIcon"
|
|
3703
|
-
},
|
|
3704
|
-
__name: "Icon",
|
|
3705
|
-
props: {
|
|
3706
|
-
icon: {}
|
|
3707
|
-
},
|
|
3708
|
-
setup(__props) {
|
|
3709
|
-
const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
|
|
3710
|
-
return (_ctx, _cache) => {
|
|
3711
|
-
return !_ctx.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
|
|
3712
|
-
key: 0,
|
|
3713
|
-
class: "magic-editor-icon"
|
|
3714
|
-
}, {
|
|
3715
|
-
default: vue.withCtx(() => [
|
|
3716
|
-
vue.createVNode(vue.unref(iconsVue.Edit))
|
|
3717
|
-
]),
|
|
3718
|
-
_: 1
|
|
3719
|
-
})) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
|
|
3720
|
-
key: 1,
|
|
3721
|
-
class: "magic-editor-icon"
|
|
3722
|
-
}, {
|
|
3723
|
-
default: vue.withCtx(() => [
|
|
3724
|
-
vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$r)
|
|
3725
|
-
]),
|
|
3726
|
-
_: 1
|
|
3727
|
-
})) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
3728
|
-
key: 2,
|
|
3729
|
-
class: vue.normalizeClass(["magic-editor-icon", _ctx.icon])
|
|
3730
|
-
}, null, 2)) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
|
|
3731
|
-
key: 3,
|
|
3732
|
-
class: "magic-editor-icon"
|
|
3733
|
-
}, {
|
|
3734
|
-
default: vue.withCtx(() => [
|
|
3735
|
-
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(_ctx.icon))))
|
|
3736
|
-
]),
|
|
3737
|
-
_: 1
|
|
3738
|
-
}));
|
|
3739
|
-
};
|
|
3740
|
-
}
|
|
3741
|
-
});
|
|
3742
|
-
|
|
3743
3755
|
const useCodeBlockEdit = (codeBlockService) => {
|
|
3744
3756
|
const codeConfig = vue.ref();
|
|
3745
3757
|
const codeId = vue.ref();
|
|
@@ -3886,14 +3898,14 @@
|
|
|
3886
3898
|
size: _ctx.size,
|
|
3887
3899
|
onChange: onParamsChangeHandler
|
|
3888
3900
|
}, null, 8, ["model", "size"]),
|
|
3889
|
-
_ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3901
|
+
_ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
3890
3902
|
key: 0,
|
|
3891
3903
|
class: "icon",
|
|
3892
3904
|
icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
|
|
3893
3905
|
onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(editCode)(_ctx.model[_ctx.name]))
|
|
3894
3906
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true)
|
|
3895
3907
|
]),
|
|
3896
|
-
paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3908
|
+
paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
|
|
3897
3909
|
name: "params",
|
|
3898
3910
|
key: _ctx.model[_ctx.name],
|
|
3899
3911
|
model: _ctx.model,
|
|
@@ -3901,7 +3913,7 @@
|
|
|
3901
3913
|
"params-config": paramsConfig.value,
|
|
3902
3914
|
onChange: onParamsChangeHandler
|
|
3903
3915
|
}, null, 8, ["model", "size", "params-config"])) : vue.createCommentVNode("", true),
|
|
3904
|
-
vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3916
|
+
vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
|
|
3905
3917
|
key: 1,
|
|
3906
3918
|
ref_key: "codeBlockEditor",
|
|
3907
3919
|
ref: codeBlockEditor,
|
|
@@ -3914,64 +3926,408 @@
|
|
|
3914
3926
|
}
|
|
3915
3927
|
});
|
|
3916
3928
|
|
|
3917
|
-
const
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3929
|
+
const useDataSourceMethod = () => {
|
|
3930
|
+
const codeConfig = vue.ref();
|
|
3931
|
+
const codeBlockEditor = vue.ref();
|
|
3932
|
+
const dataSource = vue.ref();
|
|
3933
|
+
const dataSourceMethod = vue.ref("");
|
|
3934
|
+
return {
|
|
3935
|
+
codeConfig,
|
|
3936
|
+
codeBlockEditor,
|
|
3937
|
+
createCode: async (model) => {
|
|
3938
|
+
codeConfig.value = {
|
|
3939
|
+
name: "",
|
|
3940
|
+
content: `({ params, dataSource, app }) => {
|
|
3941
|
+
// place your code here
|
|
3942
|
+
}`,
|
|
3943
|
+
params: []
|
|
3944
|
+
};
|
|
3945
|
+
await vue.nextTick();
|
|
3946
|
+
dataSource.value = model;
|
|
3947
|
+
dataSourceMethod.value = "";
|
|
3948
|
+
codeBlockEditor.value?.show();
|
|
3949
|
+
},
|
|
3950
|
+
editCode: async (model, methodName) => {
|
|
3951
|
+
const method = model.methods?.find((method2) => method2.name === methodName);
|
|
3952
|
+
if (!method) {
|
|
3953
|
+
design.tMagicMessage.error("获取数据源方法失败");
|
|
3954
|
+
return;
|
|
3955
|
+
}
|
|
3956
|
+
let codeContent = method.content;
|
|
3957
|
+
if (typeof codeContent !== "string") {
|
|
3958
|
+
codeContent = codeContent.toString();
|
|
3959
|
+
}
|
|
3960
|
+
codeConfig.value = {
|
|
3961
|
+
...lodashEs.cloneDeep(method),
|
|
3962
|
+
content: codeContent
|
|
3963
|
+
};
|
|
3964
|
+
await vue.nextTick();
|
|
3965
|
+
dataSource.value = model;
|
|
3966
|
+
dataSourceMethod.value = methodName;
|
|
3967
|
+
codeBlockEditor.value?.show();
|
|
3968
|
+
},
|
|
3969
|
+
deleteCode: async (model, methodName) => {
|
|
3970
|
+
if (!model.methods)
|
|
3971
|
+
return;
|
|
3972
|
+
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
3973
|
+
if (index === -1) {
|
|
3974
|
+
return;
|
|
3975
|
+
}
|
|
3976
|
+
model.methods.splice(index, 1);
|
|
3977
|
+
},
|
|
3978
|
+
submitCode: (values) => {
|
|
3979
|
+
if (!dataSource.value)
|
|
3980
|
+
return;
|
|
3981
|
+
if (!dataSource.value.methods) {
|
|
3982
|
+
dataSource.value.methods = [];
|
|
3983
|
+
}
|
|
3984
|
+
if (values.content) {
|
|
3985
|
+
const parseDSL = getConfig("parseDSL");
|
|
3986
|
+
if (typeof values.content === "string") {
|
|
3987
|
+
values.content = parseDSL(values.content);
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
if (dataSourceMethod.value) {
|
|
3991
|
+
const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
|
|
3992
|
+
dataSource.value.methods.splice(index, 1, values);
|
|
3993
|
+
} else {
|
|
3994
|
+
dataSource.value.methods.push(values);
|
|
3995
|
+
}
|
|
3996
|
+
codeBlockEditor.value?.hide();
|
|
3997
|
+
}
|
|
3998
|
+
};
|
|
3999
|
+
};
|
|
4000
|
+
|
|
4001
|
+
const state = vue.reactive({
|
|
4002
|
+
uiSelectMode: false,
|
|
4003
|
+
showSrc: false,
|
|
4004
|
+
zoom: 1,
|
|
4005
|
+
stageContainerRect: {
|
|
4006
|
+
width: 0,
|
|
4007
|
+
height: 0
|
|
4008
|
+
},
|
|
4009
|
+
stageRect: {
|
|
4010
|
+
width: 375,
|
|
4011
|
+
height: 817
|
|
4012
|
+
},
|
|
4013
|
+
columnWidth: {
|
|
4014
|
+
left: 0,
|
|
4015
|
+
right: 0,
|
|
4016
|
+
center: 0
|
|
4017
|
+
},
|
|
4018
|
+
showGuides: true,
|
|
4019
|
+
showRule: true,
|
|
4020
|
+
propsPanelSize: "small",
|
|
4021
|
+
showAddPageButton: true,
|
|
4022
|
+
hideSlideBar: false,
|
|
4023
|
+
navMenuRect: {
|
|
4024
|
+
left: 0,
|
|
4025
|
+
top: 0,
|
|
4026
|
+
width: 0,
|
|
4027
|
+
height: 0
|
|
4028
|
+
},
|
|
4029
|
+
frameworkRect: {
|
|
4030
|
+
width: 0,
|
|
4031
|
+
height: 0,
|
|
4032
|
+
left: 0,
|
|
4033
|
+
top: 0
|
|
4034
|
+
}
|
|
4035
|
+
});
|
|
4036
|
+
const canUsePluginMethods$2 = {
|
|
4037
|
+
async: ["zoom", "calcZoom"],
|
|
4038
|
+
sync: []
|
|
4039
|
+
};
|
|
4040
|
+
class Ui extends BaseService {
|
|
4041
|
+
constructor() {
|
|
4042
|
+
super(canUsePluginMethods$2.async.map((methodName) => ({ name: methodName, isAsync: true })));
|
|
4043
|
+
}
|
|
4044
|
+
set(name, value) {
|
|
4045
|
+
const mask = editorService.get("stage")?.mask;
|
|
4046
|
+
if (name === "stageRect") {
|
|
4047
|
+
this.setStageRect(value);
|
|
4048
|
+
return;
|
|
4049
|
+
}
|
|
4050
|
+
if (name === "showGuides") {
|
|
4051
|
+
mask?.showGuides(value);
|
|
4052
|
+
}
|
|
4053
|
+
if (name === "showRule") {
|
|
4054
|
+
mask?.showRule(value);
|
|
4055
|
+
}
|
|
4056
|
+
state[name] = value;
|
|
4057
|
+
}
|
|
4058
|
+
get(name) {
|
|
4059
|
+
return state[name];
|
|
4060
|
+
}
|
|
4061
|
+
async zoom(zoom) {
|
|
4062
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4063
|
+
if (this.get("zoom") < 0.1)
|
|
4064
|
+
this.set("zoom", 0.1);
|
|
4065
|
+
}
|
|
4066
|
+
async calcZoom() {
|
|
4067
|
+
const { stageRect, stageContainerRect } = state;
|
|
4068
|
+
const { height, width } = stageContainerRect;
|
|
4069
|
+
if (!width || !height)
|
|
4070
|
+
return 1;
|
|
4071
|
+
let stageWidth = utils.convertToNumber(stageRect.width, width);
|
|
4072
|
+
let stageHeight = utils.convertToNumber(stageRect.height, height);
|
|
4073
|
+
stageWidth = stageWidth + 30;
|
|
4074
|
+
stageHeight = stageHeight + 30;
|
|
4075
|
+
if (width > stageWidth && height > stageHeight) {
|
|
4076
|
+
return 1;
|
|
4077
|
+
}
|
|
4078
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
4079
|
+
}
|
|
4080
|
+
resetState() {
|
|
4081
|
+
this.set("showSrc", false);
|
|
4082
|
+
this.set("uiSelectMode", false);
|
|
4083
|
+
this.set("zoom", 1);
|
|
4084
|
+
this.set("stageContainerRect", {
|
|
4085
|
+
width: 0,
|
|
4086
|
+
height: 0
|
|
4087
|
+
});
|
|
4088
|
+
}
|
|
4089
|
+
destroy() {
|
|
4090
|
+
this.resetState();
|
|
4091
|
+
this.removeAllListeners();
|
|
4092
|
+
this.removeAllPlugins();
|
|
4093
|
+
}
|
|
4094
|
+
usePlugin(options) {
|
|
4095
|
+
super.usePlugin(options);
|
|
4096
|
+
}
|
|
4097
|
+
async setStageRect(value) {
|
|
4098
|
+
state.stageRect = {
|
|
4099
|
+
...state.stageRect,
|
|
4100
|
+
...value
|
|
4101
|
+
};
|
|
4102
|
+
state.zoom = await this.calcZoom();
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
const uiService = new Ui();
|
|
4106
|
+
|
|
4107
|
+
const root = vue.computed(() => editorService.get("root"));
|
|
4108
|
+
const page = vue.computed(() => editorService.get("page"));
|
|
4109
|
+
const zoom = vue.computed(() => uiService.get("zoom") || 1);
|
|
4110
|
+
const uiSelectMode = vue.computed(() => uiService.get("uiSelectMode"));
|
|
4111
|
+
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
4112
|
+
const useStage = (stageOptions) => {
|
|
4113
|
+
const stage = new StageCore({
|
|
4114
|
+
render: stageOptions.render,
|
|
4115
|
+
runtimeUrl: stageOptions.runtimeUrl,
|
|
4116
|
+
zoom: zoom.value,
|
|
4117
|
+
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
4118
|
+
isContainer: stageOptions.isContainer,
|
|
4119
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
4120
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
4121
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
4122
|
+
disabledDragStart: stageOptions.disabledDragStart,
|
|
4123
|
+
renderType: stageOptions.renderType,
|
|
4124
|
+
canSelect: (el, event, stop) => {
|
|
4125
|
+
if (!stageOptions.canSelect)
|
|
4126
|
+
return true;
|
|
4127
|
+
const elCanSelect = stageOptions.canSelect?.(el);
|
|
4128
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
4129
|
+
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
|
|
4130
|
+
return stop();
|
|
4131
|
+
}
|
|
4132
|
+
return elCanSelect;
|
|
4133
|
+
},
|
|
4134
|
+
moveableOptions: stageOptions.moveableOptions,
|
|
4135
|
+
updateDragEl: stageOptions.updateDragEl,
|
|
4136
|
+
guidesOptions: stageOptions.guidesOptions,
|
|
4137
|
+
disabledMultiSelect: stageOptions.disabledMultiSelect
|
|
4138
|
+
});
|
|
4139
|
+
vue.watch(
|
|
4140
|
+
() => editorService.get("disabledMultiSelect"),
|
|
4141
|
+
(disabledMultiSelect) => {
|
|
4142
|
+
if (disabledMultiSelect) {
|
|
4143
|
+
stage.disableMultiSelect();
|
|
4144
|
+
} else {
|
|
4145
|
+
stage.enableMultiSelect();
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
);
|
|
4149
|
+
stage.mask.setGuides([
|
|
4150
|
+
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
4151
|
+
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
4152
|
+
]);
|
|
4153
|
+
stage.on("page-el-update", () => {
|
|
4154
|
+
editorService.set("stageLoading", false);
|
|
4155
|
+
});
|
|
4156
|
+
stage.on("select", (el) => {
|
|
4157
|
+
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
4158
|
+
return;
|
|
4159
|
+
editorService.select(el.id);
|
|
4160
|
+
});
|
|
4161
|
+
stage.on("highlight", (el) => {
|
|
4162
|
+
editorService.highlight(el.id);
|
|
4163
|
+
});
|
|
4164
|
+
stage.on("multi-select", (els) => {
|
|
4165
|
+
editorService.multiSelect(els.map((el) => el.id));
|
|
4166
|
+
});
|
|
4167
|
+
stage.on("update", (ev) => {
|
|
4168
|
+
if (ev.parentEl) {
|
|
4169
|
+
for (const data of ev.data) {
|
|
4170
|
+
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
4171
|
+
}
|
|
4172
|
+
return;
|
|
4173
|
+
}
|
|
4174
|
+
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
4175
|
+
});
|
|
4176
|
+
stage.on("sort", (ev) => {
|
|
4177
|
+
editorService.sort(ev.src, ev.dist);
|
|
4178
|
+
});
|
|
4179
|
+
stage.on("remove", (ev) => {
|
|
4180
|
+
const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
|
|
4181
|
+
editorService.remove(nodes.filter((node) => Boolean(node)));
|
|
4182
|
+
});
|
|
4183
|
+
stage.on("select-parent", () => {
|
|
4184
|
+
const parent = editorService.get("parent");
|
|
4185
|
+
if (!parent)
|
|
4186
|
+
throw new Error("父节点为空");
|
|
4187
|
+
editorService.select(parent);
|
|
4188
|
+
editorService.get("stage")?.select(parent.id);
|
|
4189
|
+
});
|
|
4190
|
+
stage.on("change-guides", (e) => {
|
|
4191
|
+
uiService.set("showGuides", true);
|
|
4192
|
+
if (!root.value || !page.value)
|
|
4193
|
+
return;
|
|
4194
|
+
const storageKey = getGuideLineKey(
|
|
4195
|
+
e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
4196
|
+
);
|
|
4197
|
+
if (e.guides.length) {
|
|
4198
|
+
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
4199
|
+
} else {
|
|
4200
|
+
globalThis.localStorage.removeItem(storageKey);
|
|
4201
|
+
}
|
|
4202
|
+
});
|
|
4203
|
+
return stage;
|
|
4204
|
+
};
|
|
4205
|
+
|
|
4206
|
+
const useFloatBox = (slideKeys) => {
|
|
4207
|
+
const services = vue.inject("services");
|
|
4208
|
+
const floatBoxStates = vue.ref(
|
|
4209
|
+
slideKeys.value.reduce(
|
|
4210
|
+
(total, cur) => ({
|
|
4211
|
+
...total,
|
|
4212
|
+
[cur]: {
|
|
4213
|
+
status: false,
|
|
4214
|
+
top: 0,
|
|
4215
|
+
left: 0
|
|
4216
|
+
}
|
|
4217
|
+
}),
|
|
4218
|
+
{}
|
|
4219
|
+
)
|
|
4220
|
+
);
|
|
4221
|
+
const showingBoxKeys = vue.computed(
|
|
4222
|
+
() => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
|
|
4223
|
+
);
|
|
4224
|
+
const isDragging = vue.ref(false);
|
|
4225
|
+
const dragstartHandler = () => isDragging.value = true;
|
|
4226
|
+
const dragendHandler = (key, e) => {
|
|
4227
|
+
const navMenuRect = services?.uiService?.get("navMenuRect");
|
|
4228
|
+
floatBoxStates.value[key] = {
|
|
4229
|
+
left: e.clientX,
|
|
4230
|
+
top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0),
|
|
4231
|
+
status: true
|
|
4232
|
+
};
|
|
4233
|
+
isDragging.value = false;
|
|
4234
|
+
};
|
|
4235
|
+
document.body.addEventListener("dragover", (e) => {
|
|
4236
|
+
if (!isDragging.value)
|
|
4237
|
+
return;
|
|
4238
|
+
e.preventDefault();
|
|
4239
|
+
});
|
|
4240
|
+
vue.watch(
|
|
4241
|
+
() => slideKeys.value,
|
|
4242
|
+
(slideKeys2) => {
|
|
4243
|
+
slideKeys2.forEach((key) => {
|
|
4244
|
+
if (!floatBoxStates.value[key]) {
|
|
4245
|
+
floatBoxStates.value[key] = {
|
|
4246
|
+
status: false,
|
|
4247
|
+
top: 0,
|
|
4248
|
+
left: 0
|
|
4249
|
+
};
|
|
4250
|
+
}
|
|
4251
|
+
});
|
|
4252
|
+
},
|
|
4253
|
+
{
|
|
4254
|
+
deep: true,
|
|
4255
|
+
immediate: true
|
|
4256
|
+
}
|
|
4257
|
+
);
|
|
4258
|
+
return {
|
|
4259
|
+
dragstartHandler,
|
|
4260
|
+
dragendHandler,
|
|
4261
|
+
floatBoxStates,
|
|
4262
|
+
showingBoxKeys
|
|
4263
|
+
};
|
|
4264
|
+
};
|
|
4265
|
+
|
|
4266
|
+
const _hoisted_1$p = { class: "m-editor-data-source-fields" };
|
|
4267
|
+
const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
|
|
4268
|
+
const _sfc_main$L = /* @__PURE__ */ vue.defineComponent({
|
|
4269
|
+
...{
|
|
4270
|
+
name: "MFieldsDataSourceFields"
|
|
4271
|
+
},
|
|
4272
|
+
__name: "DataSourceFields",
|
|
4273
|
+
props: /* @__PURE__ */ vue.mergeModels({
|
|
4274
|
+
config: {},
|
|
4275
|
+
model: {},
|
|
4276
|
+
initValues: {},
|
|
4277
|
+
values: {},
|
|
4278
|
+
name: {},
|
|
4279
|
+
prop: {},
|
|
4280
|
+
disabled: { type: Boolean, default: false },
|
|
4281
|
+
size: {},
|
|
4282
|
+
lastValues: {}
|
|
4283
|
+
}, {
|
|
4284
|
+
"width": { default: 670 },
|
|
4285
|
+
"widthModifiers": {},
|
|
4286
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
4287
|
+
"visibleModifiers": {},
|
|
4288
|
+
"visible1": { type: Boolean, ...{ default: false } },
|
|
4289
|
+
"visible1Modifiers": {}
|
|
4290
|
+
}),
|
|
4291
|
+
emits: /* @__PURE__ */ vue.mergeModels(["change"], ["update:width", "update:visible", "update:visible1"]),
|
|
4292
|
+
setup(__props, { emit: __emit }) {
|
|
4293
|
+
const props = __props;
|
|
4294
|
+
const emit = __emit;
|
|
4295
|
+
const services = vue.inject("services");
|
|
4296
|
+
const fieldValues = vue.ref({});
|
|
4297
|
+
const fieldTitle = vue.ref("");
|
|
4298
|
+
const width = vue.useModel(__props, "width");
|
|
4299
|
+
const newHandler = () => {
|
|
4300
|
+
fieldValues.value = {};
|
|
4301
|
+
fieldTitle.value = "新增属性";
|
|
4302
|
+
calcBoxPosition();
|
|
4303
|
+
addDialogVisible.value = true;
|
|
4304
|
+
};
|
|
4305
|
+
const fieldChange = ({ index, ...value }) => {
|
|
4306
|
+
if (index > -1) {
|
|
4307
|
+
props.model[props.name][index] = value;
|
|
4308
|
+
} else {
|
|
4309
|
+
props.model[props.name].push(value);
|
|
4310
|
+
}
|
|
4311
|
+
addDialogVisible.value = false;
|
|
4312
|
+
emit("change", props.model[props.name]);
|
|
4313
|
+
};
|
|
4314
|
+
const fieldColumns = [
|
|
4315
|
+
{
|
|
4316
|
+
label: "属性名称",
|
|
4317
|
+
prop: "title"
|
|
4318
|
+
},
|
|
4319
|
+
{
|
|
4320
|
+
label: "属性key",
|
|
4321
|
+
prop: "name"
|
|
4322
|
+
},
|
|
4323
|
+
{
|
|
4324
|
+
label: "属性描述",
|
|
4325
|
+
prop: "description"
|
|
4326
|
+
},
|
|
4327
|
+
{
|
|
4328
|
+
label: "默认值",
|
|
4329
|
+
prop: "defaultValue",
|
|
4330
|
+
formatter(item, row) {
|
|
3975
4331
|
try {
|
|
3976
4332
|
return JSON.stringify(row.defaultValue);
|
|
3977
4333
|
} catch (e) {
|
|
@@ -3991,7 +4347,8 @@
|
|
|
3991
4347
|
index
|
|
3992
4348
|
};
|
|
3993
4349
|
fieldTitle.value = `编辑${row.title}`;
|
|
3994
|
-
|
|
4350
|
+
calcBoxPosition();
|
|
4351
|
+
addDialogVisible.value = true;
|
|
3995
4352
|
}
|
|
3996
4353
|
},
|
|
3997
4354
|
{
|
|
@@ -4089,7 +4446,6 @@
|
|
|
4089
4446
|
display: (formState, { model }) => model.type === "object" || model.type === "array"
|
|
4090
4447
|
}
|
|
4091
4448
|
];
|
|
4092
|
-
const addFromJsonDialog = vue.ref();
|
|
4093
4449
|
const jsonFromConfig = [
|
|
4094
4450
|
{
|
|
4095
4451
|
name: "data",
|
|
@@ -4105,7 +4461,8 @@
|
|
|
4105
4461
|
});
|
|
4106
4462
|
const newFromJsonHandler = () => {
|
|
4107
4463
|
jsonFromValues.value.data = utils.getDefaultValueFromFields(props.model[props.name]);
|
|
4108
|
-
|
|
4464
|
+
calcBoxPosition();
|
|
4465
|
+
addFromJsonDialogVisible.value = true;
|
|
4109
4466
|
};
|
|
4110
4467
|
const getValueType = (value) => {
|
|
4111
4468
|
if (Array.isArray(value))
|
|
@@ -4151,12 +4508,17 @@
|
|
|
4151
4508
|
try {
|
|
4152
4509
|
const value = JSON.parse(data);
|
|
4153
4510
|
props.model[props.name] = getFieldsConfig(value, props.model[props.name]);
|
|
4154
|
-
|
|
4511
|
+
addFromJsonDialogVisible.value = false;
|
|
4155
4512
|
emit("change", props.model[props.name]);
|
|
4156
4513
|
} catch (e) {
|
|
4157
4514
|
design.tMagicMessage.error(e.message);
|
|
4158
4515
|
}
|
|
4159
4516
|
};
|
|
4517
|
+
const addDialogVisible = vue.useModel(__props, "visible");
|
|
4518
|
+
const addFromJsonDialogVisible = vue.useModel(__props, "visible1");
|
|
4519
|
+
const { height: editorHeight } = useEditorContentHeight();
|
|
4520
|
+
const parentFloating = vue.inject("parentFloating", vue.ref(null));
|
|
4521
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
4160
4522
|
return (_ctx, _cache) => {
|
|
4161
4523
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$p, [
|
|
4162
4524
|
vue.createVNode(vue.unref(table.MagicTable), {
|
|
@@ -4188,28 +4550,49 @@
|
|
|
4188
4550
|
_: 1
|
|
4189
4551
|
}, 8, ["disabled"])
|
|
4190
4552
|
]),
|
|
4191
|
-
vue.createVNode(
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4553
|
+
vue.createVNode(_sfc_main$P, {
|
|
4554
|
+
visible: addDialogVisible.value,
|
|
4555
|
+
"onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
|
|
4556
|
+
width: width.value,
|
|
4557
|
+
"onUpdate:width": _cache[3] || (_cache[3] = ($event) => width.value = $event),
|
|
4558
|
+
height: vue.unref(editorHeight),
|
|
4559
|
+
"onUpdate:height": _cache[4] || (_cache[4] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
4195
4560
|
title: fieldTitle.value,
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4561
|
+
position: vue.unref(boxPosition)
|
|
4562
|
+
}, {
|
|
4563
|
+
body: vue.withCtx(() => [
|
|
4564
|
+
vue.createVNode(vue.unref(form.MFormBox), {
|
|
4565
|
+
"label-width": "80px",
|
|
4566
|
+
title: fieldTitle.value,
|
|
4567
|
+
config: dataSourceFieldsConfig,
|
|
4568
|
+
values: fieldValues.value,
|
|
4569
|
+
parentValues: _ctx.model[_ctx.name],
|
|
4570
|
+
disabled: _ctx.disabled,
|
|
4571
|
+
onSubmit: fieldChange
|
|
4572
|
+
}, null, 8, ["title", "values", "parentValues", "disabled"])
|
|
4573
|
+
]),
|
|
4574
|
+
_: 1
|
|
4575
|
+
}, 8, ["visible", "width", "height", "title", "position"]),
|
|
4576
|
+
vue.createVNode(_sfc_main$P, {
|
|
4577
|
+
visible: addFromJsonDialogVisible.value,
|
|
4578
|
+
"onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
|
|
4200
4579
|
width: width.value,
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
ref_key: "addFromJsonDialog",
|
|
4205
|
-
ref: addFromJsonDialog,
|
|
4580
|
+
"onUpdate:width": _cache[6] || (_cache[6] = ($event) => width.value = $event),
|
|
4581
|
+
height: vue.unref(editorHeight),
|
|
4582
|
+
"onUpdate:height": _cache[7] || (_cache[7] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
4206
4583
|
title: "快速添加数据定义",
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4584
|
+
position: vue.unref(boxPosition)
|
|
4585
|
+
}, {
|
|
4586
|
+
body: vue.withCtx(() => [
|
|
4587
|
+
vue.createVNode(vue.unref(form.MFormBox), {
|
|
4588
|
+
config: jsonFromConfig,
|
|
4589
|
+
values: jsonFromValues.value,
|
|
4590
|
+
disabled: _ctx.disabled,
|
|
4591
|
+
onSubmit: addFromJsonFromChange
|
|
4592
|
+
}, null, 8, ["values", "disabled"])
|
|
4593
|
+
]),
|
|
4594
|
+
_: 1
|
|
4595
|
+
}, 8, ["visible", "width", "height", "position"])
|
|
4213
4596
|
]);
|
|
4214
4597
|
};
|
|
4215
4598
|
}
|
|
@@ -4334,10 +4717,14 @@
|
|
|
4334
4717
|
style: { "margin-left": "5px" },
|
|
4335
4718
|
link: "",
|
|
4336
4719
|
type: showDataSourceFieldSelect.value ? "primary" : "default",
|
|
4337
|
-
icon: vue.unref(iconsVue.Coin),
|
|
4338
4720
|
size: _ctx.size,
|
|
4339
4721
|
onClick: _cache[0] || (_cache[0] = ($event) => showDataSourceFieldSelect.value = !showDataSourceFieldSelect.value)
|
|
4340
|
-
},
|
|
4722
|
+
}, {
|
|
4723
|
+
default: vue.withCtx(() => [
|
|
4724
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
|
|
4725
|
+
]),
|
|
4726
|
+
_: 1
|
|
4727
|
+
}, 8, ["type", "size"])) : vue.createCommentVNode("", true)
|
|
4341
4728
|
]);
|
|
4342
4729
|
};
|
|
4343
4730
|
}
|
|
@@ -4345,7 +4732,7 @@
|
|
|
4345
4732
|
|
|
4346
4733
|
const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
|
|
4347
4734
|
const _hoisted_2$h = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
|
|
4348
|
-
const _hoisted_3$7 = { class: "el-input__inner" };
|
|
4735
|
+
const _hoisted_3$7 = { class: "el-input__inner t-input__inner" };
|
|
4349
4736
|
const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
|
|
4350
4737
|
...{
|
|
4351
4738
|
name: "MFieldsDataSourceInput"
|
|
@@ -4536,7 +4923,7 @@
|
|
|
4536
4923
|
}
|
|
4537
4924
|
), {
|
|
4538
4925
|
suffix: vue.withCtx(() => [
|
|
4539
|
-
vue.createVNode(_sfc_main$
|
|
4926
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
|
|
4540
4927
|
]),
|
|
4541
4928
|
default: vue.withCtx(({ item }) => [
|
|
4542
4929
|
vue.createElementVNode("div", _hoisted_1$n, [
|
|
@@ -4547,7 +4934,7 @@
|
|
|
4547
4934
|
_: 1
|
|
4548
4935
|
}, 16, ["modelValue"])) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
4549
4936
|
key: 1,
|
|
4550
|
-
class: vue.normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
|
|
4937
|
+
class: vue.normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
|
|
4551
4938
|
onMouseup: mouseupHandler
|
|
4552
4939
|
}, [
|
|
4553
4940
|
vue.createElementVNode("div", {
|
|
@@ -4571,7 +4958,7 @@
|
|
|
4571
4958
|
}, 1032, ["size"])) : vue.createCommentVNode("", true)
|
|
4572
4959
|
], 64);
|
|
4573
4960
|
}), 256)),
|
|
4574
|
-
vue.createVNode(_sfc_main$
|
|
4961
|
+
vue.createVNode(_sfc_main$U, {
|
|
4575
4962
|
class: "tmagic-data-source-input-icon",
|
|
4576
4963
|
icon: vue.unref(iconsVue.Coin)
|
|
4577
4964
|
}, null, 8, ["icon"])
|
|
@@ -4582,78 +4969,6 @@
|
|
|
4582
4969
|
}
|
|
4583
4970
|
});
|
|
4584
4971
|
|
|
4585
|
-
const useDataSourceMethod = () => {
|
|
4586
|
-
const codeConfig = vue.ref();
|
|
4587
|
-
const codeBlockEditor = vue.ref();
|
|
4588
|
-
const dataSource = vue.ref();
|
|
4589
|
-
const dataSourceMethod = vue.ref("");
|
|
4590
|
-
return {
|
|
4591
|
-
codeConfig,
|
|
4592
|
-
codeBlockEditor,
|
|
4593
|
-
createCode: async (model) => {
|
|
4594
|
-
codeConfig.value = {
|
|
4595
|
-
name: "",
|
|
4596
|
-
content: `({ params, dataSource, app }) => {
|
|
4597
|
-
// place your code here
|
|
4598
|
-
}`,
|
|
4599
|
-
params: []
|
|
4600
|
-
};
|
|
4601
|
-
await vue.nextTick();
|
|
4602
|
-
dataSource.value = model;
|
|
4603
|
-
dataSourceMethod.value = "";
|
|
4604
|
-
codeBlockEditor.value?.show();
|
|
4605
|
-
},
|
|
4606
|
-
editCode: async (model, methodName) => {
|
|
4607
|
-
const method = model.methods?.find((method2) => method2.name === methodName);
|
|
4608
|
-
if (!method) {
|
|
4609
|
-
design.tMagicMessage.error("获取数据源方法失败");
|
|
4610
|
-
return;
|
|
4611
|
-
}
|
|
4612
|
-
let codeContent = method.content;
|
|
4613
|
-
if (typeof codeContent !== "string") {
|
|
4614
|
-
codeContent = codeContent.toString();
|
|
4615
|
-
}
|
|
4616
|
-
codeConfig.value = {
|
|
4617
|
-
...lodashEs.cloneDeep(method),
|
|
4618
|
-
content: codeContent
|
|
4619
|
-
};
|
|
4620
|
-
await vue.nextTick();
|
|
4621
|
-
dataSource.value = model;
|
|
4622
|
-
dataSourceMethod.value = methodName;
|
|
4623
|
-
codeBlockEditor.value?.show();
|
|
4624
|
-
},
|
|
4625
|
-
deleteCode: async (model, methodName) => {
|
|
4626
|
-
if (!model.methods)
|
|
4627
|
-
return;
|
|
4628
|
-
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
4629
|
-
if (index === -1) {
|
|
4630
|
-
return;
|
|
4631
|
-
}
|
|
4632
|
-
model.methods.splice(index, 1);
|
|
4633
|
-
},
|
|
4634
|
-
submitCode: (values) => {
|
|
4635
|
-
if (!dataSource.value)
|
|
4636
|
-
return;
|
|
4637
|
-
if (!dataSource.value.methods) {
|
|
4638
|
-
dataSource.value.methods = [];
|
|
4639
|
-
}
|
|
4640
|
-
if (values.content) {
|
|
4641
|
-
const parseDSL = getConfig("parseDSL");
|
|
4642
|
-
if (typeof values.content === "string") {
|
|
4643
|
-
values.content = parseDSL(values.content);
|
|
4644
|
-
}
|
|
4645
|
-
}
|
|
4646
|
-
if (dataSourceMethod.value) {
|
|
4647
|
-
const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
|
|
4648
|
-
dataSource.value.methods.splice(index, 1, values);
|
|
4649
|
-
} else {
|
|
4650
|
-
dataSource.value.methods.push(values);
|
|
4651
|
-
}
|
|
4652
|
-
codeBlockEditor.value?.hide();
|
|
4653
|
-
}
|
|
4654
|
-
};
|
|
4655
|
-
};
|
|
4656
|
-
|
|
4657
4972
|
const _hoisted_1$m = { class: "m-editor-data-source-methods" };
|
|
4658
4973
|
const _hoisted_2$g = { class: "m-editor-data-source-methods-footer" };
|
|
4659
4974
|
const _sfc_main$I = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -4745,7 +5060,7 @@
|
|
|
4745
5060
|
_: 1
|
|
4746
5061
|
}, 8, ["disabled"])
|
|
4747
5062
|
]),
|
|
4748
|
-
vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
5063
|
+
vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
|
|
4749
5064
|
key: 0,
|
|
4750
5065
|
ref_key: "codeBlockEditor",
|
|
4751
5066
|
ref: codeBlockEditor,
|
|
@@ -4861,14 +5176,14 @@
|
|
|
4861
5176
|
model: _ctx.model,
|
|
4862
5177
|
onChange: onChangeHandler
|
|
4863
5178
|
}, null, 8, ["config", "model"]),
|
|
4864
|
-
_ctx.model[_ctx.name] && isCustomMethod.value ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
5179
|
+
_ctx.model[_ctx.name] && isCustomMethod.value ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
4865
5180
|
key: 0,
|
|
4866
5181
|
class: "icon",
|
|
4867
5182
|
icon: !notEditable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
|
|
4868
5183
|
onClick: editCodeHandler
|
|
4869
5184
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true)
|
|
4870
5185
|
]),
|
|
4871
|
-
paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
5186
|
+
paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
|
|
4872
5187
|
key: 0,
|
|
4873
5188
|
name: "params",
|
|
4874
5189
|
model: _ctx.model,
|
|
@@ -4877,7 +5192,7 @@
|
|
|
4877
5192
|
"params-config": paramsConfig.value,
|
|
4878
5193
|
onChange: onChangeHandler
|
|
4879
5194
|
}, null, 8, ["model", "size", "disabled", "params-config"])) : vue.createCommentVNode("", true),
|
|
4880
|
-
vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
5195
|
+
vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
|
|
4881
5196
|
key: 1,
|
|
4882
5197
|
ref_key: "codeBlockEditor",
|
|
4883
5198
|
ref: codeBlockEditor,
|
|
@@ -4897,7 +5212,7 @@
|
|
|
4897
5212
|
name: "MFieldsDataSourceMocks"
|
|
4898
5213
|
},
|
|
4899
5214
|
__name: "DataSourceMocks",
|
|
4900
|
-
props: {
|
|
5215
|
+
props: /* @__PURE__ */ vue.mergeModels({
|
|
4901
5216
|
config: {},
|
|
4902
5217
|
model: {},
|
|
4903
5218
|
initValues: {},
|
|
@@ -4907,14 +5222,18 @@
|
|
|
4907
5222
|
disabled: { type: Boolean, default: false },
|
|
4908
5223
|
size: {},
|
|
4909
5224
|
lastValues: {}
|
|
4910
|
-
},
|
|
4911
|
-
|
|
5225
|
+
}, {
|
|
5226
|
+
"width": { default: 670 },
|
|
5227
|
+
"widthModifiers": {},
|
|
5228
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
5229
|
+
"visibleModifiers": {}
|
|
5230
|
+
}),
|
|
5231
|
+
emits: /* @__PURE__ */ vue.mergeModels(["change"], ["update:width", "update:visible"]),
|
|
4912
5232
|
setup(__props, { emit: __emit }) {
|
|
4913
5233
|
const props = __props;
|
|
4914
5234
|
const emit = __emit;
|
|
4915
5235
|
const services = vue.inject("services");
|
|
4916
|
-
const width = vue.
|
|
4917
|
-
const addDialog = vue.ref();
|
|
5236
|
+
const width = vue.useModel(__props, "width");
|
|
4918
5237
|
const drawerTitle = vue.ref("");
|
|
4919
5238
|
const formValues = vue.ref({});
|
|
4920
5239
|
const formConfig = [
|
|
@@ -4979,7 +5298,7 @@
|
|
|
4979
5298
|
const columns = [
|
|
4980
5299
|
{
|
|
4981
5300
|
type: "expand",
|
|
4982
|
-
component: _sfc_main$
|
|
5301
|
+
component: _sfc_main$T,
|
|
4983
5302
|
props: (row) => ({
|
|
4984
5303
|
initValues: row.data,
|
|
4985
5304
|
language: "json",
|
|
@@ -5041,7 +5360,8 @@
|
|
|
5041
5360
|
index
|
|
5042
5361
|
};
|
|
5043
5362
|
drawerTitle.value = `编辑${row.title}`;
|
|
5044
|
-
|
|
5363
|
+
calcBoxPosition();
|
|
5364
|
+
addDialogVisible.value = true;
|
|
5045
5365
|
}
|
|
5046
5366
|
},
|
|
5047
5367
|
{
|
|
@@ -5064,7 +5384,8 @@
|
|
|
5064
5384
|
enable: isFirstRow
|
|
5065
5385
|
};
|
|
5066
5386
|
drawerTitle.value = "新增Mock";
|
|
5067
|
-
|
|
5387
|
+
calcBoxPosition();
|
|
5388
|
+
addDialogVisible.value = true;
|
|
5068
5389
|
};
|
|
5069
5390
|
const formChangeHandler = ({ index, ...value }) => {
|
|
5070
5391
|
if (index > -1) {
|
|
@@ -5072,7 +5393,7 @@
|
|
|
5072
5393
|
} else {
|
|
5073
5394
|
props.model[props.name].push(value);
|
|
5074
5395
|
}
|
|
5075
|
-
|
|
5396
|
+
addDialogVisible.value = false;
|
|
5076
5397
|
emit("change", props.model[props.name]);
|
|
5077
5398
|
};
|
|
5078
5399
|
const toggleValue = (row, key, value, index) => {
|
|
@@ -5087,6 +5408,10 @@
|
|
|
5087
5408
|
index
|
|
5088
5409
|
});
|
|
5089
5410
|
};
|
|
5411
|
+
const addDialogVisible = vue.useModel(__props, "visible");
|
|
5412
|
+
const { height: editorHeight } = useEditorContentHeight();
|
|
5413
|
+
const parentFloating = vue.inject("parentFloating", vue.ref(null));
|
|
5414
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
5090
5415
|
return (_ctx, _cache) => {
|
|
5091
5416
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, [
|
|
5092
5417
|
vue.createVNode(vue.unref(table.MagicTable), {
|
|
@@ -5107,18 +5432,29 @@
|
|
|
5107
5432
|
_: 1
|
|
5108
5433
|
}, 8, ["disabled"])
|
|
5109
5434
|
]),
|
|
5110
|
-
vue.createVNode(
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
"label-width": "120px",
|
|
5114
|
-
title: drawerTitle.value,
|
|
5115
|
-
config: formConfig,
|
|
5116
|
-
values: formValues.value,
|
|
5117
|
-
parentValues: _ctx.model[_ctx.name],
|
|
5118
|
-
disabled: _ctx.disabled,
|
|
5435
|
+
vue.createVNode(_sfc_main$P, {
|
|
5436
|
+
visible: addDialogVisible.value,
|
|
5437
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
|
|
5119
5438
|
width: width.value,
|
|
5120
|
-
|
|
5121
|
-
|
|
5439
|
+
"onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
|
|
5440
|
+
height: vue.unref(editorHeight),
|
|
5441
|
+
"onUpdate:height": _cache[3] || (_cache[3] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
5442
|
+
title: drawerTitle.value,
|
|
5443
|
+
position: vue.unref(boxPosition)
|
|
5444
|
+
}, {
|
|
5445
|
+
body: vue.withCtx(() => [
|
|
5446
|
+
vue.createVNode(vue.unref(form.MFormBox), {
|
|
5447
|
+
ref: "addDialog",
|
|
5448
|
+
"label-width": "120px",
|
|
5449
|
+
config: formConfig,
|
|
5450
|
+
values: formValues.value,
|
|
5451
|
+
parentValues: _ctx.model[_ctx.name],
|
|
5452
|
+
disabled: _ctx.disabled,
|
|
5453
|
+
onSubmit: formChangeHandler
|
|
5454
|
+
}, null, 8, ["values", "parentValues", "disabled"])
|
|
5455
|
+
]),
|
|
5456
|
+
_: 1
|
|
5457
|
+
}, 8, ["visible", "width", "height", "title", "position"])
|
|
5122
5458
|
]);
|
|
5123
5459
|
};
|
|
5124
5460
|
}
|
|
@@ -5583,7 +5919,7 @@
|
|
|
5583
5919
|
_: 1
|
|
5584
5920
|
}, 8, ["size", "disabled", "icon"])
|
|
5585
5921
|
])) : vue.createCommentVNode("", true),
|
|
5586
|
-
_ctx.config.advanced && showCode.value ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
5922
|
+
_ctx.config.advanced && showCode.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
|
|
5587
5923
|
key: 1,
|
|
5588
5924
|
height: "200px",
|
|
5589
5925
|
"init-values": _ctx.model[_ctx.name],
|
|
@@ -5664,7 +6000,7 @@
|
|
|
5664
6000
|
size: _ctx.size,
|
|
5665
6001
|
onChange: changeHandler
|
|
5666
6002
|
}, null, 8, ["model", "size"]),
|
|
5667
|
-
_ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
6003
|
+
_ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
5668
6004
|
key: 0,
|
|
5669
6005
|
class: "icon",
|
|
5670
6006
|
icon: vue.unref(iconsVue.Edit),
|
|
@@ -6149,7 +6485,7 @@
|
|
|
6149
6485
|
disabled: disabled.value
|
|
6150
6486
|
}, {
|
|
6151
6487
|
default: vue.withCtx(() => [
|
|
6152
|
-
_ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
6488
|
+
_ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
6153
6489
|
key: 0,
|
|
6154
6490
|
icon: _ctx.data.icon
|
|
6155
6491
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -6167,7 +6503,7 @@
|
|
|
6167
6503
|
title: _ctx.data.text
|
|
6168
6504
|
}, {
|
|
6169
6505
|
default: vue.withCtx(() => [
|
|
6170
|
-
_ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
6506
|
+
_ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
6171
6507
|
key: 0,
|
|
6172
6508
|
icon: _ctx.data.icon
|
|
6173
6509
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -6255,7 +6591,7 @@
|
|
|
6255
6591
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
6256
6592
|
onClick: addPage
|
|
6257
6593
|
}, [
|
|
6258
|
-
vue.createVNode(_sfc_main$
|
|
6594
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
6259
6595
|
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d));
|
|
6260
6596
|
};
|
|
6261
6597
|
}
|
|
@@ -6367,7 +6703,7 @@
|
|
|
6367
6703
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
6368
6704
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
6369
6705
|
}, [
|
|
6370
|
-
vue.createVNode(_sfc_main$
|
|
6706
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
|
|
6371
6707
|
])) : vue.createCommentVNode("", true),
|
|
6372
6708
|
_ctx.type === vue.unref(schema.NodeType).PAGE && pageLength.value || _ctx.type === vue.unref(schema.NodeType).PAGE_FRAGMENT && pageFragmentLength.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
6373
6709
|
key: 1,
|
|
@@ -6383,7 +6719,7 @@
|
|
|
6383
6719
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
6384
6720
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
6385
6721
|
}, [
|
|
6386
|
-
vue.createVNode(_sfc_main$
|
|
6722
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
|
|
6387
6723
|
])) : vue.createCommentVNode("", true)
|
|
6388
6724
|
], 512);
|
|
6389
6725
|
};
|
|
@@ -6623,7 +6959,7 @@
|
|
|
6623
6959
|
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(vue.unref(schema.NodeType).PAGE))
|
|
6624
6960
|
}, [
|
|
6625
6961
|
vue.createElementVNode("div", null, [
|
|
6626
|
-
vue.createVNode(_sfc_main$
|
|
6962
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
6627
6963
|
]),
|
|
6628
6964
|
_hoisted_3$4
|
|
6629
6965
|
]),
|
|
@@ -6633,7 +6969,7 @@
|
|
|
6633
6969
|
onClick: _cache[1] || (_cache[1] = ($event) => clickHandler(vue.unref(schema.NodeType).PAGE_FRAGMENT))
|
|
6634
6970
|
}, [
|
|
6635
6971
|
vue.createElementVNode("div", null, [
|
|
6636
|
-
vue.createVNode(_sfc_main$
|
|
6972
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
6637
6973
|
]),
|
|
6638
6974
|
_hoisted_4$4
|
|
6639
6975
|
])) : vue.createCommentVNode("", true)
|
|
@@ -6724,7 +7060,7 @@
|
|
|
6724
7060
|
vue.renderSlot(_ctx.$slots, "nav"),
|
|
6725
7061
|
vue.renderSlot(_ctx.$slots, "content-before"),
|
|
6726
7062
|
showSrc.value ? vue.renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
|
|
6727
|
-
vue.createVNode(_sfc_main$
|
|
7063
|
+
vue.createVNode(_sfc_main$T, {
|
|
6728
7064
|
class: "m-editor-content",
|
|
6729
7065
|
"init-values": root.value,
|
|
6730
7066
|
options: vue.unref(codeOptions),
|
|
@@ -7062,87 +7398,33 @@
|
|
|
7062
7398
|
onChange: submit,
|
|
7063
7399
|
onError: errorHandler
|
|
7064
7400
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"]),
|
|
7065
|
-
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
7066
|
-
class: "m-editor-props-panel-src-icon",
|
|
7067
|
-
circle: "",
|
|
7068
|
-
size: "large",
|
|
7069
|
-
title: "源码",
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
(total, cur) => ({
|
|
7093
|
-
...total,
|
|
7094
|
-
[cur]: {
|
|
7095
|
-
status: false,
|
|
7096
|
-
top: 0,
|
|
7097
|
-
left: 0
|
|
7098
|
-
}
|
|
7099
|
-
}),
|
|
7100
|
-
{}
|
|
7101
|
-
)
|
|
7102
|
-
);
|
|
7103
|
-
const showingBoxKeys = vue.computed(
|
|
7104
|
-
() => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
|
|
7105
|
-
);
|
|
7106
|
-
const isDragging = vue.ref(false);
|
|
7107
|
-
const dragstartHandler = () => isDragging.value = true;
|
|
7108
|
-
const dragendHandler = (key, e) => {
|
|
7109
|
-
floatBoxStates.value[key] = {
|
|
7110
|
-
left: e.clientX,
|
|
7111
|
-
top: e.clientY,
|
|
7112
|
-
status: true
|
|
7113
|
-
};
|
|
7114
|
-
isDragging.value = false;
|
|
7115
|
-
};
|
|
7116
|
-
document.body.addEventListener("dragover", (e) => {
|
|
7117
|
-
if (!isDragging.value)
|
|
7118
|
-
return;
|
|
7119
|
-
e.preventDefault();
|
|
7120
|
-
});
|
|
7121
|
-
vue.watch(
|
|
7122
|
-
() => slideKeys.value,
|
|
7123
|
-
(slideKeys2) => {
|
|
7124
|
-
slideKeys2.forEach((key) => {
|
|
7125
|
-
if (floatBoxStates.value[key])
|
|
7126
|
-
return;
|
|
7127
|
-
floatBoxStates.value[key] = {
|
|
7128
|
-
status: false,
|
|
7129
|
-
top: 0,
|
|
7130
|
-
left: 0
|
|
7131
|
-
};
|
|
7132
|
-
});
|
|
7133
|
-
},
|
|
7134
|
-
{
|
|
7135
|
-
deep: true,
|
|
7136
|
-
immediate: true
|
|
7137
|
-
}
|
|
7138
|
-
);
|
|
7139
|
-
return {
|
|
7140
|
-
dragstartHandler,
|
|
7141
|
-
dragendHandler,
|
|
7142
|
-
floatBoxStates,
|
|
7143
|
-
showingBoxKeys
|
|
7144
|
-
};
|
|
7145
|
-
};
|
|
7401
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
7402
|
+
class: "m-editor-props-panel-src-icon",
|
|
7403
|
+
circle: "",
|
|
7404
|
+
size: "large",
|
|
7405
|
+
title: "源码",
|
|
7406
|
+
type: showSrc.value ? "primary" : "",
|
|
7407
|
+
onClick: _cache[0] || (_cache[0] = ($event) => showSrc.value = !showSrc.value)
|
|
7408
|
+
}, {
|
|
7409
|
+
default: vue.withCtx(() => [
|
|
7410
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Document) }, null, 8, ["icon"])
|
|
7411
|
+
]),
|
|
7412
|
+
_: 1
|
|
7413
|
+
}, 8, ["type"]),
|
|
7414
|
+
showSrc.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
|
|
7415
|
+
key: 0,
|
|
7416
|
+
height: `${vue.unref(editorContentHeight)}px`,
|
|
7417
|
+
"init-values": values.value,
|
|
7418
|
+
options: vue.unref(codeOptions),
|
|
7419
|
+
parse: true,
|
|
7420
|
+
onSave: saveCode
|
|
7421
|
+
}, null, 8, ["height", "init-values", "options"])) : vue.createCommentVNode("", true)
|
|
7422
|
+
], 512)), [
|
|
7423
|
+
[vue.vShow, nodes.value.length === 1]
|
|
7424
|
+
]);
|
|
7425
|
+
};
|
|
7426
|
+
}
|
|
7427
|
+
});
|
|
7146
7428
|
|
|
7147
7429
|
const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
|
|
7148
7430
|
...{
|
|
@@ -7269,7 +7551,7 @@
|
|
|
7269
7551
|
onContextmenu: nodeContentmenuHandler,
|
|
7270
7552
|
onMouseenter: mouseenterHandler
|
|
7271
7553
|
}, [
|
|
7272
|
-
vue.createVNode(_sfc_main$
|
|
7554
|
+
vue.createVNode(_sfc_main$U, {
|
|
7273
7555
|
class: "expand-icon",
|
|
7274
7556
|
style: vue.normalizeStyle(hasChildren.value ? "" : "color: transparent; cursor: default"),
|
|
7275
7557
|
icon: expanded.value ? vue.unref(iconsVue.ArrowDown) : vue.unref(iconsVue.ArrowRight),
|
|
@@ -7548,7 +7830,7 @@
|
|
|
7548
7830
|
placement: "bottom"
|
|
7549
7831
|
}, {
|
|
7550
7832
|
default: vue.withCtx(() => [
|
|
7551
|
-
vue.createVNode(_sfc_main$
|
|
7833
|
+
vue.createVNode(_sfc_main$U, {
|
|
7552
7834
|
icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
|
|
7553
7835
|
class: "edit-icon",
|
|
7554
7836
|
onClick: vue.withModifiers(($event) => editCode(`${data.key}`), ["stop"])
|
|
@@ -7563,7 +7845,7 @@
|
|
|
7563
7845
|
placement: "bottom"
|
|
7564
7846
|
}, {
|
|
7565
7847
|
default: vue.withCtx(() => [
|
|
7566
|
-
vue.createVNode(_sfc_main$
|
|
7848
|
+
vue.createVNode(_sfc_main$U, {
|
|
7567
7849
|
icon: vue.unref(iconsVue.Close),
|
|
7568
7850
|
class: "edit-icon",
|
|
7569
7851
|
onClick: vue.withModifiers(($event) => deleteCode(`${data.key}`), ["stop"])
|
|
@@ -7589,8 +7871,7 @@
|
|
|
7589
7871
|
},
|
|
7590
7872
|
__name: "CodeBlockListPanel",
|
|
7591
7873
|
props: {
|
|
7592
|
-
customError: { type: Function }
|
|
7593
|
-
slideType: {}
|
|
7874
|
+
customError: { type: Function }
|
|
7594
7875
|
},
|
|
7595
7876
|
setup(__props) {
|
|
7596
7877
|
const { codeBlockService } = vue.inject("services") || {};
|
|
@@ -7640,15 +7921,14 @@
|
|
|
7640
7921
|
]),
|
|
7641
7922
|
_: 3
|
|
7642
7923
|
}),
|
|
7643
|
-
vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
7924
|
+
vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
|
|
7644
7925
|
key: 0,
|
|
7645
7926
|
ref_key: "codeBlockEditor",
|
|
7646
7927
|
ref: codeBlockEditor,
|
|
7647
7928
|
disabled: !editable.value,
|
|
7648
7929
|
content: vue.unref(codeConfig),
|
|
7649
|
-
slideType: _ctx.slideType,
|
|
7650
7930
|
onSubmit: vue.unref(submitCodeBlockHandler)
|
|
7651
|
-
}, null, 8, ["disabled", "content", "
|
|
7931
|
+
}, null, 8, ["disabled", "content", "onSubmit"])) : vue.createCommentVNode("", true)
|
|
7652
7932
|
], 64);
|
|
7653
7933
|
};
|
|
7654
7934
|
}
|
|
@@ -7659,21 +7939,28 @@
|
|
|
7659
7939
|
name: "MEditorDataSourceConfigPanel"
|
|
7660
7940
|
},
|
|
7661
7941
|
__name: "DataSourceConfigPanel",
|
|
7662
|
-
props: {
|
|
7942
|
+
props: /* @__PURE__ */ vue.mergeModels({
|
|
7663
7943
|
title: {},
|
|
7664
7944
|
values: {},
|
|
7665
|
-
disabled: { type: Boolean }
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7945
|
+
disabled: { type: Boolean }
|
|
7946
|
+
}, {
|
|
7947
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
7948
|
+
"visibleModifiers": {},
|
|
7949
|
+
"width": { default: 670 },
|
|
7950
|
+
"widthModifiers": {}
|
|
7951
|
+
}),
|
|
7952
|
+
emits: /* @__PURE__ */ vue.mergeModels(["submit"], ["update:visible", "update:width"]),
|
|
7669
7953
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
7670
7954
|
const props = __props;
|
|
7955
|
+
const boxVisible = vue.useModel(__props, "visible");
|
|
7956
|
+
const width = vue.useModel(__props, "width");
|
|
7671
7957
|
const emit = __emit;
|
|
7672
7958
|
const services = vue.inject("services");
|
|
7673
|
-
const size = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
|
|
7674
|
-
const fomDrawer = vue.ref();
|
|
7675
7959
|
const initValues = vue.ref({});
|
|
7676
7960
|
const dataSourceConfig = vue.ref([]);
|
|
7961
|
+
const { height: editorHeight } = useEditorContentHeight();
|
|
7962
|
+
const parentFloating = vue.inject("parentFloating", vue.ref(null));
|
|
7963
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
7677
7964
|
vue.watchEffect(() => {
|
|
7678
7965
|
initValues.value = props.values;
|
|
7679
7966
|
dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
|
|
@@ -7686,26 +7973,38 @@
|
|
|
7686
7973
|
};
|
|
7687
7974
|
__expose({
|
|
7688
7975
|
show() {
|
|
7689
|
-
|
|
7976
|
+
calcBoxPosition();
|
|
7977
|
+
boxVisible.value = true;
|
|
7690
7978
|
},
|
|
7691
7979
|
hide() {
|
|
7692
|
-
|
|
7980
|
+
boxVisible.value = false;
|
|
7693
7981
|
}
|
|
7694
7982
|
});
|
|
7695
7983
|
return (_ctx, _cache) => {
|
|
7696
|
-
return vue.openBlock(), vue.createBlock(
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
"
|
|
7984
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$P, {
|
|
7985
|
+
visible: boxVisible.value,
|
|
7986
|
+
"onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
|
|
7987
|
+
width: width.value,
|
|
7988
|
+
"onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
|
|
7989
|
+
height: vue.unref(editorHeight),
|
|
7990
|
+
"onUpdate:height": _cache[2] || (_cache[2] = ($event) => vue.isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
7701
7991
|
title: _ctx.title,
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7992
|
+
position: vue.unref(boxPosition)
|
|
7993
|
+
}, {
|
|
7994
|
+
body: vue.withCtx(() => [
|
|
7995
|
+
vue.createVNode(vue.unref(form.MFormBox), {
|
|
7996
|
+
"label-width": "80px",
|
|
7997
|
+
title: _ctx.title,
|
|
7998
|
+
config: dataSourceConfig.value,
|
|
7999
|
+
values: initValues.value,
|
|
8000
|
+
disabled: _ctx.disabled,
|
|
8001
|
+
style: { "height": "100%" },
|
|
8002
|
+
onSubmit: submitHandler,
|
|
8003
|
+
onError: errorHandler
|
|
8004
|
+
}, null, 8, ["title", "config", "values", "disabled"])
|
|
8005
|
+
]),
|
|
8006
|
+
_: 1
|
|
8007
|
+
}, 8, ["visible", "width", "height", "title", "position"]);
|
|
7709
8008
|
};
|
|
7710
8009
|
}
|
|
7711
8010
|
});
|
|
@@ -7821,7 +8120,7 @@
|
|
|
7821
8120
|
placement: "bottom"
|
|
7822
8121
|
}, {
|
|
7823
8122
|
default: vue.withCtx(() => [
|
|
7824
|
-
vue.createVNode(_sfc_main$
|
|
8123
|
+
vue.createVNode(_sfc_main$U, {
|
|
7825
8124
|
icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
|
|
7826
8125
|
class: "edit-icon",
|
|
7827
8126
|
onClick: vue.withModifiers(($event) => editHandler(`${data.key}`), ["stop"])
|
|
@@ -7836,7 +8135,7 @@
|
|
|
7836
8135
|
placement: "bottom"
|
|
7837
8136
|
}, {
|
|
7838
8137
|
default: vue.withCtx(() => [
|
|
7839
|
-
vue.createVNode(_sfc_main$
|
|
8138
|
+
vue.createVNode(_sfc_main$U, {
|
|
7840
8139
|
icon: vue.unref(iconsVue.Close),
|
|
7841
8140
|
class: "edit-icon",
|
|
7842
8141
|
onClick: vue.withModifiers(($event) => removeHandler(`${data.key}`), ["stop"])
|
|
@@ -7859,9 +8158,6 @@
|
|
|
7859
8158
|
name: "MEditorDataSourceListPanel"
|
|
7860
8159
|
},
|
|
7861
8160
|
__name: "DataSourceListPanel",
|
|
7862
|
-
props: {
|
|
7863
|
-
slideType: {}
|
|
7864
|
-
},
|
|
7865
8161
|
setup(__props) {
|
|
7866
8162
|
const { dataSourceService } = vue.inject("services") || {};
|
|
7867
8163
|
const editDialog = vue.ref();
|
|
@@ -7956,9 +8252,11 @@
|
|
|
7956
8252
|
vue.renderSlot(_ctx.$slots, "data-source-panel-search")
|
|
7957
8253
|
]),
|
|
7958
8254
|
vue.createVNode(_sfc_main$i, {
|
|
8255
|
+
ref_key: "dataSourceList",
|
|
8256
|
+
ref: dataSourceList,
|
|
7959
8257
|
onEdit: editHandler,
|
|
7960
8258
|
onRemove: removeHandler
|
|
7961
|
-
})
|
|
8259
|
+
}, null, 512)
|
|
7962
8260
|
]),
|
|
7963
8261
|
_: 3
|
|
7964
8262
|
}),
|
|
@@ -7968,9 +8266,8 @@
|
|
|
7968
8266
|
disabled: !editable.value,
|
|
7969
8267
|
values: dataSourceValues.value,
|
|
7970
8268
|
title: dialogTitle.value,
|
|
7971
|
-
slideType: _ctx.slideType,
|
|
7972
8269
|
onSubmit: submitDataSourceHandler
|
|
7973
|
-
}, null, 8, ["disabled", "values", "title"
|
|
8270
|
+
}, null, 8, ["disabled", "values", "title"])
|
|
7974
8271
|
], 64);
|
|
7975
8272
|
};
|
|
7976
8273
|
}
|
|
@@ -8372,12 +8669,12 @@
|
|
|
8372
8669
|
};
|
|
8373
8670
|
return (_ctx, _cache) => {
|
|
8374
8671
|
return _ctx.data.type !== "page" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
8375
|
-
_ctx.data.visible === false ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
8672
|
+
_ctx.data.visible === false ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
8376
8673
|
key: 0,
|
|
8377
8674
|
icon: vue.unref(iconsVue.Hide),
|
|
8378
8675
|
onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => setNodeVisible(true), ["stop"])),
|
|
8379
8676
|
title: "点击显示"
|
|
8380
|
-
}, null, 8, ["icon"])) : (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
8677
|
+
}, null, 8, ["icon"])) : (vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
8381
8678
|
key: 1,
|
|
8382
8679
|
icon: vue.unref(iconsVue.View),
|
|
8383
8680
|
onClick: _cache[1] || (_cache[1] = vue.withModifiers(($event) => setNodeVisible(false), ["stop"])),
|
|
@@ -9018,7 +9315,7 @@
|
|
|
9018
9315
|
name: `${index}`
|
|
9019
9316
|
}, {
|
|
9020
9317
|
title: vue.withCtx(() => [
|
|
9021
|
-
vue.createVNode(_sfc_main$
|
|
9318
|
+
vue.createVNode(_sfc_main$U, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
|
|
9022
9319
|
vue.createTextVNode(vue.toDisplayString(group.title), 1)
|
|
9023
9320
|
]),
|
|
9024
9321
|
default: vue.withCtx(() => [
|
|
@@ -9039,7 +9336,7 @@
|
|
|
9039
9336
|
content: item.desc
|
|
9040
9337
|
}, {
|
|
9041
9338
|
default: vue.withCtx(() => [
|
|
9042
|
-
vue.createVNode(_sfc_main$
|
|
9339
|
+
vue.createVNode(_sfc_main$U, {
|
|
9043
9340
|
icon: item.icon
|
|
9044
9341
|
}, null, 8, ["icon"])
|
|
9045
9342
|
]),
|
|
@@ -9090,7 +9387,8 @@
|
|
|
9090
9387
|
setup(__props, { expose: __expose }) {
|
|
9091
9388
|
const props = __props;
|
|
9092
9389
|
const services = vue.inject("services");
|
|
9093
|
-
const
|
|
9390
|
+
const columnLeftWidth = vue.computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
|
|
9391
|
+
const { height: columnLeftHeight } = useEditorContentHeight();
|
|
9094
9392
|
const activeTabName = vue.ref(props.data?.status);
|
|
9095
9393
|
const getItemConfig = (data) => {
|
|
9096
9394
|
const map = {
|
|
@@ -9120,12 +9418,7 @@
|
|
|
9120
9418
|
icon: iconsVue.EditPen,
|
|
9121
9419
|
text: "代码编辑",
|
|
9122
9420
|
component: _sfc_main$k,
|
|
9123
|
-
slots: {}
|
|
9124
|
-
boxComponentConfig: {
|
|
9125
|
-
props: {
|
|
9126
|
-
slideType: "box"
|
|
9127
|
-
}
|
|
9128
|
-
}
|
|
9421
|
+
slots: {}
|
|
9129
9422
|
},
|
|
9130
9423
|
"data-source": {
|
|
9131
9424
|
$key: "data-source",
|
|
@@ -9182,7 +9475,7 @@
|
|
|
9182
9475
|
(...args) => vue.unref(dragstartHandler) && vue.unref(dragstartHandler)(...args)),
|
|
9183
9476
|
onDragend: ($event) => vue.unref(dragendHandler)(config.$key, $event)
|
|
9184
9477
|
}, [
|
|
9185
|
-
config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
9478
|
+
config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
9186
9479
|
key: 0,
|
|
9187
9480
|
icon: config.icon
|
|
9188
9481
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -9315,12 +9608,13 @@
|
|
|
9315
9608
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
9316
9609
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
|
|
9317
9610
|
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
9318
|
-
vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
9611
|
+
vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
|
|
9319
9612
|
key: config.$key ?? index,
|
|
9320
9613
|
visible: vue.unref(floatBoxStates)[config.$key].status,
|
|
9321
9614
|
"onUpdate:visible": ($event) => vue.unref(floatBoxStates)[config.$key].status = $event,
|
|
9322
|
-
|
|
9323
|
-
height:
|
|
9615
|
+
height: vue.unref(columnLeftHeight),
|
|
9616
|
+
"onUpdate:height": _cache[1] || (_cache[1] = ($event) => vue.isRef(columnLeftHeight) ? columnLeftHeight.value = $event : null),
|
|
9617
|
+
width: columnLeftWidth.value,
|
|
9324
9618
|
title: config.text,
|
|
9325
9619
|
position: {
|
|
9326
9620
|
left: vue.unref(floatBoxStates)[config.$key].left,
|
|
@@ -9329,11 +9623,11 @@
|
|
|
9329
9623
|
}, {
|
|
9330
9624
|
body: vue.withCtx(() => [
|
|
9331
9625
|
vue.createElementVNode("div", _hoisted_5$1, [
|
|
9332
|
-
config && vue.unref(floatBoxStates)[config.$key].status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.
|
|
9626
|
+
config && vue.unref(floatBoxStates)[config.$key].status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({ key: 0 }, config.props || {}, vue.toHandlers(config?.listeners || {})), null, 16)) : vue.createCommentVNode("", true)
|
|
9333
9627
|
])
|
|
9334
9628
|
]),
|
|
9335
9629
|
_: 2
|
|
9336
|
-
}, 1032, ["visible", "onUpdate:visible", "width", "title", "position"])) : vue.createCommentVNode("", true)
|
|
9630
|
+
}, 1032, ["visible", "onUpdate:visible", "height", "width", "title", "position"])) : vue.createCommentVNode("", true)
|
|
9337
9631
|
], 64);
|
|
9338
9632
|
}), 256))
|
|
9339
9633
|
]))
|
|
@@ -9665,211 +9959,6 @@
|
|
|
9665
9959
|
}
|
|
9666
9960
|
});
|
|
9667
9961
|
|
|
9668
|
-
const state = vue.reactive({
|
|
9669
|
-
uiSelectMode: false,
|
|
9670
|
-
showSrc: false,
|
|
9671
|
-
zoom: 1,
|
|
9672
|
-
stageContainerRect: {
|
|
9673
|
-
width: 0,
|
|
9674
|
-
height: 0
|
|
9675
|
-
},
|
|
9676
|
-
stageRect: {
|
|
9677
|
-
width: 375,
|
|
9678
|
-
height: 817
|
|
9679
|
-
},
|
|
9680
|
-
columnWidth: {
|
|
9681
|
-
left: 0,
|
|
9682
|
-
right: 0,
|
|
9683
|
-
center: 0
|
|
9684
|
-
},
|
|
9685
|
-
showGuides: true,
|
|
9686
|
-
showRule: true,
|
|
9687
|
-
propsPanelSize: "small",
|
|
9688
|
-
showAddPageButton: true,
|
|
9689
|
-
hideSlideBar: false,
|
|
9690
|
-
navMenuRect: {
|
|
9691
|
-
left: 0,
|
|
9692
|
-
top: 0,
|
|
9693
|
-
width: 0,
|
|
9694
|
-
height: 0
|
|
9695
|
-
},
|
|
9696
|
-
frameworkRect: {
|
|
9697
|
-
width: 0,
|
|
9698
|
-
height: 0,
|
|
9699
|
-
left: 0,
|
|
9700
|
-
top: 0
|
|
9701
|
-
}
|
|
9702
|
-
});
|
|
9703
|
-
const canUsePluginMethods$2 = {
|
|
9704
|
-
async: ["zoom", "calcZoom"],
|
|
9705
|
-
sync: []
|
|
9706
|
-
};
|
|
9707
|
-
class Ui extends BaseService {
|
|
9708
|
-
constructor() {
|
|
9709
|
-
super(canUsePluginMethods$2.async.map((methodName) => ({ name: methodName, isAsync: true })));
|
|
9710
|
-
}
|
|
9711
|
-
set(name, value) {
|
|
9712
|
-
const mask = editorService.get("stage")?.mask;
|
|
9713
|
-
if (name === "stageRect") {
|
|
9714
|
-
this.setStageRect(value);
|
|
9715
|
-
return;
|
|
9716
|
-
}
|
|
9717
|
-
if (name === "showGuides") {
|
|
9718
|
-
mask?.showGuides(value);
|
|
9719
|
-
}
|
|
9720
|
-
if (name === "showRule") {
|
|
9721
|
-
mask?.showRule(value);
|
|
9722
|
-
}
|
|
9723
|
-
state[name] = value;
|
|
9724
|
-
}
|
|
9725
|
-
get(name) {
|
|
9726
|
-
return state[name];
|
|
9727
|
-
}
|
|
9728
|
-
async zoom(zoom) {
|
|
9729
|
-
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
9730
|
-
if (this.get("zoom") < 0.1)
|
|
9731
|
-
this.set("zoom", 0.1);
|
|
9732
|
-
}
|
|
9733
|
-
async calcZoom() {
|
|
9734
|
-
const { stageRect, stageContainerRect } = state;
|
|
9735
|
-
const { height, width } = stageContainerRect;
|
|
9736
|
-
if (!width || !height)
|
|
9737
|
-
return 1;
|
|
9738
|
-
let stageWidth = utils.convertToNumber(stageRect.width, width);
|
|
9739
|
-
let stageHeight = utils.convertToNumber(stageRect.height, height);
|
|
9740
|
-
stageWidth = stageWidth + 30;
|
|
9741
|
-
stageHeight = stageHeight + 30;
|
|
9742
|
-
if (width > stageWidth && height > stageHeight) {
|
|
9743
|
-
return 1;
|
|
9744
|
-
}
|
|
9745
|
-
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
9746
|
-
}
|
|
9747
|
-
resetState() {
|
|
9748
|
-
this.set("showSrc", false);
|
|
9749
|
-
this.set("uiSelectMode", false);
|
|
9750
|
-
this.set("zoom", 1);
|
|
9751
|
-
this.set("stageContainerRect", {
|
|
9752
|
-
width: 0,
|
|
9753
|
-
height: 0
|
|
9754
|
-
});
|
|
9755
|
-
}
|
|
9756
|
-
destroy() {
|
|
9757
|
-
this.resetState();
|
|
9758
|
-
this.removeAllListeners();
|
|
9759
|
-
this.removeAllPlugins();
|
|
9760
|
-
}
|
|
9761
|
-
usePlugin(options) {
|
|
9762
|
-
super.usePlugin(options);
|
|
9763
|
-
}
|
|
9764
|
-
async setStageRect(value) {
|
|
9765
|
-
state.stageRect = {
|
|
9766
|
-
...state.stageRect,
|
|
9767
|
-
...value
|
|
9768
|
-
};
|
|
9769
|
-
state.zoom = await this.calcZoom();
|
|
9770
|
-
}
|
|
9771
|
-
}
|
|
9772
|
-
const uiService = new Ui();
|
|
9773
|
-
|
|
9774
|
-
const root = vue.computed(() => editorService.get("root"));
|
|
9775
|
-
const page = vue.computed(() => editorService.get("page"));
|
|
9776
|
-
const zoom = vue.computed(() => uiService.get("zoom") || 1);
|
|
9777
|
-
const uiSelectMode = vue.computed(() => uiService.get("uiSelectMode"));
|
|
9778
|
-
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
9779
|
-
const useStage = (stageOptions) => {
|
|
9780
|
-
const stage = new StageCore({
|
|
9781
|
-
render: stageOptions.render,
|
|
9782
|
-
runtimeUrl: stageOptions.runtimeUrl,
|
|
9783
|
-
zoom: zoom.value,
|
|
9784
|
-
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
9785
|
-
isContainer: stageOptions.isContainer,
|
|
9786
|
-
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
9787
|
-
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
9788
|
-
containerHighlightType: stageOptions.containerHighlightType,
|
|
9789
|
-
disabledDragStart: stageOptions.disabledDragStart,
|
|
9790
|
-
renderType: stageOptions.renderType,
|
|
9791
|
-
canSelect: (el, event, stop) => {
|
|
9792
|
-
if (!stageOptions.canSelect)
|
|
9793
|
-
return true;
|
|
9794
|
-
const elCanSelect = stageOptions.canSelect?.(el);
|
|
9795
|
-
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
9796
|
-
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
|
|
9797
|
-
return stop();
|
|
9798
|
-
}
|
|
9799
|
-
return elCanSelect;
|
|
9800
|
-
},
|
|
9801
|
-
moveableOptions: stageOptions.moveableOptions,
|
|
9802
|
-
updateDragEl: stageOptions.updateDragEl,
|
|
9803
|
-
guidesOptions: stageOptions.guidesOptions,
|
|
9804
|
-
disabledMultiSelect: stageOptions.disabledMultiSelect
|
|
9805
|
-
});
|
|
9806
|
-
vue.watch(
|
|
9807
|
-
() => editorService.get("disabledMultiSelect"),
|
|
9808
|
-
(disabledMultiSelect) => {
|
|
9809
|
-
if (disabledMultiSelect) {
|
|
9810
|
-
stage.disableMultiSelect();
|
|
9811
|
-
} else {
|
|
9812
|
-
stage.enableMultiSelect();
|
|
9813
|
-
}
|
|
9814
|
-
}
|
|
9815
|
-
);
|
|
9816
|
-
stage.mask.setGuides([
|
|
9817
|
-
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
9818
|
-
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
9819
|
-
]);
|
|
9820
|
-
stage.on("page-el-update", () => {
|
|
9821
|
-
editorService.set("stageLoading", false);
|
|
9822
|
-
});
|
|
9823
|
-
stage.on("select", (el) => {
|
|
9824
|
-
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
9825
|
-
return;
|
|
9826
|
-
editorService.select(el.id);
|
|
9827
|
-
});
|
|
9828
|
-
stage.on("highlight", (el) => {
|
|
9829
|
-
editorService.highlight(el.id);
|
|
9830
|
-
});
|
|
9831
|
-
stage.on("multi-select", (els) => {
|
|
9832
|
-
editorService.multiSelect(els.map((el) => el.id));
|
|
9833
|
-
});
|
|
9834
|
-
stage.on("update", (ev) => {
|
|
9835
|
-
if (ev.parentEl) {
|
|
9836
|
-
for (const data of ev.data) {
|
|
9837
|
-
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
9838
|
-
}
|
|
9839
|
-
return;
|
|
9840
|
-
}
|
|
9841
|
-
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
9842
|
-
});
|
|
9843
|
-
stage.on("sort", (ev) => {
|
|
9844
|
-
editorService.sort(ev.src, ev.dist);
|
|
9845
|
-
});
|
|
9846
|
-
stage.on("remove", (ev) => {
|
|
9847
|
-
const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
|
|
9848
|
-
editorService.remove(nodes.filter((node) => Boolean(node)));
|
|
9849
|
-
});
|
|
9850
|
-
stage.on("select-parent", () => {
|
|
9851
|
-
const parent = editorService.get("parent");
|
|
9852
|
-
if (!parent)
|
|
9853
|
-
throw new Error("父节点为空");
|
|
9854
|
-
editorService.select(parent);
|
|
9855
|
-
editorService.get("stage")?.select(parent.id);
|
|
9856
|
-
});
|
|
9857
|
-
stage.on("change-guides", (e) => {
|
|
9858
|
-
uiService.set("showGuides", true);
|
|
9859
|
-
if (!root.value || !page.value)
|
|
9860
|
-
return;
|
|
9861
|
-
const storageKey = getGuideLineKey(
|
|
9862
|
-
e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
9863
|
-
);
|
|
9864
|
-
if (e.guides.length) {
|
|
9865
|
-
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
9866
|
-
} else {
|
|
9867
|
-
globalThis.localStorage.removeItem(storageKey);
|
|
9868
|
-
}
|
|
9869
|
-
});
|
|
9870
|
-
return stage;
|
|
9871
|
-
};
|
|
9872
|
-
|
|
9873
9962
|
const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
9874
9963
|
__name: "NodeListMenu",
|
|
9875
9964
|
setup(__props) {
|
|
@@ -9952,7 +10041,7 @@
|
|
|
9952
10041
|
]),
|
|
9953
10042
|
_: 1
|
|
9954
10043
|
})) : vue.createCommentVNode("", true),
|
|
9955
|
-
page.value && vue.unref(nodeStatusMap) && buttonVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
10044
|
+
page.value && vue.unref(nodeStatusMap) && buttonVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
|
|
9956
10045
|
key: 1,
|
|
9957
10046
|
ref_key: "box",
|
|
9958
10047
|
ref: box,
|
|
@@ -10025,7 +10114,7 @@
|
|
|
10025
10114
|
}, [
|
|
10026
10115
|
vue.createVNode(vue.unref(design.TMagicIcon), {
|
|
10027
10116
|
class: "m-editor-stage-overlay-close",
|
|
10028
|
-
size: 20,
|
|
10117
|
+
size: "20",
|
|
10029
10118
|
onClick: closeOverlayHandler
|
|
10030
10119
|
}, {
|
|
10031
10120
|
default: vue.withCtx(() => [
|
|
@@ -11672,11 +11761,11 @@
|
|
|
11672
11761
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
11673
11762
|
setConfig(option);
|
|
11674
11763
|
app.component(`${_sfc_main.name || "MEditor"}`, _sfc_main);
|
|
11675
|
-
app.component("magic-code-editor", _sfc_main$
|
|
11764
|
+
app.component("magic-code-editor", _sfc_main$T);
|
|
11676
11765
|
app.component("m-fields-ui-select", _sfc_main$A);
|
|
11677
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
11678
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
11679
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
11766
|
+
app.component("m-fields-code-link", _sfc_main$R);
|
|
11767
|
+
app.component("m-fields-vs-code", _sfc_main$S);
|
|
11768
|
+
app.component("m-fields-code-select", _sfc_main$Q);
|
|
11680
11769
|
app.component("m-fields-code-select-col", _sfc_main$M);
|
|
11681
11770
|
app.component("m-fields-event-select", _sfc_main$E);
|
|
11682
11771
|
app.component("m-fields-data-source-fields", _sfc_main$L);
|
|
@@ -11697,11 +11786,11 @@
|
|
|
11697
11786
|
});
|
|
11698
11787
|
exports.CODE_DRAFT_STORAGE_KEY = CODE_DRAFT_STORAGE_KEY;
|
|
11699
11788
|
exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
|
|
11700
|
-
exports.CodeBlockEditor = _sfc_main$
|
|
11789
|
+
exports.CodeBlockEditor = _sfc_main$O;
|
|
11701
11790
|
exports.CodeBlockList = _sfc_main$l;
|
|
11702
11791
|
exports.CodeBlockListPanel = _sfc_main$k;
|
|
11703
11792
|
exports.CodeDeleteErrorType = CodeDeleteErrorType;
|
|
11704
|
-
exports.CodeSelect = _sfc_main$
|
|
11793
|
+
exports.CodeSelect = _sfc_main$Q;
|
|
11705
11794
|
exports.CodeSelectCol = _sfc_main$M;
|
|
11706
11795
|
exports.ColumnLayout = ColumnLayout;
|
|
11707
11796
|
exports.ComponentListPanel = _sfc_main$b;
|
|
@@ -11718,7 +11807,7 @@
|
|
|
11718
11807
|
exports.EventSelect = _sfc_main$E;
|
|
11719
11808
|
exports.Fixed2Other = Fixed2Other;
|
|
11720
11809
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
11721
|
-
exports.Icon = _sfc_main$
|
|
11810
|
+
exports.Icon = _sfc_main$U;
|
|
11722
11811
|
exports.KeyBindingCommand = KeyBindingCommand;
|
|
11723
11812
|
exports.KeyValue = _sfc_main$C;
|
|
11724
11813
|
exports.Keys = Keys;
|
|
@@ -11730,7 +11819,7 @@
|
|
|
11730
11819
|
exports.PropsPanel = _sfc_main$p;
|
|
11731
11820
|
exports.Resizer = _sfc_main$z;
|
|
11732
11821
|
exports.SplitView = _sfc_main$y;
|
|
11733
|
-
exports.TMagicCodeEditor = _sfc_main$
|
|
11822
|
+
exports.TMagicCodeEditor = _sfc_main$T;
|
|
11734
11823
|
exports.TMagicEditor = _sfc_main;
|
|
11735
11824
|
exports.ToolButton = _sfc_main$x;
|
|
11736
11825
|
exports.UI_SELECT_MODE_EVENT_NAME = UI_SELECT_MODE_EVENT_NAME;
|