@tmagic/editor 1.2.0-beta.11 → 1.2.0-beta.13
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 +14 -17
- package/dist/tmagic-editor.mjs +709 -562
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +715 -567
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/Editor.vue +1 -0
- package/src/components/CodeDraftEditor.vue +130 -0
- package/src/components/FunctionEditor.vue +144 -0
- package/src/fields/CodeSelect.vue +80 -101
- package/src/layouts/CodeEditor.vue +1 -2
- package/src/layouts/sidebar/LayerPanel.vue +99 -86
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +23 -79
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +37 -71
- package/src/services/codeBlock.ts +111 -120
- package/src/services/editor.ts +19 -5
- package/src/theme/code-block.scss +14 -17
- package/src/type.ts +36 -38
- package/src/utils/editor.ts +9 -1
- package/src/utils/props.ts +2 -2
- package/types/components/CodeDraftEditor.vue.d.ts +148 -0
- package/types/components/FunctionEditor.vue.d.ts +120 -0
- package/types/fields/CodeSelect.vue.d.ts +9 -9
- package/types/layouts/CodeEditor.vue.d.ts +5 -12
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +1 -1
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +6 -5
- package/types/services/codeBlock.d.ts +55 -35
- package/types/services/editor.d.ts +1 -0
- package/types/services/props.d.ts +1 -1
- package/types/type.d.ts +32 -35
- package/types/utils/editor.d.ts +1 -0
- package/types/utils/props.d.ts +1 -1
package/dist/tmagic-editor.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, inject, createElementBlock, createVNode, ref, withCtx, withModifiers, createCommentVNode, createTextVNode, toDisplayString, onMounted, onUnmounted, renderSlot, Fragment, createElementVNode, normalizeClass, resolveDynamicComponent, toRaw, createSlots, renderList, normalizeProps, mergeProps, markRaw, getCurrentInstance, watchEffect, provide, withDirectives, Teleport, vShow, nextTick, toHandlers } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { isEmpty, map, throttle, pick, omit, keys, cloneDeep, forIn, mergeWith, uniq, isObject } from 'lodash-es';
|
|
4
|
+
import { HookType, NodeType } from '@tmagic/schema';
|
|
5
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';
|
|
6
|
+
import { TMagicButton, TMagicTooltip, TMagicIcon, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, tMagicMessageBox, TMagicCard, TMagicInput, TMagicDialog, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicTabs, TMagicPopover } from '@tmagic/design';
|
|
6
7
|
import * as monaco from 'monaco-editor';
|
|
7
8
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS, ContainerHighlightType } from '@tmagic/stage';
|
|
8
9
|
import Gesto from 'gesto';
|
|
9
|
-
import {
|
|
10
|
-
import { isPop, getNodePath, isNumber, isPage, toLine, removeClassNameByClassName } from '@tmagic/utils';
|
|
10
|
+
import { isPop, getNodePath, isNumber, isPage, toLine, datetimeFormatter, removeClassNameByClassName } from '@tmagic/utils';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
12
12
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
13
13
|
import KeyController from 'keycon';
|
|
14
14
|
|
|
15
|
-
const __default__$
|
|
15
|
+
const __default__$t = defineComponent({
|
|
16
16
|
name: "MEditorCode"
|
|
17
17
|
});
|
|
18
|
-
const _sfc_main$
|
|
19
|
-
...__default__$
|
|
18
|
+
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
19
|
+
...__default__$t,
|
|
20
20
|
props: {
|
|
21
21
|
model: null,
|
|
22
22
|
name: null,
|
|
@@ -45,11 +45,11 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
const __default__$
|
|
48
|
+
const __default__$s = defineComponent({
|
|
49
49
|
name: "MEditorCodeLink"
|
|
50
50
|
});
|
|
51
|
-
const _sfc_main$
|
|
52
|
-
...__default__$
|
|
51
|
+
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
52
|
+
...__default__$s,
|
|
53
53
|
props: {
|
|
54
54
|
config: null,
|
|
55
55
|
model: null,
|
|
@@ -118,60 +118,12 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
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({
|
|
121
|
+
const _hoisted_1$g = { class: "m-fields-code-select" };
|
|
122
|
+
const __default__$r = defineComponent({
|
|
171
123
|
name: "MEditorCodeSelect"
|
|
172
124
|
});
|
|
173
|
-
const _sfc_main$
|
|
174
|
-
...__default__$
|
|
125
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
126
|
+
...__default__$r,
|
|
175
127
|
props: {
|
|
176
128
|
config: null,
|
|
177
129
|
model: null,
|
|
@@ -183,122 +135,98 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
183
135
|
setup(__props, { emit }) {
|
|
184
136
|
const props = __props;
|
|
185
137
|
const services = inject("services");
|
|
186
|
-
const
|
|
187
|
-
const
|
|
138
|
+
const codeDsl = computed(() => services?.codeBlockService.getCodeDslSync());
|
|
139
|
+
const tableConfig = computed(() => {
|
|
188
140
|
const defaultConfig = {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
141
|
+
dropSort: true,
|
|
142
|
+
enableFullscreen: false,
|
|
143
|
+
border: true,
|
|
144
|
+
items: [
|
|
145
|
+
{
|
|
146
|
+
type: "select",
|
|
147
|
+
label: "\u4EE3\u7801\u5757",
|
|
148
|
+
name: "codeId",
|
|
149
|
+
width: "200px",
|
|
150
|
+
options: () => {
|
|
151
|
+
if (codeDsl.value) {
|
|
152
|
+
return map(codeDsl.value, (value, key) => ({
|
|
153
|
+
text: `${value.name}\uFF08${key}\uFF09`,
|
|
154
|
+
label: `${value.name}\uFF08${key}\uFF09`,
|
|
155
|
+
value: key
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
return [];
|
|
159
|
+
},
|
|
160
|
+
onChange: (formState, codeId, { model }) => {
|
|
161
|
+
model.params = {};
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "params",
|
|
166
|
+
label: "\u53C2\u6570",
|
|
167
|
+
defaultValue: {},
|
|
168
|
+
itemsFunction: (row) => getParamsConfig(row.codeId)
|
|
198
169
|
}
|
|
199
|
-
|
|
200
|
-
}
|
|
170
|
+
]
|
|
201
171
|
};
|
|
202
172
|
return {
|
|
203
173
|
...defaultConfig,
|
|
204
|
-
...props.config.
|
|
174
|
+
...props.config.tableConfig
|
|
205
175
|
};
|
|
206
176
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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);
|
|
177
|
+
watch(
|
|
178
|
+
() => props.model[props.name],
|
|
179
|
+
(value) => {
|
|
180
|
+
if (isEmpty(value)) {
|
|
181
|
+
props.model[props.name] = {
|
|
182
|
+
hookType: HookType.CODE,
|
|
183
|
+
hookData: []
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
immediate: true
|
|
238
189
|
}
|
|
239
|
-
|
|
190
|
+
);
|
|
191
|
+
const changeHandler = async () => {
|
|
192
|
+
emit("change", props.model[props.name]);
|
|
240
193
|
};
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
194
|
+
const getParamsConfig = (codeId) => {
|
|
195
|
+
if (!codeDsl.value)
|
|
196
|
+
return [];
|
|
197
|
+
const paramStatements = codeDsl.value[codeId]?.params;
|
|
198
|
+
if (isEmpty(paramStatements))
|
|
199
|
+
return [];
|
|
200
|
+
return paramStatements.map((paramState) => ({
|
|
201
|
+
name: paramState.name,
|
|
202
|
+
text: paramState.name,
|
|
203
|
+
labelWidth: "100px",
|
|
204
|
+
type: "text"
|
|
205
|
+
}));
|
|
249
206
|
};
|
|
250
207
|
return (_ctx, _cache) => {
|
|
251
|
-
const
|
|
252
|
-
return openBlock(), createElementBlock("div",
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
})
|
|
208
|
+
const _component_m_form_table = resolveComponent("m-form-table");
|
|
209
|
+
return openBlock(), createElementBlock("div", _hoisted_1$g, [
|
|
210
|
+
createVNode(_component_m_form_table, {
|
|
211
|
+
config: unref(tableConfig),
|
|
212
|
+
model: __props.model[__props.name],
|
|
213
|
+
name: "hookData",
|
|
214
|
+
enableToggleMode: false,
|
|
215
|
+
prop: __props.prop,
|
|
216
|
+
size: __props.size,
|
|
217
|
+
onChange: changeHandler
|
|
218
|
+
}, null, 8, ["config", "model", "prop", "size"])
|
|
291
219
|
]);
|
|
292
220
|
};
|
|
293
221
|
}
|
|
294
222
|
});
|
|
295
223
|
|
|
296
|
-
const _hoisted_1$
|
|
297
|
-
const __default__$
|
|
224
|
+
const _hoisted_1$f = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
|
|
225
|
+
const __default__$q = defineComponent({
|
|
298
226
|
name: "MEditorUISelect"
|
|
299
227
|
});
|
|
300
|
-
const _sfc_main$
|
|
301
|
-
...__default__$
|
|
228
|
+
const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
229
|
+
...__default__$q,
|
|
302
230
|
props: {
|
|
303
231
|
config: null,
|
|
304
232
|
model: null,
|
|
@@ -360,7 +288,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
360
288
|
style: { "padding": "0" }
|
|
361
289
|
}, {
|
|
362
290
|
default: withCtx(() => [
|
|
363
|
-
_hoisted_1$
|
|
291
|
+
_hoisted_1$f
|
|
364
292
|
]),
|
|
365
293
|
_: 1
|
|
366
294
|
}, 8, ["icon"])
|
|
@@ -408,15 +336,15 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
408
336
|
|
|
409
337
|
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
410
338
|
|
|
411
|
-
const __default__$
|
|
339
|
+
const __default__$p = defineComponent({
|
|
412
340
|
name: "MEditorCodeEditor"
|
|
413
341
|
});
|
|
414
|
-
const _sfc_main$
|
|
415
|
-
...__default__$
|
|
342
|
+
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
343
|
+
...__default__$p,
|
|
416
344
|
props: {
|
|
417
345
|
initValues: null,
|
|
418
346
|
modifiedValues: null,
|
|
419
|
-
type:
|
|
347
|
+
type: null,
|
|
420
348
|
language: { default: "javascript" },
|
|
421
349
|
options: { default: () => ({
|
|
422
350
|
tabSize: 2
|
|
@@ -541,11 +469,11 @@ const setConfig = (option) => {
|
|
|
541
469
|
};
|
|
542
470
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
543
471
|
|
|
544
|
-
const __default__$
|
|
472
|
+
const __default__$o = defineComponent({
|
|
545
473
|
name: "MEditorResizer"
|
|
546
474
|
});
|
|
547
|
-
const _sfc_main$
|
|
548
|
-
...__default__$
|
|
475
|
+
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
476
|
+
...__default__$o,
|
|
549
477
|
emits: ["change"],
|
|
550
478
|
setup(__props, { emit }) {
|
|
551
479
|
const target = ref();
|
|
@@ -577,11 +505,11 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
577
505
|
}
|
|
578
506
|
});
|
|
579
507
|
|
|
580
|
-
const __default__$
|
|
508
|
+
const __default__$n = defineComponent({
|
|
581
509
|
name: "MEditorLayout"
|
|
582
510
|
});
|
|
583
|
-
const _sfc_main$
|
|
584
|
-
...__default__$
|
|
511
|
+
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
512
|
+
...__default__$n,
|
|
585
513
|
props: {
|
|
586
514
|
left: null,
|
|
587
515
|
right: null,
|
|
@@ -659,7 +587,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
659
587
|
}, [
|
|
660
588
|
renderSlot(_ctx.$slots, "left")
|
|
661
589
|
], 6),
|
|
662
|
-
createVNode(_sfc_main$
|
|
590
|
+
createVNode(_sfc_main$p, { onChange: changeLeft })
|
|
663
591
|
], 64)) : createCommentVNode("", true),
|
|
664
592
|
createElementVNode("div", {
|
|
665
593
|
class: normalizeClass(["m-editor-layout-center", __props.centerClass]),
|
|
@@ -668,7 +596,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
668
596
|
renderSlot(_ctx.$slots, "center")
|
|
669
597
|
], 6),
|
|
670
598
|
typeof props.right !== "undefined" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
671
|
-
createVNode(_sfc_main$
|
|
599
|
+
createVNode(_sfc_main$p, { onChange: changeRight }),
|
|
672
600
|
createElementVNode("div", {
|
|
673
601
|
class: normalizeClass(["m-editor-layout-right", __props.rightClass]),
|
|
674
602
|
style: normalizeStyle(`width: ${__props.right}px`)
|
|
@@ -681,12 +609,12 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
681
609
|
}
|
|
682
610
|
});
|
|
683
611
|
|
|
684
|
-
const _hoisted_1$
|
|
685
|
-
const __default__$
|
|
612
|
+
const _hoisted_1$e = ["src"];
|
|
613
|
+
const __default__$m = defineComponent({
|
|
686
614
|
name: "MEditorIcon"
|
|
687
615
|
});
|
|
688
|
-
const _sfc_main$
|
|
689
|
-
...__default__$
|
|
616
|
+
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
617
|
+
...__default__$m,
|
|
690
618
|
props: {
|
|
691
619
|
icon: null
|
|
692
620
|
},
|
|
@@ -705,7 +633,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
705
633
|
class: "magic-editor-icon"
|
|
706
634
|
}, {
|
|
707
635
|
default: withCtx(() => [
|
|
708
|
-
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$
|
|
636
|
+
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$e)
|
|
709
637
|
]),
|
|
710
638
|
_: 1
|
|
711
639
|
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
@@ -724,6 +652,42 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
724
652
|
}
|
|
725
653
|
});
|
|
726
654
|
|
|
655
|
+
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
656
|
+
ColumnLayout2["LEFT"] = "left";
|
|
657
|
+
ColumnLayout2["CENTER"] = "center";
|
|
658
|
+
ColumnLayout2["RIGHT"] = "right";
|
|
659
|
+
return ColumnLayout2;
|
|
660
|
+
})(ColumnLayout || {});
|
|
661
|
+
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
662
|
+
LayerOffset2["TOP"] = "top";
|
|
663
|
+
LayerOffset2["BOTTOM"] = "bottom";
|
|
664
|
+
return LayerOffset2;
|
|
665
|
+
})(LayerOffset || {});
|
|
666
|
+
var Layout = /* @__PURE__ */ ((Layout2) => {
|
|
667
|
+
Layout2["FLEX"] = "flex";
|
|
668
|
+
Layout2["FIXED"] = "fixed";
|
|
669
|
+
Layout2["RELATIVE"] = "relative";
|
|
670
|
+
Layout2["ABSOLUTE"] = "absolute";
|
|
671
|
+
return Layout2;
|
|
672
|
+
})(Layout || {});
|
|
673
|
+
var Keys = /* @__PURE__ */ ((Keys2) => {
|
|
674
|
+
Keys2["ESCAPE"] = "Space";
|
|
675
|
+
return Keys2;
|
|
676
|
+
})(Keys || {});
|
|
677
|
+
const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
678
|
+
const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
679
|
+
var CodeEditorMode = /* @__PURE__ */ ((CodeEditorMode2) => {
|
|
680
|
+
CodeEditorMode2["LIST"] = "list";
|
|
681
|
+
CodeEditorMode2["EDITOR"] = "editor";
|
|
682
|
+
return CodeEditorMode2;
|
|
683
|
+
})(CodeEditorMode || {});
|
|
684
|
+
var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
|
|
685
|
+
CodeDeleteErrorType2["UNDELETEABLE"] = "undeleteable";
|
|
686
|
+
CodeDeleteErrorType2["BIND"] = "bind";
|
|
687
|
+
return CodeDeleteErrorType2;
|
|
688
|
+
})(CodeDeleteErrorType || {});
|
|
689
|
+
const CODE_DRAFT_STORAGE_KEY = "magicCodeDraft";
|
|
690
|
+
|
|
727
691
|
const log = (...args) => {
|
|
728
692
|
if (process.env.NODE_ENV === "development") {
|
|
729
693
|
console.log("magic editor: ", ...args);
|
|
@@ -872,7 +836,8 @@ class CodeBlock extends BaseService {
|
|
|
872
836
|
editable: true,
|
|
873
837
|
mode: CodeEditorMode.EDITOR,
|
|
874
838
|
combineIds: [],
|
|
875
|
-
undeletableList: []
|
|
839
|
+
undeletableList: [],
|
|
840
|
+
relations: {}
|
|
876
841
|
});
|
|
877
842
|
constructor() {
|
|
878
843
|
super([
|
|
@@ -890,31 +855,37 @@ class CodeBlock extends BaseService {
|
|
|
890
855
|
"deleteCodeDslByIds"
|
|
891
856
|
]);
|
|
892
857
|
}
|
|
893
|
-
async setCodeDsl(
|
|
894
|
-
this.state.codeDsl =
|
|
858
|
+
async setCodeDsl(codeDsl2) {
|
|
859
|
+
this.state.codeDsl = codeDsl2;
|
|
895
860
|
await editorService.setCodeDsl(this.state.codeDsl);
|
|
896
861
|
info("[code-block]:code-dsl-change", this.state.codeDsl);
|
|
897
862
|
this.emit("code-dsl-change", this.state.codeDsl);
|
|
898
863
|
}
|
|
899
864
|
async getCodeDsl(forceRefresh = false) {
|
|
865
|
+
return this.getCodeDslSync(forceRefresh);
|
|
866
|
+
}
|
|
867
|
+
getCodeDslSync(forceRefresh = false) {
|
|
900
868
|
if (!this.state.codeDsl || forceRefresh) {
|
|
901
|
-
this.state.codeDsl =
|
|
869
|
+
this.state.codeDsl = editorService.getCodeDslSync();
|
|
902
870
|
}
|
|
903
871
|
return this.state.codeDsl;
|
|
904
872
|
}
|
|
905
|
-
async getCodeContentById(
|
|
906
|
-
if (!
|
|
873
|
+
async getCodeContentById(id2) {
|
|
874
|
+
if (!id2)
|
|
907
875
|
return null;
|
|
908
876
|
const totalCodeDsl = await this.getCodeDsl();
|
|
909
877
|
if (!totalCodeDsl)
|
|
910
878
|
return null;
|
|
911
|
-
return totalCodeDsl[
|
|
879
|
+
return totalCodeDsl[id2] ?? null;
|
|
912
880
|
}
|
|
913
881
|
async setCodeDslById(id, codeConfig) {
|
|
914
882
|
let codeDsl = await this.getCodeDsl();
|
|
915
883
|
if (!codeDsl) {
|
|
916
884
|
codeDsl = {
|
|
917
|
-
[id]:
|
|
885
|
+
[id]: {
|
|
886
|
+
...codeConfig,
|
|
887
|
+
content: eval(codeConfig.content)
|
|
888
|
+
}
|
|
918
889
|
};
|
|
919
890
|
} else {
|
|
920
891
|
const existContent = codeDsl[id] || {};
|
|
@@ -922,15 +893,16 @@ class CodeBlock extends BaseService {
|
|
|
922
893
|
...codeDsl,
|
|
923
894
|
[id]: {
|
|
924
895
|
...existContent,
|
|
925
|
-
...codeConfig
|
|
896
|
+
...codeConfig,
|
|
897
|
+
content: eval(codeConfig.content)
|
|
926
898
|
}
|
|
927
899
|
};
|
|
928
900
|
}
|
|
929
901
|
await this.setCodeDsl(codeDsl);
|
|
930
902
|
}
|
|
931
903
|
async getCodeDslByIds(ids) {
|
|
932
|
-
const
|
|
933
|
-
return pick(
|
|
904
|
+
const codeDsl2 = await this.getCodeDsl();
|
|
905
|
+
return pick(codeDsl2, ids);
|
|
934
906
|
}
|
|
935
907
|
async setCodeEditorShowStatus(status) {
|
|
936
908
|
this.state.isShowCodeEditor = status;
|
|
@@ -938,10 +910,10 @@ class CodeBlock extends BaseService {
|
|
|
938
910
|
getCodeEditorShowStatus() {
|
|
939
911
|
return this.state.isShowCodeEditor;
|
|
940
912
|
}
|
|
941
|
-
setCodeEditorContent(status,
|
|
942
|
-
if (!
|
|
913
|
+
setCodeEditorContent(status, id2) {
|
|
914
|
+
if (!id2)
|
|
943
915
|
return;
|
|
944
|
-
this.setId(
|
|
916
|
+
this.setId(id2);
|
|
945
917
|
this.state.isShowCodeEditor = status;
|
|
946
918
|
}
|
|
947
919
|
async getCurrentDsl() {
|
|
@@ -953,10 +925,10 @@ class CodeBlock extends BaseService {
|
|
|
953
925
|
async setEditStatus(status) {
|
|
954
926
|
this.state.editable = status;
|
|
955
927
|
}
|
|
956
|
-
setId(
|
|
957
|
-
if (!
|
|
928
|
+
setId(id2) {
|
|
929
|
+
if (!id2)
|
|
958
930
|
return;
|
|
959
|
-
this.state.id =
|
|
931
|
+
this.state.id = id2;
|
|
960
932
|
}
|
|
961
933
|
getId() {
|
|
962
934
|
return this.state.id;
|
|
@@ -973,61 +945,17 @@ class CodeBlock extends BaseService {
|
|
|
973
945
|
getCombineIds() {
|
|
974
946
|
return this.state.combineIds;
|
|
975
947
|
}
|
|
976
|
-
|
|
977
|
-
const
|
|
978
|
-
if (!
|
|
979
|
-
return;
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
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);
|
|
948
|
+
refreshCombineInfo() {
|
|
949
|
+
const root = editorService.get("root");
|
|
950
|
+
if (!root)
|
|
951
|
+
return null;
|
|
952
|
+
const relations = {};
|
|
953
|
+
this.recurseMNode(root, relations);
|
|
954
|
+
this.state.relations = relations;
|
|
955
|
+
return this.state.relations;
|
|
956
|
+
}
|
|
957
|
+
getCombineInfo() {
|
|
958
|
+
return this.state.relations;
|
|
1031
959
|
}
|
|
1032
960
|
getUndeletableList() {
|
|
1033
961
|
return this.state.undeletableList;
|
|
@@ -1035,6 +963,15 @@ class CodeBlock extends BaseService {
|
|
|
1035
963
|
async setUndeleteableList(codeIds) {
|
|
1036
964
|
this.state.undeletableList = codeIds;
|
|
1037
965
|
}
|
|
966
|
+
setCodeDraft(codeId, content) {
|
|
967
|
+
globalThis.localStorage.setItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`, content);
|
|
968
|
+
}
|
|
969
|
+
getCodeDraft(codeId) {
|
|
970
|
+
return globalThis.localStorage.getItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`);
|
|
971
|
+
}
|
|
972
|
+
removeCodeDraft(codeId) {
|
|
973
|
+
globalThis.localStorage.removeItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`);
|
|
974
|
+
}
|
|
1038
975
|
async deleteCodeDslByIds(codeIds) {
|
|
1039
976
|
const currentDsl = await this.getCodeDsl();
|
|
1040
977
|
const newDsl = omit(currentDsl, codeIds);
|
|
@@ -1050,11 +987,11 @@ class CodeBlock extends BaseService {
|
|
|
1050
987
|
return await this.getUniqueId();
|
|
1051
988
|
}
|
|
1052
989
|
async deleteCompsInRelation(node) {
|
|
1053
|
-
const
|
|
1054
|
-
if (!
|
|
990
|
+
const codeDsl2 = cloneDeep(await this.getCodeDsl());
|
|
991
|
+
if (!codeDsl2)
|
|
1055
992
|
return;
|
|
1056
|
-
this.
|
|
1057
|
-
this.setCodeDsl(
|
|
993
|
+
this.refreshRelationDeep(node, codeDsl2);
|
|
994
|
+
this.setCodeDsl(codeDsl2);
|
|
1058
995
|
}
|
|
1059
996
|
destroy() {
|
|
1060
997
|
this.state.isShowCodeEditor = false;
|
|
@@ -1065,16 +1002,39 @@ class CodeBlock extends BaseService {
|
|
|
1065
1002
|
this.state.combineIds = [];
|
|
1066
1003
|
this.state.undeletableList = [];
|
|
1067
1004
|
}
|
|
1068
|
-
|
|
1005
|
+
refreshRelationDeep(node, codeDsl2) {
|
|
1069
1006
|
if (!node.id)
|
|
1070
1007
|
return;
|
|
1071
|
-
forIn(
|
|
1008
|
+
forIn(codeDsl2, (codeBlockContent) => {
|
|
1072
1009
|
const compsContent = codeBlockContent.comps || {};
|
|
1073
1010
|
codeBlockContent.comps = omit(compsContent, node.id);
|
|
1074
1011
|
});
|
|
1075
1012
|
if (!isEmpty(node.items)) {
|
|
1076
1013
|
node.items.forEach((item) => {
|
|
1077
|
-
this.
|
|
1014
|
+
this.refreshRelationDeep(item, codeDsl2);
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
recurseMNode(node, relations) {
|
|
1019
|
+
forIn(node, (value, key) => {
|
|
1020
|
+
if (value?.hookType === HookType.CODE && !isEmpty(value.hookData)) {
|
|
1021
|
+
value.hookData.forEach((relationItem) => {
|
|
1022
|
+
if (!relationItem.codeId)
|
|
1023
|
+
return;
|
|
1024
|
+
if (!relations[relationItem.codeId]) {
|
|
1025
|
+
relations[relationItem.codeId] = {};
|
|
1026
|
+
}
|
|
1027
|
+
const codeItem = relations[relationItem.codeId];
|
|
1028
|
+
if (isEmpty(codeItem[node.id])) {
|
|
1029
|
+
codeItem[node.id] = [];
|
|
1030
|
+
}
|
|
1031
|
+
codeItem[node.id].push(key);
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
if (!isEmpty(node.items)) {
|
|
1036
|
+
node.items.forEach((item) => {
|
|
1037
|
+
this.recurseMNode(item, relations);
|
|
1078
1038
|
});
|
|
1079
1039
|
}
|
|
1080
1040
|
}
|
|
@@ -1443,6 +1403,10 @@ const fixNodePosition = (config, parent, stage) => {
|
|
|
1443
1403
|
left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
|
|
1444
1404
|
};
|
|
1445
1405
|
};
|
|
1406
|
+
const serializeConfig = (config) => serialize(config, {
|
|
1407
|
+
space: 2,
|
|
1408
|
+
unsafe: true
|
|
1409
|
+
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1446
1410
|
|
|
1447
1411
|
class Props extends BaseService {
|
|
1448
1412
|
state = reactive({
|
|
@@ -1842,7 +1806,9 @@ class Editor$1 extends BaseService {
|
|
|
1842
1806
|
stage?.select(newNodes[0].id);
|
|
1843
1807
|
}
|
|
1844
1808
|
}
|
|
1845
|
-
|
|
1809
|
+
if (!isPage(newNodes[0])) {
|
|
1810
|
+
this.pushHistoryState();
|
|
1811
|
+
}
|
|
1846
1812
|
this.emit("add", newNodes);
|
|
1847
1813
|
return Array.isArray(addNode) ? newNodes : newNodes[0];
|
|
1848
1814
|
}
|
|
@@ -1884,7 +1850,9 @@ class Editor$1 extends BaseService {
|
|
|
1884
1850
|
async remove(nodeOrNodeList) {
|
|
1885
1851
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
1886
1852
|
await Promise.all(nodes.map((node) => this.doRemove(node)));
|
|
1887
|
-
|
|
1853
|
+
if (!isPage(nodes[0])) {
|
|
1854
|
+
this.pushHistoryState();
|
|
1855
|
+
}
|
|
1888
1856
|
this.emit("remove", nodes);
|
|
1889
1857
|
}
|
|
1890
1858
|
async doUpdate(config) {
|
|
@@ -1896,6 +1864,9 @@ class Editor$1 extends BaseService {
|
|
|
1896
1864
|
const node = cloneDeep(toRaw(info.node));
|
|
1897
1865
|
let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get("root"));
|
|
1898
1866
|
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue) => {
|
|
1867
|
+
if (isObject(srcValue) && Array.isArray(objValue)) {
|
|
1868
|
+
return srcValue;
|
|
1869
|
+
}
|
|
1899
1870
|
if (Array.isArray(srcValue)) {
|
|
1900
1871
|
return srcValue;
|
|
1901
1872
|
}
|
|
@@ -1939,6 +1910,7 @@ class Editor$1 extends BaseService {
|
|
|
1939
1910
|
const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
|
|
1940
1911
|
this.pushHistoryState();
|
|
1941
1912
|
this.emit("update", newNodes);
|
|
1913
|
+
codeBlockService.refreshCombineInfo();
|
|
1942
1914
|
return Array.isArray(config) ? newNodes : newNodes[0];
|
|
1943
1915
|
}
|
|
1944
1916
|
async sort(id1, id2) {
|
|
@@ -2115,6 +2087,12 @@ class Editor$1 extends BaseService {
|
|
|
2115
2087
|
return null;
|
|
2116
2088
|
return root.codeBlocks || null;
|
|
2117
2089
|
}
|
|
2090
|
+
getCodeDslSync() {
|
|
2091
|
+
const root = this.get("root");
|
|
2092
|
+
if (!root)
|
|
2093
|
+
return null;
|
|
2094
|
+
return root.codeBlocks || null;
|
|
2095
|
+
}
|
|
2118
2096
|
async setCodeDsl(codeDsl) {
|
|
2119
2097
|
if (!this.state.root)
|
|
2120
2098
|
return;
|
|
@@ -2429,14 +2407,14 @@ const fillConfig = (config = []) => [
|
|
|
2429
2407
|
{
|
|
2430
2408
|
name: "created",
|
|
2431
2409
|
text: "created",
|
|
2432
|
-
|
|
2433
|
-
|
|
2410
|
+
labelWidth: "100px",
|
|
2411
|
+
type: "code-select"
|
|
2434
2412
|
},
|
|
2435
2413
|
{
|
|
2436
2414
|
name: "mounted",
|
|
2437
2415
|
text: "mounted",
|
|
2438
|
-
|
|
2439
|
-
|
|
2416
|
+
labelWidth: "100px",
|
|
2417
|
+
type: "code-select"
|
|
2440
2418
|
}
|
|
2441
2419
|
]
|
|
2442
2420
|
}
|
|
@@ -2591,14 +2569,14 @@ const useStage = (stageOptions) => {
|
|
|
2591
2569
|
return stage;
|
|
2592
2570
|
};
|
|
2593
2571
|
|
|
2594
|
-
const _hoisted_1$
|
|
2595
|
-
const _hoisted_2$
|
|
2596
|
-
const _hoisted_3$
|
|
2597
|
-
const __default__$
|
|
2572
|
+
const _hoisted_1$d = { class: "m-editor-empty-panel" };
|
|
2573
|
+
const _hoisted_2$7 = { class: "m-editor-empty-content" };
|
|
2574
|
+
const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
|
|
2575
|
+
const __default__$l = defineComponent({
|
|
2598
2576
|
name: "MEditorAddPageBox"
|
|
2599
2577
|
});
|
|
2600
|
-
const _sfc_main$
|
|
2601
|
-
...__default__$
|
|
2578
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
2579
|
+
...__default__$l,
|
|
2602
2580
|
setup(__props) {
|
|
2603
2581
|
const services = inject("services");
|
|
2604
2582
|
const clickHandler = () => {
|
|
@@ -2611,16 +2589,16 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2611
2589
|
});
|
|
2612
2590
|
};
|
|
2613
2591
|
return (_ctx, _cache) => {
|
|
2614
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2615
|
-
createElementVNode("div", _hoisted_2$
|
|
2592
|
+
return openBlock(), createElementBlock("div", _hoisted_1$d, [
|
|
2593
|
+
createElementVNode("div", _hoisted_2$7, [
|
|
2616
2594
|
createElementVNode("div", {
|
|
2617
2595
|
class: "m-editor-empty-button",
|
|
2618
2596
|
onClick: clickHandler
|
|
2619
2597
|
}, [
|
|
2620
2598
|
createElementVNode("div", null, [
|
|
2621
|
-
createVNode(_sfc_main$
|
|
2599
|
+
createVNode(_sfc_main$n, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
2622
2600
|
]),
|
|
2623
|
-
_hoisted_3$
|
|
2601
|
+
_hoisted_3$4
|
|
2624
2602
|
])
|
|
2625
2603
|
])
|
|
2626
2604
|
]);
|
|
@@ -2628,12 +2606,12 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2628
2606
|
}
|
|
2629
2607
|
});
|
|
2630
2608
|
|
|
2631
|
-
const _hoisted_1$
|
|
2632
|
-
const __default__$
|
|
2609
|
+
const _hoisted_1$c = { class: "m-editor" };
|
|
2610
|
+
const __default__$k = defineComponent({
|
|
2633
2611
|
name: "MEditorFramework"
|
|
2634
2612
|
});
|
|
2635
|
-
const _sfc_main$
|
|
2636
|
-
...__default__$
|
|
2613
|
+
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
2614
|
+
...__default__$k,
|
|
2637
2615
|
props: {
|
|
2638
2616
|
codeOptions: { default: () => ({}) }
|
|
2639
2617
|
},
|
|
@@ -2699,7 +2677,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2699
2677
|
};
|
|
2700
2678
|
return (_ctx, _cache) => {
|
|
2701
2679
|
const _component_magic_code_editor = resolveComponent("magic-code-editor");
|
|
2702
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
2680
|
+
return openBlock(), createElementBlock("div", _hoisted_1$c, [
|
|
2703
2681
|
renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
|
|
2704
2682
|
unref(showSrc) ? (openBlock(), createBlock(_component_magic_code_editor, {
|
|
2705
2683
|
key: 0,
|
|
@@ -2707,7 +2685,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2707
2685
|
"init-values": unref(root),
|
|
2708
2686
|
options: __props.codeOptions,
|
|
2709
2687
|
onSave: saveCode
|
|
2710
|
-
}, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$
|
|
2688
|
+
}, null, 8, ["init-values", "options"])) : (openBlock(), createBlock(_sfc_main$o, {
|
|
2711
2689
|
key: 1,
|
|
2712
2690
|
class: "m-editor-content",
|
|
2713
2691
|
"left-class": "m-editor-framework-left",
|
|
@@ -2726,7 +2704,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2726
2704
|
]),
|
|
2727
2705
|
center: withCtx(() => [
|
|
2728
2706
|
unref(pageLength) > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
2729
|
-
createVNode(_sfc_main$
|
|
2707
|
+
createVNode(_sfc_main$m)
|
|
2730
2708
|
])
|
|
2731
2709
|
]),
|
|
2732
2710
|
_: 2
|
|
@@ -2748,16 +2726,16 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2748
2726
|
}
|
|
2749
2727
|
});
|
|
2750
2728
|
|
|
2751
|
-
const _hoisted_1$
|
|
2729
|
+
const _hoisted_1$b = {
|
|
2752
2730
|
key: 1,
|
|
2753
2731
|
class: "menu-item-text"
|
|
2754
2732
|
};
|
|
2755
|
-
const _hoisted_2$
|
|
2756
|
-
const __default__$
|
|
2733
|
+
const _hoisted_2$6 = { class: "el-dropdown-link menubar-menu-button" };
|
|
2734
|
+
const __default__$j = defineComponent({
|
|
2757
2735
|
name: "MEditorToolButton"
|
|
2758
2736
|
});
|
|
2759
|
-
const _sfc_main$
|
|
2760
|
-
...__default__$
|
|
2737
|
+
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
2738
|
+
...__default__$j,
|
|
2761
2739
|
props: {
|
|
2762
2740
|
data: { default: () => ({
|
|
2763
2741
|
type: "text",
|
|
@@ -2832,7 +2810,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2832
2810
|
__props.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
|
|
2833
2811
|
key: 0,
|
|
2834
2812
|
direction: __props.data.direction || "vertical"
|
|
2835
|
-
}, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
2813
|
+
}, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$b, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
2836
2814
|
__props.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
2837
2815
|
key: 0,
|
|
2838
2816
|
effect: "dark",
|
|
@@ -2846,7 +2824,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2846
2824
|
disabled: unref(disabled)
|
|
2847
2825
|
}, {
|
|
2848
2826
|
default: withCtx(() => [
|
|
2849
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2827
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
2850
2828
|
key: 0,
|
|
2851
2829
|
icon: __props.data.icon
|
|
2852
2830
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2863,7 +2841,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2863
2841
|
disabled: unref(disabled)
|
|
2864
2842
|
}, {
|
|
2865
2843
|
default: withCtx(() => [
|
|
2866
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2844
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
2867
2845
|
key: 0,
|
|
2868
2846
|
icon: __props.data.icon
|
|
2869
2847
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2896,7 +2874,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2896
2874
|
})) : createCommentVNode("", true)
|
|
2897
2875
|
]),
|
|
2898
2876
|
default: withCtx(() => [
|
|
2899
|
-
createElementVNode("span", _hoisted_2$
|
|
2877
|
+
createElementVNode("span", _hoisted_2$6, [
|
|
2900
2878
|
createTextVNode(toDisplayString(__props.data.text), 1),
|
|
2901
2879
|
createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
|
|
2902
2880
|
default: withCtx(() => [
|
|
@@ -2913,11 +2891,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
2913
2891
|
}
|
|
2914
2892
|
});
|
|
2915
2893
|
|
|
2916
|
-
const __default__$
|
|
2894
|
+
const __default__$i = defineComponent({
|
|
2917
2895
|
name: "MEditorNavMenu"
|
|
2918
2896
|
});
|
|
2919
|
-
const _sfc_main$
|
|
2920
|
-
...__default__$
|
|
2897
|
+
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
2898
|
+
...__default__$i,
|
|
2921
2899
|
props: {
|
|
2922
2900
|
data: { default: () => ({}) },
|
|
2923
2901
|
height: { default: 35 }
|
|
@@ -3072,7 +3050,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3072
3050
|
style: normalizeStyle(`width: ${unref(columnWidth)?.[key]}px`)
|
|
3073
3051
|
}, [
|
|
3074
3052
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(buttons)[key], (item, index) => {
|
|
3075
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3053
|
+
return openBlock(), createBlock(_sfc_main$k, {
|
|
3076
3054
|
data: item,
|
|
3077
3055
|
key: index
|
|
3078
3056
|
}, null, 8, ["data"]);
|
|
@@ -3084,12 +3062,12 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3084
3062
|
}
|
|
3085
3063
|
});
|
|
3086
3064
|
|
|
3087
|
-
const _hoisted_1$
|
|
3088
|
-
const __default__$
|
|
3065
|
+
const _hoisted_1$a = { class: "m-editor-props-panel" };
|
|
3066
|
+
const __default__$h = defineComponent({
|
|
3089
3067
|
name: "MEditorPropsPanel"
|
|
3090
3068
|
});
|
|
3091
|
-
const _sfc_main$
|
|
3092
|
-
...__default__$
|
|
3069
|
+
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
3070
|
+
...__default__$h,
|
|
3093
3071
|
emits: ["mounted"],
|
|
3094
3072
|
setup(__props, { expose, emit }) {
|
|
3095
3073
|
const internalInstance = getCurrentInstance();
|
|
@@ -3132,7 +3110,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3132
3110
|
expose({ submit });
|
|
3133
3111
|
return (_ctx, _cache) => {
|
|
3134
3112
|
const _component_m_form = resolveComponent("m-form");
|
|
3135
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3113
|
+
return openBlock(), createElementBlock("div", _hoisted_1$a, [
|
|
3136
3114
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
3137
3115
|
createVNode(_component_m_form, {
|
|
3138
3116
|
ref_key: "configForm",
|
|
@@ -3149,23 +3127,276 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
3149
3127
|
}
|
|
3150
3128
|
});
|
|
3151
3129
|
|
|
3152
|
-
const _hoisted_1$
|
|
3153
|
-
const _hoisted_2$
|
|
3154
|
-
|
|
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,
|
|
3130
|
+
const _hoisted_1$9 = { class: "m-editor-wrapper" };
|
|
3131
|
+
const _hoisted_2$5 = {
|
|
3132
|
+
key: 0,
|
|
3160
3133
|
class: "m-editor-content-bottom"
|
|
3161
3134
|
};
|
|
3162
|
-
const
|
|
3163
|
-
const
|
|
3164
|
-
const
|
|
3165
|
-
key:
|
|
3135
|
+
const _hoisted_3$3 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
|
|
3136
|
+
const _hoisted_4$2 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3137
|
+
const _hoisted_5$1 = {
|
|
3138
|
+
key: 1,
|
|
3166
3139
|
class: "m-editor-content-bottom"
|
|
3167
3140
|
};
|
|
3168
|
-
const
|
|
3141
|
+
const _hoisted_6$1 = /* @__PURE__ */ createTextVNode("\u5173\u95ED");
|
|
3142
|
+
const __default__$g = defineComponent({
|
|
3143
|
+
name: "MEditorCodeDraftEditor"
|
|
3144
|
+
});
|
|
3145
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
3146
|
+
...__default__$g,
|
|
3147
|
+
props: {
|
|
3148
|
+
id: null,
|
|
3149
|
+
content: null,
|
|
3150
|
+
editable: { type: Boolean, default: true },
|
|
3151
|
+
autoSaveDraft: { type: Boolean, default: true },
|
|
3152
|
+
codeOptions: null,
|
|
3153
|
+
language: null
|
|
3154
|
+
},
|
|
3155
|
+
emits: ["save", "close", "saveAndClose"],
|
|
3156
|
+
setup(__props, { emit }) {
|
|
3157
|
+
const props = __props;
|
|
3158
|
+
const services = inject("services");
|
|
3159
|
+
const codeContent = ref("");
|
|
3160
|
+
const editorContent = ref("");
|
|
3161
|
+
const codeEditor = ref();
|
|
3162
|
+
const originCodeContent = ref("");
|
|
3163
|
+
const codeOptions = computed(() => ({
|
|
3164
|
+
...props.codeOptions,
|
|
3165
|
+
readOnly: !props.editable
|
|
3166
|
+
}));
|
|
3167
|
+
watchEffect(() => {
|
|
3168
|
+
codeContent.value = props.content;
|
|
3169
|
+
if (!originCodeContent.value) {
|
|
3170
|
+
originCodeContent.value = codeContent.value;
|
|
3171
|
+
}
|
|
3172
|
+
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3173
|
+
if (codeDraft) {
|
|
3174
|
+
codeContent.value = codeDraft;
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
const saveCodeDraft = async (codeValue) => {
|
|
3178
|
+
if (!props.autoSaveDraft)
|
|
3179
|
+
return;
|
|
3180
|
+
if (originCodeContent.value === codeValue) {
|
|
3181
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
services?.codeBlockService.setCodeDraft(props.id, codeValue);
|
|
3185
|
+
tMagicMessage.success(`\u4EE3\u7801\u8349\u7A3F\u4FDD\u5B58\u6210\u529F ${datetimeFormatter(new Date())}`);
|
|
3186
|
+
};
|
|
3187
|
+
const saveCode = () => {
|
|
3188
|
+
if (!codeEditor.value || !props.editable)
|
|
3189
|
+
return;
|
|
3190
|
+
editorContent.value = codeEditor.value.getEditor()?.getValue();
|
|
3191
|
+
emit("save", editorContent.value);
|
|
3192
|
+
};
|
|
3193
|
+
const saveAndClose = () => {
|
|
3194
|
+
if (!codeEditor.value || !props.editable)
|
|
3195
|
+
return;
|
|
3196
|
+
editorContent.value = codeEditor.value.getEditor()?.getValue();
|
|
3197
|
+
emit("saveAndClose", editorContent.value);
|
|
3198
|
+
};
|
|
3199
|
+
const close = async () => {
|
|
3200
|
+
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3201
|
+
if (codeDraft) {
|
|
3202
|
+
tMagicMessageBox.confirm("\u60A8\u6709\u4EE3\u7801\u4FEE\u6539\u672A\u4FDD\u5B58\uFF0C\u662F\u5426\u4FDD\u5B58\u540E\u518D\u5173\u95ED\uFF1F", "\u63D0\u793A", {
|
|
3203
|
+
confirmButtonText: "\u786E\u8BA4",
|
|
3204
|
+
cancelButtonText: "\u53D6\u6D88",
|
|
3205
|
+
type: "warning"
|
|
3206
|
+
}).then(async () => {
|
|
3207
|
+
saveAndClose();
|
|
3208
|
+
}).catch(() => {
|
|
3209
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3210
|
+
emit("close");
|
|
3211
|
+
});
|
|
3212
|
+
} else {
|
|
3213
|
+
emit("close");
|
|
3214
|
+
}
|
|
3215
|
+
};
|
|
3216
|
+
return (_ctx, _cache) => {
|
|
3217
|
+
return openBlock(), createElementBlock("div", _hoisted_1$9, [
|
|
3218
|
+
createVNode(_sfc_main$q, {
|
|
3219
|
+
ref_key: "codeEditor",
|
|
3220
|
+
ref: codeEditor,
|
|
3221
|
+
class: "m-editor-container",
|
|
3222
|
+
"init-values": `${codeContent.value}`,
|
|
3223
|
+
onSave: saveCodeDraft,
|
|
3224
|
+
language: __props.language,
|
|
3225
|
+
options: unref(codeOptions)
|
|
3226
|
+
}, null, 8, ["init-values", "language", "options"]),
|
|
3227
|
+
__props.editable ? (openBlock(), createElementBlock("div", _hoisted_2$5, [
|
|
3228
|
+
createVNode(unref(TMagicButton), {
|
|
3229
|
+
type: "primary",
|
|
3230
|
+
class: "button",
|
|
3231
|
+
onClick: saveCode
|
|
3232
|
+
}, {
|
|
3233
|
+
default: withCtx(() => [
|
|
3234
|
+
_hoisted_3$3
|
|
3235
|
+
]),
|
|
3236
|
+
_: 1
|
|
3237
|
+
}),
|
|
3238
|
+
createVNode(unref(TMagicButton), {
|
|
3239
|
+
type: "primary",
|
|
3240
|
+
class: "button",
|
|
3241
|
+
onClick: close
|
|
3242
|
+
}, {
|
|
3243
|
+
default: withCtx(() => [
|
|
3244
|
+
_hoisted_4$2
|
|
3245
|
+
]),
|
|
3246
|
+
_: 1
|
|
3247
|
+
})
|
|
3248
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_5$1, [
|
|
3249
|
+
createVNode(unref(TMagicButton), {
|
|
3250
|
+
type: "primary",
|
|
3251
|
+
class: "button",
|
|
3252
|
+
onClick: close
|
|
3253
|
+
}, {
|
|
3254
|
+
default: withCtx(() => [
|
|
3255
|
+
_hoisted_6$1
|
|
3256
|
+
]),
|
|
3257
|
+
_: 1
|
|
3258
|
+
})
|
|
3259
|
+
]))
|
|
3260
|
+
]);
|
|
3261
|
+
};
|
|
3262
|
+
}
|
|
3263
|
+
});
|
|
3264
|
+
|
|
3265
|
+
const _hoisted_1$8 = { class: "code-name-wrapper" };
|
|
3266
|
+
const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
|
|
3267
|
+
const _hoisted_3$2 = { class: "code-name-wrapper" };
|
|
3268
|
+
const _hoisted_4$1 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "\u53C2\u6570\u5B9A\u4E49", -1);
|
|
3269
|
+
const __default__$f = defineComponent({
|
|
3270
|
+
name: "MEditorFunctionEditor"
|
|
3271
|
+
});
|
|
3272
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
3273
|
+
...__default__$f,
|
|
3274
|
+
props: {
|
|
3275
|
+
id: null,
|
|
3276
|
+
name: null,
|
|
3277
|
+
content: null,
|
|
3278
|
+
editable: { type: Boolean, default: true },
|
|
3279
|
+
autoSaveDraft: { type: Boolean, default: true },
|
|
3280
|
+
codeOptions: null
|
|
3281
|
+
},
|
|
3282
|
+
emits: ["change", "field-input"],
|
|
3283
|
+
setup(__props, { emit }) {
|
|
3284
|
+
const props = __props;
|
|
3285
|
+
const tableConfig = {
|
|
3286
|
+
border: true,
|
|
3287
|
+
enableFullscreen: false,
|
|
3288
|
+
name: "params",
|
|
3289
|
+
items: [
|
|
3290
|
+
{
|
|
3291
|
+
type: "text",
|
|
3292
|
+
label: "\u53C2\u6570\u540D",
|
|
3293
|
+
name: "name"
|
|
3294
|
+
}
|
|
3295
|
+
]
|
|
3296
|
+
};
|
|
3297
|
+
const services = inject("services");
|
|
3298
|
+
const codeName = ref("");
|
|
3299
|
+
const codeContent = ref("");
|
|
3300
|
+
const evalRes = ref(true);
|
|
3301
|
+
provide("mForm", {
|
|
3302
|
+
$emit: emit,
|
|
3303
|
+
setField: () => {
|
|
3304
|
+
}
|
|
3305
|
+
});
|
|
3306
|
+
const tableModel = ref();
|
|
3307
|
+
watchEffect(() => {
|
|
3308
|
+
codeName.value = props.name;
|
|
3309
|
+
codeContent.value = props.content;
|
|
3310
|
+
});
|
|
3311
|
+
const initTableModel = () => {
|
|
3312
|
+
const codeDsl = services?.codeBlockService.getCodeDslSync();
|
|
3313
|
+
if (!codeDsl)
|
|
3314
|
+
return;
|
|
3315
|
+
tableModel.value = {
|
|
3316
|
+
params: codeDsl[props.id]?.params || []
|
|
3317
|
+
};
|
|
3318
|
+
};
|
|
3319
|
+
initTableModel();
|
|
3320
|
+
const beforeSave = (codeValue) => {
|
|
3321
|
+
try {
|
|
3322
|
+
eval(codeValue);
|
|
3323
|
+
return true;
|
|
3324
|
+
} catch (e) {
|
|
3325
|
+
tMagicMessage.error(e.stack);
|
|
3326
|
+
return false;
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
const saveCode = async (codeValue2) => {
|
|
3330
|
+
if (!props.editable)
|
|
3331
|
+
return;
|
|
3332
|
+
evalRes.value = beforeSave(codeValue2);
|
|
3333
|
+
if (evalRes.value) {
|
|
3334
|
+
await services?.codeBlockService.setCodeDslById(props.id, {
|
|
3335
|
+
name: codeName.value,
|
|
3336
|
+
content: codeValue2,
|
|
3337
|
+
params: tableModel.value?.params || []
|
|
3338
|
+
});
|
|
3339
|
+
tMagicMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
|
|
3340
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3341
|
+
}
|
|
3342
|
+
};
|
|
3343
|
+
const saveAndClose = async (codeValue2) => {
|
|
3344
|
+
await saveCode(codeValue2);
|
|
3345
|
+
if (evalRes.value) {
|
|
3346
|
+
close();
|
|
3347
|
+
}
|
|
3348
|
+
};
|
|
3349
|
+
const close = () => {
|
|
3350
|
+
services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
3351
|
+
};
|
|
3352
|
+
return (_ctx, _cache) => {
|
|
3353
|
+
const _component_m_form_table = resolveComponent("m-form-table");
|
|
3354
|
+
return openBlock(), createBlock(unref(TMagicCard), { shadow: "never" }, {
|
|
3355
|
+
header: withCtx(() => [
|
|
3356
|
+
createElementVNode("div", _hoisted_1$8, [
|
|
3357
|
+
_hoisted_2$4,
|
|
3358
|
+
createVNode(unref(TMagicInput), {
|
|
3359
|
+
class: "code-name-input",
|
|
3360
|
+
modelValue: codeName.value,
|
|
3361
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => codeName.value = $event),
|
|
3362
|
+
disabled: !__props.editable
|
|
3363
|
+
}, null, 8, ["modelValue", "disabled"])
|
|
3364
|
+
]),
|
|
3365
|
+
createElementVNode("div", _hoisted_3$2, [
|
|
3366
|
+
_hoisted_4$1,
|
|
3367
|
+
createVNode(_component_m_form_table, {
|
|
3368
|
+
style: { "width": "320px" },
|
|
3369
|
+
config: tableConfig,
|
|
3370
|
+
model: tableModel.value,
|
|
3371
|
+
enableToggleMode: false,
|
|
3372
|
+
name: "params",
|
|
3373
|
+
prop: "params",
|
|
3374
|
+
size: "small"
|
|
3375
|
+
}, null, 8, ["model"])
|
|
3376
|
+
])
|
|
3377
|
+
]),
|
|
3378
|
+
default: withCtx(() => [
|
|
3379
|
+
createVNode(_sfc_main$h, {
|
|
3380
|
+
id: __props.id,
|
|
3381
|
+
content: codeContent.value,
|
|
3382
|
+
editable: __props.editable,
|
|
3383
|
+
autoSaveDraft: __props.autoSaveDraft,
|
|
3384
|
+
codeOptions: __props.codeOptions,
|
|
3385
|
+
language: "javascript",
|
|
3386
|
+
onSave: saveCode,
|
|
3387
|
+
onSaveAndClose: saveAndClose,
|
|
3388
|
+
onClose: close
|
|
3389
|
+
}, null, 8, ["id", "content", "editable", "autoSaveDraft", "codeOptions"])
|
|
3390
|
+
]),
|
|
3391
|
+
_: 1
|
|
3392
|
+
});
|
|
3393
|
+
};
|
|
3394
|
+
}
|
|
3395
|
+
});
|
|
3396
|
+
|
|
3397
|
+
const _hoisted_1$7 = ["id"];
|
|
3398
|
+
const _hoisted_2$3 = { class: "list-item" };
|
|
3399
|
+
const _hoisted_3$1 = { class: "code-name" };
|
|
3169
3400
|
const __default__$e = defineComponent({
|
|
3170
3401
|
name: "MEditorCodeBlockEditor"
|
|
3171
3402
|
});
|
|
@@ -3173,22 +3404,22 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3173
3404
|
...__default__$e,
|
|
3174
3405
|
setup(__props) {
|
|
3175
3406
|
const services = inject("services");
|
|
3176
|
-
const
|
|
3407
|
+
const codeOptions = inject("codeOptions", {});
|
|
3177
3408
|
const left = ref(200);
|
|
3178
3409
|
const currentTitle = ref("");
|
|
3179
3410
|
const codeConfig = ref(null);
|
|
3180
3411
|
const state = reactive({
|
|
3181
3412
|
codeList: []
|
|
3182
3413
|
});
|
|
3183
|
-
const isShowCodeBlockEditor = computed(
|
|
3184
|
-
() => codeConfig.value && services?.codeBlockService.getCodeEditorShowStatus() || false
|
|
3185
|
-
);
|
|
3186
3414
|
const mode = computed(() => services?.codeBlockService.getMode());
|
|
3187
3415
|
const id = computed(() => services?.codeBlockService.getId() || "");
|
|
3188
3416
|
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
3189
3417
|
const selectedIds = computed(() => services?.codeBlockService.getCombineIds() || []);
|
|
3190
3418
|
watchEffect(async () => {
|
|
3191
|
-
codeConfig.value = await services?.codeBlockService.getCodeContentById(id.value) || null;
|
|
3419
|
+
codeConfig.value = cloneDeep(await services?.codeBlockService.getCodeContentById(id.value)) || null;
|
|
3420
|
+
if (!codeConfig.value)
|
|
3421
|
+
return;
|
|
3422
|
+
codeConfig.value.content = serializeConfig(codeConfig.value.content);
|
|
3192
3423
|
});
|
|
3193
3424
|
watchEffect(async () => {
|
|
3194
3425
|
const codeDsl = await services?.codeBlockService.getCodeDslByIds(selectedIds.value) || null;
|
|
@@ -3203,47 +3434,24 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3203
3434
|
});
|
|
3204
3435
|
currentTitle.value = state.codeList[0]?.name || "";
|
|
3205
3436
|
});
|
|
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
3437
|
const selectHandler = (data) => {
|
|
3230
3438
|
services?.codeBlockService.setId(data.id);
|
|
3231
3439
|
currentTitle.value = data.name;
|
|
3232
3440
|
};
|
|
3233
3441
|
return (_ctx, _cache) => {
|
|
3234
3442
|
return openBlock(), createBlock(unref(TMagicDialog), {
|
|
3235
|
-
|
|
3236
|
-
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(isShowCodeBlockEditor) ? isShowCodeBlockEditor.value = $event : null),
|
|
3443
|
+
"model-value": true,
|
|
3237
3444
|
class: "code-editor-dialog",
|
|
3238
3445
|
title: currentTitle.value,
|
|
3239
3446
|
fullscreen: true,
|
|
3240
|
-
"
|
|
3241
|
-
"append-to-body": true
|
|
3447
|
+
"close-on-press-escape": false,
|
|
3448
|
+
"append-to-body": true,
|
|
3449
|
+
"show-close": false
|
|
3242
3450
|
}, {
|
|
3243
3451
|
default: withCtx(() => [
|
|
3244
|
-
createVNode(_sfc_main$
|
|
3452
|
+
createVNode(_sfc_main$o, {
|
|
3245
3453
|
left: left.value,
|
|
3246
|
-
"onUpdate:left": _cache[
|
|
3454
|
+
"onUpdate:left": _cache[0] || (_cache[0] = ($event) => left.value = $event),
|
|
3247
3455
|
"min-left": 45,
|
|
3248
3456
|
class: "code-editor-layout"
|
|
3249
3457
|
}, createSlots({
|
|
@@ -3255,72 +3463,15 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3255
3463
|
])
|
|
3256
3464
|
}, [
|
|
3257
3465
|
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: unref(id) }),
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
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
|
-
})
|
|
3466
|
+
codeConfig.value ? (openBlock(), createBlock(_sfc_main$g, {
|
|
3467
|
+
key: 0,
|
|
3468
|
+
id: unref(id),
|
|
3469
|
+
name: codeConfig.value.name,
|
|
3470
|
+
content: codeConfig.value.content,
|
|
3471
|
+
editable: !!unref(editable),
|
|
3472
|
+
autoSaveDraft: unref(mode) === unref(CodeEditorMode).EDITOR,
|
|
3473
|
+
codeOptions: unref(codeOptions)
|
|
3474
|
+
}, null, 8, ["id", "name", "content", "editable", "autoSaveDraft", "codeOptions"])) : createCommentVNode("", true)
|
|
3324
3475
|
], 2)) : createCommentVNode("", true)
|
|
3325
3476
|
]),
|
|
3326
3477
|
_: 2
|
|
@@ -3355,7 +3506,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3355
3506
|
]), 1032, ["left"])
|
|
3356
3507
|
]),
|
|
3357
3508
|
_: 3
|
|
3358
|
-
}, 8, ["
|
|
3509
|
+
}, 8, ["title"]);
|
|
3359
3510
|
};
|
|
3360
3511
|
}
|
|
3361
3512
|
});
|
|
@@ -3394,41 +3545,38 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3394
3545
|
const props = __props;
|
|
3395
3546
|
const services = inject("services");
|
|
3396
3547
|
const state = reactive({
|
|
3397
|
-
codeList: []
|
|
3398
|
-
bindComps: {}
|
|
3548
|
+
codeList: []
|
|
3399
3549
|
});
|
|
3400
3550
|
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
3401
|
-
const
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
const
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
id: compId,
|
|
3411
|
-
name: getCompName(compId)
|
|
3551
|
+
const isShowCodeBlockEditor = computed(() => services?.codeBlockService.getCodeEditorShowStatus() || false);
|
|
3552
|
+
const codeCombineInfo = ref(null);
|
|
3553
|
+
const getBindCompsByCodeId = (codeId) => {
|
|
3554
|
+
if (!codeCombineInfo.value || !codeCombineInfo.value[codeId])
|
|
3555
|
+
return [];
|
|
3556
|
+
const bindCompsId = Object.keys(codeCombineInfo.value[codeId]);
|
|
3557
|
+
return bindCompsId.map((compId) => ({
|
|
3558
|
+
compId,
|
|
3559
|
+
compName: getCompName(compId)
|
|
3412
3560
|
}));
|
|
3413
|
-
state.bindComps[codeId] = compsInfo;
|
|
3414
3561
|
};
|
|
3415
3562
|
const initList = async () => {
|
|
3416
|
-
const codeDsl = await services?.codeBlockService.getCodeDsl() || null;
|
|
3417
|
-
|
|
3563
|
+
const codeDsl = cloneDeep(await services?.codeBlockService.getCodeDsl()) || null;
|
|
3564
|
+
codeCombineInfo.value = cloneDeep(services?.codeBlockService.getCombineInfo()) || null;
|
|
3565
|
+
if (!codeDsl || !codeCombineInfo.value)
|
|
3418
3566
|
return;
|
|
3419
3567
|
state.codeList = [];
|
|
3420
3568
|
forIn(codeDsl, (value, codeId) => {
|
|
3421
|
-
getBindCompsByCodeId(codeId, value);
|
|
3422
3569
|
state.codeList.push({
|
|
3423
3570
|
id: codeId,
|
|
3424
3571
|
name: value.name,
|
|
3425
3572
|
codeBlockContent: value,
|
|
3426
|
-
showRelation: true
|
|
3573
|
+
showRelation: true,
|
|
3574
|
+
combineInfo: getBindCompsByCodeId(codeId)
|
|
3427
3575
|
});
|
|
3428
3576
|
});
|
|
3429
3577
|
};
|
|
3430
3578
|
watch(
|
|
3431
|
-
() => services?.codeBlockService.
|
|
3579
|
+
[() => services?.codeBlockService.getCodeDslSync(), () => services?.codeBlockService.refreshCombineInfo()],
|
|
3432
3580
|
() => {
|
|
3433
3581
|
initList();
|
|
3434
3582
|
},
|
|
@@ -3437,20 +3585,6 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3437
3585
|
deep: true
|
|
3438
3586
|
}
|
|
3439
3587
|
);
|
|
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
3588
|
const createCodeBlock = async () => {
|
|
3455
3589
|
const { codeBlockService } = services || {};
|
|
3456
3590
|
if (!codeBlockService) {
|
|
@@ -3461,7 +3595,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3461
3595
|
name: "\u4EE3\u7801\u5757",
|
|
3462
3596
|
content: `() => {
|
|
3463
3597
|
// place your code here
|
|
3464
|
-
}
|
|
3598
|
+
}`,
|
|
3599
|
+
params: []
|
|
3465
3600
|
};
|
|
3466
3601
|
await codeBlockService.setMode(CodeEditorMode.EDITOR);
|
|
3467
3602
|
const id = await codeBlockService.getUniqueId();
|
|
@@ -3473,7 +3608,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3473
3608
|
services?.codeBlockService.setCodeEditorContent(true, key);
|
|
3474
3609
|
};
|
|
3475
3610
|
const deleteCode = (key) => {
|
|
3476
|
-
const
|
|
3611
|
+
const currentCode = state.codeList.find((codeItem) => codeItem.id === key);
|
|
3612
|
+
const existBinds = !isEmpty(currentCode?.combineInfo);
|
|
3477
3613
|
const undeleteableList = services?.codeBlockService.getUndeletableList() || [];
|
|
3478
3614
|
if (!existBinds && !undeleteableList.includes(key)) {
|
|
3479
3615
|
services?.codeBlockService.deleteCodeDslByIds([key]);
|
|
@@ -3556,7 +3692,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3556
3692
|
class: "list-container"
|
|
3557
3693
|
}, [
|
|
3558
3694
|
createElementVNode("div", _hoisted_5, [
|
|
3559
|
-
createElementVNode("
|
|
3695
|
+
createElementVNode("span", _hoisted_6, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1),
|
|
3560
3696
|
createElementVNode("div", _hoisted_7, [
|
|
3561
3697
|
createVNode(unref(TMagicTooltip), {
|
|
3562
3698
|
effect: "dark",
|
|
@@ -3564,7 +3700,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3564
3700
|
placement: "bottom"
|
|
3565
3701
|
}, {
|
|
3566
3702
|
default: withCtx(() => [
|
|
3567
|
-
createVNode(_sfc_main$
|
|
3703
|
+
createVNode(_sfc_main$n, {
|
|
3568
3704
|
icon: unref(editable) ? unref(Edit) : unref(View),
|
|
3569
3705
|
class: "edit-icon",
|
|
3570
3706
|
onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
@@ -3572,14 +3708,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3572
3708
|
]),
|
|
3573
3709
|
_: 2
|
|
3574
3710
|
}, 1032, ["content"]),
|
|
3575
|
-
|
|
3711
|
+
data.combineInfo && data.combineInfo.length > 0 ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3576
3712
|
key: 0,
|
|
3577
3713
|
effect: "dark",
|
|
3578
3714
|
content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
|
|
3579
3715
|
placement: "bottom"
|
|
3580
3716
|
}, {
|
|
3581
3717
|
default: withCtx(() => [
|
|
3582
|
-
createVNode(_sfc_main$
|
|
3718
|
+
createVNode(_sfc_main$n, {
|
|
3583
3719
|
icon: unref(Link),
|
|
3584
3720
|
class: "edit-icon",
|
|
3585
3721
|
onClick: withModifiers(($event) => toggleCombineRelation(data), ["stop"])
|
|
@@ -3594,7 +3730,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3594
3730
|
placement: "bottom"
|
|
3595
3731
|
}, {
|
|
3596
3732
|
default: withCtx(() => [
|
|
3597
|
-
createVNode(_sfc_main$
|
|
3733
|
+
createVNode(_sfc_main$n, {
|
|
3598
3734
|
icon: unref(Close),
|
|
3599
3735
|
class: "edit-icon",
|
|
3600
3736
|
onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
@@ -3608,18 +3744,18 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3608
3744
|
})
|
|
3609
3745
|
])
|
|
3610
3746
|
]),
|
|
3611
|
-
data.showRelation &&
|
|
3747
|
+
data.showRelation && data.combineInfo && data.combineInfo.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
3612
3748
|
_hoisted_9,
|
|
3613
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
3749
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(data.combineInfo, (comp, index) => {
|
|
3614
3750
|
return openBlock(), createBlock(unref(TMagicButton), {
|
|
3615
3751
|
key: index,
|
|
3616
3752
|
class: "code-comp",
|
|
3617
3753
|
size: "small",
|
|
3618
3754
|
plain: true,
|
|
3619
|
-
onClick: withModifiers(($event) => selectComp(comp.
|
|
3755
|
+
onClick: withModifiers(($event) => selectComp(comp.compId), ["stop"])
|
|
3620
3756
|
}, {
|
|
3621
3757
|
default: withCtx(() => [
|
|
3622
|
-
createTextVNode(toDisplayString(comp.
|
|
3758
|
+
createTextVNode(toDisplayString(comp.compName), 1)
|
|
3623
3759
|
]),
|
|
3624
3760
|
_: 2
|
|
3625
3761
|
}, 1032, ["onClick"]);
|
|
@@ -3629,12 +3765,12 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3629
3765
|
]),
|
|
3630
3766
|
_: 3
|
|
3631
3767
|
}, 8, ["data"])) : createCommentVNode("", true),
|
|
3632
|
-
|
|
3768
|
+
unref(isShowCodeBlockEditor) ? (openBlock(), createBlock(_sfc_main$f, { key: 1 }, {
|
|
3633
3769
|
"code-block-edit-panel-header": withCtx(({ id }) => [
|
|
3634
3770
|
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
3635
3771
|
]),
|
|
3636
3772
|
_: 3
|
|
3637
|
-
})
|
|
3773
|
+
})) : createCommentVNode("", true)
|
|
3638
3774
|
]);
|
|
3639
3775
|
};
|
|
3640
3776
|
}
|
|
@@ -3734,7 +3870,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3734
3870
|
name: `${index}`
|
|
3735
3871
|
}, {
|
|
3736
3872
|
title: withCtx(() => [
|
|
3737
|
-
createVNode(_sfc_main$
|
|
3873
|
+
createVNode(_sfc_main$n, { icon: unref(Grid) }, null, 8, ["icon"]),
|
|
3738
3874
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3739
3875
|
]),
|
|
3740
3876
|
default: withCtx(() => [
|
|
@@ -3749,7 +3885,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3749
3885
|
onDrag: dragHandler
|
|
3750
3886
|
}, [
|
|
3751
3887
|
renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
3752
|
-
createVNode(_sfc_main$
|
|
3888
|
+
createVNode(_sfc_main$n, {
|
|
3753
3889
|
icon: item.icon
|
|
3754
3890
|
}, null, 8, ["icon"]),
|
|
3755
3891
|
createVNode(unref(TMagicTooltip), {
|
|
@@ -3872,7 +4008,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
3872
4008
|
}, [
|
|
3873
4009
|
createElementVNode("div", null, [
|
|
3874
4010
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuData, (item, index) => {
|
|
3875
|
-
return openBlock(), createBlock(_sfc_main$
|
|
4011
|
+
return openBlock(), createBlock(_sfc_main$k, {
|
|
3876
4012
|
"event-type": "mouseup",
|
|
3877
4013
|
data: item,
|
|
3878
4014
|
key: index,
|
|
@@ -4159,28 +4295,37 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
4159
4295
|
await expandNodes();
|
|
4160
4296
|
setTreeKeyStatus();
|
|
4161
4297
|
});
|
|
4162
|
-
const
|
|
4163
|
-
const
|
|
4298
|
+
const layerPanel = ref();
|
|
4299
|
+
const mouseenterHandler = () => {
|
|
4300
|
+
layerPanel.value?.focus();
|
|
4301
|
+
};
|
|
4302
|
+
const mouseleaveHandler = () => {
|
|
4303
|
+
layerPanel.value?.blur();
|
|
4304
|
+
if (selectedIds.value.length === 1)
|
|
4305
|
+
isMultiSelectStatus.value = false;
|
|
4306
|
+
};
|
|
4307
|
+
let keycon;
|
|
4308
|
+
onMounted(() => {
|
|
4309
|
+
layerPanel.value?.addEventListener("mouseenter", mouseenterHandler);
|
|
4310
|
+
layerPanel.value?.addEventListener("mouseleave", mouseleaveHandler);
|
|
4311
|
+
keycon = new KeyController(layerPanel.value);
|
|
4164
4312
|
const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
|
|
4165
4313
|
const ctrl = isMac ? "meta" : "ctrl";
|
|
4166
|
-
keycon.
|
|
4167
|
-
keycon.value.keydown(ctrl, (e) => {
|
|
4314
|
+
keycon.keydown(ctrl, (e) => {
|
|
4168
4315
|
e.inputEvent.preventDefault();
|
|
4169
4316
|
isMultiSelectStatus.value = true;
|
|
4170
|
-
})
|
|
4171
|
-
keycon.value.on("blur", () => {
|
|
4317
|
+
}).on("blur", () => {
|
|
4172
4318
|
isMultiSelectStatus.value = false;
|
|
4173
|
-
})
|
|
4174
|
-
keycon.value.keyup(ctrl, (e) => {
|
|
4319
|
+
}).keyup(ctrl, (e) => {
|
|
4175
4320
|
e.inputEvent.preventDefault();
|
|
4176
4321
|
isMultiSelectStatus.value = false;
|
|
4177
4322
|
});
|
|
4178
|
-
};
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
};
|
|
4323
|
+
});
|
|
4324
|
+
onUnmounted(() => {
|
|
4325
|
+
layerPanel.value?.removeEventListener("mouseenter", mouseenterHandler);
|
|
4326
|
+
layerPanel.value?.removeEventListener("mouseleave", mouseleaveHandler);
|
|
4327
|
+
keycon.destroy();
|
|
4328
|
+
});
|
|
4184
4329
|
const clicked = ref(false);
|
|
4185
4330
|
const highlightNode = computed(() => editorService?.get("highlightNode"));
|
|
4186
4331
|
const highlightHandler = throttle((data) => {
|
|
@@ -4235,77 +4380,78 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
4235
4380
|
menu.value?.show(event);
|
|
4236
4381
|
};
|
|
4237
4382
|
return (_ctx, _cache) => {
|
|
4238
|
-
return openBlock(),
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4383
|
+
return openBlock(), createElementBlock("div", {
|
|
4384
|
+
ref_key: "layerPanel",
|
|
4385
|
+
ref: layerPanel
|
|
4386
|
+
}, [
|
|
4387
|
+
createVNode(unref(TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
|
|
4388
|
+
default: withCtx(() => [
|
|
4389
|
+
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
4390
|
+
createVNode(unref(TMagicInput), {
|
|
4391
|
+
modelValue: filterText.value,
|
|
4392
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
|
|
4393
|
+
class: "search-input",
|
|
4394
|
+
size: "small",
|
|
4395
|
+
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
4396
|
+
clearable: "",
|
|
4397
|
+
"prefix-icon": unref(Search),
|
|
4398
|
+
onChange: filterTextChangeHandler
|
|
4399
|
+
}, null, 8, ["modelValue", "prefix-icon"]),
|
|
4400
|
+
unref(values).length ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
4401
|
+
key: 0,
|
|
4402
|
+
class: "magic-editor-layer-tree",
|
|
4403
|
+
ref_key: "tree",
|
|
4404
|
+
ref: tree,
|
|
4405
|
+
"node-key": "id",
|
|
4406
|
+
"empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
|
|
4407
|
+
draggable: "",
|
|
4408
|
+
"default-expanded-keys": unref(defaultExpandedKeys),
|
|
4409
|
+
load: loadItems,
|
|
4410
|
+
data: unref(values),
|
|
4411
|
+
"expand-on-click-node": false,
|
|
4412
|
+
"highlight-current": true,
|
|
4413
|
+
props: {
|
|
4414
|
+
children: "items"
|
|
4415
|
+
},
|
|
4416
|
+
"filter-node-method": filterNode,
|
|
4417
|
+
"allow-drop": allowDrop,
|
|
4418
|
+
"show-checkbox": isMultiSelectStatus.value || unref(selectedIds).length > 1,
|
|
4419
|
+
onNodeClick: clickHandler,
|
|
4420
|
+
onNodeContextmenu: contextmenu,
|
|
4421
|
+
onNodeDragEnd: handleDragEnd,
|
|
4422
|
+
onNodeCollapse: handleCollapse,
|
|
4423
|
+
onNodeExpand: handleExpand,
|
|
4424
|
+
onCheck: multiClickHandler,
|
|
4425
|
+
onMousedown: toggleClickFlag,
|
|
4426
|
+
onMouseup: toggleClickFlag
|
|
4427
|
+
}, {
|
|
4428
|
+
default: withCtx(({ node, data }) => [
|
|
4429
|
+
createElementVNode("div", {
|
|
4430
|
+
id: data.id,
|
|
4431
|
+
class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": canHighlight(data) }]),
|
|
4432
|
+
onMouseenter: ($event) => unref(highlightHandler)(data)
|
|
4433
|
+
}, [
|
|
4434
|
+
renderSlot(_ctx.$slots, "layer-node-content", {
|
|
4435
|
+
node,
|
|
4436
|
+
data
|
|
4437
|
+
}, () => [
|
|
4438
|
+
createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
|
|
4439
|
+
])
|
|
4440
|
+
], 42, _hoisted_1$4)
|
|
4441
|
+
]),
|
|
4442
|
+
_: 3
|
|
4443
|
+
}, 8, ["default-expanded-keys", "data", "show-checkbox"])) : createCommentVNode("", true),
|
|
4444
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4445
|
+
createVNode(_sfc_main$b, {
|
|
4446
|
+
ref_key: "menu",
|
|
4447
|
+
ref: menu,
|
|
4448
|
+
"layer-content-menu": __props.layerContentMenu
|
|
4449
|
+
}, null, 8, ["layer-content-menu"])
|
|
4450
|
+
]))
|
|
4451
|
+
]),
|
|
4452
|
+
_: 3
|
|
4453
|
+
})
|
|
4454
|
+
], 512);
|
|
4309
4455
|
};
|
|
4310
4456
|
}
|
|
4311
4457
|
});
|
|
@@ -4388,7 +4534,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
4388
4534
|
(openBlock(), createElementBlock("div", {
|
|
4389
4535
|
key: config.text
|
|
4390
4536
|
}, [
|
|
4391
|
-
config.icon ? (openBlock(), createBlock(_sfc_main$
|
|
4537
|
+
config.icon ? (openBlock(), createBlock(_sfc_main$n, {
|
|
4392
4538
|
key: 0,
|
|
4393
4539
|
icon: config.icon
|
|
4394
4540
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -4606,14 +4752,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4606
4752
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4607
4753
|
onClick: addPage
|
|
4608
4754
|
}, [
|
|
4609
|
-
createVNode(_sfc_main$
|
|
4755
|
+
createVNode(_sfc_main$n, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
4610
4756
|
])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
|
|
4611
4757
|
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
4612
4758
|
key: 2,
|
|
4613
4759
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4614
4760
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
4615
4761
|
}, [
|
|
4616
|
-
createVNode(_sfc_main$
|
|
4762
|
+
createVNode(_sfc_main$n, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
|
|
4617
4763
|
])) : createCommentVNode("", true),
|
|
4618
4764
|
unref(pageLength) ? (openBlock(), createElementBlock("div", {
|
|
4619
4765
|
key: 3,
|
|
@@ -4629,7 +4775,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4629
4775
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4630
4776
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
4631
4777
|
}, [
|
|
4632
|
-
createVNode(_sfc_main$
|
|
4778
|
+
createVNode(_sfc_main$n, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
|
|
4633
4779
|
])) : createCommentVNode("", true)
|
|
4634
4780
|
], 512);
|
|
4635
4781
|
};
|
|
@@ -4701,7 +4847,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4701
4847
|
default: withCtx(() => [
|
|
4702
4848
|
createElementVNode("div", null, [
|
|
4703
4849
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
4704
|
-
createVNode(_sfc_main$
|
|
4850
|
+
createVNode(_sfc_main$k, {
|
|
4705
4851
|
data: {
|
|
4706
4852
|
type: "button",
|
|
4707
4853
|
text: "\u590D\u5236",
|
|
@@ -4709,7 +4855,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
4709
4855
|
handler: () => copy(item)
|
|
4710
4856
|
}
|
|
4711
4857
|
}, null, 8, ["data"]),
|
|
4712
|
-
createVNode(_sfc_main$
|
|
4858
|
+
createVNode(_sfc_main$k, {
|
|
4713
4859
|
data: {
|
|
4714
4860
|
type: "button",
|
|
4715
4861
|
text: "\u5220\u9664",
|
|
@@ -5526,11 +5672,11 @@ const componentListService = new ComponentList();
|
|
|
5526
5672
|
const _sfc_main = defineComponent({
|
|
5527
5673
|
name: "m-editor",
|
|
5528
5674
|
components: {
|
|
5529
|
-
NavMenu: _sfc_main$
|
|
5675
|
+
NavMenu: _sfc_main$j,
|
|
5530
5676
|
Sidebar: _sfc_main$9,
|
|
5531
5677
|
Workspace: _sfc_main$1,
|
|
5532
|
-
PropsPanel: _sfc_main$
|
|
5533
|
-
Framework: _sfc_main$
|
|
5678
|
+
PropsPanel: _sfc_main$i,
|
|
5679
|
+
Framework: _sfc_main$l
|
|
5534
5680
|
},
|
|
5535
5681
|
props: {
|
|
5536
5682
|
modelValue: {
|
|
@@ -5703,6 +5849,7 @@ const _sfc_main = defineComponent({
|
|
|
5703
5849
|
codeBlockService
|
|
5704
5850
|
};
|
|
5705
5851
|
provide("services", services);
|
|
5852
|
+
provide("codeOptions", props.codeOptions);
|
|
5706
5853
|
provide(
|
|
5707
5854
|
"stageOptions",
|
|
5708
5855
|
reactive({
|
|
@@ -5827,13 +5974,13 @@ const index = {
|
|
|
5827
5974
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
5828
5975
|
setConfig(option);
|
|
5829
5976
|
app.component(Editor.name, Editor);
|
|
5830
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
5831
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
5832
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
5833
|
-
app.component("magic-code-editor", _sfc_main$
|
|
5834
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
5977
|
+
app.component("m-fields-ui-select", _sfc_main$r);
|
|
5978
|
+
app.component("m-fields-code-link", _sfc_main$t);
|
|
5979
|
+
app.component("m-fields-vs-code", _sfc_main$u);
|
|
5980
|
+
app.component("magic-code-editor", _sfc_main$q);
|
|
5981
|
+
app.component("m-fields-code-select", _sfc_main$s);
|
|
5835
5982
|
}
|
|
5836
5983
|
};
|
|
5837
5984
|
|
|
5838
|
-
export { COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, CodeEditorMode, _sfc_main$
|
|
5985
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, CodeEditorMode, _sfc_main$s as CodeSelect, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$n as Icon, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$o as LayoutContainer, _sfc_main$i as PropsPanel, _sfc_main$q as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$k 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, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
|
|
5839
5986
|
//# sourceMappingURL=tmagic-editor.mjs.map
|