@tmagic/editor 1.1.6 → 1.2.0-beta.10
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 +191 -8
- package/dist/tmagic-editor.mjs +2104 -1027
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +2136 -1053
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +11 -10
- package/src/Editor.vue +27 -12
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +7 -5
- package/src/{layouts → components}/Layout.vue +15 -5
- package/src/components/ScrollBar.vue +1 -1
- package/src/components/ScrollViewer.vue +10 -1
- package/src/components/ToolButton.vue +30 -15
- package/src/fields/Code.vue +5 -2
- package/src/fields/CodeLink.vue +20 -12
- package/src/fields/CodeSelect.vue +131 -0
- package/src/fields/UISelect.vue +9 -8
- package/src/index.ts +7 -2
- package/src/layouts/AddPageBox.vue +13 -20
- package/src/layouts/CodeEditor.vue +106 -120
- package/src/layouts/Framework.vue +62 -40
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/PropsPanel.vue +5 -10
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +15 -13
- package/src/layouts/sidebar/LayerMenu.vue +89 -92
- package/src/layouts/sidebar/LayerPanel.vue +273 -178
- package/src/layouts/sidebar/Sidebar.vue +129 -37
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +169 -0
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +267 -0
- package/src/layouts/workspace/Breadcrumb.vue +32 -0
- package/src/layouts/workspace/PageBar.vue +12 -11
- package/src/layouts/workspace/PageBarScrollContainer.vue +1 -1
- package/src/layouts/workspace/Stage.vue +15 -7
- package/src/layouts/workspace/ViewerMenu.vue +8 -7
- package/src/layouts/workspace/Workspace.vue +10 -3
- package/src/services/codeBlock.ts +415 -0
- package/src/services/editor.ts +35 -5
- package/src/theme/breadcrumb.scss +6 -0
- package/src/theme/code-block.scss +184 -0
- package/src/theme/component-list-panel.scss +3 -7
- package/src/theme/index.scss +1 -13
- package/src/theme/layer-panel.scss +7 -2
- package/src/theme/layout.scss +5 -0
- package/src/theme/theme.scss +16 -0
- package/src/type.ts +88 -1
- package/src/utils/props.ts +9 -3
- package/src/utils/scroll-viewer.ts +18 -2
- package/src/utils/stage.ts +7 -0
- package/types/Editor.vue.d.ts +2 -2
- package/types/components/ContentMenu.vue.d.ts +1 -3
- package/types/components/Icon.vue.d.ts +1 -3
- package/types/{layouts → components}/Layout.vue.d.ts +0 -0
- package/types/components/ScrollBar.vue.d.ts +1 -3
- package/types/components/ScrollViewer.vue.d.ts +45 -1
- package/types/components/ToolButton.vue.d.ts +1 -3
- package/types/fields/Code.vue.d.ts +9 -3
- package/types/fields/CodeLink.vue.d.ts +5 -3
- package/types/fields/CodeSelect.vue.d.ts +94 -0
- package/types/fields/UISelect.vue.d.ts +1 -3
- package/types/index.d.ts +4 -0
- package/types/layouts/AddPageBox.vue.d.ts +43 -3
- package/types/layouts/CodeEditor.vue.d.ts +158 -45
- package/types/layouts/NavMenu.vue.d.ts +1 -3
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +31 -63
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +38 -1074
- package/types/layouts/sidebar/Sidebar.vue.d.ts +119 -17
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +50 -0
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +73 -0
- package/types/layouts/workspace/Breadcrumb.vue.d.ts +44 -0
- package/types/layouts/workspace/Stage.vue.d.ts +23 -7
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +6 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
- package/types/services/codeBlock.d.ts +155 -0
- package/types/services/editor.d.ts +12 -1
- package/types/services/props.d.ts +12 -0
- package/types/services/ui.d.ts +1 -1
- package/types/type.d.ts +78 -1
- package/types/utils/props.d.ts +12 -0
- package/types/utils/scroll-viewer.d.ts +5 -0
- package/src/layouts/sidebar/TabPane.vue +0 -99
- package/types/layouts/sidebar/TabPane.vue.d.ts +0 -14
package/dist/tmagic-editor.mjs
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, ref, createElementBlock, createVNode, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, ref, watchEffect, createElementBlock, createVNode, withCtx, createElementVNode, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted, renderSlot, Fragment, normalizeClass, resolveDynamicComponent, toRaw, createSlots, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, isRef, withDirectives, Teleport, vShow, nextTick, toHandlers, provide } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { map, xor, throttle, pick, cloneDeep, isEmpty, forIn, omit, keys, mergeWith, uniq } from 'lodash-es';
|
|
4
|
+
import { TMagicCard, TMagicTooltip, tMagicMessage, TMagicButton, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicDialog, TMagicInput, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicTabs, TMagicPopover } from '@tmagic/design';
|
|
5
|
+
import { Delete, Close, Edit, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, View, Link, Search, Files, DocumentCopy, Coin, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
|
|
5
6
|
import * as monaco from 'monaco-editor';
|
|
6
7
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
|
|
8
|
+
import Gesto from 'gesto';
|
|
7
9
|
import { NodeType } from '@tmagic/schema';
|
|
8
10
|
import { isPop, getNodePath, isNumber, isPage, toLine, removeClassNameByClassName } from '@tmagic/utils';
|
|
9
11
|
import { EventEmitter } from 'events';
|
|
10
12
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
11
|
-
import Gesto from 'gesto';
|
|
12
|
-
import { ElMessage } from 'element-plus';
|
|
13
13
|
import KeyController from 'keycon';
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const __default__$r = defineComponent({
|
|
16
|
+
name: "MEditorCode"
|
|
17
|
+
});
|
|
18
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
19
|
+
...__default__$r,
|
|
17
20
|
props: {
|
|
18
21
|
model: null,
|
|
19
22
|
name: null,
|
|
@@ -24,7 +27,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
24
27
|
setup(__props, { emit }) {
|
|
25
28
|
const props = __props;
|
|
26
29
|
const language = computed(() => props.config.language || "javascript");
|
|
27
|
-
const height = computed(() => `${document.body.clientHeight - 168}px`);
|
|
30
|
+
const height = computed(() => props.config.height || `${document.body.clientHeight - 168}px`);
|
|
28
31
|
const save = (v) => {
|
|
29
32
|
props.model[props.name] = v;
|
|
30
33
|
emit("change", v);
|
|
@@ -35,14 +38,18 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
35
38
|
style: normalizeStyle(`height: ${unref(height)}`),
|
|
36
39
|
"init-values": __props.model[__props.name],
|
|
37
40
|
language: unref(language),
|
|
41
|
+
options: __props.config.options,
|
|
38
42
|
onSave: save
|
|
39
|
-
}, null, 8, ["style", "init-values", "language"]);
|
|
43
|
+
}, null, 8, ["style", "init-values", "language", "options"]);
|
|
40
44
|
};
|
|
41
45
|
}
|
|
42
46
|
});
|
|
43
47
|
|
|
44
|
-
const
|
|
45
|
-
|
|
48
|
+
const __default__$q = defineComponent({
|
|
49
|
+
name: "MEditorCodeLink"
|
|
50
|
+
});
|
|
51
|
+
const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
52
|
+
...__default__$q,
|
|
46
53
|
props: {
|
|
47
54
|
config: null,
|
|
48
55
|
model: null,
|
|
@@ -52,17 +59,24 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
52
59
|
emits: ["change"],
|
|
53
60
|
setup(__props, { emit }) {
|
|
54
61
|
const props = __props;
|
|
55
|
-
const formConfig = computed(() =>
|
|
56
|
-
...props.config
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
const formConfig = computed(() => {
|
|
63
|
+
const { codeOptions, ...config } = props.config;
|
|
64
|
+
return {
|
|
65
|
+
...config,
|
|
66
|
+
text: "",
|
|
67
|
+
type: "link",
|
|
68
|
+
form: [
|
|
69
|
+
{
|
|
70
|
+
name: props.name,
|
|
71
|
+
type: "vs-code",
|
|
72
|
+
options: {
|
|
73
|
+
tabSize: 2,
|
|
74
|
+
...codeOptions || {}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
};
|
|
79
|
+
});
|
|
66
80
|
const modelValue = reactive({
|
|
67
81
|
form: {
|
|
68
82
|
[props.name]: ""
|
|
@@ -104,9 +118,187 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
104
118
|
}
|
|
105
119
|
});
|
|
106
120
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
121
|
+
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
122
|
+
ColumnLayout2["LEFT"] = "left";
|
|
123
|
+
ColumnLayout2["CENTER"] = "center";
|
|
124
|
+
ColumnLayout2["RIGHT"] = "right";
|
|
125
|
+
return ColumnLayout2;
|
|
126
|
+
})(ColumnLayout || {});
|
|
127
|
+
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
128
|
+
LayerOffset2["TOP"] = "top";
|
|
129
|
+
LayerOffset2["BOTTOM"] = "bottom";
|
|
130
|
+
return LayerOffset2;
|
|
131
|
+
})(LayerOffset || {});
|
|
132
|
+
var Layout = /* @__PURE__ */ ((Layout2) => {
|
|
133
|
+
Layout2["FLEX"] = "flex";
|
|
134
|
+
Layout2["FIXED"] = "fixed";
|
|
135
|
+
Layout2["RELATIVE"] = "relative";
|
|
136
|
+
Layout2["ABSOLUTE"] = "absolute";
|
|
137
|
+
return Layout2;
|
|
138
|
+
})(Layout || {});
|
|
139
|
+
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
140
|
+
Keys2["ESCAPE"] = "Space";
|
|
141
|
+
return Keys2;
|
|
142
|
+
})(Keys || {});
|
|
143
|
+
const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
144
|
+
const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
145
|
+
var CodeEditorMode = /* @__PURE__ */ ((CodeEditorMode2) => {
|
|
146
|
+
CodeEditorMode2["LIST"] = "list";
|
|
147
|
+
CodeEditorMode2["EDITOR"] = "editor";
|
|
148
|
+
return CodeEditorMode2;
|
|
149
|
+
})(CodeEditorMode || {});
|
|
150
|
+
var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
|
|
151
|
+
CodeDeleteErrorType2["UNDELETEABLE"] = "undeleteable";
|
|
152
|
+
CodeDeleteErrorType2["BIND"] = "bind";
|
|
153
|
+
return CodeDeleteErrorType2;
|
|
154
|
+
})(CodeDeleteErrorType || {});
|
|
155
|
+
var CodeSelectOp = /* @__PURE__ */ ((CodeSelectOp2) => {
|
|
156
|
+
CodeSelectOp2["ADD"] = "add";
|
|
157
|
+
CodeSelectOp2["DELETE"] = "delete";
|
|
158
|
+
CodeSelectOp2["CHANGE"] = "change";
|
|
159
|
+
return CodeSelectOp2;
|
|
160
|
+
})(CodeSelectOp || {});
|
|
161
|
+
|
|
162
|
+
const _hoisted_1$e = { class: "tool-bar" };
|
|
163
|
+
const _hoisted_2$6 = /* @__PURE__ */ createElementVNode("path", {
|
|
164
|
+
fill: "currentColor",
|
|
165
|
+
d: "m23 12l-7.071 7.071l-1.414-1.414L20.172 12l-5.657-5.657l1.414-1.414L23 12zM3.828 12l5.657 5.657l-1.414 1.414L1 12l7.071-7.071l1.414 1.414L3.828 12z"
|
|
166
|
+
}, null, -1);
|
|
167
|
+
const _hoisted_3$3 = [
|
|
168
|
+
_hoisted_2$6
|
|
169
|
+
];
|
|
170
|
+
const __default__$p = defineComponent({
|
|
171
|
+
name: "MEditorCodeSelect"
|
|
172
|
+
});
|
|
173
|
+
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
174
|
+
...__default__$p,
|
|
175
|
+
props: {
|
|
176
|
+
config: null,
|
|
177
|
+
model: null,
|
|
178
|
+
prop: null,
|
|
179
|
+
name: null,
|
|
180
|
+
size: null
|
|
181
|
+
},
|
|
182
|
+
emits: ["change"],
|
|
183
|
+
setup(__props, { emit }) {
|
|
184
|
+
const props = __props;
|
|
185
|
+
const services = inject("services");
|
|
186
|
+
const form = inject("mForm");
|
|
187
|
+
const selectConfig = computed(() => {
|
|
188
|
+
const defaultConfig = {
|
|
189
|
+
multiple: true,
|
|
190
|
+
options: async () => {
|
|
191
|
+
const codeDsl = await services?.codeBlockService.getCodeDsl();
|
|
192
|
+
if (codeDsl) {
|
|
193
|
+
return map(codeDsl, (value, key) => ({
|
|
194
|
+
text: `${value.name}\uFF08${key}\uFF09`,
|
|
195
|
+
label: `${value.name}\uFF08${key}\uFF09`,
|
|
196
|
+
value: key
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
return {
|
|
203
|
+
...defaultConfig,
|
|
204
|
+
...props.config.selectConfig
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
const fieldKey = ref("");
|
|
208
|
+
const multiple = ref(true);
|
|
209
|
+
const lastTagSnapshot = ref([]);
|
|
210
|
+
watchEffect(async () => {
|
|
211
|
+
if (!props.model[props.name])
|
|
212
|
+
return;
|
|
213
|
+
const combineNames = await Promise.all(
|
|
214
|
+
props.model[props.name].map(async (id) => {
|
|
215
|
+
const { name = "" } = await services?.codeBlockService.getCodeContentById(id) || {};
|
|
216
|
+
return name;
|
|
217
|
+
})
|
|
218
|
+
);
|
|
219
|
+
fieldKey.value = combineNames.join("-");
|
|
220
|
+
});
|
|
221
|
+
const changeHandler = async (value) => {
|
|
222
|
+
let codeIds = value;
|
|
223
|
+
if (typeof value === "string") {
|
|
224
|
+
multiple.value = false;
|
|
225
|
+
codeIds = value ? [value] : [];
|
|
226
|
+
}
|
|
227
|
+
await setCombineRelation(codeIds);
|
|
228
|
+
emit("change", value);
|
|
229
|
+
};
|
|
230
|
+
const setCombineRelation = async (codeIds) => {
|
|
231
|
+
const { id = "" } = services?.editorService.get("node") || {};
|
|
232
|
+
let opFlag = CodeSelectOp.CHANGE;
|
|
233
|
+
let diffValues = codeIds;
|
|
234
|
+
if (multiple.value) {
|
|
235
|
+
lastTagSnapshot.value = form?.initValues[props.name] || [];
|
|
236
|
+
opFlag = codeIds.length < lastTagSnapshot.value.length ? CodeSelectOp.DELETE : CodeSelectOp.ADD;
|
|
237
|
+
diffValues = xor(codeIds, lastTagSnapshot.value);
|
|
238
|
+
}
|
|
239
|
+
await services?.codeBlockService.setCombineRelation(id, diffValues, opFlag, props.prop);
|
|
240
|
+
};
|
|
241
|
+
const viewHandler = async () => {
|
|
242
|
+
if (props.model[props.name].length === 0) {
|
|
243
|
+
tMagicMessage.error("\u8BF7\u5148\u7ED1\u5B9A\u4EE3\u7801\u5757");
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
await services?.codeBlockService.setCombineIds(props.model[props.name]);
|
|
247
|
+
await services?.codeBlockService.setMode(CodeEditorMode.LIST);
|
|
248
|
+
services?.codeBlockService.setCodeEditorContent(true, props.model[props.name][0]);
|
|
249
|
+
};
|
|
250
|
+
return (_ctx, _cache) => {
|
|
251
|
+
const _component_m_fields_select = resolveComponent("m-fields-select");
|
|
252
|
+
return openBlock(), createElementBlock("div", {
|
|
253
|
+
class: "m-fields-code-select",
|
|
254
|
+
key: fieldKey.value
|
|
255
|
+
}, [
|
|
256
|
+
createVNode(unref(TMagicCard), { shadow: "never" }, {
|
|
257
|
+
header: withCtx(() => [
|
|
258
|
+
createVNode(_component_m_fields_select, {
|
|
259
|
+
config: unref(selectConfig),
|
|
260
|
+
model: __props.model,
|
|
261
|
+
prop: __props.prop,
|
|
262
|
+
name: __props.name,
|
|
263
|
+
size: __props.size,
|
|
264
|
+
onChange: changeHandler
|
|
265
|
+
}, null, 8, ["config", "model", "prop", "name", "size"])
|
|
266
|
+
]),
|
|
267
|
+
default: withCtx(() => [
|
|
268
|
+
createElementVNode("div", _hoisted_1$e, [
|
|
269
|
+
createVNode(unref(TMagicTooltip), {
|
|
270
|
+
class: "tool-item",
|
|
271
|
+
effect: "dark",
|
|
272
|
+
content: "\u67E5\u770B\u4EE3\u7801\u5757",
|
|
273
|
+
placement: "top"
|
|
274
|
+
}, {
|
|
275
|
+
default: withCtx(() => [
|
|
276
|
+
(openBlock(), createElementBlock("svg", {
|
|
277
|
+
onClick: viewHandler,
|
|
278
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
279
|
+
viewBox: "0 0 24 24",
|
|
280
|
+
width: "15px",
|
|
281
|
+
height: "15px",
|
|
282
|
+
"data-v-65a7fb6c": ""
|
|
283
|
+
}, _hoisted_3$3))
|
|
284
|
+
]),
|
|
285
|
+
_: 1
|
|
286
|
+
})
|
|
287
|
+
])
|
|
288
|
+
]),
|
|
289
|
+
_: 1
|
|
290
|
+
})
|
|
291
|
+
]);
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const _hoisted_1$d = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
|
|
297
|
+
const __default__$o = defineComponent({
|
|
298
|
+
name: "MEditorUISelect"
|
|
299
|
+
});
|
|
300
|
+
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
301
|
+
...__default__$o,
|
|
110
302
|
props: {
|
|
111
303
|
config: null,
|
|
112
304
|
model: null,
|
|
@@ -156,21 +348,19 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
156
348
|
}
|
|
157
349
|
};
|
|
158
350
|
return (_ctx, _cache) => {
|
|
159
|
-
const _component_el_button = resolveComponent("el-button");
|
|
160
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
161
351
|
return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
|
|
162
352
|
key: 0,
|
|
163
353
|
class: "m-fields-ui-select",
|
|
164
354
|
onClick: cancelHandler
|
|
165
355
|
}, [
|
|
166
|
-
createVNode(
|
|
356
|
+
createVNode(unref(TMagicButton), {
|
|
167
357
|
type: "danger",
|
|
168
358
|
icon: unref(Delete),
|
|
169
359
|
text: "",
|
|
170
360
|
style: { "padding": "0" }
|
|
171
361
|
}, {
|
|
172
362
|
default: withCtx(() => [
|
|
173
|
-
_hoisted_1$
|
|
363
|
+
_hoisted_1$d
|
|
174
364
|
]),
|
|
175
365
|
_: 1
|
|
176
366
|
}, 8, ["icon"])
|
|
@@ -180,12 +370,12 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
180
370
|
onClick: startSelect,
|
|
181
371
|
style: { "display": "flex" }
|
|
182
372
|
}, [
|
|
183
|
-
unref(val) ? (openBlock(), createBlock(
|
|
373
|
+
unref(val) ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
184
374
|
key: 0,
|
|
185
375
|
content: "\u6E05\u9664"
|
|
186
376
|
}, {
|
|
187
377
|
default: withCtx(() => [
|
|
188
|
-
createVNode(
|
|
378
|
+
createVNode(unref(TMagicButton), {
|
|
189
379
|
style: { "padding": "0" },
|
|
190
380
|
type: "danger",
|
|
191
381
|
icon: unref(Close),
|
|
@@ -195,11 +385,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
195
385
|
]),
|
|
196
386
|
_: 1
|
|
197
387
|
})) : createCommentVNode("", true),
|
|
198
|
-
createVNode(
|
|
388
|
+
createVNode(unref(TMagicTooltip), {
|
|
199
389
|
content: unref(val) ? unref(toName) + "_" + unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
|
|
200
390
|
}, {
|
|
201
391
|
default: withCtx(() => [
|
|
202
|
-
createVNode(
|
|
392
|
+
createVNode(unref(TMagicButton), {
|
|
203
393
|
text: "",
|
|
204
394
|
style: { "padding": "0", "margin": "0" }
|
|
205
395
|
}, {
|
|
@@ -218,45 +408,39 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
218
408
|
|
|
219
409
|
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
220
410
|
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
unsafe: true
|
|
227
|
-
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
228
|
-
} else {
|
|
229
|
-
value = v;
|
|
230
|
-
}
|
|
231
|
-
if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
|
|
232
|
-
value = `(${value})`;
|
|
233
|
-
}
|
|
234
|
-
return value;
|
|
235
|
-
};
|
|
236
|
-
const _sfc_main$m = defineComponent({
|
|
237
|
-
name: "magic-code-editor",
|
|
411
|
+
const __default__$n = defineComponent({
|
|
412
|
+
name: "MEditorCodeEditor"
|
|
413
|
+
});
|
|
414
|
+
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
415
|
+
...__default__$n,
|
|
238
416
|
props: {
|
|
239
|
-
initValues:
|
|
240
|
-
|
|
241
|
-
},
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
default: () => ""
|
|
248
|
-
},
|
|
249
|
-
language: {
|
|
250
|
-
type: String,
|
|
251
|
-
default: () => "javascript"
|
|
252
|
-
},
|
|
253
|
-
options: {
|
|
254
|
-
type: Object,
|
|
255
|
-
default: () => ({})
|
|
256
|
-
}
|
|
417
|
+
initValues: null,
|
|
418
|
+
modifiedValues: null,
|
|
419
|
+
type: { default: "" },
|
|
420
|
+
language: { default: "javascript" },
|
|
421
|
+
options: { default: () => ({
|
|
422
|
+
tabSize: 2
|
|
423
|
+
}) },
|
|
424
|
+
autoSave: { type: Boolean, default: true }
|
|
257
425
|
},
|
|
258
426
|
emits: ["initd", "save"],
|
|
259
|
-
setup(
|
|
427
|
+
setup(__props, { expose, emit }) {
|
|
428
|
+
const props = __props;
|
|
429
|
+
const toString = (v, language) => {
|
|
430
|
+
let value = "";
|
|
431
|
+
if (typeof v !== "string") {
|
|
432
|
+
value = serialize(v, {
|
|
433
|
+
space: 2,
|
|
434
|
+
unsafe: true
|
|
435
|
+
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
436
|
+
} else {
|
|
437
|
+
value = v;
|
|
438
|
+
}
|
|
439
|
+
if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
|
|
440
|
+
value = `(${value})`;
|
|
441
|
+
}
|
|
442
|
+
return value;
|
|
443
|
+
};
|
|
260
444
|
let vsEditor = null;
|
|
261
445
|
let vsDiffEditor = null;
|
|
262
446
|
const values = ref("");
|
|
@@ -305,7 +489,7 @@ const _sfc_main$m = defineComponent({
|
|
|
305
489
|
emit("save", getEditorValue());
|
|
306
490
|
}
|
|
307
491
|
});
|
|
308
|
-
if (props.type !== "diff") {
|
|
492
|
+
if (props.type !== "diff" && props.autoSave) {
|
|
309
493
|
vsEditor?.onDidBlurEditorWidget(() => {
|
|
310
494
|
emit("save", getEditorValue());
|
|
311
495
|
});
|
|
@@ -331,10 +515,7 @@ const _sfc_main$m = defineComponent({
|
|
|
331
515
|
onUnmounted(() => {
|
|
332
516
|
resizeObserver.disconnect();
|
|
333
517
|
});
|
|
334
|
-
|
|
335
|
-
values,
|
|
336
|
-
loading,
|
|
337
|
-
codeEditor,
|
|
518
|
+
expose({
|
|
338
519
|
getEditor() {
|
|
339
520
|
return vsEditor || vsDiffEditor;
|
|
340
521
|
},
|
|
@@ -343,102 +524,255 @@ const _sfc_main$m = defineComponent({
|
|
|
343
524
|
vsEditor?.focus();
|
|
344
525
|
vsDiffEditor?.focus();
|
|
345
526
|
}
|
|
527
|
+
});
|
|
528
|
+
return (_ctx, _cache) => {
|
|
529
|
+
return openBlock(), createElementBlock("div", {
|
|
530
|
+
ref_key: "codeEditor",
|
|
531
|
+
ref: codeEditor,
|
|
532
|
+
class: "magic-code-editor"
|
|
533
|
+
}, null, 512);
|
|
346
534
|
};
|
|
347
535
|
}
|
|
348
536
|
});
|
|
349
537
|
|
|
350
|
-
const _export_sfc = (sfc, props) => {
|
|
351
|
-
const target = sfc.__vccOpts || sfc;
|
|
352
|
-
for (const [key, val] of props) {
|
|
353
|
-
target[key] = val;
|
|
354
|
-
}
|
|
355
|
-
return target;
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
const _hoisted_1$a = {
|
|
359
|
-
ref: "codeEditor",
|
|
360
|
-
class: "magic-code-editor"
|
|
361
|
-
};
|
|
362
|
-
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
363
|
-
return openBlock(), createElementBlock("div", _hoisted_1$a, null, 512);
|
|
364
|
-
}
|
|
365
|
-
const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$6]]);
|
|
366
|
-
|
|
367
538
|
let $TMAGIC_EDITOR = {};
|
|
368
539
|
const setConfig = (option) => {
|
|
369
540
|
$TMAGIC_EDITOR = option;
|
|
370
541
|
};
|
|
371
542
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
372
543
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
408
|
-
this.listCursor += 1;
|
|
409
|
-
return this.getCurrentElement();
|
|
410
|
-
}
|
|
411
|
-
getCurrentElement() {
|
|
412
|
-
if (this.listCursor < 1) {
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
|
-
return cloneDeep(this.elementList[this.listCursor - 1]);
|
|
544
|
+
const __default__$m = defineComponent({
|
|
545
|
+
name: "MEditorResizer"
|
|
546
|
+
});
|
|
547
|
+
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
548
|
+
...__default__$m,
|
|
549
|
+
emits: ["change"],
|
|
550
|
+
setup(__props, { emit }) {
|
|
551
|
+
const target = ref();
|
|
552
|
+
let getso;
|
|
553
|
+
onMounted(() => {
|
|
554
|
+
if (!target.value)
|
|
555
|
+
return;
|
|
556
|
+
getso = new Gesto(target.value, {
|
|
557
|
+
container: window,
|
|
558
|
+
pinchOutside: true
|
|
559
|
+
}).on("drag", (e) => {
|
|
560
|
+
if (!target.value)
|
|
561
|
+
return;
|
|
562
|
+
emit("change", e.deltaX);
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
onUnmounted(() => {
|
|
566
|
+
getso?.unset();
|
|
567
|
+
});
|
|
568
|
+
return (_ctx, _cache) => {
|
|
569
|
+
return openBlock(), createElementBlock("span", {
|
|
570
|
+
ref_key: "target",
|
|
571
|
+
ref: target,
|
|
572
|
+
class: "m-editor-resizer"
|
|
573
|
+
}, [
|
|
574
|
+
renderSlot(_ctx.$slots, "default")
|
|
575
|
+
], 512);
|
|
576
|
+
};
|
|
416
577
|
}
|
|
417
|
-
}
|
|
578
|
+
});
|
|
418
579
|
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
580
|
+
const __default__$l = defineComponent({
|
|
581
|
+
name: "MEditorLayout"
|
|
582
|
+
});
|
|
583
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
584
|
+
...__default__$l,
|
|
585
|
+
props: {
|
|
586
|
+
left: null,
|
|
587
|
+
right: null,
|
|
588
|
+
minLeft: { default: 1 },
|
|
589
|
+
minRight: { default: 1 },
|
|
590
|
+
leftClass: null,
|
|
591
|
+
rightClass: null,
|
|
592
|
+
centerClass: null
|
|
593
|
+
},
|
|
594
|
+
emits: ["update:left", "change", "update:right"],
|
|
595
|
+
setup(__props, { emit }) {
|
|
596
|
+
const props = __props;
|
|
597
|
+
const el = ref();
|
|
598
|
+
let clientWidth = 0;
|
|
599
|
+
const resizerObserver = new ResizeObserver((entries) => {
|
|
600
|
+
for (const { contentRect } of entries) {
|
|
601
|
+
clientWidth = contentRect.width;
|
|
602
|
+
center.value = clientWidth - (props.left || 0) - (props.right || 0);
|
|
603
|
+
emit("change", {
|
|
604
|
+
left: props.left,
|
|
605
|
+
center: center.value,
|
|
606
|
+
right: props.right
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
onMounted(() => {
|
|
611
|
+
if (el.value) {
|
|
612
|
+
resizerObserver.observe(el.value);
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
onUnmounted(() => {
|
|
616
|
+
resizerObserver.disconnect();
|
|
617
|
+
});
|
|
618
|
+
const center = ref(0);
|
|
619
|
+
const changeLeft = (deltaX) => {
|
|
620
|
+
if (typeof props.left === "undefined")
|
|
621
|
+
return;
|
|
622
|
+
let left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
623
|
+
emit("update:left", left);
|
|
624
|
+
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
625
|
+
left = props.left;
|
|
626
|
+
}
|
|
627
|
+
center.value = clientWidth - left - (props.right || 0);
|
|
628
|
+
emit("change", {
|
|
629
|
+
left,
|
|
630
|
+
center: center.value,
|
|
631
|
+
right: props.right
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
const changeRight = (deltaX) => {
|
|
635
|
+
if (typeof props.right === "undefined")
|
|
636
|
+
return;
|
|
637
|
+
let right = Math.max(props.right - deltaX, props.minRight) || 0;
|
|
638
|
+
emit("update:right", right);
|
|
639
|
+
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
640
|
+
right = props.right;
|
|
641
|
+
}
|
|
642
|
+
center.value = clientWidth - (props.left || 0) - right;
|
|
643
|
+
emit("change", {
|
|
644
|
+
left: props.left,
|
|
645
|
+
center: center.value,
|
|
646
|
+
right
|
|
647
|
+
});
|
|
648
|
+
};
|
|
649
|
+
return (_ctx, _cache) => {
|
|
650
|
+
return openBlock(), createElementBlock("div", {
|
|
651
|
+
ref_key: "el",
|
|
652
|
+
ref: el,
|
|
653
|
+
class: "m-editor-layout"
|
|
654
|
+
}, [
|
|
655
|
+
typeof props.left !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
656
|
+
createElementVNode("div", {
|
|
657
|
+
class: normalizeClass(["m-editor-layout-left", __props.leftClass]),
|
|
658
|
+
style: normalizeStyle(`width: ${__props.left}px`)
|
|
659
|
+
}, [
|
|
660
|
+
renderSlot(_ctx.$slots, "left")
|
|
661
|
+
], 6),
|
|
662
|
+
createVNode(_sfc_main$n, { onChange: changeLeft })
|
|
663
|
+
], 64)) : createCommentVNode("", true),
|
|
664
|
+
createElementVNode("div", {
|
|
665
|
+
class: normalizeClass(["m-editor-layout-center", __props.centerClass]),
|
|
666
|
+
style: normalizeStyle(`width: ${center.value}px`)
|
|
667
|
+
}, [
|
|
668
|
+
renderSlot(_ctx.$slots, "center")
|
|
669
|
+
], 6),
|
|
670
|
+
typeof props.right !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
671
|
+
createVNode(_sfc_main$n, { onChange: changeRight }),
|
|
672
|
+
createElementVNode("div", {
|
|
673
|
+
class: normalizeClass(["m-editor-layout-right", __props.rightClass]),
|
|
674
|
+
style: normalizeStyle(`width: ${__props.right}px`)
|
|
675
|
+
}, [
|
|
676
|
+
renderSlot(_ctx.$slots, "right")
|
|
677
|
+
], 6)
|
|
678
|
+
], 64)) : createCommentVNode("", true)
|
|
679
|
+
], 512);
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
const _hoisted_1$c = ["src"];
|
|
685
|
+
const __default__$k = defineComponent({
|
|
686
|
+
name: "MEditorIcon"
|
|
687
|
+
});
|
|
688
|
+
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
689
|
+
...__default__$k,
|
|
690
|
+
props: {
|
|
691
|
+
icon: null
|
|
692
|
+
},
|
|
693
|
+
setup(__props) {
|
|
694
|
+
return (_ctx, _cache) => {
|
|
695
|
+
return !__props.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
|
|
696
|
+
key: 0,
|
|
697
|
+
class: "magic-editor-icon"
|
|
698
|
+
}, {
|
|
699
|
+
default: withCtx(() => [
|
|
700
|
+
createVNode(unref(Edit))
|
|
701
|
+
]),
|
|
702
|
+
_: 1
|
|
703
|
+
})) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(unref(TMagicIcon), {
|
|
704
|
+
key: 1,
|
|
705
|
+
class: "magic-editor-icon"
|
|
706
|
+
}, {
|
|
707
|
+
default: withCtx(() => [
|
|
708
|
+
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$c)
|
|
709
|
+
]),
|
|
710
|
+
_: 1
|
|
711
|
+
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
712
|
+
key: 2,
|
|
713
|
+
class: normalizeClass(["magic-editor-icon", __props.icon])
|
|
714
|
+
}, null, 2)) : (openBlock(), createBlock(unref(TMagicIcon), {
|
|
715
|
+
key: 3,
|
|
716
|
+
class: "magic-editor-icon"
|
|
717
|
+
}, {
|
|
718
|
+
default: withCtx(() => [
|
|
719
|
+
(openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
|
|
720
|
+
]),
|
|
721
|
+
_: 1
|
|
722
|
+
}));
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
const log = (...args) => {
|
|
728
|
+
if (process.env.NODE_ENV === "development") {
|
|
729
|
+
console.log("magic editor: ", ...args);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
const info = (...args) => {
|
|
733
|
+
if (process.env.NODE_ENV === "development") {
|
|
734
|
+
console.info("magic editor: ", ...args);
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
const warn = (...args) => {
|
|
738
|
+
if (process.env.NODE_ENV === "development") {
|
|
739
|
+
console.warn("magic editor: ", ...args);
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
const debug = (...args) => {
|
|
743
|
+
if (process.env.NODE_ENV === "development") {
|
|
744
|
+
console.debug("magic editor: ", ...args);
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
const error = (...args) => {
|
|
748
|
+
if (process.env.NODE_ENV === "development") {
|
|
749
|
+
console.error("magic editor: ", ...args);
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
const compose = (middleware) => {
|
|
754
|
+
if (!Array.isArray(middleware))
|
|
755
|
+
throw new TypeError("Middleware \u5FC5\u987B\u662F\u4E00\u4E2A\u6570\u7EC4!");
|
|
756
|
+
for (const fn of middleware) {
|
|
757
|
+
if (typeof fn !== "function")
|
|
758
|
+
throw new TypeError("Middleware \u5FC5\u987B\u7531\u51FD\u6570\u7EC4\u6210!");
|
|
759
|
+
}
|
|
760
|
+
return (args, next) => {
|
|
761
|
+
let index = -1;
|
|
762
|
+
return dispatch(0);
|
|
763
|
+
function dispatch(i) {
|
|
764
|
+
if (i <= index)
|
|
765
|
+
return Promise.reject(new Error("next() \u88AB\u591A\u6B21\u8C03\u7528"));
|
|
766
|
+
index = i;
|
|
767
|
+
let fn = middleware[i];
|
|
768
|
+
if (i === middleware.length && next)
|
|
769
|
+
fn = next;
|
|
770
|
+
if (!fn)
|
|
771
|
+
return Promise.resolve();
|
|
772
|
+
try {
|
|
773
|
+
return Promise.resolve(fn(...args, dispatch.bind(null, i + 1)));
|
|
774
|
+
} catch (err) {
|
|
775
|
+
return Promise.reject(err);
|
|
442
776
|
}
|
|
443
777
|
}
|
|
444
778
|
};
|
|
@@ -530,6 +864,269 @@ class BaseService extends EventEmitter {
|
|
|
530
864
|
}
|
|
531
865
|
}
|
|
532
866
|
|
|
867
|
+
class CodeBlock extends BaseService {
|
|
868
|
+
state = reactive({
|
|
869
|
+
isShowCodeEditor: false,
|
|
870
|
+
codeDsl: null,
|
|
871
|
+
id: "",
|
|
872
|
+
editable: true,
|
|
873
|
+
mode: CodeEditorMode.EDITOR,
|
|
874
|
+
combineIds: [],
|
|
875
|
+
undeletableList: []
|
|
876
|
+
});
|
|
877
|
+
constructor() {
|
|
878
|
+
super([
|
|
879
|
+
"setCodeDsl",
|
|
880
|
+
"getCodeDsl",
|
|
881
|
+
"getCodeContentById",
|
|
882
|
+
"getCodeDslByIds",
|
|
883
|
+
"getCurrentDsl",
|
|
884
|
+
"setCodeDslById",
|
|
885
|
+
"setCodeEditorShowStatus",
|
|
886
|
+
"setEditStatus",
|
|
887
|
+
"setMode",
|
|
888
|
+
"setCombineIds",
|
|
889
|
+
"setUndeleteableList",
|
|
890
|
+
"deleteCodeDslByIds"
|
|
891
|
+
]);
|
|
892
|
+
}
|
|
893
|
+
async setCodeDsl(codeDsl) {
|
|
894
|
+
this.state.codeDsl = codeDsl;
|
|
895
|
+
await editorService.setCodeDsl(this.state.codeDsl);
|
|
896
|
+
info("[code-block]:code-dsl-change", this.state.codeDsl);
|
|
897
|
+
this.emit("code-dsl-change", this.state.codeDsl);
|
|
898
|
+
}
|
|
899
|
+
async getCodeDsl(forceRefresh = false) {
|
|
900
|
+
if (!this.state.codeDsl || forceRefresh) {
|
|
901
|
+
this.state.codeDsl = await editorService.getCodeDsl();
|
|
902
|
+
}
|
|
903
|
+
return this.state.codeDsl;
|
|
904
|
+
}
|
|
905
|
+
async getCodeContentById(id) {
|
|
906
|
+
if (!id)
|
|
907
|
+
return null;
|
|
908
|
+
const totalCodeDsl = await this.getCodeDsl();
|
|
909
|
+
if (!totalCodeDsl)
|
|
910
|
+
return null;
|
|
911
|
+
return totalCodeDsl[id] ?? null;
|
|
912
|
+
}
|
|
913
|
+
async setCodeDslById(id, codeConfig) {
|
|
914
|
+
let codeDsl = await this.getCodeDsl();
|
|
915
|
+
if (!codeDsl) {
|
|
916
|
+
codeDsl = {
|
|
917
|
+
[id]: codeConfig
|
|
918
|
+
};
|
|
919
|
+
} else {
|
|
920
|
+
const existContent = codeDsl[id] || {};
|
|
921
|
+
codeDsl = {
|
|
922
|
+
...codeDsl,
|
|
923
|
+
[id]: {
|
|
924
|
+
...existContent,
|
|
925
|
+
...codeConfig
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
await this.setCodeDsl(codeDsl);
|
|
930
|
+
}
|
|
931
|
+
async getCodeDslByIds(ids) {
|
|
932
|
+
const codeDsl = await this.getCodeDsl();
|
|
933
|
+
return pick(codeDsl, ids);
|
|
934
|
+
}
|
|
935
|
+
async setCodeEditorShowStatus(status) {
|
|
936
|
+
this.state.isShowCodeEditor = status;
|
|
937
|
+
}
|
|
938
|
+
getCodeEditorShowStatus() {
|
|
939
|
+
return this.state.isShowCodeEditor;
|
|
940
|
+
}
|
|
941
|
+
setCodeEditorContent(status, id) {
|
|
942
|
+
if (!id)
|
|
943
|
+
return;
|
|
944
|
+
this.setId(id);
|
|
945
|
+
this.state.isShowCodeEditor = status;
|
|
946
|
+
}
|
|
947
|
+
async getCurrentDsl() {
|
|
948
|
+
return await this.getCodeContentById(this.state.id);
|
|
949
|
+
}
|
|
950
|
+
getEditStatus() {
|
|
951
|
+
return this.state.editable;
|
|
952
|
+
}
|
|
953
|
+
async setEditStatus(status) {
|
|
954
|
+
this.state.editable = status;
|
|
955
|
+
}
|
|
956
|
+
setId(id) {
|
|
957
|
+
if (!id)
|
|
958
|
+
return;
|
|
959
|
+
this.state.id = id;
|
|
960
|
+
}
|
|
961
|
+
getId() {
|
|
962
|
+
return this.state.id;
|
|
963
|
+
}
|
|
964
|
+
getMode() {
|
|
965
|
+
return this.state.mode;
|
|
966
|
+
}
|
|
967
|
+
async setMode(mode) {
|
|
968
|
+
this.state.mode = mode;
|
|
969
|
+
}
|
|
970
|
+
async setCombineIds(ids) {
|
|
971
|
+
this.state.combineIds = ids;
|
|
972
|
+
}
|
|
973
|
+
getCombineIds() {
|
|
974
|
+
return this.state.combineIds;
|
|
975
|
+
}
|
|
976
|
+
async setCombineRelation(compId, diffCodeIds, opFlag, hook) {
|
|
977
|
+
const codeDsl = cloneDeep(await this.getCodeDsl());
|
|
978
|
+
if (!codeDsl)
|
|
979
|
+
return;
|
|
980
|
+
if (opFlag === CodeSelectOp.DELETE) {
|
|
981
|
+
try {
|
|
982
|
+
diffCodeIds.forEach((codeId) => {
|
|
983
|
+
const compsContent = codeDsl[codeId].comps;
|
|
984
|
+
const index = compsContent?.[compId].findIndex((item) => item === hook);
|
|
985
|
+
if (typeof index !== "undefined" && index !== -1) {
|
|
986
|
+
compsContent?.[compId].splice(index, 1);
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
} catch (e) {
|
|
990
|
+
error(e);
|
|
991
|
+
throw new Error("\u89E3\u7ED1\u4EE3\u7801\u5757\u5931\u8D25");
|
|
992
|
+
}
|
|
993
|
+
} else if (opFlag === CodeSelectOp.ADD) {
|
|
994
|
+
try {
|
|
995
|
+
diffCodeIds.forEach((codeId) => {
|
|
996
|
+
const compsContent = codeDsl[codeId].comps;
|
|
997
|
+
const existHooks = compsContent?.[compId];
|
|
998
|
+
if (isEmpty(existHooks)) {
|
|
999
|
+
codeDsl[codeId].comps = {
|
|
1000
|
+
...codeDsl[codeId].comps || {},
|
|
1001
|
+
[compId]: [hook]
|
|
1002
|
+
};
|
|
1003
|
+
} else {
|
|
1004
|
+
existHooks?.push(hook);
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
} catch (e) {
|
|
1008
|
+
error(e);
|
|
1009
|
+
throw new Error("\u7ED1\u5B9A\u4EE3\u7801\u5757\u5931\u8D25");
|
|
1010
|
+
}
|
|
1011
|
+
} else if (opFlag === CodeSelectOp.CHANGE) {
|
|
1012
|
+
forIn(codeDsl, (codeBlockContent, codeId) => {
|
|
1013
|
+
if (codeId === diffCodeIds[0]) {
|
|
1014
|
+
codeBlockContent.comps = {
|
|
1015
|
+
...codeBlockContent?.comps || {},
|
|
1016
|
+
[compId]: [hook]
|
|
1017
|
+
};
|
|
1018
|
+
} else if (isEmpty(diffCodeIds) || codeId !== diffCodeIds[0]) {
|
|
1019
|
+
const compHooks = codeBlockContent?.comps?.[compId];
|
|
1020
|
+
if (!compHooks)
|
|
1021
|
+
return true;
|
|
1022
|
+
const index = compHooks.findIndex((hookName) => hookName === hook);
|
|
1023
|
+
if (index !== -1) {
|
|
1024
|
+
compHooks.splice(index, 1);
|
|
1025
|
+
return false;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
this.setCodeDsl(codeDsl);
|
|
1031
|
+
}
|
|
1032
|
+
getUndeletableList() {
|
|
1033
|
+
return this.state.undeletableList;
|
|
1034
|
+
}
|
|
1035
|
+
async setUndeleteableList(codeIds) {
|
|
1036
|
+
this.state.undeletableList = codeIds;
|
|
1037
|
+
}
|
|
1038
|
+
async deleteCodeDslByIds(codeIds) {
|
|
1039
|
+
const currentDsl = await this.getCodeDsl();
|
|
1040
|
+
const newDsl = omit(currentDsl, codeIds);
|
|
1041
|
+
await this.setCodeDsl(newDsl);
|
|
1042
|
+
return newDsl;
|
|
1043
|
+
}
|
|
1044
|
+
async getUniqueId() {
|
|
1045
|
+
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
1046
|
+
const dsl = await this.getCodeDsl();
|
|
1047
|
+
const existedIds = keys(dsl);
|
|
1048
|
+
if (!existedIds.includes(newId))
|
|
1049
|
+
return newId;
|
|
1050
|
+
return await this.getUniqueId();
|
|
1051
|
+
}
|
|
1052
|
+
async deleteCompsInRelation(node) {
|
|
1053
|
+
const codeDsl = cloneDeep(await this.getCodeDsl());
|
|
1054
|
+
if (!codeDsl)
|
|
1055
|
+
return;
|
|
1056
|
+
this.recurseNodes(node, codeDsl);
|
|
1057
|
+
this.setCodeDsl(codeDsl);
|
|
1058
|
+
}
|
|
1059
|
+
destroy() {
|
|
1060
|
+
this.state.isShowCodeEditor = false;
|
|
1061
|
+
this.state.codeDsl = null;
|
|
1062
|
+
this.state.id = "";
|
|
1063
|
+
this.state.editable = true;
|
|
1064
|
+
this.state.mode = CodeEditorMode.EDITOR;
|
|
1065
|
+
this.state.combineIds = [];
|
|
1066
|
+
this.state.undeletableList = [];
|
|
1067
|
+
}
|
|
1068
|
+
recurseNodes(node, codeDsl) {
|
|
1069
|
+
if (!node.id)
|
|
1070
|
+
return;
|
|
1071
|
+
forIn(codeDsl, (codeBlockContent) => {
|
|
1072
|
+
const compsContent = codeBlockContent.comps || {};
|
|
1073
|
+
codeBlockContent.comps = omit(compsContent, node.id);
|
|
1074
|
+
});
|
|
1075
|
+
if (!isEmpty(node.items)) {
|
|
1076
|
+
node.items.forEach((item) => {
|
|
1077
|
+
this.recurseNodes(item, codeDsl);
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
const codeBlockService = new CodeBlock();
|
|
1083
|
+
|
|
1084
|
+
class UndoRedo {
|
|
1085
|
+
elementList;
|
|
1086
|
+
listCursor;
|
|
1087
|
+
listMaxSize;
|
|
1088
|
+
constructor(listMaxSize = 200) {
|
|
1089
|
+
const minListMaxSize = 2;
|
|
1090
|
+
this.elementList = [];
|
|
1091
|
+
this.listCursor = 0;
|
|
1092
|
+
this.listMaxSize = listMaxSize > minListMaxSize ? listMaxSize : minListMaxSize;
|
|
1093
|
+
}
|
|
1094
|
+
pushElement(element) {
|
|
1095
|
+
this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, cloneDeep(element));
|
|
1096
|
+
this.listCursor += 1;
|
|
1097
|
+
if (this.elementList.length > this.listMaxSize) {
|
|
1098
|
+
this.elementList.shift();
|
|
1099
|
+
this.listCursor -= 1;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
canUndo() {
|
|
1103
|
+
return this.listCursor > 1;
|
|
1104
|
+
}
|
|
1105
|
+
undo() {
|
|
1106
|
+
if (!this.canUndo()) {
|
|
1107
|
+
return null;
|
|
1108
|
+
}
|
|
1109
|
+
this.listCursor -= 1;
|
|
1110
|
+
return this.getCurrentElement();
|
|
1111
|
+
}
|
|
1112
|
+
canRedo() {
|
|
1113
|
+
return this.elementList.length > this.listCursor;
|
|
1114
|
+
}
|
|
1115
|
+
redo() {
|
|
1116
|
+
if (!this.canRedo()) {
|
|
1117
|
+
return null;
|
|
1118
|
+
}
|
|
1119
|
+
this.listCursor += 1;
|
|
1120
|
+
return this.getCurrentElement();
|
|
1121
|
+
}
|
|
1122
|
+
getCurrentElement() {
|
|
1123
|
+
if (this.listCursor < 1) {
|
|
1124
|
+
return null;
|
|
1125
|
+
}
|
|
1126
|
+
return cloneDeep(this.elementList[this.listCursor - 1]);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
533
1130
|
class History extends BaseService {
|
|
534
1131
|
state = reactive({
|
|
535
1132
|
pageSteps: {},
|
|
@@ -695,31 +1292,6 @@ class WebStorage extends BaseService {
|
|
|
695
1292
|
}
|
|
696
1293
|
const storageService = new WebStorage();
|
|
697
1294
|
|
|
698
|
-
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
699
|
-
ColumnLayout2["LEFT"] = "left";
|
|
700
|
-
ColumnLayout2["CENTER"] = "center";
|
|
701
|
-
ColumnLayout2["RIGHT"] = "right";
|
|
702
|
-
return ColumnLayout2;
|
|
703
|
-
})(ColumnLayout || {});
|
|
704
|
-
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
705
|
-
LayerOffset2["TOP"] = "top";
|
|
706
|
-
LayerOffset2["BOTTOM"] = "bottom";
|
|
707
|
-
return LayerOffset2;
|
|
708
|
-
})(LayerOffset || {});
|
|
709
|
-
var Layout = /* @__PURE__ */ ((Layout2) => {
|
|
710
|
-
Layout2["FLEX"] = "flex";
|
|
711
|
-
Layout2["FIXED"] = "fixed";
|
|
712
|
-
Layout2["RELATIVE"] = "relative";
|
|
713
|
-
Layout2["ABSOLUTE"] = "absolute";
|
|
714
|
-
return Layout2;
|
|
715
|
-
})(Layout || {});
|
|
716
|
-
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
717
|
-
Keys2["ESCAPE"] = "Space";
|
|
718
|
-
return Keys2;
|
|
719
|
-
})(Keys || {});
|
|
720
|
-
const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
721
|
-
const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
722
|
-
|
|
723
1295
|
const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
724
1296
|
const getPageList = (app) => {
|
|
725
1297
|
if (app.items && Array.isArray(app.items)) {
|
|
@@ -1073,14 +1645,16 @@ class Editor$1 extends BaseService {
|
|
|
1073
1645
|
"copy",
|
|
1074
1646
|
"paste",
|
|
1075
1647
|
"doPaste",
|
|
1076
|
-
"
|
|
1648
|
+
"doAlignCenter",
|
|
1077
1649
|
"alignCenter",
|
|
1078
1650
|
"moveLayer",
|
|
1079
1651
|
"moveToContainer",
|
|
1080
1652
|
"move",
|
|
1081
1653
|
"undo",
|
|
1082
1654
|
"redo",
|
|
1083
|
-
"highlight"
|
|
1655
|
+
"highlight",
|
|
1656
|
+
"getCodeDsl",
|
|
1657
|
+
"setCodeDsl"
|
|
1084
1658
|
],
|
|
1085
1659
|
["select", "update", "moveLayer"]
|
|
1086
1660
|
);
|
|
@@ -1305,6 +1879,7 @@ class Editor$1 extends BaseService {
|
|
|
1305
1879
|
stage?.select(parent.id);
|
|
1306
1880
|
}
|
|
1307
1881
|
this.addModifiedNodeId(parent.id);
|
|
1882
|
+
codeBlockService.deleteCompsInRelation(node);
|
|
1308
1883
|
}
|
|
1309
1884
|
async remove(nodeOrNodeList) {
|
|
1310
1885
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
@@ -1344,10 +1919,10 @@ class Editor$1 extends BaseService {
|
|
|
1344
1919
|
newConfig = setLayout(newConfig, newLayout);
|
|
1345
1920
|
}
|
|
1346
1921
|
parentNodeItems[index] = newConfig;
|
|
1347
|
-
const nodes = this.get("nodes");
|
|
1922
|
+
const nodes = this.get("nodes") || [];
|
|
1348
1923
|
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
1349
1924
|
nodes.splice(targetIndex, 1, newConfig);
|
|
1350
|
-
this.set("nodes", nodes);
|
|
1925
|
+
this.set("nodes", [...nodes]);
|
|
1351
1926
|
this.get("stage")?.update({
|
|
1352
1927
|
config: cloneDeep(newConfig),
|
|
1353
1928
|
parentId: parent.id,
|
|
@@ -1429,7 +2004,11 @@ class Editor$1 extends BaseService {
|
|
|
1429
2004
|
const stage = this.get("stage");
|
|
1430
2005
|
const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
|
|
1431
2006
|
const newNode = await this.update(newNodes);
|
|
1432
|
-
|
|
2007
|
+
if (newNodes.length > 1) {
|
|
2008
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
2009
|
+
} else {
|
|
2010
|
+
await stage?.select(newNodes[0].id);
|
|
2011
|
+
}
|
|
1433
2012
|
return newNode;
|
|
1434
2013
|
}
|
|
1435
2014
|
async moveLayer(offset) {
|
|
@@ -1530,6 +2109,17 @@ class Editor$1 extends BaseService {
|
|
|
1530
2109
|
resetModifiedNodeId() {
|
|
1531
2110
|
this.get("modifiedNodeIds").clear();
|
|
1532
2111
|
}
|
|
2112
|
+
async getCodeDsl() {
|
|
2113
|
+
const root = this.get("root");
|
|
2114
|
+
if (!root)
|
|
2115
|
+
return null;
|
|
2116
|
+
return root.codeBlocks || null;
|
|
2117
|
+
}
|
|
2118
|
+
async setCodeDsl(codeDsl) {
|
|
2119
|
+
if (!this.state.root)
|
|
2120
|
+
return;
|
|
2121
|
+
this.state.root.codeBlocks = codeDsl;
|
|
2122
|
+
}
|
|
1533
2123
|
addModifiedNodeId(id) {
|
|
1534
2124
|
if (!this.isHistoryStateChange) {
|
|
1535
2125
|
this.get("modifiedNodeIds").set(id, id);
|
|
@@ -1834,13 +2424,19 @@ const fillConfig = (config = []) => [
|
|
|
1834
2424
|
},
|
|
1835
2425
|
{
|
|
1836
2426
|
title: "\u9AD8\u7EA7",
|
|
1837
|
-
|
|
2427
|
+
lazy: true,
|
|
1838
2428
|
items: [
|
|
1839
2429
|
{
|
|
1840
|
-
type: "code-link",
|
|
1841
2430
|
name: "created",
|
|
1842
2431
|
text: "created",
|
|
1843
|
-
|
|
2432
|
+
type: "code-select",
|
|
2433
|
+
labelWidth: "100px"
|
|
2434
|
+
},
|
|
2435
|
+
{
|
|
2436
|
+
name: "mounted",
|
|
2437
|
+
text: "mounted",
|
|
2438
|
+
type: "code-select",
|
|
2439
|
+
labelWidth: "100px"
|
|
1844
2440
|
}
|
|
1845
2441
|
]
|
|
1846
2442
|
}
|
|
@@ -1848,32 +2444,6 @@ const fillConfig = (config = []) => [
|
|
|
1848
2444
|
}
|
|
1849
2445
|
];
|
|
1850
2446
|
|
|
1851
|
-
const log = (...args) => {
|
|
1852
|
-
if (process.env.NODE_ENV === "development") {
|
|
1853
|
-
console.log("magic editor: ", ...args);
|
|
1854
|
-
}
|
|
1855
|
-
};
|
|
1856
|
-
const info = (...args) => {
|
|
1857
|
-
if (process.env.NODE_ENV === "development") {
|
|
1858
|
-
console.info("magic editor: ", ...args);
|
|
1859
|
-
}
|
|
1860
|
-
};
|
|
1861
|
-
const warn = (...args) => {
|
|
1862
|
-
if (process.env.NODE_ENV === "development") {
|
|
1863
|
-
console.warn("magic editor: ", ...args);
|
|
1864
|
-
}
|
|
1865
|
-
};
|
|
1866
|
-
const debug = (...args) => {
|
|
1867
|
-
if (process.env.NODE_ENV === "development") {
|
|
1868
|
-
console.debug("magic editor: ", ...args);
|
|
1869
|
-
}
|
|
1870
|
-
};
|
|
1871
|
-
const error = (...args) => {
|
|
1872
|
-
if (process.env.NODE_ENV === "development") {
|
|
1873
|
-
console.error("magic editor: ", ...args);
|
|
1874
|
-
}
|
|
1875
|
-
};
|
|
1876
|
-
|
|
1877
2447
|
const state = reactive({
|
|
1878
2448
|
uiSelectMode: false,
|
|
1879
2449
|
showSrc: false,
|
|
@@ -1978,6 +2548,8 @@ const useStage = (stageOptions) => {
|
|
|
1978
2548
|
getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
|
|
1979
2549
|
]);
|
|
1980
2550
|
stage.on("select", (el) => {
|
|
2551
|
+
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
2552
|
+
return;
|
|
1981
2553
|
editorService.select(el.id);
|
|
1982
2554
|
});
|
|
1983
2555
|
stage.on("highlight", (el) => {
|
|
@@ -1998,6 +2570,11 @@ const useStage = (stageOptions) => {
|
|
|
1998
2570
|
stage.on("sort", (ev) => {
|
|
1999
2571
|
editorService.sort(ev.src, ev.dist);
|
|
2000
2572
|
});
|
|
2573
|
+
stage.on("select-parent", () => {
|
|
2574
|
+
const parent = editorService.get("parent");
|
|
2575
|
+
editorService.select(parent);
|
|
2576
|
+
editorService.get("stage").select(parent.id);
|
|
2577
|
+
});
|
|
2001
2578
|
stage.on("changeGuides", (e) => {
|
|
2002
2579
|
uiService.set("showGuides", true);
|
|
2003
2580
|
if (!root.value || !page.value)
|
|
@@ -2014,181 +2591,49 @@ const useStage = (stageOptions) => {
|
|
|
2014
2591
|
return stage;
|
|
2015
2592
|
};
|
|
2016
2593
|
|
|
2017
|
-
const
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
clickHandler() {
|
|
2023
|
-
const { editorService } = services || {};
|
|
2024
|
-
if (!editorService)
|
|
2025
|
-
return;
|
|
2026
|
-
editorService.add({
|
|
2027
|
-
type: NodeType.PAGE,
|
|
2028
|
-
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
2029
|
-
});
|
|
2030
|
-
}
|
|
2031
|
-
};
|
|
2032
|
-
}
|
|
2594
|
+
const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
2595
|
+
const _hoisted_2$5 = { class: "m-editor-empty-content" };
|
|
2596
|
+
const _hoisted_3$2 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2597
|
+
const __default__$j = defineComponent({
|
|
2598
|
+
name: "MEditorAddPageBox"
|
|
2033
2599
|
});
|
|
2034
|
-
|
|
2035
|
-
const _hoisted_1$9 = { class: "m-editor-empty-panel" };
|
|
2036
|
-
const _hoisted_2$3 = { class: "m-editor-empty-content" };
|
|
2037
|
-
const _hoisted_3 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2038
|
-
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2039
|
-
const _component_plus = resolveComponent("plus");
|
|
2040
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
2041
|
-
return openBlock(), createElementBlock("div", _hoisted_1$9, [
|
|
2042
|
-
createElementVNode("div", _hoisted_2$3, [
|
|
2043
|
-
createElementVNode("div", {
|
|
2044
|
-
class: "m-editor-empty-button",
|
|
2045
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
|
|
2046
|
-
}, [
|
|
2047
|
-
createElementVNode("div", null, [
|
|
2048
|
-
createVNode(_component_el_icon, null, {
|
|
2049
|
-
default: withCtx(() => [
|
|
2050
|
-
createVNode(_component_plus)
|
|
2051
|
-
]),
|
|
2052
|
-
_: 1
|
|
2053
|
-
})
|
|
2054
|
-
]),
|
|
2055
|
-
_hoisted_3
|
|
2056
|
-
])
|
|
2057
|
-
])
|
|
2058
|
-
]);
|
|
2059
|
-
}
|
|
2060
|
-
const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$5]]);
|
|
2061
|
-
|
|
2062
2600
|
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
const
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
if (!target.value)
|
|
2070
|
-
return;
|
|
2071
|
-
getso = new Gesto(target.value, {
|
|
2072
|
-
container: window,
|
|
2073
|
-
pinchOutside: true
|
|
2074
|
-
}).on("drag", (e) => {
|
|
2075
|
-
if (!target.value)
|
|
2076
|
-
return;
|
|
2077
|
-
emit("change", e.deltaX);
|
|
2078
|
-
});
|
|
2079
|
-
});
|
|
2080
|
-
onUnmounted(() => {
|
|
2081
|
-
getso?.unset();
|
|
2082
|
-
});
|
|
2083
|
-
return (_ctx, _cache) => {
|
|
2084
|
-
return openBlock(), createElementBlock("span", {
|
|
2085
|
-
ref_key: "target",
|
|
2086
|
-
ref: target,
|
|
2087
|
-
class: "m-editor-resizer"
|
|
2088
|
-
}, [
|
|
2089
|
-
renderSlot(_ctx.$slots, "default")
|
|
2090
|
-
], 512);
|
|
2091
|
-
};
|
|
2092
|
-
}
|
|
2093
|
-
});
|
|
2094
|
-
|
|
2095
|
-
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
2096
|
-
__name: "Layout",
|
|
2097
|
-
props: {
|
|
2098
|
-
left: null,
|
|
2099
|
-
right: null,
|
|
2100
|
-
minLeft: { default: 1 },
|
|
2101
|
-
minRight: { default: 1 },
|
|
2102
|
-
leftClass: null,
|
|
2103
|
-
rightClass: null,
|
|
2104
|
-
centerClass: null
|
|
2105
|
-
},
|
|
2106
|
-
emits: ["update:left", "change", "update:right"],
|
|
2107
|
-
setup(__props, { emit }) {
|
|
2108
|
-
const props = __props;
|
|
2109
|
-
const el = ref();
|
|
2110
|
-
let clientWidth = 0;
|
|
2111
|
-
const resizerObserver = new ResizeObserver((entries) => {
|
|
2112
|
-
for (const { contentRect } of entries) {
|
|
2113
|
-
clientWidth = contentRect.width;
|
|
2114
|
-
center.value = clientWidth - (props.left || 0) - (props.right || 0);
|
|
2115
|
-
emit("change", {
|
|
2116
|
-
left: props.left,
|
|
2117
|
-
center: center.value,
|
|
2118
|
-
right: props.right
|
|
2119
|
-
});
|
|
2120
|
-
}
|
|
2121
|
-
});
|
|
2122
|
-
onMounted(() => {
|
|
2123
|
-
if (el.value) {
|
|
2124
|
-
resizerObserver.observe(el.value);
|
|
2125
|
-
}
|
|
2126
|
-
});
|
|
2127
|
-
onUnmounted(() => {
|
|
2128
|
-
resizerObserver.disconnect();
|
|
2129
|
-
});
|
|
2130
|
-
const center = ref(0);
|
|
2131
|
-
const changeLeft = (deltaX) => {
|
|
2132
|
-
if (typeof props.left === "undefined")
|
|
2133
|
-
return;
|
|
2134
|
-
const left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
2135
|
-
emit("update:left", left);
|
|
2136
|
-
center.value = clientWidth - left - (props.right || 0);
|
|
2137
|
-
emit("change", {
|
|
2138
|
-
left,
|
|
2139
|
-
center: center.value,
|
|
2140
|
-
right: props.right
|
|
2141
|
-
});
|
|
2142
|
-
};
|
|
2143
|
-
const changeRight = (deltaX) => {
|
|
2144
|
-
if (typeof props.right === "undefined")
|
|
2601
|
+
...__default__$j,
|
|
2602
|
+
setup(__props) {
|
|
2603
|
+
const services = inject("services");
|
|
2604
|
+
const clickHandler = () => {
|
|
2605
|
+
const { editorService } = services || {};
|
|
2606
|
+
if (!editorService)
|
|
2145
2607
|
return;
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
emit("change", {
|
|
2150
|
-
left: props.left,
|
|
2151
|
-
center: center.value,
|
|
2152
|
-
right
|
|
2608
|
+
editorService.add({
|
|
2609
|
+
type: NodeType.PAGE,
|
|
2610
|
+
name: generatePageNameByApp(toRaw(editorService.get("root")))
|
|
2153
2611
|
});
|
|
2154
2612
|
};
|
|
2155
2613
|
return (_ctx, _cache) => {
|
|
2156
|
-
return openBlock(), createElementBlock("div",
|
|
2157
|
-
|
|
2158
|
-
ref: el
|
|
2159
|
-
}, [
|
|
2160
|
-
typeof props.left !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2161
|
-
createElementVNode("div", {
|
|
2162
|
-
class: normalizeClass(["m-editor-layout-left", __props.leftClass]),
|
|
2163
|
-
style: normalizeStyle(`width: ${__props.left}px`)
|
|
2164
|
-
}, [
|
|
2165
|
-
renderSlot(_ctx.$slots, "left")
|
|
2166
|
-
], 6),
|
|
2167
|
-
createVNode(_sfc_main$k, { onChange: changeLeft })
|
|
2168
|
-
], 64)) : createCommentVNode("", true),
|
|
2169
|
-
createElementVNode("div", {
|
|
2170
|
-
class: normalizeClass(["m-editor-layout-center", __props.centerClass]),
|
|
2171
|
-
style: normalizeStyle(`width: ${center.value}px`)
|
|
2172
|
-
}, [
|
|
2173
|
-
renderSlot(_ctx.$slots, "center")
|
|
2174
|
-
], 6),
|
|
2175
|
-
typeof props.right !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
2176
|
-
createVNode(_sfc_main$k, { onChange: changeRight }),
|
|
2614
|
+
return openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
2615
|
+
createElementVNode("div", _hoisted_2$5, [
|
|
2177
2616
|
createElementVNode("div", {
|
|
2178
|
-
class:
|
|
2179
|
-
|
|
2617
|
+
class: "m-editor-empty-button",
|
|
2618
|
+
onClick: clickHandler
|
|
2180
2619
|
}, [
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2620
|
+
createElementVNode("div", null, [
|
|
2621
|
+
createVNode(_sfc_main$l, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
2622
|
+
]),
|
|
2623
|
+
_hoisted_3$2
|
|
2624
|
+
])
|
|
2625
|
+
])
|
|
2626
|
+
]);
|
|
2185
2627
|
};
|
|
2186
2628
|
}
|
|
2187
2629
|
});
|
|
2188
2630
|
|
|
2189
|
-
const _hoisted_1$
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2631
|
+
const _hoisted_1$a = { class: "m-editor" };
|
|
2632
|
+
const __default__$i = defineComponent({
|
|
2633
|
+
name: "MEditorFramework"
|
|
2634
|
+
});
|
|
2635
|
+
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
2636
|
+
...__default__$i,
|
|
2192
2637
|
props: {
|
|
2193
2638
|
codeOptions: { default: () => ({}) }
|
|
2194
2639
|
},
|
|
@@ -2197,48 +2642,64 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2197
2642
|
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
2198
2643
|
const { editorService, uiService } = inject("services") || {};
|
|
2199
2644
|
const root = computed(() => editorService?.get("root"));
|
|
2645
|
+
const nodes = computed(() => editorService?.get("nodes") || []);
|
|
2200
2646
|
const pageLength = computed(() => editorService?.get("pageLength") || 0);
|
|
2201
2647
|
const showSrc = computed(() => uiService?.get("showSrc"));
|
|
2648
|
+
const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
|
|
2649
|
+
const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
|
|
2650
|
+
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
|
|
2651
|
+
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
|
|
2202
2652
|
const columnWidth = ref({
|
|
2203
|
-
left:
|
|
2653
|
+
left: leftColumnWidthCacheData,
|
|
2204
2654
|
center: 0,
|
|
2205
|
-
right:
|
|
2655
|
+
right: RightColumnWidthCacheData
|
|
2206
2656
|
});
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
columnWidth.value.
|
|
2211
|
-
columnWidth.value.
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2657
|
+
watch(
|
|
2658
|
+
pageLength,
|
|
2659
|
+
(length) => {
|
|
2660
|
+
const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
2661
|
+
columnWidth.value.left = left;
|
|
2662
|
+
if (length <= 0) {
|
|
2663
|
+
columnWidth.value.right = void 0;
|
|
2664
|
+
columnWidth.value.center = globalThis.document.body.clientWidth - left;
|
|
2665
|
+
} else {
|
|
2666
|
+
const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
2667
|
+
columnWidth.value.right = right;
|
|
2668
|
+
columnWidth.value.center = globalThis.document.body.clientWidth - left - right;
|
|
2669
|
+
}
|
|
2670
|
+
uiService?.set("columnWidth", columnWidth);
|
|
2671
|
+
},
|
|
2672
|
+
{
|
|
2673
|
+
immediate: true
|
|
2215
2674
|
}
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2675
|
+
);
|
|
2676
|
+
watch(
|
|
2677
|
+
() => columnWidth.value.right,
|
|
2678
|
+
(right) => {
|
|
2679
|
+
if (typeof right === "undefined")
|
|
2680
|
+
return;
|
|
2681
|
+
globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
|
|
2682
|
+
}
|
|
2683
|
+
);
|
|
2684
|
+
watch(
|
|
2685
|
+
() => columnWidth.value.left,
|
|
2686
|
+
(left) => {
|
|
2687
|
+
globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
|
|
2222
2688
|
}
|
|
2689
|
+
);
|
|
2690
|
+
const columnWidthChange = (columnWidth2) => {
|
|
2691
|
+
uiService?.set("columnWidth", columnWidth2);
|
|
2223
2692
|
};
|
|
2224
|
-
const
|
|
2225
|
-
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
2226
|
-
if (columnWidthCacheData) {
|
|
2693
|
+
const saveCode = (value) => {
|
|
2227
2694
|
try {
|
|
2228
|
-
|
|
2229
|
-
columnWidth.value = columnWidthCache;
|
|
2695
|
+
editorService?.set("root", eval(value));
|
|
2230
2696
|
} catch (e) {
|
|
2231
2697
|
console.error(e);
|
|
2232
2698
|
}
|
|
2233
|
-
}
|
|
2234
|
-
const columnWidthChange = (columnWidth2) => {
|
|
2235
|
-
uiService?.set("columnWidth", columnWidth2);
|
|
2236
|
-
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth2));
|
|
2237
2699
|
};
|
|
2238
2700
|
return (_ctx, _cache) => {
|
|
2239
2701
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2240
|
-
|
|
2241
|
-
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
2702
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
2242
2703
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2243
2704
|
unref(showSrc) ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2244
2705
|
key: 0,
|
|
@@ -2246,95 +2707,57 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2246
2707
|
"init-values": unref(root),
|
|
2247
2708
|
options: __props.codeOptions,
|
|
2248
2709
|
onSave: saveCode
|
|
2249
|
-
}, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$
|
|
2710
|
+
}, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$m, {
|
|
2250
2711
|
key: 1,
|
|
2251
2712
|
class: "m-editor-content",
|
|
2252
2713
|
"left-class": "m-editor-framework-left",
|
|
2253
2714
|
"center-class": "m-editor-framework-center",
|
|
2254
|
-
"right-class": "m-editor-framework-right",
|
|
2255
|
-
left: columnWidth.value.left,
|
|
2256
|
-
"onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
|
|
2257
|
-
right: columnWidth.value.right,
|
|
2258
|
-
"onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
|
|
2259
|
-
"min-left": 45,
|
|
2260
|
-
"min-right": 1,
|
|
2261
|
-
onChange: columnWidthChange
|
|
2262
|
-
}, createSlots({
|
|
2263
|
-
left: withCtx(() => [
|
|
2264
|
-
renderSlot(_ctx.$slots, "sidebar")
|
|
2265
|
-
]),
|
|
2266
|
-
center: withCtx(() => [
|
|
2267
|
-
unref(pageLength) > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
2268
|
-
createVNode(
|
|
2269
|
-
])
|
|
2270
|
-
]),
|
|
2271
|
-
_: 2
|
|
2272
|
-
}, [
|
|
2273
|
-
unref(pageLength) > 0 ? {
|
|
2274
|
-
name: "right",
|
|
2275
|
-
fn: withCtx(() => [
|
|
2276
|
-
createVNode(
|
|
2277
|
-
default: withCtx(() => [
|
|
2278
|
-
renderSlot(_ctx.$slots, "props-panel")
|
|
2279
|
-
]),
|
|
2280
|
-
_: 3
|
|
2281
|
-
})
|
|
2282
|
-
])
|
|
2283
|
-
} : void 0
|
|
2284
|
-
]), 1032, ["left", "right"]))
|
|
2285
|
-
]);
|
|
2286
|
-
};
|
|
2287
|
-
}
|
|
2288
|
-
});
|
|
2289
|
-
|
|
2290
|
-
const _hoisted_1$7 = ["src"];
|
|
2291
|
-
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
2292
|
-
__name: "Icon",
|
|
2293
|
-
props: {
|
|
2294
|
-
icon: null
|
|
2295
|
-
},
|
|
2296
|
-
setup(__props) {
|
|
2297
|
-
return (_ctx, _cache) => {
|
|
2298
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
2299
|
-
return !__props.icon ? (openBlock(), createBlock(_component_el_icon, {
|
|
2300
|
-
key: 0,
|
|
2301
|
-
class: "magic-editor-icon"
|
|
2302
|
-
}, {
|
|
2303
|
-
default: withCtx(() => [
|
|
2304
|
-
createVNode(unref(Edit))
|
|
2305
|
-
]),
|
|
2306
|
-
_: 1
|
|
2307
|
-
})) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, {
|
|
2308
|
-
key: 1,
|
|
2309
|
-
class: "magic-editor-icon"
|
|
2310
|
-
}, {
|
|
2311
|
-
default: withCtx(() => [
|
|
2312
|
-
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$7)
|
|
2313
|
-
]),
|
|
2314
|
-
_: 1
|
|
2315
|
-
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
2316
|
-
key: 2,
|
|
2317
|
-
class: normalizeClass(["magic-editor-icon", __props.icon])
|
|
2318
|
-
}, null, 2)) : (openBlock(), createBlock(_component_el_icon, {
|
|
2319
|
-
key: 3,
|
|
2320
|
-
class: "magic-editor-icon"
|
|
2321
|
-
}, {
|
|
2322
|
-
default: withCtx(() => [
|
|
2323
|
-
(openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
|
|
2324
|
-
]),
|
|
2325
|
-
_: 1
|
|
2326
|
-
}));
|
|
2715
|
+
"right-class": "m-editor-framework-right",
|
|
2716
|
+
left: columnWidth.value.left,
|
|
2717
|
+
"onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
|
|
2718
|
+
right: columnWidth.value.right,
|
|
2719
|
+
"onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
|
|
2720
|
+
"min-left": 45,
|
|
2721
|
+
"min-right": 1,
|
|
2722
|
+
onChange: columnWidthChange
|
|
2723
|
+
}, createSlots({
|
|
2724
|
+
left: withCtx(() => [
|
|
2725
|
+
renderSlot(_ctx.$slots, "sidebar")
|
|
2726
|
+
]),
|
|
2727
|
+
center: withCtx(() => [
|
|
2728
|
+
unref(pageLength) > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
2729
|
+
createVNode(_sfc_main$k)
|
|
2730
|
+
])
|
|
2731
|
+
]),
|
|
2732
|
+
_: 2
|
|
2733
|
+
}, [
|
|
2734
|
+
unref(pageLength) > 0 && unref(nodes).length === 1 ? {
|
|
2735
|
+
name: "right",
|
|
2736
|
+
fn: withCtx(() => [
|
|
2737
|
+
createVNode(unref(TMagicScrollbar), null, {
|
|
2738
|
+
default: withCtx(() => [
|
|
2739
|
+
renderSlot(_ctx.$slots, "props-panel")
|
|
2740
|
+
]),
|
|
2741
|
+
_: 3
|
|
2742
|
+
})
|
|
2743
|
+
])
|
|
2744
|
+
} : void 0
|
|
2745
|
+
]), 1032, ["left", "right"]))
|
|
2746
|
+
]);
|
|
2327
2747
|
};
|
|
2328
2748
|
}
|
|
2329
2749
|
});
|
|
2330
2750
|
|
|
2331
|
-
const _hoisted_1$
|
|
2751
|
+
const _hoisted_1$9 = {
|
|
2332
2752
|
key: 1,
|
|
2333
2753
|
class: "menu-item-text"
|
|
2334
2754
|
};
|
|
2335
|
-
const _hoisted_2$
|
|
2336
|
-
const
|
|
2337
|
-
|
|
2755
|
+
const _hoisted_2$4 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2756
|
+
const __default__$h = defineComponent({
|
|
2757
|
+
name: "MEditorToolButton"
|
|
2758
|
+
});
|
|
2759
|
+
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
2760
|
+
...__default__$h,
|
|
2338
2761
|
props: {
|
|
2339
2762
|
data: { default: () => ({
|
|
2340
2763
|
type: "text",
|
|
@@ -2399,13 +2822,6 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2399
2822
|
}
|
|
2400
2823
|
};
|
|
2401
2824
|
return (_ctx, _cache) => {
|
|
2402
|
-
const _component_el_divider = resolveComponent("el-divider");
|
|
2403
|
-
const _component_el_button = resolveComponent("el-button");
|
|
2404
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2405
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
2406
|
-
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
2407
|
-
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
2408
|
-
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
2409
2825
|
return unref(display) ? (openBlock(), createElementBlock("div", {
|
|
2410
2826
|
key: 0,
|
|
2411
2827
|
class: normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
|
|
@@ -2413,24 +2829,24 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2413
2829
|
onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
|
|
2414
2830
|
onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
|
|
2415
2831
|
}, [
|
|
2416
|
-
__props.data.type === "divider" ? (openBlock(), createBlock(
|
|
2832
|
+
__props.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
|
|
2417
2833
|
key: 0,
|
|
2418
2834
|
direction: __props.data.direction || "vertical"
|
|
2419
|
-
}, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2420
|
-
__props.data.tooltip ? (openBlock(), createBlock(
|
|
2835
|
+
}, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$9, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
2836
|
+
__props.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
2421
2837
|
key: 0,
|
|
2422
2838
|
effect: "dark",
|
|
2423
2839
|
placement: "bottom-start",
|
|
2424
2840
|
content: __props.data.tooltip
|
|
2425
2841
|
}, {
|
|
2426
2842
|
default: withCtx(() => [
|
|
2427
|
-
createVNode(
|
|
2843
|
+
createVNode(unref(TMagicButton), {
|
|
2428
2844
|
size: "small",
|
|
2429
2845
|
text: "",
|
|
2430
2846
|
disabled: unref(disabled)
|
|
2431
2847
|
}, {
|
|
2432
2848
|
default: withCtx(() => [
|
|
2433
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2849
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$l, {
|
|
2434
2850
|
key: 0,
|
|
2435
2851
|
icon: __props.data.icon
|
|
2436
2852
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2440,14 +2856,14 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2440
2856
|
}, 8, ["disabled"])
|
|
2441
2857
|
]),
|
|
2442
2858
|
_: 1
|
|
2443
|
-
}, 8, ["content"])) : (openBlock(), createBlock(
|
|
2859
|
+
}, 8, ["content"])) : (openBlock(), createBlock(unref(TMagicButton), {
|
|
2444
2860
|
key: 1,
|
|
2445
2861
|
size: "small",
|
|
2446
2862
|
text: "",
|
|
2447
2863
|
disabled: unref(disabled)
|
|
2448
2864
|
}, {
|
|
2449
2865
|
default: withCtx(() => [
|
|
2450
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2866
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$l, {
|
|
2451
2867
|
key: 0,
|
|
2452
2868
|
icon: __props.data.icon
|
|
2453
2869
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2455,17 +2871,17 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2455
2871
|
]),
|
|
2456
2872
|
_: 1
|
|
2457
2873
|
}, 8, ["disabled"]))
|
|
2458
|
-
], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(
|
|
2874
|
+
], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(unref(TMagicDropdown), {
|
|
2459
2875
|
key: 3,
|
|
2460
2876
|
trigger: "click",
|
|
2461
2877
|
disabled: unref(disabled),
|
|
2462
2878
|
onCommand: dropdownHandler
|
|
2463
2879
|
}, {
|
|
2464
2880
|
dropdown: withCtx(() => [
|
|
2465
|
-
__props.data.items && __props.data.items.length ? (openBlock(), createBlock(
|
|
2881
|
+
__props.data.items && __props.data.items.length ? (openBlock(), createBlock(unref(TMagicDropdownMenu), { key: 0 }, {
|
|
2466
2882
|
default: withCtx(() => [
|
|
2467
2883
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.data.items, (subItem, index) => {
|
|
2468
|
-
return openBlock(), createBlock(
|
|
2884
|
+
return openBlock(), createBlock(unref(TMagicDropdownItem), {
|
|
2469
2885
|
key: index,
|
|
2470
2886
|
command: { data: __props.data, subItem }
|
|
2471
2887
|
}, {
|
|
@@ -2480,9 +2896,9 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2480
2896
|
})) : createCommentVNode("", true)
|
|
2481
2897
|
]),
|
|
2482
2898
|
default: withCtx(() => [
|
|
2483
|
-
createElementVNode("span", _hoisted_2$
|
|
2899
|
+
createElementVNode("span", _hoisted_2$4, [
|
|
2484
2900
|
createTextVNode(toDisplayString(__props.data.text), 1),
|
|
2485
|
-
createVNode(
|
|
2901
|
+
createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
|
|
2486
2902
|
default: withCtx(() => [
|
|
2487
2903
|
createVNode(unref(ArrowDown))
|
|
2488
2904
|
]),
|
|
@@ -2497,8 +2913,11 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2497
2913
|
}
|
|
2498
2914
|
});
|
|
2499
2915
|
|
|
2500
|
-
const
|
|
2501
|
-
|
|
2916
|
+
const __default__$g = defineComponent({
|
|
2917
|
+
name: "MEditorNavMenu"
|
|
2918
|
+
});
|
|
2919
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
2920
|
+
...__default__$g,
|
|
2502
2921
|
props: {
|
|
2503
2922
|
data: { default: () => ({}) },
|
|
2504
2923
|
height: { default: 35 }
|
|
@@ -2653,7 +3072,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2653
3072
|
style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
|
|
2654
3073
|
}, [
|
|
2655
3074
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
|
|
2656
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3075
|
+
return openBlock(), createBlock(_sfc_main$i, {
|
|
2657
3076
|
data: item,
|
|
2658
3077
|
key: index
|
|
2659
3078
|
}, null, 8, ["data"]);
|
|
@@ -2665,9 +3084,12 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2665
3084
|
}
|
|
2666
3085
|
});
|
|
2667
3086
|
|
|
2668
|
-
const _hoisted_1$
|
|
2669
|
-
const
|
|
2670
|
-
|
|
3087
|
+
const _hoisted_1$8 = { class: "m-editor-props-panel" };
|
|
3088
|
+
const __default__$f = defineComponent({
|
|
3089
|
+
name: "MEditorPropsPanel"
|
|
3090
|
+
});
|
|
3091
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
3092
|
+
...__default__$f,
|
|
2671
3093
|
emits: ["mounted"],
|
|
2672
3094
|
setup(__props, { expose, emit }) {
|
|
2673
3095
|
const internalInstance = getCurrentInstance();
|
|
@@ -2703,19 +3125,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
2703
3125
|
services?.editorService.update(values2);
|
|
2704
3126
|
} catch (e) {
|
|
2705
3127
|
console.error(e);
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
duration: 1e4,
|
|
2709
|
-
showClose: true,
|
|
2710
|
-
message: e.message,
|
|
2711
|
-
dangerouslyUseHTMLString: true
|
|
2712
|
-
});
|
|
3128
|
+
tMagicMessage.closeAll();
|
|
3129
|
+
tMagicMessage.error(e.message);
|
|
2713
3130
|
}
|
|
2714
3131
|
};
|
|
2715
3132
|
expose({ submit });
|
|
2716
3133
|
return (_ctx, _cache) => {
|
|
2717
3134
|
const _component_m_form = resolveComponent("m-form");
|
|
2718
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3135
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
2719
3136
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
2720
3137
|
createVNode(_component_m_form, {
|
|
2721
3138
|
ref_key: "configForm",
|
|
@@ -2732,10 +3149,503 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
2732
3149
|
}
|
|
2733
3150
|
});
|
|
2734
3151
|
|
|
2735
|
-
const _hoisted_1$
|
|
2736
|
-
const _hoisted_2$
|
|
3152
|
+
const _hoisted_1$7 = ["id"];
|
|
3153
|
+
const _hoisted_2$3 = { class: "list-item" };
|
|
3154
|
+
const _hoisted_3$1 = { class: "code-name" };
|
|
3155
|
+
const _hoisted_4$1 = { class: "code-name-wrapper" };
|
|
3156
|
+
const _hoisted_5$1 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
|
|
3157
|
+
const _hoisted_6$1 = { class: "m-editor-wrapper" };
|
|
3158
|
+
const _hoisted_7$1 = {
|
|
3159
|
+
key: 1,
|
|
3160
|
+
class: "m-editor-content-bottom"
|
|
3161
|
+
};
|
|
3162
|
+
const _hoisted_8$1 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
|
|
3163
|
+
const _hoisted_9$1 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3164
|
+
const _hoisted_10 = {
|
|
3165
|
+
key: 2,
|
|
3166
|
+
class: "m-editor-content-bottom"
|
|
3167
|
+
};
|
|
3168
|
+
const _hoisted_11 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3169
|
+
const __default__$e = defineComponent({
|
|
3170
|
+
name: "MEditorCodeBlockEditor"
|
|
3171
|
+
});
|
|
3172
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
3173
|
+
...__default__$e,
|
|
3174
|
+
setup(__props) {
|
|
3175
|
+
const services = inject("services");
|
|
3176
|
+
const codeEditor = ref();
|
|
3177
|
+
const left = ref(200);
|
|
3178
|
+
const currentTitle = ref("");
|
|
3179
|
+
const codeConfig = ref(null);
|
|
3180
|
+
const state = reactive({
|
|
3181
|
+
codeList: []
|
|
3182
|
+
});
|
|
3183
|
+
const isShowCodeBlockEditor = computed(
|
|
3184
|
+
() => codeConfig.value && services?.codeBlockService.getCodeEditorShowStatus() || false
|
|
3185
|
+
);
|
|
3186
|
+
const mode = computed(() => services?.codeBlockService.getMode());
|
|
3187
|
+
const id = computed(() => services?.codeBlockService.getId() || "");
|
|
3188
|
+
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
3189
|
+
const selectedIds = computed(() => services?.codeBlockService.getCombineIds() || []);
|
|
3190
|
+
watchEffect(async () => {
|
|
3191
|
+
codeConfig.value = await services?.codeBlockService.getCodeContentById(id.value) || null;
|
|
3192
|
+
});
|
|
3193
|
+
watchEffect(async () => {
|
|
3194
|
+
const codeDsl = await services?.codeBlockService.getCodeDslByIds(selectedIds.value) || null;
|
|
3195
|
+
if (!codeDsl)
|
|
3196
|
+
return;
|
|
3197
|
+
state.codeList = [];
|
|
3198
|
+
forIn(codeDsl, (value, key) => {
|
|
3199
|
+
state.codeList.push({
|
|
3200
|
+
id: key,
|
|
3201
|
+
name: value.name
|
|
3202
|
+
});
|
|
3203
|
+
});
|
|
3204
|
+
currentTitle.value = state.codeList[0]?.name || "";
|
|
3205
|
+
});
|
|
3206
|
+
const saveCode = async () => {
|
|
3207
|
+
if (!codeEditor.value || !codeConfig.value || !editable.value)
|
|
3208
|
+
return true;
|
|
3209
|
+
try {
|
|
3210
|
+
const codeContent = codeEditor.value.getEditor()?.getValue();
|
|
3211
|
+
codeConfig.value.content = eval(codeContent);
|
|
3212
|
+
} catch (e) {
|
|
3213
|
+
tMagicMessage.error(e.stack);
|
|
3214
|
+
return false;
|
|
3215
|
+
}
|
|
3216
|
+
await services?.codeBlockService.setCodeDslById(id.value, {
|
|
3217
|
+
name: codeConfig.value.name,
|
|
3218
|
+
content: codeConfig.value.content
|
|
3219
|
+
});
|
|
3220
|
+
tMagicMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
|
|
3221
|
+
return true;
|
|
3222
|
+
};
|
|
3223
|
+
const saveAndClose = async () => {
|
|
3224
|
+
const saveRes = await saveCode();
|
|
3225
|
+
if (saveRes) {
|
|
3226
|
+
await services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3229
|
+
const selectHandler = (data) => {
|
|
3230
|
+
services?.codeBlockService.setId(data.id);
|
|
3231
|
+
currentTitle.value = data.name;
|
|
3232
|
+
};
|
|
3233
|
+
return (_ctx, _cache) => {
|
|
3234
|
+
return openBlock(), createBlock(unref(TMagicDialog), {
|
|
3235
|
+
modelValue: unref(isShowCodeBlockEditor),
|
|
3236
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(isShowCodeBlockEditor) ? isShowCodeBlockEditor.value = $event : null),
|
|
3237
|
+
class: "code-editor-dialog",
|
|
3238
|
+
title: currentTitle.value,
|
|
3239
|
+
fullscreen: true,
|
|
3240
|
+
"before-close": saveAndClose,
|
|
3241
|
+
"append-to-body": true
|
|
3242
|
+
}, {
|
|
3243
|
+
default: withCtx(() => [
|
|
3244
|
+
createVNode(_sfc_main$m, {
|
|
3245
|
+
left: left.value,
|
|
3246
|
+
"onUpdate:left": _cache[1] || (_cache[1] = ($event) => left.value = $event),
|
|
3247
|
+
"min-left": 45,
|
|
3248
|
+
class: "code-editor-layout"
|
|
3249
|
+
}, createSlots({
|
|
3250
|
+
center: withCtx(() => [
|
|
3251
|
+
!unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", {
|
|
3252
|
+
key: 0,
|
|
3253
|
+
class: normalizeClass([
|
|
3254
|
+
unref(mode) === unref(CodeEditorMode).LIST ? "m-editor-code-block-editor-panel-list-mode" : "m-editor-code-block-editor-panel"
|
|
3255
|
+
])
|
|
3256
|
+
}, [
|
|
3257
|
+
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: unref(id) }),
|
|
3258
|
+
createVNode(unref(TMagicCard), { shadow: "never" }, {
|
|
3259
|
+
header: withCtx(() => [
|
|
3260
|
+
createElementVNode("div", _hoisted_4$1, [
|
|
3261
|
+
_hoisted_5$1,
|
|
3262
|
+
codeConfig.value ? (openBlock(), createBlock(unref(TMagicInput), {
|
|
3263
|
+
key: 0,
|
|
3264
|
+
class: "code-name-input",
|
|
3265
|
+
modelValue: codeConfig.value.name,
|
|
3266
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => codeConfig.value.name = $event),
|
|
3267
|
+
disabled: !unref(editable)
|
|
3268
|
+
}, null, 8, ["modelValue", "disabled"])) : createCommentVNode("", true)
|
|
3269
|
+
])
|
|
3270
|
+
]),
|
|
3271
|
+
default: withCtx(() => [
|
|
3272
|
+
createElementVNode("div", _hoisted_6$1, [
|
|
3273
|
+
codeConfig.value ? (openBlock(), createBlock(_sfc_main$o, {
|
|
3274
|
+
key: 0,
|
|
3275
|
+
ref_key: "codeEditor",
|
|
3276
|
+
ref: codeEditor,
|
|
3277
|
+
class: "m-editor-container",
|
|
3278
|
+
"init-values": `${codeConfig.value.content}`,
|
|
3279
|
+
onSave: saveCode,
|
|
3280
|
+
options: {
|
|
3281
|
+
tabSize: 2,
|
|
3282
|
+
fontSize: 16,
|
|
3283
|
+
formatOnPaste: true,
|
|
3284
|
+
readOnly: !unref(editable)
|
|
3285
|
+
}
|
|
3286
|
+
}, null, 8, ["init-values", "options"])) : createCommentVNode("", true),
|
|
3287
|
+
unref(editable) ? (openBlock(), createElementBlock("div", _hoisted_7$1, [
|
|
3288
|
+
createVNode(unref(TMagicButton), {
|
|
3289
|
+
type: "primary",
|
|
3290
|
+
class: "button",
|
|
3291
|
+
onClick: saveCode
|
|
3292
|
+
}, {
|
|
3293
|
+
default: withCtx(() => [
|
|
3294
|
+
_hoisted_8$1
|
|
3295
|
+
]),
|
|
3296
|
+
_: 1
|
|
3297
|
+
}),
|
|
3298
|
+
createVNode(unref(TMagicButton), {
|
|
3299
|
+
type: "primary",
|
|
3300
|
+
class: "button",
|
|
3301
|
+
onClick: saveAndClose
|
|
3302
|
+
}, {
|
|
3303
|
+
default: withCtx(() => [
|
|
3304
|
+
_hoisted_9$1
|
|
3305
|
+
]),
|
|
3306
|
+
_: 1
|
|
3307
|
+
})
|
|
3308
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_10, [
|
|
3309
|
+
createVNode(unref(TMagicButton), {
|
|
3310
|
+
type: "primary",
|
|
3311
|
+
class: "button",
|
|
3312
|
+
onClick: saveAndClose
|
|
3313
|
+
}, {
|
|
3314
|
+
default: withCtx(() => [
|
|
3315
|
+
_hoisted_11
|
|
3316
|
+
]),
|
|
3317
|
+
_: 1
|
|
3318
|
+
})
|
|
3319
|
+
]))
|
|
3320
|
+
])
|
|
3321
|
+
]),
|
|
3322
|
+
_: 1
|
|
3323
|
+
})
|
|
3324
|
+
], 2)) : createCommentVNode("", true)
|
|
3325
|
+
]),
|
|
3326
|
+
_: 2
|
|
3327
|
+
}, [
|
|
3328
|
+
unref(mode) === unref(CodeEditorMode).LIST ? {
|
|
3329
|
+
name: "left",
|
|
3330
|
+
fn: withCtx(() => [
|
|
3331
|
+
!unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
3332
|
+
key: 0,
|
|
3333
|
+
class: "side-tree",
|
|
3334
|
+
"node-key": "id",
|
|
3335
|
+
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3336
|
+
data: state.codeList,
|
|
3337
|
+
"highlight-current": true,
|
|
3338
|
+
"current-node-key": state.codeList[0].id,
|
|
3339
|
+
onNodeClick: selectHandler
|
|
3340
|
+
}, {
|
|
3341
|
+
default: withCtx(({ data }) => [
|
|
3342
|
+
createElementVNode("div", {
|
|
3343
|
+
id: data.id,
|
|
3344
|
+
class: "list-container"
|
|
3345
|
+
}, [
|
|
3346
|
+
createElementVNode("div", _hoisted_2$3, [
|
|
3347
|
+
createElementVNode("div", _hoisted_3$1, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1)
|
|
3348
|
+
])
|
|
3349
|
+
], 8, _hoisted_1$7)
|
|
3350
|
+
]),
|
|
3351
|
+
_: 1
|
|
3352
|
+
}, 8, ["data", "current-node-key"])) : createCommentVNode("", true)
|
|
3353
|
+
])
|
|
3354
|
+
} : void 0
|
|
3355
|
+
]), 1032, ["left"])
|
|
3356
|
+
]),
|
|
3357
|
+
_: 3
|
|
3358
|
+
}, 8, ["modelValue", "title"]);
|
|
3359
|
+
};
|
|
3360
|
+
}
|
|
3361
|
+
});
|
|
3362
|
+
|
|
3363
|
+
const _hoisted_1$6 = { class: "m-editor-code-block-list" };
|
|
3364
|
+
const _hoisted_2$2 = { class: "code-header-wrapper" };
|
|
3365
|
+
const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u65B0\u589E");
|
|
3366
|
+
const _hoisted_4 = ["id"];
|
|
3367
|
+
const _hoisted_5 = { class: "list-item" };
|
|
3368
|
+
const _hoisted_6 = { class: "code-name" };
|
|
3369
|
+
const _hoisted_7 = { class: "right-tool" };
|
|
3370
|
+
const _hoisted_8 = {
|
|
3371
|
+
key: 0,
|
|
3372
|
+
class: "code-comp-map-wrapper"
|
|
3373
|
+
};
|
|
3374
|
+
const _hoisted_9 = /* @__PURE__ */ createElementVNode("svg", {
|
|
3375
|
+
class: "arrow-left",
|
|
3376
|
+
viewBox: "0 0 1024 1024",
|
|
3377
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3378
|
+
"data-v-029747aa": ""
|
|
3379
|
+
}, [
|
|
3380
|
+
/* @__PURE__ */ createElementVNode("path", {
|
|
3381
|
+
fill: "currentColor",
|
|
3382
|
+
d: "M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"
|
|
3383
|
+
})
|
|
3384
|
+
], -1);
|
|
3385
|
+
const __default__$d = defineComponent({
|
|
3386
|
+
name: "MEditorCodeBlockList"
|
|
3387
|
+
});
|
|
3388
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
3389
|
+
...__default__$d,
|
|
3390
|
+
props: {
|
|
3391
|
+
customError: null
|
|
3392
|
+
},
|
|
3393
|
+
setup(__props) {
|
|
3394
|
+
const props = __props;
|
|
3395
|
+
const services = inject("services");
|
|
3396
|
+
const state = reactive({
|
|
3397
|
+
codeList: [],
|
|
3398
|
+
bindComps: {}
|
|
3399
|
+
});
|
|
3400
|
+
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
3401
|
+
const getBindCompsByCodeId = (codeId, codeBlockContent) => {
|
|
3402
|
+
if (isEmpty(codeBlockContent) || isEmpty(codeBlockContent.comps)) {
|
|
3403
|
+
state.bindComps[codeId] = [];
|
|
3404
|
+
return;
|
|
3405
|
+
}
|
|
3406
|
+
const compsField = codeBlockContent.comps;
|
|
3407
|
+
const bindCompIds = Object.keys(compsField);
|
|
3408
|
+
const bindCompsFiltered = bindCompIds.filter((compId) => !isEmpty(compsField[compId]));
|
|
3409
|
+
const compsInfo = bindCompsFiltered.map((compId) => ({
|
|
3410
|
+
id: compId,
|
|
3411
|
+
name: getCompName(compId)
|
|
3412
|
+
}));
|
|
3413
|
+
state.bindComps[codeId] = compsInfo;
|
|
3414
|
+
};
|
|
3415
|
+
const initList = async () => {
|
|
3416
|
+
const codeDsl = await services?.codeBlockService.getCodeDsl() || null;
|
|
3417
|
+
if (!codeDsl)
|
|
3418
|
+
return;
|
|
3419
|
+
state.codeList = [];
|
|
3420
|
+
forIn(codeDsl, (value, codeId) => {
|
|
3421
|
+
getBindCompsByCodeId(codeId, value);
|
|
3422
|
+
state.codeList.push({
|
|
3423
|
+
id: codeId,
|
|
3424
|
+
name: value.name,
|
|
3425
|
+
codeBlockContent: value,
|
|
3426
|
+
showRelation: true
|
|
3427
|
+
});
|
|
3428
|
+
});
|
|
3429
|
+
};
|
|
3430
|
+
watch(
|
|
3431
|
+
() => services?.codeBlockService.getCodeDsl(),
|
|
3432
|
+
() => {
|
|
3433
|
+
initList();
|
|
3434
|
+
},
|
|
3435
|
+
{
|
|
3436
|
+
immediate: true,
|
|
3437
|
+
deep: true
|
|
3438
|
+
}
|
|
3439
|
+
);
|
|
3440
|
+
watch(
|
|
3441
|
+
() => services?.editorService.get("node"),
|
|
3442
|
+
(curNode) => {
|
|
3443
|
+
if (!curNode?.id)
|
|
3444
|
+
return;
|
|
3445
|
+
forIn(state.bindComps, (bindCompInfo) => {
|
|
3446
|
+
bindCompInfo.forEach((comp) => {
|
|
3447
|
+
if (comp.id === curNode.id) {
|
|
3448
|
+
comp.name = curNode.name;
|
|
3449
|
+
}
|
|
3450
|
+
});
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3453
|
+
);
|
|
3454
|
+
const createCodeBlock = async () => {
|
|
3455
|
+
const { codeBlockService } = services || {};
|
|
3456
|
+
if (!codeBlockService) {
|
|
3457
|
+
tMagicMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
|
|
3458
|
+
return;
|
|
3459
|
+
}
|
|
3460
|
+
const codeConfig = {
|
|
3461
|
+
name: "\u4EE3\u7801\u5757",
|
|
3462
|
+
content: `() => {
|
|
3463
|
+
// place your code here
|
|
3464
|
+
}`
|
|
3465
|
+
};
|
|
3466
|
+
await codeBlockService.setMode(CodeEditorMode.EDITOR);
|
|
3467
|
+
const id = await codeBlockService.getUniqueId();
|
|
3468
|
+
await codeBlockService.setCodeDslById(id, codeConfig);
|
|
3469
|
+
codeBlockService.setCodeEditorContent(true, id);
|
|
3470
|
+
};
|
|
3471
|
+
const editCode = async (key) => {
|
|
3472
|
+
await services?.codeBlockService.setMode(CodeEditorMode.EDITOR);
|
|
3473
|
+
services?.codeBlockService.setCodeEditorContent(true, key);
|
|
3474
|
+
};
|
|
3475
|
+
const deleteCode = (key) => {
|
|
3476
|
+
const existBinds = !!(state.bindComps[key]?.length > 0);
|
|
3477
|
+
const undeleteableList = services?.codeBlockService.getUndeletableList() || [];
|
|
3478
|
+
if (!existBinds && !undeleteableList.includes(key)) {
|
|
3479
|
+
services?.codeBlockService.deleteCodeDslByIds([key]);
|
|
3480
|
+
} else {
|
|
3481
|
+
if (typeof props.customError === "function") {
|
|
3482
|
+
props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
|
|
3483
|
+
} else {
|
|
3484
|
+
tMagicMessage.error("\u4EE3\u7801\u5757\u5220\u9664\u5931\u8D25");
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
};
|
|
3488
|
+
const filterText = ref("");
|
|
3489
|
+
const tree = ref();
|
|
3490
|
+
const filterNode = (value, data) => {
|
|
3491
|
+
if (!value) {
|
|
3492
|
+
return true;
|
|
3493
|
+
}
|
|
3494
|
+
return `${data.name}${data.id}`.indexOf(value) !== -1;
|
|
3495
|
+
};
|
|
3496
|
+
const filterTextChangeHandler = (val) => {
|
|
3497
|
+
tree.value?.filter(val);
|
|
3498
|
+
};
|
|
3499
|
+
const toggleCombineRelation = (data) => {
|
|
3500
|
+
const { id } = data;
|
|
3501
|
+
const currentCode = state.codeList.find((item) => item.id === id);
|
|
3502
|
+
if (!currentCode)
|
|
3503
|
+
return;
|
|
3504
|
+
currentCode.showRelation = !currentCode?.showRelation;
|
|
3505
|
+
};
|
|
3506
|
+
const getCompName = (compId) => {
|
|
3507
|
+
const node = services?.editorService.getNodeById(compId);
|
|
3508
|
+
return node?.name || String(compId);
|
|
3509
|
+
};
|
|
3510
|
+
const selectComp = (compId) => {
|
|
3511
|
+
const stage = services?.editorService.get("stage");
|
|
3512
|
+
services?.editorService.select(compId);
|
|
3513
|
+
stage?.select(compId);
|
|
3514
|
+
};
|
|
3515
|
+
return (_ctx, _cache) => {
|
|
3516
|
+
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
3517
|
+
renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
3518
|
+
createElementVNode("div", _hoisted_2$2, [
|
|
3519
|
+
createVNode(unref(TMagicInput), {
|
|
3520
|
+
class: normalizeClass([unref(editable) ? "code-filter-input" : "code-filter-input-no-btn"]),
|
|
3521
|
+
size: "small",
|
|
3522
|
+
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
3523
|
+
clearable: "",
|
|
3524
|
+
modelValue: filterText.value,
|
|
3525
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
|
|
3526
|
+
onInput: filterTextChangeHandler
|
|
3527
|
+
}, null, 8, ["class", "modelValue"]),
|
|
3528
|
+
unref(editable) ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
3529
|
+
key: 0,
|
|
3530
|
+
class: "create-code-button",
|
|
3531
|
+
type: "primary",
|
|
3532
|
+
size: "small",
|
|
3533
|
+
onClick: createCodeBlock
|
|
3534
|
+
}, {
|
|
3535
|
+
default: withCtx(() => [
|
|
3536
|
+
_hoisted_3
|
|
3537
|
+
]),
|
|
3538
|
+
_: 1
|
|
3539
|
+
})) : createCommentVNode("", true)
|
|
3540
|
+
])
|
|
3541
|
+
]),
|
|
3542
|
+
!unref(isEmpty)(state.codeList) ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
3543
|
+
key: 0,
|
|
3544
|
+
ref_key: "tree",
|
|
3545
|
+
ref: tree,
|
|
3546
|
+
"node-key": "id",
|
|
3547
|
+
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3548
|
+
data: state.codeList,
|
|
3549
|
+
"highlight-current": true,
|
|
3550
|
+
"filter-node-method": filterNode,
|
|
3551
|
+
onNodeClick: toggleCombineRelation
|
|
3552
|
+
}, {
|
|
3553
|
+
default: withCtx(({ data }) => [
|
|
3554
|
+
createElementVNode("div", {
|
|
3555
|
+
id: data.id,
|
|
3556
|
+
class: "list-container"
|
|
3557
|
+
}, [
|
|
3558
|
+
createElementVNode("div", _hoisted_5, [
|
|
3559
|
+
createElementVNode("div", _hoisted_6, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1),
|
|
3560
|
+
createElementVNode("div", _hoisted_7, [
|
|
3561
|
+
createVNode(unref(TMagicTooltip), {
|
|
3562
|
+
effect: "dark",
|
|
3563
|
+
content: unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
|
|
3564
|
+
placement: "bottom"
|
|
3565
|
+
}, {
|
|
3566
|
+
default: withCtx(() => [
|
|
3567
|
+
createVNode(_sfc_main$l, {
|
|
3568
|
+
icon: unref(editable) ? unref(Edit) : unref(View),
|
|
3569
|
+
class: "edit-icon",
|
|
3570
|
+
onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
3571
|
+
}, null, 8, ["icon", "onClick"])
|
|
3572
|
+
]),
|
|
3573
|
+
_: 2
|
|
3574
|
+
}, 1032, ["content"]),
|
|
3575
|
+
state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3576
|
+
key: 0,
|
|
3577
|
+
effect: "dark",
|
|
3578
|
+
content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
|
|
3579
|
+
placement: "bottom"
|
|
3580
|
+
}, {
|
|
3581
|
+
default: withCtx(() => [
|
|
3582
|
+
createVNode(_sfc_main$l, {
|
|
3583
|
+
icon: unref(Link),
|
|
3584
|
+
class: "edit-icon",
|
|
3585
|
+
onClick: withModifiers(($event) => toggleCombineRelation(data), ["stop"])
|
|
3586
|
+
}, null, 8, ["icon", "onClick"])
|
|
3587
|
+
]),
|
|
3588
|
+
_: 2
|
|
3589
|
+
}, 1024)) : createCommentVNode("", true),
|
|
3590
|
+
unref(editable) ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3591
|
+
key: 1,
|
|
3592
|
+
effect: "dark",
|
|
3593
|
+
content: "\u5220\u9664",
|
|
3594
|
+
placement: "bottom"
|
|
3595
|
+
}, {
|
|
3596
|
+
default: withCtx(() => [
|
|
3597
|
+
createVNode(_sfc_main$l, {
|
|
3598
|
+
icon: unref(Close),
|
|
3599
|
+
class: "edit-icon",
|
|
3600
|
+
onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
3601
|
+
}, null, 8, ["icon", "onClick"])
|
|
3602
|
+
]),
|
|
3603
|
+
_: 2
|
|
3604
|
+
}, 1024)) : createCommentVNode("", true),
|
|
3605
|
+
renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
3606
|
+
id: data.id,
|
|
3607
|
+
data: data.codeBlockContent
|
|
3608
|
+
})
|
|
3609
|
+
])
|
|
3610
|
+
]),
|
|
3611
|
+
data.showRelation && state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
3612
|
+
_hoisted_9,
|
|
3613
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(state.bindComps[data.id], (comp, index) => {
|
|
3614
|
+
return openBlock(), createBlock(unref(TMagicButton), {
|
|
3615
|
+
key: index,
|
|
3616
|
+
class: "code-comp",
|
|
3617
|
+
size: "small",
|
|
3618
|
+
plain: true,
|
|
3619
|
+
onClick: withModifiers(($event) => selectComp(comp.id), ["stop"])
|
|
3620
|
+
}, {
|
|
3621
|
+
default: withCtx(() => [
|
|
3622
|
+
createTextVNode(toDisplayString(comp.name), 1)
|
|
3623
|
+
]),
|
|
3624
|
+
_: 2
|
|
3625
|
+
}, 1032, ["onClick"]);
|
|
3626
|
+
}), 128))
|
|
3627
|
+
])) : createCommentVNode("", true)
|
|
3628
|
+
], 8, _hoisted_4)
|
|
3629
|
+
]),
|
|
3630
|
+
_: 3
|
|
3631
|
+
}, 8, ["data"])) : createCommentVNode("", true),
|
|
3632
|
+
createVNode(_sfc_main$f, null, {
|
|
3633
|
+
"code-block-edit-panel-header": withCtx(({ id }) => [
|
|
3634
|
+
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
3635
|
+
]),
|
|
3636
|
+
_: 3
|
|
3637
|
+
})
|
|
3638
|
+
]);
|
|
3639
|
+
};
|
|
3640
|
+
}
|
|
3641
|
+
});
|
|
3642
|
+
|
|
3643
|
+
const _hoisted_1$5 = ["onClick", "onDragstart"];
|
|
3644
|
+
const __default__$c = defineComponent({
|
|
3645
|
+
name: "MEditorComponentListPanel"
|
|
3646
|
+
});
|
|
2737
3647
|
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
2738
|
-
|
|
3648
|
+
...__default__$c,
|
|
2739
3649
|
setup(__props) {
|
|
2740
3650
|
const searchText = ref("");
|
|
2741
3651
|
const services = inject("services");
|
|
@@ -2748,7 +3658,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2748
3658
|
}))
|
|
2749
3659
|
);
|
|
2750
3660
|
const collapseValue = computed(
|
|
2751
|
-
() => Array(list.value?.length).fill(1).map((x, i) => i)
|
|
3661
|
+
() => Array(list.value?.length).fill(1).map((x, i) => `${i}`)
|
|
2752
3662
|
);
|
|
2753
3663
|
let timeout;
|
|
2754
3664
|
let clientX;
|
|
@@ -2800,36 +3710,31 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2800
3710
|
timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
|
|
2801
3711
|
};
|
|
2802
3712
|
return (_ctx, _cache) => {
|
|
2803
|
-
|
|
2804
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
2805
|
-
const _component_el_collapse_item = resolveComponent("el-collapse-item");
|
|
2806
|
-
const _component_el_collapse = resolveComponent("el-collapse");
|
|
2807
|
-
const _component_el_scrollbar = resolveComponent("el-scrollbar");
|
|
2808
|
-
return openBlock(), createBlock(_component_el_scrollbar, null, {
|
|
3713
|
+
return openBlock(), createBlock(unref(TMagicScrollbar), null, {
|
|
2809
3714
|
default: withCtx(() => [
|
|
2810
3715
|
renderSlot(_ctx.$slots, "component-list-panel-header"),
|
|
2811
|
-
createVNode(
|
|
3716
|
+
createVNode(unref(TMagicCollapse), {
|
|
2812
3717
|
class: "ui-component-panel",
|
|
2813
3718
|
"model-value": unref(collapseValue)
|
|
2814
3719
|
}, {
|
|
2815
3720
|
default: withCtx(() => [
|
|
2816
|
-
createVNode(
|
|
2817
|
-
"prefix-icon": "el-icon-search",
|
|
3721
|
+
createVNode(unref(TMagicInput), {
|
|
2818
3722
|
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
2819
3723
|
class: "search-input",
|
|
2820
3724
|
size: "small",
|
|
2821
3725
|
clearable: "",
|
|
3726
|
+
"prefix-icon": unref(Search),
|
|
2822
3727
|
modelValue: searchText.value,
|
|
2823
3728
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
|
|
2824
|
-
}, null, 8, ["modelValue"]),
|
|
3729
|
+
}, null, 8, ["prefix-icon", "modelValue"]),
|
|
2825
3730
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (group, index) => {
|
|
2826
3731
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
2827
|
-
group.items && group.items.length ? (openBlock(), createBlock(
|
|
3732
|
+
group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
|
|
2828
3733
|
key: index,
|
|
2829
|
-
name: index
|
|
3734
|
+
name: `${index}`
|
|
2830
3735
|
}, {
|
|
2831
3736
|
title: withCtx(() => [
|
|
2832
|
-
|
|
3737
|
+
createVNode(_sfc_main$l, { icon: unref(Grid) }, null, 8, ["icon"]),
|
|
2833
3738
|
createTextVNode(toDisplayString(group.title), 1)
|
|
2834
3739
|
]),
|
|
2835
3740
|
default: withCtx(() => [
|
|
@@ -2844,10 +3749,10 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2844
3749
|
onDrag: dragHandler
|
|
2845
3750
|
}, [
|
|
2846
3751
|
renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
2847
|
-
createVNode(_sfc_main$
|
|
3752
|
+
createVNode(_sfc_main$l, {
|
|
2848
3753
|
icon: item.icon
|
|
2849
3754
|
}, null, 8, ["icon"]),
|
|
2850
|
-
createVNode(
|
|
3755
|
+
createVNode(unref(TMagicTooltip), {
|
|
2851
3756
|
effect: "dark",
|
|
2852
3757
|
placement: "bottom",
|
|
2853
3758
|
content: item.text
|
|
@@ -2858,7 +3763,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2858
3763
|
_: 2
|
|
2859
3764
|
}, 1032, ["content"])
|
|
2860
3765
|
])
|
|
2861
|
-
], 40,
|
|
3766
|
+
], 40, _hoisted_1$5);
|
|
2862
3767
|
}), 128))
|
|
2863
3768
|
]),
|
|
2864
3769
|
_: 2
|
|
@@ -2875,8 +3780,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
2875
3780
|
}
|
|
2876
3781
|
});
|
|
2877
3782
|
|
|
3783
|
+
const __default__$b = defineComponent({
|
|
3784
|
+
name: "MEditorContentMenu"
|
|
3785
|
+
});
|
|
2878
3786
|
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
2879
|
-
|
|
3787
|
+
...__default__$b,
|
|
2880
3788
|
props: {
|
|
2881
3789
|
menuData: { default: () => [] },
|
|
2882
3790
|
isSubMenu: { type: Boolean, default: false }
|
|
@@ -2955,7 +3863,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
2955
3863
|
});
|
|
2956
3864
|
return (_ctx, _cache) => {
|
|
2957
3865
|
const _component_content_menu = resolveComponent("content-menu", true);
|
|
2958
|
-
return __props.menuData.length
|
|
3866
|
+
return __props.menuData.length ? withDirectives((openBlock(), createElementBlock("div", {
|
|
2959
3867
|
key: 0,
|
|
2960
3868
|
class: "magic-editor-content-menu",
|
|
2961
3869
|
ref_key: "menu",
|
|
@@ -2964,7 +3872,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
2964
3872
|
}, [
|
|
2965
3873
|
createElementVNode("div", null, [
|
|
2966
3874
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
2967
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3875
|
+
return openBlock(), createBlock(_sfc_main$i, {
|
|
2968
3876
|
"event-type": "mouseup",
|
|
2969
3877
|
data: item,
|
|
2970
3878
|
key: index,
|
|
@@ -2983,21 +3891,29 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
2983
3891
|
onHide: hide
|
|
2984
3892
|
}, null, 8, ["menu-data"])
|
|
2985
3893
|
]))
|
|
2986
|
-
], 4))
|
|
3894
|
+
], 4)), [
|
|
3895
|
+
[vShow, visible.value]
|
|
3896
|
+
]) : createCommentVNode("", true);
|
|
2987
3897
|
};
|
|
2988
3898
|
}
|
|
2989
3899
|
});
|
|
2990
3900
|
|
|
2991
|
-
const
|
|
2992
|
-
|
|
2993
|
-
|
|
3901
|
+
const __default__$a = defineComponent({
|
|
3902
|
+
name: "MEditorLayerMenu"
|
|
3903
|
+
});
|
|
3904
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
3905
|
+
...__default__$a,
|
|
3906
|
+
props: {
|
|
3907
|
+
layerContentMenu: null
|
|
3908
|
+
},
|
|
3909
|
+
setup(__props, { expose }) {
|
|
3910
|
+
const props = __props;
|
|
2994
3911
|
const services = inject("services");
|
|
2995
3912
|
const menu = ref();
|
|
2996
3913
|
const node = computed(() => services?.editorService.get("node"));
|
|
2997
3914
|
const isRoot = computed(() => node.value?.type === NodeType.ROOT);
|
|
2998
3915
|
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
2999
3916
|
const componentList = computed(() => services?.componentListService.getList() || []);
|
|
3000
|
-
const layerContentMenu = inject("layerContentMenu", []);
|
|
3001
3917
|
const createMenuItems = (group) => group.items.map((component) => ({
|
|
3002
3918
|
text: component.text,
|
|
3003
3919
|
type: "button",
|
|
@@ -3039,485 +3955,577 @@ const _sfc_main$b = defineComponent({
|
|
|
3039
3955
|
[]
|
|
3040
3956
|
) || [];
|
|
3041
3957
|
}
|
|
3042
|
-
return [];
|
|
3043
|
-
});
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3958
|
+
return [];
|
|
3959
|
+
});
|
|
3960
|
+
const menuData = computed(() => [
|
|
3961
|
+
{
|
|
3962
|
+
type: "button",
|
|
3963
|
+
text: "\u65B0\u589E",
|
|
3964
|
+
icon: markRaw(Plus),
|
|
3965
|
+
display: () => node.value?.items,
|
|
3966
|
+
items: getSubMenuData.value
|
|
3967
|
+
},
|
|
3968
|
+
{
|
|
3969
|
+
type: "button",
|
|
3970
|
+
text: "\u590D\u5236",
|
|
3971
|
+
icon: markRaw(DocumentCopy),
|
|
3972
|
+
display: () => !isRoot.value,
|
|
3973
|
+
handler: () => {
|
|
3974
|
+
node.value && services?.editorService.copy(node.value);
|
|
3975
|
+
}
|
|
3976
|
+
},
|
|
3977
|
+
{
|
|
3978
|
+
type: "button",
|
|
3979
|
+
text: "\u5220\u9664",
|
|
3980
|
+
icon: markRaw(Delete),
|
|
3981
|
+
display: () => !isRoot.value && !isPage.value,
|
|
3982
|
+
handler: () => {
|
|
3983
|
+
node.value && services?.editorService.remove(node.value);
|
|
3984
|
+
}
|
|
3985
|
+
},
|
|
3986
|
+
...props.layerContentMenu
|
|
3987
|
+
]);
|
|
3988
|
+
const show = (e) => {
|
|
3989
|
+
menu.value?.show(e);
|
|
3990
|
+
};
|
|
3991
|
+
expose({
|
|
3992
|
+
show
|
|
3993
|
+
});
|
|
3994
|
+
return (_ctx, _cache) => {
|
|
3995
|
+
return openBlock(), createBlock(_sfc_main$c, {
|
|
3996
|
+
"menu-data": unref(menuData),
|
|
3997
|
+
ref_key: "menu",
|
|
3998
|
+
ref: menu,
|
|
3999
|
+
style: { "overflow": "initial" }
|
|
4000
|
+
}, null, 8, ["menu-data"]);
|
|
4001
|
+
};
|
|
4002
|
+
}
|
|
4003
|
+
});
|
|
4004
|
+
|
|
4005
|
+
const _hoisted_1$4 = ["id", "onMouseenter"];
|
|
4006
|
+
const __default__$9 = defineComponent({
|
|
4007
|
+
name: "MEditorLayerPanel"
|
|
4008
|
+
});
|
|
4009
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
4010
|
+
...__default__$9,
|
|
4011
|
+
props: {
|
|
4012
|
+
layerContentMenu: null
|
|
4013
|
+
},
|
|
4014
|
+
setup(__props) {
|
|
4015
|
+
const throttleTime = 150;
|
|
4016
|
+
const services = inject("services");
|
|
4017
|
+
const tree = ref();
|
|
4018
|
+
const menu = ref();
|
|
4019
|
+
const editorService = services?.editorService;
|
|
4020
|
+
const page = computed(() => editorService?.get("page"));
|
|
4021
|
+
const values = computed(() => page.value ? [page.value] : []);
|
|
4022
|
+
const selectedNodes = ref([]);
|
|
4023
|
+
const selectedIds = computed(() => selectedNodes.value.map((node) => node.id));
|
|
4024
|
+
const isMultiSelectStatus = ref(false);
|
|
4025
|
+
const spliceNodeKey = ref();
|
|
4026
|
+
const filterText = ref("");
|
|
4027
|
+
const defaultExpandedKeys = computed(() => selectedIds.value.length > 0 ? selectedIds.value : []);
|
|
4028
|
+
editorService?.on("remove", () => {
|
|
4029
|
+
setTimeout(() => {
|
|
4030
|
+
tree.value?.getNode(editorService.get("node").id)?.updateChildren();
|
|
4031
|
+
}, 0);
|
|
4032
|
+
});
|
|
4033
|
+
const select = async (data) => {
|
|
4034
|
+
if (!data.id) {
|
|
4035
|
+
throw new Error("\u6CA1\u6709id");
|
|
4036
|
+
}
|
|
4037
|
+
await editorService?.select(data);
|
|
4038
|
+
editorService?.get("stage")?.select(data.id);
|
|
4039
|
+
};
|
|
4040
|
+
const multiSelect = async (data) => {
|
|
4041
|
+
await editorService?.multiSelect(data);
|
|
4042
|
+
editorService?.get("stage")?.multiSelect(data);
|
|
4043
|
+
};
|
|
4044
|
+
const highlight = (data) => {
|
|
4045
|
+
if (!data?.id) {
|
|
4046
|
+
throw new Error("\u6CA1\u6709id");
|
|
4047
|
+
}
|
|
4048
|
+
editorService?.highlight(data);
|
|
4049
|
+
editorService?.get("stage")?.highlight(data.id);
|
|
4050
|
+
};
|
|
4051
|
+
const expandedKeys = /* @__PURE__ */ new Map();
|
|
4052
|
+
const allowDrop = (draggingNode, dropNode, type) => {
|
|
4053
|
+
const { data } = dropNode || {};
|
|
4054
|
+
const { data: ingData } = draggingNode;
|
|
4055
|
+
const { type: ingType } = ingData;
|
|
4056
|
+
if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE)
|
|
4057
|
+
return false;
|
|
4058
|
+
if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
|
|
4059
|
+
return false;
|
|
4060
|
+
if (!data || !data.type)
|
|
4061
|
+
return false;
|
|
4062
|
+
if (["prev", "next"].includes(type))
|
|
4063
|
+
return true;
|
|
4064
|
+
if (data.items || data.type === "container")
|
|
4065
|
+
return true;
|
|
4066
|
+
return false;
|
|
4067
|
+
};
|
|
4068
|
+
const handleDragEnd = async (e) => {
|
|
4069
|
+
if (!tree.value)
|
|
4070
|
+
return;
|
|
4071
|
+
const { data: node } = e;
|
|
4072
|
+
const parent = editorService?.getParentById(node.id, false);
|
|
4073
|
+
const layout = await editorService?.getLayout(parent);
|
|
4074
|
+
node.style.position = layout;
|
|
4075
|
+
if (layout === Layout.RELATIVE) {
|
|
4076
|
+
node.style.top = 0;
|
|
4077
|
+
node.style.left = 0;
|
|
4078
|
+
}
|
|
4079
|
+
const data = tree.value.getData();
|
|
4080
|
+
const [page2] = data;
|
|
4081
|
+
editorService?.update(page2);
|
|
4082
|
+
};
|
|
4083
|
+
const loadItems = (node, resolve) => {
|
|
4084
|
+
if (Array.isArray(node.data)) {
|
|
4085
|
+
return resolve(node.data);
|
|
4086
|
+
}
|
|
4087
|
+
if (Array.isArray(node.data?.items)) {
|
|
4088
|
+
return resolve(node.data?.items);
|
|
4089
|
+
}
|
|
4090
|
+
resolve([]);
|
|
4091
|
+
};
|
|
4092
|
+
const handleCollapse = (data) => {
|
|
4093
|
+
expandedKeys.delete(data.id);
|
|
4094
|
+
};
|
|
4095
|
+
const handleExpand = (data) => {
|
|
4096
|
+
const parent = editorService?.getParentById(data.id);
|
|
4097
|
+
if (!parent?.id)
|
|
4098
|
+
return;
|
|
4099
|
+
expandedKeys.set(parent.id, parent.id);
|
|
4100
|
+
};
|
|
4101
|
+
const filterNode = (value, data) => {
|
|
4102
|
+
if (!value) {
|
|
4103
|
+
return true;
|
|
4104
|
+
}
|
|
4105
|
+
let name = "";
|
|
4106
|
+
if (data.name) {
|
|
4107
|
+
name = data.name;
|
|
4108
|
+
} else if (data.items) {
|
|
4109
|
+
name = "container";
|
|
3076
4110
|
}
|
|
4111
|
+
return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
|
|
3077
4112
|
};
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
const _component_content_menu = resolveComponent("content-menu");
|
|
3083
|
-
return openBlock(), createBlock(_component_content_menu, {
|
|
3084
|
-
"menu-data": _ctx.menuData,
|
|
3085
|
-
ref: "menu",
|
|
3086
|
-
style: { "overflow": "initial" }
|
|
3087
|
-
}, null, 8, ["menu-data"]);
|
|
3088
|
-
}
|
|
3089
|
-
const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
|
|
3090
|
-
|
|
3091
|
-
const throttleTime = 150;
|
|
3092
|
-
const select = async (data, editorService) => {
|
|
3093
|
-
if (!data.id) {
|
|
3094
|
-
throw new Error("\u6CA1\u6709id");
|
|
3095
|
-
}
|
|
3096
|
-
await editorService?.select(data);
|
|
3097
|
-
editorService?.get("stage")?.select(data.id);
|
|
3098
|
-
};
|
|
3099
|
-
const highlight = (data, editorService) => {
|
|
3100
|
-
if (!data?.id) {
|
|
3101
|
-
throw new Error("\u6CA1\u6709id");
|
|
3102
|
-
}
|
|
3103
|
-
editorService?.highlight(data);
|
|
3104
|
-
editorService?.get("stage")?.highlight(data.id);
|
|
3105
|
-
};
|
|
3106
|
-
const useDrop = (tree, editorService) => ({
|
|
3107
|
-
allowDrop: (draggingNode, dropNode, type) => {
|
|
3108
|
-
const { data } = dropNode || {};
|
|
3109
|
-
const { data: ingData } = draggingNode;
|
|
3110
|
-
const { type: ingType } = ingData;
|
|
3111
|
-
if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE)
|
|
3112
|
-
return false;
|
|
3113
|
-
if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
|
|
3114
|
-
return false;
|
|
3115
|
-
if (!data || !data.type)
|
|
3116
|
-
return false;
|
|
3117
|
-
if (["prev", "next"].includes(type))
|
|
3118
|
-
return true;
|
|
3119
|
-
if (data.items || data.type === "container")
|
|
3120
|
-
return true;
|
|
3121
|
-
return false;
|
|
3122
|
-
},
|
|
3123
|
-
async handleDragEnd(e) {
|
|
3124
|
-
if (!tree.value)
|
|
3125
|
-
return;
|
|
3126
|
-
const { data: node } = e;
|
|
3127
|
-
const parent = editorService?.getParentById(node.id, false);
|
|
3128
|
-
const layout = await editorService?.getLayout(parent);
|
|
3129
|
-
node.style.position = layout;
|
|
3130
|
-
if (layout === Layout.RELATIVE) {
|
|
3131
|
-
node.style.top = 0;
|
|
3132
|
-
node.style.left = 0;
|
|
3133
|
-
}
|
|
3134
|
-
const { data } = tree.value;
|
|
3135
|
-
const [page] = data;
|
|
3136
|
-
editorService?.update(page);
|
|
3137
|
-
}
|
|
3138
|
-
});
|
|
3139
|
-
const useStatus = (tree, editorService) => {
|
|
3140
|
-
const node = ref();
|
|
3141
|
-
const page = computed(() => editorService?.get("page"));
|
|
3142
|
-
const expandedKeys = /* @__PURE__ */ new Map();
|
|
3143
|
-
const expandNodes = () => {
|
|
3144
|
-
expandedKeys.forEach((key) => {
|
|
4113
|
+
const filterTextChangeHandler = (val) => {
|
|
4114
|
+
tree.value?.filter(val);
|
|
4115
|
+
};
|
|
4116
|
+
const expandNodes = async () => {
|
|
3145
4117
|
if (!tree.value)
|
|
3146
4118
|
return;
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
watchEffect(() => {
|
|
3151
|
-
if (!tree.value)
|
|
3152
|
-
return;
|
|
3153
|
-
if (!editorService)
|
|
3154
|
-
return;
|
|
3155
|
-
node.value = editorService.get("node");
|
|
3156
|
-
if (!node.value)
|
|
3157
|
-
return;
|
|
3158
|
-
tree.value.setCurrentKey(node.value.id, true);
|
|
3159
|
-
const parent = editorService.get("parent");
|
|
3160
|
-
if (!parent?.id)
|
|
3161
|
-
return;
|
|
3162
|
-
const treeNode = tree.value.getNode(parent.id);
|
|
3163
|
-
treeNode?.updateChildren();
|
|
3164
|
-
setTimeout(() => {
|
|
3165
|
-
tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
|
|
3166
|
-
if (node2.expanded && node2.data.items) {
|
|
4119
|
+
await nextTick();
|
|
4120
|
+
tree.value && Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]) => {
|
|
4121
|
+
if (node.expanded && node.data.items) {
|
|
3167
4122
|
expandedKeys.set(id, id);
|
|
3168
4123
|
}
|
|
3169
4124
|
});
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
4125
|
+
expandedKeys.forEach((key) => {
|
|
4126
|
+
if (!tree.value)
|
|
4127
|
+
return;
|
|
4128
|
+
tree.value.getNode(key)?.expand();
|
|
4129
|
+
});
|
|
4130
|
+
};
|
|
4131
|
+
watch(
|
|
4132
|
+
() => editorService?.get("nodes"),
|
|
4133
|
+
(nodes) => {
|
|
4134
|
+
selectedNodes.value = nodes ?? [];
|
|
3178
4135
|
}
|
|
3179
|
-
|
|
3180
|
-
|
|
4136
|
+
);
|
|
4137
|
+
const setTreeKeyStatus = () => {
|
|
4138
|
+
if (!tree.value)
|
|
4139
|
+
return;
|
|
4140
|
+
if (selectedIds.value.length === 0) {
|
|
4141
|
+
tree.value.setCheckedKeys([]);
|
|
4142
|
+
tree.value.setCurrentKey();
|
|
4143
|
+
} else if (selectedIds.value.length === 1 && !isMultiSelectStatus.value) {
|
|
4144
|
+
tree.value.setCurrentKey(selectedIds.value[0], true);
|
|
4145
|
+
tree.value.setCheckedKeys([]);
|
|
4146
|
+
} else {
|
|
4147
|
+
tree.value.setCheckedKeys(selectedIds.value);
|
|
4148
|
+
tree.value.setCurrentKey();
|
|
3181
4149
|
}
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
handleCollapse: (data) => {
|
|
3188
|
-
expandedKeys.delete(data.id);
|
|
3189
|
-
},
|
|
3190
|
-
handleExpand: (data) => {
|
|
3191
|
-
const parent = editorService?.getParentById(data.id);
|
|
4150
|
+
};
|
|
4151
|
+
watch([selectedIds, tree], async () => {
|
|
4152
|
+
if (!tree.value || !editorService)
|
|
4153
|
+
return;
|
|
4154
|
+
const parent = editorService.get("parent");
|
|
3192
4155
|
if (!parent?.id)
|
|
3193
4156
|
return;
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
}
|
|
3216
|
-
const
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
const tree = ref();
|
|
3222
|
-
const menu = ref();
|
|
4157
|
+
const treeNode = tree.value.getNode(parent.id);
|
|
4158
|
+
treeNode?.updateChildren();
|
|
4159
|
+
await expandNodes();
|
|
4160
|
+
setTreeKeyStatus();
|
|
4161
|
+
});
|
|
4162
|
+
const keycon = ref();
|
|
4163
|
+
const addSelectModeListener = () => {
|
|
4164
|
+
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4165
|
+
const ctrl = isMac ? "meta" : "ctrl";
|
|
4166
|
+
keycon.value = new KeyController();
|
|
4167
|
+
keycon.value.keydown(ctrl, (e) => {
|
|
4168
|
+
e.inputEvent.preventDefault();
|
|
4169
|
+
isMultiSelectStatus.value = true;
|
|
4170
|
+
});
|
|
4171
|
+
keycon.value.on("blur", () => {
|
|
4172
|
+
isMultiSelectStatus.value = false;
|
|
4173
|
+
});
|
|
4174
|
+
keycon.value.keyup(ctrl, (e) => {
|
|
4175
|
+
e.inputEvent.preventDefault();
|
|
4176
|
+
isMultiSelectStatus.value = false;
|
|
4177
|
+
});
|
|
4178
|
+
};
|
|
4179
|
+
const removeSelectModeListener = () => {
|
|
4180
|
+
keycon.value?.destroy();
|
|
4181
|
+
if (selectedIds.value.length === 1)
|
|
4182
|
+
isMultiSelectStatus.value = false;
|
|
4183
|
+
};
|
|
3223
4184
|
const clicked = ref(false);
|
|
3224
|
-
const
|
|
4185
|
+
const highlightNode = computed(() => editorService?.get("highlightNode"));
|
|
3225
4186
|
const highlightHandler = throttle((data) => {
|
|
3226
|
-
highlight(data
|
|
4187
|
+
highlight(data);
|
|
3227
4188
|
}, throttleTime);
|
|
3228
4189
|
const toggleClickFlag = () => {
|
|
3229
4190
|
clicked.value = !clicked.value;
|
|
3230
4191
|
};
|
|
3231
|
-
const
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
4192
|
+
const canHighlight = (data) => {
|
|
4193
|
+
if (clicked.value)
|
|
4194
|
+
return false;
|
|
4195
|
+
return data.id === highlightNode?.value?.id && !selectedIds.value.includes(data.id) && spliceNodeKey.value !== data.id;
|
|
4196
|
+
};
|
|
4197
|
+
watch(isMultiSelectStatus, () => {
|
|
4198
|
+
if (isMultiSelectStatus.value && selectedNodes.value.length === 1 && selectedNodes.value[0].type === NodeType.PAGE) {
|
|
4199
|
+
selectedNodes.value = [];
|
|
4200
|
+
}
|
|
3239
4201
|
});
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
4202
|
+
const multiClickHandler = (data) => {
|
|
4203
|
+
if (!data?.id) {
|
|
4204
|
+
throw new Error("\u6CA1\u6709id");
|
|
4205
|
+
}
|
|
4206
|
+
if (data.type === NodeType.PAGE) {
|
|
4207
|
+
tree.value?.setCheckedKeys([]);
|
|
4208
|
+
return;
|
|
4209
|
+
}
|
|
4210
|
+
const index = selectedNodes.value.findIndex((node) => node.id === data.id);
|
|
4211
|
+
if (index !== -1) {
|
|
4212
|
+
selectedNodes.value.splice(index, 1);
|
|
4213
|
+
spliceNodeKey.value = data.id;
|
|
4214
|
+
} else {
|
|
4215
|
+
selectedNodes.value = [...selectedNodes.value, data];
|
|
4216
|
+
}
|
|
4217
|
+
tree.value?.setCheckedKeys(selectedIds.value);
|
|
4218
|
+
multiSelect(selectedIds.value);
|
|
4219
|
+
};
|
|
4220
|
+
const clickHandler = (data) => {
|
|
4221
|
+
if (!isMultiSelectStatus.value) {
|
|
3250
4222
|
if (services?.uiService.get("uiSelectMode")) {
|
|
3251
4223
|
document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
|
|
3252
4224
|
return;
|
|
3253
4225
|
}
|
|
3254
4226
|
tree.value?.setCurrentKey(data.id);
|
|
3255
|
-
select(data
|
|
3256
|
-
}
|
|
3257
|
-
|
|
3258
|
-
event.preventDefault();
|
|
3259
|
-
await select(data, editorService);
|
|
3260
|
-
menu.value?.show(event);
|
|
4227
|
+
select(data);
|
|
4228
|
+
} else {
|
|
4229
|
+
multiClickHandler(data);
|
|
3261
4230
|
}
|
|
3262
4231
|
};
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
default: withCtx(() => [
|
|
3274
|
-
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
3275
|
-
createVNode(_component_el_input, {
|
|
3276
|
-
class: "filterInput",
|
|
3277
|
-
size: "small",
|
|
3278
|
-
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
3279
|
-
clearable: "",
|
|
3280
|
-
modelValue: _ctx.filterText,
|
|
3281
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.filterText = $event),
|
|
3282
|
-
onChange: _ctx.filterTextChangeHandler
|
|
3283
|
-
}, null, 8, ["modelValue", "onChange"]),
|
|
3284
|
-
_ctx.values.length ? (openBlock(), createBlock(_component_el_tree, {
|
|
3285
|
-
key: 0,
|
|
3286
|
-
ref: "tree",
|
|
3287
|
-
"node-key": "id",
|
|
3288
|
-
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
3289
|
-
draggable: "",
|
|
3290
|
-
"default-expanded-keys": _ctx.expandedKeys,
|
|
3291
|
-
load: _ctx.loadItems,
|
|
3292
|
-
data: _ctx.values,
|
|
3293
|
-
"expand-on-click-node": false,
|
|
3294
|
-
"highlight-current": true,
|
|
3295
|
-
props: {
|
|
3296
|
-
children: "items"
|
|
3297
|
-
},
|
|
3298
|
-
"filter-node-method": _ctx.filterNode,
|
|
3299
|
-
"allow-drop": _ctx.allowDrop,
|
|
3300
|
-
onNodeClick: _ctx.clickHandler,
|
|
3301
|
-
onNodeContextmenu: _ctx.contextmenu,
|
|
3302
|
-
onNodeDragEnd: _ctx.handleDragEnd,
|
|
3303
|
-
onNodeCollapse: _ctx.handleCollapse,
|
|
3304
|
-
onNodeExpand: _ctx.handleExpand
|
|
4232
|
+
const contextmenu = async (event, data) => {
|
|
4233
|
+
event.preventDefault();
|
|
4234
|
+
await select(data);
|
|
4235
|
+
menu.value?.show(event);
|
|
4236
|
+
};
|
|
4237
|
+
return (_ctx, _cache) => {
|
|
4238
|
+
return openBlock(), createBlock(unref(TMagicScrollbar), {
|
|
4239
|
+
class: "magic-editor-layer-panel",
|
|
4240
|
+
onMouseenter: addSelectModeListener,
|
|
4241
|
+
onMouseleave: removeSelectModeListener
|
|
3305
4242
|
}, {
|
|
3306
|
-
default: withCtx((
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
4243
|
+
default: withCtx(() => [
|
|
4244
|
+
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
4245
|
+
createVNode(unref(TMagicInput), {
|
|
4246
|
+
modelValue: filterText.value,
|
|
4247
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
|
|
4248
|
+
class: "search-input",
|
|
4249
|
+
size: "small",
|
|
4250
|
+
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
4251
|
+
clearable: "",
|
|
4252
|
+
"prefix-icon": unref(Search),
|
|
4253
|
+
onChange: filterTextChangeHandler
|
|
4254
|
+
}, null, 8, ["modelValue", "prefix-icon"]),
|
|
4255
|
+
unref(values).length ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
4256
|
+
key: 0,
|
|
4257
|
+
class: "magic-editor-layer-tree",
|
|
4258
|
+
ref_key: "tree",
|
|
4259
|
+
ref: tree,
|
|
4260
|
+
"node-key": "id",
|
|
4261
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
4262
|
+
draggable: "",
|
|
4263
|
+
"default-expanded-keys": unref(defaultExpandedKeys),
|
|
4264
|
+
load: loadItems,
|
|
4265
|
+
data: unref(values),
|
|
4266
|
+
"expand-on-click-node": false,
|
|
4267
|
+
"highlight-current": true,
|
|
4268
|
+
props: {
|
|
4269
|
+
children: "items"
|
|
4270
|
+
},
|
|
4271
|
+
"filter-node-method": filterNode,
|
|
4272
|
+
"allow-drop": allowDrop,
|
|
4273
|
+
"show-checkbox": isMultiSelectStatus.value || unref(selectedIds).length > 1,
|
|
4274
|
+
onNodeClick: clickHandler,
|
|
4275
|
+
onNodeContextmenu: contextmenu,
|
|
4276
|
+
onNodeDragEnd: handleDragEnd,
|
|
4277
|
+
onNodeCollapse: handleCollapse,
|
|
4278
|
+
onNodeExpand: handleExpand,
|
|
4279
|
+
onCheck: multiClickHandler,
|
|
4280
|
+
onMousedown: toggleClickFlag,
|
|
4281
|
+
onMouseup: toggleClickFlag
|
|
4282
|
+
}, {
|
|
4283
|
+
default: withCtx(({ node, data }) => [
|
|
4284
|
+
createElementVNode("div", {
|
|
4285
|
+
id: data.id,
|
|
4286
|
+
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": canHighlight(data) }]),
|
|
4287
|
+
onMouseenter: ($event) => unref(highlightHandler)(data)
|
|
4288
|
+
}, [
|
|
4289
|
+
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4290
|
+
node,
|
|
4291
|
+
data
|
|
4292
|
+
}, () => [
|
|
4293
|
+
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
4294
|
+
])
|
|
4295
|
+
], 42, _hoisted_1$4)
|
|
4296
|
+
]),
|
|
4297
|
+
_: 3
|
|
4298
|
+
}, 8, ["default-expanded-keys", "data", "show-checkbox"])) : createCommentVNode("", true),
|
|
4299
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4300
|
+
createVNode(_sfc_main$b, {
|
|
4301
|
+
ref_key: "menu",
|
|
4302
|
+
ref: menu,
|
|
4303
|
+
"layer-content-menu": __props.layerContentMenu
|
|
4304
|
+
}, null, 8, ["layer-content-menu"])
|
|
4305
|
+
]))
|
|
3321
4306
|
]),
|
|
3322
4307
|
_: 3
|
|
3323
|
-
}
|
|
3324
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
3325
|
-
createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
|
|
3326
|
-
]))
|
|
3327
|
-
]),
|
|
3328
|
-
_: 3
|
|
3329
|
-
});
|
|
3330
|
-
}
|
|
3331
|
-
const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
|
|
3332
|
-
|
|
3333
|
-
const _sfc_main$9 = defineComponent({
|
|
3334
|
-
components: { MIcon: _sfc_main$h },
|
|
3335
|
-
props: {
|
|
3336
|
-
data: {
|
|
3337
|
-
type: [Object, String]
|
|
3338
|
-
}
|
|
3339
|
-
},
|
|
3340
|
-
setup(props) {
|
|
3341
|
-
return {
|
|
3342
|
-
config: computed(() => {
|
|
3343
|
-
if (typeof props.data !== "string") {
|
|
3344
|
-
return props.data;
|
|
3345
|
-
}
|
|
3346
|
-
switch (props.data) {
|
|
3347
|
-
case "component-list":
|
|
3348
|
-
return {
|
|
3349
|
-
type: "component",
|
|
3350
|
-
icon: Coin,
|
|
3351
|
-
text: "\u7EC4\u4EF6",
|
|
3352
|
-
component: _sfc_main$d,
|
|
3353
|
-
slots: {}
|
|
3354
|
-
};
|
|
3355
|
-
case "layer":
|
|
3356
|
-
return {
|
|
3357
|
-
type: "component",
|
|
3358
|
-
icon: Files,
|
|
3359
|
-
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
3360
|
-
component: LayerPanel,
|
|
3361
|
-
slots: {}
|
|
3362
|
-
};
|
|
3363
|
-
default:
|
|
3364
|
-
return void 0;
|
|
3365
|
-
}
|
|
3366
|
-
})
|
|
4308
|
+
});
|
|
3367
4309
|
};
|
|
3368
4310
|
}
|
|
3369
4311
|
});
|
|
3370
4312
|
|
|
3371
|
-
const _hoisted_1$
|
|
4313
|
+
const _hoisted_1$3 = {
|
|
3372
4314
|
key: 1,
|
|
3373
4315
|
class: "magic-editor-tab-panel-title"
|
|
3374
4316
|
};
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
name: _ctx.config.text
|
|
3381
|
-
}, {
|
|
3382
|
-
label: withCtx(() => [
|
|
3383
|
-
(openBlock(), createElementBlock("div", {
|
|
3384
|
-
key: _ctx.config.text
|
|
3385
|
-
}, [
|
|
3386
|
-
_ctx.config.icon ? (openBlock(), createBlock(_component_m_icon, {
|
|
3387
|
-
key: 0,
|
|
3388
|
-
icon: _ctx.config.icon
|
|
3389
|
-
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
3390
|
-
_ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$2, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
|
|
3391
|
-
]))
|
|
3392
|
-
]),
|
|
3393
|
-
default: withCtx(() => [
|
|
3394
|
-
(openBlock(), createBlock(resolveDynamicComponent(_ctx.config.component), mergeProps(_ctx.config.props || {}, toHandlers(_ctx.config?.listeners || {})), createSlots({ _: 2 }, [
|
|
3395
|
-
_ctx.data === "component-list" || _ctx.config.slots?.componentListPanelHeader ? {
|
|
3396
|
-
name: "component-list-panel-header",
|
|
3397
|
-
fn: withCtx(() => [
|
|
3398
|
-
_ctx.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : _ctx.config.slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
3399
|
-
])
|
|
3400
|
-
} : void 0,
|
|
3401
|
-
_ctx.data === "component-list" || _ctx.config.slots?.componentListItem ? {
|
|
3402
|
-
name: "component-list-item",
|
|
3403
|
-
fn: withCtx(({ component }) => [
|
|
3404
|
-
_ctx.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
|
|
3405
|
-
key: 0,
|
|
3406
|
-
component
|
|
3407
|
-
}) : _ctx.config.slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.componentListItem), {
|
|
3408
|
-
key: 1,
|
|
3409
|
-
component
|
|
3410
|
-
}, null, 8, ["component"])) : createCommentVNode("", true)
|
|
3411
|
-
])
|
|
3412
|
-
} : void 0,
|
|
3413
|
-
_ctx.data === "layer" || _ctx.config.slots?.layerPanelHeader ? {
|
|
3414
|
-
name: "layer-panel-header",
|
|
3415
|
-
fn: withCtx(() => [
|
|
3416
|
-
_ctx.data === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : _ctx.config.slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.layerPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
3417
|
-
])
|
|
3418
|
-
} : void 0,
|
|
3419
|
-
_ctx.data === "layer" || _ctx.config.slots?.layerNodeContent ? {
|
|
3420
|
-
name: "layer-node-content",
|
|
3421
|
-
fn: withCtx(({ data: nodeData, node }) => [
|
|
3422
|
-
_ctx.data === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
|
|
3423
|
-
key: 0,
|
|
3424
|
-
data: nodeData,
|
|
3425
|
-
node
|
|
3426
|
-
}) : _ctx.config.slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.layerNodeContent), {
|
|
3427
|
-
key: 1,
|
|
3428
|
-
data: nodeData,
|
|
3429
|
-
node
|
|
3430
|
-
}, null, 8, ["data", "node"])) : createCommentVNode("", true)
|
|
3431
|
-
])
|
|
3432
|
-
} : void 0
|
|
3433
|
-
]), 1040))
|
|
3434
|
-
]),
|
|
3435
|
-
_: 3
|
|
3436
|
-
}, 8, ["name"])) : createCommentVNode("", true);
|
|
3437
|
-
}
|
|
3438
|
-
const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
|
|
3439
|
-
|
|
3440
|
-
const _sfc_main$8 = defineComponent({
|
|
3441
|
-
components: { TabPane },
|
|
3442
|
-
name: "m-sidebar",
|
|
4317
|
+
const __default__$8 = defineComponent({
|
|
4318
|
+
name: "MEditorSidebar"
|
|
4319
|
+
});
|
|
4320
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
4321
|
+
...__default__$8,
|
|
3443
4322
|
props: {
|
|
3444
|
-
data: {
|
|
3445
|
-
|
|
3446
|
-
default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
|
|
3447
|
-
}
|
|
4323
|
+
data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) },
|
|
4324
|
+
layerContentMenu: null
|
|
3448
4325
|
},
|
|
3449
|
-
setup(
|
|
4326
|
+
setup(__props, { expose }) {
|
|
4327
|
+
const props = __props;
|
|
4328
|
+
const uiComponent = getConfig$1("components").tabPane;
|
|
3450
4329
|
const activeTabName = ref(props.data?.status);
|
|
4330
|
+
const getItemConfig = (data) => {
|
|
4331
|
+
const map = {
|
|
4332
|
+
"component-list": {
|
|
4333
|
+
$key: "component-list",
|
|
4334
|
+
type: "component",
|
|
4335
|
+
icon: Coin,
|
|
4336
|
+
text: "\u7EC4\u4EF6",
|
|
4337
|
+
component: _sfc_main$d,
|
|
4338
|
+
slots: {}
|
|
4339
|
+
},
|
|
4340
|
+
layer: {
|
|
4341
|
+
$key: "layer",
|
|
4342
|
+
type: "component",
|
|
4343
|
+
icon: Files,
|
|
4344
|
+
text: "\u5DF2\u9009\u7EC4\u4EF6",
|
|
4345
|
+
props: {
|
|
4346
|
+
layerContentMenu: props.layerContentMenu
|
|
4347
|
+
},
|
|
4348
|
+
component: _sfc_main$a,
|
|
4349
|
+
slots: {}
|
|
4350
|
+
},
|
|
4351
|
+
"code-block": {
|
|
4352
|
+
$key: "code-block",
|
|
4353
|
+
type: "component",
|
|
4354
|
+
icon: EditPen,
|
|
4355
|
+
text: "\u4EE3\u7801\u7F16\u8F91",
|
|
4356
|
+
component: _sfc_main$e,
|
|
4357
|
+
slots: {}
|
|
4358
|
+
}
|
|
4359
|
+
};
|
|
4360
|
+
return typeof data === "string" ? map[data] : data;
|
|
4361
|
+
};
|
|
4362
|
+
const sideBarItems = computed(() => props.data.items.map((item) => getItemConfig(item)));
|
|
3451
4363
|
watch(
|
|
3452
|
-
() => props.data
|
|
4364
|
+
() => props.data.status,
|
|
3453
4365
|
(status) => {
|
|
3454
4366
|
activeTabName.value = status || "0";
|
|
3455
4367
|
}
|
|
3456
4368
|
);
|
|
3457
|
-
|
|
4369
|
+
expose({
|
|
3458
4370
|
activeTabName
|
|
4371
|
+
});
|
|
4372
|
+
return (_ctx, _cache) => {
|
|
4373
|
+
return __props.data.type === "tabs" && __props.data.items.length ? (openBlock(), createBlock(unref(TMagicTabs), {
|
|
4374
|
+
key: 0,
|
|
4375
|
+
class: "m-editor-sidebar",
|
|
4376
|
+
modelValue: activeTabName.value,
|
|
4377
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event),
|
|
4378
|
+
type: "card",
|
|
4379
|
+
"tab-position": "left"
|
|
4380
|
+
}, {
|
|
4381
|
+
default: withCtx(() => [
|
|
4382
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(sideBarItems), (config, index) => {
|
|
4383
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(uiComponent).component), {
|
|
4384
|
+
key: index,
|
|
4385
|
+
name: config.text
|
|
4386
|
+
}, {
|
|
4387
|
+
label: withCtx(() => [
|
|
4388
|
+
(openBlock(), createElementBlock("div", {
|
|
4389
|
+
key: config.text
|
|
4390
|
+
}, [
|
|
4391
|
+
config.icon ? (openBlock(), createBlock(_sfc_main$l, {
|
|
4392
|
+
key: 0,
|
|
4393
|
+
icon: config.icon
|
|
4394
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
4395
|
+
config.text ? (openBlock(), createElementBlock("div", _hoisted_1$3, toDisplayString(config.text), 1)) : createCommentVNode("", true)
|
|
4396
|
+
]))
|
|
4397
|
+
]),
|
|
4398
|
+
default: withCtx(() => [
|
|
4399
|
+
config ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({ key: 0 }, config.props || {}, toHandlers(config?.listeners || {})), createSlots({ _: 2 }, [
|
|
4400
|
+
config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
|
|
4401
|
+
name: "component-list-panel-header",
|
|
4402
|
+
fn: withCtx(() => [
|
|
4403
|
+
config.$key === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : config.slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4404
|
+
])
|
|
4405
|
+
} : void 0,
|
|
4406
|
+
config.$key === "component-list" || config.slots?.componentListItem ? {
|
|
4407
|
+
name: "component-list-item",
|
|
4408
|
+
fn: withCtx(({ component }) => [
|
|
4409
|
+
config.$key === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
|
|
4410
|
+
key: 0,
|
|
4411
|
+
component
|
|
4412
|
+
}) : config.slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentListItem), {
|
|
4413
|
+
key: 1,
|
|
4414
|
+
component
|
|
4415
|
+
}, null, 8, ["component"])) : createCommentVNode("", true)
|
|
4416
|
+
])
|
|
4417
|
+
} : void 0,
|
|
4418
|
+
config.$key === "layer" || config.slots?.layerPanelHeader ? {
|
|
4419
|
+
name: "layer-panel-header",
|
|
4420
|
+
fn: withCtx(() => [
|
|
4421
|
+
config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : config.slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4422
|
+
])
|
|
4423
|
+
} : void 0,
|
|
4424
|
+
config.$key === "code-block" || config.slots?.codeBlockPanelHeader ? {
|
|
4425
|
+
name: "code-block-panel-header",
|
|
4426
|
+
fn: withCtx(() => [
|
|
4427
|
+
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : config.slots?.codeBlockPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4428
|
+
])
|
|
4429
|
+
} : void 0,
|
|
4430
|
+
config.$key === "code-block" || config.slots?.codeBlockPanelTool ? {
|
|
4431
|
+
name: "code-block-panel-tool",
|
|
4432
|
+
fn: withCtx(({ id, data }) => [
|
|
4433
|
+
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4434
|
+
key: 0,
|
|
4435
|
+
id,
|
|
4436
|
+
data
|
|
4437
|
+
}) : config.slots?.codeBlockPanelTool ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelTool), { key: 1 })) : createCommentVNode("", true)
|
|
4438
|
+
])
|
|
4439
|
+
} : void 0,
|
|
4440
|
+
config.$key === "code-block" || config.slots?.codeBlockEditPanelHeader ? {
|
|
4441
|
+
name: "code-block-edit-panel-header",
|
|
4442
|
+
fn: withCtx(({ id }) => [
|
|
4443
|
+
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
|
|
4444
|
+
key: 0,
|
|
4445
|
+
id
|
|
4446
|
+
}) : config.slots?.codeBlockEditPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockEditPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
4447
|
+
])
|
|
4448
|
+
} : void 0,
|
|
4449
|
+
config.$key === "layer" || config.slots?.layerNodeContent ? {
|
|
4450
|
+
name: "layer-node-content",
|
|
4451
|
+
fn: withCtx(({ data: nodeData, node }) => [
|
|
4452
|
+
config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4453
|
+
key: 0,
|
|
4454
|
+
data: nodeData,
|
|
4455
|
+
node
|
|
4456
|
+
}) : config.slots?.layerNodeContent ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerNodeContent), {
|
|
4457
|
+
key: 1,
|
|
4458
|
+
data: nodeData,
|
|
4459
|
+
node
|
|
4460
|
+
}, null, 8, ["data", "node"])) : createCommentVNode("", true)
|
|
4461
|
+
])
|
|
4462
|
+
} : void 0
|
|
4463
|
+
]), 1040)) : createCommentVNode("", true)
|
|
4464
|
+
]),
|
|
4465
|
+
_: 2
|
|
4466
|
+
}, 1032, ["name"]);
|
|
4467
|
+
}), 128))
|
|
4468
|
+
]),
|
|
4469
|
+
_: 3
|
|
4470
|
+
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
3459
4471
|
};
|
|
3460
4472
|
}
|
|
3461
4473
|
});
|
|
3462
4474
|
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
])
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
]), 1032, ["data"]);
|
|
3508
|
-
}), 128))
|
|
3509
|
-
]),
|
|
3510
|
-
_: 3
|
|
3511
|
-
}, 8, ["modelValue"])) : createCommentVNode("", true);
|
|
3512
|
-
}
|
|
3513
|
-
const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
|
|
4475
|
+
const _hoisted_1$2 = {
|
|
4476
|
+
key: 0,
|
|
4477
|
+
class: "m-editor-breadcrumb"
|
|
4478
|
+
};
|
|
4479
|
+
const _hoisted_2$1 = { key: 0 };
|
|
4480
|
+
const __default__$7 = defineComponent({
|
|
4481
|
+
name: "MEditorBreadcrumb"
|
|
4482
|
+
});
|
|
4483
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
4484
|
+
...__default__$7,
|
|
4485
|
+
setup(__props) {
|
|
4486
|
+
const services = inject("services");
|
|
4487
|
+
const editorService = services?.editorService;
|
|
4488
|
+
const node = computed(() => editorService?.get("node"));
|
|
4489
|
+
const nodes = computed(() => editorService?.get("nodes") || []);
|
|
4490
|
+
const root = computed(() => editorService?.get("root"));
|
|
4491
|
+
const path = computed(() => getNodePath(node.value?.id || "", root.value?.items || []));
|
|
4492
|
+
const select = async (node2) => {
|
|
4493
|
+
await editorService?.select(node2);
|
|
4494
|
+
editorService?.get("stage")?.select(node2.id);
|
|
4495
|
+
};
|
|
4496
|
+
return (_ctx, _cache) => {
|
|
4497
|
+
return unref(nodes).length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
4498
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(path), (item, index) => {
|
|
4499
|
+
return openBlock(), createElementBlock(Fragment, {
|
|
4500
|
+
key: item.id
|
|
4501
|
+
}, [
|
|
4502
|
+
createVNode(unref(TMagicButton), {
|
|
4503
|
+
text: "",
|
|
4504
|
+
disabled: item.id === unref(node)?.id,
|
|
4505
|
+
onClick: ($event) => select(item)
|
|
4506
|
+
}, {
|
|
4507
|
+
default: withCtx(() => [
|
|
4508
|
+
createTextVNode(toDisplayString(item.name), 1)
|
|
4509
|
+
]),
|
|
4510
|
+
_: 2
|
|
4511
|
+
}, 1032, ["disabled", "onClick"]),
|
|
4512
|
+
index < unref(path).length - 1 ? (openBlock(), createElementBlock("span", _hoisted_2$1, "/")) : createCommentVNode("", true)
|
|
4513
|
+
], 64);
|
|
4514
|
+
}), 128))
|
|
4515
|
+
])) : createCommentVNode("", true);
|
|
4516
|
+
};
|
|
4517
|
+
}
|
|
4518
|
+
});
|
|
3514
4519
|
|
|
3515
4520
|
const _hoisted_1$1 = {
|
|
3516
4521
|
key: 1,
|
|
3517
4522
|
style: { "width": "21px" }
|
|
3518
4523
|
};
|
|
4524
|
+
const __default__$6 = defineComponent({
|
|
4525
|
+
name: "MEditorPageBarScrollContainer"
|
|
4526
|
+
});
|
|
3519
4527
|
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
3520
|
-
|
|
4528
|
+
...__default__$6,
|
|
3521
4529
|
setup(__props) {
|
|
3522
4530
|
const services = inject("services");
|
|
3523
4531
|
const editorService = services?.editorService;
|
|
@@ -3598,14 +4606,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
3598
4606
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3599
4607
|
onClick: addPage
|
|
3600
4608
|
}, [
|
|
3601
|
-
createVNode(_sfc_main$
|
|
4609
|
+
createVNode(_sfc_main$l, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
3602
4610
|
])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
|
|
3603
4611
|
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
3604
4612
|
key: 2,
|
|
3605
4613
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3606
4614
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
3607
4615
|
}, [
|
|
3608
|
-
createVNode(_sfc_main$
|
|
4616
|
+
createVNode(_sfc_main$l, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
|
|
3609
4617
|
])) : createCommentVNode("", true),
|
|
3610
4618
|
unref(pageLength) ? (openBlock(), createElementBlock("div", {
|
|
3611
4619
|
key: 3,
|
|
@@ -3621,7 +4629,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
3621
4629
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
3622
4630
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
3623
4631
|
}, [
|
|
3624
|
-
createVNode(_sfc_main$
|
|
4632
|
+
createVNode(_sfc_main$l, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
|
|
3625
4633
|
])) : createCommentVNode("", true)
|
|
3626
4634
|
], 512);
|
|
3627
4635
|
};
|
|
@@ -3630,8 +4638,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
3630
4638
|
|
|
3631
4639
|
const _hoisted_1 = ["onClick"];
|
|
3632
4640
|
const _hoisted_2 = { class: "m-editor-page-bar-title" };
|
|
4641
|
+
const __default__$5 = defineComponent({
|
|
4642
|
+
name: "MEditorPageBar"
|
|
4643
|
+
});
|
|
3633
4644
|
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
3634
|
-
|
|
4645
|
+
...__default__$5,
|
|
3635
4646
|
setup(__props) {
|
|
3636
4647
|
const services = inject("services");
|
|
3637
4648
|
const editorService = services?.editorService;
|
|
@@ -3651,9 +4662,6 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3651
4662
|
editorService?.remove(node);
|
|
3652
4663
|
};
|
|
3653
4664
|
return (_ctx, _cache) => {
|
|
3654
|
-
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
3655
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
3656
|
-
const _component_el_popover = resolveComponent("el-popover");
|
|
3657
4665
|
return openBlock(), createBlock(_sfc_main$7, null, {
|
|
3658
4666
|
default: withCtx(() => [
|
|
3659
4667
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(root) && unref(root).items || [], (item) => {
|
|
@@ -3664,7 +4672,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3664
4672
|
}, [
|
|
3665
4673
|
createElementVNode("div", _hoisted_2, [
|
|
3666
4674
|
renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
|
|
3667
|
-
createVNode(
|
|
4675
|
+
createVNode(unref(TMagicTooltip), {
|
|
3668
4676
|
effect: "dark",
|
|
3669
4677
|
placement: "top-start",
|
|
3670
4678
|
content: item.name
|
|
@@ -3676,14 +4684,14 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3676
4684
|
}, 1032, ["content"])
|
|
3677
4685
|
])
|
|
3678
4686
|
]),
|
|
3679
|
-
createVNode(
|
|
4687
|
+
createVNode(unref(TMagicPopover), {
|
|
3680
4688
|
"popper-class": "page-bar-popover",
|
|
3681
4689
|
placement: "top",
|
|
3682
4690
|
width: 160,
|
|
3683
4691
|
trigger: "hover"
|
|
3684
4692
|
}, {
|
|
3685
4693
|
reference: withCtx(() => [
|
|
3686
|
-
createVNode(
|
|
4694
|
+
createVNode(unref(TMagicIcon), { class: "m-editor-page-bar-menu-icon" }, {
|
|
3687
4695
|
default: withCtx(() => [
|
|
3688
4696
|
createVNode(unref(CaretBottom))
|
|
3689
4697
|
]),
|
|
@@ -3693,7 +4701,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3693
4701
|
default: withCtx(() => [
|
|
3694
4702
|
createElementVNode("div", null, [
|
|
3695
4703
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
3696
|
-
createVNode(_sfc_main$
|
|
4704
|
+
createVNode(_sfc_main$i, {
|
|
3697
4705
|
data: {
|
|
3698
4706
|
type: "button",
|
|
3699
4707
|
text: "\u590D\u5236",
|
|
@@ -3701,7 +4709,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3701
4709
|
handler: () => copy(item)
|
|
3702
4710
|
}
|
|
3703
4711
|
}, null, 8, ["data"]),
|
|
3704
|
-
createVNode(_sfc_main$
|
|
4712
|
+
createVNode(_sfc_main$i, {
|
|
3705
4713
|
data: {
|
|
3706
4714
|
type: "button",
|
|
3707
4715
|
text: "\u5220\u9664",
|
|
@@ -3735,6 +4743,10 @@ class ScrollViewer extends EventEmitter {
|
|
|
3735
4743
|
height = 0;
|
|
3736
4744
|
translateXCorrectionValue = 0;
|
|
3737
4745
|
translateYCorrectionValue = 0;
|
|
4746
|
+
correctionScrollSize = {
|
|
4747
|
+
width: 0,
|
|
4748
|
+
height: 0
|
|
4749
|
+
};
|
|
3738
4750
|
resizeObserver = new ResizeObserver(() => {
|
|
3739
4751
|
this.setSize();
|
|
3740
4752
|
this.setScrollSize();
|
|
@@ -3744,6 +4756,12 @@ class ScrollViewer extends EventEmitter {
|
|
|
3744
4756
|
this.container = options.container;
|
|
3745
4757
|
this.target = options.target;
|
|
3746
4758
|
this.zoom = options.zoom;
|
|
4759
|
+
if (this.correctionScrollSize) {
|
|
4760
|
+
this.correctionScrollSize = {
|
|
4761
|
+
...this.correctionScrollSize,
|
|
4762
|
+
...options.correctionScrollSize
|
|
4763
|
+
};
|
|
4764
|
+
}
|
|
3747
4765
|
this.container.addEventListener("wheel", this.wheelHandler, false);
|
|
3748
4766
|
this.setSize();
|
|
3749
4767
|
this.setScrollSize();
|
|
@@ -3806,9 +4824,9 @@ class ScrollViewer extends EventEmitter {
|
|
|
3806
4824
|
}
|
|
3807
4825
|
setScrollSize = () => {
|
|
3808
4826
|
const targetRect = this.target.getBoundingClientRect();
|
|
3809
|
-
this.scrollWidth = targetRect.width * this.zoom +
|
|
4827
|
+
this.scrollWidth = targetRect.width * this.zoom + this.correctionScrollSize.width;
|
|
3810
4828
|
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
3811
|
-
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom +
|
|
4829
|
+
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + this.correctionScrollSize.height;
|
|
3812
4830
|
let left;
|
|
3813
4831
|
let top;
|
|
3814
4832
|
if (this.scrollWidth < this.width) {
|
|
@@ -3841,8 +4859,11 @@ class ScrollViewer extends EventEmitter {
|
|
|
3841
4859
|
};
|
|
3842
4860
|
}
|
|
3843
4861
|
|
|
4862
|
+
const __default__$4 = defineComponent({
|
|
4863
|
+
name: "MEditorScrollBar"
|
|
4864
|
+
});
|
|
3844
4865
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3845
|
-
|
|
4866
|
+
...__default__$4,
|
|
3846
4867
|
props: {
|
|
3847
4868
|
size: null,
|
|
3848
4869
|
scrollSize: null,
|
|
@@ -3927,14 +4948,21 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3927
4948
|
|
|
3928
4949
|
const ScrollBar_vue_vue_type_style_index_0_lang = '';
|
|
3929
4950
|
|
|
4951
|
+
const __default__$3 = defineComponent({
|
|
4952
|
+
name: "MEditorScrollViewer"
|
|
4953
|
+
});
|
|
3930
4954
|
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
3931
|
-
|
|
4955
|
+
...__default__$3,
|
|
3932
4956
|
props: {
|
|
3933
4957
|
width: { default: 0 },
|
|
3934
4958
|
height: { default: 0 },
|
|
3935
4959
|
wrapWidth: { default: 0 },
|
|
3936
4960
|
wrapHeight: { default: 0 },
|
|
3937
|
-
zoom: { default: 1 }
|
|
4961
|
+
zoom: { default: 1 },
|
|
4962
|
+
correctionScrollSize: { default: () => ({
|
|
4963
|
+
width: 0,
|
|
4964
|
+
height: 0
|
|
4965
|
+
}) }
|
|
3938
4966
|
},
|
|
3939
4967
|
setup(__props, { expose }) {
|
|
3940
4968
|
const props = __props;
|
|
@@ -3957,7 +4985,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3957
4985
|
scrollViewer = new ScrollViewer({
|
|
3958
4986
|
container: container.value,
|
|
3959
4987
|
target: el.value,
|
|
3960
|
-
zoom: props.zoom
|
|
4988
|
+
zoom: props.zoom,
|
|
4989
|
+
correctionScrollSize: props.correctionScrollSize
|
|
3961
4990
|
});
|
|
3962
4991
|
scrollViewer.on("scroll", (data) => {
|
|
3963
4992
|
hOffset.value = data.scrollLeft;
|
|
@@ -4025,10 +5054,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
4025
5054
|
}
|
|
4026
5055
|
});
|
|
4027
5056
|
|
|
5057
|
+
const __default__$2 = defineComponent({
|
|
5058
|
+
name: "MEditorViewerMenu"
|
|
5059
|
+
});
|
|
4028
5060
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
4029
|
-
|
|
5061
|
+
...__default__$2,
|
|
4030
5062
|
props: {
|
|
4031
|
-
isMultiSelect: { type: Boolean, default: false }
|
|
5063
|
+
isMultiSelect: { type: Boolean, default: false },
|
|
5064
|
+
stageContentMenu: null
|
|
4032
5065
|
},
|
|
4033
5066
|
setup(__props, { expose }) {
|
|
4034
5067
|
const props = __props;
|
|
@@ -4041,8 +5074,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
4041
5074
|
const nodes = computed(() => editorService?.get("nodes"));
|
|
4042
5075
|
const parent = computed(() => editorService?.get("parent"));
|
|
4043
5076
|
const stage = computed(() => editorService?.get("stage"));
|
|
4044
|
-
const
|
|
4045
|
-
const menuData = reactive([
|
|
5077
|
+
const menuData = computed(() => [
|
|
4046
5078
|
{
|
|
4047
5079
|
type: "button",
|
|
4048
5080
|
text: "\u6C34\u5E73\u5C45\u4E2D",
|
|
@@ -4144,7 +5176,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
4144
5176
|
editorService?.get("stage").clearGuides();
|
|
4145
5177
|
}
|
|
4146
5178
|
},
|
|
4147
|
-
...stageContentMenu
|
|
5179
|
+
...props.stageContentMenu
|
|
4148
5180
|
]);
|
|
4149
5181
|
watch(
|
|
4150
5182
|
parent,
|
|
@@ -4168,7 +5200,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
4168
5200
|
expose({ show });
|
|
4169
5201
|
return (_ctx, _cache) => {
|
|
4170
5202
|
return openBlock(), createBlock(_sfc_main$c, {
|
|
4171
|
-
"menu-data": menuData,
|
|
5203
|
+
"menu-data": unref(menuData),
|
|
4172
5204
|
ref_key: "menu",
|
|
4173
5205
|
ref: menu
|
|
4174
5206
|
}, null, 8, ["menu-data"]);
|
|
@@ -4176,8 +5208,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
4176
5208
|
}
|
|
4177
5209
|
});
|
|
4178
5210
|
|
|
5211
|
+
const __default__$1 = defineComponent({
|
|
5212
|
+
name: "MEditorStage"
|
|
5213
|
+
});
|
|
4179
5214
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
4180
|
-
|
|
5215
|
+
...__default__$1,
|
|
5216
|
+
props: {
|
|
5217
|
+
stageContentMenu: null
|
|
5218
|
+
},
|
|
4181
5219
|
setup(__props) {
|
|
4182
5220
|
let stage = null;
|
|
4183
5221
|
let runtime = null;
|
|
@@ -4296,7 +5334,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
4296
5334
|
height: unref(stageRect)?.height,
|
|
4297
5335
|
"wrap-width": unref(stageContainerRect)?.width,
|
|
4298
5336
|
"wrap-height": unref(stageContainerRect)?.height,
|
|
4299
|
-
zoom: unref(zoom)
|
|
5337
|
+
zoom: unref(zoom),
|
|
5338
|
+
"correction-scroll-size": {
|
|
5339
|
+
width: 60,
|
|
5340
|
+
height: 50
|
|
5341
|
+
}
|
|
4300
5342
|
}, {
|
|
4301
5343
|
default: withCtx(() => [
|
|
4302
5344
|
createElementVNode("div", {
|
|
@@ -4312,8 +5354,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
4312
5354
|
createVNode(_sfc_main$3, {
|
|
4313
5355
|
ref_key: "menu",
|
|
4314
5356
|
ref: menu,
|
|
4315
|
-
"is-multi-select": unref(isMultiSelect)
|
|
4316
|
-
|
|
5357
|
+
"is-multi-select": unref(isMultiSelect),
|
|
5358
|
+
"stage-content-menu": __props.stageContentMenu
|
|
5359
|
+
}, null, 8, ["is-multi-select", "stage-content-menu"])
|
|
4317
5360
|
]))
|
|
4318
5361
|
]),
|
|
4319
5362
|
_: 1
|
|
@@ -4322,8 +5365,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
4322
5365
|
}
|
|
4323
5366
|
});
|
|
4324
5367
|
|
|
5368
|
+
const __default__ = defineComponent({
|
|
5369
|
+
name: "MEditorWorkspace"
|
|
5370
|
+
});
|
|
4325
5371
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
4326
|
-
|
|
5372
|
+
...__default__,
|
|
5373
|
+
props: {
|
|
5374
|
+
stageContentMenu: null
|
|
5375
|
+
},
|
|
4327
5376
|
setup(__props) {
|
|
4328
5377
|
const services = inject("services");
|
|
4329
5378
|
const workspace = ref();
|
|
@@ -4432,10 +5481,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
4432
5481
|
ref_key: "workspace",
|
|
4433
5482
|
ref: workspace
|
|
4434
5483
|
}, [
|
|
5484
|
+
createVNode(_sfc_main$8),
|
|
4435
5485
|
renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
4436
5486
|
(openBlock(), createBlock(_sfc_main$2, {
|
|
4437
|
-
key: unref(page)?.id
|
|
4438
|
-
|
|
5487
|
+
key: unref(page)?.id,
|
|
5488
|
+
"stage-content-menu": __props.stageContentMenu
|
|
5489
|
+
}, null, 8, ["stage-content-menu"]))
|
|
4439
5490
|
]),
|
|
4440
5491
|
renderSlot(_ctx.$slots, "workspace-content"),
|
|
4441
5492
|
createVNode(_sfc_main$6, null, {
|
|
@@ -4475,11 +5526,11 @@ const componentListService = new ComponentList();
|
|
|
4475
5526
|
const _sfc_main = defineComponent({
|
|
4476
5527
|
name: "m-editor",
|
|
4477
5528
|
components: {
|
|
4478
|
-
NavMenu: _sfc_main$
|
|
4479
|
-
Sidebar,
|
|
5529
|
+
NavMenu: _sfc_main$h,
|
|
5530
|
+
Sidebar: _sfc_main$9,
|
|
4480
5531
|
Workspace: _sfc_main$1,
|
|
4481
|
-
PropsPanel: _sfc_main$
|
|
4482
|
-
Framework: _sfc_main$
|
|
5532
|
+
PropsPanel: _sfc_main$g,
|
|
5533
|
+
Framework: _sfc_main$j
|
|
4483
5534
|
},
|
|
4484
5535
|
props: {
|
|
4485
5536
|
modelValue: {
|
|
@@ -4574,7 +5625,9 @@ const _sfc_main = defineComponent({
|
|
|
4574
5625
|
});
|
|
4575
5626
|
watch(
|
|
4576
5627
|
() => props.modelValue,
|
|
4577
|
-
(modelValue) =>
|
|
5628
|
+
(modelValue) => {
|
|
5629
|
+
editorService.set("root", modelValue);
|
|
5630
|
+
},
|
|
4578
5631
|
{
|
|
4579
5632
|
immediate: true
|
|
4580
5633
|
}
|
|
@@ -4637,6 +5690,7 @@ const _sfc_main = defineComponent({
|
|
|
4637
5690
|
uiService.destroy();
|
|
4638
5691
|
componentListService.destroy();
|
|
4639
5692
|
storageService.destroy();
|
|
5693
|
+
codeBlockService.destroy();
|
|
4640
5694
|
});
|
|
4641
5695
|
const services = {
|
|
4642
5696
|
componentListService,
|
|
@@ -4645,11 +5699,10 @@ const _sfc_main = defineComponent({
|
|
|
4645
5699
|
propsService,
|
|
4646
5700
|
editorService,
|
|
4647
5701
|
uiService,
|
|
4648
|
-
storageService
|
|
5702
|
+
storageService,
|
|
5703
|
+
codeBlockService
|
|
4649
5704
|
};
|
|
4650
5705
|
provide("services", services);
|
|
4651
|
-
provide("layerContentMenu", props.layerContentMenu);
|
|
4652
|
-
provide("stageContentMenu", props.stageContentMenu);
|
|
4653
5706
|
provide(
|
|
4654
5707
|
"stageOptions",
|
|
4655
5708
|
reactive({
|
|
@@ -4669,21 +5722,32 @@ const _sfc_main = defineComponent({
|
|
|
4669
5722
|
}
|
|
4670
5723
|
});
|
|
4671
5724
|
|
|
5725
|
+
const _export_sfc = (sfc, props) => {
|
|
5726
|
+
const target = sfc.__vccOpts || sfc;
|
|
5727
|
+
for (const [key, val] of props) {
|
|
5728
|
+
target[key] = val;
|
|
5729
|
+
}
|
|
5730
|
+
return target;
|
|
5731
|
+
};
|
|
5732
|
+
|
|
4672
5733
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
4673
|
-
const
|
|
4674
|
-
const
|
|
4675
|
-
const
|
|
4676
|
-
const
|
|
4677
|
-
const
|
|
4678
|
-
return openBlock(), createBlock(
|
|
5734
|
+
const _component_NavMenu = resolveComponent("NavMenu");
|
|
5735
|
+
const _component_Sidebar = resolveComponent("Sidebar");
|
|
5736
|
+
const _component_Workspace = resolveComponent("Workspace");
|
|
5737
|
+
const _component_PropsPanel = resolveComponent("PropsPanel");
|
|
5738
|
+
const _component_Framework = resolveComponent("Framework");
|
|
5739
|
+
return openBlock(), createBlock(_component_Framework, { "code-options": _ctx.codeOptions }, {
|
|
4679
5740
|
nav: withCtx(() => [
|
|
4680
5741
|
renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
|
|
4681
|
-
createVNode(
|
|
5742
|
+
createVNode(_component_NavMenu, { data: _ctx.menu }, null, 8, ["data"])
|
|
4682
5743
|
])
|
|
4683
5744
|
]),
|
|
4684
5745
|
sidebar: withCtx(() => [
|
|
4685
5746
|
renderSlot(_ctx.$slots, "sidebar", { editorService: _ctx.editorService }, () => [
|
|
4686
|
-
createVNode(
|
|
5747
|
+
createVNode(_component_Sidebar, {
|
|
5748
|
+
data: _ctx.sidebar,
|
|
5749
|
+
"layer-content-menu": _ctx.layerContentMenu
|
|
5750
|
+
}, {
|
|
4687
5751
|
"layer-panel-header": withCtx(() => [
|
|
4688
5752
|
renderSlot(_ctx.$slots, "layer-panel-header")
|
|
4689
5753
|
]),
|
|
@@ -4699,13 +5763,25 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4699
5763
|
"component-list-item": withCtx(({ component }) => [
|
|
4700
5764
|
renderSlot(_ctx.$slots, "component-list-item", { component })
|
|
4701
5765
|
]),
|
|
5766
|
+
"code-block-panel-header": withCtx(() => [
|
|
5767
|
+
renderSlot(_ctx.$slots, "code-block-panel-header")
|
|
5768
|
+
]),
|
|
5769
|
+
"code-block-panel-tool": withCtx(({ id, data }) => [
|
|
5770
|
+
renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
5771
|
+
id,
|
|
5772
|
+
data
|
|
5773
|
+
})
|
|
5774
|
+
]),
|
|
5775
|
+
"code-block-edit-panel-header": withCtx(({ id }) => [
|
|
5776
|
+
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
5777
|
+
]),
|
|
4702
5778
|
_: 3
|
|
4703
|
-
}, 8, ["data"])
|
|
5779
|
+
}, 8, ["data", "layer-content-menu"])
|
|
4704
5780
|
])
|
|
4705
5781
|
]),
|
|
4706
5782
|
workspace: withCtx(() => [
|
|
4707
5783
|
renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
|
|
4708
|
-
createVNode(
|
|
5784
|
+
createVNode(_component_Workspace, { "stage-content-menu": _ctx.stageContentMenu }, {
|
|
4709
5785
|
stage: withCtx(() => [
|
|
4710
5786
|
renderSlot(_ctx.$slots, "stage")
|
|
4711
5787
|
]),
|
|
@@ -4719,12 +5795,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4719
5795
|
renderSlot(_ctx.$slots, "page-bar-popover", { page })
|
|
4720
5796
|
]),
|
|
4721
5797
|
_: 3
|
|
4722
|
-
})
|
|
5798
|
+
}, 8, ["stage-content-menu"])
|
|
4723
5799
|
])
|
|
4724
5800
|
]),
|
|
4725
5801
|
"props-panel": withCtx(() => [
|
|
4726
5802
|
renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
4727
|
-
createVNode(
|
|
5803
|
+
createVNode(_component_PropsPanel, {
|
|
4728
5804
|
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
|
|
4729
5805
|
}, {
|
|
4730
5806
|
"props-panel-header": withCtx(() => [
|
|
@@ -4751,12 +5827,13 @@ const index = {
|
|
|
4751
5827
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
4752
5828
|
setConfig(option);
|
|
4753
5829
|
app.component(Editor.name, Editor);
|
|
4754
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
4755
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
4756
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
4757
|
-
app.component(
|
|
5830
|
+
app.component("m-fields-ui-select", _sfc_main$p);
|
|
5831
|
+
app.component("m-fields-code-link", _sfc_main$r);
|
|
5832
|
+
app.component("m-fields-vs-code", _sfc_main$s);
|
|
5833
|
+
app.component("magic-code-editor", _sfc_main$o);
|
|
5834
|
+
app.component("m-fields-code-select", _sfc_main$q);
|
|
4758
5835
|
}
|
|
4759
5836
|
};
|
|
4760
5837
|
|
|
4761
|
-
export { COPY_STORAGE_KEY, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$
|
|
5838
|
+
export { COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, CodeEditorMode, _sfc_main$q as CodeSelect, CodeSelectOp, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$l as Icon, Keys, LayerOffset, _sfc_main$a as LayerPanel, _sfc_main$m as Layout, _sfc_main$g as PropsPanel, _sfc_main$o as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$i as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, codeBlockService, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, useStage, warn };
|
|
4762
5839
|
//# sourceMappingURL=tmagic-editor.mjs.map
|