@tmagic/editor 1.3.0-beta.2 → 1.3.0-beta.3
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 +52 -60
- package/dist/tmagic-editor.js +1634 -1065
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +1659 -1087
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +70 -65
- package/src/components/ContentMenu.vue +5 -1
- package/src/components/SearchInput.vue +5 -1
- package/src/editorProps.ts +51 -129
- package/src/fields/Code.vue +9 -3
- package/src/fields/DataSourceFieldSelect.vue +28 -16
- package/src/fields/DataSourceFields.vue +95 -7
- package/src/fields/DataSourceMethodSelect.vue +23 -14
- package/src/fields/DataSourceMocks.vue +237 -0
- package/src/fields/EventSelect.vue +18 -11
- package/src/index.ts +4 -1
- package/src/initService.ts +50 -20
- package/src/layouts/CodeEditor.vue +20 -4
- package/src/layouts/Framework.vue +3 -1
- package/src/layouts/PropsPanel.vue +3 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +18 -8
- package/src/layouts/sidebar/Sidebar.vue +7 -10
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +3 -1
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +3 -1
- package/src/layouts/sidebar/layer/LayerNode.vue +206 -0
- package/src/layouts/sidebar/layer/LayerNodeTool.vue +32 -0
- package/src/layouts/sidebar/layer/LayerPanel.vue +85 -0
- package/src/layouts/sidebar/layer/use-drag.ts +157 -0
- package/src/layouts/sidebar/layer/use-filter.ts +70 -0
- package/src/layouts/sidebar/layer/use-keybinding.ts +47 -0
- package/src/layouts/sidebar/layer/use-node-status.ts +103 -0
- package/src/layouts/workspace/Workspace.vue +3 -1
- package/src/layouts/workspace/viewer/NodeListMenu.vue +1 -1
- package/src/layouts/workspace/viewer/Stage.vue +19 -17
- package/src/services/dataSource.ts +10 -0
- package/src/services/editor.ts +45 -5
- package/src/theme/common/var.scss +2 -2
- package/src/theme/framework.scss +2 -0
- package/src/theme/layer-panel.scss +63 -63
- package/src/theme/props-panel.scss +8 -0
- package/src/theme/sidebar.scss +1 -5
- package/src/type.ts +60 -0
- package/src/utils/data-source/index.ts +11 -0
- package/src/utils/dep.ts +26 -11
- package/src/utils/editor.ts +14 -3
- package/src/utils/props.ts +3 -0
- package/types/editorProps.d.ts +61 -107
- package/types/fields/Code.vue.d.ts +10 -6
- package/types/fields/DataSourceMocks.vue.d.ts +32 -0
- package/types/index.d.ts +2 -1
- package/types/initService.d.ts +5 -4
- package/types/layouts/CodeEditor.vue.d.ts +5 -0
- package/types/layouts/Framework.vue.d.ts +2 -12
- package/types/layouts/PropsPanel.vue.d.ts +2 -3
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +2 -7
- package/types/layouts/sidebar/Sidebar.vue.d.ts +2 -17
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +2 -7
- package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +2 -9
- package/types/layouts/sidebar/{LayerMenu.vue.d.ts → layer/LayerMenu.vue.d.ts} +1 -1
- package/types/layouts/sidebar/layer/LayerNode.vue.d.ts +50 -0
- package/types/layouts/sidebar/{LayerNode.vue.d.ts → layer/LayerNodeTool.vue.d.ts} +1 -1
- package/types/layouts/sidebar/{LayerPanel.vue.d.ts → layer/LayerPanel.vue.d.ts} +2 -8
- package/types/layouts/sidebar/layer/use-drag.d.ts +14 -0
- package/types/layouts/sidebar/layer/use-filter.d.ts +8 -0
- package/types/layouts/sidebar/layer/use-keybinding.d.ts +4 -0
- package/types/layouts/sidebar/layer/use-node-status.d.ts +7 -0
- package/types/layouts/workspace/Workspace.vue.d.ts +2 -11
- package/types/layouts/workspace/viewer/Stage.vue.d.ts +1 -1
- package/types/services/dataSource.d.ts +3 -0
- package/types/services/editor.d.ts +1 -0
- package/types/type.d.ts +60 -0
- package/types/utils/dep.d.ts +1 -1
- package/types/utils/editor.d.ts +3 -2
- package/src/layouts/sidebar/LayerNode.vue +0 -40
- package/src/layouts/sidebar/LayerPanel.vue +0 -369
- package/types/Editor.vue.d.ts +0 -233
- /package/src/layouts/sidebar/{LayerMenu.vue → layer/LayerMenu.vue} +0 -0
package/dist/tmagic-editor.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import { defineComponent, ref, watch, onMounted, onUnmounted, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, Fragment, createTextVNode, createCommentVNode, toRaw, resolveDynamicComponent, nextTick, mergeProps, toDisplayString, renderList, watchEffect, withModifiers, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, withDirectives, vShow, createStaticVNode, Transition, onBeforeUnmount, toHandlers,
|
|
2
|
-
import { FullScreen, Edit, View, Coin, Delete, Plus, Close, ArrowDown, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Aim, CopyDocument, DocumentCopy, Files, Hide, Goods, List, EditPen, Top, Bottom, ArrowLeftBold, ArrowRightBold, CaretBottom } from '@element-plus/icons-vue';
|
|
3
|
-
import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, map, has,
|
|
1
|
+
import { defineComponent, ref, watch, onMounted, onUnmounted, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, Fragment, createTextVNode, createCommentVNode, toRaw, resolveDynamicComponent, nextTick, mergeProps, toDisplayString, renderList, watchEffect, withModifiers, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, withDirectives, vShow, createStaticVNode, Transition, onBeforeUnmount, provide, toHandlers, mergeDefaults } from 'vue';
|
|
2
|
+
import { FullScreen, Edit, View, Coin, Delete, Plus, Close, ArrowDown, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Aim, CopyDocument, DocumentCopy, Files, Hide, ArrowRight, Goods, List, EditPen, Top, Bottom, ArrowLeftBold, ArrowRightBold, CaretBottom } from '@element-plus/icons-vue';
|
|
3
|
+
import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, map, has, pick, keys } from 'lodash-es';
|
|
4
4
|
import * as monaco from 'monaco-editor';
|
|
5
5
|
import serialize from 'serialize-javascript';
|
|
6
|
-
import { TMagicButton, TMagicCard, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox, TMagicIcon, getConfig as getConfig$1, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicTree, TMagicPopover, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
|
|
6
|
+
import { TMagicButton, TMagicCard, tMagicMessage, TMagicDialog, TMagicTag, tMagicMessageBox, TMagicIcon, getConfig as getConfig$1, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicTree, TMagicPopover, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
|
|
7
7
|
import { HookType, NodeType, ActionType } from '@tmagic/schema';
|
|
8
8
|
import { MFormDrawer, MForm, createValues, MSelect } from '@tmagic/form';
|
|
9
9
|
import { MagicTable } from '@tmagic/table';
|
|
10
|
+
import { guid, isPop, getNodePath, isNumber, isPage, toLine, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getDefaultValueFromFields, addClassName, removeClassName, getKeys, removeClassNameByClassName, getNodes, isObject as isObject$1 } from '@tmagic/utils';
|
|
10
11
|
import Gesto from 'gesto';
|
|
11
|
-
import { guid, isPop, getNodePath, isNumber, isPage, toLine, removeClassNameByClassName, getNodes, isObject as isObject$1 } from '@tmagic/utils';
|
|
12
12
|
import StageCore, { GuidesType, StageDragStatus, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
13
13
|
import { EventEmitter } from 'events';
|
|
14
14
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
15
15
|
import KeyController from 'keycon';
|
|
16
16
|
|
|
17
|
+
let $TMAGIC_EDITOR = {};
|
|
18
|
+
const setConfig = (option) => {
|
|
19
|
+
$TMAGIC_EDITOR = option;
|
|
20
|
+
};
|
|
21
|
+
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
22
|
+
|
|
17
23
|
const _hoisted_1$w = {
|
|
18
24
|
class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
|
|
19
25
|
};
|
|
20
|
-
const _sfc_main$
|
|
26
|
+
const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
21
27
|
...{
|
|
22
28
|
name: "MEditorCodeEditor"
|
|
23
29
|
},
|
|
@@ -31,7 +37,8 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
31
37
|
tabSize: 2
|
|
32
38
|
}) },
|
|
33
39
|
height: {},
|
|
34
|
-
autoSave: { type: Boolean, default: true }
|
|
40
|
+
autoSave: { type: Boolean, default: true },
|
|
41
|
+
parse: { type: Boolean, default: false }
|
|
35
42
|
},
|
|
36
43
|
emits: ["initd", "save"],
|
|
37
44
|
setup(__props, { expose: __expose, emit }) {
|
|
@@ -39,7 +46,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
39
46
|
const toString = (v, language) => {
|
|
40
47
|
let value = "";
|
|
41
48
|
if (typeof v !== "string") {
|
|
42
|
-
if (
|
|
49
|
+
if (language === "json") {
|
|
43
50
|
value = JSON.stringify(v, null, 2);
|
|
44
51
|
} else {
|
|
45
52
|
value = serialize(v, {
|
|
@@ -55,6 +62,15 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
55
62
|
}
|
|
56
63
|
return value;
|
|
57
64
|
};
|
|
65
|
+
const parse = (v, language) => {
|
|
66
|
+
if (typeof v !== "string") {
|
|
67
|
+
return v;
|
|
68
|
+
}
|
|
69
|
+
if (language === "json") {
|
|
70
|
+
return JSON.parse(v);
|
|
71
|
+
}
|
|
72
|
+
return getConfig("parseDSL")(v);
|
|
73
|
+
};
|
|
58
74
|
let vsEditor = null;
|
|
59
75
|
let vsDiffEditor = null;
|
|
60
76
|
const values = ref("");
|
|
@@ -67,7 +83,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
67
83
|
}, 300)
|
|
68
84
|
);
|
|
69
85
|
const setEditorValue = (v, m) => {
|
|
70
|
-
values.value = toString(v, props.language);
|
|
86
|
+
values.value = toString(v, props.language.toLocaleLowerCase());
|
|
71
87
|
if (props.type === "diff") {
|
|
72
88
|
const originalModel = monaco.editor.createModel(values.value, "text/javascript");
|
|
73
89
|
const modifiedModel = monaco.editor.createModel(toString(m, props.language), "text/javascript");
|
|
@@ -102,7 +118,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
102
118
|
e.stopPropagation();
|
|
103
119
|
const newValue = getEditorValue();
|
|
104
120
|
values.value = newValue;
|
|
105
|
-
emit("save", newValue);
|
|
121
|
+
emit("save", props.parse ? parse(newValue, props.language) : newValue);
|
|
106
122
|
}
|
|
107
123
|
});
|
|
108
124
|
if (props.type !== "diff" && props.autoSave) {
|
|
@@ -110,7 +126,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
110
126
|
const newValue = getEditorValue();
|
|
111
127
|
if (values.value !== newValue) {
|
|
112
128
|
values.value = newValue;
|
|
113
|
-
emit("save", newValue);
|
|
129
|
+
emit("save", props.parse ? parse(newValue, props.language) : newValue);
|
|
114
130
|
}
|
|
115
131
|
});
|
|
116
132
|
}
|
|
@@ -192,7 +208,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
192
208
|
}
|
|
193
209
|
});
|
|
194
210
|
|
|
195
|
-
const _sfc_main$
|
|
211
|
+
const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
196
212
|
...{
|
|
197
213
|
name: "MEditorCode"
|
|
198
214
|
},
|
|
@@ -216,7 +232,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
216
232
|
emit("change", v);
|
|
217
233
|
};
|
|
218
234
|
return (_ctx, _cache) => {
|
|
219
|
-
return openBlock(), createBlock(_sfc_main$
|
|
235
|
+
return openBlock(), createBlock(_sfc_main$S, {
|
|
220
236
|
height: _ctx.config.height,
|
|
221
237
|
"init-values": _ctx.model[_ctx.name],
|
|
222
238
|
language: _ctx.config.language,
|
|
@@ -224,19 +240,14 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
224
240
|
..._ctx.config.options,
|
|
225
241
|
readOnly: _ctx.disabled
|
|
226
242
|
},
|
|
243
|
+
parse: _ctx.config.parse,
|
|
227
244
|
onSave: save
|
|
228
|
-
}, null, 8, ["height", "init-values", "language", "options"]);
|
|
245
|
+
}, null, 8, ["height", "init-values", "language", "options", "parse"]);
|
|
229
246
|
};
|
|
230
247
|
}
|
|
231
248
|
});
|
|
232
249
|
|
|
233
|
-
|
|
234
|
-
const setConfig = (option) => {
|
|
235
|
-
$TMAGIC_EDITOR = option;
|
|
236
|
-
};
|
|
237
|
-
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
238
|
-
|
|
239
|
-
const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
250
|
+
const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
240
251
|
...{
|
|
241
252
|
name: "MEditorCodeLink"
|
|
242
253
|
},
|
|
@@ -315,7 +326,7 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
|
315
326
|
}
|
|
316
327
|
});
|
|
317
328
|
|
|
318
|
-
const _sfc_main$
|
|
329
|
+
const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
319
330
|
...{
|
|
320
331
|
name: "MEditorCodeSelect"
|
|
321
332
|
},
|
|
@@ -388,10 +399,10 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
388
399
|
});
|
|
389
400
|
|
|
390
401
|
const _hoisted_1$v = { style: { "display": "flex", "margin-bottom": "10px" } };
|
|
391
|
-
const _hoisted_2$
|
|
392
|
-
const _hoisted_3$
|
|
393
|
-
const _hoisted_4$
|
|
394
|
-
const _sfc_main$
|
|
402
|
+
const _hoisted_2$p = { style: { "flex": "1" } };
|
|
403
|
+
const _hoisted_3$b = { style: { "flex": "1" } };
|
|
404
|
+
const _hoisted_4$7 = { class: "dialog-footer" };
|
|
405
|
+
const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
395
406
|
...{
|
|
396
407
|
name: "MEditorCodeBlockEditor"
|
|
397
408
|
},
|
|
@@ -610,7 +621,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
610
621
|
fullscreen: ""
|
|
611
622
|
}, {
|
|
612
623
|
footer: withCtx(() => [
|
|
613
|
-
createElementVNode("span", _hoisted_4$
|
|
624
|
+
createElementVNode("span", _hoisted_4$7, [
|
|
614
625
|
createVNode(unref(TMagicButton), {
|
|
615
626
|
size: "small",
|
|
616
627
|
onClick: _cache[1] || (_cache[1] = ($event) => difVisible.value = false)
|
|
@@ -634,7 +645,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
634
645
|
]),
|
|
635
646
|
default: withCtx(() => [
|
|
636
647
|
createElementVNode("div", _hoisted_1$v, [
|
|
637
|
-
createElementVNode("div", _hoisted_2$
|
|
648
|
+
createElementVNode("div", _hoisted_2$p, [
|
|
638
649
|
createVNode(unref(TMagicTag), {
|
|
639
650
|
size: "small",
|
|
640
651
|
type: "info"
|
|
@@ -645,7 +656,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
645
656
|
_: 1
|
|
646
657
|
})
|
|
647
658
|
]),
|
|
648
|
-
createElementVNode("div", _hoisted_3$
|
|
659
|
+
createElementVNode("div", _hoisted_3$b, [
|
|
649
660
|
createVNode(unref(TMagicTag), {
|
|
650
661
|
size: "small",
|
|
651
662
|
type: "success"
|
|
@@ -657,7 +668,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
657
668
|
})
|
|
658
669
|
])
|
|
659
670
|
]),
|
|
660
|
-
difVisible.value ? (openBlock(), createBlock(_sfc_main$
|
|
671
|
+
difVisible.value ? (openBlock(), createBlock(_sfc_main$S, {
|
|
661
672
|
key: 0,
|
|
662
673
|
ref_key: "magicVsEditor",
|
|
663
674
|
ref: magicVsEditor,
|
|
@@ -798,6 +809,17 @@ const fillConfig$1 = (config) => [
|
|
|
798
809
|
type: "event-select"
|
|
799
810
|
}
|
|
800
811
|
]
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
type: "panel",
|
|
815
|
+
title: "mock数据",
|
|
816
|
+
items: [
|
|
817
|
+
{
|
|
818
|
+
name: "mocks",
|
|
819
|
+
type: "data-source-mocks",
|
|
820
|
+
defaultValue: () => []
|
|
821
|
+
}
|
|
822
|
+
]
|
|
801
823
|
}
|
|
802
824
|
];
|
|
803
825
|
const getFormConfig = (type, configs) => {
|
|
@@ -979,7 +1001,8 @@ class DataSource extends BaseService {
|
|
|
979
1001
|
editable: true,
|
|
980
1002
|
configs: {},
|
|
981
1003
|
values: {},
|
|
982
|
-
events: {}
|
|
1004
|
+
events: {},
|
|
1005
|
+
methods: {}
|
|
983
1006
|
});
|
|
984
1007
|
set(name, value) {
|
|
985
1008
|
this.state[name] = value;
|
|
@@ -1005,6 +1028,12 @@ class DataSource extends BaseService {
|
|
|
1005
1028
|
setFormEvent(type, value = []) {
|
|
1006
1029
|
this.get("events")[type] = value;
|
|
1007
1030
|
}
|
|
1031
|
+
getFormMethod(type = "base") {
|
|
1032
|
+
return this.get("methods")[type] || [];
|
|
1033
|
+
}
|
|
1034
|
+
setFormMethod(type, value = []) {
|
|
1035
|
+
this.get("methods")[type] = value;
|
|
1036
|
+
}
|
|
1008
1037
|
add(config) {
|
|
1009
1038
|
const newConfig = {
|
|
1010
1039
|
...config,
|
|
@@ -1251,6 +1280,8 @@ const displayTabConfig = {
|
|
|
1251
1280
|
{
|
|
1252
1281
|
type: "groupList",
|
|
1253
1282
|
name: "displayConds",
|
|
1283
|
+
titlePrefix: "条件组",
|
|
1284
|
+
expandAll: true,
|
|
1254
1285
|
items: [
|
|
1255
1286
|
{
|
|
1256
1287
|
type: "table",
|
|
@@ -1259,6 +1290,7 @@ const displayTabConfig = {
|
|
|
1259
1290
|
{
|
|
1260
1291
|
type: "data-source-field-select",
|
|
1261
1292
|
name: "field",
|
|
1293
|
+
value: "key",
|
|
1262
1294
|
label: "字段"
|
|
1263
1295
|
},
|
|
1264
1296
|
{
|
|
@@ -1444,6 +1476,11 @@ var DepTargetType = /* @__PURE__ */ ((DepTargetType2) => {
|
|
|
1444
1476
|
DepTargetType2["DATA_SOURCE_COND"] = "data-source-cond";
|
|
1445
1477
|
return DepTargetType2;
|
|
1446
1478
|
})(DepTargetType || {});
|
|
1479
|
+
var DragType = /* @__PURE__ */ ((DragType2) => {
|
|
1480
|
+
DragType2["COMPONENT_LIST"] = "component-list";
|
|
1481
|
+
DragType2["LAYER_TREE"] = "layer-tree";
|
|
1482
|
+
return DragType2;
|
|
1483
|
+
})(DragType || {});
|
|
1447
1484
|
|
|
1448
1485
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
1449
1486
|
const getPageList = (app) => {
|
|
@@ -1466,9 +1503,9 @@ const generatePageName = (pageNameList) => {
|
|
|
1466
1503
|
};
|
|
1467
1504
|
const generatePageNameByApp = (app) => generatePageName(getPageNameList(getPageList(app)));
|
|
1468
1505
|
const isFixed = (node) => node.style?.position === "fixed";
|
|
1469
|
-
const getNodeIndex = (
|
|
1506
|
+
const getNodeIndex = (id, parent) => {
|
|
1470
1507
|
const items = parent?.items || [];
|
|
1471
|
-
return items.findIndex((item) => `${item.id}` === `${
|
|
1508
|
+
return items.findIndex((item) => `${item.id}` === `${id}`);
|
|
1472
1509
|
};
|
|
1473
1510
|
const getRelativeStyle = (style = {}) => ({
|
|
1474
1511
|
...style,
|
|
@@ -1604,6 +1641,15 @@ const serializeConfig = (config) => serialize(config, {
|
|
|
1604
1641
|
space: 2,
|
|
1605
1642
|
unsafe: true
|
|
1606
1643
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1644
|
+
const traverseNode = (node, cb, parents = []) => {
|
|
1645
|
+
cb(node, parents);
|
|
1646
|
+
if (node.items?.length) {
|
|
1647
|
+
parents.push(node);
|
|
1648
|
+
node.items.forEach((item) => {
|
|
1649
|
+
traverseNode(item, cb, parents);
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1607
1653
|
|
|
1608
1654
|
class UndoRedo {
|
|
1609
1655
|
elementList;
|
|
@@ -1982,7 +2028,7 @@ class Props extends BaseService {
|
|
|
1982
2028
|
}
|
|
1983
2029
|
const propsService = new Props();
|
|
1984
2030
|
|
|
1985
|
-
|
|
2031
|
+
class Editor extends BaseService {
|
|
1986
2032
|
state = reactive({
|
|
1987
2033
|
root: null,
|
|
1988
2034
|
page: null,
|
|
@@ -2017,7 +2063,8 @@ let Editor$1 = class Editor extends BaseService {
|
|
|
2017
2063
|
"move",
|
|
2018
2064
|
"undo",
|
|
2019
2065
|
"redo",
|
|
2020
|
-
"highlight"
|
|
2066
|
+
"highlight",
|
|
2067
|
+
"dragTo"
|
|
2021
2068
|
],
|
|
2022
2069
|
// 需要注意循环依赖问题,如果函数间有相互调用的话,不能设置为串行调用
|
|
2023
2070
|
["select", "update", "moveLayer"]
|
|
@@ -2160,7 +2207,7 @@ let Editor$1 = class Editor extends BaseService {
|
|
|
2160
2207
|
const parent = toRaw(this.getParentById(node.id));
|
|
2161
2208
|
if (!parent)
|
|
2162
2209
|
return node;
|
|
2163
|
-
const index = getNodeIndex(node, parent);
|
|
2210
|
+
const index = getNodeIndex(node.id, parent);
|
|
2164
2211
|
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
2165
2212
|
await this.select(nextNode);
|
|
2166
2213
|
this.get("stage")?.select(nextNode.id);
|
|
@@ -2173,7 +2220,7 @@ let Editor$1 = class Editor extends BaseService {
|
|
|
2173
2220
|
throw new Error("page不能为空");
|
|
2174
2221
|
if (!root)
|
|
2175
2222
|
throw new Error("root不能为空");
|
|
2176
|
-
const index = getNodeIndex(page, root);
|
|
2223
|
+
const index = getNodeIndex(page.id, root);
|
|
2177
2224
|
const nextPage = root.items[index + 1] || root.items[0];
|
|
2178
2225
|
await this.select(nextPage);
|
|
2179
2226
|
this.get("stage")?.select(nextPage.id);
|
|
@@ -2294,7 +2341,7 @@ let Editor$1 = class Editor extends BaseService {
|
|
|
2294
2341
|
const { parent, node: curNode } = this.getNodeInfo(node.id);
|
|
2295
2342
|
if (!parent || !curNode)
|
|
2296
2343
|
throw new Error("找不要删除的节点");
|
|
2297
|
-
const index = getNodeIndex(curNode, parent);
|
|
2344
|
+
const index = getNodeIndex(curNode.id, parent);
|
|
2298
2345
|
if (typeof index !== "number" || index === -1)
|
|
2299
2346
|
throw new Error("找不要删除的节点");
|
|
2300
2347
|
parent.items?.splice(index, 1);
|
|
@@ -2362,7 +2409,7 @@ let Editor$1 = class Editor extends BaseService {
|
|
|
2362
2409
|
if (!parent)
|
|
2363
2410
|
throw new Error("获取不到父级节点");
|
|
2364
2411
|
const parentNodeItems = parent.items;
|
|
2365
|
-
const index = getNodeIndex(newConfig, parent);
|
|
2412
|
+
const index = getNodeIndex(newConfig.id, parent);
|
|
2366
2413
|
if (!parentNodeItems || typeof index === "undefined" || index === -1)
|
|
2367
2414
|
throw new Error("更新的节点未找到");
|
|
2368
2415
|
const newLayout = await this.getLayout(newConfig);
|
|
@@ -2552,7 +2599,7 @@ let Editor$1 = class Editor extends BaseService {
|
|
|
2552
2599
|
const target = this.getNodeById(targetId, false);
|
|
2553
2600
|
const stage = this.get("stage");
|
|
2554
2601
|
if (root && node && parent && stage) {
|
|
2555
|
-
const index = getNodeIndex(node, parent);
|
|
2602
|
+
const index = getNodeIndex(node.id, parent);
|
|
2556
2603
|
parent.items?.splice(index, 1);
|
|
2557
2604
|
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
2558
2605
|
const layout = await this.getLayout(target);
|
|
@@ -2574,6 +2621,38 @@ let Editor$1 = class Editor extends BaseService {
|
|
|
2574
2621
|
return newConfig;
|
|
2575
2622
|
}
|
|
2576
2623
|
}
|
|
2624
|
+
async dragTo(config, targetParent, targetIndex) {
|
|
2625
|
+
if (!targetParent || !Array.isArray(targetParent.items))
|
|
2626
|
+
return;
|
|
2627
|
+
const { parent, node: curNode } = this.getNodeInfo(config.id, false);
|
|
2628
|
+
if (!parent || !curNode)
|
|
2629
|
+
throw new Error("找不要删除的节点");
|
|
2630
|
+
const index = getNodeIndex(curNode.id, parent);
|
|
2631
|
+
if (typeof index !== "number" || index === -1)
|
|
2632
|
+
throw new Error("找不要删除的节点");
|
|
2633
|
+
if (parent.id === targetParent.id) {
|
|
2634
|
+
if (index === targetIndex)
|
|
2635
|
+
return;
|
|
2636
|
+
if (index < targetIndex) {
|
|
2637
|
+
targetIndex -= 1;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
parent.items?.splice(index, 1);
|
|
2641
|
+
targetParent.items?.splice(targetIndex, 0, config);
|
|
2642
|
+
const page = this.get("page");
|
|
2643
|
+
const root = this.get("root");
|
|
2644
|
+
const stage = this.get("stage");
|
|
2645
|
+
if (stage && page && root) {
|
|
2646
|
+
stage.update({
|
|
2647
|
+
config: cloneDeep(page),
|
|
2648
|
+
parentId: root.id,
|
|
2649
|
+
root: cloneDeep(root)
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
this.addModifiedNodeId(config.id);
|
|
2653
|
+
this.addModifiedNodeId(parent.id);
|
|
2654
|
+
this.pushHistoryState();
|
|
2655
|
+
}
|
|
2577
2656
|
/**
|
|
2578
2657
|
* 撤销当前操作
|
|
2579
2658
|
* @returns 上一次数据
|
|
@@ -2718,8 +2797,8 @@ let Editor$1 = class Editor extends BaseService {
|
|
|
2718
2797
|
page
|
|
2719
2798
|
};
|
|
2720
2799
|
}
|
|
2721
|
-
}
|
|
2722
|
-
const editorService = new Editor
|
|
2800
|
+
}
|
|
2801
|
+
const editorService = new Editor();
|
|
2723
2802
|
|
|
2724
2803
|
const beforePaste = async (position, config) => {
|
|
2725
2804
|
if (!config[0]?.style)
|
|
@@ -2793,7 +2872,7 @@ const getDefaultConfig = async (addNode, parentNode) => {
|
|
|
2793
2872
|
return newNode;
|
|
2794
2873
|
};
|
|
2795
2874
|
|
|
2796
|
-
const _sfc_main$
|
|
2875
|
+
const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
2797
2876
|
...{
|
|
2798
2877
|
name: "MEditorCodeParams"
|
|
2799
2878
|
},
|
|
@@ -2843,7 +2922,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
2843
2922
|
});
|
|
2844
2923
|
|
|
2845
2924
|
const _hoisted_1$u = ["src"];
|
|
2846
|
-
const _sfc_main$
|
|
2925
|
+
const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
2847
2926
|
...{
|
|
2848
2927
|
name: "MEditorIcon"
|
|
2849
2928
|
},
|
|
@@ -2944,8 +3023,8 @@ const useCodeBlockEdit = (codeBlockService) => {
|
|
|
2944
3023
|
};
|
|
2945
3024
|
|
|
2946
3025
|
const _hoisted_1$t = { class: "m-fields-code-select-col" };
|
|
2947
|
-
const _hoisted_2$
|
|
2948
|
-
const _sfc_main$
|
|
3026
|
+
const _hoisted_2$o = { class: "code-select-container" };
|
|
3027
|
+
const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
2949
3028
|
...{
|
|
2950
3029
|
name: "MEditorCodeSelectCol"
|
|
2951
3030
|
},
|
|
@@ -3020,21 +3099,21 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
3020
3099
|
return (_ctx, _cache) => {
|
|
3021
3100
|
const _component_m_form_container = resolveComponent("m-form-container");
|
|
3022
3101
|
return openBlock(), createElementBlock("div", _hoisted_1$t, [
|
|
3023
|
-
createElementVNode("div", _hoisted_2$
|
|
3102
|
+
createElementVNode("div", _hoisted_2$o, [
|
|
3024
3103
|
createVNode(_component_m_form_container, {
|
|
3025
3104
|
class: "select",
|
|
3026
3105
|
config: selectConfig,
|
|
3027
3106
|
model: _ctx.model,
|
|
3028
3107
|
onChange: onParamsChangeHandler
|
|
3029
3108
|
}, null, 8, ["model"]),
|
|
3030
|
-
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$
|
|
3109
|
+
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$M, {
|
|
3031
3110
|
key: 0,
|
|
3032
3111
|
class: "icon",
|
|
3033
3112
|
icon: !_ctx.disabled ? unref(Edit) : unref(View),
|
|
3034
3113
|
onClick: _cache[0] || (_cache[0] = ($event) => unref(editCode)(_ctx.model[_ctx.name]))
|
|
3035
3114
|
}, null, 8, ["icon"])) : createCommentVNode("", true)
|
|
3036
3115
|
]),
|
|
3037
|
-
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$
|
|
3116
|
+
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$N, {
|
|
3038
3117
|
key: 0,
|
|
3039
3118
|
name: "params",
|
|
3040
3119
|
model: _ctx.model,
|
|
@@ -3042,7 +3121,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
3042
3121
|
"params-config": paramsConfig.value,
|
|
3043
3122
|
onChange: onParamsChangeHandler
|
|
3044
3123
|
}, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true),
|
|
3045
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
3124
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
3046
3125
|
key: 1,
|
|
3047
3126
|
ref_key: "codeBlockEditor",
|
|
3048
3127
|
ref: codeBlockEditor,
|
|
@@ -3056,8 +3135,8 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
3056
3135
|
});
|
|
3057
3136
|
|
|
3058
3137
|
const _hoisted_1$s = { class: "m-editor-data-source-fields" };
|
|
3059
|
-
const _hoisted_2$
|
|
3060
|
-
const _sfc_main$
|
|
3138
|
+
const _hoisted_2$n = { class: "m-editor-data-source-fields-footer" };
|
|
3139
|
+
const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
3061
3140
|
...{
|
|
3062
3141
|
name: "MEditorDataSourceFields"
|
|
3063
3142
|
},
|
|
@@ -3079,11 +3158,11 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
3079
3158
|
const services = inject("services");
|
|
3080
3159
|
const addDialog = ref();
|
|
3081
3160
|
const fieldValues = ref({});
|
|
3082
|
-
const
|
|
3161
|
+
const fieldTitle = ref("");
|
|
3083
3162
|
const width = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
|
|
3084
3163
|
const newHandler = () => {
|
|
3085
3164
|
fieldValues.value = {};
|
|
3086
|
-
|
|
3165
|
+
fieldTitle.value = "新增属性";
|
|
3087
3166
|
addDialog.value?.show();
|
|
3088
3167
|
};
|
|
3089
3168
|
const fieldChange = ({ index, ...value }) => {
|
|
@@ -3123,7 +3202,7 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
3123
3202
|
...row,
|
|
3124
3203
|
index
|
|
3125
3204
|
};
|
|
3126
|
-
|
|
3205
|
+
fieldTitle.value = `编辑${row.title}`;
|
|
3127
3206
|
addDialog.value?.show();
|
|
3128
3207
|
}
|
|
3129
3208
|
},
|
|
@@ -3193,12 +3272,16 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
3193
3272
|
{
|
|
3194
3273
|
name: "defaultValue",
|
|
3195
3274
|
text: "默认值",
|
|
3275
|
+
height: "200px",
|
|
3276
|
+
parse: true,
|
|
3196
3277
|
type: (mForm, { model }) => {
|
|
3197
3278
|
if (model.type === "number")
|
|
3198
3279
|
return "number";
|
|
3199
3280
|
if (model.type === "boolean")
|
|
3200
3281
|
return "select";
|
|
3201
|
-
|
|
3282
|
+
if (model.type === "string")
|
|
3283
|
+
return "text";
|
|
3284
|
+
return "vs-code";
|
|
3202
3285
|
},
|
|
3203
3286
|
options: [
|
|
3204
3287
|
{ text: "true", value: true },
|
|
@@ -3215,22 +3298,98 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
3215
3298
|
name: "fields",
|
|
3216
3299
|
type: "data-source-fields",
|
|
3217
3300
|
defaultValue: [],
|
|
3218
|
-
display: (formState, { model }) => model.type === "object"
|
|
3301
|
+
display: (formState, { model }) => model.type === "object" || model.type === "array"
|
|
3302
|
+
}
|
|
3303
|
+
];
|
|
3304
|
+
const addFromJsonDialog = ref();
|
|
3305
|
+
const jsonFromConfig = [
|
|
3306
|
+
{
|
|
3307
|
+
name: "data",
|
|
3308
|
+
type: "vs-code",
|
|
3309
|
+
labelWidth: "0",
|
|
3310
|
+
language: "json",
|
|
3311
|
+
height: "600px",
|
|
3312
|
+
options: inject("codeOptions", {})
|
|
3219
3313
|
}
|
|
3220
3314
|
];
|
|
3315
|
+
const jsonFromValues = ref({
|
|
3316
|
+
data: {}
|
|
3317
|
+
});
|
|
3318
|
+
const newFromJsonHandler = () => {
|
|
3319
|
+
addFromJsonDialog.value?.show();
|
|
3320
|
+
};
|
|
3321
|
+
const getValueType = (value) => {
|
|
3322
|
+
if (Array.isArray(value))
|
|
3323
|
+
return "array";
|
|
3324
|
+
if (value === null)
|
|
3325
|
+
return "null";
|
|
3326
|
+
if (typeof value === "object")
|
|
3327
|
+
return "object";
|
|
3328
|
+
if (typeof value === "number")
|
|
3329
|
+
return "number";
|
|
3330
|
+
if (typeof value === "boolean")
|
|
3331
|
+
return "boolean";
|
|
3332
|
+
if (typeof value === "string")
|
|
3333
|
+
return "string";
|
|
3334
|
+
return "any";
|
|
3335
|
+
};
|
|
3336
|
+
const getFieldsConfig = (value) => {
|
|
3337
|
+
if (!value || typeof value !== "object")
|
|
3338
|
+
throw new Error("数据格式错误");
|
|
3339
|
+
const fields = [];
|
|
3340
|
+
Object.entries(value).forEach(([key, value2]) => {
|
|
3341
|
+
const type = getValueType(value2);
|
|
3342
|
+
let childFields = [];
|
|
3343
|
+
if (Array.isArray(value2) && value2.length > 0) {
|
|
3344
|
+
childFields = getFieldsConfig(value2[0]);
|
|
3345
|
+
} else if (type === "object") {
|
|
3346
|
+
childFields = getFieldsConfig(value2);
|
|
3347
|
+
}
|
|
3348
|
+
fields.push({
|
|
3349
|
+
name: key,
|
|
3350
|
+
title: key,
|
|
3351
|
+
type,
|
|
3352
|
+
defaultValue: value2,
|
|
3353
|
+
fields: childFields
|
|
3354
|
+
});
|
|
3355
|
+
});
|
|
3356
|
+
return fields;
|
|
3357
|
+
};
|
|
3358
|
+
const addFromJsonFromChange = ({ data }) => {
|
|
3359
|
+
console.log(data);
|
|
3360
|
+
try {
|
|
3361
|
+
const value = JSON.parse(data);
|
|
3362
|
+
props.model[props.name] = getFieldsConfig(value);
|
|
3363
|
+
addFromJsonDialog.value?.hide();
|
|
3364
|
+
emit("change", props.model[props.name]);
|
|
3365
|
+
} catch (e) {
|
|
3366
|
+
tMagicMessage.error(e.message);
|
|
3367
|
+
}
|
|
3368
|
+
};
|
|
3221
3369
|
return (_ctx, _cache) => {
|
|
3222
3370
|
return openBlock(), createElementBlock("div", _hoisted_1$s, [
|
|
3223
3371
|
createVNode(unref(MagicTable), {
|
|
3224
3372
|
data: _ctx.model[_ctx.name],
|
|
3225
3373
|
columns: fieldColumns
|
|
3226
3374
|
}, null, 8, ["data"]),
|
|
3227
|
-
createElementVNode("div", _hoisted_2$
|
|
3375
|
+
createElementVNode("div", _hoisted_2$n, [
|
|
3376
|
+
createVNode(unref(TMagicButton), {
|
|
3377
|
+
size: "small",
|
|
3378
|
+
disabled: _ctx.disabled,
|
|
3379
|
+
plain: "",
|
|
3380
|
+
onClick: _cache[0] || (_cache[0] = ($event) => newFromJsonHandler())
|
|
3381
|
+
}, {
|
|
3382
|
+
default: withCtx(() => [
|
|
3383
|
+
createTextVNode("快速添加")
|
|
3384
|
+
]),
|
|
3385
|
+
_: 1
|
|
3386
|
+
}, 8, ["disabled"]),
|
|
3228
3387
|
createVNode(unref(TMagicButton), {
|
|
3229
3388
|
size: "small",
|
|
3230
3389
|
type: "primary",
|
|
3231
3390
|
disabled: _ctx.disabled,
|
|
3232
3391
|
plain: "",
|
|
3233
|
-
onClick: _cache[
|
|
3392
|
+
onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
|
|
3234
3393
|
}, {
|
|
3235
3394
|
default: withCtx(() => [
|
|
3236
3395
|
createTextVNode("添加")
|
|
@@ -3242,20 +3401,30 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
3242
3401
|
ref_key: "addDialog",
|
|
3243
3402
|
ref: addDialog,
|
|
3244
3403
|
"label-width": "80px",
|
|
3245
|
-
title:
|
|
3404
|
+
title: fieldTitle.value,
|
|
3246
3405
|
config: dataSourceFieldsConfig,
|
|
3247
3406
|
values: fieldValues.value,
|
|
3248
3407
|
parentValues: _ctx.model[_ctx.name],
|
|
3249
3408
|
disabled: _ctx.disabled,
|
|
3250
3409
|
width: width.value,
|
|
3251
3410
|
onSubmit: fieldChange
|
|
3252
|
-
}, null, 8, ["title", "values", "parentValues", "disabled", "width"])
|
|
3411
|
+
}, null, 8, ["title", "values", "parentValues", "disabled", "width"]),
|
|
3412
|
+
createVNode(unref(MFormDrawer), {
|
|
3413
|
+
ref_key: "addFromJsonDialog",
|
|
3414
|
+
ref: addFromJsonDialog,
|
|
3415
|
+
title: "快速添加数据定义",
|
|
3416
|
+
config: jsonFromConfig,
|
|
3417
|
+
values: jsonFromValues.value,
|
|
3418
|
+
disabled: _ctx.disabled,
|
|
3419
|
+
width: width.value,
|
|
3420
|
+
onSubmit: addFromJsonFromChange
|
|
3421
|
+
}, null, 8, ["values", "disabled", "width"])
|
|
3253
3422
|
]);
|
|
3254
3423
|
};
|
|
3255
3424
|
}
|
|
3256
3425
|
});
|
|
3257
3426
|
|
|
3258
|
-
const _sfc_main$
|
|
3427
|
+
const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
3259
3428
|
__name: "DataSourceFieldSelect",
|
|
3260
3429
|
props: {
|
|
3261
3430
|
config: {},
|
|
@@ -3273,18 +3442,25 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
3273
3442
|
const props = __props;
|
|
3274
3443
|
const services = inject("services");
|
|
3275
3444
|
const dataSources = computed(() => services?.dataSourceService.get("dataSources"));
|
|
3276
|
-
const
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3445
|
+
const getOptionChildren = (fields = []) => fields.map((field) => ({
|
|
3446
|
+
label: field.title || field.name,
|
|
3447
|
+
value: field.name,
|
|
3448
|
+
children: field.type === "array" ? [] : getOptionChildren(field.fields)
|
|
3449
|
+
}));
|
|
3450
|
+
const cascaderConfig = computed(() => {
|
|
3451
|
+
const valueIsKey = props.config.value === "key";
|
|
3452
|
+
return {
|
|
3453
|
+
type: "cascader",
|
|
3454
|
+
name: props.name,
|
|
3455
|
+
checkStrictly: !valueIsKey,
|
|
3456
|
+
text: "",
|
|
3457
|
+
options: () => dataSources.value?.filter((ds) => ds.fields?.length)?.map((ds) => ({
|
|
3458
|
+
label: ds.title || ds.id,
|
|
3459
|
+
value: valueIsKey ? ds.id : `${DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX}${ds.id}`,
|
|
3460
|
+
children: getOptionChildren(ds.fields)
|
|
3461
|
+
})) || []
|
|
3462
|
+
};
|
|
3463
|
+
});
|
|
3288
3464
|
const onChangeHandler = (value) => {
|
|
3289
3465
|
emit("change", value);
|
|
3290
3466
|
};
|
|
@@ -3293,7 +3469,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
3293
3469
|
return openBlock(), createBlock(_component_m_form_container, {
|
|
3294
3470
|
config: {
|
|
3295
3471
|
..._ctx.config,
|
|
3296
|
-
...cascaderConfig
|
|
3472
|
+
...cascaderConfig.value
|
|
3297
3473
|
},
|
|
3298
3474
|
model: _ctx.model,
|
|
3299
3475
|
onChange: onChangeHandler
|
|
@@ -3303,9 +3479,9 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
3303
3479
|
});
|
|
3304
3480
|
|
|
3305
3481
|
const _hoisted_1$r = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
|
|
3306
|
-
const _hoisted_2$
|
|
3307
|
-
const _hoisted_3$
|
|
3308
|
-
const _sfc_main$
|
|
3482
|
+
const _hoisted_2$m = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
|
|
3483
|
+
const _hoisted_3$a = { class: "el-input__inner" };
|
|
3484
|
+
const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
3309
3485
|
...{
|
|
3310
3486
|
name: "MEditorDataSourceInput"
|
|
3311
3487
|
},
|
|
@@ -3494,12 +3670,12 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
3494
3670
|
}
|
|
3495
3671
|
), {
|
|
3496
3672
|
suffix: withCtx(() => [
|
|
3497
|
-
createVNode(_sfc_main$
|
|
3673
|
+
createVNode(_sfc_main$M, { icon: unref(Coin) }, null, 8, ["icon"])
|
|
3498
3674
|
]),
|
|
3499
3675
|
default: withCtx(({ item }) => [
|
|
3500
3676
|
createElementVNode("div", _hoisted_1$r, [
|
|
3501
3677
|
createElementVNode("div", null, toDisplayString(item.text), 1),
|
|
3502
|
-
createElementVNode("span", _hoisted_2$
|
|
3678
|
+
createElementVNode("span", _hoisted_2$m, toDisplayString(item.value), 1)
|
|
3503
3679
|
])
|
|
3504
3680
|
]),
|
|
3505
3681
|
_: 1
|
|
@@ -3511,7 +3687,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
3511
3687
|
createElementVNode("div", {
|
|
3512
3688
|
class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
|
|
3513
3689
|
}, [
|
|
3514
|
-
createElementVNode("div", _hoisted_3$
|
|
3690
|
+
createElementVNode("div", _hoisted_3$a, [
|
|
3515
3691
|
(openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
|
|
3516
3692
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
3517
3693
|
item.type === "text" ? (openBlock(), createElementBlock("span", {
|
|
@@ -3529,7 +3705,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
3529
3705
|
}, 1032, ["size"])) : createCommentVNode("", true)
|
|
3530
3706
|
], 64);
|
|
3531
3707
|
}), 256)),
|
|
3532
|
-
createVNode(_sfc_main$
|
|
3708
|
+
createVNode(_sfc_main$M, {
|
|
3533
3709
|
class: "tmagic-data-source-input-icon",
|
|
3534
3710
|
icon: unref(Coin)
|
|
3535
3711
|
}, null, 8, ["icon"])
|
|
@@ -3613,8 +3789,8 @@ const useDataSourceMethod = () => {
|
|
|
3613
3789
|
};
|
|
3614
3790
|
|
|
3615
3791
|
const _hoisted_1$q = { class: "m-editor-data-source-methods" };
|
|
3616
|
-
const _hoisted_2$
|
|
3617
|
-
const _sfc_main$
|
|
3792
|
+
const _hoisted_2$l = { class: "m-editor-data-source-methods-footer" };
|
|
3793
|
+
const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
3618
3794
|
...{
|
|
3619
3795
|
name: "MEditorDataSourceMethods"
|
|
3620
3796
|
},
|
|
@@ -3688,7 +3864,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
3688
3864
|
data: _ctx.model[_ctx.name],
|
|
3689
3865
|
columns: methodColumns
|
|
3690
3866
|
}, null, 8, ["data"]),
|
|
3691
|
-
createElementVNode("div", _hoisted_2$
|
|
3867
|
+
createElementVNode("div", _hoisted_2$l, [
|
|
3692
3868
|
createVNode(unref(TMagicButton), {
|
|
3693
3869
|
size: "small",
|
|
3694
3870
|
type: "primary",
|
|
@@ -3702,7 +3878,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
3702
3878
|
_: 1
|
|
3703
3879
|
}, 8, ["disabled"])
|
|
3704
3880
|
]),
|
|
3705
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
3881
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
3706
3882
|
key: 0,
|
|
3707
3883
|
ref_key: "codeBlockEditor",
|
|
3708
3884
|
ref: codeBlockEditor,
|
|
@@ -3718,8 +3894,8 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
3718
3894
|
});
|
|
3719
3895
|
|
|
3720
3896
|
const _hoisted_1$p = { class: "m-fields-data-source-method-select" };
|
|
3721
|
-
const _hoisted_2$
|
|
3722
|
-
const _sfc_main$
|
|
3897
|
+
const _hoisted_2$k = { class: "data-source-method-select-container" };
|
|
3898
|
+
const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
3723
3899
|
...{
|
|
3724
3900
|
name: "MEditorDataSourceMethodSelect"
|
|
3725
3901
|
},
|
|
@@ -3739,7 +3915,8 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
3739
3915
|
setup(__props, { emit }) {
|
|
3740
3916
|
const props = __props;
|
|
3741
3917
|
const services = inject("services");
|
|
3742
|
-
const
|
|
3918
|
+
const dataSourceService = services?.dataSourceService;
|
|
3919
|
+
const dataSources = computed(() => dataSourceService?.get("dataSources"));
|
|
3743
3920
|
const getParamItemsConfig = ([dataSourceId, medthodName] = ["", ""]) => {
|
|
3744
3921
|
if (!dataSourceId)
|
|
3745
3922
|
return [];
|
|
@@ -3761,24 +3938,30 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
3761
3938
|
props.model.params = {};
|
|
3762
3939
|
}
|
|
3763
3940
|
};
|
|
3764
|
-
const
|
|
3941
|
+
const methodsOptions = computed(
|
|
3942
|
+
() => dataSources.value?.filter((ds) => ds.methods?.length || dataSourceService?.getFormMethod(ds.type).length)?.map((ds) => ({
|
|
3943
|
+
label: ds.title || ds.id,
|
|
3944
|
+
value: ds.id,
|
|
3945
|
+
children: [
|
|
3946
|
+
...dataSourceService?.getFormMethod(ds.type) || [],
|
|
3947
|
+
...(ds.methods || []).map((method) => ({
|
|
3948
|
+
label: method.name,
|
|
3949
|
+
value: method.name
|
|
3950
|
+
}))
|
|
3951
|
+
]
|
|
3952
|
+
})) || []
|
|
3953
|
+
);
|
|
3954
|
+
const cascaderConfig = computed(() => ({
|
|
3765
3955
|
type: "cascader",
|
|
3766
3956
|
text: "数据源方法",
|
|
3767
3957
|
name: props.name,
|
|
3768
3958
|
labelWidth: "80px",
|
|
3769
|
-
options:
|
|
3770
|
-
label: ds.title || ds.id,
|
|
3771
|
-
value: ds.id,
|
|
3772
|
-
children: ds.methods?.map((method) => ({
|
|
3773
|
-
label: method.name,
|
|
3774
|
-
value: method.name
|
|
3775
|
-
}))
|
|
3776
|
-
})) || [],
|
|
3959
|
+
options: methodsOptions.value,
|
|
3777
3960
|
onChange: (formState, dataSourceMethod) => {
|
|
3778
3961
|
setParamsConfig(dataSourceMethod, formState);
|
|
3779
3962
|
return dataSourceMethod;
|
|
3780
3963
|
}
|
|
3781
|
-
};
|
|
3964
|
+
}));
|
|
3782
3965
|
const onChangeHandler = (value) => {
|
|
3783
3966
|
props.model.params = value.params;
|
|
3784
3967
|
emit("change", props.model);
|
|
@@ -3786,7 +3969,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
3786
3969
|
const { codeBlockEditor, codeConfig, editCode, submitCode } = useDataSourceMethod();
|
|
3787
3970
|
const editCodeHandler = () => {
|
|
3788
3971
|
const [id, name] = props.model[props.name];
|
|
3789
|
-
const dataSource =
|
|
3972
|
+
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
3790
3973
|
if (!dataSource)
|
|
3791
3974
|
return;
|
|
3792
3975
|
editCode(dataSource, name);
|
|
@@ -3798,21 +3981,21 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
3798
3981
|
return (_ctx, _cache) => {
|
|
3799
3982
|
const _component_m_form_container = resolveComponent("m-form-container");
|
|
3800
3983
|
return openBlock(), createElementBlock("div", _hoisted_1$p, [
|
|
3801
|
-
createElementVNode("div", _hoisted_2$
|
|
3984
|
+
createElementVNode("div", _hoisted_2$k, [
|
|
3802
3985
|
createVNode(_component_m_form_container, {
|
|
3803
3986
|
class: "select",
|
|
3804
|
-
config: cascaderConfig,
|
|
3987
|
+
config: cascaderConfig.value,
|
|
3805
3988
|
model: _ctx.model,
|
|
3806
3989
|
onChange: onChangeHandler
|
|
3807
|
-
}, null, 8, ["model"]),
|
|
3808
|
-
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$
|
|
3990
|
+
}, null, 8, ["config", "model"]),
|
|
3991
|
+
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$M, {
|
|
3809
3992
|
key: 0,
|
|
3810
3993
|
class: "icon",
|
|
3811
3994
|
icon: !_ctx.disabled ? unref(Edit) : unref(View),
|
|
3812
3995
|
onClick: editCodeHandler
|
|
3813
3996
|
}, null, 8, ["icon"])) : createCommentVNode("", true)
|
|
3814
3997
|
]),
|
|
3815
|
-
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$
|
|
3998
|
+
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$N, {
|
|
3816
3999
|
key: 0,
|
|
3817
4000
|
name: "params",
|
|
3818
4001
|
model: _ctx.model,
|
|
@@ -3821,7 +4004,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
3821
4004
|
"params-config": paramsConfig.value,
|
|
3822
4005
|
onChange: onChangeHandler
|
|
3823
4006
|
}, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true),
|
|
3824
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
4007
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
3825
4008
|
key: 1,
|
|
3826
4009
|
ref_key: "codeBlockEditor",
|
|
3827
4010
|
ref: codeBlockEditor,
|
|
@@ -3834,11 +4017,13 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
3834
4017
|
}
|
|
3835
4018
|
});
|
|
3836
4019
|
|
|
3837
|
-
const
|
|
4020
|
+
const _hoisted_1$o = { class: "m-editor-data-source-fields" };
|
|
4021
|
+
const _hoisted_2$j = { class: "m-editor-data-source-fields-footer" };
|
|
4022
|
+
const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
3838
4023
|
...{
|
|
3839
|
-
name: "
|
|
4024
|
+
name: "MEditorDataSourceMocks"
|
|
3840
4025
|
},
|
|
3841
|
-
__name: "
|
|
4026
|
+
__name: "DataSourceMocks",
|
|
3842
4027
|
props: {
|
|
3843
4028
|
config: {},
|
|
3844
4029
|
model: {},
|
|
@@ -3851,132 +4036,367 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
3851
4036
|
lastValues: {}
|
|
3852
4037
|
},
|
|
3853
4038
|
emits: ["change"],
|
|
3854
|
-
setup(__props, { emit }) {
|
|
3855
|
-
const props = __props;
|
|
3856
|
-
const { dataSourceService } = inject("services") || {};
|
|
3857
|
-
const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
|
|
3858
|
-
const selectConfig = computed(() => {
|
|
3859
|
-
const { type, dataSourceType, ...config } = props.config;
|
|
3860
|
-
return {
|
|
3861
|
-
...config,
|
|
3862
|
-
type: "select",
|
|
3863
|
-
valueKey: "dataSourceId",
|
|
3864
|
-
options: dataSources.value.filter((ds) => !dataSourceType || ds.type === dataSourceType).map((ds) => ({
|
|
3865
|
-
value: {
|
|
3866
|
-
isBindDataSource: true,
|
|
3867
|
-
dataSourceType: ds.type,
|
|
3868
|
-
dataSourceId: ds.id
|
|
3869
|
-
},
|
|
3870
|
-
text: ds.title || ds.id
|
|
3871
|
-
}))
|
|
3872
|
-
};
|
|
3873
|
-
});
|
|
3874
|
-
const changeHandler = (value) => {
|
|
3875
|
-
emit("change", value);
|
|
3876
|
-
};
|
|
3877
|
-
return (_ctx, _cache) => {
|
|
3878
|
-
return openBlock(), createBlock(unref(MSelect), {
|
|
3879
|
-
model: _ctx.model,
|
|
3880
|
-
name: _ctx.name,
|
|
3881
|
-
size: _ctx.size,
|
|
3882
|
-
prop: _ctx.prop,
|
|
3883
|
-
disabled: _ctx.disabled,
|
|
3884
|
-
config: selectConfig.value,
|
|
3885
|
-
"last-values": _ctx.lastValues,
|
|
3886
|
-
onChange: changeHandler
|
|
3887
|
-
}, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]);
|
|
3888
|
-
};
|
|
3889
|
-
}
|
|
3890
|
-
});
|
|
3891
|
-
|
|
3892
|
-
const _hoisted_1$o = { class: "m-fields-event-select" };
|
|
3893
|
-
const _hoisted_2$h = {
|
|
3894
|
-
key: 1,
|
|
3895
|
-
class: "fullWidth"
|
|
3896
|
-
};
|
|
3897
|
-
const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
3898
|
-
...{
|
|
3899
|
-
name: "MEditorEventSelect"
|
|
3900
|
-
},
|
|
3901
|
-
__name: "EventSelect",
|
|
3902
|
-
props: {
|
|
3903
|
-
config: {},
|
|
3904
|
-
model: {},
|
|
3905
|
-
initValues: {},
|
|
3906
|
-
values: {},
|
|
3907
|
-
name: {},
|
|
3908
|
-
prop: {},
|
|
3909
|
-
disabled: { type: Boolean },
|
|
3910
|
-
size: {},
|
|
3911
|
-
lastValues: {}
|
|
3912
|
-
},
|
|
3913
|
-
emits: ["change"],
|
|
3914
4039
|
setup(__props, { emit }) {
|
|
3915
4040
|
const props = __props;
|
|
3916
4041
|
const services = inject("services");
|
|
3917
|
-
const
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
if (props.config.src === "component") {
|
|
3928
|
-
events = services.eventsService.getEvent(formValue.type);
|
|
3929
|
-
} else if (props.config.src === "datasource") {
|
|
3930
|
-
events = services.dataSourceService.getFormEvent(formValue.type);
|
|
3931
|
-
}
|
|
3932
|
-
return events.map((option) => ({
|
|
3933
|
-
text: option.label,
|
|
3934
|
-
value: option.value
|
|
3935
|
-
}));
|
|
3936
|
-
}
|
|
3937
|
-
};
|
|
3938
|
-
return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
|
|
3939
|
-
});
|
|
3940
|
-
const actionTypeConfig = computed(() => {
|
|
3941
|
-
const defaultActionTypeConfig = {
|
|
3942
|
-
name: "actionType",
|
|
3943
|
-
text: "联动类型",
|
|
3944
|
-
labelWidth: "80px",
|
|
3945
|
-
type: "select",
|
|
3946
|
-
defaultValue: ActionType.COMP,
|
|
3947
|
-
options: () => [
|
|
3948
|
-
{
|
|
3949
|
-
text: "组件",
|
|
3950
|
-
label: "组件",
|
|
3951
|
-
value: ActionType.COMP
|
|
3952
|
-
},
|
|
4042
|
+
const width = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
|
|
4043
|
+
const addDialog = ref();
|
|
4044
|
+
const drawerTitle = ref("");
|
|
4045
|
+
const formValues = ref({});
|
|
4046
|
+
const formConfig = [
|
|
4047
|
+
{ name: "index", type: "hidden", filter: "number", defaultValue: -1 },
|
|
4048
|
+
{
|
|
4049
|
+
name: "title",
|
|
4050
|
+
text: "名称",
|
|
4051
|
+
rules: [
|
|
3953
4052
|
{
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
disabled: !Object.keys(services?.codeBlockService.getCodeDsl() || {}).length,
|
|
3957
|
-
value: ActionType.CODE
|
|
4053
|
+
required: true,
|
|
4054
|
+
message: "请输入字段名称"
|
|
3958
4055
|
},
|
|
3959
4056
|
{
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
disabled: !services?.dataSourceService.get("dataSources")?.filter((ds) => ds.methods?.length).length,
|
|
3963
|
-
value: ActionType.DATA_SOURCE
|
|
4057
|
+
required: true,
|
|
4058
|
+
message: "请输入名称"
|
|
3964
4059
|
}
|
|
3965
4060
|
]
|
|
3966
|
-
}
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
type: "
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
4061
|
+
},
|
|
4062
|
+
{
|
|
4063
|
+
name: "description",
|
|
4064
|
+
text: "描述"
|
|
4065
|
+
},
|
|
4066
|
+
{
|
|
4067
|
+
name: "enable",
|
|
4068
|
+
text: "启用",
|
|
4069
|
+
type: "switch"
|
|
4070
|
+
},
|
|
4071
|
+
{
|
|
4072
|
+
name: "useInEditor",
|
|
4073
|
+
text: "编辑器中使用",
|
|
4074
|
+
type: "switch"
|
|
4075
|
+
},
|
|
4076
|
+
{
|
|
4077
|
+
name: "data",
|
|
4078
|
+
text: "mock数据",
|
|
4079
|
+
type: "vs-code",
|
|
4080
|
+
language: "json",
|
|
4081
|
+
options: inject("codeOptions", {}),
|
|
4082
|
+
defaultValue: "{}",
|
|
4083
|
+
height: "400px",
|
|
4084
|
+
onChange: (formState, v) => {
|
|
4085
|
+
if (typeof v !== "string")
|
|
4086
|
+
return v;
|
|
4087
|
+
return JSON.parse(v);
|
|
4088
|
+
},
|
|
4089
|
+
rules: [
|
|
4090
|
+
{
|
|
4091
|
+
validator: ({ value, callback }) => {
|
|
4092
|
+
if (typeof value !== "string")
|
|
4093
|
+
return callback();
|
|
4094
|
+
try {
|
|
4095
|
+
JSON.parse(value);
|
|
4096
|
+
callback();
|
|
4097
|
+
} catch (error) {
|
|
4098
|
+
callback(error);
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
]
|
|
4103
|
+
}
|
|
4104
|
+
];
|
|
4105
|
+
const columns = [
|
|
4106
|
+
{
|
|
4107
|
+
type: "expand",
|
|
4108
|
+
component: _sfc_main$S,
|
|
4109
|
+
props: (row) => ({
|
|
4110
|
+
initValues: row.data,
|
|
4111
|
+
language: "json",
|
|
4112
|
+
height: "150px",
|
|
4113
|
+
options: {
|
|
4114
|
+
readOnly: true
|
|
4115
|
+
}
|
|
4116
|
+
})
|
|
4117
|
+
},
|
|
4118
|
+
{
|
|
4119
|
+
label: "名称",
|
|
4120
|
+
prop: "title"
|
|
4121
|
+
},
|
|
4122
|
+
{
|
|
4123
|
+
label: "描述",
|
|
4124
|
+
prop: "description"
|
|
4125
|
+
},
|
|
4126
|
+
{
|
|
4127
|
+
label: "是否启用",
|
|
4128
|
+
prop: "enable",
|
|
4129
|
+
type: "component",
|
|
4130
|
+
component: TMagicSwitch,
|
|
4131
|
+
props: (row) => ({
|
|
4132
|
+
modelValue: row.enable,
|
|
4133
|
+
activeValue: true,
|
|
4134
|
+
inactiveValue: false
|
|
4135
|
+
}),
|
|
4136
|
+
listeners: (row, index) => ({
|
|
4137
|
+
"update:modelValue": (v) => {
|
|
4138
|
+
toggleValue(row, "enable", v, index);
|
|
4139
|
+
}
|
|
4140
|
+
})
|
|
4141
|
+
},
|
|
4142
|
+
{
|
|
4143
|
+
label: "编辑器中使用",
|
|
4144
|
+
prop: "useInEditor",
|
|
4145
|
+
type: "component",
|
|
4146
|
+
component: TMagicSwitch,
|
|
4147
|
+
props: (row) => ({
|
|
4148
|
+
modelValue: row.useInEditor,
|
|
4149
|
+
activeValue: true,
|
|
4150
|
+
inactiveValue: false
|
|
4151
|
+
}),
|
|
4152
|
+
listeners: (row, index) => ({
|
|
4153
|
+
"update:modelValue": (v) => {
|
|
4154
|
+
toggleValue(row, "useInEditor", v, index);
|
|
4155
|
+
}
|
|
4156
|
+
})
|
|
4157
|
+
},
|
|
4158
|
+
{
|
|
4159
|
+
label: "操作",
|
|
4160
|
+
fixed: "right",
|
|
4161
|
+
actions: [
|
|
4162
|
+
{
|
|
4163
|
+
text: "编辑",
|
|
4164
|
+
handler: (row, index) => {
|
|
4165
|
+
formValues.value = {
|
|
4166
|
+
...row,
|
|
4167
|
+
index
|
|
4168
|
+
};
|
|
4169
|
+
drawerTitle.value = `编辑${row.title}`;
|
|
4170
|
+
addDialog.value?.show();
|
|
4171
|
+
}
|
|
4172
|
+
},
|
|
4173
|
+
{
|
|
4174
|
+
text: "删除",
|
|
4175
|
+
buttonType: "danger",
|
|
4176
|
+
handler: async (row, index) => {
|
|
4177
|
+
await tMagicMessageBox.confirm(`确定删除${row.title}?`, "提示");
|
|
4178
|
+
props.model[props.name].splice(index, 1);
|
|
4179
|
+
emit("change", props.model[props.name]);
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
]
|
|
4183
|
+
}
|
|
4184
|
+
];
|
|
4185
|
+
const newHandler = () => {
|
|
4186
|
+
const isFirstRow = props.model[props.name].length === 0;
|
|
4187
|
+
formValues.value = {
|
|
4188
|
+
data: getDefaultValueFromFields(props.model.fields || []),
|
|
4189
|
+
useInEditor: isFirstRow,
|
|
4190
|
+
enable: isFirstRow
|
|
4191
|
+
};
|
|
4192
|
+
drawerTitle.value = "新增Mock";
|
|
4193
|
+
addDialog.value?.show();
|
|
4194
|
+
};
|
|
4195
|
+
const formChangeHandler = ({ index, ...value }) => {
|
|
4196
|
+
if (index > -1) {
|
|
4197
|
+
props.model[props.name][index] = value;
|
|
4198
|
+
} else {
|
|
4199
|
+
props.model[props.name].push(value);
|
|
4200
|
+
}
|
|
4201
|
+
addDialog.value?.hide();
|
|
4202
|
+
emit("change", props.model[props.name]);
|
|
4203
|
+
};
|
|
4204
|
+
const toggleValue = (row, key, value, index) => {
|
|
4205
|
+
if (value) {
|
|
4206
|
+
props.model[props.name].forEach((item) => {
|
|
4207
|
+
item[key] = false;
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
formChangeHandler({
|
|
4211
|
+
...row,
|
|
4212
|
+
[key]: value,
|
|
4213
|
+
index
|
|
4214
|
+
});
|
|
4215
|
+
};
|
|
4216
|
+
return (_ctx, _cache) => {
|
|
4217
|
+
return openBlock(), createElementBlock("div", _hoisted_1$o, [
|
|
4218
|
+
createVNode(unref(MagicTable), {
|
|
4219
|
+
data: _ctx.model[_ctx.name],
|
|
4220
|
+
columns
|
|
4221
|
+
}, null, 8, ["data"]),
|
|
4222
|
+
createElementVNode("div", _hoisted_2$j, [
|
|
4223
|
+
createVNode(unref(TMagicButton), {
|
|
4224
|
+
size: "small",
|
|
4225
|
+
type: "primary",
|
|
4226
|
+
disabled: _ctx.disabled,
|
|
4227
|
+
plain: "",
|
|
4228
|
+
onClick: _cache[0] || (_cache[0] = ($event) => newHandler())
|
|
4229
|
+
}, {
|
|
4230
|
+
default: withCtx(() => [
|
|
4231
|
+
createTextVNode("添加")
|
|
4232
|
+
]),
|
|
4233
|
+
_: 1
|
|
4234
|
+
}, 8, ["disabled"])
|
|
4235
|
+
]),
|
|
4236
|
+
createVNode(unref(MFormDrawer), {
|
|
4237
|
+
ref_key: "addDialog",
|
|
4238
|
+
ref: addDialog,
|
|
4239
|
+
"label-width": "120px",
|
|
4240
|
+
title: drawerTitle.value,
|
|
4241
|
+
config: formConfig,
|
|
4242
|
+
values: formValues.value,
|
|
4243
|
+
parentValues: _ctx.model[_ctx.name],
|
|
4244
|
+
disabled: _ctx.disabled,
|
|
4245
|
+
width: width.value,
|
|
4246
|
+
onSubmit: formChangeHandler
|
|
4247
|
+
}, null, 8, ["title", "values", "parentValues", "disabled", "width"])
|
|
4248
|
+
]);
|
|
4249
|
+
};
|
|
4250
|
+
}
|
|
4251
|
+
});
|
|
4252
|
+
|
|
4253
|
+
const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
4254
|
+
...{
|
|
4255
|
+
name: "MEditorDataSourceSelect"
|
|
4256
|
+
},
|
|
4257
|
+
__name: "DataSourceSelect",
|
|
4258
|
+
props: {
|
|
4259
|
+
config: {},
|
|
4260
|
+
model: {},
|
|
4261
|
+
initValues: {},
|
|
4262
|
+
values: {},
|
|
4263
|
+
name: {},
|
|
4264
|
+
prop: {},
|
|
4265
|
+
disabled: { type: Boolean, default: false },
|
|
4266
|
+
size: {},
|
|
4267
|
+
lastValues: {}
|
|
4268
|
+
},
|
|
4269
|
+
emits: ["change"],
|
|
4270
|
+
setup(__props, { emit }) {
|
|
4271
|
+
const props = __props;
|
|
4272
|
+
const { dataSourceService } = inject("services") || {};
|
|
4273
|
+
const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
|
|
4274
|
+
const selectConfig = computed(() => {
|
|
4275
|
+
const { type, dataSourceType, ...config } = props.config;
|
|
4276
|
+
return {
|
|
4277
|
+
...config,
|
|
4278
|
+
type: "select",
|
|
4279
|
+
valueKey: "dataSourceId",
|
|
4280
|
+
options: dataSources.value.filter((ds) => !dataSourceType || ds.type === dataSourceType).map((ds) => ({
|
|
4281
|
+
value: {
|
|
4282
|
+
isBindDataSource: true,
|
|
4283
|
+
dataSourceType: ds.type,
|
|
4284
|
+
dataSourceId: ds.id
|
|
4285
|
+
},
|
|
4286
|
+
text: ds.title || ds.id
|
|
4287
|
+
}))
|
|
4288
|
+
};
|
|
4289
|
+
});
|
|
4290
|
+
const changeHandler = (value) => {
|
|
4291
|
+
emit("change", value);
|
|
4292
|
+
};
|
|
4293
|
+
return (_ctx, _cache) => {
|
|
4294
|
+
return openBlock(), createBlock(unref(MSelect), {
|
|
4295
|
+
model: _ctx.model,
|
|
4296
|
+
name: _ctx.name,
|
|
4297
|
+
size: _ctx.size,
|
|
4298
|
+
prop: _ctx.prop,
|
|
4299
|
+
disabled: _ctx.disabled,
|
|
4300
|
+
config: selectConfig.value,
|
|
4301
|
+
"last-values": _ctx.lastValues,
|
|
4302
|
+
onChange: changeHandler
|
|
4303
|
+
}, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]);
|
|
4304
|
+
};
|
|
4305
|
+
}
|
|
4306
|
+
});
|
|
4307
|
+
|
|
4308
|
+
const _hoisted_1$n = { class: "m-fields-event-select" };
|
|
4309
|
+
const _hoisted_2$i = {
|
|
4310
|
+
key: 1,
|
|
4311
|
+
class: "fullWidth"
|
|
4312
|
+
};
|
|
4313
|
+
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
4314
|
+
...{
|
|
4315
|
+
name: "MEditorEventSelect"
|
|
4316
|
+
},
|
|
4317
|
+
__name: "EventSelect",
|
|
4318
|
+
props: {
|
|
4319
|
+
config: {},
|
|
4320
|
+
model: {},
|
|
4321
|
+
initValues: {},
|
|
4322
|
+
values: {},
|
|
4323
|
+
name: {},
|
|
4324
|
+
prop: {},
|
|
4325
|
+
disabled: { type: Boolean },
|
|
4326
|
+
size: {},
|
|
4327
|
+
lastValues: {}
|
|
4328
|
+
},
|
|
4329
|
+
emits: ["change"],
|
|
4330
|
+
setup(__props, { emit }) {
|
|
4331
|
+
const props = __props;
|
|
4332
|
+
const services = inject("services");
|
|
4333
|
+
const editorService = services?.editorService;
|
|
4334
|
+
const dataSourceService = services?.dataSourceService;
|
|
4335
|
+
const eventsService = services?.eventsService;
|
|
4336
|
+
const codeBlockService = services?.codeBlockService;
|
|
4337
|
+
const eventNameConfig = computed(() => {
|
|
4338
|
+
const defaultEventNameConfig = {
|
|
4339
|
+
name: "name",
|
|
4340
|
+
text: "事件",
|
|
4341
|
+
type: "select",
|
|
4342
|
+
labelWidth: "40px",
|
|
4343
|
+
options: (mForm, { formValue }) => {
|
|
4344
|
+
let events = [];
|
|
4345
|
+
if (!eventsService || !dataSourceService)
|
|
4346
|
+
return events;
|
|
4347
|
+
if (props.config.src === "component") {
|
|
4348
|
+
events = eventsService.getEvent(formValue.type);
|
|
4349
|
+
} else if (props.config.src === "datasource") {
|
|
4350
|
+
events = dataSourceService.getFormEvent(formValue.type);
|
|
4351
|
+
}
|
|
4352
|
+
return events.map((option) => ({
|
|
4353
|
+
text: option.label,
|
|
4354
|
+
value: option.value
|
|
4355
|
+
}));
|
|
4356
|
+
}
|
|
4357
|
+
};
|
|
4358
|
+
return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
|
|
4359
|
+
});
|
|
4360
|
+
const actionTypeConfig = computed(() => {
|
|
4361
|
+
const defaultActionTypeConfig = {
|
|
4362
|
+
name: "actionType",
|
|
4363
|
+
text: "联动类型",
|
|
4364
|
+
labelWidth: "80px",
|
|
4365
|
+
type: "select",
|
|
4366
|
+
defaultValue: ActionType.COMP,
|
|
4367
|
+
options: () => [
|
|
4368
|
+
{
|
|
4369
|
+
text: "组件",
|
|
4370
|
+
label: "组件",
|
|
4371
|
+
value: ActionType.COMP
|
|
4372
|
+
},
|
|
4373
|
+
{
|
|
4374
|
+
text: "代码",
|
|
4375
|
+
label: "代码",
|
|
4376
|
+
disabled: !Object.keys(codeBlockService?.getCodeDsl() || {}).length,
|
|
4377
|
+
value: ActionType.CODE
|
|
4378
|
+
},
|
|
4379
|
+
{
|
|
4380
|
+
text: "数据源",
|
|
4381
|
+
label: "数据源",
|
|
4382
|
+
disabled: !dataSourceService?.get("dataSources")?.filter((ds) => ds.methods?.length || dataSourceService?.getFormMethod(ds.type).length).length,
|
|
4383
|
+
value: ActionType.DATA_SOURCE
|
|
4384
|
+
}
|
|
4385
|
+
]
|
|
4386
|
+
};
|
|
4387
|
+
return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
|
|
4388
|
+
});
|
|
4389
|
+
const targetCompConfig = computed(() => {
|
|
4390
|
+
const defaultTargetCompConfig = {
|
|
4391
|
+
name: "to",
|
|
4392
|
+
text: "联动组件",
|
|
4393
|
+
labelWidth: "80px",
|
|
4394
|
+
type: "ui-select",
|
|
4395
|
+
display: (mForm, { model }) => model.actionType === ActionType.COMP
|
|
4396
|
+
};
|
|
4397
|
+
return { ...defaultTargetCompConfig, ...props.config.targetCompConfig };
|
|
4398
|
+
});
|
|
4399
|
+
const compActionConfig = computed(() => {
|
|
3980
4400
|
const defaultCompActionConfig = {
|
|
3981
4401
|
name: "method",
|
|
3982
4402
|
text: "动作",
|
|
@@ -3984,10 +4404,10 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
3984
4404
|
type: "select",
|
|
3985
4405
|
display: (mForm, { model }) => model.actionType === ActionType.COMP,
|
|
3986
4406
|
options: (mForm, { model }) => {
|
|
3987
|
-
const node =
|
|
4407
|
+
const node = editorService?.getNodeById(model.to);
|
|
3988
4408
|
if (!node?.type)
|
|
3989
4409
|
return [];
|
|
3990
|
-
return
|
|
4410
|
+
return eventsService?.getMethod(node.type).map((option) => ({
|
|
3991
4411
|
text: option.label,
|
|
3992
4412
|
value: option.value
|
|
3993
4413
|
}));
|
|
@@ -4000,7 +4420,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
4000
4420
|
type: "code-select-col",
|
|
4001
4421
|
labelWidth: 0,
|
|
4002
4422
|
name: "codeId",
|
|
4003
|
-
disabled: () => !
|
|
4423
|
+
disabled: () => !codeBlockService?.getEditStatus(),
|
|
4004
4424
|
display: (mForm, { model }) => model.actionType === ActionType.CODE
|
|
4005
4425
|
};
|
|
4006
4426
|
return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
|
|
@@ -4022,7 +4442,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
4022
4442
|
name: "name",
|
|
4023
4443
|
label: "事件名",
|
|
4024
4444
|
type: eventNameConfig.value.type,
|
|
4025
|
-
options: (mForm, { formValue }) =>
|
|
4445
|
+
options: (mForm, { formValue }) => eventsService?.getEvent(formValue.type).map((option) => ({
|
|
4026
4446
|
text: option.label,
|
|
4027
4447
|
value: option.value
|
|
4028
4448
|
}))
|
|
@@ -4037,10 +4457,10 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
4037
4457
|
label: "动作",
|
|
4038
4458
|
type: compActionConfig.value.type,
|
|
4039
4459
|
options: (mForm, { model }) => {
|
|
4040
|
-
const node =
|
|
4460
|
+
const node = editorService?.getNodeById(model.to);
|
|
4041
4461
|
if (!node?.type)
|
|
4042
4462
|
return [];
|
|
4043
|
-
return
|
|
4463
|
+
return eventsService?.getMethod(node.type).map((option) => ({
|
|
4044
4464
|
text: option.label,
|
|
4045
4465
|
value: option.value
|
|
4046
4466
|
}));
|
|
@@ -4094,7 +4514,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
4094
4514
|
const _component_m_form_table = resolveComponent("m-form-table");
|
|
4095
4515
|
const _component_m_form_container = resolveComponent("m-form-container");
|
|
4096
4516
|
const _component_m_form_panel = resolveComponent("m-form-panel");
|
|
4097
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4517
|
+
return openBlock(), createElementBlock("div", _hoisted_1$n, [
|
|
4098
4518
|
isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
|
|
4099
4519
|
key: 0,
|
|
4100
4520
|
ref: "eventForm",
|
|
@@ -4104,7 +4524,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
4104
4524
|
model: _ctx.model,
|
|
4105
4525
|
config: tableConfig.value,
|
|
4106
4526
|
onChange: onChangeHandler
|
|
4107
|
-
}, null, 8, ["size", "disabled", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$
|
|
4527
|
+
}, null, 8, ["size", "disabled", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$i, [
|
|
4108
4528
|
createVNode(unref(TMagicButton), {
|
|
4109
4529
|
class: "create-button",
|
|
4110
4530
|
type: "primary",
|
|
@@ -4153,9 +4573,9 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
4153
4573
|
}
|
|
4154
4574
|
});
|
|
4155
4575
|
|
|
4156
|
-
const _hoisted_1$
|
|
4157
|
-
const _hoisted_2$
|
|
4158
|
-
const _sfc_main$
|
|
4576
|
+
const _hoisted_1$m = { class: "m-fields-key-value" };
|
|
4577
|
+
const _hoisted_2$h = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
|
|
4578
|
+
const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
4159
4579
|
...{
|
|
4160
4580
|
name: "MEditorKeyValue"
|
|
4161
4581
|
},
|
|
@@ -4200,7 +4620,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4200
4620
|
records.value.splice(index, 1);
|
|
4201
4621
|
};
|
|
4202
4622
|
return (_ctx, _cache) => {
|
|
4203
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4623
|
+
return openBlock(), createElementBlock("div", _hoisted_1$m, [
|
|
4204
4624
|
(openBlock(true), createElementBlock(Fragment, null, renderList(records.value, (item, index) => {
|
|
4205
4625
|
return openBlock(), createElementBlock("div", {
|
|
4206
4626
|
class: "m-fields-key-value-item",
|
|
@@ -4214,7 +4634,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4214
4634
|
size: _ctx.size,
|
|
4215
4635
|
onChange: keyChangeHandler
|
|
4216
4636
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "size"]),
|
|
4217
|
-
_hoisted_2$
|
|
4637
|
+
_hoisted_2$h,
|
|
4218
4638
|
createVNode(unref(TMagicInput), {
|
|
4219
4639
|
placeholder: "value",
|
|
4220
4640
|
modelValue: records.value[index][1],
|
|
@@ -4253,12 +4673,12 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4253
4673
|
}
|
|
4254
4674
|
});
|
|
4255
4675
|
|
|
4256
|
-
const _hoisted_1$
|
|
4676
|
+
const _hoisted_1$l = {
|
|
4257
4677
|
key: 1,
|
|
4258
4678
|
class: "m-fields-ui-select",
|
|
4259
4679
|
style: { "display": "flex" }
|
|
4260
4680
|
};
|
|
4261
|
-
const _sfc_main$
|
|
4681
|
+
const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
4262
4682
|
...{
|
|
4263
4683
|
name: "MEditorUISelect"
|
|
4264
4684
|
},
|
|
@@ -4347,7 +4767,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
4347
4767
|
]),
|
|
4348
4768
|
_: 1
|
|
4349
4769
|
}, 8, ["icon", "disabled", "size"])
|
|
4350
|
-
])) : (openBlock(), createElementBlock("div", _hoisted_1$
|
|
4770
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_1$l, [
|
|
4351
4771
|
val.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
4352
4772
|
createVNode(unref(TMagicTooltip), {
|
|
4353
4773
|
content: "清除",
|
|
@@ -4444,7 +4864,7 @@ const useGetSo = (target, emit) => {
|
|
|
4444
4864
|
};
|
|
4445
4865
|
};
|
|
4446
4866
|
|
|
4447
|
-
const _sfc_main$
|
|
4867
|
+
const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
4448
4868
|
...{
|
|
4449
4869
|
name: "MEditorResizer"
|
|
4450
4870
|
},
|
|
@@ -4465,7 +4885,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
4465
4885
|
}
|
|
4466
4886
|
});
|
|
4467
4887
|
|
|
4468
|
-
const _sfc_main$
|
|
4888
|
+
const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
4469
4889
|
...{
|
|
4470
4890
|
name: "MEditorLayout"
|
|
4471
4891
|
},
|
|
@@ -4577,7 +4997,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
4577
4997
|
}, [
|
|
4578
4998
|
renderSlot(_ctx.$slots, "left")
|
|
4579
4999
|
], 6),
|
|
4580
|
-
createVNode(_sfc_main$
|
|
5000
|
+
createVNode(_sfc_main$A, { onChange: changeLeft })
|
|
4581
5001
|
], 64)) : createCommentVNode("", true),
|
|
4582
5002
|
createElementVNode("div", {
|
|
4583
5003
|
class: normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
|
|
@@ -4586,7 +5006,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
4586
5006
|
renderSlot(_ctx.$slots, "center")
|
|
4587
5007
|
], 6),
|
|
4588
5008
|
hasRight.value && _ctx.$slots.right ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
4589
|
-
createVNode(_sfc_main$
|
|
5009
|
+
createVNode(_sfc_main$A, { onChange: changeRight }),
|
|
4590
5010
|
createElementVNode("div", {
|
|
4591
5011
|
class: normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
|
|
4592
5012
|
style: normalizeStyle(`width: ${_ctx.right}px`)
|
|
@@ -4599,10 +5019,10 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
4599
5019
|
}
|
|
4600
5020
|
});
|
|
4601
5021
|
|
|
4602
|
-
const _hoisted_1$
|
|
4603
|
-
const _hoisted_2$
|
|
4604
|
-
const _hoisted_3$
|
|
4605
|
-
const _sfc_main$
|
|
5022
|
+
const _hoisted_1$k = { class: "m-editor-empty-panel" };
|
|
5023
|
+
const _hoisted_2$g = { class: "m-editor-empty-content" };
|
|
5024
|
+
const _hoisted_3$9 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
|
|
5025
|
+
const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
4606
5026
|
...{
|
|
4607
5027
|
name: "MEditorAddPageBox"
|
|
4608
5028
|
},
|
|
@@ -4622,16 +5042,16 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
4622
5042
|
});
|
|
4623
5043
|
};
|
|
4624
5044
|
return (_ctx, _cache) => {
|
|
4625
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4626
|
-
createElementVNode("div", _hoisted_2$
|
|
5045
|
+
return openBlock(), createElementBlock("div", _hoisted_1$k, [
|
|
5046
|
+
createElementVNode("div", _hoisted_2$g, [
|
|
4627
5047
|
createElementVNode("div", {
|
|
4628
5048
|
class: "m-editor-empty-button",
|
|
4629
5049
|
onClick: clickHandler
|
|
4630
5050
|
}, [
|
|
4631
5051
|
createElementVNode("div", null, [
|
|
4632
|
-
createVNode(_sfc_main$
|
|
5052
|
+
createVNode(_sfc_main$M, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
4633
5053
|
]),
|
|
4634
|
-
_hoisted_3$
|
|
5054
|
+
_hoisted_3$9
|
|
4635
5055
|
])
|
|
4636
5056
|
])
|
|
4637
5057
|
]);
|
|
@@ -4643,7 +5063,7 @@ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
|
4643
5063
|
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
4644
5064
|
const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
|
|
4645
5065
|
const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
|
|
4646
|
-
const _sfc_main$
|
|
5066
|
+
const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
4647
5067
|
...{
|
|
4648
5068
|
name: "MEditorFramework"
|
|
4649
5069
|
},
|
|
@@ -4720,13 +5140,13 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
4720
5140
|
renderSlot(_ctx.$slots, "nav"),
|
|
4721
5141
|
renderSlot(_ctx.$slots, "content-before"),
|
|
4722
5142
|
showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
|
|
4723
|
-
createVNode(_sfc_main$
|
|
5143
|
+
createVNode(_sfc_main$S, {
|
|
4724
5144
|
class: "m-editor-content",
|
|
4725
5145
|
"init-values": root.value,
|
|
4726
5146
|
options: unref(codeOptions),
|
|
4727
5147
|
onSave: saveCode
|
|
4728
5148
|
}, null, 8, ["init-values", "options"])
|
|
4729
|
-
]) : (openBlock(), createBlock(_sfc_main$
|
|
5149
|
+
]) : (openBlock(), createBlock(_sfc_main$z, {
|
|
4730
5150
|
key: 1,
|
|
4731
5151
|
class: "m-editor-content",
|
|
4732
5152
|
"left-class": "m-editor-framework-left",
|
|
@@ -4745,7 +5165,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
4745
5165
|
]),
|
|
4746
5166
|
center: withCtx(() => [
|
|
4747
5167
|
pageLength.value > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
4748
|
-
createVNode(_sfc_main$
|
|
5168
|
+
createVNode(_sfc_main$y)
|
|
4749
5169
|
])
|
|
4750
5170
|
]),
|
|
4751
5171
|
_: 2
|
|
@@ -4770,12 +5190,12 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
4770
5190
|
}
|
|
4771
5191
|
});
|
|
4772
5192
|
|
|
4773
|
-
const _hoisted_1$
|
|
5193
|
+
const _hoisted_1$j = {
|
|
4774
5194
|
key: 1,
|
|
4775
5195
|
class: "menu-item-text"
|
|
4776
5196
|
};
|
|
4777
|
-
const _hoisted_2$
|
|
4778
|
-
const _sfc_main$
|
|
5197
|
+
const _hoisted_2$f = { class: "el-dropdown-link menubar-menu-button" };
|
|
5198
|
+
const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
4779
5199
|
...{
|
|
4780
5200
|
name: "MEditorToolButton"
|
|
4781
5201
|
},
|
|
@@ -4854,7 +5274,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
4854
5274
|
_ctx.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
|
|
4855
5275
|
key: 0,
|
|
4856
5276
|
direction: _ctx.data.direction || "vertical"
|
|
4857
|
-
}, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
5277
|
+
}, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$j, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
4858
5278
|
_ctx.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
4859
5279
|
key: 0,
|
|
4860
5280
|
effect: "dark",
|
|
@@ -4868,7 +5288,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
4868
5288
|
disabled: disabled.value
|
|
4869
5289
|
}, {
|
|
4870
5290
|
default: withCtx(() => [
|
|
4871
|
-
_ctx.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
5291
|
+
_ctx.data.icon ? (openBlock(), createBlock(_sfc_main$M, {
|
|
4872
5292
|
key: 0,
|
|
4873
5293
|
icon: _ctx.data.icon
|
|
4874
5294
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -4886,7 +5306,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
4886
5306
|
title: _ctx.data.text
|
|
4887
5307
|
}, {
|
|
4888
5308
|
default: withCtx(() => [
|
|
4889
|
-
_ctx.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
5309
|
+
_ctx.data.icon ? (openBlock(), createBlock(_sfc_main$M, {
|
|
4890
5310
|
key: 0,
|
|
4891
5311
|
icon: _ctx.data.icon
|
|
4892
5312
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -4919,7 +5339,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
4919
5339
|
})) : createCommentVNode("", true)
|
|
4920
5340
|
]),
|
|
4921
5341
|
default: withCtx(() => [
|
|
4922
|
-
createElementVNode("span", _hoisted_2$
|
|
5342
|
+
createElementVNode("span", _hoisted_2$f, [
|
|
4923
5343
|
createTextVNode(toDisplayString(_ctx.data.text), 1),
|
|
4924
5344
|
createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
|
|
4925
5345
|
default: withCtx(() => [
|
|
@@ -4936,7 +5356,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
4936
5356
|
}
|
|
4937
5357
|
});
|
|
4938
5358
|
|
|
4939
|
-
const _sfc_main$
|
|
5359
|
+
const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
4940
5360
|
...{
|
|
4941
5361
|
name: "MEditorNavMenu"
|
|
4942
5362
|
},
|
|
@@ -5098,7 +5518,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
5098
5518
|
style: normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
|
|
5099
5519
|
}, [
|
|
5100
5520
|
(openBlock(true), createElementBlock(Fragment, null, renderList(buttons.value[key], (item, index) => {
|
|
5101
|
-
return openBlock(), createBlock(_sfc_main$
|
|
5521
|
+
return openBlock(), createBlock(_sfc_main$w, {
|
|
5102
5522
|
data: item,
|
|
5103
5523
|
key: index
|
|
5104
5524
|
}, null, 8, ["data"]);
|
|
@@ -5110,8 +5530,8 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
5110
5530
|
}
|
|
5111
5531
|
});
|
|
5112
5532
|
|
|
5113
|
-
const _hoisted_1$
|
|
5114
|
-
const _sfc_main$
|
|
5533
|
+
const _hoisted_1$i = { class: "m-editor-props-panel" };
|
|
5534
|
+
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
5115
5535
|
...{
|
|
5116
5536
|
name: "MEditorPropsPanel"
|
|
5117
5537
|
},
|
|
@@ -5164,7 +5584,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
5164
5584
|
};
|
|
5165
5585
|
__expose({ configForm, submit });
|
|
5166
5586
|
return (_ctx, _cache) => {
|
|
5167
|
-
return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$
|
|
5587
|
+
return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$i, [
|
|
5168
5588
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
5169
5589
|
createVNode(unref(MForm), {
|
|
5170
5590
|
ref_key: "configForm",
|
|
@@ -5184,7 +5604,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
5184
5604
|
}
|
|
5185
5605
|
});
|
|
5186
5606
|
|
|
5187
|
-
const _sfc_main$
|
|
5607
|
+
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
5188
5608
|
...{
|
|
5189
5609
|
name: "MEditorSearchInput"
|
|
5190
5610
|
},
|
|
@@ -5192,8 +5612,12 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
5192
5612
|
emits: ["search"],
|
|
5193
5613
|
setup(__props, { emit }) {
|
|
5194
5614
|
const filterText = ref("");
|
|
5615
|
+
let timer = null;
|
|
5195
5616
|
const filterTextChangeHandler = () => {
|
|
5196
|
-
|
|
5617
|
+
timer && clearTimeout(timer);
|
|
5618
|
+
timer = setTimeout(() => {
|
|
5619
|
+
emit("search", filterText.value);
|
|
5620
|
+
}, 300);
|
|
5197
5621
|
};
|
|
5198
5622
|
return (_ctx, _cache) => {
|
|
5199
5623
|
return openBlock(), createBlock(unref(TMagicInput), {
|
|
@@ -5219,8 +5643,8 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
5219
5643
|
}
|
|
5220
5644
|
});
|
|
5221
5645
|
|
|
5222
|
-
const _hoisted_1$
|
|
5223
|
-
const _hoisted_2$
|
|
5646
|
+
const _hoisted_1$h = { xmlns: "http://www.w3.org/2000/svg" };
|
|
5647
|
+
const _hoisted_2$e = /* @__PURE__ */ createElementVNode("g", {
|
|
5224
5648
|
fill: "#7C878E",
|
|
5225
5649
|
"fill-rule": "evenodd"
|
|
5226
5650
|
}, [
|
|
@@ -5230,50 +5654,50 @@ const _hoisted_2$d = /* @__PURE__ */ createElementVNode("g", {
|
|
|
5230
5654
|
}),
|
|
5231
5655
|
/* @__PURE__ */ createElementVNode("path", { d: "M8 13.5L2.3 9.2 0.7 10.5 8 16 15.3 10.5 13.7 9.2z" })
|
|
5232
5656
|
], -1);
|
|
5233
|
-
const _hoisted_3$
|
|
5234
|
-
_hoisted_2$
|
|
5657
|
+
const _hoisted_3$8 = [
|
|
5658
|
+
_hoisted_2$e
|
|
5235
5659
|
];
|
|
5236
|
-
const _sfc_main$
|
|
5660
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
5237
5661
|
...{
|
|
5238
5662
|
name: "MEditorAppManageIcon"
|
|
5239
5663
|
},
|
|
5240
5664
|
__name: "AppManageIcon",
|
|
5241
5665
|
setup(__props) {
|
|
5242
5666
|
return (_ctx, _cache) => {
|
|
5243
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
5667
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$h, _hoisted_3$8);
|
|
5244
5668
|
};
|
|
5245
5669
|
}
|
|
5246
5670
|
});
|
|
5247
5671
|
|
|
5248
|
-
const _hoisted_1$
|
|
5672
|
+
const _hoisted_1$g = {
|
|
5249
5673
|
viewBox: "0 0 32 32",
|
|
5250
5674
|
version: "1.1",
|
|
5251
5675
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5252
5676
|
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
5253
5677
|
};
|
|
5254
|
-
const _hoisted_2$
|
|
5255
|
-
const _hoisted_4$
|
|
5256
|
-
_hoisted_2$
|
|
5678
|
+
const _hoisted_2$d = /* @__PURE__ */ createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2);
|
|
5679
|
+
const _hoisted_4$6 = [
|
|
5680
|
+
_hoisted_2$d
|
|
5257
5681
|
];
|
|
5258
|
-
const _sfc_main$
|
|
5682
|
+
const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
5259
5683
|
...{
|
|
5260
5684
|
name: "MEditorCodeIcon"
|
|
5261
5685
|
},
|
|
5262
5686
|
__name: "CodeIcon",
|
|
5263
5687
|
setup(__props) {
|
|
5264
5688
|
return (_ctx, _cache) => {
|
|
5265
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
5689
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$g, _hoisted_4$6);
|
|
5266
5690
|
};
|
|
5267
5691
|
}
|
|
5268
5692
|
});
|
|
5269
5693
|
|
|
5270
|
-
const _hoisted_1$
|
|
5271
|
-
const _hoisted_2$
|
|
5272
|
-
const _hoisted_3$
|
|
5694
|
+
const _hoisted_1$f = ["id"];
|
|
5695
|
+
const _hoisted_2$c = { class: "list-item" };
|
|
5696
|
+
const _hoisted_3$7 = {
|
|
5273
5697
|
key: 2,
|
|
5274
5698
|
class: "right-tool"
|
|
5275
5699
|
};
|
|
5276
|
-
const _sfc_main$
|
|
5700
|
+
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
5277
5701
|
...{
|
|
5278
5702
|
name: "MEditorCodeBlockList"
|
|
5279
5703
|
},
|
|
@@ -5374,26 +5798,26 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
5374
5798
|
id: data.id,
|
|
5375
5799
|
class: "list-container"
|
|
5376
5800
|
}, [
|
|
5377
|
-
createElementVNode("div", _hoisted_2$
|
|
5378
|
-
data.type === "code" ? (openBlock(), createBlock(_sfc_main$
|
|
5801
|
+
createElementVNode("div", _hoisted_2$c, [
|
|
5802
|
+
data.type === "code" ? (openBlock(), createBlock(_sfc_main$r, {
|
|
5379
5803
|
key: 0,
|
|
5380
5804
|
class: "codeIcon"
|
|
5381
5805
|
})) : createCommentVNode("", true),
|
|
5382
|
-
data.type === "node" ? (openBlock(), createBlock(_sfc_main$
|
|
5806
|
+
data.type === "node" ? (openBlock(), createBlock(_sfc_main$s, {
|
|
5383
5807
|
key: 1,
|
|
5384
5808
|
class: "compIcon"
|
|
5385
5809
|
})) : createCommentVNode("", true),
|
|
5386
5810
|
createElementVNode("span", {
|
|
5387
5811
|
class: normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
|
|
5388
5812
|
}, toDisplayString(data.name) + " (" + toDisplayString(data.id) + ")", 3),
|
|
5389
|
-
data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_3$
|
|
5813
|
+
data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_3$7, [
|
|
5390
5814
|
createVNode(unref(TMagicTooltip), {
|
|
5391
5815
|
effect: "dark",
|
|
5392
5816
|
content: editable.value ? "编辑" : "查看",
|
|
5393
5817
|
placement: "bottom"
|
|
5394
5818
|
}, {
|
|
5395
5819
|
default: withCtx(() => [
|
|
5396
|
-
createVNode(_sfc_main$
|
|
5820
|
+
createVNode(_sfc_main$M, {
|
|
5397
5821
|
icon: editable.value ? unref(Edit) : unref(View),
|
|
5398
5822
|
class: "edit-icon",
|
|
5399
5823
|
onClick: withModifiers(($event) => editCode(data.id), ["stop"])
|
|
@@ -5408,7 +5832,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
5408
5832
|
placement: "bottom"
|
|
5409
5833
|
}, {
|
|
5410
5834
|
default: withCtx(() => [
|
|
5411
|
-
createVNode(_sfc_main$
|
|
5835
|
+
createVNode(_sfc_main$M, {
|
|
5412
5836
|
icon: unref(Close),
|
|
5413
5837
|
class: "edit-icon",
|
|
5414
5838
|
onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
@@ -5422,7 +5846,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
5422
5846
|
})
|
|
5423
5847
|
])) : createCommentVNode("", true)
|
|
5424
5848
|
])
|
|
5425
|
-
], 8, _hoisted_1$
|
|
5849
|
+
], 8, _hoisted_1$f)
|
|
5426
5850
|
]),
|
|
5427
5851
|
_: 3
|
|
5428
5852
|
}, 8, ["default-expanded-keys", "data"]);
|
|
@@ -5430,8 +5854,8 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
5430
5854
|
}
|
|
5431
5855
|
});
|
|
5432
5856
|
|
|
5433
|
-
const _hoisted_1$
|
|
5434
|
-
const _sfc_main$
|
|
5857
|
+
const _hoisted_1$e = { class: "search-wrapper" };
|
|
5858
|
+
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
5435
5859
|
...{
|
|
5436
5860
|
name: "MEditorCodeBlockListPanel"
|
|
5437
5861
|
},
|
|
@@ -5451,8 +5875,8 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
5451
5875
|
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
|
|
5452
5876
|
default: withCtx(() => [
|
|
5453
5877
|
renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
5454
|
-
createElementVNode("div", _hoisted_1$
|
|
5455
|
-
createVNode(_sfc_main$
|
|
5878
|
+
createElementVNode("div", _hoisted_1$e, [
|
|
5879
|
+
createVNode(_sfc_main$t, { onSearch: filterTextChangeHandler }),
|
|
5456
5880
|
editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
5457
5881
|
key: 0,
|
|
5458
5882
|
class: "create-code-button",
|
|
@@ -5468,7 +5892,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
5468
5892
|
renderSlot(_ctx.$slots, "code-block-panel-search")
|
|
5469
5893
|
])
|
|
5470
5894
|
]),
|
|
5471
|
-
createVNode(_sfc_main$
|
|
5895
|
+
createVNode(_sfc_main$q, {
|
|
5472
5896
|
ref_key: "codeBlockList",
|
|
5473
5897
|
ref: codeBlockList,
|
|
5474
5898
|
"custom-error": _ctx.customError,
|
|
@@ -5483,7 +5907,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
5483
5907
|
]),
|
|
5484
5908
|
_: 3
|
|
5485
5909
|
}, 8, ["custom-error", "onEdit", "onRemove"]),
|
|
5486
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
5910
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
5487
5911
|
key: 0,
|
|
5488
5912
|
ref_key: "codeBlockEditor",
|
|
5489
5913
|
ref: codeBlockEditor,
|
|
@@ -5498,7 +5922,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
5498
5922
|
}
|
|
5499
5923
|
});
|
|
5500
5924
|
|
|
5501
|
-
const _sfc_main$
|
|
5925
|
+
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
5502
5926
|
...{
|
|
5503
5927
|
name: "MEditorDataSourceConfigPanel"
|
|
5504
5928
|
},
|
|
@@ -5552,13 +5976,13 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
5552
5976
|
}
|
|
5553
5977
|
});
|
|
5554
5978
|
|
|
5555
|
-
const _hoisted_1$
|
|
5556
|
-
const _hoisted_2$
|
|
5557
|
-
const _hoisted_3$
|
|
5979
|
+
const _hoisted_1$d = ["id"];
|
|
5980
|
+
const _hoisted_2$b = { class: "list-item" };
|
|
5981
|
+
const _hoisted_3$6 = {
|
|
5558
5982
|
key: 2,
|
|
5559
5983
|
class: "right-tool"
|
|
5560
5984
|
};
|
|
5561
|
-
const _sfc_main$
|
|
5985
|
+
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
5562
5986
|
...{
|
|
5563
5987
|
name: "MEditorDataSourceList"
|
|
5564
5988
|
},
|
|
@@ -5653,13 +6077,13 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
5653
6077
|
id: data.id,
|
|
5654
6078
|
class: "list-container"
|
|
5655
6079
|
}, [
|
|
5656
|
-
createElementVNode("div", _hoisted_2$
|
|
5657
|
-
data.type === "code" ? (openBlock(), createBlock(_sfc_main$
|
|
6080
|
+
createElementVNode("div", _hoisted_2$b, [
|
|
6081
|
+
data.type === "code" ? (openBlock(), createBlock(_sfc_main$M, {
|
|
5658
6082
|
key: 0,
|
|
5659
6083
|
class: "codeIcon",
|
|
5660
6084
|
icon: unref(Coin)
|
|
5661
6085
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
5662
|
-
data.type === "node" ? (openBlock(), createBlock(_sfc_main$
|
|
6086
|
+
data.type === "node" ? (openBlock(), createBlock(_sfc_main$M, {
|
|
5663
6087
|
key: 1,
|
|
5664
6088
|
class: "compIcon",
|
|
5665
6089
|
icon: unref(Aim)
|
|
@@ -5667,14 +6091,14 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
5667
6091
|
createElementVNode("span", {
|
|
5668
6092
|
class: normalizeClass(["name", { code: data.type === "ds", hook: data.type === "key" }])
|
|
5669
6093
|
}, toDisplayString(data.type === "key" ? data.name : `${data.name}(${data.id})`), 3),
|
|
5670
|
-
data.type === "ds" ? (openBlock(), createElementBlock("div", _hoisted_3$
|
|
6094
|
+
data.type === "ds" ? (openBlock(), createElementBlock("div", _hoisted_3$6, [
|
|
5671
6095
|
createVNode(unref(TMagicTooltip), {
|
|
5672
6096
|
effect: "dark",
|
|
5673
6097
|
content: editable.value ? "编辑" : "查看",
|
|
5674
6098
|
placement: "bottom"
|
|
5675
6099
|
}, {
|
|
5676
6100
|
default: withCtx(() => [
|
|
5677
|
-
createVNode(_sfc_main$
|
|
6101
|
+
createVNode(_sfc_main$M, {
|
|
5678
6102
|
icon: editable.value ? unref(Edit) : unref(View),
|
|
5679
6103
|
class: "edit-icon",
|
|
5680
6104
|
onClick: withModifiers(($event) => editHandler(`${data.id}`), ["stop"])
|
|
@@ -5689,7 +6113,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
5689
6113
|
placement: "bottom"
|
|
5690
6114
|
}, {
|
|
5691
6115
|
default: withCtx(() => [
|
|
5692
|
-
createVNode(_sfc_main$
|
|
6116
|
+
createVNode(_sfc_main$M, {
|
|
5693
6117
|
icon: unref(Close),
|
|
5694
6118
|
class: "edit-icon",
|
|
5695
6119
|
onClick: withModifiers(($event) => removeHandler(`${data.id}`), ["stop"])
|
|
@@ -5703,7 +6127,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
5703
6127
|
})
|
|
5704
6128
|
])) : createCommentVNode("", true)
|
|
5705
6129
|
])
|
|
5706
|
-
], 8, _hoisted_1$
|
|
6130
|
+
], 8, _hoisted_1$d)
|
|
5707
6131
|
]),
|
|
5708
6132
|
_: 3
|
|
5709
6133
|
}, 8, ["data"]);
|
|
@@ -5711,9 +6135,9 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
5711
6135
|
}
|
|
5712
6136
|
});
|
|
5713
6137
|
|
|
5714
|
-
const _hoisted_1$
|
|
5715
|
-
const _hoisted_2$
|
|
5716
|
-
const _sfc_main$
|
|
6138
|
+
const _hoisted_1$c = { class: "search-wrapper" };
|
|
6139
|
+
const _hoisted_2$a = { class: "data-source-list-panel-add-menu" };
|
|
6140
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
5717
6141
|
...{
|
|
5718
6142
|
name: "MEditorDataSourceListPanel"
|
|
5719
6143
|
},
|
|
@@ -5773,8 +6197,8 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
5773
6197
|
return (_ctx, _cache) => {
|
|
5774
6198
|
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
|
|
5775
6199
|
default: withCtx(() => [
|
|
5776
|
-
createElementVNode("div", _hoisted_1$
|
|
5777
|
-
createVNode(_sfc_main$
|
|
6200
|
+
createElementVNode("div", _hoisted_1$c, [
|
|
6201
|
+
createVNode(_sfc_main$t, { onSearch: filterTextChangeHandler }),
|
|
5778
6202
|
editable.value ? (openBlock(), createBlock(unref(TMagicPopover), {
|
|
5779
6203
|
key: 0,
|
|
5780
6204
|
placement: "right"
|
|
@@ -5791,9 +6215,9 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
5791
6215
|
})
|
|
5792
6216
|
]),
|
|
5793
6217
|
default: withCtx(() => [
|
|
5794
|
-
createElementVNode("div", _hoisted_2$
|
|
6218
|
+
createElementVNode("div", _hoisted_2$a, [
|
|
5795
6219
|
(openBlock(true), createElementBlock(Fragment, null, renderList(datasourceTypeList.value, (item, index) => {
|
|
5796
|
-
return openBlock(), createBlock(_sfc_main$
|
|
6220
|
+
return openBlock(), createBlock(_sfc_main$w, {
|
|
5797
6221
|
data: {
|
|
5798
6222
|
type: "button",
|
|
5799
6223
|
text: item.text,
|
|
@@ -5809,11 +6233,11 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
5809
6233
|
_: 1
|
|
5810
6234
|
})) : createCommentVNode("", true)
|
|
5811
6235
|
]),
|
|
5812
|
-
createVNode(_sfc_main$
|
|
6236
|
+
createVNode(_sfc_main$n, {
|
|
5813
6237
|
onEdit: editHandler,
|
|
5814
6238
|
onRemove: removeHandler
|
|
5815
6239
|
}),
|
|
5816
|
-
createVNode(_sfc_main$
|
|
6240
|
+
createVNode(_sfc_main$o, {
|
|
5817
6241
|
ref_key: "editDialog",
|
|
5818
6242
|
ref: editDialog,
|
|
5819
6243
|
disabled: !editable.value,
|
|
@@ -5828,136 +6252,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
5828
6252
|
}
|
|
5829
6253
|
});
|
|
5830
6254
|
|
|
5831
|
-
const
|
|
5832
|
-
const _hoisted_2$8 = ["title"];
|
|
5833
|
-
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
5834
|
-
...{
|
|
5835
|
-
name: "MEditorComponentListPanel"
|
|
5836
|
-
},
|
|
5837
|
-
__name: "ComponentListPanel",
|
|
5838
|
-
setup(__props) {
|
|
5839
|
-
const searchText = ref("");
|
|
5840
|
-
const filterTextChangeHandler = (v) => {
|
|
5841
|
-
searchText.value = v;
|
|
5842
|
-
};
|
|
5843
|
-
const services = inject("services");
|
|
5844
|
-
const stageOptions = inject("stageOptions");
|
|
5845
|
-
const stage = computed(() => services?.editorService.get("stage"));
|
|
5846
|
-
const list = computed(
|
|
5847
|
-
() => services?.componentListService.getList().map((group) => ({
|
|
5848
|
-
...group,
|
|
5849
|
-
items: group.items.filter((item) => item.text.includes(searchText.value))
|
|
5850
|
-
}))
|
|
5851
|
-
);
|
|
5852
|
-
const collapseValue = computed(
|
|
5853
|
-
() => Array(list.value?.length).fill(1).map((x, i) => `${i}`)
|
|
5854
|
-
);
|
|
5855
|
-
let timeout;
|
|
5856
|
-
let clientX;
|
|
5857
|
-
let clientY;
|
|
5858
|
-
const appendComponent = ({ text, type, data = {} }) => {
|
|
5859
|
-
services?.editorService.add({
|
|
5860
|
-
name: text,
|
|
5861
|
-
type,
|
|
5862
|
-
...data
|
|
5863
|
-
});
|
|
5864
|
-
};
|
|
5865
|
-
const dragstartHandler = ({ text, type, data = {} }, e) => {
|
|
5866
|
-
if (e.dataTransfer) {
|
|
5867
|
-
e.dataTransfer.setData(
|
|
5868
|
-
"text/json",
|
|
5869
|
-
serialize({
|
|
5870
|
-
name: text,
|
|
5871
|
-
type,
|
|
5872
|
-
...data
|
|
5873
|
-
})
|
|
5874
|
-
);
|
|
5875
|
-
}
|
|
5876
|
-
};
|
|
5877
|
-
const dragendHandler = () => {
|
|
5878
|
-
if (timeout) {
|
|
5879
|
-
globalThis.clearTimeout(timeout);
|
|
5880
|
-
timeout = void 0;
|
|
5881
|
-
}
|
|
5882
|
-
const doc = stage.value?.renderer.contentWindow?.document;
|
|
5883
|
-
if (doc && stageOptions) {
|
|
5884
|
-
removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
5885
|
-
}
|
|
5886
|
-
clientX = 0;
|
|
5887
|
-
clientY = 0;
|
|
5888
|
-
};
|
|
5889
|
-
const dragHandler = (e) => {
|
|
5890
|
-
if (e.clientX !== clientX || e.clientY !== clientY) {
|
|
5891
|
-
clientX = e.clientX;
|
|
5892
|
-
clientY = e.clientY;
|
|
5893
|
-
if (timeout) {
|
|
5894
|
-
globalThis.clearTimeout(timeout);
|
|
5895
|
-
timeout = void 0;
|
|
5896
|
-
}
|
|
5897
|
-
return;
|
|
5898
|
-
}
|
|
5899
|
-
if (timeout || !stage.value)
|
|
5900
|
-
return;
|
|
5901
|
-
timeout = stage.value.delayedMarkContainer(e);
|
|
5902
|
-
};
|
|
5903
|
-
return (_ctx, _cache) => {
|
|
5904
|
-
return openBlock(), createBlock(unref(TMagicScrollbar), null, {
|
|
5905
|
-
default: withCtx(() => [
|
|
5906
|
-
renderSlot(_ctx.$slots, "component-list-panel-header"),
|
|
5907
|
-
createVNode(unref(TMagicCollapse), {
|
|
5908
|
-
class: "ui-component-panel",
|
|
5909
|
-
"model-value": collapseValue.value
|
|
5910
|
-
}, {
|
|
5911
|
-
default: withCtx(() => [
|
|
5912
|
-
createVNode(_sfc_main$s, { onSearch: filterTextChangeHandler }),
|
|
5913
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
|
|
5914
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
5915
|
-
group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
|
|
5916
|
-
key: index,
|
|
5917
|
-
name: `${index}`
|
|
5918
|
-
}, {
|
|
5919
|
-
title: withCtx(() => [
|
|
5920
|
-
createVNode(_sfc_main$K, { icon: unref(Grid) }, null, 8, ["icon"]),
|
|
5921
|
-
createTextVNode(toDisplayString(group.title), 1)
|
|
5922
|
-
]),
|
|
5923
|
-
default: withCtx(() => [
|
|
5924
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
|
|
5925
|
-
return openBlock(), createElementBlock("div", {
|
|
5926
|
-
class: "component-item",
|
|
5927
|
-
draggable: "true",
|
|
5928
|
-
key: item.type,
|
|
5929
|
-
onClick: ($event) => appendComponent(item),
|
|
5930
|
-
onDragstart: ($event) => dragstartHandler(item, $event),
|
|
5931
|
-
onDragend: dragendHandler,
|
|
5932
|
-
onDrag: dragHandler
|
|
5933
|
-
}, [
|
|
5934
|
-
renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
5935
|
-
createVNode(_sfc_main$K, {
|
|
5936
|
-
title: item.text,
|
|
5937
|
-
icon: item.icon
|
|
5938
|
-
}, null, 8, ["title", "icon"]),
|
|
5939
|
-
createElementVNode("span", {
|
|
5940
|
-
title: item.text
|
|
5941
|
-
}, toDisplayString(item.text), 9, _hoisted_2$8)
|
|
5942
|
-
])
|
|
5943
|
-
], 40, _hoisted_1$c);
|
|
5944
|
-
}), 128))
|
|
5945
|
-
]),
|
|
5946
|
-
_: 2
|
|
5947
|
-
}, 1032, ["name"])) : createCommentVNode("", true)
|
|
5948
|
-
], 64);
|
|
5949
|
-
}), 256))
|
|
5950
|
-
]),
|
|
5951
|
-
_: 3
|
|
5952
|
-
}, 8, ["model-value"])
|
|
5953
|
-
]),
|
|
5954
|
-
_: 3
|
|
5955
|
-
});
|
|
5956
|
-
};
|
|
5957
|
-
}
|
|
5958
|
-
});
|
|
5959
|
-
|
|
5960
|
-
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
6255
|
+
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
5961
6256
|
...{
|
|
5962
6257
|
name: "MEditorContentMenu"
|
|
5963
6258
|
},
|
|
@@ -6034,11 +6329,14 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
6034
6329
|
};
|
|
6035
6330
|
const showSubMenu = (item, index) => {
|
|
6036
6331
|
const menuItem = item;
|
|
6037
|
-
if (typeof item !== "object"
|
|
6332
|
+
if (typeof item !== "object") {
|
|
6038
6333
|
return;
|
|
6039
6334
|
}
|
|
6040
6335
|
subMenuData.value = menuItem.items || [];
|
|
6041
6336
|
setTimeout(() => {
|
|
6337
|
+
if (!visible.value) {
|
|
6338
|
+
return;
|
|
6339
|
+
}
|
|
6042
6340
|
if (menu.value) {
|
|
6043
6341
|
let y = menu.value.offsetTop;
|
|
6044
6342
|
if (buttons.value?.[index].$el) {
|
|
@@ -6087,7 +6385,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
6087
6385
|
renderSlot(_ctx.$slots, "title"),
|
|
6088
6386
|
createElementVNode("div", null, [
|
|
6089
6387
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
6090
|
-
return openBlock(), createBlock(_sfc_main$
|
|
6388
|
+
return openBlock(), createBlock(_sfc_main$w, {
|
|
6091
6389
|
"event-type": "mouseup",
|
|
6092
6390
|
ref_for: true,
|
|
6093
6391
|
ref_key: "buttons",
|
|
@@ -6130,26 +6428,26 @@ const _hoisted_1$b = {
|
|
|
6130
6428
|
fill: "currentColor",
|
|
6131
6429
|
xmlns: "http://www.w3.org/2000/svg"
|
|
6132
6430
|
};
|
|
6133
|
-
const _hoisted_2$
|
|
6431
|
+
const _hoisted_2$9 = /* @__PURE__ */ createElementVNode("path", {
|
|
6134
6432
|
"fill-rule": "evenodd",
|
|
6135
6433
|
d: "M9.828 4H2.19a1 1 0 0 0-.996 1.09l.637 7a1 1 0 0 0 .995.91H9v1H2.826a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31L.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181L15.546 8H14.54l.265-2.91A1 1 0 0 0 13.81 4H9.828zm-2.95-1.707L7.587 3H2.19c-.24 0-.47.042-.684.12L1.5 2.98a1 1 0 0 1 1-.98h3.672a1 1 0 0 1 .707.293z"
|
|
6136
6434
|
}, null, -1);
|
|
6137
|
-
const _hoisted_3$
|
|
6435
|
+
const _hoisted_3$5 = /* @__PURE__ */ createElementVNode("path", {
|
|
6138
6436
|
"fill-rule": "evenodd",
|
|
6139
6437
|
d: "M11 11.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5z"
|
|
6140
6438
|
}, null, -1);
|
|
6141
|
-
const _hoisted_4$
|
|
6142
|
-
_hoisted_2$
|
|
6143
|
-
_hoisted_3$
|
|
6439
|
+
const _hoisted_4$5 = [
|
|
6440
|
+
_hoisted_2$9,
|
|
6441
|
+
_hoisted_3$5
|
|
6144
6442
|
];
|
|
6145
|
-
const _sfc_main$
|
|
6443
|
+
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
6146
6444
|
...{
|
|
6147
6445
|
name: "MEditorFolderMinusIcon"
|
|
6148
6446
|
},
|
|
6149
6447
|
__name: "FolderMinusIcon",
|
|
6150
6448
|
setup(__props) {
|
|
6151
6449
|
return (_ctx, _cache) => {
|
|
6152
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$b, _hoisted_4$
|
|
6450
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$b, _hoisted_4$5);
|
|
6153
6451
|
};
|
|
6154
6452
|
}
|
|
6155
6453
|
});
|
|
@@ -6229,7 +6527,7 @@ const useMoveToMenu = (services) => {
|
|
|
6229
6527
|
};
|
|
6230
6528
|
};
|
|
6231
6529
|
|
|
6232
|
-
const _sfc_main$
|
|
6530
|
+
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
6233
6531
|
...{
|
|
6234
6532
|
name: "MEditorLayerMenu"
|
|
6235
6533
|
},
|
|
@@ -6292,7 +6590,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
6292
6590
|
{
|
|
6293
6591
|
type: "button",
|
|
6294
6592
|
text: "全部折叠",
|
|
6295
|
-
icon: _sfc_main$
|
|
6593
|
+
icon: _sfc_main$k,
|
|
6296
6594
|
display: () => isPage(node.value),
|
|
6297
6595
|
handler: () => {
|
|
6298
6596
|
emit("collapse-all");
|
|
@@ -6318,7 +6616,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
6318
6616
|
show
|
|
6319
6617
|
});
|
|
6320
6618
|
return (_ctx, _cache) => {
|
|
6321
|
-
return openBlock(), createBlock(_sfc_main$
|
|
6619
|
+
return openBlock(), createBlock(_sfc_main$l, {
|
|
6322
6620
|
"menu-data": menuData.value,
|
|
6323
6621
|
ref_key: "menu",
|
|
6324
6622
|
ref: menu,
|
|
@@ -6328,9 +6626,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
6328
6626
|
}
|
|
6329
6627
|
});
|
|
6330
6628
|
|
|
6331
|
-
const
|
|
6332
|
-
|
|
6333
|
-
__name: "LayerNode",
|
|
6629
|
+
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
6630
|
+
__name: "LayerNodeTool",
|
|
6334
6631
|
props: {
|
|
6335
6632
|
data: {}
|
|
6336
6633
|
},
|
|
@@ -6347,342 +6644,673 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
6347
6644
|
});
|
|
6348
6645
|
};
|
|
6349
6646
|
return (_ctx, _cache) => {
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
})) : (openBlock(), createBlock(_component_el_icon, {
|
|
6365
|
-
key: 1,
|
|
6366
|
-
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => setNodeVisible(false), ["stop"])),
|
|
6367
|
-
class: "node-lock",
|
|
6368
|
-
title: "点击隐藏"
|
|
6369
|
-
}, {
|
|
6370
|
-
default: withCtx(() => [
|
|
6371
|
-
createVNode(unref(View))
|
|
6372
|
-
]),
|
|
6373
|
-
_: 1
|
|
6374
|
-
}))
|
|
6375
|
-
], 64)) : createCommentVNode("", true)
|
|
6376
|
-
])
|
|
6377
|
-
], 64);
|
|
6647
|
+
return _ctx.data.type !== "page" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
6648
|
+
_ctx.data.visible === false ? (openBlock(), createBlock(_sfc_main$M, {
|
|
6649
|
+
key: 0,
|
|
6650
|
+
icon: unref(Hide),
|
|
6651
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => setNodeVisible(true), ["stop"])),
|
|
6652
|
+
title: "点击显示"
|
|
6653
|
+
}, null, 8, ["icon"])) : (openBlock(), createBlock(_sfc_main$M, {
|
|
6654
|
+
key: 1,
|
|
6655
|
+
icon: unref(View),
|
|
6656
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => setNodeVisible(false), ["stop"])),
|
|
6657
|
+
class: "node-lock",
|
|
6658
|
+
title: "点击隐藏"
|
|
6659
|
+
}, null, 8, ["icon"]))
|
|
6660
|
+
], 64)) : createCommentVNode("", true);
|
|
6378
6661
|
};
|
|
6379
6662
|
}
|
|
6380
6663
|
});
|
|
6381
6664
|
|
|
6382
|
-
const
|
|
6383
|
-
|
|
6384
|
-
|
|
6665
|
+
const dragState = {
|
|
6666
|
+
dragOverNodeId: "",
|
|
6667
|
+
dropType: "",
|
|
6668
|
+
container: null
|
|
6669
|
+
};
|
|
6670
|
+
const getNodeEl = (el) => {
|
|
6671
|
+
if (el.dataset.nodeId) {
|
|
6672
|
+
return el;
|
|
6673
|
+
}
|
|
6674
|
+
if (el.parentElement) {
|
|
6675
|
+
return getNodeEl(el.parentElement);
|
|
6676
|
+
}
|
|
6677
|
+
};
|
|
6678
|
+
const removeStatusClass = (el) => {
|
|
6679
|
+
if (!el)
|
|
6680
|
+
return;
|
|
6681
|
+
["drag-before", "drag-after", "drag-inner"].forEach((className) => {
|
|
6682
|
+
el.querySelectorAll(`.${className}`).forEach((el2) => {
|
|
6683
|
+
removeClassName(el2, className);
|
|
6684
|
+
});
|
|
6685
|
+
});
|
|
6686
|
+
};
|
|
6687
|
+
const useDrag = (services) => {
|
|
6688
|
+
const handleDragStart = (event) => {
|
|
6689
|
+
if (!event.dataTransfer || !event.target || !event.currentTarget)
|
|
6690
|
+
return;
|
|
6691
|
+
const targetEl = getNodeEl(event.target);
|
|
6692
|
+
if (!targetEl || targetEl !== event.currentTarget)
|
|
6693
|
+
return;
|
|
6694
|
+
event.dataTransfer.effectAllowed = "move";
|
|
6695
|
+
try {
|
|
6696
|
+
event.dataTransfer.setData(
|
|
6697
|
+
"text/json",
|
|
6698
|
+
JSON.stringify({
|
|
6699
|
+
dragType: DragType.LAYER_TREE
|
|
6700
|
+
})
|
|
6701
|
+
);
|
|
6702
|
+
} catch {
|
|
6703
|
+
}
|
|
6704
|
+
};
|
|
6705
|
+
const handleDragOver = (event) => {
|
|
6706
|
+
if (!event.target)
|
|
6707
|
+
return;
|
|
6708
|
+
const targetEl = getNodeEl(event.target);
|
|
6709
|
+
if (!targetEl)
|
|
6710
|
+
return;
|
|
6711
|
+
const labelEl = targetEl.children[0];
|
|
6712
|
+
if (!labelEl)
|
|
6713
|
+
return;
|
|
6714
|
+
const { top: targetTop, height: targetHeight } = labelEl.getBoundingClientRect();
|
|
6715
|
+
const distance = event.clientY - targetTop;
|
|
6716
|
+
const isContainer = targetEl.dataset.isContainer === "true";
|
|
6717
|
+
if (distance < targetHeight / 3) {
|
|
6718
|
+
dragState.dropType = "before";
|
|
6719
|
+
addClassName(labelEl, globalThis.document, "drag-before");
|
|
6720
|
+
removeClassName(labelEl, "drag-after", "drag-inner");
|
|
6721
|
+
} else if (distance > targetHeight * 2 / 3) {
|
|
6722
|
+
dragState.dropType = "after";
|
|
6723
|
+
addClassName(labelEl, globalThis.document, "drag-after");
|
|
6724
|
+
removeClassName(labelEl, "drag-before", "drag-inner");
|
|
6725
|
+
} else if (isContainer) {
|
|
6726
|
+
dragState.dropType = "inner";
|
|
6727
|
+
addClassName(labelEl, globalThis.document, "drag-inner");
|
|
6728
|
+
removeClassName(labelEl, "drag-before", "drag-after");
|
|
6729
|
+
}
|
|
6730
|
+
if (!dragState.dropType) {
|
|
6731
|
+
return;
|
|
6732
|
+
}
|
|
6733
|
+
dragState.dragOverNodeId = targetEl.dataset.nodeId || "";
|
|
6734
|
+
dragState.container = event.currentTarget;
|
|
6735
|
+
event.preventDefault();
|
|
6736
|
+
};
|
|
6737
|
+
const handleDragLeave = (event) => {
|
|
6738
|
+
if (!event.target || !event.currentTarget)
|
|
6739
|
+
return;
|
|
6740
|
+
const targetEl = getNodeEl(event.target);
|
|
6741
|
+
if (!targetEl || targetEl !== event.currentTarget)
|
|
6742
|
+
return;
|
|
6743
|
+
const labelEl = targetEl.children[0];
|
|
6744
|
+
removeClassName(labelEl, "drag-before", "drag-after", "drag-inner");
|
|
6745
|
+
};
|
|
6746
|
+
const handleDragEnd = (event, node) => {
|
|
6747
|
+
if (!event.target || !event.currentTarget)
|
|
6748
|
+
return;
|
|
6749
|
+
const targetEl = getNodeEl(event.target);
|
|
6750
|
+
if (!targetEl || targetEl !== event.currentTarget)
|
|
6751
|
+
return;
|
|
6752
|
+
removeStatusClass(dragState.container);
|
|
6753
|
+
if (node && dragState.dragOverNodeId && dragState.dropType && services) {
|
|
6754
|
+
const targetInfo = services.editorService.getNodeInfo(dragState.dragOverNodeId, false);
|
|
6755
|
+
const targetNode = targetInfo.node;
|
|
6756
|
+
let targetParent = targetInfo.parent;
|
|
6757
|
+
if (!targetParent || !targetNode)
|
|
6758
|
+
return;
|
|
6759
|
+
let targetIndex = -1;
|
|
6760
|
+
if (Array.isArray(targetNode.items) && dragState.dropType === "inner") {
|
|
6761
|
+
targetIndex = targetNode.items.length;
|
|
6762
|
+
targetParent = targetNode;
|
|
6763
|
+
} else {
|
|
6764
|
+
targetIndex = getNodeIndex(dragState.dragOverNodeId, targetParent);
|
|
6765
|
+
}
|
|
6766
|
+
if (dragState.dropType === "after") {
|
|
6767
|
+
targetIndex += 1;
|
|
6768
|
+
}
|
|
6769
|
+
services?.editorService.dragTo(node, targetParent, targetIndex);
|
|
6770
|
+
}
|
|
6771
|
+
dragState.dragOverNodeId = "";
|
|
6772
|
+
dragState.dropType = "";
|
|
6773
|
+
dragState.container = null;
|
|
6774
|
+
};
|
|
6775
|
+
return {
|
|
6776
|
+
handleDragStart,
|
|
6777
|
+
handleDragEnd,
|
|
6778
|
+
handleDragLeave,
|
|
6779
|
+
handleDragOver
|
|
6780
|
+
};
|
|
6781
|
+
};
|
|
6782
|
+
|
|
6783
|
+
const updateStatus = (nodeStatusMap, id, status) => {
|
|
6784
|
+
const nodeStatus = nodeStatusMap.get(id);
|
|
6785
|
+
if (!nodeStatus)
|
|
6786
|
+
return;
|
|
6787
|
+
getKeys(status).forEach((key) => {
|
|
6788
|
+
if (nodeStatus[key] !== void 0 && status[key] !== void 0) {
|
|
6789
|
+
nodeStatus[key] = Boolean(status[key]);
|
|
6790
|
+
}
|
|
6791
|
+
});
|
|
6792
|
+
};
|
|
6793
|
+
const useFilter = (nodeStatusMap, page) => {
|
|
6794
|
+
const filterIsMatch = (value, data) => {
|
|
6795
|
+
if (!value) {
|
|
6796
|
+
return true;
|
|
6797
|
+
}
|
|
6798
|
+
let name = "";
|
|
6799
|
+
if (data.name) {
|
|
6800
|
+
name = data.name;
|
|
6801
|
+
} else if (data.items) {
|
|
6802
|
+
name = "container";
|
|
6803
|
+
}
|
|
6804
|
+
return `${data.id}${name}${data.type}`.includes(value);
|
|
6805
|
+
};
|
|
6806
|
+
const filterNode = (text) => (node, parents) => {
|
|
6807
|
+
if (!nodeStatusMap.value)
|
|
6808
|
+
return;
|
|
6809
|
+
const visible = filterIsMatch(text, node);
|
|
6810
|
+
if (visible && parents.length) {
|
|
6811
|
+
parents.forEach((parent) => {
|
|
6812
|
+
updateStatus(nodeStatusMap.value, parent.id, {
|
|
6813
|
+
visible,
|
|
6814
|
+
expand: true
|
|
6815
|
+
});
|
|
6816
|
+
});
|
|
6817
|
+
}
|
|
6818
|
+
updateStatus(nodeStatusMap.value, node.id, {
|
|
6819
|
+
visible
|
|
6820
|
+
});
|
|
6821
|
+
};
|
|
6822
|
+
const filter = (text) => {
|
|
6823
|
+
if (!page.value?.items?.length)
|
|
6824
|
+
return;
|
|
6825
|
+
page.value.items.forEach((node) => {
|
|
6826
|
+
traverseNode(node, filterNode(text));
|
|
6827
|
+
});
|
|
6828
|
+
};
|
|
6829
|
+
return {
|
|
6830
|
+
filterText: ref(""),
|
|
6831
|
+
filterTextChangeHandler(text) {
|
|
6832
|
+
filter(text);
|
|
6833
|
+
}
|
|
6834
|
+
};
|
|
6835
|
+
};
|
|
6836
|
+
|
|
6837
|
+
const _hoisted_1$a = ["draggable", "data-node-id", "data-is-container"];
|
|
6838
|
+
const _hoisted_2$8 = { class: "layer-node-label" };
|
|
6839
|
+
const _hoisted_3$4 = { class: "layer-node-tool" };
|
|
6840
|
+
const _hoisted_4$4 = {
|
|
6841
|
+
key: 0,
|
|
6842
|
+
class: "magic-editor-layer-node-children"
|
|
6843
|
+
};
|
|
6844
|
+
const throttleTime = 300;
|
|
6845
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
6385
6846
|
...{
|
|
6386
|
-
name: "
|
|
6847
|
+
name: "MEditorLayerNode"
|
|
6387
6848
|
},
|
|
6388
|
-
__name: "
|
|
6849
|
+
__name: "LayerNode",
|
|
6389
6850
|
props: {
|
|
6390
|
-
|
|
6851
|
+
data: {},
|
|
6852
|
+
parent: {},
|
|
6853
|
+
indent: { default: 0 },
|
|
6854
|
+
filterText: { default: "" },
|
|
6855
|
+
isCtrlKeyDown: { type: Boolean, default: false }
|
|
6391
6856
|
},
|
|
6392
|
-
|
|
6857
|
+
emits: ["node-contextmenu"],
|
|
6858
|
+
setup(__props, { emit }) {
|
|
6859
|
+
const props = __props;
|
|
6393
6860
|
const services = inject("services");
|
|
6861
|
+
const nodeStatusMap = inject("nodeStatusMap");
|
|
6394
6862
|
const editorService = services?.editorService;
|
|
6395
|
-
const
|
|
6396
|
-
const
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
const currentNodeKey = ref();
|
|
6402
|
-
const clicked = ref(false);
|
|
6403
|
-
const treeProps = {
|
|
6404
|
-
children: "items",
|
|
6405
|
-
label: "name",
|
|
6406
|
-
value: "id",
|
|
6407
|
-
disabled: (data) => Boolean(data.items?.length),
|
|
6408
|
-
class: (data) => {
|
|
6409
|
-
if (clicked.value || isPage(data))
|
|
6410
|
-
return "";
|
|
6411
|
-
if (data.id === highlightNode?.value?.id && !checkedKeys.value.includes(data.id)) {
|
|
6412
|
-
return "cus-tree-node-hover";
|
|
6413
|
-
}
|
|
6863
|
+
const uiService = services?.uiService;
|
|
6864
|
+
const nodeStatus = computed(
|
|
6865
|
+
() => nodeStatusMap?.value?.get(props.data.id) || {
|
|
6866
|
+
selected: false,
|
|
6867
|
+
expand: false,
|
|
6868
|
+
visible: false
|
|
6414
6869
|
}
|
|
6870
|
+
);
|
|
6871
|
+
const expanded = computed(() => nodeStatus.value.expand);
|
|
6872
|
+
const selected = computed(() => nodeStatus.value.selected);
|
|
6873
|
+
const visible = computed(() => nodeStatus.value.visible);
|
|
6874
|
+
const hasChilren = computed(() => props.data.items?.length > 0);
|
|
6875
|
+
const nodeEl = ref();
|
|
6876
|
+
const { handleDragStart, handleDragEnd, handleDragLeave } = useDrag(services);
|
|
6877
|
+
const expandHandler = () => {
|
|
6878
|
+
if (!nodeStatusMap?.value)
|
|
6879
|
+
return;
|
|
6880
|
+
updateStatus(nodeStatusMap.value, props.data.id, {
|
|
6881
|
+
expand: !expanded.value
|
|
6882
|
+
});
|
|
6883
|
+
};
|
|
6884
|
+
const nodeClickHandler = () => {
|
|
6885
|
+
if (!nodeStatusMap?.value)
|
|
6886
|
+
return;
|
|
6887
|
+
if (uiService?.get("uiSelectMode")) {
|
|
6888
|
+
document.dispatchEvent(new CustomEvent("ui-select", { detail: props.data }));
|
|
6889
|
+
return;
|
|
6890
|
+
}
|
|
6891
|
+
if (hasChilren.value && !props.isCtrlKeyDown) {
|
|
6892
|
+
updateStatus(nodeStatusMap.value, props.data.id, {
|
|
6893
|
+
expand: true
|
|
6894
|
+
});
|
|
6895
|
+
}
|
|
6896
|
+
nextTick(() => {
|
|
6897
|
+
select(props.data);
|
|
6898
|
+
});
|
|
6899
|
+
};
|
|
6900
|
+
const contextmenuHandler = (event) => {
|
|
6901
|
+
event.preventDefault();
|
|
6902
|
+
nodeClickHandler();
|
|
6903
|
+
emit("node-contextmenu", event, props.data);
|
|
6904
|
+
};
|
|
6905
|
+
const nodeContentmenuHandler = (event, node) => {
|
|
6906
|
+
emit("node-contextmenu", event, node);
|
|
6415
6907
|
};
|
|
6416
|
-
const isMultiSelect = computed(() => isCtrlKeyDown.value || checkedKeys.value.length > 1);
|
|
6417
|
-
const nodes = computed(() => editorService?.get("nodes") || []);
|
|
6418
|
-
const page = computed(() => editorService?.get("page"));
|
|
6419
|
-
const values = computed(() => page.value ? [page.value] : []);
|
|
6420
|
-
const highlightNode = computed(() => editorService?.get("highlightNode"));
|
|
6421
6908
|
const select = async (data) => {
|
|
6422
6909
|
if (!data.id) {
|
|
6423
6910
|
throw new Error("没有id");
|
|
6424
6911
|
}
|
|
6425
|
-
|
|
6426
|
-
|
|
6912
|
+
if (props.isCtrlKeyDown) {
|
|
6913
|
+
multiSelect(data);
|
|
6914
|
+
} else {
|
|
6915
|
+
await editorService?.select(data);
|
|
6916
|
+
editorService?.get("stage")?.select(data.id);
|
|
6917
|
+
}
|
|
6427
6918
|
};
|
|
6428
6919
|
const multiSelect = async (data) => {
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6920
|
+
const nodes = editorService?.get("nodes") || [];
|
|
6921
|
+
const newNodes = [];
|
|
6922
|
+
let isCancel = false;
|
|
6923
|
+
nodes.forEach((node) => {
|
|
6924
|
+
if (node.id === data.id) {
|
|
6925
|
+
isCancel = true;
|
|
6926
|
+
return;
|
|
6927
|
+
}
|
|
6928
|
+
newNodes.push(node.id);
|
|
6929
|
+
});
|
|
6930
|
+
if (!isCancel || newNodes.length === 0) {
|
|
6931
|
+
newNodes.push(data.id);
|
|
6435
6932
|
}
|
|
6436
|
-
editorService?.
|
|
6437
|
-
editorService?.get("stage")?.
|
|
6933
|
+
await editorService?.multiSelect(newNodes);
|
|
6934
|
+
editorService?.get("stage")?.multiSelect(newNodes);
|
|
6438
6935
|
};
|
|
6439
|
-
const
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
|
|
6446
|
-
return false;
|
|
6447
|
-
if (!data?.type)
|
|
6448
|
-
return false;
|
|
6449
|
-
if (["prev", "next"].includes(type))
|
|
6450
|
-
return true;
|
|
6451
|
-
if (data.items || data.type === "container")
|
|
6452
|
-
return true;
|
|
6453
|
-
return false;
|
|
6936
|
+
const highlightHandler = throttle(() => {
|
|
6937
|
+
highlight();
|
|
6938
|
+
}, throttleTime);
|
|
6939
|
+
const highlight = () => {
|
|
6940
|
+
editorService?.highlight(props.data);
|
|
6941
|
+
editorService?.get("stage")?.highlight(props.data.id);
|
|
6454
6942
|
};
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6943
|
+
return (_ctx, _cache) => {
|
|
6944
|
+
const _component_LayerNode = resolveComponent("LayerNode", true);
|
|
6945
|
+
return withDirectives((openBlock(), createElementBlock("div", {
|
|
6946
|
+
class: "magic-editor-layer-node",
|
|
6947
|
+
ref_key: "nodeEl",
|
|
6948
|
+
ref: nodeEl,
|
|
6949
|
+
draggable: !unref(isPage)(_ctx.data),
|
|
6950
|
+
"data-node-id": _ctx.data.id,
|
|
6951
|
+
"data-is-container": Array.isArray(_ctx.data.items),
|
|
6952
|
+
onDragstart: _cache[1] || (_cache[1] = //@ts-ignore
|
|
6953
|
+
(...args) => unref(handleDragStart) && unref(handleDragStart)(...args)),
|
|
6954
|
+
onDragleave: _cache[2] || (_cache[2] = //@ts-ignore
|
|
6955
|
+
(...args) => unref(handleDragLeave) && unref(handleDragLeave)(...args)),
|
|
6956
|
+
onDragend: _cache[3] || (_cache[3] = ($event) => unref(handleDragEnd)($event, _ctx.data))
|
|
6957
|
+
}, [
|
|
6958
|
+
createElementVNode("div", {
|
|
6959
|
+
class: normalizeClass(["layer-node", { selected: selected.value, expanded: expanded.value }]),
|
|
6960
|
+
style: normalizeStyle(`padding-left: ${_ctx.indent}px`),
|
|
6961
|
+
onContextmenu: contextmenuHandler,
|
|
6962
|
+
onMouseenter: _cache[0] || (_cache[0] = ($event) => unref(highlightHandler)())
|
|
6963
|
+
}, [
|
|
6964
|
+
createVNode(_sfc_main$M, {
|
|
6965
|
+
class: "expand-icon",
|
|
6966
|
+
style: normalizeStyle(hasChilren.value ? "" : "color: transparent; cursor: default"),
|
|
6967
|
+
icon: expanded.value ? unref(ArrowDown) : unref(ArrowRight),
|
|
6968
|
+
onClick: expandHandler
|
|
6969
|
+
}, null, 8, ["style", "icon"]),
|
|
6970
|
+
createElementVNode("div", {
|
|
6971
|
+
class: "layer-node-content",
|
|
6972
|
+
onClick: nodeClickHandler
|
|
6973
|
+
}, [
|
|
6974
|
+
renderSlot(_ctx.$slots, "layer-node-content", { data: _ctx.data }, () => [
|
|
6975
|
+
createElementVNode("div", _hoisted_2$8, toDisplayString(`${_ctx.data.name} (${_ctx.data.id})`), 1),
|
|
6976
|
+
createElementVNode("div", _hoisted_3$4, [
|
|
6977
|
+
createVNode(_sfc_main$i, { data: _ctx.data }, null, 8, ["data"])
|
|
6978
|
+
])
|
|
6979
|
+
])
|
|
6980
|
+
])
|
|
6981
|
+
], 38),
|
|
6982
|
+
hasChilren.value && expanded.value ? (openBlock(), createElementBlock("div", _hoisted_4$4, [
|
|
6983
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.items, (item) => {
|
|
6984
|
+
return openBlock(), createBlock(_component_LayerNode, {
|
|
6985
|
+
data: item,
|
|
6986
|
+
parent: _ctx.data,
|
|
6987
|
+
key: item.id,
|
|
6988
|
+
indent: _ctx.indent + 11,
|
|
6989
|
+
"filter-text": _ctx.filterText,
|
|
6990
|
+
"is-ctrl-key-down": _ctx.isCtrlKeyDown,
|
|
6991
|
+
onNodeContextmenu: nodeContentmenuHandler
|
|
6992
|
+
}, {
|
|
6993
|
+
"layer-node-content": withCtx(({ data: nodeData }) => [
|
|
6994
|
+
renderSlot(_ctx.$slots, "layer-node-content", { data: nodeData })
|
|
6995
|
+
]),
|
|
6996
|
+
_: 2
|
|
6997
|
+
}, 1032, ["data", "parent", "indent", "filter-text", "is-ctrl-key-down"]);
|
|
6998
|
+
}), 128))
|
|
6999
|
+
])) : createCommentVNode("", true)
|
|
7000
|
+
], 40, _hoisted_1$a)), [
|
|
7001
|
+
[vShow, visible.value]
|
|
7002
|
+
]);
|
|
7003
|
+
};
|
|
7004
|
+
}
|
|
7005
|
+
});
|
|
7006
|
+
|
|
7007
|
+
const useKeybinding = (services) => {
|
|
7008
|
+
const keybindingService = services?.keybindingService;
|
|
7009
|
+
const isCtrlKeyDown = ref(false);
|
|
7010
|
+
const windowBlurHandler = () => {
|
|
7011
|
+
isCtrlKeyDown.value = false;
|
|
7012
|
+
};
|
|
7013
|
+
keybindingService?.registeCommand("layer-panel-global-keyup", () => {
|
|
7014
|
+
isCtrlKeyDown.value = false;
|
|
7015
|
+
});
|
|
7016
|
+
keybindingService?.registeCommand("layer-panel-global-keydwon", () => {
|
|
7017
|
+
isCtrlKeyDown.value = true;
|
|
7018
|
+
});
|
|
7019
|
+
keybindingService?.registe([
|
|
7020
|
+
{
|
|
7021
|
+
command: "layer-panel-global-keydwon",
|
|
7022
|
+
keybinding: "ctrl",
|
|
7023
|
+
when: [["global", "keydown"]]
|
|
7024
|
+
},
|
|
7025
|
+
{
|
|
7026
|
+
command: "layer-panel-global-keyup",
|
|
7027
|
+
keybinding: "ctrl",
|
|
7028
|
+
when: [["global", "keyup"]]
|
|
7029
|
+
}
|
|
7030
|
+
]);
|
|
7031
|
+
onMounted(() => {
|
|
7032
|
+
globalThis.addEventListener("blur", windowBlurHandler);
|
|
7033
|
+
});
|
|
7034
|
+
onBeforeUnmount(() => {
|
|
7035
|
+
globalThis.removeEventListener("blur", windowBlurHandler);
|
|
7036
|
+
});
|
|
7037
|
+
return {
|
|
7038
|
+
isCtrlKeyDown
|
|
7039
|
+
};
|
|
7040
|
+
};
|
|
7041
|
+
|
|
7042
|
+
const createPageNodeStatus = (services, pageId) => {
|
|
7043
|
+
const map = /* @__PURE__ */ new Map();
|
|
7044
|
+
map.set(pageId, {
|
|
7045
|
+
visible: true,
|
|
7046
|
+
expand: true,
|
|
7047
|
+
selected: true
|
|
7048
|
+
});
|
|
7049
|
+
services?.editorService.getNodeById(pageId)?.items.forEach(
|
|
7050
|
+
(node) => traverseNode(node, (node2) => {
|
|
7051
|
+
map.set(node2.id, {
|
|
7052
|
+
visible: true,
|
|
7053
|
+
expand: false,
|
|
7054
|
+
selected: false
|
|
7055
|
+
});
|
|
7056
|
+
})
|
|
7057
|
+
);
|
|
7058
|
+
return map;
|
|
7059
|
+
};
|
|
7060
|
+
const useNodeStatus = (services, page) => {
|
|
7061
|
+
const nodes = computed(() => services?.editorService.get("nodes") || []);
|
|
7062
|
+
const nodeStatusMaps = ref(/* @__PURE__ */ new Map());
|
|
7063
|
+
const nodeStatusMap = computed(
|
|
7064
|
+
() => page.value ? nodeStatusMaps.value.get(page.value.id) : /* @__PURE__ */ new Map()
|
|
7065
|
+
);
|
|
7066
|
+
watch(
|
|
7067
|
+
() => page.value?.id,
|
|
7068
|
+
(pageId) => {
|
|
7069
|
+
if (!pageId || nodeStatusMaps.value.has(pageId)) {
|
|
6476
7070
|
return;
|
|
6477
7071
|
}
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
}
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
7072
|
+
nodeStatusMaps.value.set(pageId, createPageNodeStatus(services, pageId));
|
|
7073
|
+
},
|
|
7074
|
+
{
|
|
7075
|
+
immediate: true
|
|
7076
|
+
}
|
|
7077
|
+
);
|
|
7078
|
+
watch(
|
|
7079
|
+
nodes,
|
|
7080
|
+
(nodes2) => {
|
|
7081
|
+
if (!nodeStatusMap.value)
|
|
7082
|
+
return;
|
|
7083
|
+
for (const [id, status] of nodeStatusMap.value.entries()) {
|
|
7084
|
+
status.selected = nodes2.some((node) => node.id === id);
|
|
7085
|
+
if (status.selected) {
|
|
7086
|
+
getNodePath(id, page.value?.items).forEach((node) => {
|
|
7087
|
+
updateStatus(nodeStatusMap.value, node.id, {
|
|
7088
|
+
expand: true
|
|
7089
|
+
});
|
|
7090
|
+
});
|
|
7091
|
+
}
|
|
6486
7092
|
}
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
7093
|
+
},
|
|
7094
|
+
{
|
|
7095
|
+
immediate: true
|
|
7096
|
+
}
|
|
7097
|
+
);
|
|
7098
|
+
services?.editorService.on("add", (newNodes) => {
|
|
7099
|
+
newNodes.forEach((node) => {
|
|
7100
|
+
nodeStatusMap.value?.set(node.id, {
|
|
7101
|
+
visible: true,
|
|
7102
|
+
expand: Array.isArray(node.items),
|
|
7103
|
+
selected: true
|
|
7104
|
+
});
|
|
7105
|
+
});
|
|
7106
|
+
});
|
|
7107
|
+
services?.editorService.on("remove", (nodes2) => {
|
|
7108
|
+
nodes2.forEach((node) => {
|
|
7109
|
+
nodeStatusMap.value?.delete(node.id);
|
|
7110
|
+
});
|
|
7111
|
+
});
|
|
7112
|
+
return {
|
|
7113
|
+
nodeStatusMaps,
|
|
7114
|
+
nodeStatusMap
|
|
7115
|
+
};
|
|
7116
|
+
};
|
|
7117
|
+
|
|
7118
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
7119
|
+
...{
|
|
7120
|
+
name: "MEditorLayerPanel"
|
|
7121
|
+
},
|
|
7122
|
+
__name: "LayerPanel",
|
|
7123
|
+
props: {
|
|
7124
|
+
layerContentMenu: {}
|
|
7125
|
+
},
|
|
7126
|
+
setup(__props) {
|
|
7127
|
+
const services = inject("services");
|
|
7128
|
+
const editorService = services?.editorService;
|
|
7129
|
+
const page = computed(() => editorService?.get("page"));
|
|
7130
|
+
const root = computed(() => editorService?.get("root"));
|
|
7131
|
+
const { nodeStatusMap } = useNodeStatus(services, page);
|
|
7132
|
+
const { isCtrlKeyDown } = useKeybinding(services);
|
|
7133
|
+
provide("nodeStatusMap", nodeStatusMap);
|
|
7134
|
+
const { filterText, filterTextChangeHandler } = useFilter(nodeStatusMap, page);
|
|
7135
|
+
const collapseAllHandler = () => {
|
|
7136
|
+
if (!page.value || !nodeStatusMap.value)
|
|
7137
|
+
return;
|
|
7138
|
+
const items = nodeStatusMap.value.entries();
|
|
7139
|
+
for (const [id, status] of items) {
|
|
7140
|
+
if (id === page.value.id) {
|
|
7141
|
+
continue;
|
|
7142
|
+
}
|
|
7143
|
+
status.expand = false;
|
|
6492
7144
|
}
|
|
6493
|
-
return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
|
|
6494
7145
|
};
|
|
6495
|
-
const
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
7146
|
+
const menu = ref();
|
|
7147
|
+
const contextmenu = (event) => {
|
|
7148
|
+
event.preventDefault();
|
|
7149
|
+
menu.value?.show(event);
|
|
7150
|
+
};
|
|
7151
|
+
const { handleDragOver } = useDrag(services);
|
|
7152
|
+
return (_ctx, _cache) => {
|
|
7153
|
+
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
|
|
7154
|
+
default: withCtx(() => [
|
|
7155
|
+
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
7156
|
+
createVNode(_sfc_main$t, { onSearch: unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
|
|
7157
|
+
createElementVNode("div", {
|
|
7158
|
+
class: "magic-editor-layer-tree",
|
|
7159
|
+
tabindex: "-1",
|
|
7160
|
+
onDragover: _cache[0] || (_cache[0] = //@ts-ignore
|
|
7161
|
+
(...args) => unref(handleDragOver) && unref(handleDragOver)(...args))
|
|
7162
|
+
}, [
|
|
7163
|
+
page.value && root.value ? (openBlock(), createBlock(_sfc_main$h, {
|
|
7164
|
+
key: 0,
|
|
7165
|
+
data: page.value,
|
|
7166
|
+
"filter-text": unref(filterText),
|
|
7167
|
+
"is-ctrl-key-down": unref(isCtrlKeyDown),
|
|
7168
|
+
onNodeContextmenu: contextmenu
|
|
7169
|
+
}, {
|
|
7170
|
+
"layer-node-content": withCtx(({ data: nodeData }) => [
|
|
7171
|
+
renderSlot(_ctx.$slots, "layer-node-content", { data: nodeData })
|
|
7172
|
+
]),
|
|
7173
|
+
_: 3
|
|
7174
|
+
}, 8, ["data", "filter-text", "is-ctrl-key-down"])) : createCommentVNode("", true)
|
|
7175
|
+
], 32),
|
|
7176
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
7177
|
+
createVNode(_sfc_main$j, {
|
|
7178
|
+
ref_key: "menu",
|
|
7179
|
+
ref: menu,
|
|
7180
|
+
"layer-content-menu": _ctx.layerContentMenu,
|
|
7181
|
+
onCollapseAll: collapseAllHandler
|
|
7182
|
+
}, null, 8, ["layer-content-menu"])
|
|
7183
|
+
]))
|
|
7184
|
+
]),
|
|
7185
|
+
_: 3
|
|
7186
|
+
});
|
|
7187
|
+
};
|
|
7188
|
+
}
|
|
7189
|
+
});
|
|
7190
|
+
|
|
7191
|
+
const _hoisted_1$9 = ["onClick", "onDragstart"];
|
|
7192
|
+
const _hoisted_2$7 = ["title"];
|
|
7193
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
7194
|
+
...{
|
|
7195
|
+
name: "MEditorComponentListPanel"
|
|
7196
|
+
},
|
|
7197
|
+
__name: "ComponentListPanel",
|
|
7198
|
+
setup(__props) {
|
|
7199
|
+
const searchText = ref("");
|
|
7200
|
+
const filterTextChangeHandler = (v) => {
|
|
7201
|
+
searchText.value = v;
|
|
7202
|
+
};
|
|
7203
|
+
const services = inject("services");
|
|
7204
|
+
const stageOptions = inject("stageOptions");
|
|
7205
|
+
const stage = computed(() => services?.editorService.get("stage"));
|
|
7206
|
+
const list = computed(
|
|
7207
|
+
() => services?.componentListService.getList().map((group) => ({
|
|
7208
|
+
...group,
|
|
7209
|
+
items: group.items.filter((item) => item.text.includes(searchText.value))
|
|
7210
|
+
}))
|
|
7211
|
+
);
|
|
7212
|
+
const collapseValue = computed(
|
|
7213
|
+
() => Array(list.value?.length).fill(1).map((x, i) => `${i}`)
|
|
7214
|
+
);
|
|
7215
|
+
let timeout;
|
|
7216
|
+
let clientX;
|
|
7217
|
+
let clientY;
|
|
7218
|
+
const appendComponent = ({ text, type, data = {} }) => {
|
|
7219
|
+
services?.editorService.add({
|
|
7220
|
+
name: text,
|
|
7221
|
+
type,
|
|
7222
|
+
...data
|
|
6513
7223
|
});
|
|
6514
|
-
});
|
|
6515
|
-
watch(isMultiSelect, (isMultiSelect2) => {
|
|
6516
|
-
if (!isMultiSelect2) {
|
|
6517
|
-
currentNodeKey.value = editorService?.get("node")?.id;
|
|
6518
|
-
tree.value?.setCurrentKey(currentNodeKey.value);
|
|
6519
|
-
}
|
|
6520
|
-
});
|
|
6521
|
-
const editorServiceRemoveHandler = () => {
|
|
6522
|
-
setTimeout(() => {
|
|
6523
|
-
tree.value?.getNode(editorService?.get("node")?.id)?.updateChildren();
|
|
6524
|
-
}, 0);
|
|
6525
7224
|
};
|
|
6526
|
-
const
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
isCtrlKeyDown.value = false;
|
|
6539
|
-
});
|
|
6540
|
-
keybindingService?.registeCommand("layer-panel-global-keydwon", () => {
|
|
6541
|
-
if (!tree.value?.$el.contains(document.activeElement)) {
|
|
6542
|
-
isCtrlKeyDown.value = false;
|
|
6543
|
-
}
|
|
6544
|
-
});
|
|
6545
|
-
keybindingService?.registe([
|
|
6546
|
-
{
|
|
6547
|
-
command: "layer-panel-not-ctrl-keydown",
|
|
6548
|
-
when: [["layer-panel", "keydown"]]
|
|
6549
|
-
},
|
|
6550
|
-
{
|
|
6551
|
-
command: "layer-panel-ctrl-keydown",
|
|
6552
|
-
keybinding: "ctrl",
|
|
6553
|
-
when: [["layer-panel", "keydown"]]
|
|
6554
|
-
},
|
|
6555
|
-
{
|
|
6556
|
-
command: "layer-panel-ctrl-keyup",
|
|
6557
|
-
keybinding: "ctrl",
|
|
6558
|
-
when: [["layer-panel", "keyup"]]
|
|
6559
|
-
},
|
|
6560
|
-
{
|
|
6561
|
-
command: "layer-panel-global-keydwon",
|
|
6562
|
-
keybinding: "ctrl",
|
|
6563
|
-
when: [["global", "keydown"]]
|
|
6564
|
-
}
|
|
6565
|
-
]);
|
|
6566
|
-
watch(tree, () => {
|
|
6567
|
-
if (tree.value?.$el) {
|
|
6568
|
-
keybindingService?.registeEl("layer-panel", tree.value.$el);
|
|
6569
|
-
tree.value.$el.addEventListener("blur", windowBlurHandler);
|
|
6570
|
-
} else {
|
|
6571
|
-
keybindingService?.unregisteEl("layer-panel");
|
|
6572
|
-
}
|
|
6573
|
-
});
|
|
6574
|
-
onMounted(() => {
|
|
6575
|
-
editorService?.on("remove", editorServiceRemoveHandler);
|
|
6576
|
-
globalThis.addEventListener("blur", windowBlurHandler);
|
|
6577
|
-
});
|
|
6578
|
-
onBeforeUnmount(() => {
|
|
6579
|
-
tree.value?.$el.removeEventListener("blur", windowBlurHandler);
|
|
6580
|
-
});
|
|
6581
|
-
onUnmounted(() => {
|
|
6582
|
-
editorService?.off("remove", editorServiceRemoveHandler);
|
|
6583
|
-
globalThis.removeEventListener("blur", windowBlurHandler);
|
|
6584
|
-
});
|
|
6585
|
-
const highlightHandler = throttle((data) => {
|
|
6586
|
-
highlight(data);
|
|
6587
|
-
}, throttleTime);
|
|
6588
|
-
const toggleClickFlag = () => {
|
|
6589
|
-
clicked.value = !clicked.value;
|
|
7225
|
+
const dragstartHandler = ({ text, type, data = {} }, e) => {
|
|
7226
|
+
e.dataTransfer?.setData(
|
|
7227
|
+
"text/json",
|
|
7228
|
+
serialize({
|
|
7229
|
+
dragType: DragType.COMPONENT_LIST,
|
|
7230
|
+
data: {
|
|
7231
|
+
name: text,
|
|
7232
|
+
type,
|
|
7233
|
+
...data
|
|
7234
|
+
}
|
|
7235
|
+
})
|
|
7236
|
+
);
|
|
6590
7237
|
};
|
|
6591
|
-
const
|
|
6592
|
-
if (
|
|
6593
|
-
|
|
7238
|
+
const dragendHandler = () => {
|
|
7239
|
+
if (timeout) {
|
|
7240
|
+
globalThis.clearTimeout(timeout);
|
|
7241
|
+
timeout = void 0;
|
|
6594
7242
|
}
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
multiSelect(nodes.value.map((node) => node.id));
|
|
7243
|
+
const doc = stage.value?.renderer.contentWindow?.document;
|
|
7244
|
+
if (doc && stageOptions) {
|
|
7245
|
+
removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
6599
7246
|
}
|
|
7247
|
+
clientX = 0;
|
|
7248
|
+
clientY = 0;
|
|
6600
7249
|
};
|
|
6601
|
-
const
|
|
6602
|
-
if (
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
7250
|
+
const dragHandler = (e) => {
|
|
7251
|
+
if (e.clientX !== clientX || e.clientY !== clientY) {
|
|
7252
|
+
clientX = e.clientX;
|
|
7253
|
+
clientY = e.clientY;
|
|
7254
|
+
if (timeout) {
|
|
7255
|
+
globalThis.clearTimeout(timeout);
|
|
7256
|
+
timeout = void 0;
|
|
7257
|
+
}
|
|
6607
7258
|
return;
|
|
6608
7259
|
}
|
|
6609
|
-
|
|
6610
|
-
};
|
|
6611
|
-
const contextmenu = async (event, data) => {
|
|
6612
|
-
event.preventDefault();
|
|
6613
|
-
if (nodes.value.length < 2) {
|
|
6614
|
-
await select(data);
|
|
6615
|
-
}
|
|
6616
|
-
menu.value?.show(event);
|
|
6617
|
-
};
|
|
6618
|
-
const collapseAllHandler = () => {
|
|
6619
|
-
const page2 = editorService?.get("page");
|
|
6620
|
-
if (!tree.value || !page2)
|
|
7260
|
+
if (timeout || !stage.value)
|
|
6621
7261
|
return;
|
|
6622
|
-
|
|
6623
|
-
rootNode.childNodes.forEach((node) => {
|
|
6624
|
-
node.collapse();
|
|
6625
|
-
handleCollapse(node.data);
|
|
6626
|
-
});
|
|
7262
|
+
timeout = stage.value.delayedMarkContainer(e);
|
|
6627
7263
|
};
|
|
6628
7264
|
return (_ctx, _cache) => {
|
|
6629
|
-
return openBlock(), createBlock(unref(TMagicScrollbar),
|
|
7265
|
+
return openBlock(), createBlock(unref(TMagicScrollbar), null, {
|
|
6630
7266
|
default: withCtx(() => [
|
|
6631
|
-
renderSlot(_ctx.$slots, "
|
|
6632
|
-
createVNode(
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
class: "magic-editor-layer-tree",
|
|
6636
|
-
ref_key: "tree",
|
|
6637
|
-
ref: tree,
|
|
6638
|
-
"node-key": "id",
|
|
6639
|
-
"empty-text": "页面空荡荡的",
|
|
6640
|
-
tabindex: "-1",
|
|
6641
|
-
draggable: "",
|
|
6642
|
-
"default-expanded-keys": expandedKeys.value,
|
|
6643
|
-
"default-checked-keys": checkedKeys.value,
|
|
6644
|
-
"current-node-key": currentNodeKey.value,
|
|
6645
|
-
data: values.value,
|
|
6646
|
-
"expand-on-click-node": false,
|
|
6647
|
-
"highlight-current": !isMultiSelect.value,
|
|
6648
|
-
"check-on-click-node": true,
|
|
6649
|
-
props: treeProps,
|
|
6650
|
-
"filter-node-method": filterNode,
|
|
6651
|
-
"allow-drop": allowDrop,
|
|
6652
|
-
"show-checkbox": isMultiSelect.value,
|
|
6653
|
-
onNodeClick: clickHandler,
|
|
6654
|
-
onNodeContextmenu: contextmenu,
|
|
6655
|
-
onNodeDragEnd: handleDragEnd,
|
|
6656
|
-
onNodeCollapse: handleCollapse,
|
|
6657
|
-
onNodeExpand: handleExpand,
|
|
6658
|
-
onCheck: checkHandler,
|
|
6659
|
-
onMousedown: toggleClickFlag,
|
|
6660
|
-
onMouseup: toggleClickFlag
|
|
7267
|
+
renderSlot(_ctx.$slots, "component-list-panel-header"),
|
|
7268
|
+
createVNode(unref(TMagicCollapse), {
|
|
7269
|
+
class: "ui-component-panel",
|
|
7270
|
+
"model-value": collapseValue.value
|
|
6661
7271
|
}, {
|
|
6662
|
-
default: withCtx((
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
7272
|
+
default: withCtx(() => [
|
|
7273
|
+
createVNode(_sfc_main$t, { onSearch: filterTextChangeHandler }),
|
|
7274
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
|
|
7275
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
7276
|
+
group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
|
|
7277
|
+
key: index,
|
|
7278
|
+
name: `${index}`
|
|
7279
|
+
}, {
|
|
7280
|
+
title: withCtx(() => [
|
|
7281
|
+
createVNode(_sfc_main$M, { icon: unref(Grid) }, null, 8, ["icon"]),
|
|
7282
|
+
createTextVNode(toDisplayString(group.title), 1)
|
|
7283
|
+
]),
|
|
7284
|
+
default: withCtx(() => [
|
|
7285
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
|
|
7286
|
+
return openBlock(), createElementBlock("div", {
|
|
7287
|
+
class: "component-item",
|
|
7288
|
+
draggable: "true",
|
|
7289
|
+
key: item.type,
|
|
7290
|
+
onClick: ($event) => appendComponent(item),
|
|
7291
|
+
onDragstart: ($event) => dragstartHandler(item, $event),
|
|
7292
|
+
onDragend: dragendHandler,
|
|
7293
|
+
onDrag: dragHandler
|
|
7294
|
+
}, [
|
|
7295
|
+
renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
7296
|
+
createVNode(_sfc_main$M, {
|
|
7297
|
+
title: item.text,
|
|
7298
|
+
icon: item.icon
|
|
7299
|
+
}, null, 8, ["title", "icon"]),
|
|
7300
|
+
createElementVNode("span", {
|
|
7301
|
+
title: item.text
|
|
7302
|
+
}, toDisplayString(item.text), 9, _hoisted_2$7)
|
|
7303
|
+
])
|
|
7304
|
+
], 40, _hoisted_1$9);
|
|
7305
|
+
}), 128))
|
|
7306
|
+
]),
|
|
7307
|
+
_: 2
|
|
7308
|
+
}, 1032, ["name"])) : createCommentVNode("", true)
|
|
7309
|
+
], 64);
|
|
7310
|
+
}), 256))
|
|
6675
7311
|
]),
|
|
6676
7312
|
_: 3
|
|
6677
|
-
}, 8, ["
|
|
6678
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
6679
|
-
createVNode(_sfc_main$h, {
|
|
6680
|
-
ref_key: "menu",
|
|
6681
|
-
ref: menu,
|
|
6682
|
-
"layer-content-menu": _ctx.layerContentMenu,
|
|
6683
|
-
onCollapseAll: collapseAllHandler
|
|
6684
|
-
}, null, 8, ["layer-content-menu"])
|
|
6685
|
-
]))
|
|
7313
|
+
}, 8, ["model-value"])
|
|
6686
7314
|
]),
|
|
6687
7315
|
_: 3
|
|
6688
7316
|
});
|
|
@@ -6719,7 +7347,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
6719
7347
|
type: "component",
|
|
6720
7348
|
icon: Goods,
|
|
6721
7349
|
text: "组件",
|
|
6722
|
-
component: _sfc_main$
|
|
7350
|
+
component: _sfc_main$f,
|
|
6723
7351
|
slots: {}
|
|
6724
7352
|
},
|
|
6725
7353
|
layer: {
|
|
@@ -6730,7 +7358,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
6730
7358
|
props: {
|
|
6731
7359
|
layerContentMenu: props.layerContentMenu
|
|
6732
7360
|
},
|
|
6733
|
-
component: _sfc_main$
|
|
7361
|
+
component: _sfc_main$g,
|
|
6734
7362
|
slots: {}
|
|
6735
7363
|
},
|
|
6736
7364
|
"code-block": {
|
|
@@ -6738,7 +7366,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
6738
7366
|
type: "component",
|
|
6739
7367
|
icon: EditPen,
|
|
6740
7368
|
text: "代码编辑",
|
|
6741
|
-
component: _sfc_main$
|
|
7369
|
+
component: _sfc_main$p,
|
|
6742
7370
|
slots: {}
|
|
6743
7371
|
},
|
|
6744
7372
|
"data-source": {
|
|
@@ -6746,7 +7374,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
6746
7374
|
type: "component",
|
|
6747
7375
|
icon: Coin,
|
|
6748
7376
|
text: "数据源",
|
|
6749
|
-
component: _sfc_main$
|
|
7377
|
+
component: _sfc_main$m,
|
|
6750
7378
|
slots: {}
|
|
6751
7379
|
}
|
|
6752
7380
|
};
|
|
@@ -6771,7 +7399,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
6771
7399
|
key: config.$key ?? index,
|
|
6772
7400
|
onClick: ($event) => activeTabName.value = config.text || `${index}`
|
|
6773
7401
|
}, [
|
|
6774
|
-
config.icon ? (openBlock(), createBlock(_sfc_main$
|
|
7402
|
+
config.icon ? (openBlock(), createBlock(_sfc_main$M, {
|
|
6775
7403
|
key: 0,
|
|
6776
7404
|
icon: config.icon
|
|
6777
7405
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -6832,16 +7460,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
6832
7460
|
} : void 0,
|
|
6833
7461
|
config.$key === "layer" || config.slots?.layerNodeContent ? {
|
|
6834
7462
|
name: "layer-node-content",
|
|
6835
|
-
fn: withCtx(({ data: nodeData
|
|
7463
|
+
fn: withCtx(({ data: nodeData }) => [
|
|
6836
7464
|
config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
|
|
6837
7465
|
key: 0,
|
|
6838
|
-
data: nodeData
|
|
6839
|
-
node
|
|
7466
|
+
data: nodeData
|
|
6840
7467
|
}) : config.slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerNodeContent), {
|
|
6841
7468
|
key: 1,
|
|
6842
|
-
data: nodeData
|
|
6843
|
-
|
|
6844
|
-
}, null, 8, ["data", "node"])) : createCommentVNode("", true)
|
|
7469
|
+
data: nodeData
|
|
7470
|
+
}, null, 8, ["data"])) : createCommentVNode("", true)
|
|
6845
7471
|
]),
|
|
6846
7472
|
key: "5"
|
|
6847
7473
|
} : void 0
|
|
@@ -7471,7 +8097,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
7471
8097
|
content: _ctx.pinned ? "取消置于顶层自动隐藏" : "置于顶层不消失"
|
|
7472
8098
|
}, {
|
|
7473
8099
|
default: withCtx(() => [
|
|
7474
|
-
createVNode(_sfc_main$
|
|
8100
|
+
createVNode(_sfc_main$M, {
|
|
7475
8101
|
style: { "margin-left": "10px", "cursor": "pointer" },
|
|
7476
8102
|
icon: _ctx.pinned ? _sfc_main$a : _sfc_main$b,
|
|
7477
8103
|
onClick: pinHandler
|
|
@@ -7487,7 +8113,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
7487
8113
|
onClick: closeHandler
|
|
7488
8114
|
}, {
|
|
7489
8115
|
default: withCtx(() => [
|
|
7490
|
-
createVNode(_sfc_main$
|
|
8116
|
+
createVNode(_sfc_main$M, { icon: unref(Close) }, null, 8, ["icon"])
|
|
7491
8117
|
]),
|
|
7492
8118
|
_: 1
|
|
7493
8119
|
})
|
|
@@ -7545,7 +8171,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
7545
8171
|
return;
|
|
7546
8172
|
}
|
|
7547
8173
|
timeout = globalThis.setTimeout(() => {
|
|
7548
|
-
const els = stage2
|
|
8174
|
+
const els = stage2.renderer.getElementsFromPoint(event) || [];
|
|
7549
8175
|
const nodes = getNodes(
|
|
7550
8176
|
els.map((el) => el.id),
|
|
7551
8177
|
page.value?.items
|
|
@@ -7614,7 +8240,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
7614
8240
|
menu.value?.hide();
|
|
7615
8241
|
};
|
|
7616
8242
|
return (_ctx, _cache) => {
|
|
7617
|
-
return openBlock(), createBlock(_sfc_main$
|
|
8243
|
+
return openBlock(), createBlock(_sfc_main$l, {
|
|
7618
8244
|
ref_key: "menu",
|
|
7619
8245
|
ref: menu,
|
|
7620
8246
|
class: "magic-editor-node-list-menu",
|
|
@@ -7800,7 +8426,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
7800
8426
|
};
|
|
7801
8427
|
__expose({ show });
|
|
7802
8428
|
return (_ctx, _cache) => {
|
|
7803
|
-
return openBlock(), createBlock(_sfc_main$
|
|
8429
|
+
return openBlock(), createBlock(_sfc_main$l, {
|
|
7804
8430
|
"menu-data": menuData.value,
|
|
7805
8431
|
ref_key: "menu",
|
|
7806
8432
|
ref: menu
|
|
@@ -7895,17 +8521,26 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
7895
8521
|
services?.editorService.set("stage", null);
|
|
7896
8522
|
services?.keybindingService.unregisteEl("stage");
|
|
7897
8523
|
});
|
|
8524
|
+
const parseDSL = getConfig("parseDSL");
|
|
7898
8525
|
const contextmenuHandler = (e) => {
|
|
7899
8526
|
e.preventDefault();
|
|
7900
8527
|
menu.value?.show(e);
|
|
7901
8528
|
};
|
|
7902
8529
|
const dragoverHandler = (e) => {
|
|
7903
|
-
e.preventDefault();
|
|
7904
8530
|
if (!e.dataTransfer)
|
|
7905
8531
|
return;
|
|
8532
|
+
e.preventDefault();
|
|
7906
8533
|
e.dataTransfer.dropEffect = "move";
|
|
7907
8534
|
};
|
|
7908
8535
|
const dropHandler = async (e) => {
|
|
8536
|
+
if (!e.dataTransfer)
|
|
8537
|
+
return;
|
|
8538
|
+
const data = e.dataTransfer.getData("text/json");
|
|
8539
|
+
if (!data)
|
|
8540
|
+
return;
|
|
8541
|
+
const config = parseDSL(`(${data})`);
|
|
8542
|
+
if (!config || config.dragType !== DragType.COMPONENT_LIST)
|
|
8543
|
+
return;
|
|
7909
8544
|
e.preventDefault();
|
|
7910
8545
|
const doc = stage?.renderer.contentWindow?.document;
|
|
7911
8546
|
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
@@ -7913,18 +8548,11 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
7913
8548
|
if (parentEl) {
|
|
7914
8549
|
parent = services?.editorService.getNodeById(parentEl.id, false);
|
|
7915
8550
|
}
|
|
7916
|
-
if (
|
|
7917
|
-
const parseDSL = getConfig("parseDSL");
|
|
7918
|
-
const data = e.dataTransfer.getData("text/json");
|
|
7919
|
-
if (!data)
|
|
7920
|
-
return;
|
|
7921
|
-
const config = parseDSL(`(${data})`);
|
|
7922
|
-
if (!config)
|
|
7923
|
-
return;
|
|
8551
|
+
if (parent && stageContainer.value && stage) {
|
|
7924
8552
|
const layout = await services?.editorService.getLayout(parent);
|
|
7925
8553
|
const containerRect = stageContainer.value.getBoundingClientRect();
|
|
7926
8554
|
const { scrollTop, scrollLeft } = stage.mask;
|
|
7927
|
-
const { style = {} } = config;
|
|
8555
|
+
const { style = {} } = config.data;
|
|
7928
8556
|
let top = 0;
|
|
7929
8557
|
let left = 0;
|
|
7930
8558
|
let position = "relative";
|
|
@@ -7938,14 +8566,14 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
7938
8566
|
top = top - calcValueByFontsize(doc, parentTop);
|
|
7939
8567
|
}
|
|
7940
8568
|
}
|
|
7941
|
-
config.style = {
|
|
8569
|
+
config.data.style = {
|
|
7942
8570
|
...style,
|
|
7943
8571
|
position,
|
|
7944
8572
|
top: top / zoom.value,
|
|
7945
8573
|
left: left / zoom.value
|
|
7946
8574
|
};
|
|
7947
|
-
config.inputEvent = e;
|
|
7948
|
-
services?.editorService.add(config, parent);
|
|
8575
|
+
config.data.inputEvent = e;
|
|
8576
|
+
services?.editorService.add(config.data, parent);
|
|
7949
8577
|
}
|
|
7950
8578
|
};
|
|
7951
8579
|
return (_ctx, _cache) => {
|
|
@@ -8131,14 +8759,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
8131
8759
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
8132
8760
|
onClick: addPage
|
|
8133
8761
|
}, [
|
|
8134
|
-
createVNode(_sfc_main$
|
|
8762
|
+
createVNode(_sfc_main$M, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
8135
8763
|
])) : (openBlock(), createElementBlock("div", _hoisted_1$2)),
|
|
8136
8764
|
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
8137
8765
|
key: 2,
|
|
8138
8766
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
8139
8767
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
8140
8768
|
}, [
|
|
8141
|
-
createVNode(_sfc_main$
|
|
8769
|
+
createVNode(_sfc_main$M, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
|
|
8142
8770
|
])) : createCommentVNode("", true),
|
|
8143
8771
|
pageLength.value ? (openBlock(), createElementBlock("div", {
|
|
8144
8772
|
key: 3,
|
|
@@ -8154,7 +8782,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
8154
8782
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
8155
8783
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
8156
8784
|
}, [
|
|
8157
|
-
createVNode(_sfc_main$
|
|
8785
|
+
createVNode(_sfc_main$M, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
|
|
8158
8786
|
])) : createCommentVNode("", true)
|
|
8159
8787
|
], 512);
|
|
8160
8788
|
};
|
|
@@ -8226,7 +8854,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
8226
8854
|
default: withCtx(() => [
|
|
8227
8855
|
createElementVNode("div", null, [
|
|
8228
8856
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
8229
|
-
createVNode(_sfc_main$
|
|
8857
|
+
createVNode(_sfc_main$w, {
|
|
8230
8858
|
data: {
|
|
8231
8859
|
type: "button",
|
|
8232
8860
|
text: "复制",
|
|
@@ -8234,7 +8862,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
8234
8862
|
handler: () => copy(item)
|
|
8235
8863
|
}
|
|
8236
8864
|
}, null, 8, ["data"]),
|
|
8237
|
-
createVNode(_sfc_main$
|
|
8865
|
+
createVNode(_sfc_main$w, {
|
|
8238
8866
|
data: {
|
|
8239
8867
|
type: "button",
|
|
8240
8868
|
text: "删除",
|
|
@@ -9075,119 +9703,23 @@ const keybindingConfig = [
|
|
|
9075
9703
|
}
|
|
9076
9704
|
];
|
|
9077
9705
|
|
|
9078
|
-
const
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
},
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
}
|
|
9095
|
-
/** 左侧面板配置 */
|
|
9096
|
-
sidebar: {
|
|
9097
|
-
type: Object
|
|
9098
|
-
},
|
|
9099
|
-
/** 顶部工具栏配置 */
|
|
9100
|
-
menu: {
|
|
9101
|
-
type: Object,
|
|
9102
|
-
default: () => ({ left: [], right: [] })
|
|
9103
|
-
},
|
|
9104
|
-
/** 组件树右键菜单 */
|
|
9105
|
-
layerContentMenu: {
|
|
9106
|
-
type: Array,
|
|
9107
|
-
default: () => []
|
|
9108
|
-
},
|
|
9109
|
-
/** 画布右键菜单 */
|
|
9110
|
-
stageContentMenu: {
|
|
9111
|
-
type: Array,
|
|
9112
|
-
default: () => []
|
|
9113
|
-
},
|
|
9114
|
-
/** 中间工作区域中画布渲染的内容 */
|
|
9115
|
-
render: {
|
|
9116
|
-
type: Function
|
|
9117
|
-
},
|
|
9118
|
-
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
9119
|
-
runtimeUrl: String,
|
|
9120
|
-
/** 选中时是否自动滚动到可视区域 */
|
|
9121
|
-
autoScrollIntoView: Boolean,
|
|
9122
|
-
/** 组件的属性配置表单的dsl */
|
|
9123
|
-
propsConfigs: {
|
|
9124
|
-
type: Object,
|
|
9125
|
-
default: () => ({})
|
|
9126
|
-
},
|
|
9127
|
-
/** 添加组件时的默认值 */
|
|
9128
|
-
propsValues: {
|
|
9129
|
-
type: Object,
|
|
9130
|
-
default: () => ({})
|
|
9131
|
-
},
|
|
9132
|
-
/** 组件联动事件选项列表 */
|
|
9133
|
-
eventMethodList: {
|
|
9134
|
-
type: Object,
|
|
9135
|
-
default: () => ({})
|
|
9136
|
-
},
|
|
9137
|
-
/** 添加数据源时的默认值 */
|
|
9138
|
-
datasourceValues: {
|
|
9139
|
-
type: Object,
|
|
9140
|
-
default: () => ({})
|
|
9141
|
-
},
|
|
9142
|
-
/** 数据源的属性配置表单的dsl */
|
|
9143
|
-
datasourceConfigs: {
|
|
9144
|
-
type: Object,
|
|
9145
|
-
default: () => ({})
|
|
9146
|
-
},
|
|
9147
|
-
/** 画布中组件选中框的移动范围 */
|
|
9148
|
-
moveableOptions: {
|
|
9149
|
-
type: [Object, Function]
|
|
9150
|
-
},
|
|
9151
|
-
/** 编辑器初始化时默认选中的组件ID */
|
|
9152
|
-
defaultSelected: {
|
|
9153
|
-
type: [Number, String]
|
|
9154
|
-
},
|
|
9155
|
-
canSelect: {
|
|
9156
|
-
type: Function,
|
|
9157
|
-
default: (el) => Boolean(el.id)
|
|
9158
|
-
},
|
|
9159
|
-
isContainer: {
|
|
9160
|
-
type: Function,
|
|
9161
|
-
default: (el) => el.classList.contains("magic-ui-container")
|
|
9162
|
-
},
|
|
9163
|
-
containerHighlightClassName: {
|
|
9164
|
-
type: String,
|
|
9165
|
-
default: CONTAINER_HIGHLIGHT_CLASS_NAME
|
|
9166
|
-
},
|
|
9167
|
-
containerHighlightDuration: {
|
|
9168
|
-
type: Number,
|
|
9169
|
-
default: 800
|
|
9170
|
-
},
|
|
9171
|
-
containerHighlightType: {
|
|
9172
|
-
type: String,
|
|
9173
|
-
default: ContainerHighlightType.DEFAULT
|
|
9174
|
-
},
|
|
9175
|
-
stageRect: {
|
|
9176
|
-
type: [String, Object]
|
|
9177
|
-
},
|
|
9178
|
-
codeOptions: {
|
|
9179
|
-
type: Object,
|
|
9180
|
-
default: () => ({})
|
|
9181
|
-
},
|
|
9182
|
-
updateDragEl: {
|
|
9183
|
-
type: Function
|
|
9184
|
-
},
|
|
9185
|
-
disabledDragStart: {
|
|
9186
|
-
type: Boolean
|
|
9187
|
-
},
|
|
9188
|
-
extendFormState: {
|
|
9189
|
-
type: Function
|
|
9190
|
-
}
|
|
9706
|
+
const defaultEditorProps = {
|
|
9707
|
+
componentGroupList: () => [],
|
|
9708
|
+
datasourceList: () => [],
|
|
9709
|
+
menu: () => ({ left: [], right: [] }),
|
|
9710
|
+
layerContentMenu: () => [],
|
|
9711
|
+
stageContentMenu: () => [],
|
|
9712
|
+
propsConfigs: () => ({}),
|
|
9713
|
+
propsValues: () => ({}),
|
|
9714
|
+
eventMethodList: () => ({}),
|
|
9715
|
+
datasourceValues: () => ({}),
|
|
9716
|
+
datasourceConfigs: () => ({}),
|
|
9717
|
+
canSelect: (el) => Boolean(el.id),
|
|
9718
|
+
isContainer: (el) => el.classList.contains("magic-ui-container"),
|
|
9719
|
+
containerHighlightClassName: CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
9720
|
+
containerHighlightDuration: 800,
|
|
9721
|
+
containerHighlightType: ContainerHighlightType.DEFAULT,
|
|
9722
|
+
codeOptions: () => ({})
|
|
9191
9723
|
};
|
|
9192
9724
|
|
|
9193
9725
|
const createCodeBlockTarget = (id, codeBlock) => new Target({
|
|
@@ -9208,20 +9740,26 @@ const createCodeBlockTarget = (id, codeBlock) => new Target({
|
|
|
9208
9740
|
const createDataSourceTarget = (id) => new Target({
|
|
9209
9741
|
type: DepTargetType.DATA_SOURCE,
|
|
9210
9742
|
id,
|
|
9211
|
-
isTarget: (key, value) =>
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9743
|
+
isTarget: (key, value) => {
|
|
9744
|
+
if (value?.isBindDataSource && value.dataSourceId || typeof value === "string" && value.includes(`${id}`)) {
|
|
9745
|
+
return true;
|
|
9746
|
+
}
|
|
9747
|
+
if (!Array.isArray(value) || typeof value[0] !== "string") {
|
|
9748
|
+
return false;
|
|
9749
|
+
}
|
|
9750
|
+
const [prefixId] = value;
|
|
9751
|
+
const prefixIndex = prefixId.indexOf(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);
|
|
9752
|
+
if (prefixIndex === -1) {
|
|
9753
|
+
return false;
|
|
9754
|
+
}
|
|
9755
|
+
const dsId = prefixId.substring(prefixIndex + DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length);
|
|
9756
|
+
return dsId === id && Boolean(dataSourceService.getDataSourceById(id));
|
|
9757
|
+
}
|
|
9215
9758
|
});
|
|
9216
9759
|
const createDataSourceCondTarget = (id) => new Target({
|
|
9217
9760
|
type: DepTargetType.DATA_SOURCE_COND,
|
|
9218
9761
|
id,
|
|
9219
|
-
isTarget: (key, value) =>
|
|
9220
|
-
if (!Array.isArray(value) || value[0] !== id)
|
|
9221
|
-
return false;
|
|
9222
|
-
const ds = dataSourceService.getDataSourceById(id);
|
|
9223
|
-
return Boolean(ds?.fields?.find((field) => field.name === value[1]));
|
|
9224
|
-
}
|
|
9762
|
+
isTarget: (key, value) => Array.isArray(value) && value[0] === id && Boolean(dataSourceService.getDataSourceById(id))
|
|
9225
9763
|
});
|
|
9226
9764
|
const createDataSourceMethodTarget = (id) => new Target({
|
|
9227
9765
|
type: DepTargetType.DATA_SOURCE_METHOD,
|
|
@@ -9248,7 +9786,7 @@ const initServiceState = (props, {
|
|
|
9248
9786
|
watch(
|
|
9249
9787
|
() => props.modelValue,
|
|
9250
9788
|
(modelValue) => {
|
|
9251
|
-
editorService.set("root", modelValue);
|
|
9789
|
+
editorService.set("root", modelValue || null);
|
|
9252
9790
|
},
|
|
9253
9791
|
{
|
|
9254
9792
|
immediate: true
|
|
@@ -9256,28 +9794,28 @@ const initServiceState = (props, {
|
|
|
9256
9794
|
);
|
|
9257
9795
|
watch(
|
|
9258
9796
|
() => props.componentGroupList,
|
|
9259
|
-
(componentGroupList) => componentListService.setList(componentGroupList),
|
|
9797
|
+
(componentGroupList) => componentGroupList && componentListService.setList(componentGroupList),
|
|
9260
9798
|
{
|
|
9261
9799
|
immediate: true
|
|
9262
9800
|
}
|
|
9263
9801
|
);
|
|
9264
9802
|
watch(
|
|
9265
9803
|
() => props.datasourceList,
|
|
9266
|
-
(datasourceList) => dataSourceService.set("datasourceTypeList", datasourceList),
|
|
9804
|
+
(datasourceList) => datasourceList && dataSourceService.set("datasourceTypeList", datasourceList),
|
|
9267
9805
|
{
|
|
9268
9806
|
immediate: true
|
|
9269
9807
|
}
|
|
9270
9808
|
);
|
|
9271
9809
|
watch(
|
|
9272
9810
|
() => props.propsConfigs,
|
|
9273
|
-
(configs) => propsService.setPropsConfigs(configs),
|
|
9811
|
+
(configs) => configs && propsService.setPropsConfigs(configs),
|
|
9274
9812
|
{
|
|
9275
9813
|
immediate: true
|
|
9276
9814
|
}
|
|
9277
9815
|
);
|
|
9278
9816
|
watch(
|
|
9279
9817
|
() => props.propsValues,
|
|
9280
|
-
(values) => propsService.setPropsValues(values),
|
|
9818
|
+
(values) => values && propsService.setPropsValues(values),
|
|
9281
9819
|
{
|
|
9282
9820
|
immediate: true
|
|
9283
9821
|
}
|
|
@@ -9287,7 +9825,7 @@ const initServiceState = (props, {
|
|
|
9287
9825
|
(eventMethodList) => {
|
|
9288
9826
|
const eventsList = {};
|
|
9289
9827
|
const methodsList = {};
|
|
9290
|
-
Object.keys(eventMethodList).forEach((type) => {
|
|
9828
|
+
eventMethodList && Object.keys(eventMethodList).forEach((type) => {
|
|
9291
9829
|
eventsList[type] = eventMethodList[type].events;
|
|
9292
9830
|
methodsList[type] = eventMethodList[type].methods;
|
|
9293
9831
|
});
|
|
@@ -9301,7 +9839,7 @@ const initServiceState = (props, {
|
|
|
9301
9839
|
watch(
|
|
9302
9840
|
() => props.datasourceConfigs,
|
|
9303
9841
|
(configs) => {
|
|
9304
|
-
Object.entries(configs).forEach(([key, value]) => {
|
|
9842
|
+
configs && Object.entries(configs).forEach(([key, value]) => {
|
|
9305
9843
|
dataSourceService.setFormConfig(key, value);
|
|
9306
9844
|
});
|
|
9307
9845
|
},
|
|
@@ -9312,7 +9850,7 @@ const initServiceState = (props, {
|
|
|
9312
9850
|
watch(
|
|
9313
9851
|
() => props.datasourceValues,
|
|
9314
9852
|
(values) => {
|
|
9315
|
-
Object.entries(values).forEach(([key, value]) => {
|
|
9853
|
+
values && Object.entries(values).forEach(([key, value]) => {
|
|
9316
9854
|
dataSourceService.setFormValue(key, value);
|
|
9317
9855
|
});
|
|
9318
9856
|
},
|
|
@@ -9320,6 +9858,26 @@ const initServiceState = (props, {
|
|
|
9320
9858
|
immediate: true
|
|
9321
9859
|
}
|
|
9322
9860
|
);
|
|
9861
|
+
watch(
|
|
9862
|
+
() => props.datasourceEventMethodList,
|
|
9863
|
+
(eventMethodList) => {
|
|
9864
|
+
const eventsList = {};
|
|
9865
|
+
const methodsList = {};
|
|
9866
|
+
eventMethodList && Object.keys(eventMethodList).forEach((type) => {
|
|
9867
|
+
eventsList[type] = eventMethodList[type].events;
|
|
9868
|
+
methodsList[type] = eventMethodList[type].methods;
|
|
9869
|
+
});
|
|
9870
|
+
Object.entries(eventsList).forEach(([key, value]) => {
|
|
9871
|
+
dataSourceService.setFormEvent(key, value);
|
|
9872
|
+
});
|
|
9873
|
+
Object.entries(methodsList).forEach(([key, value]) => {
|
|
9874
|
+
dataSourceService.setFormMethod(key, value);
|
|
9875
|
+
});
|
|
9876
|
+
},
|
|
9877
|
+
{
|
|
9878
|
+
immediate: true
|
|
9879
|
+
}
|
|
9880
|
+
);
|
|
9323
9881
|
watch(
|
|
9324
9882
|
() => props.defaultSelected,
|
|
9325
9883
|
(defaultSelected) => defaultSelected && editorService.select(defaultSelected),
|
|
@@ -9441,6 +9999,8 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
9441
9999
|
if (toRaw(value) !== toRaw(preValue)) {
|
|
9442
10000
|
emit("update:modelValue", value);
|
|
9443
10001
|
}
|
|
10002
|
+
if (!value)
|
|
10003
|
+
return;
|
|
9444
10004
|
value.codeBlocks = value.codeBlocks || {};
|
|
9445
10005
|
value.dataSources = value.dataSources || [];
|
|
9446
10006
|
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
@@ -9523,18 +10083,44 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
9523
10083
|
});
|
|
9524
10084
|
};
|
|
9525
10085
|
|
|
9526
|
-
const _sfc_main = defineComponent({
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
10086
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10087
|
+
...{
|
|
10088
|
+
name: "MEditor"
|
|
10089
|
+
},
|
|
10090
|
+
__name: "Editor",
|
|
10091
|
+
props: mergeDefaults({
|
|
10092
|
+
modelValue: {},
|
|
10093
|
+
componentGroupList: {},
|
|
10094
|
+
datasourceList: {},
|
|
10095
|
+
sidebar: {},
|
|
10096
|
+
menu: {},
|
|
10097
|
+
layerContentMenu: {},
|
|
10098
|
+
stageContentMenu: {},
|
|
10099
|
+
render: { type: Function },
|
|
10100
|
+
runtimeUrl: {},
|
|
10101
|
+
autoScrollIntoView: { type: Boolean },
|
|
10102
|
+
propsConfigs: {},
|
|
10103
|
+
propsValues: {},
|
|
10104
|
+
eventMethodList: {},
|
|
10105
|
+
datasourceValues: {},
|
|
10106
|
+
datasourceConfigs: {},
|
|
10107
|
+
datasourceEventMethodList: {},
|
|
10108
|
+
moveableOptions: { type: Function },
|
|
10109
|
+
defaultSelected: {},
|
|
10110
|
+
canSelect: { type: Function },
|
|
10111
|
+
isContainer: { type: Function },
|
|
10112
|
+
containerHighlightClassName: {},
|
|
10113
|
+
containerHighlightDuration: {},
|
|
10114
|
+
containerHighlightType: {},
|
|
10115
|
+
stageRect: {},
|
|
10116
|
+
codeOptions: {},
|
|
10117
|
+
updateDragEl: { type: Function },
|
|
10118
|
+
disabledDragStart: { type: Boolean },
|
|
10119
|
+
extendFormState: { type: Function }
|
|
10120
|
+
}, defaultEditorProps),
|
|
9536
10121
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
9537
|
-
setup(
|
|
10122
|
+
setup(__props, { expose: __expose, emit }) {
|
|
10123
|
+
const props = __props;
|
|
9538
10124
|
const services = {
|
|
9539
10125
|
componentListService,
|
|
9540
10126
|
eventsService,
|
|
@@ -9570,119 +10156,101 @@ const _sfc_main = defineComponent({
|
|
|
9570
10156
|
disabledDragStart: props.disabledDragStart
|
|
9571
10157
|
})
|
|
9572
10158
|
);
|
|
9573
|
-
|
|
10159
|
+
__expose(services);
|
|
10160
|
+
return (_ctx, _cache) => {
|
|
10161
|
+
return openBlock(), createBlock(_sfc_main$x, null, {
|
|
10162
|
+
header: withCtx(() => [
|
|
10163
|
+
renderSlot(_ctx.$slots, "header")
|
|
10164
|
+
]),
|
|
10165
|
+
nav: withCtx(() => [
|
|
10166
|
+
renderSlot(_ctx.$slots, "nav", { editorService: unref(editorService) }, () => [
|
|
10167
|
+
createVNode(_sfc_main$v, { data: _ctx.menu }, null, 8, ["data"])
|
|
10168
|
+
])
|
|
10169
|
+
]),
|
|
10170
|
+
"content-before": withCtx(() => [
|
|
10171
|
+
renderSlot(_ctx.$slots, "content-before")
|
|
10172
|
+
]),
|
|
10173
|
+
"src-code": withCtx(() => [
|
|
10174
|
+
renderSlot(_ctx.$slots, "src-code", { editorService: unref(editorService) })
|
|
10175
|
+
]),
|
|
10176
|
+
sidebar: withCtx(() => [
|
|
10177
|
+
renderSlot(_ctx.$slots, "sidebar", { editorService: unref(editorService) }, () => [
|
|
10178
|
+
createVNode(_sfc_main$e, {
|
|
10179
|
+
data: _ctx.sidebar,
|
|
10180
|
+
"layer-content-menu": _ctx.layerContentMenu
|
|
10181
|
+
}, {
|
|
10182
|
+
"layer-panel-header": withCtx(() => [
|
|
10183
|
+
renderSlot(_ctx.$slots, "layer-panel-header")
|
|
10184
|
+
]),
|
|
10185
|
+
"layer-node-content": withCtx(({ data }) => [
|
|
10186
|
+
renderSlot(_ctx.$slots, "layer-node-content", { data })
|
|
10187
|
+
]),
|
|
10188
|
+
"component-list-panel-header": withCtx(() => [
|
|
10189
|
+
renderSlot(_ctx.$slots, "component-list-panel-header")
|
|
10190
|
+
]),
|
|
10191
|
+
"component-list-item": withCtx(({ component }) => [
|
|
10192
|
+
renderSlot(_ctx.$slots, "component-list-item", { component })
|
|
10193
|
+
]),
|
|
10194
|
+
"code-block-panel-header": withCtx(() => [
|
|
10195
|
+
renderSlot(_ctx.$slots, "code-block-panel-header")
|
|
10196
|
+
]),
|
|
10197
|
+
"code-block-panel-tool": withCtx(({ id, data }) => [
|
|
10198
|
+
renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
10199
|
+
id,
|
|
10200
|
+
data
|
|
10201
|
+
})
|
|
10202
|
+
]),
|
|
10203
|
+
_: 3
|
|
10204
|
+
}, 8, ["data", "layer-content-menu"])
|
|
10205
|
+
])
|
|
10206
|
+
]),
|
|
10207
|
+
workspace: withCtx(() => [
|
|
10208
|
+
renderSlot(_ctx.$slots, "workspace", { editorService: unref(editorService) }, () => [
|
|
10209
|
+
createVNode(_sfc_main$1, { "stage-content-menu": _ctx.stageContentMenu }, {
|
|
10210
|
+
stage: withCtx(() => [
|
|
10211
|
+
renderSlot(_ctx.$slots, "stage")
|
|
10212
|
+
]),
|
|
10213
|
+
"workspace-content": withCtx(() => [
|
|
10214
|
+
renderSlot(_ctx.$slots, "workspace-content", { editorService: unref(editorService) })
|
|
10215
|
+
]),
|
|
10216
|
+
"page-bar-title": withCtx(({ page }) => [
|
|
10217
|
+
renderSlot(_ctx.$slots, "page-bar-title", { page })
|
|
10218
|
+
]),
|
|
10219
|
+
"page-bar-popover": withCtx(({ page }) => [
|
|
10220
|
+
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
10221
|
+
]),
|
|
10222
|
+
_: 3
|
|
10223
|
+
}, 8, ["stage-content-menu"])
|
|
10224
|
+
])
|
|
10225
|
+
]),
|
|
10226
|
+
"props-panel": withCtx(() => [
|
|
10227
|
+
renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
10228
|
+
createVNode(_sfc_main$u, {
|
|
10229
|
+
"extend-state": _ctx.extendFormState,
|
|
10230
|
+
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
10231
|
+
}, {
|
|
10232
|
+
"props-panel-header": withCtx(() => [
|
|
10233
|
+
renderSlot(_ctx.$slots, "props-panel-header")
|
|
10234
|
+
]),
|
|
10235
|
+
_: 3
|
|
10236
|
+
}, 8, ["extend-state"])
|
|
10237
|
+
])
|
|
10238
|
+
]),
|
|
10239
|
+
empty: withCtx(() => [
|
|
10240
|
+
renderSlot(_ctx.$slots, "empty", { editorService: unref(editorService) })
|
|
10241
|
+
]),
|
|
10242
|
+
"content-after": withCtx(() => [
|
|
10243
|
+
renderSlot(_ctx.$slots, "content-after")
|
|
10244
|
+
]),
|
|
10245
|
+
footer: withCtx(() => [
|
|
10246
|
+
renderSlot(_ctx.$slots, "footer")
|
|
10247
|
+
]),
|
|
10248
|
+
_: 3
|
|
10249
|
+
});
|
|
10250
|
+
};
|
|
9574
10251
|
}
|
|
9575
10252
|
});
|
|
9576
10253
|
|
|
9577
|
-
const _export_sfc = (sfc, props) => {
|
|
9578
|
-
const target = sfc.__vccOpts || sfc;
|
|
9579
|
-
for (const [key, val] of props) {
|
|
9580
|
-
target[key] = val;
|
|
9581
|
-
}
|
|
9582
|
-
return target;
|
|
9583
|
-
};
|
|
9584
|
-
|
|
9585
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
9586
|
-
const _component_TMagicNavMenu = resolveComponent("TMagicNavMenu");
|
|
9587
|
-
const _component_Sidebar = resolveComponent("Sidebar");
|
|
9588
|
-
const _component_Workspace = resolveComponent("Workspace");
|
|
9589
|
-
const _component_PropsPanel = resolveComponent("PropsPanel");
|
|
9590
|
-
const _component_Framework = resolveComponent("Framework");
|
|
9591
|
-
return openBlock(), createBlock(_component_Framework, null, {
|
|
9592
|
-
header: withCtx(() => [
|
|
9593
|
-
renderSlot(_ctx.$slots, "header")
|
|
9594
|
-
]),
|
|
9595
|
-
nav: withCtx(() => [
|
|
9596
|
-
renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
|
|
9597
|
-
createVNode(_component_TMagicNavMenu, { data: _ctx.menu }, null, 8, ["data"])
|
|
9598
|
-
])
|
|
9599
|
-
]),
|
|
9600
|
-
"content-before": withCtx(() => [
|
|
9601
|
-
renderSlot(_ctx.$slots, "content-before")
|
|
9602
|
-
]),
|
|
9603
|
-
"src-code": withCtx(() => [
|
|
9604
|
-
renderSlot(_ctx.$slots, "src-code", { editorService: _ctx.editorService })
|
|
9605
|
-
]),
|
|
9606
|
-
sidebar: withCtx(() => [
|
|
9607
|
-
renderSlot(_ctx.$slots, "sidebar", { editorService: _ctx.editorService }, () => [
|
|
9608
|
-
createVNode(_component_Sidebar, {
|
|
9609
|
-
data: _ctx.sidebar,
|
|
9610
|
-
"layer-content-menu": _ctx.layerContentMenu
|
|
9611
|
-
}, {
|
|
9612
|
-
"layer-panel-header": withCtx(() => [
|
|
9613
|
-
renderSlot(_ctx.$slots, "layer-panel-header")
|
|
9614
|
-
]),
|
|
9615
|
-
"layer-node-content": withCtx(({ node, data }) => [
|
|
9616
|
-
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
9617
|
-
data,
|
|
9618
|
-
node
|
|
9619
|
-
})
|
|
9620
|
-
]),
|
|
9621
|
-
"component-list-panel-header": withCtx(() => [
|
|
9622
|
-
renderSlot(_ctx.$slots, "component-list-panel-header")
|
|
9623
|
-
]),
|
|
9624
|
-
"component-list-item": withCtx(({ component }) => [
|
|
9625
|
-
renderSlot(_ctx.$slots, "component-list-item", { component })
|
|
9626
|
-
]),
|
|
9627
|
-
"code-block-panel-header": withCtx(() => [
|
|
9628
|
-
renderSlot(_ctx.$slots, "code-block-panel-header")
|
|
9629
|
-
]),
|
|
9630
|
-
"code-block-panel-tool": withCtx(({ id, data }) => [
|
|
9631
|
-
renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
9632
|
-
id,
|
|
9633
|
-
data
|
|
9634
|
-
})
|
|
9635
|
-
]),
|
|
9636
|
-
_: 3
|
|
9637
|
-
}, 8, ["data", "layer-content-menu"])
|
|
9638
|
-
])
|
|
9639
|
-
]),
|
|
9640
|
-
workspace: withCtx(() => [
|
|
9641
|
-
renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
9642
|
-
createVNode(_component_Workspace, { "stage-content-menu": _ctx.stageContentMenu }, {
|
|
9643
|
-
stage: withCtx(() => [
|
|
9644
|
-
renderSlot(_ctx.$slots, "stage")
|
|
9645
|
-
]),
|
|
9646
|
-
"workspace-content": withCtx(() => [
|
|
9647
|
-
renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
|
|
9648
|
-
]),
|
|
9649
|
-
"page-bar-title": withCtx(({ page }) => [
|
|
9650
|
-
renderSlot(_ctx.$slots, "page-bar-title", { page })
|
|
9651
|
-
]),
|
|
9652
|
-
"page-bar-popover": withCtx(({ page }) => [
|
|
9653
|
-
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
9654
|
-
]),
|
|
9655
|
-
_: 3
|
|
9656
|
-
}, 8, ["stage-content-menu"])
|
|
9657
|
-
])
|
|
9658
|
-
]),
|
|
9659
|
-
"props-panel": withCtx(() => [
|
|
9660
|
-
renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
9661
|
-
createVNode(_component_PropsPanel, {
|
|
9662
|
-
"extend-state": _ctx.extendFormState,
|
|
9663
|
-
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
9664
|
-
}, {
|
|
9665
|
-
"props-panel-header": withCtx(() => [
|
|
9666
|
-
renderSlot(_ctx.$slots, "props-panel-header")
|
|
9667
|
-
]),
|
|
9668
|
-
_: 3
|
|
9669
|
-
}, 8, ["extend-state"])
|
|
9670
|
-
])
|
|
9671
|
-
]),
|
|
9672
|
-
empty: withCtx(() => [
|
|
9673
|
-
renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
|
|
9674
|
-
]),
|
|
9675
|
-
"content-after": withCtx(() => [
|
|
9676
|
-
renderSlot(_ctx.$slots, "content-after")
|
|
9677
|
-
]),
|
|
9678
|
-
footer: withCtx(() => [
|
|
9679
|
-
renderSlot(_ctx.$slots, "footer")
|
|
9680
|
-
]),
|
|
9681
|
-
_: 3
|
|
9682
|
-
});
|
|
9683
|
-
}
|
|
9684
|
-
const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
9685
|
-
|
|
9686
10254
|
const index$1 = '';
|
|
9687
10255
|
|
|
9688
10256
|
const defaultInstallOpt = {
|
|
@@ -9694,23 +10262,24 @@ const index = {
|
|
|
9694
10262
|
const option = Object.assign(defaultInstallOpt, opt || {});
|
|
9695
10263
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
9696
10264
|
setConfig(option);
|
|
9697
|
-
app.component(
|
|
9698
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
9699
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
9700
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
9701
|
-
app.component("magic-code-editor", _sfc_main$
|
|
9702
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
9703
|
-
app.component("m-fields-code-select-col", _sfc_main$
|
|
9704
|
-
app.component("m-fields-event-select", _sfc_main$
|
|
9705
|
-
app.component("m-fields-data-source-fields", _sfc_main$
|
|
9706
|
-
app.component("m-fields-
|
|
9707
|
-
app.component("m-fields-
|
|
9708
|
-
app.component("m-fields-data-source-
|
|
9709
|
-
app.component("m-fields-data-source-
|
|
9710
|
-
app.component("m-fields-data-source-
|
|
9711
|
-
app.component("m-fields-data-source-
|
|
10265
|
+
app.component(_sfc_main.name, _sfc_main);
|
|
10266
|
+
app.component("m-fields-ui-select", _sfc_main$B);
|
|
10267
|
+
app.component("m-fields-code-link", _sfc_main$Q);
|
|
10268
|
+
app.component("m-fields-vs-code", _sfc_main$R);
|
|
10269
|
+
app.component("magic-code-editor", _sfc_main$S);
|
|
10270
|
+
app.component("m-fields-code-select", _sfc_main$P);
|
|
10271
|
+
app.component("m-fields-code-select-col", _sfc_main$L);
|
|
10272
|
+
app.component("m-fields-event-select", _sfc_main$D);
|
|
10273
|
+
app.component("m-fields-data-source-fields", _sfc_main$K);
|
|
10274
|
+
app.component("m-fields-data-source-mocks", _sfc_main$F);
|
|
10275
|
+
app.component("m-fields-key-value", _sfc_main$C);
|
|
10276
|
+
app.component("m-fields-data-source-input", _sfc_main$I);
|
|
10277
|
+
app.component("m-fields-data-source-select", _sfc_main$E);
|
|
10278
|
+
app.component("m-fields-data-source-methods", _sfc_main$H);
|
|
10279
|
+
app.component("m-fields-data-source-method-select", _sfc_main$G);
|
|
10280
|
+
app.component("m-fields-data-source-field-select", _sfc_main$J);
|
|
9712
10281
|
}
|
|
9713
10282
|
};
|
|
9714
10283
|
|
|
9715
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$
|
|
10284
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$O as CodeBlockEditor, _sfc_main$q as CodeBlockList, _sfc_main$p as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$P as CodeSelect, _sfc_main$L as CodeSelectCol, ColumnLayout, _sfc_main$f as ComponentListPanel, _sfc_main$l as ContentMenu, _sfc_main$J as DataSourceFieldSelect, _sfc_main$K as DataSourceFields, _sfc_main$I as DataSourceInput, _sfc_main$G as DataSourceMethodSelect, _sfc_main$H as DataSourceMethods, _sfc_main$F as DataSourceMocks, _sfc_main$E as DataSourceSelect, DepTargetType, DragType, _sfc_main$D as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$M as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$g as LayerPanel, Layout, _sfc_main$z as LayoutContainer, _sfc_main$u as PropsPanel, _sfc_main$A as Resizer, _sfc_main$z as SplitView, _sfc_main$S as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$w as ToolButton, 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, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useStage, warn };
|
|
9716
10285
|
//# sourceMappingURL=tmagic-editor.js.map
|