@tmagic/editor 1.4.0-beta.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/style.css +22 -26
- package/dist/tmagic-editor.js +977 -798
- package/dist/tmagic-editor.umd.cjs +981 -800
- package/package.json +11 -11
- package/src/components/CodeBlockEditor.vue +75 -101
- package/src/components/FloatingBox.vue +58 -38
- package/src/components/SplitView.vue +46 -35
- 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/index.ts +2 -0
- package/src/hooks/use-code-block-edit.ts +1 -1
- package/src/hooks/use-editor-content-height.ts +20 -0
- package/src/hooks/use-float-box.ts +21 -15
- package/src/hooks/use-next-float-box-position.ts +29 -0
- package/src/hooks/use-window-rect.ts +20 -0
- package/src/layouts/CodeEditor.vue +3 -6
- package/src/layouts/Framework.vue +33 -34
- package/src/layouts/PropsPanel.vue +37 -0
- package/src/layouts/sidebar/Sidebar.vue +17 -15
- 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 +1 -6
- package/src/layouts/workspace/viewer/NodeListMenu.vue +1 -0
- package/src/layouts/workspace/viewer/StageOverlay.vue +3 -1
- package/src/services/stageOverlay.ts +2 -2
- package/src/services/ui.ts +6 -0
- package/src/theme/code-block.scss +0 -19
- package/src/theme/component-list-panel.scss +0 -1
- package/src/theme/floating-box.scss +2 -2
- package/src/theme/icon.scss +7 -1
- package/src/theme/layer-panel.scss +0 -1
- package/src/theme/props-panel.scss +14 -0
- package/src/theme/sidebar.scss +0 -7
- package/src/type.ts +6 -6
- package/types/components/CodeBlockEditor.vue.d.ts +39 -25
- package/types/components/FloatingBox.vue.d.ts +42 -57
- package/types/components/SplitView.vue.d.ts +2 -0
- package/types/fields/DataSourceFields.vue.d.ts +84 -28
- package/types/fields/DataSourceMocks.vue.d.ts +80 -28
- package/types/hooks/index.d.ts +2 -0
- package/types/hooks/use-code-block-edit.d.ts +16 -11
- package/types/hooks/use-data-source-method.d.ts +16 -11
- package/types/hooks/use-editor-content-height.d.ts +3 -0
- package/types/hooks/use-next-float-box-position.d.ts +9 -0
- package/types/hooks/use-window-rect.d.ts +6 -0
- package/types/layouts/sidebar/Sidebar.vue.d.ts +1 -1
- 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/services/stageOverlay.d.ts +1 -1
- package/types/services/ui.d.ts +6 -0
- package/types/type.d.ts +6 -5
package/dist/tmagic-editor.js
CHANGED
|
@@ -1,23 +1,67 @@
|
|
|
1
|
-
import { defineComponent,
|
|
2
|
-
import { FullScreen, Close,
|
|
1
|
+
import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, ref, watch, onMounted, onBeforeUnmount, Teleport, normalizeStyle, computed, reactive, resolveComponent, inject, mergeModels, useModel, nextTick, provide, renderSlot, toDisplayString, createCommentVNode, watchEffect, Fragment, isRef, createTextVNode, mergeProps, renderList, createStaticVNode, withModifiers, toHandlers, resolveDirective, withDirectives, createSlots, markRaw, getCurrentInstance, vShow, Transition, mergeDefaults } from 'vue';
|
|
2
|
+
import { Edit, FullScreen, Close, View, Coin, Delete, Plus, ArrowDown, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Document, Search, ArrowRight, CopyDocument, Files, Hide, Goods, List, EditPen, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
|
|
3
3
|
import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, get, map, has, pick, keys } from 'lodash-es';
|
|
4
4
|
import serialize from 'serialize-javascript';
|
|
5
|
-
import { TMagicButton, TMagicCard, useZIndex, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox,
|
|
5
|
+
import { TMagicIcon, TMagicButton, TMagicCard, useZIndex, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox, getConfig as getConfig$1, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
|
|
6
6
|
import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
|
|
7
7
|
import * as monaco from 'monaco-editor';
|
|
8
8
|
import { HookCodeType, HookType, NodeType, ActionType } from '@tmagic/schema';
|
|
9
|
-
import { MFormBox, MForm, filterFunction, createValues,
|
|
9
|
+
import { MFormBox, MForm, filterFunction, createValues, MCascader, MSelect } from '@tmagic/form';
|
|
10
10
|
import VanillaMoveable from 'moveable';
|
|
11
11
|
import { MagicTable } from '@tmagic/table';
|
|
12
|
-
import { toLine, guid, isPage, isPageFragment, isPop, getNodePath, isNumber, getValueByKeyPath, setValueByKeyPath, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName,
|
|
13
|
-
import Gesto from 'gesto';
|
|
12
|
+
import { toLine, guid, isPage, isPageFragment, isPop, getNodePath, isNumber, getValueByKeyPath, setValueByKeyPath, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
|
|
14
13
|
import { Watcher, DepTargetType, createRelatedCompTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
|
|
15
14
|
export { DepTargetType } from '@tmagic/dep';
|
|
15
|
+
import Gesto from 'gesto';
|
|
16
16
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, RenderType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
17
17
|
import { EventEmitter } from 'events';
|
|
18
18
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
19
19
|
import KeyController from 'keycon';
|
|
20
20
|
|
|
21
|
+
const _hoisted_1$t = ["src"];
|
|
22
|
+
const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
23
|
+
...{
|
|
24
|
+
name: "MEditorIcon"
|
|
25
|
+
},
|
|
26
|
+
__name: "Icon",
|
|
27
|
+
props: {
|
|
28
|
+
icon: {}
|
|
29
|
+
},
|
|
30
|
+
setup(__props) {
|
|
31
|
+
const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
|
|
32
|
+
return (_ctx, _cache) => {
|
|
33
|
+
return !_ctx.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
|
|
34
|
+
key: 0,
|
|
35
|
+
class: "magic-editor-icon"
|
|
36
|
+
}, {
|
|
37
|
+
default: withCtx(() => [
|
|
38
|
+
createVNode(unref(Edit))
|
|
39
|
+
]),
|
|
40
|
+
_: 1
|
|
41
|
+
})) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (openBlock(), createBlock(unref(TMagicIcon), {
|
|
42
|
+
key: 1,
|
|
43
|
+
class: "magic-editor-icon"
|
|
44
|
+
}, {
|
|
45
|
+
default: withCtx(() => [
|
|
46
|
+
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$t)
|
|
47
|
+
]),
|
|
48
|
+
_: 1
|
|
49
|
+
})) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
50
|
+
key: 2,
|
|
51
|
+
class: normalizeClass(["magic-editor-icon", _ctx.icon])
|
|
52
|
+
}, null, 2)) : (openBlock(), createBlock(unref(TMagicIcon), {
|
|
53
|
+
key: 3,
|
|
54
|
+
class: "magic-editor-icon"
|
|
55
|
+
}, {
|
|
56
|
+
default: withCtx(() => [
|
|
57
|
+
(openBlock(), createBlock(resolveDynamicComponent(toRaw(_ctx.icon))))
|
|
58
|
+
]),
|
|
59
|
+
_: 1
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
21
65
|
let $TMAGIC_EDITOR = {};
|
|
22
66
|
const setConfig = (option) => {
|
|
23
67
|
$TMAGIC_EDITOR = option;
|
|
@@ -27,10 +71,10 @@ const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
|
27
71
|
emmetHTML(monaco);
|
|
28
72
|
emmetCSS(monaco, ["css", "scss"]);
|
|
29
73
|
|
|
30
|
-
const _hoisted_1$
|
|
74
|
+
const _hoisted_1$s = {
|
|
31
75
|
class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
|
|
32
76
|
};
|
|
33
|
-
const _sfc_main$
|
|
77
|
+
const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
34
78
|
...{
|
|
35
79
|
name: "MEditorCodeEditor"
|
|
36
80
|
},
|
|
@@ -188,7 +232,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
|
188
232
|
}
|
|
189
233
|
});
|
|
190
234
|
return (_ctx, _cache) => {
|
|
191
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
235
|
+
return openBlock(), createElementBlock("div", _hoisted_1$s, [
|
|
192
236
|
(openBlock(), createBlock(Teleport, {
|
|
193
237
|
to: "body",
|
|
194
238
|
disabled: !fullScreen.value
|
|
@@ -201,9 +245,13 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
|
201
245
|
class: "magic-code-editor-full-screen-icon",
|
|
202
246
|
circle: "",
|
|
203
247
|
size: "small",
|
|
204
|
-
icon: unref(FullScreen),
|
|
205
248
|
onClick: fullScreenHandler
|
|
206
|
-
},
|
|
249
|
+
}, {
|
|
250
|
+
default: withCtx(() => [
|
|
251
|
+
createVNode(_sfc_main$U, { icon: unref(FullScreen) }, null, 8, ["icon"])
|
|
252
|
+
]),
|
|
253
|
+
_: 1
|
|
254
|
+
}),
|
|
207
255
|
createElementVNode("div", {
|
|
208
256
|
ref_key: "codeEditor",
|
|
209
257
|
ref: codeEditor,
|
|
@@ -216,7 +264,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
|
216
264
|
}
|
|
217
265
|
});
|
|
218
266
|
|
|
219
|
-
const _sfc_main$
|
|
267
|
+
const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
220
268
|
...{
|
|
221
269
|
name: "MFieldsVsCode"
|
|
222
270
|
},
|
|
@@ -241,7 +289,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
|
241
289
|
emit("change", v);
|
|
242
290
|
};
|
|
243
291
|
return (_ctx, _cache) => {
|
|
244
|
-
return openBlock(), createBlock(_sfc_main$
|
|
292
|
+
return openBlock(), createBlock(_sfc_main$T, {
|
|
245
293
|
height: _ctx.config.height,
|
|
246
294
|
"init-values": _ctx.model[_ctx.name],
|
|
247
295
|
language: _ctx.config.language,
|
|
@@ -256,7 +304,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
|
256
304
|
}
|
|
257
305
|
});
|
|
258
306
|
|
|
259
|
-
const _sfc_main$
|
|
307
|
+
const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
260
308
|
...{
|
|
261
309
|
name: "MFieldsCodeLink"
|
|
262
310
|
},
|
|
@@ -336,7 +384,7 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
336
384
|
}
|
|
337
385
|
});
|
|
338
386
|
|
|
339
|
-
const _sfc_main$
|
|
387
|
+
const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
340
388
|
...{
|
|
341
389
|
name: "MFieldsCodeSelect"
|
|
342
390
|
},
|
|
@@ -454,40 +502,54 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
454
502
|
}
|
|
455
503
|
});
|
|
456
504
|
|
|
457
|
-
const
|
|
458
|
-
const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
505
|
+
const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
459
506
|
__name: "FloatingBox",
|
|
460
|
-
props: {
|
|
461
|
-
visible: { type: Boolean, default: false },
|
|
507
|
+
props: /* @__PURE__ */ mergeModels({
|
|
462
508
|
position: { default: () => ({ left: 0, top: 0 }) },
|
|
463
|
-
rect: { default: () => ({ width: "auto", height: "auto" }) },
|
|
464
509
|
title: { default: "" },
|
|
465
510
|
beforeClose: {}
|
|
466
|
-
},
|
|
467
|
-
|
|
468
|
-
|
|
511
|
+
}, {
|
|
512
|
+
"width": { default: 0 },
|
|
513
|
+
"widthModifiers": {},
|
|
514
|
+
"height": { default: 0 },
|
|
515
|
+
"heightModifiers": {},
|
|
516
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
517
|
+
"visibleModifiers": {}
|
|
518
|
+
}),
|
|
519
|
+
emits: ["update:width", "update:height", "update:visible"],
|
|
520
|
+
setup(__props, { expose: __expose }) {
|
|
521
|
+
const width = useModel(__props, "width");
|
|
522
|
+
const height = useModel(__props, "height");
|
|
523
|
+
const visible = useModel(__props, "visible");
|
|
469
524
|
const props = __props;
|
|
470
|
-
const emit = __emit;
|
|
471
525
|
const target = ref();
|
|
472
|
-
const
|
|
526
|
+
const titleEl = ref();
|
|
473
527
|
const zIndex = useZIndex();
|
|
474
|
-
const curZIndex = ref(
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
height
|
|
528
|
+
const curZIndex = ref(0);
|
|
529
|
+
const titleHeight = ref(0);
|
|
530
|
+
const bodyHeight = computed(() => {
|
|
531
|
+
if (height.value) {
|
|
532
|
+
return height.value - titleHeight.value;
|
|
533
|
+
}
|
|
534
|
+
if (target.value) {
|
|
535
|
+
return target.value.clientHeight - titleHeight.value;
|
|
536
|
+
}
|
|
537
|
+
return "auto";
|
|
478
538
|
});
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
539
|
+
const services = inject("services");
|
|
540
|
+
const frameworkWidth = computed(() => services?.uiService.get("frameworkRect").width || 0);
|
|
541
|
+
const style = computed(() => {
|
|
542
|
+
let { left } = props.position;
|
|
543
|
+
if (width.value) {
|
|
544
|
+
left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
|
|
545
|
+
}
|
|
546
|
+
return {
|
|
547
|
+
left: `${left}px`,
|
|
548
|
+
top: `${props.position.top}px`,
|
|
549
|
+
width: width.value ? `${width.value}px` : "auto",
|
|
550
|
+
height: height.value ? `${height.value}px` : "auto"
|
|
483
551
|
};
|
|
484
552
|
});
|
|
485
|
-
const style = computed(() => ({
|
|
486
|
-
left: `${props.position.left}px`,
|
|
487
|
-
top: `${props.position.top}px`,
|
|
488
|
-
width: typeof rect.value.width === "string" ? rect.value.width : `${rect.value.width}px`,
|
|
489
|
-
height: typeof rect.value.height === "string" ? rect.value.height : `${rect.value.height}px`
|
|
490
|
-
}));
|
|
491
553
|
let moveable = null;
|
|
492
554
|
const initMoveable = () => {
|
|
493
555
|
moveable = new VanillaMoveable(globalThis.document.body, {
|
|
@@ -499,7 +561,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
499
561
|
keepRatio: false,
|
|
500
562
|
origin: false,
|
|
501
563
|
snappable: true,
|
|
502
|
-
dragTarget:
|
|
564
|
+
dragTarget: titleEl.value,
|
|
503
565
|
dragTargetSelf: false,
|
|
504
566
|
linePadding: 10,
|
|
505
567
|
controlPadding: 10,
|
|
@@ -509,8 +571,8 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
509
571
|
e.target.style.transform = e.transform;
|
|
510
572
|
});
|
|
511
573
|
moveable.on("resize", (e) => {
|
|
512
|
-
|
|
513
|
-
|
|
574
|
+
width.value = e.width;
|
|
575
|
+
height.value = e.height;
|
|
514
576
|
e.target.style.width = `${e.width}px`;
|
|
515
577
|
e.target.style.height = `${e.height}px`;
|
|
516
578
|
e.target.style.transform = e.drag.transform;
|
|
@@ -521,11 +583,21 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
521
583
|
moveable = null;
|
|
522
584
|
};
|
|
523
585
|
watch(
|
|
524
|
-
|
|
525
|
-
async (
|
|
526
|
-
if (
|
|
586
|
+
visible,
|
|
587
|
+
async (visible2) => {
|
|
588
|
+
if (visible2) {
|
|
527
589
|
await nextTick();
|
|
528
|
-
|
|
590
|
+
curZIndex.value = zIndex.nextZIndex();
|
|
591
|
+
const targetRect = target.value?.getBoundingClientRect();
|
|
592
|
+
if (targetRect) {
|
|
593
|
+
width.value = targetRect.width;
|
|
594
|
+
height.value = targetRect.height;
|
|
595
|
+
initMoveable();
|
|
596
|
+
}
|
|
597
|
+
if (titleEl.value) {
|
|
598
|
+
const titleRect = titleEl.value.getBoundingClientRect();
|
|
599
|
+
titleHeight.value = titleRect.height;
|
|
600
|
+
}
|
|
529
601
|
} else {
|
|
530
602
|
destroyMoveable();
|
|
531
603
|
}
|
|
@@ -539,7 +611,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
539
611
|
});
|
|
540
612
|
const hide = (cancel) => {
|
|
541
613
|
if (cancel !== false) {
|
|
542
|
-
|
|
614
|
+
visible.value = false;
|
|
543
615
|
}
|
|
544
616
|
};
|
|
545
617
|
const closeHandler = () => {
|
|
@@ -552,11 +624,14 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
552
624
|
const nextZIndex = () => {
|
|
553
625
|
curZIndex.value = zIndex.nextZIndex();
|
|
554
626
|
};
|
|
627
|
+
provide("parentFloating", target);
|
|
555
628
|
__expose({
|
|
556
|
-
|
|
629
|
+
bodyHeight,
|
|
630
|
+
target,
|
|
631
|
+
titleEl
|
|
557
632
|
});
|
|
558
633
|
return (_ctx, _cache) => {
|
|
559
|
-
return
|
|
634
|
+
return visible.value ? (openBlock(), createBlock(Teleport, {
|
|
560
635
|
key: 0,
|
|
561
636
|
to: "body"
|
|
562
637
|
}, [
|
|
@@ -568,8 +643,8 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
568
643
|
onMousedown: nextZIndex
|
|
569
644
|
}, [
|
|
570
645
|
createElementVNode("div", {
|
|
571
|
-
ref_key: "
|
|
572
|
-
ref:
|
|
646
|
+
ref_key: "titleEl",
|
|
647
|
+
ref: titleEl,
|
|
573
648
|
class: "m-editor-float-box-title"
|
|
574
649
|
}, [
|
|
575
650
|
renderSlot(_ctx.$slots, "title", {}, () => [
|
|
@@ -579,63 +654,120 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
579
654
|
createVNode(unref(TMagicButton), {
|
|
580
655
|
link: "",
|
|
581
656
|
size: "small",
|
|
582
|
-
icon: unref(Close),
|
|
583
657
|
onClick: closeHandler
|
|
584
|
-
},
|
|
658
|
+
}, {
|
|
659
|
+
default: withCtx(() => [
|
|
660
|
+
createVNode(_sfc_main$U, { icon: unref(Close) }, null, 8, ["icon"])
|
|
661
|
+
]),
|
|
662
|
+
_: 1
|
|
663
|
+
})
|
|
585
664
|
])
|
|
586
665
|
], 512),
|
|
587
|
-
createElementVNode("div",
|
|
666
|
+
createElementVNode("div", {
|
|
667
|
+
class: "m-editor-float-box-body",
|
|
668
|
+
style: normalizeStyle({ height: `${bodyHeight.value}px` })
|
|
669
|
+
}, [
|
|
588
670
|
renderSlot(_ctx.$slots, "body")
|
|
589
|
-
])
|
|
671
|
+
], 4)
|
|
590
672
|
], 36)
|
|
591
673
|
])) : createCommentVNode("", true);
|
|
592
674
|
};
|
|
593
675
|
}
|
|
594
676
|
});
|
|
595
677
|
|
|
596
|
-
const
|
|
678
|
+
const useEditorContentHeight = () => {
|
|
679
|
+
const services = inject("services");
|
|
680
|
+
const frameworkHeight = computed(() => services?.uiService.get("frameworkRect").height || 0);
|
|
681
|
+
const navMenuHeight = computed(() => services?.uiService.get("navMenuRect").height || 0);
|
|
682
|
+
const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
|
|
683
|
+
const height = ref(0);
|
|
684
|
+
watchEffect(() => {
|
|
685
|
+
if (height.value > 0 && height.value === editorContentHeight.value)
|
|
686
|
+
return;
|
|
687
|
+
height.value = editorContentHeight.value;
|
|
688
|
+
});
|
|
689
|
+
return {
|
|
690
|
+
height
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
const useNextFloatBoxPosition = (uiService, parent) => {
|
|
695
|
+
const boxPosition = ref({
|
|
696
|
+
left: 0,
|
|
697
|
+
top: 0
|
|
698
|
+
});
|
|
699
|
+
const calcBoxPosition = () => {
|
|
700
|
+
const columnWidth = uiService?.get("columnWidth");
|
|
701
|
+
const navMenuRect = uiService?.get("navMenuRect");
|
|
702
|
+
let left = columnWidth?.left ?? 0;
|
|
703
|
+
if (parent?.value) {
|
|
704
|
+
const rect = parent?.value?.getBoundingClientRect();
|
|
705
|
+
left = (rect?.left ?? 0) + (rect?.width ?? 0);
|
|
706
|
+
}
|
|
707
|
+
boxPosition.value = {
|
|
708
|
+
left,
|
|
709
|
+
top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
|
|
710
|
+
};
|
|
711
|
+
};
|
|
712
|
+
return {
|
|
713
|
+
boxPosition,
|
|
714
|
+
calcBoxPosition
|
|
715
|
+
};
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
const useWindowRect = () => {
|
|
719
|
+
const rect = reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
|
|
720
|
+
const windowResizeHandler = () => {
|
|
721
|
+
rect.width = globalThis.innerWidth;
|
|
722
|
+
rect.height = globalThis.innerHeight;
|
|
723
|
+
};
|
|
724
|
+
globalThis.addEventListener("resize", windowResizeHandler);
|
|
725
|
+
onBeforeUnmount(() => {
|
|
726
|
+
globalThis.removeEventListener("resize", windowResizeHandler);
|
|
727
|
+
});
|
|
728
|
+
return {
|
|
729
|
+
rect
|
|
730
|
+
};
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
const _hoisted_1$r = { style: { "display": "flex", "margin-bottom": "10px" } };
|
|
597
734
|
const _hoisted_2$k = { style: { "flex": "1" } };
|
|
598
735
|
const _hoisted_3$8 = { style: { "flex": "1" } };
|
|
599
736
|
const _hoisted_4$7 = { class: "dialog-footer" };
|
|
600
|
-
const _sfc_main$
|
|
737
|
+
const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
601
738
|
...{
|
|
602
739
|
name: "MEditorCodeBlockEditor"
|
|
603
740
|
},
|
|
604
741
|
__name: "CodeBlockEditor",
|
|
605
|
-
props: {
|
|
742
|
+
props: /* @__PURE__ */ mergeModels({
|
|
606
743
|
content: {},
|
|
607
744
|
disabled: { type: Boolean },
|
|
608
745
|
isDataSource: { type: Boolean },
|
|
609
|
-
dataSourceType: {}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
746
|
+
dataSourceType: {}
|
|
747
|
+
}, {
|
|
748
|
+
"width": { default: 670 },
|
|
749
|
+
"widthModifiers": {},
|
|
750
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
751
|
+
"visibleModifiers": {}
|
|
752
|
+
}),
|
|
753
|
+
emits: /* @__PURE__ */ mergeModels(["submit"], ["update:width", "update:visible"]),
|
|
613
754
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
755
|
+
const width = useModel(__props, "width");
|
|
756
|
+
const boxVisible = useModel(__props, "visible");
|
|
614
757
|
const props = __props;
|
|
615
758
|
const emit = __emit;
|
|
616
759
|
const services = inject("services");
|
|
760
|
+
const { height: codeBlockEditorHeight } = useEditorContentHeight();
|
|
617
761
|
const difVisible = ref(false);
|
|
618
|
-
const
|
|
619
|
-
const windowReizehandler = () => {
|
|
620
|
-
height.value = globalThis.innerHeight;
|
|
621
|
-
};
|
|
622
|
-
globalThis.addEventListener("resize", windowReizehandler);
|
|
623
|
-
onBeforeUnmount(() => {
|
|
624
|
-
globalThis.removeEventListener("resize", windowReizehandler);
|
|
625
|
-
});
|
|
762
|
+
const { rect: windowRect } = useWindowRect();
|
|
626
763
|
const magicVsEditor = ref();
|
|
627
764
|
const diffChange = () => {
|
|
628
|
-
if (!magicVsEditor.value || !
|
|
765
|
+
if (!magicVsEditor.value || !formBox.value?.form) {
|
|
629
766
|
return;
|
|
630
767
|
}
|
|
631
|
-
|
|
768
|
+
formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
|
|
632
769
|
difVisible.value = false;
|
|
633
770
|
};
|
|
634
|
-
const columnWidth = computed(() => services?.uiService.get("columnWidth"));
|
|
635
|
-
const size = computed(
|
|
636
|
-
() => columnWidth.value ? columnWidth.value.center + columnWidth.value.right - (props.isDataSource ? 100 : 0) : 600
|
|
637
|
-
);
|
|
638
|
-
const codeEditorHeight = ref("600px");
|
|
639
771
|
const defaultParamColConfig = {
|
|
640
772
|
type: "row",
|
|
641
773
|
label: "参数类型",
|
|
@@ -718,7 +850,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
718
850
|
name: "content",
|
|
719
851
|
type: "vs-code",
|
|
720
852
|
options: inject("codeOptions", {}),
|
|
721
|
-
height:
|
|
853
|
+
height: "500px",
|
|
722
854
|
onChange: (formState, code) => {
|
|
723
855
|
try {
|
|
724
856
|
getConfig("parseDSL")(code);
|
|
@@ -731,20 +863,13 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
731
863
|
}
|
|
732
864
|
]);
|
|
733
865
|
const submitForm = (values) => {
|
|
866
|
+
changedValue.value = void 0;
|
|
734
867
|
emit("submit", values);
|
|
735
868
|
};
|
|
736
869
|
const errorHandler = (error) => {
|
|
737
870
|
tMagicMessage.error(error.message);
|
|
738
871
|
};
|
|
739
|
-
const
|
|
740
|
-
const openHandler = () => {
|
|
741
|
-
setTimeout(() => {
|
|
742
|
-
if (fomDrawer.value) {
|
|
743
|
-
const height2 = fomDrawer.value?.bodyHeight - 348 - (props.isDataSource ? 50 : 0);
|
|
744
|
-
codeEditorHeight.value = `${height2 > 100 ? height2 : 600}px`;
|
|
745
|
-
}
|
|
746
|
-
});
|
|
747
|
-
};
|
|
872
|
+
const formBox = ref();
|
|
748
873
|
const changedValue = ref();
|
|
749
874
|
const changeHandler = (values) => {
|
|
750
875
|
changedValue.value = values;
|
|
@@ -769,151 +894,134 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
769
894
|
const closedHandler = () => {
|
|
770
895
|
changedValue.value = void 0;
|
|
771
896
|
};
|
|
772
|
-
const
|
|
773
|
-
const
|
|
774
|
-
const floatingBoxBody = ref();
|
|
775
|
-
const boxPosition = computed(() => {
|
|
776
|
-
const columnWidth2 = services?.uiService?.get("columnWidth");
|
|
777
|
-
const navMenuRect = services?.uiService?.get("navMenuRect");
|
|
778
|
-
return {
|
|
779
|
-
left: columnWidth2?.left ?? 0,
|
|
780
|
-
top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
|
|
781
|
-
};
|
|
782
|
-
});
|
|
897
|
+
const parentFloating = inject("parentFloating", ref(null));
|
|
898
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
783
899
|
__expose({
|
|
784
900
|
async show() {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
await nextTick();
|
|
789
|
-
editVisible.value = true;
|
|
790
|
-
fomDrawer.value?.show();
|
|
901
|
+
calcBoxPosition();
|
|
902
|
+
boxVisible.value = true;
|
|
791
903
|
},
|
|
792
|
-
hide() {
|
|
793
|
-
|
|
904
|
+
async hide() {
|
|
905
|
+
boxVisible.value = false;
|
|
794
906
|
}
|
|
795
907
|
});
|
|
796
908
|
return (_ctx, _cache) => {
|
|
797
909
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
798
|
-
createVNode(_sfc_main$
|
|
910
|
+
createVNode(_sfc_main$P, {
|
|
799
911
|
visible: boxVisible.value,
|
|
800
|
-
"onUpdate:visible": _cache[
|
|
801
|
-
|
|
802
|
-
|
|
912
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
|
|
913
|
+
width: width.value,
|
|
914
|
+
"onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
|
|
915
|
+
height: unref(codeBlockEditorHeight),
|
|
916
|
+
"onUpdate:height": _cache[3] || (_cache[3] = ($event) => isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
|
|
917
|
+
title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
|
|
918
|
+
position: unref(boxPosition),
|
|
803
919
|
"before-close": beforeClose
|
|
804
920
|
}, {
|
|
805
921
|
body: withCtx(() => [
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
922
|
+
createVNode(unref(MFormBox), {
|
|
923
|
+
class: "m-editor-code-block-editor",
|
|
924
|
+
ref_key: "formBox",
|
|
925
|
+
ref: formBox,
|
|
926
|
+
"label-width": "80px",
|
|
927
|
+
"close-on-press-escape": false,
|
|
928
|
+
title: _ctx.content.name,
|
|
929
|
+
config: functionConfig.value,
|
|
930
|
+
values: _ctx.content,
|
|
931
|
+
disabled: _ctx.disabled,
|
|
932
|
+
style: { "height": "100%" },
|
|
933
|
+
onChange: changeHandler,
|
|
934
|
+
onSubmit: submitForm,
|
|
935
|
+
onError: errorHandler,
|
|
936
|
+
onClosed: closedHandler
|
|
937
|
+
}, {
|
|
938
|
+
left: withCtx(() => [
|
|
939
|
+
!_ctx.disabled ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
940
|
+
key: 0,
|
|
941
|
+
type: "primary",
|
|
942
|
+
link: "",
|
|
943
|
+
onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
|
|
944
|
+
}, {
|
|
945
|
+
default: withCtx(() => [
|
|
946
|
+
createTextVNode("查看修改")
|
|
947
|
+
]),
|
|
948
|
+
_: 1
|
|
949
|
+
})) : createCommentVNode("", true)
|
|
950
|
+
]),
|
|
951
|
+
_: 1
|
|
952
|
+
}, 8, ["title", "config", "values", "disabled"])
|
|
810
953
|
]),
|
|
811
954
|
_: 1
|
|
812
|
-
}, 8, ["visible", "position"]),
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
class: "m-editor-code-block-editor",
|
|
820
|
-
ref_key: "fomDrawer",
|
|
821
|
-
ref: fomDrawer,
|
|
822
|
-
"label-width": "80px",
|
|
823
|
-
"close-on-press-escape": false,
|
|
824
|
-
title: _ctx.content.name,
|
|
825
|
-
width: size.value,
|
|
826
|
-
config: functionConfig.value,
|
|
827
|
-
values: _ctx.content,
|
|
828
|
-
disabled: _ctx.disabled,
|
|
829
|
-
onChange: changeHandler,
|
|
830
|
-
onSubmit: submitForm,
|
|
831
|
-
onError: errorHandler,
|
|
832
|
-
onOpen: openHandler,
|
|
833
|
-
onClosed: closedHandler
|
|
955
|
+
}, 8, ["visible", "width", "height", "title", "position"]),
|
|
956
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
957
|
+
createVNode(unref(TMagicDialog), {
|
|
958
|
+
title: "查看修改",
|
|
959
|
+
modelValue: difVisible.value,
|
|
960
|
+
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
|
|
961
|
+
fullscreen: ""
|
|
834
962
|
}, {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
link: "",
|
|
839
|
-
onClick: _cache[1] || (_cache[1] = ($event) => difVisible.value = true)
|
|
840
|
-
}, {
|
|
841
|
-
default: withCtx(() => [
|
|
842
|
-
createTextVNode("查看修改")
|
|
843
|
-
]),
|
|
844
|
-
_: 1
|
|
845
|
-
})
|
|
846
|
-
]),
|
|
847
|
-
_: 1
|
|
848
|
-
}, 8, ["title", "width", "config", "values", "disabled"])
|
|
849
|
-
], 8, ["to", "disabled"])) : createCommentVNode("", true),
|
|
850
|
-
createVNode(unref(TMagicDialog), {
|
|
851
|
-
modelValue: difVisible.value,
|
|
852
|
-
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => difVisible.value = $event),
|
|
853
|
-
title: "查看修改",
|
|
854
|
-
fullscreen: ""
|
|
855
|
-
}, {
|
|
856
|
-
footer: withCtx(() => [
|
|
857
|
-
createElementVNode("span", _hoisted_4$7, [
|
|
858
|
-
createVNode(unref(TMagicButton), {
|
|
859
|
-
size: "small",
|
|
860
|
-
onClick: _cache[2] || (_cache[2] = ($event) => difVisible.value = false)
|
|
861
|
-
}, {
|
|
862
|
-
default: withCtx(() => [
|
|
863
|
-
createTextVNode("取消")
|
|
864
|
-
]),
|
|
865
|
-
_: 1
|
|
866
|
-
}),
|
|
867
|
-
createVNode(unref(TMagicButton), {
|
|
868
|
-
size: "small",
|
|
869
|
-
type: "primary",
|
|
870
|
-
onClick: diffChange
|
|
871
|
-
}, {
|
|
872
|
-
default: withCtx(() => [
|
|
873
|
-
createTextVNode("确定")
|
|
874
|
-
]),
|
|
875
|
-
_: 1
|
|
876
|
-
})
|
|
877
|
-
])
|
|
878
|
-
]),
|
|
879
|
-
default: withCtx(() => [
|
|
880
|
-
createElementVNode("div", _hoisted_1$s, [
|
|
881
|
-
createElementVNode("div", _hoisted_2$k, [
|
|
882
|
-
createVNode(unref(TMagicTag), {
|
|
963
|
+
footer: withCtx(() => [
|
|
964
|
+
createElementVNode("span", _hoisted_4$7, [
|
|
965
|
+
createVNode(unref(TMagicButton), {
|
|
883
966
|
size: "small",
|
|
884
|
-
|
|
967
|
+
onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
|
|
885
968
|
}, {
|
|
886
969
|
default: withCtx(() => [
|
|
887
|
-
createTextVNode("
|
|
970
|
+
createTextVNode("取消")
|
|
888
971
|
]),
|
|
889
972
|
_: 1
|
|
890
|
-
})
|
|
891
|
-
|
|
892
|
-
createElementVNode("div", _hoisted_3$8, [
|
|
893
|
-
createVNode(unref(TMagicTag), {
|
|
973
|
+
}),
|
|
974
|
+
createVNode(unref(TMagicButton), {
|
|
894
975
|
size: "small",
|
|
895
|
-
type: "
|
|
976
|
+
type: "primary",
|
|
977
|
+
onClick: diffChange
|
|
896
978
|
}, {
|
|
897
979
|
default: withCtx(() => [
|
|
898
|
-
createTextVNode("
|
|
980
|
+
createTextVNode("确定")
|
|
899
981
|
]),
|
|
900
982
|
_: 1
|
|
901
983
|
})
|
|
902
984
|
])
|
|
903
985
|
]),
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
986
|
+
default: withCtx(() => [
|
|
987
|
+
createElementVNode("div", _hoisted_1$r, [
|
|
988
|
+
createElementVNode("div", _hoisted_2$k, [
|
|
989
|
+
createVNode(unref(TMagicTag), {
|
|
990
|
+
size: "small",
|
|
991
|
+
type: "info"
|
|
992
|
+
}, {
|
|
993
|
+
default: withCtx(() => [
|
|
994
|
+
createTextVNode("修改前")
|
|
995
|
+
]),
|
|
996
|
+
_: 1
|
|
997
|
+
})
|
|
998
|
+
]),
|
|
999
|
+
createElementVNode("div", _hoisted_3$8, [
|
|
1000
|
+
createVNode(unref(TMagicTag), {
|
|
1001
|
+
size: "small",
|
|
1002
|
+
type: "success"
|
|
1003
|
+
}, {
|
|
1004
|
+
default: withCtx(() => [
|
|
1005
|
+
createTextVNode("修改后")
|
|
1006
|
+
]),
|
|
1007
|
+
_: 1
|
|
1008
|
+
})
|
|
1009
|
+
])
|
|
1010
|
+
]),
|
|
1011
|
+
difVisible.value ? (openBlock(), createBlock(_sfc_main$T, {
|
|
1012
|
+
key: 0,
|
|
1013
|
+
ref_key: "magicVsEditor",
|
|
1014
|
+
ref: magicVsEditor,
|
|
1015
|
+
type: "diff",
|
|
1016
|
+
language: "json",
|
|
1017
|
+
initValues: _ctx.content.content,
|
|
1018
|
+
modifiedValues: formBox.value?.form?.values.content,
|
|
1019
|
+
style: normalizeStyle(`height: ${unref(windowRect).height - 150}px`)
|
|
1020
|
+
}, null, 8, ["initValues", "modifiedValues", "style"])) : createCommentVNode("", true)
|
|
1021
|
+
]),
|
|
1022
|
+
_: 1
|
|
1023
|
+
}, 8, ["modelValue"])
|
|
1024
|
+
]))
|
|
917
1025
|
], 64);
|
|
918
1026
|
};
|
|
919
1027
|
}
|
|
@@ -3589,7 +3697,7 @@ const getDefaultConfig = async (addNode, parentNode) => {
|
|
|
3589
3697
|
return newNode;
|
|
3590
3698
|
};
|
|
3591
3699
|
|
|
3592
|
-
const _sfc_main$
|
|
3700
|
+
const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
3593
3701
|
...{
|
|
3594
3702
|
name: "MEditorCodeParams"
|
|
3595
3703
|
},
|
|
@@ -3639,50 +3747,6 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
|
3639
3747
|
}
|
|
3640
3748
|
});
|
|
3641
3749
|
|
|
3642
|
-
const _hoisted_1$r = ["src"];
|
|
3643
|
-
const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
3644
|
-
...{
|
|
3645
|
-
name: "MEditorIcon"
|
|
3646
|
-
},
|
|
3647
|
-
__name: "Icon",
|
|
3648
|
-
props: {
|
|
3649
|
-
icon: {}
|
|
3650
|
-
},
|
|
3651
|
-
setup(__props) {
|
|
3652
|
-
const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
|
|
3653
|
-
return (_ctx, _cache) => {
|
|
3654
|
-
return !_ctx.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
|
|
3655
|
-
key: 0,
|
|
3656
|
-
class: "magic-editor-icon"
|
|
3657
|
-
}, {
|
|
3658
|
-
default: withCtx(() => [
|
|
3659
|
-
createVNode(unref(Edit))
|
|
3660
|
-
]),
|
|
3661
|
-
_: 1
|
|
3662
|
-
})) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (openBlock(), createBlock(unref(TMagicIcon), {
|
|
3663
|
-
key: 1,
|
|
3664
|
-
class: "magic-editor-icon"
|
|
3665
|
-
}, {
|
|
3666
|
-
default: withCtx(() => [
|
|
3667
|
-
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$r)
|
|
3668
|
-
]),
|
|
3669
|
-
_: 1
|
|
3670
|
-
})) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
3671
|
-
key: 2,
|
|
3672
|
-
class: normalizeClass(["magic-editor-icon", _ctx.icon])
|
|
3673
|
-
}, null, 2)) : (openBlock(), createBlock(unref(TMagicIcon), {
|
|
3674
|
-
key: 3,
|
|
3675
|
-
class: "magic-editor-icon"
|
|
3676
|
-
}, {
|
|
3677
|
-
default: withCtx(() => [
|
|
3678
|
-
(openBlock(), createBlock(resolveDynamicComponent(toRaw(_ctx.icon))))
|
|
3679
|
-
]),
|
|
3680
|
-
_: 1
|
|
3681
|
-
}));
|
|
3682
|
-
};
|
|
3683
|
-
}
|
|
3684
|
-
});
|
|
3685
|
-
|
|
3686
3750
|
const useCodeBlockEdit = (codeBlockService) => {
|
|
3687
3751
|
const codeConfig = ref();
|
|
3688
3752
|
const codeId = ref();
|
|
@@ -3693,7 +3757,7 @@ const useCodeBlockEdit = (codeBlockService) => {
|
|
|
3693
3757
|
return;
|
|
3694
3758
|
}
|
|
3695
3759
|
codeConfig.value = {
|
|
3696
|
-
name: "
|
|
3760
|
+
name: "",
|
|
3697
3761
|
content: `({app, params}) => {
|
|
3698
3762
|
// place your code here
|
|
3699
3763
|
}`,
|
|
@@ -3829,14 +3893,14 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
3829
3893
|
size: _ctx.size,
|
|
3830
3894
|
onChange: onParamsChangeHandler
|
|
3831
3895
|
}, null, 8, ["model", "size"]),
|
|
3832
|
-
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$
|
|
3896
|
+
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$U, {
|
|
3833
3897
|
key: 0,
|
|
3834
3898
|
class: "icon",
|
|
3835
3899
|
icon: !notEditable.value ? unref(Edit) : unref(View),
|
|
3836
3900
|
onClick: _cache[0] || (_cache[0] = ($event) => unref(editCode)(_ctx.model[_ctx.name]))
|
|
3837
3901
|
}, null, 8, ["icon"])) : createCommentVNode("", true)
|
|
3838
3902
|
]),
|
|
3839
|
-
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$
|
|
3903
|
+
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$N, {
|
|
3840
3904
|
name: "params",
|
|
3841
3905
|
key: _ctx.model[_ctx.name],
|
|
3842
3906
|
model: _ctx.model,
|
|
@@ -3844,7 +3908,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
3844
3908
|
"params-config": paramsConfig.value,
|
|
3845
3909
|
onChange: onParamsChangeHandler
|
|
3846
3910
|
}, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true),
|
|
3847
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
3911
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
3848
3912
|
key: 1,
|
|
3849
3913
|
ref_key: "codeBlockEditor",
|
|
3850
3914
|
ref: codeBlockEditor,
|
|
@@ -3857,37 +3921,381 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
3857
3921
|
}
|
|
3858
3922
|
});
|
|
3859
3923
|
|
|
3860
|
-
const
|
|
3861
|
-
const
|
|
3862
|
-
const
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3924
|
+
const useDataSourceMethod = () => {
|
|
3925
|
+
const codeConfig = ref();
|
|
3926
|
+
const codeBlockEditor = ref();
|
|
3927
|
+
const dataSource = ref();
|
|
3928
|
+
const dataSourceMethod = ref("");
|
|
3929
|
+
return {
|
|
3930
|
+
codeConfig,
|
|
3931
|
+
codeBlockEditor,
|
|
3932
|
+
createCode: async (model) => {
|
|
3933
|
+
codeConfig.value = {
|
|
3934
|
+
name: "",
|
|
3935
|
+
content: `({ params, dataSource, app }) => {
|
|
3936
|
+
// place your code here
|
|
3937
|
+
}`,
|
|
3938
|
+
params: []
|
|
3939
|
+
};
|
|
3940
|
+
await nextTick();
|
|
3941
|
+
dataSource.value = model;
|
|
3942
|
+
dataSourceMethod.value = "";
|
|
3943
|
+
codeBlockEditor.value?.show();
|
|
3944
|
+
},
|
|
3945
|
+
editCode: async (model, methodName) => {
|
|
3946
|
+
const method = model.methods?.find((method2) => method2.name === methodName);
|
|
3947
|
+
if (!method) {
|
|
3948
|
+
tMagicMessage.error("获取数据源方法失败");
|
|
3949
|
+
return;
|
|
3950
|
+
}
|
|
3951
|
+
let codeContent = method.content;
|
|
3952
|
+
if (typeof codeContent !== "string") {
|
|
3953
|
+
codeContent = codeContent.toString();
|
|
3954
|
+
}
|
|
3955
|
+
codeConfig.value = {
|
|
3956
|
+
...cloneDeep(method),
|
|
3957
|
+
content: codeContent
|
|
3958
|
+
};
|
|
3959
|
+
await nextTick();
|
|
3960
|
+
dataSource.value = model;
|
|
3961
|
+
dataSourceMethod.value = methodName;
|
|
3962
|
+
codeBlockEditor.value?.show();
|
|
3963
|
+
},
|
|
3964
|
+
deleteCode: async (model, methodName) => {
|
|
3965
|
+
if (!model.methods)
|
|
3966
|
+
return;
|
|
3967
|
+
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
3968
|
+
if (index === -1) {
|
|
3969
|
+
return;
|
|
3970
|
+
}
|
|
3971
|
+
model.methods.splice(index, 1);
|
|
3972
|
+
},
|
|
3973
|
+
submitCode: (values) => {
|
|
3974
|
+
if (!dataSource.value)
|
|
3975
|
+
return;
|
|
3976
|
+
if (!dataSource.value.methods) {
|
|
3977
|
+
dataSource.value.methods = [];
|
|
3978
|
+
}
|
|
3979
|
+
if (values.content) {
|
|
3980
|
+
const parseDSL = getConfig("parseDSL");
|
|
3981
|
+
if (typeof values.content === "string") {
|
|
3982
|
+
values.content = parseDSL(values.content);
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
if (dataSourceMethod.value) {
|
|
3986
|
+
const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
|
|
3987
|
+
dataSource.value.methods.splice(index, 1, values);
|
|
3988
|
+
} else {
|
|
3989
|
+
dataSource.value.methods.push(values);
|
|
3990
|
+
}
|
|
3991
|
+
codeBlockEditor.value?.hide();
|
|
3992
|
+
}
|
|
3993
|
+
};
|
|
3994
|
+
};
|
|
3995
|
+
|
|
3996
|
+
const state = reactive({
|
|
3997
|
+
uiSelectMode: false,
|
|
3998
|
+
showSrc: false,
|
|
3999
|
+
zoom: 1,
|
|
4000
|
+
stageContainerRect: {
|
|
4001
|
+
width: 0,
|
|
4002
|
+
height: 0
|
|
4003
|
+
},
|
|
4004
|
+
stageRect: {
|
|
4005
|
+
width: 375,
|
|
4006
|
+
height: 817
|
|
4007
|
+
},
|
|
4008
|
+
columnWidth: {
|
|
4009
|
+
left: 0,
|
|
4010
|
+
right: 0,
|
|
4011
|
+
center: 0
|
|
4012
|
+
},
|
|
4013
|
+
showGuides: true,
|
|
4014
|
+
showRule: true,
|
|
4015
|
+
propsPanelSize: "small",
|
|
4016
|
+
showAddPageButton: true,
|
|
4017
|
+
hideSlideBar: false,
|
|
4018
|
+
navMenuRect: {
|
|
4019
|
+
left: 0,
|
|
4020
|
+
top: 0,
|
|
4021
|
+
width: 0,
|
|
4022
|
+
height: 0
|
|
4023
|
+
},
|
|
4024
|
+
frameworkRect: {
|
|
4025
|
+
width: 0,
|
|
4026
|
+
height: 0,
|
|
4027
|
+
left: 0,
|
|
4028
|
+
top: 0
|
|
4029
|
+
}
|
|
4030
|
+
});
|
|
4031
|
+
const canUsePluginMethods$2 = {
|
|
4032
|
+
async: ["zoom", "calcZoom"],
|
|
4033
|
+
sync: []
|
|
4034
|
+
};
|
|
4035
|
+
class Ui extends BaseService {
|
|
4036
|
+
constructor() {
|
|
4037
|
+
super(canUsePluginMethods$2.async.map((methodName) => ({ name: methodName, isAsync: true })));
|
|
4038
|
+
}
|
|
4039
|
+
set(name, value) {
|
|
4040
|
+
const mask = editorService.get("stage")?.mask;
|
|
4041
|
+
if (name === "stageRect") {
|
|
4042
|
+
this.setStageRect(value);
|
|
4043
|
+
return;
|
|
4044
|
+
}
|
|
4045
|
+
if (name === "showGuides") {
|
|
4046
|
+
mask?.showGuides(value);
|
|
4047
|
+
}
|
|
4048
|
+
if (name === "showRule") {
|
|
4049
|
+
mask?.showRule(value);
|
|
4050
|
+
}
|
|
4051
|
+
state[name] = value;
|
|
4052
|
+
}
|
|
4053
|
+
get(name) {
|
|
4054
|
+
return state[name];
|
|
4055
|
+
}
|
|
4056
|
+
async zoom(zoom) {
|
|
4057
|
+
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
4058
|
+
if (this.get("zoom") < 0.1)
|
|
4059
|
+
this.set("zoom", 0.1);
|
|
4060
|
+
}
|
|
4061
|
+
async calcZoom() {
|
|
4062
|
+
const { stageRect, stageContainerRect } = state;
|
|
4063
|
+
const { height, width } = stageContainerRect;
|
|
4064
|
+
if (!width || !height)
|
|
4065
|
+
return 1;
|
|
4066
|
+
let stageWidth = convertToNumber(stageRect.width, width);
|
|
4067
|
+
let stageHeight = convertToNumber(stageRect.height, height);
|
|
4068
|
+
stageWidth = stageWidth + 30;
|
|
4069
|
+
stageHeight = stageHeight + 30;
|
|
4070
|
+
if (width > stageWidth && height > stageHeight) {
|
|
4071
|
+
return 1;
|
|
4072
|
+
}
|
|
4073
|
+
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
4074
|
+
}
|
|
4075
|
+
resetState() {
|
|
4076
|
+
this.set("showSrc", false);
|
|
4077
|
+
this.set("uiSelectMode", false);
|
|
4078
|
+
this.set("zoom", 1);
|
|
4079
|
+
this.set("stageContainerRect", {
|
|
4080
|
+
width: 0,
|
|
4081
|
+
height: 0
|
|
4082
|
+
});
|
|
4083
|
+
}
|
|
4084
|
+
destroy() {
|
|
4085
|
+
this.resetState();
|
|
4086
|
+
this.removeAllListeners();
|
|
4087
|
+
this.removeAllPlugins();
|
|
4088
|
+
}
|
|
4089
|
+
usePlugin(options) {
|
|
4090
|
+
super.usePlugin(options);
|
|
4091
|
+
}
|
|
4092
|
+
async setStageRect(value) {
|
|
4093
|
+
state.stageRect = {
|
|
4094
|
+
...state.stageRect,
|
|
4095
|
+
...value
|
|
4096
|
+
};
|
|
4097
|
+
state.zoom = await this.calcZoom();
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
const uiService = new Ui();
|
|
4101
|
+
|
|
4102
|
+
const root = computed(() => editorService.get("root"));
|
|
4103
|
+
const page = computed(() => editorService.get("page"));
|
|
4104
|
+
const zoom = computed(() => uiService.get("zoom") || 1);
|
|
4105
|
+
const uiSelectMode = computed(() => uiService.get("uiSelectMode"));
|
|
4106
|
+
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
4107
|
+
const useStage = (stageOptions) => {
|
|
4108
|
+
const stage = new StageCore({
|
|
4109
|
+
render: stageOptions.render,
|
|
4110
|
+
runtimeUrl: stageOptions.runtimeUrl,
|
|
4111
|
+
zoom: zoom.value,
|
|
4112
|
+
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
4113
|
+
isContainer: stageOptions.isContainer,
|
|
4114
|
+
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
4115
|
+
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
4116
|
+
containerHighlightType: stageOptions.containerHighlightType,
|
|
4117
|
+
disabledDragStart: stageOptions.disabledDragStart,
|
|
4118
|
+
renderType: stageOptions.renderType,
|
|
4119
|
+
canSelect: (el, event, stop) => {
|
|
4120
|
+
if (!stageOptions.canSelect)
|
|
4121
|
+
return true;
|
|
4122
|
+
const elCanSelect = stageOptions.canSelect?.(el);
|
|
4123
|
+
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
4124
|
+
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
|
|
4125
|
+
return stop();
|
|
4126
|
+
}
|
|
4127
|
+
return elCanSelect;
|
|
4128
|
+
},
|
|
4129
|
+
moveableOptions: stageOptions.moveableOptions,
|
|
4130
|
+
updateDragEl: stageOptions.updateDragEl,
|
|
4131
|
+
guidesOptions: stageOptions.guidesOptions,
|
|
4132
|
+
disabledMultiSelect: stageOptions.disabledMultiSelect
|
|
4133
|
+
});
|
|
4134
|
+
watch(
|
|
4135
|
+
() => editorService.get("disabledMultiSelect"),
|
|
4136
|
+
(disabledMultiSelect) => {
|
|
4137
|
+
if (disabledMultiSelect) {
|
|
4138
|
+
stage.disableMultiSelect();
|
|
4139
|
+
} else {
|
|
4140
|
+
stage.enableMultiSelect();
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
);
|
|
4144
|
+
stage.mask.setGuides([
|
|
4145
|
+
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
4146
|
+
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
4147
|
+
]);
|
|
4148
|
+
stage.on("page-el-update", () => {
|
|
4149
|
+
editorService.set("stageLoading", false);
|
|
4150
|
+
});
|
|
4151
|
+
stage.on("select", (el) => {
|
|
4152
|
+
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
4153
|
+
return;
|
|
4154
|
+
editorService.select(el.id);
|
|
4155
|
+
});
|
|
4156
|
+
stage.on("highlight", (el) => {
|
|
4157
|
+
editorService.highlight(el.id);
|
|
4158
|
+
});
|
|
4159
|
+
stage.on("multi-select", (els) => {
|
|
4160
|
+
editorService.multiSelect(els.map((el) => el.id));
|
|
4161
|
+
});
|
|
4162
|
+
stage.on("update", (ev) => {
|
|
4163
|
+
if (ev.parentEl) {
|
|
4164
|
+
for (const data of ev.data) {
|
|
4165
|
+
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
4166
|
+
}
|
|
4167
|
+
return;
|
|
4168
|
+
}
|
|
4169
|
+
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
4170
|
+
});
|
|
4171
|
+
stage.on("sort", (ev) => {
|
|
4172
|
+
editorService.sort(ev.src, ev.dist);
|
|
4173
|
+
});
|
|
4174
|
+
stage.on("remove", (ev) => {
|
|
4175
|
+
const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
|
|
4176
|
+
editorService.remove(nodes.filter((node) => Boolean(node)));
|
|
4177
|
+
});
|
|
4178
|
+
stage.on("select-parent", () => {
|
|
4179
|
+
const parent = editorService.get("parent");
|
|
4180
|
+
if (!parent)
|
|
4181
|
+
throw new Error("父节点为空");
|
|
4182
|
+
editorService.select(parent);
|
|
4183
|
+
editorService.get("stage")?.select(parent.id);
|
|
4184
|
+
});
|
|
4185
|
+
stage.on("change-guides", (e) => {
|
|
4186
|
+
uiService.set("showGuides", true);
|
|
4187
|
+
if (!root.value || !page.value)
|
|
4188
|
+
return;
|
|
4189
|
+
const storageKey = getGuideLineKey(
|
|
4190
|
+
e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
4191
|
+
);
|
|
4192
|
+
if (e.guides.length) {
|
|
4193
|
+
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
4194
|
+
} else {
|
|
4195
|
+
globalThis.localStorage.removeItem(storageKey);
|
|
4196
|
+
}
|
|
4197
|
+
});
|
|
4198
|
+
return stage;
|
|
4199
|
+
};
|
|
4200
|
+
|
|
4201
|
+
const useFloatBox = (slideKeys) => {
|
|
4202
|
+
const services = inject("services");
|
|
4203
|
+
const floatBoxStates = ref(
|
|
4204
|
+
slideKeys.value.reduce(
|
|
4205
|
+
(total, cur) => ({
|
|
4206
|
+
...total,
|
|
4207
|
+
[cur]: {
|
|
4208
|
+
status: false,
|
|
4209
|
+
top: 0,
|
|
4210
|
+
left: 0
|
|
4211
|
+
}
|
|
4212
|
+
}),
|
|
4213
|
+
{}
|
|
4214
|
+
)
|
|
4215
|
+
);
|
|
4216
|
+
const showingBoxKeys = computed(
|
|
4217
|
+
() => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
|
|
4218
|
+
);
|
|
4219
|
+
const isDragging = ref(false);
|
|
4220
|
+
const dragstartHandler = () => isDragging.value = true;
|
|
4221
|
+
const dragendHandler = (key, e) => {
|
|
4222
|
+
const navMenuRect = services?.uiService?.get("navMenuRect");
|
|
4223
|
+
floatBoxStates.value[key] = {
|
|
4224
|
+
left: e.clientX,
|
|
4225
|
+
top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0),
|
|
4226
|
+
status: true
|
|
4227
|
+
};
|
|
4228
|
+
isDragging.value = false;
|
|
4229
|
+
};
|
|
4230
|
+
document.body.addEventListener("dragover", (e) => {
|
|
4231
|
+
if (!isDragging.value)
|
|
4232
|
+
return;
|
|
4233
|
+
e.preventDefault();
|
|
4234
|
+
});
|
|
4235
|
+
watch(
|
|
4236
|
+
() => slideKeys.value,
|
|
4237
|
+
(slideKeys2) => {
|
|
4238
|
+
slideKeys2.forEach((key) => {
|
|
4239
|
+
if (!floatBoxStates.value[key]) {
|
|
4240
|
+
floatBoxStates.value[key] = {
|
|
4241
|
+
status: false,
|
|
4242
|
+
top: 0,
|
|
4243
|
+
left: 0
|
|
4244
|
+
};
|
|
4245
|
+
}
|
|
4246
|
+
});
|
|
4247
|
+
},
|
|
4248
|
+
{
|
|
4249
|
+
deep: true,
|
|
4250
|
+
immediate: true
|
|
4251
|
+
}
|
|
4252
|
+
);
|
|
4253
|
+
return {
|
|
4254
|
+
dragstartHandler,
|
|
4255
|
+
dragendHandler,
|
|
4256
|
+
floatBoxStates,
|
|
4257
|
+
showingBoxKeys
|
|
4258
|
+
};
|
|
4259
|
+
};
|
|
4260
|
+
|
|
4261
|
+
const _hoisted_1$p = { class: "m-editor-data-source-fields" };
|
|
4262
|
+
const _hoisted_2$i = { class: "m-editor-data-source-fields-footer" };
|
|
4263
|
+
const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
4264
|
+
...{
|
|
4265
|
+
name: "MFieldsDataSourceFields"
|
|
3877
4266
|
},
|
|
3878
|
-
|
|
4267
|
+
__name: "DataSourceFields",
|
|
4268
|
+
props: /* @__PURE__ */ mergeModels({
|
|
4269
|
+
config: {},
|
|
4270
|
+
model: {},
|
|
4271
|
+
initValues: {},
|
|
4272
|
+
values: {},
|
|
4273
|
+
name: {},
|
|
4274
|
+
prop: {},
|
|
4275
|
+
disabled: { type: Boolean, default: false },
|
|
4276
|
+
size: {},
|
|
4277
|
+
lastValues: {}
|
|
4278
|
+
}, {
|
|
4279
|
+
"width": { default: 670 },
|
|
4280
|
+
"widthModifiers": {},
|
|
4281
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
4282
|
+
"visibleModifiers": {},
|
|
4283
|
+
"visible1": { type: Boolean, ...{ default: false } },
|
|
4284
|
+
"visible1Modifiers": {}
|
|
4285
|
+
}),
|
|
4286
|
+
emits: /* @__PURE__ */ mergeModels(["change"], ["update:width", "update:visible", "update:visible1"]),
|
|
3879
4287
|
setup(__props, { emit: __emit }) {
|
|
3880
4288
|
const props = __props;
|
|
3881
4289
|
const emit = __emit;
|
|
3882
4290
|
const services = inject("services");
|
|
3883
|
-
const addDialog = ref();
|
|
3884
4291
|
const fieldValues = ref({});
|
|
3885
4292
|
const fieldTitle = ref("");
|
|
3886
|
-
const width =
|
|
4293
|
+
const width = useModel(__props, "width");
|
|
3887
4294
|
const newHandler = () => {
|
|
3888
4295
|
fieldValues.value = {};
|
|
3889
4296
|
fieldTitle.value = "新增属性";
|
|
3890
|
-
|
|
4297
|
+
calcBoxPosition();
|
|
4298
|
+
addDialogVisible.value = true;
|
|
3891
4299
|
};
|
|
3892
4300
|
const fieldChange = ({ index, ...value }) => {
|
|
3893
4301
|
if (index > -1) {
|
|
@@ -3895,7 +4303,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
3895
4303
|
} else {
|
|
3896
4304
|
props.model[props.name].push(value);
|
|
3897
4305
|
}
|
|
3898
|
-
|
|
4306
|
+
addDialogVisible.value = false;
|
|
3899
4307
|
emit("change", props.model[props.name]);
|
|
3900
4308
|
};
|
|
3901
4309
|
const fieldColumns = [
|
|
@@ -3934,7 +4342,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
3934
4342
|
index
|
|
3935
4343
|
};
|
|
3936
4344
|
fieldTitle.value = `编辑${row.title}`;
|
|
3937
|
-
|
|
4345
|
+
calcBoxPosition();
|
|
4346
|
+
addDialogVisible.value = true;
|
|
3938
4347
|
}
|
|
3939
4348
|
},
|
|
3940
4349
|
{
|
|
@@ -4032,7 +4441,6 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4032
4441
|
display: (formState, { model }) => model.type === "object" || model.type === "array"
|
|
4033
4442
|
}
|
|
4034
4443
|
];
|
|
4035
|
-
const addFromJsonDialog = ref();
|
|
4036
4444
|
const jsonFromConfig = [
|
|
4037
4445
|
{
|
|
4038
4446
|
name: "data",
|
|
@@ -4048,7 +4456,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4048
4456
|
});
|
|
4049
4457
|
const newFromJsonHandler = () => {
|
|
4050
4458
|
jsonFromValues.value.data = getDefaultValueFromFields(props.model[props.name]);
|
|
4051
|
-
|
|
4459
|
+
calcBoxPosition();
|
|
4460
|
+
addFromJsonDialogVisible.value = true;
|
|
4052
4461
|
};
|
|
4053
4462
|
const getValueType = (value) => {
|
|
4054
4463
|
if (Array.isArray(value))
|
|
@@ -4094,12 +4503,17 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4094
4503
|
try {
|
|
4095
4504
|
const value = JSON.parse(data);
|
|
4096
4505
|
props.model[props.name] = getFieldsConfig(value, props.model[props.name]);
|
|
4097
|
-
|
|
4506
|
+
addFromJsonDialogVisible.value = false;
|
|
4098
4507
|
emit("change", props.model[props.name]);
|
|
4099
4508
|
} catch (e) {
|
|
4100
4509
|
tMagicMessage.error(e.message);
|
|
4101
4510
|
}
|
|
4102
4511
|
};
|
|
4512
|
+
const addDialogVisible = useModel(__props, "visible");
|
|
4513
|
+
const addFromJsonDialogVisible = useModel(__props, "visible1");
|
|
4514
|
+
const { height: editorHeight } = useEditorContentHeight();
|
|
4515
|
+
const parentFloating = inject("parentFloating", ref(null));
|
|
4516
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
4103
4517
|
return (_ctx, _cache) => {
|
|
4104
4518
|
return openBlock(), createElementBlock("div", _hoisted_1$p, [
|
|
4105
4519
|
createVNode(unref(MagicTable), {
|
|
@@ -4131,28 +4545,49 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4131
4545
|
_: 1
|
|
4132
4546
|
}, 8, ["disabled"])
|
|
4133
4547
|
]),
|
|
4134
|
-
createVNode(
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4548
|
+
createVNode(_sfc_main$P, {
|
|
4549
|
+
visible: addDialogVisible.value,
|
|
4550
|
+
"onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
|
|
4551
|
+
width: width.value,
|
|
4552
|
+
"onUpdate:width": _cache[3] || (_cache[3] = ($event) => width.value = $event),
|
|
4553
|
+
height: unref(editorHeight),
|
|
4554
|
+
"onUpdate:height": _cache[4] || (_cache[4] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
4138
4555
|
title: fieldTitle.value,
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4556
|
+
position: unref(boxPosition)
|
|
4557
|
+
}, {
|
|
4558
|
+
body: withCtx(() => [
|
|
4559
|
+
createVNode(unref(MFormBox), {
|
|
4560
|
+
"label-width": "80px",
|
|
4561
|
+
title: fieldTitle.value,
|
|
4562
|
+
config: dataSourceFieldsConfig,
|
|
4563
|
+
values: fieldValues.value,
|
|
4564
|
+
parentValues: _ctx.model[_ctx.name],
|
|
4565
|
+
disabled: _ctx.disabled,
|
|
4566
|
+
onSubmit: fieldChange
|
|
4567
|
+
}, null, 8, ["title", "values", "parentValues", "disabled"])
|
|
4568
|
+
]),
|
|
4569
|
+
_: 1
|
|
4570
|
+
}, 8, ["visible", "width", "height", "title", "position"]),
|
|
4571
|
+
createVNode(_sfc_main$P, {
|
|
4572
|
+
visible: addFromJsonDialogVisible.value,
|
|
4573
|
+
"onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
|
|
4143
4574
|
width: width.value,
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
ref_key: "addFromJsonDialog",
|
|
4148
|
-
ref: addFromJsonDialog,
|
|
4575
|
+
"onUpdate:width": _cache[6] || (_cache[6] = ($event) => width.value = $event),
|
|
4576
|
+
height: unref(editorHeight),
|
|
4577
|
+
"onUpdate:height": _cache[7] || (_cache[7] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
4149
4578
|
title: "快速添加数据定义",
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4579
|
+
position: unref(boxPosition)
|
|
4580
|
+
}, {
|
|
4581
|
+
body: withCtx(() => [
|
|
4582
|
+
createVNode(unref(MFormBox), {
|
|
4583
|
+
config: jsonFromConfig,
|
|
4584
|
+
values: jsonFromValues.value,
|
|
4585
|
+
disabled: _ctx.disabled,
|
|
4586
|
+
onSubmit: addFromJsonFromChange
|
|
4587
|
+
}, null, 8, ["values", "disabled"])
|
|
4588
|
+
]),
|
|
4589
|
+
_: 1
|
|
4590
|
+
}, 8, ["visible", "width", "height", "position"])
|
|
4156
4591
|
]);
|
|
4157
4592
|
};
|
|
4158
4593
|
}
|
|
@@ -4277,10 +4712,14 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
|
4277
4712
|
style: { "margin-left": "5px" },
|
|
4278
4713
|
link: "",
|
|
4279
4714
|
type: showDataSourceFieldSelect.value ? "primary" : "default",
|
|
4280
|
-
icon: unref(Coin),
|
|
4281
4715
|
size: _ctx.size,
|
|
4282
4716
|
onClick: _cache[0] || (_cache[0] = ($event) => showDataSourceFieldSelect.value = !showDataSourceFieldSelect.value)
|
|
4283
|
-
},
|
|
4717
|
+
}, {
|
|
4718
|
+
default: withCtx(() => [
|
|
4719
|
+
createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
|
|
4720
|
+
]),
|
|
4721
|
+
_: 1
|
|
4722
|
+
}, 8, ["type", "size"])) : createCommentVNode("", true)
|
|
4284
4723
|
]);
|
|
4285
4724
|
};
|
|
4286
4725
|
}
|
|
@@ -4288,7 +4727,7 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
|
4288
4727
|
|
|
4289
4728
|
const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
|
|
4290
4729
|
const _hoisted_2$h = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
|
|
4291
|
-
const _hoisted_3$7 = { class: "el-input__inner" };
|
|
4730
|
+
const _hoisted_3$7 = { class: "el-input__inner t-input__inner" };
|
|
4292
4731
|
const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
4293
4732
|
...{
|
|
4294
4733
|
name: "MFieldsDataSourceInput"
|
|
@@ -4479,7 +4918,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4479
4918
|
}
|
|
4480
4919
|
), {
|
|
4481
4920
|
suffix: withCtx(() => [
|
|
4482
|
-
createVNode(_sfc_main$
|
|
4921
|
+
createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
|
|
4483
4922
|
]),
|
|
4484
4923
|
default: withCtx(({ item }) => [
|
|
4485
4924
|
createElementVNode("div", _hoisted_1$n, [
|
|
@@ -4490,7 +4929,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4490
4929
|
_: 1
|
|
4491
4930
|
}, 16, ["modelValue"])) : (openBlock(), createElementBlock("div", {
|
|
4492
4931
|
key: 1,
|
|
4493
|
-
class: normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
|
|
4932
|
+
class: normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
|
|
4494
4933
|
onMouseup: mouseupHandler
|
|
4495
4934
|
}, [
|
|
4496
4935
|
createElementVNode("div", {
|
|
@@ -4514,7 +4953,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4514
4953
|
}, 1032, ["size"])) : createCommentVNode("", true)
|
|
4515
4954
|
], 64);
|
|
4516
4955
|
}), 256)),
|
|
4517
|
-
createVNode(_sfc_main$
|
|
4956
|
+
createVNode(_sfc_main$U, {
|
|
4518
4957
|
class: "tmagic-data-source-input-icon",
|
|
4519
4958
|
icon: unref(Coin)
|
|
4520
4959
|
}, null, 8, ["icon"])
|
|
@@ -4525,78 +4964,6 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4525
4964
|
}
|
|
4526
4965
|
});
|
|
4527
4966
|
|
|
4528
|
-
const useDataSourceMethod = () => {
|
|
4529
|
-
const codeConfig = ref();
|
|
4530
|
-
const codeBlockEditor = ref();
|
|
4531
|
-
const dataSource = ref();
|
|
4532
|
-
const dataSourceMethod = ref("");
|
|
4533
|
-
return {
|
|
4534
|
-
codeConfig,
|
|
4535
|
-
codeBlockEditor,
|
|
4536
|
-
createCode: async (model) => {
|
|
4537
|
-
codeConfig.value = {
|
|
4538
|
-
name: "",
|
|
4539
|
-
content: `({ params, dataSource, app }) => {
|
|
4540
|
-
// place your code here
|
|
4541
|
-
}`,
|
|
4542
|
-
params: []
|
|
4543
|
-
};
|
|
4544
|
-
await nextTick();
|
|
4545
|
-
dataSource.value = model;
|
|
4546
|
-
dataSourceMethod.value = "";
|
|
4547
|
-
codeBlockEditor.value?.show();
|
|
4548
|
-
},
|
|
4549
|
-
editCode: async (model, methodName) => {
|
|
4550
|
-
const method = model.methods?.find((method2) => method2.name === methodName);
|
|
4551
|
-
if (!method) {
|
|
4552
|
-
tMagicMessage.error("获取数据源方法失败");
|
|
4553
|
-
return;
|
|
4554
|
-
}
|
|
4555
|
-
let codeContent = method.content;
|
|
4556
|
-
if (typeof codeContent !== "string") {
|
|
4557
|
-
codeContent = codeContent.toString();
|
|
4558
|
-
}
|
|
4559
|
-
codeConfig.value = {
|
|
4560
|
-
...cloneDeep(method),
|
|
4561
|
-
content: codeContent
|
|
4562
|
-
};
|
|
4563
|
-
await nextTick();
|
|
4564
|
-
dataSource.value = model;
|
|
4565
|
-
dataSourceMethod.value = methodName;
|
|
4566
|
-
codeBlockEditor.value?.show();
|
|
4567
|
-
},
|
|
4568
|
-
deleteCode: async (model, methodName) => {
|
|
4569
|
-
if (!model.methods)
|
|
4570
|
-
return;
|
|
4571
|
-
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
4572
|
-
if (index === -1) {
|
|
4573
|
-
return;
|
|
4574
|
-
}
|
|
4575
|
-
model.methods.splice(index, 1);
|
|
4576
|
-
},
|
|
4577
|
-
submitCode: (values) => {
|
|
4578
|
-
if (!dataSource.value)
|
|
4579
|
-
return;
|
|
4580
|
-
if (!dataSource.value.methods) {
|
|
4581
|
-
dataSource.value.methods = [];
|
|
4582
|
-
}
|
|
4583
|
-
if (values.content) {
|
|
4584
|
-
const parseDSL = getConfig("parseDSL");
|
|
4585
|
-
if (typeof values.content === "string") {
|
|
4586
|
-
values.content = parseDSL(values.content);
|
|
4587
|
-
}
|
|
4588
|
-
}
|
|
4589
|
-
if (dataSourceMethod.value) {
|
|
4590
|
-
const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
|
|
4591
|
-
dataSource.value.methods.splice(index, 1, values);
|
|
4592
|
-
} else {
|
|
4593
|
-
dataSource.value.methods.push(values);
|
|
4594
|
-
}
|
|
4595
|
-
codeBlockEditor.value?.hide();
|
|
4596
|
-
}
|
|
4597
|
-
};
|
|
4598
|
-
};
|
|
4599
|
-
|
|
4600
4967
|
const _hoisted_1$m = { class: "m-editor-data-source-methods" };
|
|
4601
4968
|
const _hoisted_2$g = { class: "m-editor-data-source-methods-footer" };
|
|
4602
4969
|
const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
@@ -4688,7 +5055,7 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
4688
5055
|
_: 1
|
|
4689
5056
|
}, 8, ["disabled"])
|
|
4690
5057
|
]),
|
|
4691
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
5058
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
4692
5059
|
key: 0,
|
|
4693
5060
|
ref_key: "codeBlockEditor",
|
|
4694
5061
|
ref: codeBlockEditor,
|
|
@@ -4804,14 +5171,14 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
4804
5171
|
model: _ctx.model,
|
|
4805
5172
|
onChange: onChangeHandler
|
|
4806
5173
|
}, null, 8, ["config", "model"]),
|
|
4807
|
-
_ctx.model[_ctx.name] && isCustomMethod.value ? (openBlock(), createBlock(_sfc_main$
|
|
5174
|
+
_ctx.model[_ctx.name] && isCustomMethod.value ? (openBlock(), createBlock(_sfc_main$U, {
|
|
4808
5175
|
key: 0,
|
|
4809
5176
|
class: "icon",
|
|
4810
5177
|
icon: !notEditable.value ? unref(Edit) : unref(View),
|
|
4811
5178
|
onClick: editCodeHandler
|
|
4812
5179
|
}, null, 8, ["icon"])) : createCommentVNode("", true)
|
|
4813
5180
|
]),
|
|
4814
|
-
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$
|
|
5181
|
+
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$N, {
|
|
4815
5182
|
key: 0,
|
|
4816
5183
|
name: "params",
|
|
4817
5184
|
model: _ctx.model,
|
|
@@ -4820,7 +5187,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
4820
5187
|
"params-config": paramsConfig.value,
|
|
4821
5188
|
onChange: onChangeHandler
|
|
4822
5189
|
}, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true),
|
|
4823
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
5190
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
4824
5191
|
key: 1,
|
|
4825
5192
|
ref_key: "codeBlockEditor",
|
|
4826
5193
|
ref: codeBlockEditor,
|
|
@@ -4840,7 +5207,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
4840
5207
|
name: "MFieldsDataSourceMocks"
|
|
4841
5208
|
},
|
|
4842
5209
|
__name: "DataSourceMocks",
|
|
4843
|
-
props: {
|
|
5210
|
+
props: /* @__PURE__ */ mergeModels({
|
|
4844
5211
|
config: {},
|
|
4845
5212
|
model: {},
|
|
4846
5213
|
initValues: {},
|
|
@@ -4850,14 +5217,18 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
4850
5217
|
disabled: { type: Boolean, default: false },
|
|
4851
5218
|
size: {},
|
|
4852
5219
|
lastValues: {}
|
|
4853
|
-
},
|
|
4854
|
-
|
|
5220
|
+
}, {
|
|
5221
|
+
"width": { default: 670 },
|
|
5222
|
+
"widthModifiers": {},
|
|
5223
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
5224
|
+
"visibleModifiers": {}
|
|
5225
|
+
}),
|
|
5226
|
+
emits: /* @__PURE__ */ mergeModels(["change"], ["update:width", "update:visible"]),
|
|
4855
5227
|
setup(__props, { emit: __emit }) {
|
|
4856
5228
|
const props = __props;
|
|
4857
5229
|
const emit = __emit;
|
|
4858
5230
|
const services = inject("services");
|
|
4859
|
-
const width =
|
|
4860
|
-
const addDialog = ref();
|
|
5231
|
+
const width = useModel(__props, "width");
|
|
4861
5232
|
const drawerTitle = ref("");
|
|
4862
5233
|
const formValues = ref({});
|
|
4863
5234
|
const formConfig = [
|
|
@@ -4922,7 +5293,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
4922
5293
|
const columns = [
|
|
4923
5294
|
{
|
|
4924
5295
|
type: "expand",
|
|
4925
|
-
component: _sfc_main$
|
|
5296
|
+
component: _sfc_main$T,
|
|
4926
5297
|
props: (row) => ({
|
|
4927
5298
|
initValues: row.data,
|
|
4928
5299
|
language: "json",
|
|
@@ -4984,7 +5355,8 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
4984
5355
|
index
|
|
4985
5356
|
};
|
|
4986
5357
|
drawerTitle.value = `编辑${row.title}`;
|
|
4987
|
-
|
|
5358
|
+
calcBoxPosition();
|
|
5359
|
+
addDialogVisible.value = true;
|
|
4988
5360
|
}
|
|
4989
5361
|
},
|
|
4990
5362
|
{
|
|
@@ -5007,7 +5379,8 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5007
5379
|
enable: isFirstRow
|
|
5008
5380
|
};
|
|
5009
5381
|
drawerTitle.value = "新增Mock";
|
|
5010
|
-
|
|
5382
|
+
calcBoxPosition();
|
|
5383
|
+
addDialogVisible.value = true;
|
|
5011
5384
|
};
|
|
5012
5385
|
const formChangeHandler = ({ index, ...value }) => {
|
|
5013
5386
|
if (index > -1) {
|
|
@@ -5015,7 +5388,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5015
5388
|
} else {
|
|
5016
5389
|
props.model[props.name].push(value);
|
|
5017
5390
|
}
|
|
5018
|
-
|
|
5391
|
+
addDialogVisible.value = false;
|
|
5019
5392
|
emit("change", props.model[props.name]);
|
|
5020
5393
|
};
|
|
5021
5394
|
const toggleValue = (row, key, value, index) => {
|
|
@@ -5030,6 +5403,10 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5030
5403
|
index
|
|
5031
5404
|
});
|
|
5032
5405
|
};
|
|
5406
|
+
const addDialogVisible = useModel(__props, "visible");
|
|
5407
|
+
const { height: editorHeight } = useEditorContentHeight();
|
|
5408
|
+
const parentFloating = inject("parentFloating", ref(null));
|
|
5409
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
5033
5410
|
return (_ctx, _cache) => {
|
|
5034
5411
|
return openBlock(), createElementBlock("div", _hoisted_1$k, [
|
|
5035
5412
|
createVNode(unref(MagicTable), {
|
|
@@ -5050,18 +5427,29 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5050
5427
|
_: 1
|
|
5051
5428
|
}, 8, ["disabled"])
|
|
5052
5429
|
]),
|
|
5053
|
-
createVNode(
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
"label-width": "120px",
|
|
5057
|
-
title: drawerTitle.value,
|
|
5058
|
-
config: formConfig,
|
|
5059
|
-
values: formValues.value,
|
|
5060
|
-
parentValues: _ctx.model[_ctx.name],
|
|
5061
|
-
disabled: _ctx.disabled,
|
|
5430
|
+
createVNode(_sfc_main$P, {
|
|
5431
|
+
visible: addDialogVisible.value,
|
|
5432
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
|
|
5062
5433
|
width: width.value,
|
|
5063
|
-
|
|
5064
|
-
|
|
5434
|
+
"onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
|
|
5435
|
+
height: unref(editorHeight),
|
|
5436
|
+
"onUpdate:height": _cache[3] || (_cache[3] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
5437
|
+
title: drawerTitle.value,
|
|
5438
|
+
position: unref(boxPosition)
|
|
5439
|
+
}, {
|
|
5440
|
+
body: withCtx(() => [
|
|
5441
|
+
createVNode(unref(MFormBox), {
|
|
5442
|
+
ref: "addDialog",
|
|
5443
|
+
"label-width": "120px",
|
|
5444
|
+
config: formConfig,
|
|
5445
|
+
values: formValues.value,
|
|
5446
|
+
parentValues: _ctx.model[_ctx.name],
|
|
5447
|
+
disabled: _ctx.disabled,
|
|
5448
|
+
onSubmit: formChangeHandler
|
|
5449
|
+
}, null, 8, ["values", "parentValues", "disabled"])
|
|
5450
|
+
]),
|
|
5451
|
+
_: 1
|
|
5452
|
+
}, 8, ["visible", "width", "height", "title", "position"])
|
|
5065
5453
|
]);
|
|
5066
5454
|
};
|
|
5067
5455
|
}
|
|
@@ -5526,7 +5914,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
5526
5914
|
_: 1
|
|
5527
5915
|
}, 8, ["size", "disabled", "icon"])
|
|
5528
5916
|
])) : createCommentVNode("", true),
|
|
5529
|
-
_ctx.config.advanced && showCode.value ? (openBlock(), createBlock(_sfc_main$
|
|
5917
|
+
_ctx.config.advanced && showCode.value ? (openBlock(), createBlock(_sfc_main$T, {
|
|
5530
5918
|
key: 1,
|
|
5531
5919
|
height: "200px",
|
|
5532
5920
|
"init-values": _ctx.model[_ctx.name],
|
|
@@ -5607,7 +5995,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
5607
5995
|
size: _ctx.size,
|
|
5608
5996
|
onChange: changeHandler
|
|
5609
5997
|
}, null, 8, ["model", "size"]),
|
|
5610
|
-
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$
|
|
5998
|
+
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$U, {
|
|
5611
5999
|
key: 0,
|
|
5612
6000
|
class: "icon",
|
|
5613
6001
|
icon: unref(Edit),
|
|
@@ -5840,6 +6228,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5840
6228
|
},
|
|
5841
6229
|
__name: "SplitView",
|
|
5842
6230
|
props: {
|
|
6231
|
+
width: {},
|
|
5843
6232
|
left: {},
|
|
5844
6233
|
right: {},
|
|
5845
6234
|
minLeft: { default: 46 },
|
|
@@ -5856,17 +6245,19 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5856
6245
|
const el = ref();
|
|
5857
6246
|
const hasLeft = computed(() => typeof props.left !== "undefined");
|
|
5858
6247
|
const hasRight = computed(() => typeof props.right !== "undefined");
|
|
5859
|
-
const
|
|
6248
|
+
const center = ref(0);
|
|
6249
|
+
let clientWidth = 0;
|
|
6250
|
+
const getCenterWidth = (l = 0, r = 0) => {
|
|
5860
6251
|
let right = r > 0 ? r : 0;
|
|
5861
6252
|
let left = l > 0 ? l : 0;
|
|
5862
|
-
let center2 =
|
|
6253
|
+
let center2 = clientWidth - left - right;
|
|
5863
6254
|
if (center2 < props.minCenter) {
|
|
5864
6255
|
center2 = props.minCenter;
|
|
5865
6256
|
if (right > center2 + props.minRight) {
|
|
5866
|
-
right =
|
|
6257
|
+
right = clientWidth - left - center2;
|
|
5867
6258
|
} else {
|
|
5868
6259
|
right = props.minRight;
|
|
5869
|
-
left =
|
|
6260
|
+
left = clientWidth - right - center2;
|
|
5870
6261
|
}
|
|
5871
6262
|
}
|
|
5872
6263
|
return {
|
|
@@ -5875,36 +6266,43 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5875
6266
|
right
|
|
5876
6267
|
};
|
|
5877
6268
|
};
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
clientWidth = contentRect.width;
|
|
5882
|
-
let left = props.left || 0;
|
|
5883
|
-
let right = props.right || 0;
|
|
5884
|
-
if (left > clientWidth) {
|
|
5885
|
-
left = clientWidth / 3;
|
|
5886
|
-
}
|
|
5887
|
-
if (right > clientWidth) {
|
|
5888
|
-
right = clientWidth / 3;
|
|
5889
|
-
}
|
|
5890
|
-
const columnWidth = getCenterWidth(clientWidth, left, right);
|
|
5891
|
-
center.value = columnWidth.center;
|
|
5892
|
-
emit("change", {
|
|
5893
|
-
left: columnWidth.left,
|
|
5894
|
-
center: center.value,
|
|
5895
|
-
right: columnWidth.right
|
|
5896
|
-
});
|
|
6269
|
+
const widthChange = (width) => {
|
|
6270
|
+
if (width <= 0) {
|
|
6271
|
+
return;
|
|
5897
6272
|
}
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
6273
|
+
clientWidth = width;
|
|
6274
|
+
let left = props.left || 0;
|
|
6275
|
+
let right = props.right || 0;
|
|
6276
|
+
if (left > clientWidth) {
|
|
6277
|
+
left = clientWidth / 3;
|
|
5902
6278
|
}
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
6279
|
+
if (right > clientWidth) {
|
|
6280
|
+
right = clientWidth / 3;
|
|
6281
|
+
}
|
|
6282
|
+
const columnWidth = getCenterWidth(left, right);
|
|
6283
|
+
center.value = columnWidth.center;
|
|
6284
|
+
emit("change", columnWidth);
|
|
6285
|
+
};
|
|
6286
|
+
if (typeof props.width !== "number") {
|
|
6287
|
+
const resizerObserver = new ResizeObserver((entries) => {
|
|
6288
|
+
for (const { contentRect } of entries) {
|
|
6289
|
+
widthChange(contentRect.width);
|
|
6290
|
+
}
|
|
6291
|
+
});
|
|
6292
|
+
onMounted(() => {
|
|
6293
|
+
if (el.value) {
|
|
6294
|
+
resizerObserver.observe(el.value);
|
|
6295
|
+
}
|
|
6296
|
+
});
|
|
6297
|
+
onBeforeUnmount(() => {
|
|
6298
|
+
resizerObserver.disconnect();
|
|
6299
|
+
});
|
|
6300
|
+
} else {
|
|
6301
|
+
watchEffect(() => {
|
|
6302
|
+
if (typeof props.width === "number")
|
|
6303
|
+
widthChange(props.width);
|
|
6304
|
+
});
|
|
6305
|
+
}
|
|
5908
6306
|
const changeLeft = ({ deltaX }) => {
|
|
5909
6307
|
if (typeof props.left === "undefined")
|
|
5910
6308
|
return;
|
|
@@ -5913,7 +6311,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5913
6311
|
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
5914
6312
|
left = props.left;
|
|
5915
6313
|
}
|
|
5916
|
-
const columnWidth = getCenterWidth(
|
|
6314
|
+
const columnWidth = getCenterWidth(left, props.right || 0);
|
|
5917
6315
|
center.value = columnWidth.center;
|
|
5918
6316
|
emit("change", {
|
|
5919
6317
|
left: columnWidth.left,
|
|
@@ -5929,7 +6327,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5929
6327
|
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
5930
6328
|
right = props.right;
|
|
5931
6329
|
}
|
|
5932
|
-
const columnWidth = getCenterWidth(
|
|
6330
|
+
const columnWidth = getCenterWidth(props.left, right);
|
|
5933
6331
|
center.value = columnWidth.center;
|
|
5934
6332
|
emit("change", {
|
|
5935
6333
|
left: columnWidth.left,
|
|
@@ -5939,7 +6337,8 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5939
6337
|
};
|
|
5940
6338
|
__expose({
|
|
5941
6339
|
updateWidth() {
|
|
5942
|
-
|
|
6340
|
+
clientWidth = props.width ?? el.value?.clientWidth ?? clientWidth;
|
|
6341
|
+
const columnWidth = getCenterWidth(props.left, props.right);
|
|
5943
6342
|
emit("change", {
|
|
5944
6343
|
left: columnWidth.left,
|
|
5945
6344
|
center: center.value,
|
|
@@ -6081,7 +6480,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6081
6480
|
disabled: disabled.value
|
|
6082
6481
|
}, {
|
|
6083
6482
|
default: withCtx(() => [
|
|
6084
|
-
_ctx.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
6483
|
+
_ctx.data.icon ? (openBlock(), createBlock(_sfc_main$U, {
|
|
6085
6484
|
key: 0,
|
|
6086
6485
|
icon: _ctx.data.icon
|
|
6087
6486
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -6099,7 +6498,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6099
6498
|
title: _ctx.data.text
|
|
6100
6499
|
}, {
|
|
6101
6500
|
default: withCtx(() => [
|
|
6102
|
-
_ctx.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
6501
|
+
_ctx.data.icon ? (openBlock(), createBlock(_sfc_main$U, {
|
|
6103
6502
|
key: 0,
|
|
6104
6503
|
icon: _ctx.data.icon
|
|
6105
6504
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -6187,7 +6586,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
6187
6586
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
6188
6587
|
onClick: addPage
|
|
6189
6588
|
}, [
|
|
6190
|
-
createVNode(_sfc_main$
|
|
6589
|
+
createVNode(_sfc_main$U, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
6191
6590
|
])) : (openBlock(), createElementBlock("div", _hoisted_1$d));
|
|
6192
6591
|
};
|
|
6193
6592
|
}
|
|
@@ -6299,7 +6698,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
6299
6698
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
6300
6699
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
6301
6700
|
}, [
|
|
6302
|
-
createVNode(_sfc_main$
|
|
6701
|
+
createVNode(_sfc_main$U, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
|
|
6303
6702
|
])) : createCommentVNode("", true),
|
|
6304
6703
|
_ctx.type === unref(NodeType).PAGE && pageLength.value || _ctx.type === unref(NodeType).PAGE_FRAGMENT && pageFragmentLength.value ? (openBlock(), createElementBlock("div", {
|
|
6305
6704
|
key: 1,
|
|
@@ -6315,7 +6714,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
6315
6714
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
6316
6715
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
6317
6716
|
}, [
|
|
6318
|
-
createVNode(_sfc_main$
|
|
6717
|
+
createVNode(_sfc_main$U, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
|
|
6319
6718
|
])) : createCommentVNode("", true)
|
|
6320
6719
|
], 512);
|
|
6321
6720
|
};
|
|
@@ -6555,7 +6954,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
6555
6954
|
onClick: _cache[0] || (_cache[0] = ($event) => clickHandler(unref(NodeType).PAGE))
|
|
6556
6955
|
}, [
|
|
6557
6956
|
createElementVNode("div", null, [
|
|
6558
|
-
createVNode(_sfc_main$
|
|
6957
|
+
createVNode(_sfc_main$U, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
6559
6958
|
]),
|
|
6560
6959
|
_hoisted_3$4
|
|
6561
6960
|
]),
|
|
@@ -6565,7 +6964,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
6565
6964
|
onClick: _cache[1] || (_cache[1] = ($event) => clickHandler(unref(NodeType).PAGE_FRAGMENT))
|
|
6566
6965
|
}, [
|
|
6567
6966
|
createElementVNode("div", null, [
|
|
6568
|
-
createVNode(_sfc_main$
|
|
6967
|
+
createVNode(_sfc_main$U, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
6569
6968
|
]),
|
|
6570
6969
|
_hoisted_4$4
|
|
6571
6970
|
])) : createCommentVNode("", true)
|
|
@@ -6598,36 +6997,14 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
6598
6997
|
const stageLoading = computed(() => editorService?.get("stageLoading") || false);
|
|
6599
6998
|
const showSrc = computed(() => uiService?.get("showSrc"));
|
|
6600
6999
|
const getLeftColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
6601
|
-
const leftColumnWidthCacheData = getLeftColumnWidthCacheData();
|
|
6602
|
-
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
6603
7000
|
const columnWidth = ref({
|
|
6604
|
-
left:
|
|
7001
|
+
left: getLeftColumnWidthCacheData(),
|
|
6605
7002
|
center: 0,
|
|
6606
|
-
right:
|
|
7003
|
+
right: Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH
|
|
7004
|
+
});
|
|
7005
|
+
watch(pageLength, () => {
|
|
7006
|
+
splitView.value?.updateWidth();
|
|
6607
7007
|
});
|
|
6608
|
-
watch(
|
|
6609
|
-
[pageLength, splitView],
|
|
6610
|
-
() => {
|
|
6611
|
-
splitView.value?.updateWidth();
|
|
6612
|
-
},
|
|
6613
|
-
{
|
|
6614
|
-
immediate: true
|
|
6615
|
-
}
|
|
6616
|
-
);
|
|
6617
|
-
watch(
|
|
6618
|
-
() => columnWidth.value.right,
|
|
6619
|
-
(right) => {
|
|
6620
|
-
if (typeof right === "undefined")
|
|
6621
|
-
return;
|
|
6622
|
-
globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
|
|
6623
|
-
}
|
|
6624
|
-
);
|
|
6625
|
-
watch(
|
|
6626
|
-
() => columnWidth.value.left,
|
|
6627
|
-
(left) => {
|
|
6628
|
-
globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
|
|
6629
|
-
}
|
|
6630
|
-
);
|
|
6631
7008
|
watch(
|
|
6632
7009
|
() => uiService?.get("hideSlideBar"),
|
|
6633
7010
|
(hideSlideBar) => {
|
|
@@ -6635,11 +7012,29 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
6635
7012
|
}
|
|
6636
7013
|
);
|
|
6637
7014
|
const columnWidthChange = (columnW) => {
|
|
6638
|
-
columnWidth.value
|
|
6639
|
-
|
|
6640
|
-
|
|
7015
|
+
columnWidth.value = columnW;
|
|
7016
|
+
globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.left}`);
|
|
7017
|
+
globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.right}`);
|
|
6641
7018
|
uiService?.set("columnWidth", columnW);
|
|
6642
7019
|
};
|
|
7020
|
+
const frameworkRect = computed(() => uiService?.get("frameworkRect"));
|
|
7021
|
+
const resizerObserver = new ResizeObserver((entries) => {
|
|
7022
|
+
const { contentRect } = entries[0];
|
|
7023
|
+
uiService?.set("frameworkRect", {
|
|
7024
|
+
width: contentRect.width,
|
|
7025
|
+
height: contentRect.height,
|
|
7026
|
+
left: contentRect.left,
|
|
7027
|
+
top: contentRect.top
|
|
7028
|
+
});
|
|
7029
|
+
});
|
|
7030
|
+
onMounted(() => {
|
|
7031
|
+
if (content.value) {
|
|
7032
|
+
resizerObserver.observe(content.value);
|
|
7033
|
+
}
|
|
7034
|
+
});
|
|
7035
|
+
onBeforeUnmount(() => {
|
|
7036
|
+
resizerObserver.disconnect();
|
|
7037
|
+
});
|
|
6643
7038
|
const saveCode = (value) => {
|
|
6644
7039
|
try {
|
|
6645
7040
|
const parseDSL = getConfig("parseDSL");
|
|
@@ -6660,7 +7055,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
6660
7055
|
renderSlot(_ctx.$slots, "nav"),
|
|
6661
7056
|
renderSlot(_ctx.$slots, "content-before"),
|
|
6662
7057
|
showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
|
|
6663
|
-
createVNode(_sfc_main$
|
|
7058
|
+
createVNode(_sfc_main$T, {
|
|
6664
7059
|
class: "m-editor-content",
|
|
6665
7060
|
"init-values": root.value,
|
|
6666
7061
|
options: unref(codeOptions),
|
|
@@ -6682,6 +7077,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
6682
7077
|
"min-left": 65,
|
|
6683
7078
|
"min-right": 20,
|
|
6684
7079
|
"min-center": 100,
|
|
7080
|
+
width: frameworkRect.value?.width || 0,
|
|
6685
7081
|
onChange: columnWidthChange
|
|
6686
7082
|
}, createSlots({
|
|
6687
7083
|
left: withCtx(() => [
|
|
@@ -6717,7 +7113,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
6717
7113
|
]),
|
|
6718
7114
|
key: "0"
|
|
6719
7115
|
} : void 0
|
|
6720
|
-
]), 1032, ["left", "right"])), [
|
|
7116
|
+
]), 1032, ["left", "right", "width"])), [
|
|
6721
7117
|
[_directive_loading, stageLoading.value]
|
|
6722
7118
|
]),
|
|
6723
7119
|
renderSlot(_ctx.$slots, "content-after"),
|
|
@@ -6932,7 +7328,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
6932
7328
|
},
|
|
6933
7329
|
emits: ["mounted", "submit-error", "form-error"],
|
|
6934
7330
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
7331
|
+
const codeOptions = inject("codeOptions", {});
|
|
6935
7332
|
const emit = __emit;
|
|
7333
|
+
const showSrc = ref(false);
|
|
6936
7334
|
const internalInstance = getCurrentInstance();
|
|
6937
7335
|
const values = ref({});
|
|
6938
7336
|
const configForm = ref();
|
|
@@ -6942,6 +7340,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
6942
7340
|
const nodes = computed(() => services?.editorService.get("nodes") || []);
|
|
6943
7341
|
const propsPanelSize = computed(() => services?.uiService.get("propsPanelSize") || "small");
|
|
6944
7342
|
const stage = computed(() => services?.editorService.get("stage"));
|
|
7343
|
+
const { height: editorContentHeight } = useEditorContentHeight();
|
|
6945
7344
|
const init = async () => {
|
|
6946
7345
|
if (!node.value) {
|
|
6947
7346
|
curFormConfig.value = [];
|
|
@@ -6975,6 +7374,9 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
6975
7374
|
const errorHandler = (e) => {
|
|
6976
7375
|
emit("form-error", e);
|
|
6977
7376
|
};
|
|
7377
|
+
const saveCode = (values2) => {
|
|
7378
|
+
services?.editorService.update(values2);
|
|
7379
|
+
};
|
|
6978
7380
|
__expose({ configForm, submit });
|
|
6979
7381
|
return (_ctx, _cache) => {
|
|
6980
7382
|
return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
@@ -6990,71 +7392,34 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
6990
7392
|
"extend-state": _ctx.extendState,
|
|
6991
7393
|
onChange: submit,
|
|
6992
7394
|
onError: errorHandler
|
|
6993
|
-
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"])
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
[
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
const isDraging = ref(false);
|
|
7019
|
-
const dragstartHandler = () => isDraging.value = true;
|
|
7020
|
-
const dragendHandler = (key, e) => {
|
|
7021
|
-
floatBoxStates.value[key] = {
|
|
7022
|
-
left: e.clientX,
|
|
7023
|
-
top: e.clientY,
|
|
7024
|
-
status: true
|
|
7395
|
+
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"]),
|
|
7396
|
+
createVNode(unref(TMagicButton), {
|
|
7397
|
+
class: "m-editor-props-panel-src-icon",
|
|
7398
|
+
circle: "",
|
|
7399
|
+
size: "large",
|
|
7400
|
+
title: "源码",
|
|
7401
|
+
type: showSrc.value ? "primary" : "",
|
|
7402
|
+
onClick: _cache[0] || (_cache[0] = ($event) => showSrc.value = !showSrc.value)
|
|
7403
|
+
}, {
|
|
7404
|
+
default: withCtx(() => [
|
|
7405
|
+
createVNode(_sfc_main$U, { icon: unref(Document) }, null, 8, ["icon"])
|
|
7406
|
+
]),
|
|
7407
|
+
_: 1
|
|
7408
|
+
}, 8, ["type"]),
|
|
7409
|
+
showSrc.value ? (openBlock(), createBlock(_sfc_main$T, {
|
|
7410
|
+
key: 0,
|
|
7411
|
+
height: `${unref(editorContentHeight)}px`,
|
|
7412
|
+
"init-values": values.value,
|
|
7413
|
+
options: unref(codeOptions),
|
|
7414
|
+
parse: true,
|
|
7415
|
+
onSave: saveCode
|
|
7416
|
+
}, null, 8, ["height", "init-values", "options"])) : createCommentVNode("", true)
|
|
7417
|
+
], 512)), [
|
|
7418
|
+
[vShow, nodes.value.length === 1]
|
|
7419
|
+
]);
|
|
7025
7420
|
};
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
document.body.addEventListener("dragover", (e) => {
|
|
7029
|
-
if (!isDraging.value)
|
|
7030
|
-
return;
|
|
7031
|
-
e.preventDefault();
|
|
7032
|
-
});
|
|
7033
|
-
watch(
|
|
7034
|
-
() => slideKeys.value,
|
|
7035
|
-
() => {
|
|
7036
|
-
for (const key in slideKeys.value) {
|
|
7037
|
-
if (floatBoxStates.value[key])
|
|
7038
|
-
continue;
|
|
7039
|
-
floatBoxStates.value[key] = {
|
|
7040
|
-
status: false,
|
|
7041
|
-
top: 0,
|
|
7042
|
-
left: 0
|
|
7043
|
-
};
|
|
7044
|
-
}
|
|
7045
|
-
},
|
|
7046
|
-
{
|
|
7047
|
-
deep: true,
|
|
7048
|
-
immediate: true
|
|
7049
|
-
}
|
|
7050
|
-
);
|
|
7051
|
-
return {
|
|
7052
|
-
dragstartHandler,
|
|
7053
|
-
dragendHandler,
|
|
7054
|
-
floatBoxStates,
|
|
7055
|
-
showingBoxKeys
|
|
7056
|
-
};
|
|
7057
|
-
};
|
|
7421
|
+
}
|
|
7422
|
+
});
|
|
7058
7423
|
|
|
7059
7424
|
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
7060
7425
|
...{
|
|
@@ -7181,7 +7546,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
7181
7546
|
onContextmenu: nodeContentmenuHandler,
|
|
7182
7547
|
onMouseenter: mouseenterHandler
|
|
7183
7548
|
}, [
|
|
7184
|
-
createVNode(_sfc_main$
|
|
7549
|
+
createVNode(_sfc_main$U, {
|
|
7185
7550
|
class: "expand-icon",
|
|
7186
7551
|
style: normalizeStyle(hasChildren.value ? "" : "color: transparent; cursor: default"),
|
|
7187
7552
|
icon: expanded.value ? unref(ArrowDown) : unref(ArrowRight),
|
|
@@ -7460,7 +7825,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
7460
7825
|
placement: "bottom"
|
|
7461
7826
|
}, {
|
|
7462
7827
|
default: withCtx(() => [
|
|
7463
|
-
createVNode(_sfc_main$
|
|
7828
|
+
createVNode(_sfc_main$U, {
|
|
7464
7829
|
icon: editable.value ? unref(Edit) : unref(View),
|
|
7465
7830
|
class: "edit-icon",
|
|
7466
7831
|
onClick: withModifiers(($event) => editCode(`${data.key}`), ["stop"])
|
|
@@ -7475,7 +7840,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
7475
7840
|
placement: "bottom"
|
|
7476
7841
|
}, {
|
|
7477
7842
|
default: withCtx(() => [
|
|
7478
|
-
createVNode(_sfc_main$
|
|
7843
|
+
createVNode(_sfc_main$U, {
|
|
7479
7844
|
icon: unref(Close),
|
|
7480
7845
|
class: "edit-icon",
|
|
7481
7846
|
onClick: withModifiers(($event) => deleteCode(`${data.key}`), ["stop"])
|
|
@@ -7501,8 +7866,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
7501
7866
|
},
|
|
7502
7867
|
__name: "CodeBlockListPanel",
|
|
7503
7868
|
props: {
|
|
7504
|
-
customError: { type: Function }
|
|
7505
|
-
slideType: {}
|
|
7869
|
+
customError: { type: Function }
|
|
7506
7870
|
},
|
|
7507
7871
|
setup(__props) {
|
|
7508
7872
|
const { codeBlockService } = inject("services") || {};
|
|
@@ -7552,15 +7916,14 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
7552
7916
|
]),
|
|
7553
7917
|
_: 3
|
|
7554
7918
|
}),
|
|
7555
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
7919
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
7556
7920
|
key: 0,
|
|
7557
7921
|
ref_key: "codeBlockEditor",
|
|
7558
7922
|
ref: codeBlockEditor,
|
|
7559
7923
|
disabled: !editable.value,
|
|
7560
7924
|
content: unref(codeConfig),
|
|
7561
|
-
slideType: _ctx.slideType,
|
|
7562
7925
|
onSubmit: unref(submitCodeBlockHandler)
|
|
7563
|
-
}, null, 8, ["disabled", "content", "
|
|
7926
|
+
}, null, 8, ["disabled", "content", "onSubmit"])) : createCommentVNode("", true)
|
|
7564
7927
|
], 64);
|
|
7565
7928
|
};
|
|
7566
7929
|
}
|
|
@@ -7571,21 +7934,28 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
7571
7934
|
name: "MEditorDataSourceConfigPanel"
|
|
7572
7935
|
},
|
|
7573
7936
|
__name: "DataSourceConfigPanel",
|
|
7574
|
-
props: {
|
|
7937
|
+
props: /* @__PURE__ */ mergeModels({
|
|
7575
7938
|
title: {},
|
|
7576
7939
|
values: {},
|
|
7577
|
-
disabled: { type: Boolean }
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7940
|
+
disabled: { type: Boolean }
|
|
7941
|
+
}, {
|
|
7942
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
7943
|
+
"visibleModifiers": {},
|
|
7944
|
+
"width": { default: 670 },
|
|
7945
|
+
"widthModifiers": {}
|
|
7946
|
+
}),
|
|
7947
|
+
emits: /* @__PURE__ */ mergeModels(["submit"], ["update:visible", "update:width"]),
|
|
7581
7948
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
7582
7949
|
const props = __props;
|
|
7950
|
+
const boxVisible = useModel(__props, "visible");
|
|
7951
|
+
const width = useModel(__props, "width");
|
|
7583
7952
|
const emit = __emit;
|
|
7584
7953
|
const services = inject("services");
|
|
7585
|
-
const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
|
|
7586
|
-
const fomDrawer = ref();
|
|
7587
7954
|
const initValues = ref({});
|
|
7588
7955
|
const dataSourceConfig = ref([]);
|
|
7956
|
+
const { height: editorHeight } = useEditorContentHeight();
|
|
7957
|
+
const parentFloating = inject("parentFloating", ref(null));
|
|
7958
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
7589
7959
|
watchEffect(() => {
|
|
7590
7960
|
initValues.value = props.values;
|
|
7591
7961
|
dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
|
|
@@ -7598,26 +7968,38 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
7598
7968
|
};
|
|
7599
7969
|
__expose({
|
|
7600
7970
|
show() {
|
|
7601
|
-
|
|
7971
|
+
calcBoxPosition();
|
|
7972
|
+
boxVisible.value = true;
|
|
7602
7973
|
},
|
|
7603
7974
|
hide() {
|
|
7604
|
-
|
|
7975
|
+
boxVisible.value = false;
|
|
7605
7976
|
}
|
|
7606
7977
|
});
|
|
7607
7978
|
return (_ctx, _cache) => {
|
|
7608
|
-
return openBlock(), createBlock(
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
"
|
|
7979
|
+
return openBlock(), createBlock(_sfc_main$P, {
|
|
7980
|
+
visible: boxVisible.value,
|
|
7981
|
+
"onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
|
|
7982
|
+
width: width.value,
|
|
7983
|
+
"onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
|
|
7984
|
+
height: unref(editorHeight),
|
|
7985
|
+
"onUpdate:height": _cache[2] || (_cache[2] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
7613
7986
|
title: _ctx.title,
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7987
|
+
position: unref(boxPosition)
|
|
7988
|
+
}, {
|
|
7989
|
+
body: withCtx(() => [
|
|
7990
|
+
createVNode(unref(MFormBox), {
|
|
7991
|
+
"label-width": "80px",
|
|
7992
|
+
title: _ctx.title,
|
|
7993
|
+
config: dataSourceConfig.value,
|
|
7994
|
+
values: initValues.value,
|
|
7995
|
+
disabled: _ctx.disabled,
|
|
7996
|
+
style: { "height": "100%" },
|
|
7997
|
+
onSubmit: submitHandler,
|
|
7998
|
+
onError: errorHandler
|
|
7999
|
+
}, null, 8, ["title", "config", "values", "disabled"])
|
|
8000
|
+
]),
|
|
8001
|
+
_: 1
|
|
8002
|
+
}, 8, ["visible", "width", "height", "title", "position"]);
|
|
7621
8003
|
};
|
|
7622
8004
|
}
|
|
7623
8005
|
});
|
|
@@ -7733,7 +8115,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
7733
8115
|
placement: "bottom"
|
|
7734
8116
|
}, {
|
|
7735
8117
|
default: withCtx(() => [
|
|
7736
|
-
createVNode(_sfc_main$
|
|
8118
|
+
createVNode(_sfc_main$U, {
|
|
7737
8119
|
icon: editable.value ? unref(Edit) : unref(View),
|
|
7738
8120
|
class: "edit-icon",
|
|
7739
8121
|
onClick: withModifiers(($event) => editHandler(`${data.key}`), ["stop"])
|
|
@@ -7748,7 +8130,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
7748
8130
|
placement: "bottom"
|
|
7749
8131
|
}, {
|
|
7750
8132
|
default: withCtx(() => [
|
|
7751
|
-
createVNode(_sfc_main$
|
|
8133
|
+
createVNode(_sfc_main$U, {
|
|
7752
8134
|
icon: unref(Close),
|
|
7753
8135
|
class: "edit-icon",
|
|
7754
8136
|
onClick: withModifiers(($event) => removeHandler(`${data.key}`), ["stop"])
|
|
@@ -7771,9 +8153,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
7771
8153
|
name: "MEditorDataSourceListPanel"
|
|
7772
8154
|
},
|
|
7773
8155
|
__name: "DataSourceListPanel",
|
|
7774
|
-
props: {
|
|
7775
|
-
slideType: {}
|
|
7776
|
-
},
|
|
7777
8156
|
setup(__props) {
|
|
7778
8157
|
const { dataSourceService } = inject("services") || {};
|
|
7779
8158
|
const editDialog = ref();
|
|
@@ -7880,9 +8259,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
7880
8259
|
disabled: !editable.value,
|
|
7881
8260
|
values: dataSourceValues.value,
|
|
7882
8261
|
title: dialogTitle.value,
|
|
7883
|
-
slideType: _ctx.slideType,
|
|
7884
8262
|
onSubmit: submitDataSourceHandler
|
|
7885
|
-
}, null, 8, ["disabled", "values", "title"
|
|
8263
|
+
}, null, 8, ["disabled", "values", "title"])
|
|
7886
8264
|
], 64);
|
|
7887
8265
|
};
|
|
7888
8266
|
}
|
|
@@ -8284,12 +8662,12 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
8284
8662
|
};
|
|
8285
8663
|
return (_ctx, _cache) => {
|
|
8286
8664
|
return _ctx.data.type !== "page" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
8287
|
-
_ctx.data.visible === false ? (openBlock(), createBlock(_sfc_main$
|
|
8665
|
+
_ctx.data.visible === false ? (openBlock(), createBlock(_sfc_main$U, {
|
|
8288
8666
|
key: 0,
|
|
8289
8667
|
icon: unref(Hide),
|
|
8290
8668
|
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => setNodeVisible(true), ["stop"])),
|
|
8291
8669
|
title: "点击显示"
|
|
8292
|
-
}, null, 8, ["icon"])) : (openBlock(), createBlock(_sfc_main$
|
|
8670
|
+
}, null, 8, ["icon"])) : (openBlock(), createBlock(_sfc_main$U, {
|
|
8293
8671
|
key: 1,
|
|
8294
8672
|
icon: unref(View),
|
|
8295
8673
|
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => setNodeVisible(false), ["stop"])),
|
|
@@ -8930,7 +9308,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
8930
9308
|
name: `${index}`
|
|
8931
9309
|
}, {
|
|
8932
9310
|
title: withCtx(() => [
|
|
8933
|
-
createVNode(_sfc_main$
|
|
9311
|
+
createVNode(_sfc_main$U, { icon: unref(Grid) }, null, 8, ["icon"]),
|
|
8934
9312
|
createTextVNode(toDisplayString(group.title), 1)
|
|
8935
9313
|
]),
|
|
8936
9314
|
default: withCtx(() => [
|
|
@@ -8951,7 +9329,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
8951
9329
|
content: item.desc
|
|
8952
9330
|
}, {
|
|
8953
9331
|
default: withCtx(() => [
|
|
8954
|
-
createVNode(_sfc_main$
|
|
9332
|
+
createVNode(_sfc_main$U, {
|
|
8955
9333
|
icon: item.icon
|
|
8956
9334
|
}, null, 8, ["icon"])
|
|
8957
9335
|
]),
|
|
@@ -9002,6 +9380,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9002
9380
|
setup(__props, { expose: __expose }) {
|
|
9003
9381
|
const props = __props;
|
|
9004
9382
|
const services = inject("services");
|
|
9383
|
+
const columnLeftWidth = computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
|
|
9384
|
+
const { height: columnLeftHeight } = useEditorContentHeight();
|
|
9005
9385
|
const activeTabName = ref(props.data?.status);
|
|
9006
9386
|
const getItemConfig = (data) => {
|
|
9007
9387
|
const map = {
|
|
@@ -9031,12 +9411,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9031
9411
|
icon: EditPen,
|
|
9032
9412
|
text: "代码编辑",
|
|
9033
9413
|
component: _sfc_main$k,
|
|
9034
|
-
slots: {}
|
|
9035
|
-
boxComponentConfig: {
|
|
9036
|
-
props: {
|
|
9037
|
-
slideType: "box"
|
|
9038
|
-
}
|
|
9039
|
-
}
|
|
9414
|
+
slots: {}
|
|
9040
9415
|
},
|
|
9041
9416
|
"data-source": {
|
|
9042
9417
|
$key: "data-source",
|
|
@@ -9093,7 +9468,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9093
9468
|
(...args) => unref(dragstartHandler) && unref(dragstartHandler)(...args)),
|
|
9094
9469
|
onDragend: ($event) => unref(dragendHandler)(config.$key, $event)
|
|
9095
9470
|
}, [
|
|
9096
|
-
config.icon ? (openBlock(), createBlock(_sfc_main$
|
|
9471
|
+
config.icon ? (openBlock(), createBlock(_sfc_main$U, {
|
|
9097
9472
|
key: 0,
|
|
9098
9473
|
icon: config.icon
|
|
9099
9474
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -9226,10 +9601,13 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9226
9601
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
9227
9602
|
(openBlock(true), createElementBlock(Fragment, null, renderList(sideBarItems.value, (config, index) => {
|
|
9228
9603
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
9229
|
-
unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(_sfc_main$
|
|
9604
|
+
unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(_sfc_main$P, {
|
|
9230
9605
|
key: config.$key ?? index,
|
|
9231
9606
|
visible: unref(floatBoxStates)[config.$key].status,
|
|
9232
9607
|
"onUpdate:visible": ($event) => unref(floatBoxStates)[config.$key].status = $event,
|
|
9608
|
+
height: unref(columnLeftHeight),
|
|
9609
|
+
"onUpdate:height": _cache[1] || (_cache[1] = ($event) => isRef(columnLeftHeight) ? columnLeftHeight.value = $event : null),
|
|
9610
|
+
width: columnLeftWidth.value,
|
|
9233
9611
|
title: config.text,
|
|
9234
9612
|
position: {
|
|
9235
9613
|
left: unref(floatBoxStates)[config.$key].left,
|
|
@@ -9238,11 +9616,11 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9238
9616
|
}, {
|
|
9239
9617
|
body: withCtx(() => [
|
|
9240
9618
|
createElementVNode("div", _hoisted_5$1, [
|
|
9241
|
-
config && unref(floatBoxStates)[config.$key].status ? (openBlock(), createBlock(resolveDynamicComponent(config.
|
|
9619
|
+
config && unref(floatBoxStates)[config.$key].status ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({ key: 0 }, config.props || {}, toHandlers(config?.listeners || {})), null, 16)) : createCommentVNode("", true)
|
|
9242
9620
|
])
|
|
9243
9621
|
]),
|
|
9244
9622
|
_: 2
|
|
9245
|
-
}, 1032, ["visible", "onUpdate:visible", "title", "position"])) : createCommentVNode("", true)
|
|
9623
|
+
}, 1032, ["visible", "onUpdate:visible", "height", "width", "title", "position"])) : createCommentVNode("", true)
|
|
9246
9624
|
], 64);
|
|
9247
9625
|
}), 256))
|
|
9248
9626
|
]))
|
|
@@ -9574,205 +9952,6 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
9574
9952
|
}
|
|
9575
9953
|
});
|
|
9576
9954
|
|
|
9577
|
-
const state = reactive({
|
|
9578
|
-
uiSelectMode: false,
|
|
9579
|
-
showSrc: false,
|
|
9580
|
-
zoom: 1,
|
|
9581
|
-
stageContainerRect: {
|
|
9582
|
-
width: 0,
|
|
9583
|
-
height: 0
|
|
9584
|
-
},
|
|
9585
|
-
stageRect: {
|
|
9586
|
-
width: 375,
|
|
9587
|
-
height: 817
|
|
9588
|
-
},
|
|
9589
|
-
columnWidth: {
|
|
9590
|
-
left: 0,
|
|
9591
|
-
right: 0,
|
|
9592
|
-
center: 0
|
|
9593
|
-
},
|
|
9594
|
-
showGuides: true,
|
|
9595
|
-
showRule: true,
|
|
9596
|
-
propsPanelSize: "small",
|
|
9597
|
-
showAddPageButton: true,
|
|
9598
|
-
hideSlideBar: false,
|
|
9599
|
-
navMenuRect: {
|
|
9600
|
-
left: 0,
|
|
9601
|
-
top: 0,
|
|
9602
|
-
width: 0,
|
|
9603
|
-
height: 0
|
|
9604
|
-
}
|
|
9605
|
-
});
|
|
9606
|
-
const canUsePluginMethods$2 = {
|
|
9607
|
-
async: ["zoom", "calcZoom"],
|
|
9608
|
-
sync: []
|
|
9609
|
-
};
|
|
9610
|
-
class Ui extends BaseService {
|
|
9611
|
-
constructor() {
|
|
9612
|
-
super(canUsePluginMethods$2.async.map((methodName) => ({ name: methodName, isAsync: true })));
|
|
9613
|
-
}
|
|
9614
|
-
set(name, value) {
|
|
9615
|
-
const mask = editorService.get("stage")?.mask;
|
|
9616
|
-
if (name === "stageRect") {
|
|
9617
|
-
this.setStageRect(value);
|
|
9618
|
-
return;
|
|
9619
|
-
}
|
|
9620
|
-
if (name === "showGuides") {
|
|
9621
|
-
mask?.showGuides(value);
|
|
9622
|
-
}
|
|
9623
|
-
if (name === "showRule") {
|
|
9624
|
-
mask?.showRule(value);
|
|
9625
|
-
}
|
|
9626
|
-
state[name] = value;
|
|
9627
|
-
}
|
|
9628
|
-
get(name) {
|
|
9629
|
-
return state[name];
|
|
9630
|
-
}
|
|
9631
|
-
async zoom(zoom) {
|
|
9632
|
-
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
9633
|
-
if (this.get("zoom") < 0.1)
|
|
9634
|
-
this.set("zoom", 0.1);
|
|
9635
|
-
}
|
|
9636
|
-
async calcZoom() {
|
|
9637
|
-
const { stageRect, stageContainerRect } = state;
|
|
9638
|
-
const { height, width } = stageContainerRect;
|
|
9639
|
-
if (!width || !height)
|
|
9640
|
-
return 1;
|
|
9641
|
-
let stageWidth = convertToNumber(stageRect.width, width);
|
|
9642
|
-
let stageHeight = convertToNumber(stageRect.height, height);
|
|
9643
|
-
stageWidth = stageWidth + 30;
|
|
9644
|
-
stageHeight = stageHeight + 30;
|
|
9645
|
-
if (width > stageWidth && height > stageHeight) {
|
|
9646
|
-
return 1;
|
|
9647
|
-
}
|
|
9648
|
-
return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
|
|
9649
|
-
}
|
|
9650
|
-
resetState() {
|
|
9651
|
-
this.set("showSrc", false);
|
|
9652
|
-
this.set("uiSelectMode", false);
|
|
9653
|
-
this.set("zoom", 1);
|
|
9654
|
-
this.set("stageContainerRect", {
|
|
9655
|
-
width: 0,
|
|
9656
|
-
height: 0
|
|
9657
|
-
});
|
|
9658
|
-
}
|
|
9659
|
-
destroy() {
|
|
9660
|
-
this.resetState();
|
|
9661
|
-
this.removeAllListeners();
|
|
9662
|
-
this.removeAllPlugins();
|
|
9663
|
-
}
|
|
9664
|
-
usePlugin(options) {
|
|
9665
|
-
super.usePlugin(options);
|
|
9666
|
-
}
|
|
9667
|
-
async setStageRect(value) {
|
|
9668
|
-
state.stageRect = {
|
|
9669
|
-
...state.stageRect,
|
|
9670
|
-
...value
|
|
9671
|
-
};
|
|
9672
|
-
state.zoom = await this.calcZoom();
|
|
9673
|
-
}
|
|
9674
|
-
}
|
|
9675
|
-
const uiService = new Ui();
|
|
9676
|
-
|
|
9677
|
-
const root = computed(() => editorService.get("root"));
|
|
9678
|
-
const page = computed(() => editorService.get("page"));
|
|
9679
|
-
const zoom = computed(() => uiService.get("zoom") || 1);
|
|
9680
|
-
const uiSelectMode = computed(() => uiService.get("uiSelectMode"));
|
|
9681
|
-
const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
|
|
9682
|
-
const useStage = (stageOptions) => {
|
|
9683
|
-
const stage = new StageCore({
|
|
9684
|
-
render: stageOptions.render,
|
|
9685
|
-
runtimeUrl: stageOptions.runtimeUrl,
|
|
9686
|
-
zoom: zoom.value,
|
|
9687
|
-
autoScrollIntoView: stageOptions.autoScrollIntoView,
|
|
9688
|
-
isContainer: stageOptions.isContainer,
|
|
9689
|
-
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
|
9690
|
-
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
|
9691
|
-
containerHighlightType: stageOptions.containerHighlightType,
|
|
9692
|
-
disabledDragStart: stageOptions.disabledDragStart,
|
|
9693
|
-
renderType: stageOptions.renderType,
|
|
9694
|
-
canSelect: (el, event, stop) => {
|
|
9695
|
-
if (!stageOptions.canSelect)
|
|
9696
|
-
return true;
|
|
9697
|
-
const elCanSelect = stageOptions.canSelect?.(el);
|
|
9698
|
-
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
9699
|
-
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
|
|
9700
|
-
return stop();
|
|
9701
|
-
}
|
|
9702
|
-
return elCanSelect;
|
|
9703
|
-
},
|
|
9704
|
-
moveableOptions: stageOptions.moveableOptions,
|
|
9705
|
-
updateDragEl: stageOptions.updateDragEl,
|
|
9706
|
-
guidesOptions: stageOptions.guidesOptions,
|
|
9707
|
-
disabledMultiSelect: stageOptions.disabledMultiSelect
|
|
9708
|
-
});
|
|
9709
|
-
watch(
|
|
9710
|
-
() => editorService.get("disabledMultiSelect"),
|
|
9711
|
-
(disabledMultiSelect) => {
|
|
9712
|
-
if (disabledMultiSelect) {
|
|
9713
|
-
stage.disableMultiSelect();
|
|
9714
|
-
} else {
|
|
9715
|
-
stage.enableMultiSelect();
|
|
9716
|
-
}
|
|
9717
|
-
}
|
|
9718
|
-
);
|
|
9719
|
-
stage.mask.setGuides([
|
|
9720
|
-
getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
|
|
9721
|
-
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
9722
|
-
]);
|
|
9723
|
-
stage.on("page-el-update", () => {
|
|
9724
|
-
editorService.set("stageLoading", false);
|
|
9725
|
-
});
|
|
9726
|
-
stage.on("select", (el) => {
|
|
9727
|
-
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
9728
|
-
return;
|
|
9729
|
-
editorService.select(el.id);
|
|
9730
|
-
});
|
|
9731
|
-
stage.on("highlight", (el) => {
|
|
9732
|
-
editorService.highlight(el.id);
|
|
9733
|
-
});
|
|
9734
|
-
stage.on("multi-select", (els) => {
|
|
9735
|
-
editorService.multiSelect(els.map((el) => el.id));
|
|
9736
|
-
});
|
|
9737
|
-
stage.on("update", (ev) => {
|
|
9738
|
-
if (ev.parentEl) {
|
|
9739
|
-
for (const data of ev.data) {
|
|
9740
|
-
editorService.moveToContainer({ id: data.el.id, style: data.style }, ev.parentEl.id);
|
|
9741
|
-
}
|
|
9742
|
-
return;
|
|
9743
|
-
}
|
|
9744
|
-
editorService.update(ev.data.map((data) => ({ id: data.el.id, style: data.style })));
|
|
9745
|
-
});
|
|
9746
|
-
stage.on("sort", (ev) => {
|
|
9747
|
-
editorService.sort(ev.src, ev.dist);
|
|
9748
|
-
});
|
|
9749
|
-
stage.on("remove", (ev) => {
|
|
9750
|
-
const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
|
|
9751
|
-
editorService.remove(nodes.filter((node) => Boolean(node)));
|
|
9752
|
-
});
|
|
9753
|
-
stage.on("select-parent", () => {
|
|
9754
|
-
const parent = editorService.get("parent");
|
|
9755
|
-
if (!parent)
|
|
9756
|
-
throw new Error("父节点为空");
|
|
9757
|
-
editorService.select(parent);
|
|
9758
|
-
editorService.get("stage")?.select(parent.id);
|
|
9759
|
-
});
|
|
9760
|
-
stage.on("change-guides", (e) => {
|
|
9761
|
-
uiService.set("showGuides", true);
|
|
9762
|
-
if (!root.value || !page.value)
|
|
9763
|
-
return;
|
|
9764
|
-
const storageKey = getGuideLineKey(
|
|
9765
|
-
e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
9766
|
-
);
|
|
9767
|
-
if (e.guides.length) {
|
|
9768
|
-
globalThis.localStorage.setItem(storageKey, JSON.stringify(e.guides));
|
|
9769
|
-
} else {
|
|
9770
|
-
globalThis.localStorage.removeItem(storageKey);
|
|
9771
|
-
}
|
|
9772
|
-
});
|
|
9773
|
-
return stage;
|
|
9774
|
-
};
|
|
9775
|
-
|
|
9776
9955
|
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
9777
9956
|
__name: "NodeListMenu",
|
|
9778
9957
|
setup(__props) {
|
|
@@ -9855,7 +10034,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
9855
10034
|
]),
|
|
9856
10035
|
_: 1
|
|
9857
10036
|
})) : createCommentVNode("", true),
|
|
9858
|
-
page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$
|
|
10037
|
+
page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$P, {
|
|
9859
10038
|
key: 1,
|
|
9860
10039
|
ref_key: "box",
|
|
9861
10040
|
ref: box,
|
|
@@ -9928,7 +10107,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
9928
10107
|
}, [
|
|
9929
10108
|
createVNode(unref(TMagicIcon), {
|
|
9930
10109
|
class: "m-editor-stage-overlay-close",
|
|
9931
|
-
size: 20,
|
|
10110
|
+
size: "20",
|
|
9932
10111
|
onClick: closeOverlayHandler
|
|
9933
10112
|
}, {
|
|
9934
10113
|
default: withCtx(() => [
|
|
@@ -10975,7 +11154,7 @@ class StageOverlay extends BaseService {
|
|
|
10975
11154
|
subStage?.renderer.contentWindow?.magic.onPageElUpdate(wrapDiv);
|
|
10976
11155
|
});
|
|
10977
11156
|
if (await stageOptions?.canSelect?.(contentEl)) {
|
|
10978
|
-
subStage?.select(contentEl);
|
|
11157
|
+
subStage?.select(contentEl.id);
|
|
10979
11158
|
}
|
|
10980
11159
|
}
|
|
10981
11160
|
updateHandler = () => {
|
|
@@ -11575,11 +11754,11 @@ const index = {
|
|
|
11575
11754
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
11576
11755
|
setConfig(option);
|
|
11577
11756
|
app.component(`${_sfc_main.name || "MEditor"}`, _sfc_main);
|
|
11578
|
-
app.component("magic-code-editor", _sfc_main$
|
|
11757
|
+
app.component("magic-code-editor", _sfc_main$T);
|
|
11579
11758
|
app.component("m-fields-ui-select", _sfc_main$A);
|
|
11580
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
11581
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
11582
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
11759
|
+
app.component("m-fields-code-link", _sfc_main$R);
|
|
11760
|
+
app.component("m-fields-vs-code", _sfc_main$S);
|
|
11761
|
+
app.component("m-fields-code-select", _sfc_main$Q);
|
|
11583
11762
|
app.component("m-fields-code-select-col", _sfc_main$M);
|
|
11584
11763
|
app.component("m-fields-event-select", _sfc_main$E);
|
|
11585
11764
|
app.component("m-fields-data-source-fields", _sfc_main$L);
|
|
@@ -11594,4 +11773,4 @@ const index = {
|
|
|
11594
11773
|
}
|
|
11595
11774
|
};
|
|
11596
11775
|
|
|
11597
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$
|
|
11776
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$O as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$M as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$K as DataSourceFieldSelect, _sfc_main$L as DataSourceFields, _sfc_main$J as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$U as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, _sfc_main$y as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useEditorContentHeight, useFloatBox, useStage, useWindowRect, warn };
|