@tmagic/editor 1.2.10 → 1.2.12
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 +26 -32
- package/dist/tmagic-editor.js +1689 -1308
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +1694 -1310
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +9 -9
- package/src/Editor.vue +10 -244
- package/src/components/CodeDraftEditor.vue +10 -6
- package/src/editorProps.ts +135 -0
- package/src/fields/CodeSelect.vue +23 -12
- package/src/fields/CodeSelectCol.vue +117 -0
- package/src/fields/EventSelect.vue +216 -0
- package/src/index.ts +7 -0
- package/src/initService.ts +198 -0
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +49 -127
- package/src/services/codeBlock.ts +8 -115
- package/src/services/dep.ts +328 -0
- package/src/services/editor.ts +1 -1
- package/src/theme/code-block.scss +5 -33
- package/src/theme/event.scss +24 -0
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +18 -3
- package/src/utils/dep.ts +21 -0
- package/src/utils/props.ts +1 -35
- package/types/Editor.vue.d.ts +49 -82
- package/types/editorProps.d.ts +109 -0
- package/types/fields/CodeSelect.vue.d.ts +28 -5
- package/types/fields/CodeSelectCol.vue.d.ts +30 -0
- package/types/fields/EventSelect.vue.d.ts +26 -0
- package/types/index.d.ts +3 -0
- package/types/initService.d.ts +8 -0
- package/types/services/codeBlock.d.ts +1 -32
- package/types/services/dep.d.ts +130 -0
- package/types/services/props.d.ts +1 -15
- package/types/type.d.ts +17 -3
- package/types/utils/dep.d.ts +3 -0
- package/types/utils/props.d.ts +2 -16
package/dist/tmagic-editor.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, inject, createCommentVNode, ref,
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeStyle, unref, reactive, watch, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, inject, createCommentVNode, ref, Fragment, renderList, createTextVNode, withModifiers, toDisplayString, onMounted, onUnmounted, renderSlot, createSlots, normalizeProps, mergeProps, markRaw, getCurrentInstance, watchEffect, provide, withDirectives, Teleport, vShow, nextTick, toHandlers } from 'vue';
|
|
2
2
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import { Edit, View, Delete, Close, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back,
|
|
4
|
-
import { isEmpty, map, throttle, cloneDeep, mergeWith, isObject, uniq, forIn, difference, union, pick, keys
|
|
3
|
+
import { Edit, View, Delete, Close, Plus, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Files, CopyDocument, Coin, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
|
|
4
|
+
import { isEmpty, map, has, throttle, cloneDeep, mergeWith, isObject, uniq, forIn, difference, union, pick, keys } from 'lodash-es';
|
|
5
5
|
import { createValues, MForm } from '@tmagic/form';
|
|
6
|
-
import { HookType, NodeType } from '@tmagic/schema';
|
|
6
|
+
import { HookType, ActionType, NodeType } from '@tmagic/schema';
|
|
7
7
|
import { TMagicIcon, TMagicButton, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, tMagicMessageBox, TMagicCard, TMagicInput, TMagicDialog, TMagicTree, TMagicCollapse, TMagicCollapseItem, getConfig as getConfig$1, TMagicTabs, TMagicPopover } from '@tmagic/design';
|
|
8
8
|
import * as monaco from 'monaco-editor';
|
|
9
|
-
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
10
9
|
import Gesto from 'gesto';
|
|
11
10
|
import { isPop, getNodePath, isNumber, isPage, toLine, datetimeFormatter, removeClassNameByClassName } from '@tmagic/utils';
|
|
11
|
+
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
12
12
|
import { EventEmitter } from 'events';
|
|
13
|
-
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
14
13
|
import KeyController from 'keycon';
|
|
14
|
+
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
15
15
|
|
|
16
|
-
const __default__$
|
|
16
|
+
const __default__$v = defineComponent({
|
|
17
17
|
name: "MEditorCode"
|
|
18
18
|
});
|
|
19
|
-
const _sfc_main$
|
|
20
|
-
...__default__$
|
|
19
|
+
const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
20
|
+
...__default__$v,
|
|
21
21
|
props: {
|
|
22
22
|
model: null,
|
|
23
23
|
name: null,
|
|
@@ -46,11 +46,11 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
const __default__$
|
|
49
|
+
const __default__$u = defineComponent({
|
|
50
50
|
name: "MEditorCodeLink"
|
|
51
51
|
});
|
|
52
|
-
const _sfc_main$
|
|
53
|
-
...__default__$
|
|
52
|
+
const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
53
|
+
...__default__$u,
|
|
54
54
|
props: {
|
|
55
55
|
config: null,
|
|
56
56
|
model: null,
|
|
@@ -119,12 +119,12 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
const _hoisted_1$
|
|
123
|
-
const __default__$
|
|
122
|
+
const _hoisted_1$h = ["src"];
|
|
123
|
+
const __default__$t = defineComponent({
|
|
124
124
|
name: "MEditorIcon"
|
|
125
125
|
});
|
|
126
|
-
const _sfc_main$
|
|
127
|
-
...__default__$
|
|
126
|
+
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
127
|
+
...__default__$t,
|
|
128
128
|
props: {
|
|
129
129
|
icon: null
|
|
130
130
|
},
|
|
@@ -143,7 +143,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
143
143
|
class: "magic-editor-icon"
|
|
144
144
|
}, {
|
|
145
145
|
default: withCtx(() => [
|
|
146
|
-
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$
|
|
146
|
+
createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$h)
|
|
147
147
|
]),
|
|
148
148
|
_: 1
|
|
149
149
|
})) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
@@ -162,14 +162,15 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
const
|
|
166
|
-
const __default__$q = defineComponent({
|
|
165
|
+
const __default__$s = defineComponent({
|
|
167
166
|
name: "MEditorCodeSelect"
|
|
168
167
|
});
|
|
169
|
-
const _sfc_main$
|
|
170
|
-
...__default__$
|
|
168
|
+
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
169
|
+
...__default__$s,
|
|
171
170
|
props: {
|
|
172
|
-
config:
|
|
171
|
+
config: { default: () => ({
|
|
172
|
+
editable: true
|
|
173
|
+
}) },
|
|
173
174
|
model: null,
|
|
174
175
|
prop: null,
|
|
175
176
|
name: null,
|
|
@@ -213,7 +214,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
213
214
|
defaultValue: {},
|
|
214
215
|
itemsFunction: (row) => {
|
|
215
216
|
const paramsConfig = getParamsConfig(row.codeId);
|
|
216
|
-
if (
|
|
217
|
+
if (!row.params || isEmpty(row.params)) {
|
|
217
218
|
createValues(mForm, paramsConfig, {}, row.params);
|
|
218
219
|
}
|
|
219
220
|
return paramsConfig;
|
|
@@ -253,6 +254,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
253
254
|
return paramStatements.map((paramState) => ({
|
|
254
255
|
labelWidth: "100px",
|
|
255
256
|
text: paramState.name,
|
|
257
|
+
inline: true,
|
|
256
258
|
...paramState
|
|
257
259
|
}));
|
|
258
260
|
};
|
|
@@ -261,7 +263,9 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
261
263
|
};
|
|
262
264
|
return (_ctx, _cache) => {
|
|
263
265
|
const _component_m_form_table = resolveComponent("m-form-table");
|
|
264
|
-
return openBlock(), createElementBlock("div",
|
|
266
|
+
return openBlock(), createElementBlock("div", {
|
|
267
|
+
class: normalizeClass(["m-fields-code-select", __props.config.className])
|
|
268
|
+
}, [
|
|
265
269
|
createVNode(_component_m_form_table, {
|
|
266
270
|
config: unref(tableConfig),
|
|
267
271
|
model: __props.model[__props.name],
|
|
@@ -272,7 +276,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
272
276
|
onChange: changeHandler
|
|
273
277
|
}, {
|
|
274
278
|
operateCol: withCtx(({ scope }) => [
|
|
275
|
-
scope.row.codeId ? (openBlock(), createBlock(_sfc_main$
|
|
279
|
+
scope.row.codeId && __props.config.editable ? (openBlock(), createBlock(_sfc_main$u, {
|
|
276
280
|
key: 0,
|
|
277
281
|
icon: unref(editable) ? unref(Edit) : unref(View),
|
|
278
282
|
class: "edit-icon",
|
|
@@ -281,6 +285,326 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
281
285
|
]),
|
|
282
286
|
_: 1
|
|
283
287
|
}, 8, ["config", "model", "prop", "size"])
|
|
288
|
+
], 2);
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
const _hoisted_1$g = { class: "m-fields-code-select-col" };
|
|
294
|
+
const __default__$r = defineComponent({
|
|
295
|
+
name: "MEditorCodeSelectCol"
|
|
296
|
+
});
|
|
297
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
298
|
+
...__default__$r,
|
|
299
|
+
props: {
|
|
300
|
+
config: null,
|
|
301
|
+
model: null,
|
|
302
|
+
prop: null,
|
|
303
|
+
name: null,
|
|
304
|
+
size: null
|
|
305
|
+
},
|
|
306
|
+
emits: ["change"],
|
|
307
|
+
setup(__props, { emit }) {
|
|
308
|
+
const props = __props;
|
|
309
|
+
const services = inject("services");
|
|
310
|
+
const mForm = inject("mForm");
|
|
311
|
+
const codeDsl = computed(() => services?.codeBlockService.getCodeDsl());
|
|
312
|
+
const codeParamsConfig = ref({
|
|
313
|
+
type: "fieldset",
|
|
314
|
+
items: [],
|
|
315
|
+
legend: "\u53C2\u6570",
|
|
316
|
+
labelWidth: "70px",
|
|
317
|
+
name: "params",
|
|
318
|
+
display: false
|
|
319
|
+
});
|
|
320
|
+
const selectConfig = {
|
|
321
|
+
type: "select",
|
|
322
|
+
text: "\u4EE3\u7801\u5757",
|
|
323
|
+
name: "codeId",
|
|
324
|
+
labelWidth: "70px",
|
|
325
|
+
options: () => {
|
|
326
|
+
if (codeDsl.value) {
|
|
327
|
+
return map(codeDsl.value, (value, key) => ({
|
|
328
|
+
text: `${value.name}\uFF08${key}\uFF09`,
|
|
329
|
+
label: `${value.name}\uFF08${key}\uFF09`,
|
|
330
|
+
value: key
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
return [];
|
|
334
|
+
},
|
|
335
|
+
onChange: (formState, codeId, { model }) => {
|
|
336
|
+
model.params = {};
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
const getParamItemsConfig = (codeId) => {
|
|
340
|
+
if (!codeDsl.value)
|
|
341
|
+
return [];
|
|
342
|
+
const paramStatements = codeDsl.value[codeId]?.params;
|
|
343
|
+
if (isEmpty(paramStatements))
|
|
344
|
+
return [];
|
|
345
|
+
return paramStatements.map((paramState) => ({
|
|
346
|
+
labelWidth: "100px",
|
|
347
|
+
text: paramState.name,
|
|
348
|
+
...paramState
|
|
349
|
+
}));
|
|
350
|
+
};
|
|
351
|
+
const getCodeParamsConfig = (codeId) => {
|
|
352
|
+
const paramsConfig = getParamItemsConfig(codeId);
|
|
353
|
+
if (!props.model.params || isEmpty(props.model.params)) {
|
|
354
|
+
props.model.params = {};
|
|
355
|
+
createValues(mForm, paramsConfig, {}, props.model.params);
|
|
356
|
+
}
|
|
357
|
+
codeParamsConfig.value = {
|
|
358
|
+
type: "fieldset",
|
|
359
|
+
items: paramsConfig,
|
|
360
|
+
legend: "\u53C2\u6570",
|
|
361
|
+
labelWidth: "70px",
|
|
362
|
+
name: "params",
|
|
363
|
+
display: !isEmpty(paramsConfig)
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
const onParamsChangeHandler = () => {
|
|
367
|
+
emit("change", props.model);
|
|
368
|
+
};
|
|
369
|
+
watch(
|
|
370
|
+
() => props.model.codeId,
|
|
371
|
+
(codeId) => {
|
|
372
|
+
if (!codeId)
|
|
373
|
+
return;
|
|
374
|
+
getCodeParamsConfig(codeId);
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
immediate: true
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
return (_ctx, _cache) => {
|
|
381
|
+
const _component_m_form_container = resolveComponent("m-form-container");
|
|
382
|
+
return openBlock(), createElementBlock("div", _hoisted_1$g, [
|
|
383
|
+
createVNode(_component_m_form_container, {
|
|
384
|
+
config: selectConfig,
|
|
385
|
+
model: __props.model,
|
|
386
|
+
onChange: onParamsChangeHandler
|
|
387
|
+
}, null, 8, ["model"]),
|
|
388
|
+
createVNode(_component_m_form_container, {
|
|
389
|
+
config: codeParamsConfig.value,
|
|
390
|
+
model: __props.model,
|
|
391
|
+
onChange: onParamsChangeHandler
|
|
392
|
+
}, null, 8, ["config", "model"])
|
|
393
|
+
]);
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
const _hoisted_1$f = { class: "m-fields-event-select" };
|
|
399
|
+
const _hoisted_2$7 = {
|
|
400
|
+
key: 1,
|
|
401
|
+
class: "fullWidth"
|
|
402
|
+
};
|
|
403
|
+
const _hoisted_3$4 = /* @__PURE__ */ createTextVNode("\u6DFB\u52A0\u4E8B\u4EF6");
|
|
404
|
+
const __default__$q = defineComponent({
|
|
405
|
+
name: "MEditorEventSelect"
|
|
406
|
+
});
|
|
407
|
+
const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
408
|
+
...__default__$q,
|
|
409
|
+
props: {
|
|
410
|
+
config: null,
|
|
411
|
+
model: null,
|
|
412
|
+
prop: null,
|
|
413
|
+
name: null,
|
|
414
|
+
size: null
|
|
415
|
+
},
|
|
416
|
+
emits: ["change"],
|
|
417
|
+
setup(__props, { emit }) {
|
|
418
|
+
const props = __props;
|
|
419
|
+
const services = inject("services");
|
|
420
|
+
const eventNameConfig = computed(() => {
|
|
421
|
+
const defaultEventNameConfig = {
|
|
422
|
+
name: "name",
|
|
423
|
+
text: "\u4E8B\u4EF6",
|
|
424
|
+
type: "select",
|
|
425
|
+
labelWidth: "40px",
|
|
426
|
+
options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
|
|
427
|
+
text: option.label,
|
|
428
|
+
value: option.value
|
|
429
|
+
}))
|
|
430
|
+
};
|
|
431
|
+
return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
|
|
432
|
+
});
|
|
433
|
+
const actionTypeConfig = computed(() => {
|
|
434
|
+
const defaultActionTypeConfig = {
|
|
435
|
+
name: "actionType",
|
|
436
|
+
text: "\u8054\u52A8\u7C7B\u578B",
|
|
437
|
+
labelWidth: "70px",
|
|
438
|
+
type: "select",
|
|
439
|
+
defaultValue: ActionType.COMP,
|
|
440
|
+
options: () => [
|
|
441
|
+
{
|
|
442
|
+
text: "\u7EC4\u4EF6",
|
|
443
|
+
label: "\u7EC4\u4EF6",
|
|
444
|
+
value: ActionType.COMP
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
text: "\u4EE3\u7801",
|
|
448
|
+
label: "\u4EE3\u7801",
|
|
449
|
+
value: ActionType.CODE
|
|
450
|
+
}
|
|
451
|
+
]
|
|
452
|
+
};
|
|
453
|
+
return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
|
|
454
|
+
});
|
|
455
|
+
const targetCompConfig = computed(() => {
|
|
456
|
+
const defaultTargetCompConfig = {
|
|
457
|
+
name: "to",
|
|
458
|
+
text: "\u8054\u52A8\u7EC4\u4EF6",
|
|
459
|
+
labelWidth: "70px",
|
|
460
|
+
type: "ui-select",
|
|
461
|
+
display: (mForm, { model }) => model.actionType === ActionType.COMP
|
|
462
|
+
};
|
|
463
|
+
return { ...defaultTargetCompConfig, ...props.config.targetCompConfig };
|
|
464
|
+
});
|
|
465
|
+
const compActionConfig = computed(() => {
|
|
466
|
+
const defaultCompActionConfig = {
|
|
467
|
+
name: "method",
|
|
468
|
+
text: "\u52A8\u4F5C",
|
|
469
|
+
labelWidth: "70px",
|
|
470
|
+
type: "select",
|
|
471
|
+
display: (mForm, { model }) => model.actionType === ActionType.COMP,
|
|
472
|
+
options: (mForm, { model }) => {
|
|
473
|
+
const node = services?.editorService.getNodeById(model.to);
|
|
474
|
+
if (!node?.type)
|
|
475
|
+
return [];
|
|
476
|
+
return services?.eventsService.getMethod(node.type).map((option) => ({
|
|
477
|
+
text: option.label,
|
|
478
|
+
value: option.value
|
|
479
|
+
}));
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
return { ...defaultCompActionConfig, ...props.config.compActionConfig };
|
|
483
|
+
});
|
|
484
|
+
const codeActionConfig = computed(() => {
|
|
485
|
+
const defaultCodeActionConfig = {
|
|
486
|
+
type: "code-select-col",
|
|
487
|
+
display: (mForm, { model }) => model.actionType === ActionType.CODE
|
|
488
|
+
};
|
|
489
|
+
return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
|
|
490
|
+
});
|
|
491
|
+
const tableConfig = computed(() => ({
|
|
492
|
+
type: "table",
|
|
493
|
+
name: "events",
|
|
494
|
+
items: [
|
|
495
|
+
{
|
|
496
|
+
name: "name",
|
|
497
|
+
label: "\u4E8B\u4EF6\u540D",
|
|
498
|
+
type: eventNameConfig.value.type,
|
|
499
|
+
options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
|
|
500
|
+
text: option.label,
|
|
501
|
+
value: option.value
|
|
502
|
+
}))
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: "to",
|
|
506
|
+
label: "\u8054\u52A8\u7EC4\u4EF6",
|
|
507
|
+
type: "ui-select"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
name: "method",
|
|
511
|
+
label: "\u52A8\u4F5C",
|
|
512
|
+
type: compActionConfig.value.type,
|
|
513
|
+
options: (mForm, { model }) => {
|
|
514
|
+
const node = services?.editorService.getNodeById(model.to);
|
|
515
|
+
if (!node?.type)
|
|
516
|
+
return [];
|
|
517
|
+
return services?.eventsService.getMethod(node.type).map((option) => ({
|
|
518
|
+
text: option.label,
|
|
519
|
+
value: option.value
|
|
520
|
+
}));
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
]
|
|
524
|
+
}));
|
|
525
|
+
const actionsConfig = computed(() => ({
|
|
526
|
+
items: [
|
|
527
|
+
{
|
|
528
|
+
type: "group-list",
|
|
529
|
+
name: "actions",
|
|
530
|
+
enableToggleMode: false,
|
|
531
|
+
items: [actionTypeConfig.value, targetCompConfig.value, compActionConfig.value, codeActionConfig.value]
|
|
532
|
+
}
|
|
533
|
+
]
|
|
534
|
+
}));
|
|
535
|
+
const isOldVersion = computed(() => {
|
|
536
|
+
if (props.model[props.name].length === 0)
|
|
537
|
+
return false;
|
|
538
|
+
return !has(props.model[props.name][0], "actions");
|
|
539
|
+
});
|
|
540
|
+
const addEvent = () => {
|
|
541
|
+
const defaultEvent = {
|
|
542
|
+
name: "",
|
|
543
|
+
actions: []
|
|
544
|
+
};
|
|
545
|
+
if (!props.model[props.name]) {
|
|
546
|
+
props.model[props.name] = [];
|
|
547
|
+
}
|
|
548
|
+
props.model[props.name].push(defaultEvent);
|
|
549
|
+
onChangeHandler();
|
|
550
|
+
};
|
|
551
|
+
const removeEvent = (index) => {
|
|
552
|
+
if (!props.name)
|
|
553
|
+
return;
|
|
554
|
+
props.model[props.name].splice(index, 1);
|
|
555
|
+
onChangeHandler();
|
|
556
|
+
};
|
|
557
|
+
const onChangeHandler = () => {
|
|
558
|
+
emit("change", props.model);
|
|
559
|
+
};
|
|
560
|
+
return (_ctx, _cache) => {
|
|
561
|
+
const _component_m_form_container = resolveComponent("m-form-container");
|
|
562
|
+
const _component_m_form_panel = resolveComponent("m-form-panel");
|
|
563
|
+
return openBlock(), createElementBlock("div", _hoisted_1$f, [
|
|
564
|
+
unref(isOldVersion) ? (openBlock(), createBlock(_component_m_form_container, {
|
|
565
|
+
key: 0,
|
|
566
|
+
ref: "eventForm",
|
|
567
|
+
size: props.size,
|
|
568
|
+
model: __props.model,
|
|
569
|
+
config: unref(tableConfig),
|
|
570
|
+
onChange: onChangeHandler
|
|
571
|
+
}, null, 8, ["size", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$7, [
|
|
572
|
+
createVNode(unref(TMagicButton), {
|
|
573
|
+
class: "create-button",
|
|
574
|
+
type: "primary",
|
|
575
|
+
size: "small",
|
|
576
|
+
onClick: _cache[0] || (_cache[0] = ($event) => addEvent())
|
|
577
|
+
}, {
|
|
578
|
+
default: withCtx(() => [
|
|
579
|
+
_hoisted_3$4
|
|
580
|
+
]),
|
|
581
|
+
_: 1
|
|
582
|
+
}),
|
|
583
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.model[__props.name], (cardItem, index) => {
|
|
584
|
+
return openBlock(), createBlock(_component_m_form_panel, {
|
|
585
|
+
key: index,
|
|
586
|
+
config: unref(actionsConfig),
|
|
587
|
+
model: cardItem,
|
|
588
|
+
onChange: onChangeHandler
|
|
589
|
+
}, {
|
|
590
|
+
header: withCtx(() => [
|
|
591
|
+
createVNode(_component_m_form_container, {
|
|
592
|
+
class: "fullWidth",
|
|
593
|
+
config: unref(eventNameConfig),
|
|
594
|
+
model: cardItem,
|
|
595
|
+
onChange: onChangeHandler
|
|
596
|
+
}, null, 8, ["config", "model"]),
|
|
597
|
+
createVNode(unref(TMagicButton), {
|
|
598
|
+
style: { "color": "#f56c6c" },
|
|
599
|
+
text: "",
|
|
600
|
+
icon: unref(Delete),
|
|
601
|
+
onClick: ($event) => removeEvent(index)
|
|
602
|
+
}, null, 8, ["icon", "onClick"])
|
|
603
|
+
]),
|
|
604
|
+
_: 2
|
|
605
|
+
}, 1032, ["config", "model"]);
|
|
606
|
+
}), 128))
|
|
607
|
+
]))
|
|
284
608
|
]);
|
|
285
609
|
};
|
|
286
610
|
}
|
|
@@ -704,341 +1028,211 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
704
1028
|
}
|
|
705
1029
|
});
|
|
706
1030
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1031
|
+
const fillConfig = (config = []) => [
|
|
1032
|
+
{
|
|
1033
|
+
type: "tab",
|
|
1034
|
+
items: [
|
|
1035
|
+
{
|
|
1036
|
+
title: "\u5C5E\u6027",
|
|
1037
|
+
labelWidth: "80px",
|
|
1038
|
+
items: [
|
|
1039
|
+
{
|
|
1040
|
+
text: "type",
|
|
1041
|
+
name: "type",
|
|
1042
|
+
type: "hidden"
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
name: "id",
|
|
1046
|
+
type: "display",
|
|
1047
|
+
text: "id"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
name: "name",
|
|
1051
|
+
text: "\u7EC4\u4EF6\u540D\u79F0"
|
|
1052
|
+
},
|
|
1053
|
+
...config
|
|
1054
|
+
]
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
title: "\u6837\u5F0F",
|
|
1058
|
+
labelWidth: "80px",
|
|
1059
|
+
items: [
|
|
1060
|
+
{
|
|
1061
|
+
name: "style",
|
|
1062
|
+
items: [
|
|
1063
|
+
{
|
|
1064
|
+
type: "fieldset",
|
|
1065
|
+
legend: "\u4F4D\u7F6E",
|
|
1066
|
+
items: [
|
|
1067
|
+
{
|
|
1068
|
+
name: "position",
|
|
1069
|
+
type: "checkbox",
|
|
1070
|
+
activeValue: "fixed",
|
|
1071
|
+
inactiveValue: "absolute",
|
|
1072
|
+
defaultValue: "absolute",
|
|
1073
|
+
text: "\u56FA\u5B9A\u5B9A\u4F4D"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
name: "left",
|
|
1077
|
+
text: "left"
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
name: "top",
|
|
1081
|
+
text: "top",
|
|
1082
|
+
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedBottom"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
name: "right",
|
|
1086
|
+
text: "right"
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
name: "bottom",
|
|
1090
|
+
text: "bottom",
|
|
1091
|
+
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedTop"
|
|
1092
|
+
}
|
|
1093
|
+
]
|
|
1094
|
+
},
|
|
1095
|
+
{
|
|
1096
|
+
type: "fieldset",
|
|
1097
|
+
legend: "\u76D2\u5B50",
|
|
1098
|
+
items: [
|
|
1099
|
+
{
|
|
1100
|
+
name: "width",
|
|
1101
|
+
text: "\u5BBD\u5EA6"
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
name: "height",
|
|
1105
|
+
text: "\u9AD8\u5EA6"
|
|
1106
|
+
}
|
|
1107
|
+
]
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
type: "fieldset",
|
|
1111
|
+
legend: "\u80CC\u666F",
|
|
1112
|
+
items: [
|
|
1113
|
+
{
|
|
1114
|
+
name: "backgroundImage",
|
|
1115
|
+
text: "\u80CC\u666F\u56FE"
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
name: "backgroundColor",
|
|
1119
|
+
text: "\u80CC\u666F\u989C\u8272",
|
|
1120
|
+
type: "colorPicker"
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
name: "backgroundRepeat",
|
|
1124
|
+
text: "\u80CC\u666F\u56FE\u91CD\u590D",
|
|
1125
|
+
type: "select",
|
|
1126
|
+
defaultValue: "no-repeat",
|
|
1127
|
+
options: [
|
|
1128
|
+
{ text: "repeat", value: "repeat" },
|
|
1129
|
+
{ text: "repeat-x", value: "repeat-x" },
|
|
1130
|
+
{ text: "repeat-y", value: "repeat-y" },
|
|
1131
|
+
{ text: "no-repeat", value: "no-repeat" },
|
|
1132
|
+
{ text: "inherit", value: "inherit" }
|
|
1133
|
+
]
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
name: "backgroundSize",
|
|
1137
|
+
text: "\u80CC\u666F\u56FE\u5927\u5C0F",
|
|
1138
|
+
defaultValue: "100% 100%"
|
|
1139
|
+
}
|
|
1140
|
+
]
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
type: "fieldset",
|
|
1144
|
+
legend: "\u5B57\u4F53",
|
|
1145
|
+
items: [
|
|
1146
|
+
{
|
|
1147
|
+
name: "color",
|
|
1148
|
+
text: "\u989C\u8272",
|
|
1149
|
+
type: "colorPicker"
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
name: "fontSize",
|
|
1153
|
+
text: "\u5927\u5C0F"
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
name: "fontWeight",
|
|
1157
|
+
text: "\u7C97\u7EC6"
|
|
1158
|
+
}
|
|
1159
|
+
]
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
type: "fieldset",
|
|
1163
|
+
legend: "\u53D8\u5F62",
|
|
1164
|
+
name: "transform",
|
|
1165
|
+
items: [
|
|
1166
|
+
{
|
|
1167
|
+
name: "rotate",
|
|
1168
|
+
text: "\u65CB\u8F6C\u89D2\u5EA6"
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
name: "scale",
|
|
1172
|
+
text: "\u7F29\u653E"
|
|
1173
|
+
}
|
|
1174
|
+
]
|
|
833
1175
|
}
|
|
834
|
-
|
|
835
|
-
});
|
|
836
|
-
if (!this.doingTask) {
|
|
837
|
-
this.doTask();
|
|
1176
|
+
]
|
|
838
1177
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1178
|
+
]
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
title: "\u4E8B\u4EF6",
|
|
1182
|
+
items: [
|
|
1183
|
+
{
|
|
1184
|
+
name: "events",
|
|
1185
|
+
type: "event-select"
|
|
1186
|
+
}
|
|
1187
|
+
]
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
title: "\u9AD8\u7EA7",
|
|
1191
|
+
lazy: true,
|
|
1192
|
+
items: [
|
|
1193
|
+
{
|
|
1194
|
+
name: "created",
|
|
1195
|
+
text: "created",
|
|
1196
|
+
labelWidth: "100px",
|
|
1197
|
+
type: "code-select"
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
name: "mounted",
|
|
1201
|
+
text: "mounted",
|
|
1202
|
+
labelWidth: "100px",
|
|
1203
|
+
type: "code-select"
|
|
1204
|
+
}
|
|
1205
|
+
]
|
|
1206
|
+
}
|
|
1207
|
+
]
|
|
849
1208
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1209
|
+
];
|
|
1210
|
+
|
|
1211
|
+
const log = (...args) => {
|
|
1212
|
+
if (process.env.NODE_ENV === "development") {
|
|
1213
|
+
console.log("magic editor: ", ...args);
|
|
855
1214
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
Object.keys(this.middleware).forEach((key) => {
|
|
861
|
-
this.middleware[key] = [];
|
|
862
|
-
});
|
|
1215
|
+
};
|
|
1216
|
+
const info = (...args) => {
|
|
1217
|
+
if (process.env.NODE_ENV === "development") {
|
|
1218
|
+
console.info("magic editor: ", ...args);
|
|
863
1219
|
}
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
await task();
|
|
869
|
-
task = this.taskList.shift();
|
|
870
|
-
}
|
|
871
|
-
this.doingTask = false;
|
|
1220
|
+
};
|
|
1221
|
+
const warn = (...args) => {
|
|
1222
|
+
if (process.env.NODE_ENV === "development") {
|
|
1223
|
+
console.warn("magic editor: ", ...args);
|
|
872
1224
|
}
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
pageSteps: {},
|
|
878
|
-
pageId: void 0,
|
|
879
|
-
canRedo: false,
|
|
880
|
-
canUndo: false
|
|
881
|
-
});
|
|
882
|
-
constructor() {
|
|
883
|
-
super([]);
|
|
884
|
-
this.on("change", this.setCanUndoRedo);
|
|
885
|
-
}
|
|
886
|
-
reset() {
|
|
887
|
-
this.state.pageSteps = {};
|
|
888
|
-
this.state.pageId = void 0;
|
|
889
|
-
this.state.canRedo = false;
|
|
890
|
-
this.state.canUndo = false;
|
|
891
|
-
}
|
|
892
|
-
changePage(page) {
|
|
893
|
-
if (!page)
|
|
894
|
-
return;
|
|
895
|
-
this.state.pageId = page.id;
|
|
896
|
-
if (!this.state.pageSteps[this.state.pageId]) {
|
|
897
|
-
const undoRedo = new UndoRedo();
|
|
898
|
-
undoRedo.pushElement({
|
|
899
|
-
data: page,
|
|
900
|
-
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
901
|
-
nodeId: page.id
|
|
902
|
-
});
|
|
903
|
-
this.state.pageSteps[this.state.pageId] = undoRedo;
|
|
904
|
-
}
|
|
905
|
-
this.setCanUndoRedo();
|
|
906
|
-
this.emit("page-change", this.state.pageSteps[this.state.pageId]);
|
|
907
|
-
}
|
|
908
|
-
resetState() {
|
|
909
|
-
this.state.pageId = void 0;
|
|
910
|
-
this.state.pageSteps = {};
|
|
911
|
-
this.state.canRedo = false;
|
|
912
|
-
this.state.canUndo = false;
|
|
913
|
-
}
|
|
914
|
-
push(state) {
|
|
915
|
-
const undoRedo = this.getUndoRedo();
|
|
916
|
-
if (!undoRedo)
|
|
917
|
-
return null;
|
|
918
|
-
undoRedo.pushElement(state);
|
|
919
|
-
this.emit("change", state);
|
|
920
|
-
return state;
|
|
921
|
-
}
|
|
922
|
-
undo() {
|
|
923
|
-
const undoRedo = this.getUndoRedo();
|
|
924
|
-
if (!undoRedo)
|
|
925
|
-
return null;
|
|
926
|
-
const state = undoRedo.undo();
|
|
927
|
-
this.emit("change", state);
|
|
928
|
-
return state;
|
|
929
|
-
}
|
|
930
|
-
redo() {
|
|
931
|
-
const undoRedo = this.getUndoRedo();
|
|
932
|
-
if (!undoRedo)
|
|
933
|
-
return null;
|
|
934
|
-
const state = undoRedo.redo();
|
|
935
|
-
this.emit("change", state);
|
|
936
|
-
return state;
|
|
937
|
-
}
|
|
938
|
-
destroy() {
|
|
939
|
-
this.resetState();
|
|
940
|
-
this.removeAllListeners();
|
|
941
|
-
this.removeAllPlugins();
|
|
942
|
-
}
|
|
943
|
-
getUndoRedo() {
|
|
944
|
-
if (!this.state.pageId)
|
|
945
|
-
return null;
|
|
946
|
-
return this.state.pageSteps[this.state.pageId];
|
|
947
|
-
}
|
|
948
|
-
setCanUndoRedo() {
|
|
949
|
-
const undoRedo = this.getUndoRedo();
|
|
950
|
-
this.state.canRedo = undoRedo?.canRedo() || false;
|
|
951
|
-
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
const historyService = new History();
|
|
955
|
-
|
|
956
|
-
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
957
|
-
Protocol2["OBJECT"] = "object";
|
|
958
|
-
Protocol2["JSON"] = "json";
|
|
959
|
-
Protocol2["STRING"] = "string";
|
|
960
|
-
Protocol2["NUMBER"] = "number";
|
|
961
|
-
Protocol2["BOOLEAN"] = "boolean";
|
|
962
|
-
return Protocol2;
|
|
963
|
-
})(Protocol || {});
|
|
964
|
-
class WebStorage extends BaseService {
|
|
965
|
-
storage = globalThis.localStorage;
|
|
966
|
-
namespace = "tmagic";
|
|
967
|
-
constructor() {
|
|
968
|
-
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
969
|
-
}
|
|
970
|
-
async getStorage() {
|
|
971
|
-
return this.storage;
|
|
972
|
-
}
|
|
973
|
-
async getNamespace() {
|
|
974
|
-
return this.namespace;
|
|
975
|
-
}
|
|
976
|
-
async clear() {
|
|
977
|
-
const storage2 = await this.getStorage();
|
|
978
|
-
storage2.clear();
|
|
979
|
-
}
|
|
980
|
-
async getItem(key, options = {}) {
|
|
981
|
-
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
982
|
-
const { protocol = options.protocol, item } = this.getValueAndProtocol(
|
|
983
|
-
storage.getItem(`${options.namespace || namespace}:${key}`)
|
|
984
|
-
);
|
|
985
|
-
if (item === null)
|
|
986
|
-
return null;
|
|
987
|
-
switch (protocol) {
|
|
988
|
-
case "object" /* OBJECT */:
|
|
989
|
-
return eval(`(${item})`);
|
|
990
|
-
case "json" /* JSON */:
|
|
991
|
-
return JSON.parse(item);
|
|
992
|
-
case "number" /* NUMBER */:
|
|
993
|
-
return Number(item);
|
|
994
|
-
case "boolean" /* BOOLEAN */:
|
|
995
|
-
return Boolean(item);
|
|
996
|
-
default:
|
|
997
|
-
return item;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
async key(index) {
|
|
1001
|
-
const storage2 = await this.getStorage();
|
|
1002
|
-
return storage2.key(index);
|
|
1003
|
-
}
|
|
1004
|
-
async removeItem(key2, options2 = {}) {
|
|
1005
|
-
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1006
|
-
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
1007
|
-
}
|
|
1008
|
-
async setItem(key2, value, options2 = {}) {
|
|
1009
|
-
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1010
|
-
let item2 = value;
|
|
1011
|
-
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
1012
|
-
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
1013
|
-
item2 = `${protocol2}${value}`;
|
|
1014
|
-
} else {
|
|
1015
|
-
item2 = `${protocol2}${serialize(value)}`;
|
|
1016
|
-
}
|
|
1017
|
-
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
1018
|
-
}
|
|
1019
|
-
destroy() {
|
|
1020
|
-
this.removeAllListeners();
|
|
1021
|
-
this.removeAllPlugins();
|
|
1225
|
+
};
|
|
1226
|
+
const debug = (...args) => {
|
|
1227
|
+
if (process.env.NODE_ENV === "development") {
|
|
1228
|
+
console.debug("magic editor: ", ...args);
|
|
1022
1229
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
item: value,
|
|
1028
|
-
protocol: protocol2
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
1032
|
-
protocol2 = $1;
|
|
1033
|
-
return $3;
|
|
1034
|
-
});
|
|
1035
|
-
return {
|
|
1036
|
-
protocol: protocol2,
|
|
1037
|
-
item: item2
|
|
1038
|
-
};
|
|
1230
|
+
};
|
|
1231
|
+
const error = (...args) => {
|
|
1232
|
+
if (process.env.NODE_ENV === "development") {
|
|
1233
|
+
console.error("magic editor: ", ...args);
|
|
1039
1234
|
}
|
|
1040
|
-
}
|
|
1041
|
-
const storageService = new WebStorage();
|
|
1235
|
+
};
|
|
1042
1236
|
|
|
1043
1237
|
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
1044
1238
|
ColumnLayout2["LEFT"] = "left";
|
|
@@ -1231,143 +1425,479 @@ const serializeConfig = (config) => serialize(config, {
|
|
|
1231
1425
|
unsafe: true
|
|
1232
1426
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1233
1427
|
|
|
1234
|
-
class
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
"setPropsValue",
|
|
1244
|
-
"getPropsValue",
|
|
1245
|
-
"createId",
|
|
1246
|
-
"setNewItemId",
|
|
1247
|
-
"fillConfig",
|
|
1248
|
-
"getDefaultPropsValue"
|
|
1249
|
-
]);
|
|
1250
|
-
}
|
|
1251
|
-
setPropsConfigs(configs) {
|
|
1252
|
-
Object.keys(configs).forEach((type) => {
|
|
1253
|
-
this.setPropsConfig(toLine(type), configs[type]);
|
|
1254
|
-
});
|
|
1255
|
-
this.emit("props-configs-change");
|
|
1428
|
+
class UndoRedo {
|
|
1429
|
+
elementList;
|
|
1430
|
+
listCursor;
|
|
1431
|
+
listMaxSize;
|
|
1432
|
+
constructor(listMaxSize = 200) {
|
|
1433
|
+
const minListMaxSize = 2;
|
|
1434
|
+
this.elementList = [];
|
|
1435
|
+
this.listCursor = 0;
|
|
1436
|
+
this.listMaxSize = listMaxSize > minListMaxSize ? listMaxSize : minListMaxSize;
|
|
1256
1437
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1438
|
+
pushElement(element) {
|
|
1439
|
+
this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, cloneDeep(element));
|
|
1440
|
+
this.listCursor += 1;
|
|
1441
|
+
if (this.elementList.length > this.listMaxSize) {
|
|
1442
|
+
this.elementList.shift();
|
|
1443
|
+
this.listCursor -= 1;
|
|
1444
|
+
}
|
|
1259
1445
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1446
|
+
canUndo() {
|
|
1447
|
+
return this.listCursor > 1;
|
|
1262
1448
|
}
|
|
1263
|
-
|
|
1264
|
-
if (
|
|
1265
|
-
return
|
|
1449
|
+
undo() {
|
|
1450
|
+
if (!this.canUndo()) {
|
|
1451
|
+
return null;
|
|
1266
1452
|
}
|
|
1267
|
-
|
|
1453
|
+
this.listCursor -= 1;
|
|
1454
|
+
return this.getCurrentElement();
|
|
1268
1455
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
this.setPropsValue(toLine(type), values[type]);
|
|
1272
|
-
});
|
|
1456
|
+
canRedo() {
|
|
1457
|
+
return this.elementList.length > this.listCursor;
|
|
1273
1458
|
}
|
|
1274
|
-
|
|
1275
|
-
this.
|
|
1459
|
+
redo() {
|
|
1460
|
+
if (!this.canRedo()) {
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
this.listCursor += 1;
|
|
1464
|
+
return this.getCurrentElement();
|
|
1276
1465
|
}
|
|
1277
|
-
|
|
1278
|
-
if (
|
|
1279
|
-
|
|
1280
|
-
value.className = "action-area";
|
|
1281
|
-
value.text = "";
|
|
1282
|
-
if (value.style) {
|
|
1283
|
-
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
1284
|
-
}
|
|
1285
|
-
return value;
|
|
1466
|
+
getCurrentElement() {
|
|
1467
|
+
if (this.listCursor < 1) {
|
|
1468
|
+
return null;
|
|
1286
1469
|
}
|
|
1287
|
-
|
|
1288
|
-
this.createId(type),
|
|
1289
|
-
this.getDefaultPropsValue(type),
|
|
1290
|
-
this.setNewItemId(
|
|
1291
|
-
cloneDeep({
|
|
1292
|
-
type,
|
|
1293
|
-
...defaultValue
|
|
1294
|
-
})
|
|
1295
|
-
)
|
|
1296
|
-
]);
|
|
1297
|
-
return {
|
|
1298
|
-
id,
|
|
1299
|
-
...defaultPropsValue,
|
|
1300
|
-
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
1301
|
-
};
|
|
1470
|
+
return cloneDeep(this.elementList[this.listCursor - 1]);
|
|
1302
1471
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
const compose = (middleware) => {
|
|
1475
|
+
if (!Array.isArray(middleware))
|
|
1476
|
+
throw new TypeError("Middleware \u5FC5\u987B\u662F\u4E00\u4E2A\u6570\u7EC4!");
|
|
1477
|
+
for (const fn of middleware) {
|
|
1478
|
+
if (typeof fn !== "function")
|
|
1479
|
+
throw new TypeError("Middleware \u5FC5\u987B\u7531\u51FD\u6570\u7EC4\u6210!");
|
|
1305
1480
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1481
|
+
return (args, next) => {
|
|
1482
|
+
let index = -1;
|
|
1483
|
+
return dispatch(0);
|
|
1484
|
+
function dispatch(i) {
|
|
1485
|
+
if (i <= index)
|
|
1486
|
+
return Promise.reject(new Error("next() \u88AB\u591A\u6B21\u8C03\u7528"));
|
|
1487
|
+
index = i;
|
|
1488
|
+
let fn = middleware[i];
|
|
1489
|
+
if (i === middleware.length && next)
|
|
1490
|
+
fn = next;
|
|
1491
|
+
if (!fn)
|
|
1492
|
+
return Promise.resolve();
|
|
1493
|
+
try {
|
|
1494
|
+
return Promise.resolve(fn(...args, dispatch.bind(null, i + 1)));
|
|
1495
|
+
} catch (err) {
|
|
1496
|
+
return Promise.reject(err);
|
|
1311
1497
|
}
|
|
1312
1498
|
}
|
|
1313
|
-
|
|
1499
|
+
};
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
const methodName = (prefix, name) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
|
|
1503
|
+
const isError = (error) => Object.prototype.toString.call(error) === "[object Error]";
|
|
1504
|
+
const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethodName, fn) => {
|
|
1505
|
+
try {
|
|
1506
|
+
let beforeArgs = args;
|
|
1507
|
+
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
1508
|
+
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
1509
|
+
if (isError(beforeArgs))
|
|
1510
|
+
throw beforeArgs;
|
|
1511
|
+
if (!Array.isArray(beforeArgs)) {
|
|
1512
|
+
beforeArgs = [beforeArgs];
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
1516
|
+
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
1517
|
+
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
1518
|
+
if (isError(returnValue))
|
|
1519
|
+
throw returnValue;
|
|
1520
|
+
}
|
|
1521
|
+
return returnValue;
|
|
1522
|
+
} catch (error) {
|
|
1523
|
+
throw error;
|
|
1314
1524
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1525
|
+
};
|
|
1526
|
+
class BaseService extends EventEmitter {
|
|
1527
|
+
pluginOptionsList = {};
|
|
1528
|
+
middleware = {};
|
|
1529
|
+
taskList = [];
|
|
1530
|
+
doingTask = false;
|
|
1531
|
+
constructor(methods = [], serialMethods = []) {
|
|
1532
|
+
super();
|
|
1533
|
+
methods.forEach((propertyName) => {
|
|
1534
|
+
const scope = this;
|
|
1535
|
+
const sourceMethod = scope[propertyName];
|
|
1536
|
+
const beforeMethodName = methodName("before", propertyName);
|
|
1537
|
+
const afterMethodName = methodName("after", propertyName);
|
|
1538
|
+
this.pluginOptionsList[beforeMethodName] = [];
|
|
1539
|
+
this.pluginOptionsList[afterMethodName] = [];
|
|
1540
|
+
this.middleware[propertyName] = [];
|
|
1541
|
+
const fn = compose(this.middleware[propertyName]);
|
|
1542
|
+
Object.defineProperty(scope, propertyName, {
|
|
1543
|
+
value: async (...args) => {
|
|
1544
|
+
if (!serialMethods.includes(propertyName)) {
|
|
1545
|
+
return doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
1546
|
+
}
|
|
1547
|
+
const promise = new Promise((resolve, reject) => {
|
|
1548
|
+
this.taskList.push(async () => {
|
|
1549
|
+
try {
|
|
1550
|
+
const value = await doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
1551
|
+
resolve(value);
|
|
1552
|
+
} catch (e) {
|
|
1553
|
+
reject(e);
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
});
|
|
1557
|
+
if (!this.doingTask) {
|
|
1558
|
+
this.doTask();
|
|
1559
|
+
}
|
|
1560
|
+
return promise;
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
use(options) {
|
|
1566
|
+
Object.entries(options).forEach(([methodName2, method]) => {
|
|
1567
|
+
if (typeof method === "function")
|
|
1568
|
+
this.middleware[methodName2].push(method);
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
usePlugin(options) {
|
|
1572
|
+
Object.entries(options).forEach(([methodName2, method]) => {
|
|
1573
|
+
if (typeof method === "function")
|
|
1574
|
+
this.pluginOptionsList[methodName2].push(method);
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
removeAllPlugins() {
|
|
1578
|
+
Object.keys(this.pluginOptionsList).forEach((key) => {
|
|
1579
|
+
this.pluginOptionsList[key] = [];
|
|
1580
|
+
});
|
|
1581
|
+
Object.keys(this.middleware).forEach((key) => {
|
|
1582
|
+
this.middleware[key] = [];
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
async doTask() {
|
|
1586
|
+
this.doingTask = true;
|
|
1587
|
+
let task = this.taskList.shift();
|
|
1588
|
+
while (task) {
|
|
1589
|
+
await task();
|
|
1590
|
+
task = this.taskList.shift();
|
|
1591
|
+
}
|
|
1592
|
+
this.doingTask = false;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
class History extends BaseService {
|
|
1597
|
+
state = reactive({
|
|
1598
|
+
pageSteps: {},
|
|
1599
|
+
pageId: void 0,
|
|
1600
|
+
canRedo: false,
|
|
1601
|
+
canUndo: false
|
|
1602
|
+
});
|
|
1603
|
+
constructor() {
|
|
1604
|
+
super([]);
|
|
1605
|
+
this.on("change", this.setCanUndoRedo);
|
|
1606
|
+
}
|
|
1607
|
+
reset() {
|
|
1608
|
+
this.state.pageSteps = {};
|
|
1609
|
+
this.state.pageId = void 0;
|
|
1610
|
+
this.state.canRedo = false;
|
|
1611
|
+
this.state.canUndo = false;
|
|
1612
|
+
}
|
|
1613
|
+
changePage(page) {
|
|
1614
|
+
if (!page)
|
|
1615
|
+
return;
|
|
1616
|
+
this.state.pageId = page.id;
|
|
1617
|
+
if (!this.state.pageSteps[this.state.pageId]) {
|
|
1618
|
+
const undoRedo = new UndoRedo();
|
|
1619
|
+
undoRedo.pushElement({
|
|
1620
|
+
data: page,
|
|
1621
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1622
|
+
nodeId: page.id
|
|
1623
|
+
});
|
|
1624
|
+
this.state.pageSteps[this.state.pageId] = undoRedo;
|
|
1625
|
+
}
|
|
1626
|
+
this.setCanUndoRedo();
|
|
1627
|
+
this.emit("page-change", this.state.pageSteps[this.state.pageId]);
|
|
1327
1628
|
}
|
|
1328
1629
|
resetState() {
|
|
1329
|
-
this.state.
|
|
1330
|
-
this.state.
|
|
1630
|
+
this.state.pageId = void 0;
|
|
1631
|
+
this.state.pageSteps = {};
|
|
1632
|
+
this.state.canRedo = false;
|
|
1633
|
+
this.state.canUndo = false;
|
|
1634
|
+
}
|
|
1635
|
+
push(state) {
|
|
1636
|
+
const undoRedo = this.getUndoRedo();
|
|
1637
|
+
if (!undoRedo)
|
|
1638
|
+
return null;
|
|
1639
|
+
undoRedo.pushElement(state);
|
|
1640
|
+
this.emit("change", state);
|
|
1641
|
+
return state;
|
|
1642
|
+
}
|
|
1643
|
+
undo() {
|
|
1644
|
+
const undoRedo = this.getUndoRedo();
|
|
1645
|
+
if (!undoRedo)
|
|
1646
|
+
return null;
|
|
1647
|
+
const state = undoRedo.undo();
|
|
1648
|
+
this.emit("change", state);
|
|
1649
|
+
return state;
|
|
1650
|
+
}
|
|
1651
|
+
redo() {
|
|
1652
|
+
const undoRedo = this.getUndoRedo();
|
|
1653
|
+
if (!undoRedo)
|
|
1654
|
+
return null;
|
|
1655
|
+
const state = undoRedo.redo();
|
|
1656
|
+
this.emit("change", state);
|
|
1657
|
+
return state;
|
|
1331
1658
|
}
|
|
1332
1659
|
destroy() {
|
|
1333
1660
|
this.resetState();
|
|
1334
1661
|
this.removeAllListeners();
|
|
1335
1662
|
this.removeAllPlugins();
|
|
1336
1663
|
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1664
|
+
getUndoRedo() {
|
|
1665
|
+
if (!this.state.pageId)
|
|
1666
|
+
return null;
|
|
1667
|
+
return this.state.pageSteps[this.state.pageId];
|
|
1668
|
+
}
|
|
1669
|
+
setCanUndoRedo() {
|
|
1670
|
+
const undoRedo = this.getUndoRedo();
|
|
1671
|
+
this.state.canRedo = undoRedo?.canRedo() || false;
|
|
1672
|
+
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
1343
1673
|
}
|
|
1344
1674
|
}
|
|
1345
|
-
const
|
|
1675
|
+
const historyService = new History();
|
|
1346
1676
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1677
|
+
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
1678
|
+
Protocol2["OBJECT"] = "object";
|
|
1679
|
+
Protocol2["JSON"] = "json";
|
|
1680
|
+
Protocol2["STRING"] = "string";
|
|
1681
|
+
Protocol2["NUMBER"] = "number";
|
|
1682
|
+
Protocol2["BOOLEAN"] = "boolean";
|
|
1683
|
+
return Protocol2;
|
|
1684
|
+
})(Protocol || {});
|
|
1685
|
+
class WebStorage extends BaseService {
|
|
1686
|
+
storage = globalThis.localStorage;
|
|
1687
|
+
namespace = "tmagic";
|
|
1688
|
+
constructor() {
|
|
1689
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
1690
|
+
}
|
|
1691
|
+
async getStorage() {
|
|
1692
|
+
return this.storage;
|
|
1693
|
+
}
|
|
1694
|
+
async getNamespace() {
|
|
1695
|
+
return this.namespace;
|
|
1696
|
+
}
|
|
1697
|
+
async clear() {
|
|
1698
|
+
const storage2 = await this.getStorage();
|
|
1699
|
+
storage2.clear();
|
|
1700
|
+
}
|
|
1701
|
+
async getItem(key, options = {}) {
|
|
1702
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1703
|
+
const { protocol = options.protocol, item } = this.getValueAndProtocol(
|
|
1704
|
+
storage.getItem(`${options.namespace || namespace}:${key}`)
|
|
1705
|
+
);
|
|
1706
|
+
if (item === null)
|
|
1707
|
+
return null;
|
|
1708
|
+
switch (protocol) {
|
|
1709
|
+
case "object" /* OBJECT */:
|
|
1710
|
+
return eval(`(${item})`);
|
|
1711
|
+
case "json" /* JSON */:
|
|
1712
|
+
return JSON.parse(item);
|
|
1713
|
+
case "number" /* NUMBER */:
|
|
1714
|
+
return Number(item);
|
|
1715
|
+
case "boolean" /* BOOLEAN */:
|
|
1716
|
+
return Boolean(item);
|
|
1717
|
+
default:
|
|
1718
|
+
return item;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
async key(index) {
|
|
1722
|
+
const storage2 = await this.getStorage();
|
|
1723
|
+
return storage2.key(index);
|
|
1724
|
+
}
|
|
1725
|
+
async removeItem(key2, options2 = {}) {
|
|
1726
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1727
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
1728
|
+
}
|
|
1729
|
+
async setItem(key2, value, options2 = {}) {
|
|
1730
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1731
|
+
let item2 = value;
|
|
1732
|
+
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
1733
|
+
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
1734
|
+
item2 = `${protocol2}${value}`;
|
|
1735
|
+
} else {
|
|
1736
|
+
item2 = `${protocol2}${serialize(value)}`;
|
|
1737
|
+
}
|
|
1738
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
1739
|
+
}
|
|
1740
|
+
destroy() {
|
|
1741
|
+
this.removeAllListeners();
|
|
1742
|
+
this.removeAllPlugins();
|
|
1743
|
+
}
|
|
1744
|
+
getValueAndProtocol(value) {
|
|
1745
|
+
let protocol2 = "";
|
|
1746
|
+
if (value === null) {
|
|
1747
|
+
return {
|
|
1748
|
+
item: value,
|
|
1749
|
+
protocol: protocol2
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
1753
|
+
protocol2 = $1;
|
|
1754
|
+
return $3;
|
|
1755
|
+
});
|
|
1756
|
+
return {
|
|
1757
|
+
protocol: protocol2,
|
|
1758
|
+
item: item2
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
const storageService = new WebStorage();
|
|
1763
|
+
|
|
1764
|
+
class Props extends BaseService {
|
|
1765
|
+
state = reactive({
|
|
1766
|
+
propsConfigMap: {},
|
|
1767
|
+
propsValueMap: {}
|
|
1768
|
+
});
|
|
1769
|
+
constructor() {
|
|
1770
|
+
super([
|
|
1771
|
+
"setPropsConfig",
|
|
1772
|
+
"getPropsConfig",
|
|
1773
|
+
"setPropsValue",
|
|
1774
|
+
"getPropsValue",
|
|
1775
|
+
"createId",
|
|
1776
|
+
"setNewItemId",
|
|
1777
|
+
"fillConfig",
|
|
1778
|
+
"getDefaultPropsValue"
|
|
1779
|
+
]);
|
|
1780
|
+
}
|
|
1781
|
+
setPropsConfigs(configs) {
|
|
1782
|
+
Object.keys(configs).forEach((type) => {
|
|
1783
|
+
this.setPropsConfig(toLine(type), configs[type]);
|
|
1784
|
+
});
|
|
1785
|
+
this.emit("props-configs-change");
|
|
1786
|
+
}
|
|
1787
|
+
async fillConfig(config) {
|
|
1788
|
+
return fillConfig(config);
|
|
1789
|
+
}
|
|
1790
|
+
async setPropsConfig(type, config) {
|
|
1791
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
1792
|
+
}
|
|
1793
|
+
async getPropsConfig(type) {
|
|
1794
|
+
if (type === "area") {
|
|
1795
|
+
return await this.getPropsConfig("button");
|
|
1796
|
+
}
|
|
1797
|
+
return cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
1798
|
+
}
|
|
1799
|
+
setPropsValues(values) {
|
|
1800
|
+
Object.keys(values).forEach((type) => {
|
|
1801
|
+
this.setPropsValue(toLine(type), values[type]);
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
async setPropsValue(type, value) {
|
|
1805
|
+
this.state.propsValueMap[type] = value;
|
|
1806
|
+
}
|
|
1807
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
1808
|
+
if (type === "area") {
|
|
1809
|
+
const value = await this.getPropsValue("button");
|
|
1810
|
+
value.className = "action-area";
|
|
1811
|
+
value.text = "";
|
|
1812
|
+
if (value.style) {
|
|
1813
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
1814
|
+
}
|
|
1815
|
+
return value;
|
|
1816
|
+
}
|
|
1817
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
1818
|
+
this.createId(type),
|
|
1819
|
+
this.getDefaultPropsValue(type),
|
|
1820
|
+
this.setNewItemId(
|
|
1821
|
+
cloneDeep({
|
|
1822
|
+
type,
|
|
1823
|
+
...defaultValue
|
|
1824
|
+
})
|
|
1825
|
+
)
|
|
1826
|
+
]);
|
|
1827
|
+
return {
|
|
1828
|
+
id,
|
|
1829
|
+
...defaultPropsValue,
|
|
1830
|
+
...mergeWith({}, cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
async createId(type) {
|
|
1834
|
+
return `${type}_${this.guid()}`;
|
|
1835
|
+
}
|
|
1836
|
+
async setNewItemId(config) {
|
|
1837
|
+
config.id = await this.createId(config.type || "component");
|
|
1838
|
+
if (config.items && Array.isArray(config.items)) {
|
|
1839
|
+
for (const item of config.items) {
|
|
1840
|
+
await this.setNewItemId(item);
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
return config;
|
|
1844
|
+
}
|
|
1845
|
+
async getDefaultPropsValue(type) {
|
|
1846
|
+
return ["page", "container"].includes(type) ? {
|
|
1847
|
+
type,
|
|
1848
|
+
layout: "absolute",
|
|
1849
|
+
style: {},
|
|
1850
|
+
name: type,
|
|
1851
|
+
items: []
|
|
1852
|
+
} : {
|
|
1853
|
+
type,
|
|
1854
|
+
style: {},
|
|
1855
|
+
name: type
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
resetState() {
|
|
1859
|
+
this.state.propsConfigMap = {};
|
|
1860
|
+
this.state.propsValueMap = {};
|
|
1861
|
+
}
|
|
1862
|
+
destroy() {
|
|
1863
|
+
this.resetState();
|
|
1864
|
+
this.removeAllListeners();
|
|
1865
|
+
this.removeAllPlugins();
|
|
1866
|
+
}
|
|
1867
|
+
guid(digit = 8) {
|
|
1868
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
1869
|
+
const r = Math.random() * 16 | 0;
|
|
1870
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
1871
|
+
return v.toString(16);
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
const propsService = new Props();
|
|
1876
|
+
|
|
1877
|
+
const beforePaste = async (position, config) => {
|
|
1878
|
+
if (!config[0]?.style)
|
|
1879
|
+
return config;
|
|
1880
|
+
const curNode = editorService.get("node");
|
|
1881
|
+
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
1882
|
+
const pasteConfigs = await Promise.all(
|
|
1883
|
+
config.map(async (configItem) => {
|
|
1884
|
+
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
1885
|
+
let pastePosition = positionClone;
|
|
1886
|
+
if (!isEmpty(pastePosition) && curNode?.items) {
|
|
1887
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
1888
|
+
}
|
|
1889
|
+
if (pastePosition.left && configItem.style?.left) {
|
|
1890
|
+
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
1891
|
+
}
|
|
1892
|
+
if (pastePosition.top && configItem.style?.top) {
|
|
1893
|
+
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1894
|
+
}
|
|
1895
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
1896
|
+
if (pasteConfig.style) {
|
|
1897
|
+
const { left, top } = pasteConfig.style;
|
|
1898
|
+
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
1899
|
+
pasteConfig.style.left = Number(left) + offsetX;
|
|
1900
|
+
}
|
|
1371
1901
|
if (typeof top === "number" || !!top && !isNaN(Number(top))) {
|
|
1372
1902
|
pasteConfig.style.top = Number(top) + offsetY;
|
|
1373
1903
|
}
|
|
@@ -1537,7 +2067,7 @@ class Editor$1 extends BaseService {
|
|
|
1537
2067
|
historyService.resetState();
|
|
1538
2068
|
}
|
|
1539
2069
|
if (node?.id) {
|
|
1540
|
-
this.get("stage")?.renderer.runtime?.getApp?.()
|
|
2070
|
+
this.get("stage")?.renderer.runtime?.getApp?.()?.page?.emit(
|
|
1541
2071
|
"editor:select",
|
|
1542
2072
|
{
|
|
1543
2073
|
node,
|
|
@@ -1888,437 +2418,148 @@ class Editor$1 extends BaseService {
|
|
|
1888
2418
|
}
|
|
1889
2419
|
async moveToContainer(config, targetId) {
|
|
1890
2420
|
const root = cloneDeep(this.get("root"));
|
|
1891
|
-
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1892
|
-
const target = this.getNodeById(targetId, false);
|
|
1893
|
-
const stage = this.get("stage");
|
|
1894
|
-
if (root && node && parent && stage) {
|
|
1895
|
-
const index = getNodeIndex(node, parent);
|
|
1896
|
-
parent.items?.splice(index, 1);
|
|
1897
|
-
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1898
|
-
const layout = await this.getLayout(target);
|
|
1899
|
-
const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
|
|
1900
|
-
if (Array.isArray(srcValue)) {
|
|
1901
|
-
return srcValue;
|
|
1902
|
-
}
|
|
1903
|
-
});
|
|
1904
|
-
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1905
|
-
target.items.push(newConfig);
|
|
1906
|
-
await stage.select(targetId);
|
|
1907
|
-
const targetParent = this.getParentById(target.id);
|
|
1908
|
-
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root });
|
|
1909
|
-
await this.select(newConfig);
|
|
1910
|
-
stage.select(newConfig.id);
|
|
1911
|
-
this.addModifiedNodeId(target.id);
|
|
1912
|
-
this.addModifiedNodeId(parent.id);
|
|
1913
|
-
this.pushHistoryState();
|
|
1914
|
-
return newConfig;
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
async undo() {
|
|
1918
|
-
const value = historyService.undo();
|
|
1919
|
-
await this.changeHistoryState(value);
|
|
1920
|
-
return value;
|
|
1921
|
-
}
|
|
1922
|
-
async redo() {
|
|
1923
|
-
const value = historyService.redo();
|
|
1924
|
-
await this.changeHistoryState(value);
|
|
1925
|
-
return value;
|
|
1926
|
-
}
|
|
1927
|
-
async move(left, top) {
|
|
1928
|
-
const node = toRaw(this.get("node"));
|
|
1929
|
-
if (!node || isPage(node))
|
|
1930
|
-
return;
|
|
1931
|
-
const { style, id, type } = node;
|
|
1932
|
-
if (!style || style.position !== "absolute")
|
|
1933
|
-
return;
|
|
1934
|
-
if (top && !isNumber(style.top))
|
|
1935
|
-
return;
|
|
1936
|
-
if (left && !isNumber(style.left))
|
|
1937
|
-
return;
|
|
1938
|
-
this.update({
|
|
1939
|
-
id,
|
|
1940
|
-
type,
|
|
1941
|
-
style: {
|
|
1942
|
-
...style,
|
|
1943
|
-
left: Number(style.left) + left,
|
|
1944
|
-
top: Number(style.top) + top
|
|
1945
|
-
}
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
resetState() {
|
|
1949
|
-
this.set("root", null);
|
|
1950
|
-
this.set("node", null);
|
|
1951
|
-
this.set("nodes", []);
|
|
1952
|
-
this.set("page", null);
|
|
1953
|
-
this.set("parent", null);
|
|
1954
|
-
this.set("stage", null);
|
|
1955
|
-
this.set("highlightNode", null);
|
|
1956
|
-
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
1957
|
-
this.set("pageLength", 0);
|
|
1958
|
-
}
|
|
1959
|
-
destroy() {
|
|
1960
|
-
this.removeAllListeners();
|
|
1961
|
-
this.resetState();
|
|
1962
|
-
this.removeAllPlugins();
|
|
1963
|
-
}
|
|
1964
|
-
resetModifiedNodeId() {
|
|
1965
|
-
this.get("modifiedNodeIds").clear();
|
|
1966
|
-
}
|
|
1967
|
-
addModifiedNodeId(id) {
|
|
1968
|
-
if (!this.isHistoryStateChange) {
|
|
1969
|
-
this.get("modifiedNodeIds").set(id, id);
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
pushHistoryState() {
|
|
1973
|
-
const curNode = cloneDeep(toRaw(this.get("node")));
|
|
1974
|
-
const page = this.get("page");
|
|
1975
|
-
if (!this.isHistoryStateChange && curNode && page) {
|
|
1976
|
-
historyService.push({
|
|
1977
|
-
data: cloneDeep(toRaw(page)),
|
|
1978
|
-
modifiedNodeIds: this.get("modifiedNodeIds"),
|
|
1979
|
-
nodeId: curNode.id
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
this.isHistoryStateChange = false;
|
|
1983
|
-
}
|
|
1984
|
-
async changeHistoryState(value) {
|
|
1985
|
-
if (!value)
|
|
1986
|
-
return;
|
|
1987
|
-
this.isHistoryStateChange = true;
|
|
1988
|
-
await this.update(value.data);
|
|
1989
|
-
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
1990
|
-
setTimeout(async () => {
|
|
1991
|
-
if (!value.nodeId)
|
|
1992
|
-
return;
|
|
1993
|
-
await this.select(value.nodeId);
|
|
1994
|
-
this.get("stage")?.select(value.nodeId);
|
|
1995
|
-
}, 0);
|
|
1996
|
-
this.emit("history-change", value.data);
|
|
1997
|
-
}
|
|
1998
|
-
async toggleFixedPosition(dist, src, root) {
|
|
1999
|
-
const newConfig = cloneDeep(dist);
|
|
2000
|
-
if (!isPop(src) && newConfig.style?.position) {
|
|
2001
|
-
if (isFixed(newConfig) && !isFixed(src)) {
|
|
2002
|
-
newConfig.style = change2Fixed(newConfig, root);
|
|
2003
|
-
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
2004
|
-
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
return newConfig;
|
|
2008
|
-
}
|
|
2009
|
-
selectedConfigExceptionHandler(config) {
|
|
2010
|
-
let id;
|
|
2011
|
-
if (typeof config === "string" || typeof config === "number") {
|
|
2012
|
-
id = config;
|
|
2013
|
-
} else {
|
|
2014
|
-
id = config.id;
|
|
2015
|
-
}
|
|
2016
|
-
if (!id) {
|
|
2017
|
-
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
2018
|
-
}
|
|
2019
|
-
const { node, parent, page } = this.getNodeInfo(id);
|
|
2020
|
-
if (!node)
|
|
2021
|
-
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
2022
|
-
if (node.id === this.state.root?.id) {
|
|
2023
|
-
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
2024
|
-
}
|
|
2025
|
-
return {
|
|
2026
|
-
node,
|
|
2027
|
-
parent,
|
|
2028
|
-
page
|
|
2029
|
-
};
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
const editorService = new Editor$1();
|
|
2033
|
-
|
|
2034
|
-
let eventMap = reactive({});
|
|
2035
|
-
let methodMap = reactive({});
|
|
2036
|
-
class Events extends BaseService {
|
|
2037
|
-
constructor() {
|
|
2038
|
-
super([]);
|
|
2039
|
-
}
|
|
2040
|
-
init(componentGroupList) {
|
|
2041
|
-
componentGroupList.forEach((group) => {
|
|
2042
|
-
group.items.forEach((element) => {
|
|
2043
|
-
const type = toLine(element.type);
|
|
2044
|
-
if (!this.getEvent(type)) {
|
|
2045
|
-
this.setEvent(type, DEFAULT_EVENTS);
|
|
2046
|
-
}
|
|
2047
|
-
if (!this.getMethod(type)) {
|
|
2048
|
-
this.setMethod(type, DEFAULT_METHODS);
|
|
2049
|
-
}
|
|
2050
|
-
});
|
|
2051
|
-
});
|
|
2052
|
-
}
|
|
2053
|
-
setEvents(events) {
|
|
2054
|
-
Object.keys(events).forEach((type) => {
|
|
2055
|
-
this.setEvent(toLine(type), events[type] || []);
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
setEvent(type, events) {
|
|
2059
|
-
eventMap[type] = [...DEFAULT_EVENTS, ...events];
|
|
2060
|
-
}
|
|
2061
|
-
getEvent(type) {
|
|
2062
|
-
return cloneDeep(eventMap[type] || DEFAULT_EVENTS);
|
|
2063
|
-
}
|
|
2064
|
-
setMethods(methods) {
|
|
2065
|
-
Object.keys(methods).forEach((type) => {
|
|
2066
|
-
this.setMethod(toLine(type), methods[type] || []);
|
|
2067
|
-
});
|
|
2068
|
-
}
|
|
2069
|
-
setMethod(type, method) {
|
|
2070
|
-
methodMap[type] = [...DEFAULT_METHODS, ...method];
|
|
2071
|
-
}
|
|
2072
|
-
getMethod(type) {
|
|
2073
|
-
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
2074
|
-
}
|
|
2075
|
-
resetState() {
|
|
2076
|
-
eventMap = reactive({});
|
|
2077
|
-
methodMap = reactive({});
|
|
2078
|
-
}
|
|
2079
|
-
destroy() {
|
|
2080
|
-
this.resetState();
|
|
2081
|
-
this.removeAllListeners();
|
|
2082
|
-
this.removeAllPlugins();
|
|
2083
|
-
}
|
|
2084
|
-
}
|
|
2085
|
-
const eventsService = new Events();
|
|
2086
|
-
|
|
2087
|
-
const fillConfig = (config = []) => [
|
|
2088
|
-
{
|
|
2089
|
-
type: "tab",
|
|
2090
|
-
items: [
|
|
2091
|
-
{
|
|
2092
|
-
title: "\u5C5E\u6027",
|
|
2093
|
-
labelWidth: "80px",
|
|
2094
|
-
items: [
|
|
2095
|
-
{
|
|
2096
|
-
text: "type",
|
|
2097
|
-
name: "type",
|
|
2098
|
-
type: "hidden"
|
|
2099
|
-
},
|
|
2100
|
-
{
|
|
2101
|
-
name: "id",
|
|
2102
|
-
type: "display",
|
|
2103
|
-
text: "id"
|
|
2104
|
-
},
|
|
2105
|
-
{
|
|
2106
|
-
name: "name",
|
|
2107
|
-
text: "\u7EC4\u4EF6\u540D\u79F0"
|
|
2108
|
-
},
|
|
2109
|
-
...config
|
|
2110
|
-
]
|
|
2111
|
-
},
|
|
2112
|
-
{
|
|
2113
|
-
title: "\u6837\u5F0F",
|
|
2114
|
-
labelWidth: "80px",
|
|
2115
|
-
items: [
|
|
2116
|
-
{
|
|
2117
|
-
name: "style",
|
|
2118
|
-
items: [
|
|
2119
|
-
{
|
|
2120
|
-
type: "fieldset",
|
|
2121
|
-
legend: "\u4F4D\u7F6E",
|
|
2122
|
-
items: [
|
|
2123
|
-
{
|
|
2124
|
-
name: "position",
|
|
2125
|
-
type: "checkbox",
|
|
2126
|
-
activeValue: "fixed",
|
|
2127
|
-
inactiveValue: "absolute",
|
|
2128
|
-
defaultValue: "absolute",
|
|
2129
|
-
text: "\u56FA\u5B9A\u5B9A\u4F4D"
|
|
2130
|
-
},
|
|
2131
|
-
{
|
|
2132
|
-
name: "left",
|
|
2133
|
-
text: "left"
|
|
2134
|
-
},
|
|
2135
|
-
{
|
|
2136
|
-
name: "top",
|
|
2137
|
-
text: "top",
|
|
2138
|
-
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedBottom"
|
|
2139
|
-
},
|
|
2140
|
-
{
|
|
2141
|
-
name: "right",
|
|
2142
|
-
text: "right"
|
|
2143
|
-
},
|
|
2144
|
-
{
|
|
2145
|
-
name: "bottom",
|
|
2146
|
-
text: "bottom",
|
|
2147
|
-
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedTop"
|
|
2148
|
-
}
|
|
2149
|
-
]
|
|
2150
|
-
},
|
|
2151
|
-
{
|
|
2152
|
-
type: "fieldset",
|
|
2153
|
-
legend: "\u76D2\u5B50",
|
|
2154
|
-
items: [
|
|
2155
|
-
{
|
|
2156
|
-
name: "width",
|
|
2157
|
-
text: "\u5BBD\u5EA6"
|
|
2158
|
-
},
|
|
2159
|
-
{
|
|
2160
|
-
name: "height",
|
|
2161
|
-
text: "\u9AD8\u5EA6"
|
|
2162
|
-
}
|
|
2163
|
-
]
|
|
2164
|
-
},
|
|
2165
|
-
{
|
|
2166
|
-
type: "fieldset",
|
|
2167
|
-
legend: "\u80CC\u666F",
|
|
2168
|
-
items: [
|
|
2169
|
-
{
|
|
2170
|
-
name: "backgroundImage",
|
|
2171
|
-
text: "\u80CC\u666F\u56FE"
|
|
2172
|
-
},
|
|
2173
|
-
{
|
|
2174
|
-
name: "backgroundColor",
|
|
2175
|
-
text: "\u80CC\u666F\u989C\u8272",
|
|
2176
|
-
type: "colorPicker"
|
|
2177
|
-
},
|
|
2178
|
-
{
|
|
2179
|
-
name: "backgroundRepeat",
|
|
2180
|
-
text: "\u80CC\u666F\u56FE\u91CD\u590D",
|
|
2181
|
-
type: "select",
|
|
2182
|
-
defaultValue: "no-repeat",
|
|
2183
|
-
options: [
|
|
2184
|
-
{ text: "repeat", value: "repeat" },
|
|
2185
|
-
{ text: "repeat-x", value: "repeat-x" },
|
|
2186
|
-
{ text: "repeat-y", value: "repeat-y" },
|
|
2187
|
-
{ text: "no-repeat", value: "no-repeat" },
|
|
2188
|
-
{ text: "inherit", value: "inherit" }
|
|
2189
|
-
]
|
|
2190
|
-
},
|
|
2191
|
-
{
|
|
2192
|
-
name: "backgroundSize",
|
|
2193
|
-
text: "\u80CC\u666F\u56FE\u5927\u5C0F",
|
|
2194
|
-
defaultValue: "100% 100%"
|
|
2195
|
-
}
|
|
2196
|
-
]
|
|
2197
|
-
},
|
|
2198
|
-
{
|
|
2199
|
-
type: "fieldset",
|
|
2200
|
-
legend: "\u5B57\u4F53",
|
|
2201
|
-
items: [
|
|
2202
|
-
{
|
|
2203
|
-
name: "color",
|
|
2204
|
-
text: "\u989C\u8272",
|
|
2205
|
-
type: "colorPicker"
|
|
2206
|
-
},
|
|
2207
|
-
{
|
|
2208
|
-
name: "fontSize",
|
|
2209
|
-
text: "\u5927\u5C0F"
|
|
2210
|
-
},
|
|
2211
|
-
{
|
|
2212
|
-
name: "fontWeight",
|
|
2213
|
-
text: "\u7C97\u7EC6"
|
|
2214
|
-
}
|
|
2215
|
-
]
|
|
2216
|
-
},
|
|
2217
|
-
{
|
|
2218
|
-
type: "fieldset",
|
|
2219
|
-
legend: "\u53D8\u5F62",
|
|
2220
|
-
name: "transform",
|
|
2221
|
-
items: [
|
|
2222
|
-
{
|
|
2223
|
-
name: "rotate",
|
|
2224
|
-
text: "\u65CB\u8F6C\u89D2\u5EA6"
|
|
2225
|
-
},
|
|
2226
|
-
{
|
|
2227
|
-
name: "scale",
|
|
2228
|
-
text: "\u7F29\u653E"
|
|
2229
|
-
}
|
|
2230
|
-
]
|
|
2231
|
-
}
|
|
2232
|
-
]
|
|
2233
|
-
}
|
|
2234
|
-
]
|
|
2235
|
-
},
|
|
2236
|
-
{
|
|
2237
|
-
title: "\u4E8B\u4EF6",
|
|
2238
|
-
items: [
|
|
2239
|
-
{
|
|
2240
|
-
type: "table",
|
|
2241
|
-
name: "events",
|
|
2242
|
-
items: [
|
|
2243
|
-
{
|
|
2244
|
-
name: "name",
|
|
2245
|
-
label: "\u4E8B\u4EF6\u540D",
|
|
2246
|
-
type: "select",
|
|
2247
|
-
options: (mForm, { formValue }) => eventsService.getEvent(formValue.type).map((option) => ({
|
|
2248
|
-
text: option.label,
|
|
2249
|
-
value: option.value
|
|
2250
|
-
}))
|
|
2251
|
-
},
|
|
2252
|
-
{
|
|
2253
|
-
name: "to",
|
|
2254
|
-
label: "\u8054\u52A8\u7EC4\u4EF6",
|
|
2255
|
-
type: "ui-select"
|
|
2256
|
-
},
|
|
2257
|
-
{
|
|
2258
|
-
name: "method",
|
|
2259
|
-
label: "\u52A8\u4F5C",
|
|
2260
|
-
type: "select",
|
|
2261
|
-
options: (mForm, { model }) => {
|
|
2262
|
-
const node = editorService.getNodeById(model.to);
|
|
2263
|
-
if (!node?.type)
|
|
2264
|
-
return [];
|
|
2265
|
-
return eventsService.getMethod(node.type).map((option) => ({
|
|
2266
|
-
text: option.label,
|
|
2267
|
-
value: option.value
|
|
2268
|
-
}));
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
]
|
|
2272
|
-
}
|
|
2273
|
-
]
|
|
2274
|
-
},
|
|
2275
|
-
{
|
|
2276
|
-
title: "\u9AD8\u7EA7",
|
|
2277
|
-
lazy: true,
|
|
2278
|
-
items: [
|
|
2279
|
-
{
|
|
2280
|
-
name: "created",
|
|
2281
|
-
text: "created",
|
|
2282
|
-
labelWidth: "100px",
|
|
2283
|
-
type: "code-select"
|
|
2284
|
-
},
|
|
2285
|
-
{
|
|
2286
|
-
name: "mounted",
|
|
2287
|
-
text: "mounted",
|
|
2288
|
-
labelWidth: "100px",
|
|
2289
|
-
type: "code-select"
|
|
2290
|
-
}
|
|
2291
|
-
]
|
|
2421
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
2422
|
+
const target = this.getNodeById(targetId, false);
|
|
2423
|
+
const stage = this.get("stage");
|
|
2424
|
+
if (root && node && parent && stage) {
|
|
2425
|
+
const index = getNodeIndex(node, parent);
|
|
2426
|
+
parent.items?.splice(index, 1);
|
|
2427
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
2428
|
+
const layout = await this.getLayout(target);
|
|
2429
|
+
const newConfig = mergeWith(cloneDeep(node), config, (objValue, srcValue) => {
|
|
2430
|
+
if (Array.isArray(srcValue)) {
|
|
2431
|
+
return srcValue;
|
|
2432
|
+
}
|
|
2433
|
+
});
|
|
2434
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
2435
|
+
target.items.push(newConfig);
|
|
2436
|
+
await stage.select(targetId);
|
|
2437
|
+
const targetParent = this.getParentById(target.id);
|
|
2438
|
+
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root });
|
|
2439
|
+
await this.select(newConfig);
|
|
2440
|
+
stage.select(newConfig.id);
|
|
2441
|
+
this.addModifiedNodeId(target.id);
|
|
2442
|
+
this.addModifiedNodeId(parent.id);
|
|
2443
|
+
this.pushHistoryState();
|
|
2444
|
+
return newConfig;
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
async undo() {
|
|
2448
|
+
const value = historyService.undo();
|
|
2449
|
+
await this.changeHistoryState(value);
|
|
2450
|
+
return value;
|
|
2451
|
+
}
|
|
2452
|
+
async redo() {
|
|
2453
|
+
const value = historyService.redo();
|
|
2454
|
+
await this.changeHistoryState(value);
|
|
2455
|
+
return value;
|
|
2456
|
+
}
|
|
2457
|
+
async move(left, top) {
|
|
2458
|
+
const node = toRaw(this.get("node"));
|
|
2459
|
+
if (!node || isPage(node))
|
|
2460
|
+
return;
|
|
2461
|
+
const { style, id, type } = node;
|
|
2462
|
+
if (!style || style.position !== "absolute")
|
|
2463
|
+
return;
|
|
2464
|
+
if (top && !isNumber(style.top))
|
|
2465
|
+
return;
|
|
2466
|
+
if (left && !isNumber(style.left))
|
|
2467
|
+
return;
|
|
2468
|
+
this.update({
|
|
2469
|
+
id,
|
|
2470
|
+
type,
|
|
2471
|
+
style: {
|
|
2472
|
+
...style,
|
|
2473
|
+
left: Number(style.left) + left,
|
|
2474
|
+
top: Number(style.top) + top
|
|
2292
2475
|
}
|
|
2293
|
-
|
|
2476
|
+
});
|
|
2294
2477
|
}
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2478
|
+
resetState() {
|
|
2479
|
+
this.set("root", null);
|
|
2480
|
+
this.set("node", null);
|
|
2481
|
+
this.set("nodes", []);
|
|
2482
|
+
this.set("page", null);
|
|
2483
|
+
this.set("parent", null);
|
|
2484
|
+
this.set("stage", null);
|
|
2485
|
+
this.set("highlightNode", null);
|
|
2486
|
+
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
2487
|
+
this.set("pageLength", 0);
|
|
2300
2488
|
}
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2489
|
+
destroy() {
|
|
2490
|
+
this.removeAllListeners();
|
|
2491
|
+
this.resetState();
|
|
2492
|
+
this.removeAllPlugins();
|
|
2305
2493
|
}
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
if (process.env.NODE_ENV === "development") {
|
|
2309
|
-
console.warn("magic editor: ", ...args);
|
|
2494
|
+
resetModifiedNodeId() {
|
|
2495
|
+
this.get("modifiedNodeIds").clear();
|
|
2310
2496
|
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2497
|
+
addModifiedNodeId(id) {
|
|
2498
|
+
if (!this.isHistoryStateChange) {
|
|
2499
|
+
this.get("modifiedNodeIds").set(id, id);
|
|
2500
|
+
}
|
|
2315
2501
|
}
|
|
2316
|
-
|
|
2317
|
-
const
|
|
2318
|
-
|
|
2319
|
-
|
|
2502
|
+
pushHistoryState() {
|
|
2503
|
+
const curNode = cloneDeep(toRaw(this.get("node")));
|
|
2504
|
+
const page = this.get("page");
|
|
2505
|
+
if (!this.isHistoryStateChange && curNode && page) {
|
|
2506
|
+
historyService.push({
|
|
2507
|
+
data: cloneDeep(toRaw(page)),
|
|
2508
|
+
modifiedNodeIds: this.get("modifiedNodeIds"),
|
|
2509
|
+
nodeId: curNode.id
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
this.isHistoryStateChange = false;
|
|
2320
2513
|
}
|
|
2321
|
-
|
|
2514
|
+
async changeHistoryState(value) {
|
|
2515
|
+
if (!value)
|
|
2516
|
+
return;
|
|
2517
|
+
this.isHistoryStateChange = true;
|
|
2518
|
+
await this.update(value.data);
|
|
2519
|
+
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
2520
|
+
setTimeout(async () => {
|
|
2521
|
+
if (!value.nodeId)
|
|
2522
|
+
return;
|
|
2523
|
+
await this.select(value.nodeId);
|
|
2524
|
+
this.get("stage")?.select(value.nodeId);
|
|
2525
|
+
}, 0);
|
|
2526
|
+
this.emit("history-change", value.data);
|
|
2527
|
+
}
|
|
2528
|
+
async toggleFixedPosition(dist, src, root) {
|
|
2529
|
+
const newConfig = cloneDeep(dist);
|
|
2530
|
+
if (!isPop(src) && newConfig.style?.position) {
|
|
2531
|
+
if (isFixed(newConfig) && !isFixed(src)) {
|
|
2532
|
+
newConfig.style = change2Fixed(newConfig, root);
|
|
2533
|
+
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
2534
|
+
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
return newConfig;
|
|
2538
|
+
}
|
|
2539
|
+
selectedConfigExceptionHandler(config) {
|
|
2540
|
+
let id;
|
|
2541
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
2542
|
+
id = config;
|
|
2543
|
+
} else {
|
|
2544
|
+
id = config.id;
|
|
2545
|
+
}
|
|
2546
|
+
if (!id) {
|
|
2547
|
+
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
2548
|
+
}
|
|
2549
|
+
const { node, parent, page } = this.getNodeInfo(id);
|
|
2550
|
+
if (!node)
|
|
2551
|
+
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
2552
|
+
if (node.id === this.state.root?.id) {
|
|
2553
|
+
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
2554
|
+
}
|
|
2555
|
+
return {
|
|
2556
|
+
node,
|
|
2557
|
+
parent,
|
|
2558
|
+
page
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
const editorService = new Editor$1();
|
|
2322
2563
|
|
|
2323
2564
|
const state = reactive({
|
|
2324
2565
|
uiSelectMode: false,
|
|
@@ -2518,7 +2759,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
2518
2759
|
onClick: clickHandler
|
|
2519
2760
|
}, [
|
|
2520
2761
|
createElementVNode("div", null, [
|
|
2521
|
-
createVNode(_sfc_main$
|
|
2762
|
+
createVNode(_sfc_main$u, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
2522
2763
|
]),
|
|
2523
2764
|
_hoisted_3$3
|
|
2524
2765
|
])
|
|
@@ -2749,7 +2990,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2749
2990
|
disabled: unref(disabled)
|
|
2750
2991
|
}, {
|
|
2751
2992
|
default: withCtx(() => [
|
|
2752
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
2993
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$u, {
|
|
2753
2994
|
key: 0,
|
|
2754
2995
|
icon: __props.data.icon
|
|
2755
2996
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -2766,7 +3007,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
2766
3007
|
disabled: unref(disabled)
|
|
2767
3008
|
}, {
|
|
2768
3009
|
default: withCtx(() => [
|
|
2769
|
-
__props.data.icon ? (openBlock(), createBlock(_sfc_main$
|
|
3010
|
+
__props.data.icon ? (openBlock(), createBlock(_sfc_main$u, {
|
|
2770
3011
|
key: 0,
|
|
2771
3012
|
icon: __props.data.icon
|
|
2772
3013
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -3124,14 +3365,17 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
3124
3365
|
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3125
3366
|
if (codeDraft) {
|
|
3126
3367
|
tMagicMessageBox.confirm("\u60A8\u6709\u4EE3\u7801\u4FEE\u6539\u672A\u4FDD\u5B58\uFF0C\u662F\u5426\u4FDD\u5B58\u540E\u518D\u5173\u95ED\uFF1F", "\u63D0\u793A", {
|
|
3127
|
-
confirmButtonText: "\
|
|
3128
|
-
cancelButtonText: "\
|
|
3129
|
-
type: "warning"
|
|
3368
|
+
confirmButtonText: "\u4FDD\u5B58\u5E76\u5173\u95ED",
|
|
3369
|
+
cancelButtonText: "\u76F4\u63A5\u5173\u95ED",
|
|
3370
|
+
type: "warning",
|
|
3371
|
+
distinguishCancelAndClose: true
|
|
3130
3372
|
}).then(async () => {
|
|
3131
3373
|
saveAndClose();
|
|
3132
|
-
}).catch(() => {
|
|
3133
|
-
|
|
3134
|
-
|
|
3374
|
+
}).catch((action) => {
|
|
3375
|
+
if (action === "cancel") {
|
|
3376
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3377
|
+
emit("close");
|
|
3378
|
+
}
|
|
3135
3379
|
});
|
|
3136
3380
|
} else {
|
|
3137
3381
|
emit("close");
|
|
@@ -3472,22 +3716,10 @@ const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u65B0\u589E");
|
|
|
3472
3716
|
const _hoisted_4 = ["id"];
|
|
3473
3717
|
const _hoisted_5 = { class: "list-item" };
|
|
3474
3718
|
const _hoisted_6 = { class: "code-name" };
|
|
3475
|
-
const _hoisted_7 = {
|
|
3476
|
-
const _hoisted_8 = {
|
|
3719
|
+
const _hoisted_7 = {
|
|
3477
3720
|
key: 0,
|
|
3478
|
-
class: "
|
|
3721
|
+
class: "right-tool"
|
|
3479
3722
|
};
|
|
3480
|
-
const _hoisted_9 = /* @__PURE__ */ createElementVNode("svg", {
|
|
3481
|
-
class: "arrow-left",
|
|
3482
|
-
viewBox: "0 0 1024 1024",
|
|
3483
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3484
|
-
"data-v-029747aa": ""
|
|
3485
|
-
}, [
|
|
3486
|
-
/* @__PURE__ */ createElementVNode("path", {
|
|
3487
|
-
fill: "currentColor",
|
|
3488
|
-
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"
|
|
3489
|
-
})
|
|
3490
|
-
], -1);
|
|
3491
3723
|
const __default__$d = defineComponent({
|
|
3492
3724
|
name: "MEditorCodeBlockList"
|
|
3493
3725
|
});
|
|
@@ -3499,64 +3731,23 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3499
3731
|
},
|
|
3500
3732
|
setup(__props) {
|
|
3501
3733
|
const props = __props;
|
|
3502
|
-
const
|
|
3503
|
-
const
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
bindsComp.push({
|
|
3516
|
-
compId,
|
|
3517
|
-
compName: getCompName(compId)
|
|
3518
|
-
});
|
|
3519
|
-
}
|
|
3520
|
-
});
|
|
3521
|
-
return bindsComp;
|
|
3522
|
-
};
|
|
3523
|
-
const refreshCodeList = async () => {
|
|
3524
|
-
const codeDsl = cloneDeep(await services?.codeBlockService.getCodeDsl()) || null;
|
|
3525
|
-
codeCombineInfo.value = cloneDeep(services?.codeBlockService.getCombineInfo()) || null;
|
|
3526
|
-
if (!codeDsl || !codeCombineInfo.value)
|
|
3527
|
-
return;
|
|
3528
|
-
state.codeList = [];
|
|
3529
|
-
forIn(codeDsl, (value, codeId) => {
|
|
3530
|
-
state.codeList.push({
|
|
3531
|
-
id: codeId,
|
|
3532
|
-
name: value.name,
|
|
3533
|
-
codeBlockContent: value,
|
|
3534
|
-
showRelation: true,
|
|
3535
|
-
combineInfo: getBindCompsByCodeId(codeId)
|
|
3536
|
-
});
|
|
3537
|
-
});
|
|
3538
|
-
};
|
|
3539
|
-
watch(
|
|
3540
|
-
() => services?.editorService.get("root"),
|
|
3541
|
-
() => {
|
|
3542
|
-
services?.codeBlockService.refreshAllRelations();
|
|
3543
|
-
refreshCodeList();
|
|
3544
|
-
},
|
|
3545
|
-
{
|
|
3546
|
-
immediate: true
|
|
3547
|
-
}
|
|
3548
|
-
);
|
|
3549
|
-
watch(
|
|
3550
|
-
[() => services?.codeBlockService.getCodeDsl(), () => services?.codeBlockService.getCombineInfo()],
|
|
3551
|
-
() => {
|
|
3552
|
-
refreshCodeList();
|
|
3553
|
-
},
|
|
3554
|
-
{
|
|
3555
|
-
deep: true
|
|
3556
|
-
}
|
|
3734
|
+
const { codeBlockService, depService, editorService } = inject("services") || {};
|
|
3735
|
+
const codeList = computed(
|
|
3736
|
+
() => Object.values(depService?.targets["code-block"] || {}).map((target) => ({
|
|
3737
|
+
id: target.id,
|
|
3738
|
+
name: target.name,
|
|
3739
|
+
type: "code",
|
|
3740
|
+
children: Object.entries(target.deps).map(([id, dep]) => ({
|
|
3741
|
+
name: dep.name,
|
|
3742
|
+
type: "node",
|
|
3743
|
+
id,
|
|
3744
|
+
children: dep.keys.map((key) => ({ name: key, id: key, type: "key" }))
|
|
3745
|
+
}))
|
|
3746
|
+
}))
|
|
3557
3747
|
);
|
|
3748
|
+
const editable = computed(() => codeBlockService?.getEditStatus());
|
|
3749
|
+
const isShowCodeBlockEditor = computed(() => codeBlockService?.getCodeEditorShowStatus() || false);
|
|
3558
3750
|
const createCodeBlock = async () => {
|
|
3559
|
-
const { codeBlockService } = services || {};
|
|
3560
3751
|
if (!codeBlockService) {
|
|
3561
3752
|
tMagicMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
|
|
3562
3753
|
return;
|
|
@@ -3573,14 +3764,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3573
3764
|
codeBlockService.setCodeEditorContent(true, id);
|
|
3574
3765
|
};
|
|
3575
3766
|
const editCode = async (key) => {
|
|
3576
|
-
|
|
3767
|
+
codeBlockService?.setCodeEditorContent(true, key);
|
|
3577
3768
|
};
|
|
3578
3769
|
const deleteCode = (key) => {
|
|
3579
|
-
const currentCode =
|
|
3580
|
-
const existBinds =
|
|
3581
|
-
const undeleteableList =
|
|
3770
|
+
const currentCode = codeList.value.find((codeItem) => codeItem.id === key);
|
|
3771
|
+
const existBinds = Boolean(currentCode?.children.length);
|
|
3772
|
+
const undeleteableList = codeBlockService?.getUndeletableList() || [];
|
|
3582
3773
|
if (!existBinds && !undeleteableList.includes(key)) {
|
|
3583
|
-
|
|
3774
|
+
codeBlockService?.deleteCodeDslByIds([key]);
|
|
3584
3775
|
} else {
|
|
3585
3776
|
if (typeof props.customError === "function") {
|
|
3586
3777
|
props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
|
|
@@ -3595,27 +3786,23 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3595
3786
|
if (!value) {
|
|
3596
3787
|
return true;
|
|
3597
3788
|
}
|
|
3598
|
-
return `${data.name}${data.id}`.indexOf(value) !== -1;
|
|
3789
|
+
return `${data.name}${data.id}`.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) !== -1;
|
|
3599
3790
|
};
|
|
3600
3791
|
const filterTextChangeHandler = (val) => {
|
|
3601
3792
|
tree.value?.filter(val);
|
|
3602
3793
|
};
|
|
3603
|
-
const toggleCombineRelation = (data) => {
|
|
3604
|
-
const { id } = data;
|
|
3605
|
-
const currentCode = state.codeList.find((item) => item.id === id);
|
|
3606
|
-
if (!currentCode)
|
|
3607
|
-
return;
|
|
3608
|
-
currentCode.showRelation = !currentCode?.showRelation;
|
|
3609
|
-
};
|
|
3610
|
-
const getCompName = (compId) => {
|
|
3611
|
-
const node = services?.editorService.getNodeById(compId);
|
|
3612
|
-
return node?.name || String(compId);
|
|
3613
|
-
};
|
|
3614
3794
|
const selectComp = (compId) => {
|
|
3615
|
-
const stage =
|
|
3616
|
-
|
|
3795
|
+
const stage = editorService?.get("stage");
|
|
3796
|
+
editorService?.select(compId);
|
|
3617
3797
|
stage?.select(compId);
|
|
3618
3798
|
};
|
|
3799
|
+
const clickHandler = (data, node) => {
|
|
3800
|
+
if (data.type === "node") {
|
|
3801
|
+
selectComp(data.id);
|
|
3802
|
+
} else if (data.type === "key") {
|
|
3803
|
+
selectComp(node.parent.data.id);
|
|
3804
|
+
}
|
|
3805
|
+
};
|
|
3619
3806
|
return (_ctx, _cache) => {
|
|
3620
3807
|
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
3621
3808
|
renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
@@ -3645,16 +3832,18 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3645
3832
|
]),
|
|
3646
3833
|
createVNode(unref(TMagicScrollbar), null, {
|
|
3647
3834
|
default: withCtx(() => [
|
|
3648
|
-
|
|
3649
|
-
key: 0,
|
|
3835
|
+
createVNode(unref(TMagicTree), {
|
|
3650
3836
|
ref_key: "tree",
|
|
3651
3837
|
ref: tree,
|
|
3838
|
+
class: "magic-editor-layer-tree",
|
|
3652
3839
|
"node-key": "id",
|
|
3653
3840
|
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3654
|
-
|
|
3841
|
+
"default-expand-all": "",
|
|
3842
|
+
"expand-on-click-node": false,
|
|
3843
|
+
data: unref(codeList),
|
|
3655
3844
|
"highlight-current": true,
|
|
3656
3845
|
"filter-node-method": filterNode,
|
|
3657
|
-
onNodeClick:
|
|
3846
|
+
onNodeClick: clickHandler
|
|
3658
3847
|
}, {
|
|
3659
3848
|
default: withCtx(({ data }) => [
|
|
3660
3849
|
createElementVNode("div", {
|
|
@@ -3663,14 +3852,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3663
3852
|
}, [
|
|
3664
3853
|
createElementVNode("div", _hoisted_5, [
|
|
3665
3854
|
createElementVNode("span", _hoisted_6, toDisplayString(data.name) + "\uFF08" + toDisplayString(data.id) + "\uFF09", 1),
|
|
3666
|
-
|
|
3855
|
+
data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
3667
3856
|
createVNode(unref(TMagicTooltip), {
|
|
3668
3857
|
effect: "dark",
|
|
3669
3858
|
content: unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
|
|
3670
3859
|
placement: "bottom"
|
|
3671
3860
|
}, {
|
|
3672
3861
|
default: withCtx(() => [
|
|
3673
|
-
createVNode(_sfc_main$
|
|
3862
|
+
createVNode(_sfc_main$u, {
|
|
3674
3863
|
icon: unref(editable) ? unref(Edit) : unref(View),
|
|
3675
3864
|
class: "edit-icon",
|
|
3676
3865
|
onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
@@ -3678,29 +3867,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3678
3867
|
]),
|
|
3679
3868
|
_: 2
|
|
3680
3869
|
}, 1032, ["content"]),
|
|
3681
|
-
data.combineInfo && data.combineInfo.length > 0 ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3682
|
-
key: 0,
|
|
3683
|
-
effect: "dark",
|
|
3684
|
-
content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
|
|
3685
|
-
placement: "bottom"
|
|
3686
|
-
}, {
|
|
3687
|
-
default: withCtx(() => [
|
|
3688
|
-
createVNode(_sfc_main$s, {
|
|
3689
|
-
icon: unref(Link),
|
|
3690
|
-
class: "edit-icon",
|
|
3691
|
-
onClick: withModifiers(($event) => toggleCombineRelation(data), ["stop"])
|
|
3692
|
-
}, null, 8, ["icon", "onClick"])
|
|
3693
|
-
]),
|
|
3694
|
-
_: 2
|
|
3695
|
-
}, 1024)) : createCommentVNode("", true),
|
|
3696
3870
|
unref(editable) ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3697
|
-
key:
|
|
3871
|
+
key: 0,
|
|
3698
3872
|
effect: "dark",
|
|
3699
3873
|
content: "\u5220\u9664",
|
|
3700
3874
|
placement: "bottom"
|
|
3701
3875
|
}, {
|
|
3702
3876
|
default: withCtx(() => [
|
|
3703
|
-
createVNode(_sfc_main$
|
|
3877
|
+
createVNode(_sfc_main$u, {
|
|
3704
3878
|
icon: unref(Close),
|
|
3705
3879
|
class: "edit-icon",
|
|
3706
3880
|
onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
@@ -3712,29 +3886,12 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
3712
3886
|
id: data.id,
|
|
3713
3887
|
data: data.codeBlockContent
|
|
3714
3888
|
})
|
|
3715
|
-
])
|
|
3716
|
-
])
|
|
3717
|
-
data.showRelation && data.combineInfo && data.combineInfo.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
3718
|
-
_hoisted_9,
|
|
3719
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(data.combineInfo, (comp, index) => {
|
|
3720
|
-
return openBlock(), createBlock(unref(TMagicButton), {
|
|
3721
|
-
key: index,
|
|
3722
|
-
class: "code-comp",
|
|
3723
|
-
size: "small",
|
|
3724
|
-
plain: true,
|
|
3725
|
-
onClick: withModifiers(($event) => selectComp(comp.compId), ["stop"])
|
|
3726
|
-
}, {
|
|
3727
|
-
default: withCtx(() => [
|
|
3728
|
-
createTextVNode(toDisplayString(comp.compName), 1)
|
|
3729
|
-
]),
|
|
3730
|
-
_: 2
|
|
3731
|
-
}, 1032, ["onClick"]);
|
|
3732
|
-
}), 128))
|
|
3733
|
-
])) : createCommentVNode("", true)
|
|
3889
|
+
])) : createCommentVNode("", true)
|
|
3890
|
+
])
|
|
3734
3891
|
], 8, _hoisted_4)
|
|
3735
3892
|
]),
|
|
3736
3893
|
_: 3
|
|
3737
|
-
}, 8, ["data"])
|
|
3894
|
+
}, 8, ["data"])
|
|
3738
3895
|
]),
|
|
3739
3896
|
_: 3
|
|
3740
3897
|
}),
|
|
@@ -3846,7 +4003,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3846
4003
|
name: `${index}`
|
|
3847
4004
|
}, {
|
|
3848
4005
|
title: withCtx(() => [
|
|
3849
|
-
createVNode(_sfc_main$
|
|
4006
|
+
createVNode(_sfc_main$u, { icon: unref(Grid) }, null, 8, ["icon"]),
|
|
3850
4007
|
createTextVNode(toDisplayString(group.title), 1)
|
|
3851
4008
|
]),
|
|
3852
4009
|
default: withCtx(() => [
|
|
@@ -3861,7 +4018,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
3861
4018
|
onDrag: dragHandler
|
|
3862
4019
|
}, [
|
|
3863
4020
|
renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
3864
|
-
createVNode(_sfc_main$
|
|
4021
|
+
createVNode(_sfc_main$u, {
|
|
3865
4022
|
icon: item.icon
|
|
3866
4023
|
}, null, 8, ["icon"]),
|
|
3867
4024
|
createVNode(unref(TMagicTooltip), {
|
|
@@ -4462,7 +4619,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
4462
4619
|
(openBlock(), createElementBlock("div", {
|
|
4463
4620
|
key: config.text
|
|
4464
4621
|
}, [
|
|
4465
|
-
config.icon ? (openBlock(), createBlock(_sfc_main$
|
|
4622
|
+
config.icon ? (openBlock(), createBlock(_sfc_main$u, {
|
|
4466
4623
|
key: 0,
|
|
4467
4624
|
icon: config.icon
|
|
4468
4625
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
@@ -4683,14 +4840,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4683
4840
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4684
4841
|
onClick: addPage
|
|
4685
4842
|
}, [
|
|
4686
|
-
createVNode(_sfc_main$
|
|
4843
|
+
createVNode(_sfc_main$u, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
4687
4844
|
])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
|
|
4688
4845
|
canScroll.value ? (openBlock(), createElementBlock("div", {
|
|
4689
4846
|
key: 2,
|
|
4690
4847
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4691
4848
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
4692
4849
|
}, [
|
|
4693
|
-
createVNode(_sfc_main$
|
|
4850
|
+
createVNode(_sfc_main$u, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
|
|
4694
4851
|
])) : createCommentVNode("", true),
|
|
4695
4852
|
unref(pageLength) ? (openBlock(), createElementBlock("div", {
|
|
4696
4853
|
key: 3,
|
|
@@ -4706,7 +4863,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4706
4863
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4707
4864
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
4708
4865
|
}, [
|
|
4709
|
-
createVNode(_sfc_main$
|
|
4866
|
+
createVNode(_sfc_main$u, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
|
|
4710
4867
|
])) : createCommentVNode("", true)
|
|
4711
4868
|
], 512);
|
|
4712
4869
|
};
|
|
@@ -5597,8 +5754,7 @@ class CodeBlock extends BaseService {
|
|
|
5597
5754
|
id: "",
|
|
5598
5755
|
editable: true,
|
|
5599
5756
|
combineIds: [],
|
|
5600
|
-
undeletableList: []
|
|
5601
|
-
relations: {}
|
|
5757
|
+
undeletableList: []
|
|
5602
5758
|
});
|
|
5603
5759
|
constructor() {
|
|
5604
5760
|
super([
|
|
@@ -5643,6 +5799,7 @@ class CodeBlock extends BaseService {
|
|
|
5643
5799
|
...existContent,
|
|
5644
5800
|
...codeConfigProcessed
|
|
5645
5801
|
};
|
|
5802
|
+
this.emit("addOrUpdate", id, codeDsl[id]);
|
|
5646
5803
|
}
|
|
5647
5804
|
async getCodeDslByIds(ids) {
|
|
5648
5805
|
const codeDsl2 = await this.getCodeDsl();
|
|
@@ -5683,39 +5840,6 @@ class CodeBlock extends BaseService {
|
|
|
5683
5840
|
getCombineIds() {
|
|
5684
5841
|
return this.state.combineIds;
|
|
5685
5842
|
}
|
|
5686
|
-
addCodeRelationListener() {
|
|
5687
|
-
editorService.on("update", (nodes) => {
|
|
5688
|
-
const relations = cloneDeep(this.state.relations);
|
|
5689
|
-
nodes.forEach((node) => {
|
|
5690
|
-
if (node?.id) {
|
|
5691
|
-
relations[node.id] = [];
|
|
5692
|
-
this.getNodeRelation(node, relations);
|
|
5693
|
-
}
|
|
5694
|
-
});
|
|
5695
|
-
this.state.relations = { ...relations };
|
|
5696
|
-
});
|
|
5697
|
-
editorService.on("remove", (nodes) => {
|
|
5698
|
-
nodes.forEach((node) => {
|
|
5699
|
-
this.state.relations = this.deleteNodeRelation(node, this.state.relations);
|
|
5700
|
-
});
|
|
5701
|
-
});
|
|
5702
|
-
editorService.on("history-change", (page) => {
|
|
5703
|
-
const relations = {};
|
|
5704
|
-
this.getNodeRelation(page, relations, true);
|
|
5705
|
-
this.state.relations = relations;
|
|
5706
|
-
});
|
|
5707
|
-
}
|
|
5708
|
-
refreshAllRelations() {
|
|
5709
|
-
const root = editorService.get("root");
|
|
5710
|
-
if (!root)
|
|
5711
|
-
return;
|
|
5712
|
-
const relations = {};
|
|
5713
|
-
this.getNodeRelation(root, relations, true);
|
|
5714
|
-
this.state.relations = relations;
|
|
5715
|
-
}
|
|
5716
|
-
getCombineInfo() {
|
|
5717
|
-
return this.state.relations;
|
|
5718
|
-
}
|
|
5719
5843
|
getUndeletableList() {
|
|
5720
5844
|
return this.state.undeletableList;
|
|
5721
5845
|
}
|
|
@@ -5737,88 +5861,268 @@ class CodeBlock extends BaseService {
|
|
|
5737
5861
|
return;
|
|
5738
5862
|
codeIds.forEach((id2) => {
|
|
5739
5863
|
delete currentDsl[id2];
|
|
5864
|
+
this.emit("remove", id2);
|
|
5740
5865
|
});
|
|
5741
5866
|
}
|
|
5742
|
-
async getUniqueId() {
|
|
5743
|
-
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
5744
|
-
const dsl = await this.getCodeDsl();
|
|
5745
|
-
const existedIds = keys(dsl);
|
|
5746
|
-
if (!existedIds.includes(newId))
|
|
5747
|
-
return newId;
|
|
5748
|
-
return await this.getUniqueId();
|
|
5867
|
+
async getUniqueId() {
|
|
5868
|
+
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
5869
|
+
const dsl = await this.getCodeDsl();
|
|
5870
|
+
const existedIds = keys(dsl);
|
|
5871
|
+
if (!existedIds.includes(newId))
|
|
5872
|
+
return newId;
|
|
5873
|
+
return await this.getUniqueId();
|
|
5874
|
+
}
|
|
5875
|
+
resetState() {
|
|
5876
|
+
this.state.isShowCodeEditor = false;
|
|
5877
|
+
this.state.codeDsl = null;
|
|
5878
|
+
this.state.id = "";
|
|
5879
|
+
this.state.editable = true;
|
|
5880
|
+
this.state.combineIds = [];
|
|
5881
|
+
this.state.undeletableList = [];
|
|
5882
|
+
}
|
|
5883
|
+
destroy() {
|
|
5884
|
+
this.resetState();
|
|
5885
|
+
this.removeAllListeners();
|
|
5886
|
+
this.removeAllPlugins();
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5889
|
+
const codeBlockService = new CodeBlock();
|
|
5890
|
+
|
|
5891
|
+
class ComponentList extends BaseService {
|
|
5892
|
+
state = reactive({
|
|
5893
|
+
list: []
|
|
5894
|
+
});
|
|
5895
|
+
constructor() {
|
|
5896
|
+
super([]);
|
|
5897
|
+
}
|
|
5898
|
+
setList(componentGroupList) {
|
|
5899
|
+
this.state.list = componentGroupList;
|
|
5900
|
+
}
|
|
5901
|
+
getList() {
|
|
5902
|
+
return this.state.list;
|
|
5749
5903
|
}
|
|
5750
5904
|
resetState() {
|
|
5751
|
-
this.state.
|
|
5752
|
-
this.state.codeDsl = null;
|
|
5753
|
-
this.state.id = "";
|
|
5754
|
-
this.state.editable = true;
|
|
5755
|
-
this.state.combineIds = [];
|
|
5756
|
-
this.state.undeletableList = [];
|
|
5905
|
+
this.state.list = [];
|
|
5757
5906
|
}
|
|
5758
5907
|
destroy() {
|
|
5759
5908
|
this.resetState();
|
|
5760
5909
|
this.removeAllListeners();
|
|
5761
5910
|
this.removeAllPlugins();
|
|
5762
5911
|
}
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5912
|
+
}
|
|
5913
|
+
const componentListService = new ComponentList();
|
|
5914
|
+
|
|
5915
|
+
class Target extends EventEmitter {
|
|
5916
|
+
isTarget;
|
|
5917
|
+
id;
|
|
5918
|
+
name;
|
|
5919
|
+
type = "default";
|
|
5920
|
+
deps = reactive({});
|
|
5921
|
+
constructor(options) {
|
|
5922
|
+
super();
|
|
5923
|
+
this.isTarget = options.isTarget;
|
|
5924
|
+
this.id = options.id;
|
|
5925
|
+
this.name = options.name;
|
|
5926
|
+
if (options.type) {
|
|
5927
|
+
this.type = options.type;
|
|
5928
|
+
}
|
|
5929
|
+
}
|
|
5930
|
+
updateDep(node, key) {
|
|
5931
|
+
const dep = this.deps[node.id] || {
|
|
5932
|
+
name: node.name,
|
|
5933
|
+
keys: []
|
|
5934
|
+
};
|
|
5935
|
+
if (node.name) {
|
|
5936
|
+
dep.name = node.name;
|
|
5937
|
+
}
|
|
5938
|
+
this.deps[node.id] = dep;
|
|
5939
|
+
if (dep.keys.indexOf(key) === -1) {
|
|
5940
|
+
dep.keys.push(key);
|
|
5941
|
+
}
|
|
5942
|
+
this.emit("change");
|
|
5943
|
+
}
|
|
5944
|
+
removeDep(node, key) {
|
|
5945
|
+
if (!node) {
|
|
5946
|
+
Object.keys(this.deps).forEach((depKey) => {
|
|
5947
|
+
delete this.deps[depKey];
|
|
5948
|
+
});
|
|
5949
|
+
this.emit("change");
|
|
5950
|
+
return;
|
|
5951
|
+
}
|
|
5952
|
+
const dep = this.deps[node.id];
|
|
5953
|
+
if (!dep)
|
|
5954
|
+
return;
|
|
5955
|
+
if (key) {
|
|
5956
|
+
const index = dep.keys.indexOf(key);
|
|
5957
|
+
dep.keys.splice(index, 1);
|
|
5958
|
+
if (dep.keys.length === 0) {
|
|
5959
|
+
delete this.deps[node.id];
|
|
5772
5960
|
}
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5961
|
+
} else {
|
|
5962
|
+
delete this.deps[node.id];
|
|
5963
|
+
}
|
|
5964
|
+
this.emit("change");
|
|
5965
|
+
}
|
|
5966
|
+
hasDep(node, key) {
|
|
5967
|
+
const dep = this.deps[node.id];
|
|
5968
|
+
return Boolean(dep?.keys.find((d) => d === key));
|
|
5969
|
+
}
|
|
5970
|
+
destroy() {
|
|
5971
|
+
this.removeAllListeners();
|
|
5972
|
+
}
|
|
5973
|
+
}
|
|
5974
|
+
class Watcher extends EventEmitter {
|
|
5975
|
+
targets = reactive({});
|
|
5976
|
+
getTargets(type = "default") {
|
|
5977
|
+
return this.targets[type] || {};
|
|
5978
|
+
}
|
|
5979
|
+
addTarget(target) {
|
|
5980
|
+
const targets = this.getTargets(target.type) || {};
|
|
5981
|
+
this.targets[target.type] = targets;
|
|
5982
|
+
targets[target.id] = target;
|
|
5983
|
+
this.emit("add-target", target);
|
|
5984
|
+
}
|
|
5985
|
+
getTarget(id) {
|
|
5986
|
+
const allTargets = Object.values(this.targets);
|
|
5987
|
+
for (const targets of allTargets) {
|
|
5988
|
+
if (targets[id]) {
|
|
5989
|
+
return targets[id];
|
|
5778
5990
|
}
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5991
|
+
}
|
|
5992
|
+
}
|
|
5993
|
+
hasTarget(id) {
|
|
5994
|
+
const allTargets = Object.values(this.targets);
|
|
5995
|
+
for (const targets of allTargets) {
|
|
5996
|
+
if (targets[id]) {
|
|
5997
|
+
return true;
|
|
5785
5998
|
}
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5999
|
+
}
|
|
6000
|
+
return false;
|
|
6001
|
+
}
|
|
6002
|
+
removeTarget(id) {
|
|
6003
|
+
const allTargets = Object.values(this.targets);
|
|
6004
|
+
for (const targets of allTargets) {
|
|
6005
|
+
if (targets[id]) {
|
|
6006
|
+
targets[id].destroy();
|
|
6007
|
+
delete targets[id];
|
|
5790
6008
|
}
|
|
6009
|
+
}
|
|
6010
|
+
this.emit("remove-target");
|
|
6011
|
+
}
|
|
6012
|
+
removeTargets(type = "default") {
|
|
6013
|
+
const targets = this.targets[type];
|
|
6014
|
+
if (!targets)
|
|
6015
|
+
return;
|
|
6016
|
+
for (const target of Object.values(targets)) {
|
|
6017
|
+
target.destroy();
|
|
6018
|
+
}
|
|
6019
|
+
delete this.targets[type];
|
|
6020
|
+
this.emit("remove-target");
|
|
6021
|
+
}
|
|
6022
|
+
clearTargets() {
|
|
6023
|
+
Object.keys(this.targets).forEach((key) => {
|
|
6024
|
+
delete this.targets[key];
|
|
6025
|
+
});
|
|
6026
|
+
}
|
|
6027
|
+
collect(nodes, deep = false) {
|
|
6028
|
+
Object.values(this.targets).forEach((targets) => {
|
|
6029
|
+
Object.values(targets).forEach((target) => {
|
|
6030
|
+
nodes.forEach((node) => {
|
|
6031
|
+
target.removeDep(node);
|
|
6032
|
+
this.collectItem(node, target, deep);
|
|
6033
|
+
});
|
|
6034
|
+
});
|
|
5791
6035
|
});
|
|
5792
6036
|
}
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
6037
|
+
clear(nodes) {
|
|
6038
|
+
Object.values(this.targets).forEach((targets) => {
|
|
6039
|
+
Object.values(targets).forEach((target) => {
|
|
6040
|
+
if (nodes) {
|
|
6041
|
+
nodes.forEach((node) => {
|
|
6042
|
+
target.removeDep(node);
|
|
6043
|
+
if (Array.isArray(node.items)) {
|
|
6044
|
+
this.clear(node.items);
|
|
6045
|
+
}
|
|
6046
|
+
});
|
|
6047
|
+
} else {
|
|
6048
|
+
target.removeDep();
|
|
6049
|
+
}
|
|
5800
6050
|
});
|
|
5801
|
-
}
|
|
5802
|
-
|
|
6051
|
+
});
|
|
6052
|
+
}
|
|
6053
|
+
collectItem(node, target, deep = false) {
|
|
6054
|
+
const collectTarget = (config, prop = "") => {
|
|
6055
|
+
const doCollect = (key, value) => {
|
|
6056
|
+
const keyIsItems = key === "items";
|
|
6057
|
+
const fullKey = prop ? `${prop}.${key}` : key;
|
|
6058
|
+
if (target.isTarget(key, value)) {
|
|
6059
|
+
target.updateDep(node, fullKey);
|
|
6060
|
+
} else if (!keyIsItems && Array.isArray(value)) {
|
|
6061
|
+
value.forEach((item, index) => {
|
|
6062
|
+
collectTarget(item, `${fullKey}.${index}`);
|
|
6063
|
+
});
|
|
6064
|
+
} else if (Object.prototype.toString.call(value) === "[object Object]") {
|
|
6065
|
+
collectTarget(value, fullKey);
|
|
6066
|
+
}
|
|
6067
|
+
if (keyIsItems && deep && Array.isArray(value)) {
|
|
6068
|
+
value.forEach((child) => {
|
|
6069
|
+
this.collectItem(child, target, deep);
|
|
6070
|
+
});
|
|
6071
|
+
}
|
|
6072
|
+
};
|
|
6073
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
6074
|
+
doCollect(key, value);
|
|
6075
|
+
});
|
|
6076
|
+
};
|
|
6077
|
+
collectTarget(node);
|
|
5803
6078
|
}
|
|
5804
6079
|
}
|
|
5805
|
-
const
|
|
6080
|
+
const depService = new Watcher();
|
|
5806
6081
|
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
});
|
|
6082
|
+
let eventMap = reactive({});
|
|
6083
|
+
let methodMap = reactive({});
|
|
6084
|
+
class Events extends BaseService {
|
|
5811
6085
|
constructor() {
|
|
5812
6086
|
super([]);
|
|
5813
6087
|
}
|
|
5814
|
-
|
|
5815
|
-
|
|
6088
|
+
init(componentGroupList) {
|
|
6089
|
+
componentGroupList.forEach((group) => {
|
|
6090
|
+
group.items.forEach((element) => {
|
|
6091
|
+
const type = toLine(element.type);
|
|
6092
|
+
if (!this.getEvent(type)) {
|
|
6093
|
+
this.setEvent(type, DEFAULT_EVENTS);
|
|
6094
|
+
}
|
|
6095
|
+
if (!this.getMethod(type)) {
|
|
6096
|
+
this.setMethod(type, DEFAULT_METHODS);
|
|
6097
|
+
}
|
|
6098
|
+
});
|
|
6099
|
+
});
|
|
5816
6100
|
}
|
|
5817
|
-
|
|
5818
|
-
|
|
6101
|
+
setEvents(events) {
|
|
6102
|
+
Object.keys(events).forEach((type) => {
|
|
6103
|
+
this.setEvent(toLine(type), events[type] || []);
|
|
6104
|
+
});
|
|
6105
|
+
}
|
|
6106
|
+
setEvent(type, events) {
|
|
6107
|
+
eventMap[type] = [...DEFAULT_EVENTS, ...events];
|
|
6108
|
+
}
|
|
6109
|
+
getEvent(type) {
|
|
6110
|
+
return cloneDeep(eventMap[type] || DEFAULT_EVENTS);
|
|
6111
|
+
}
|
|
6112
|
+
setMethods(methods) {
|
|
6113
|
+
Object.keys(methods).forEach((type) => {
|
|
6114
|
+
this.setMethod(toLine(type), methods[type] || []);
|
|
6115
|
+
});
|
|
6116
|
+
}
|
|
6117
|
+
setMethod(type, method) {
|
|
6118
|
+
methodMap[type] = [...DEFAULT_METHODS, ...method];
|
|
6119
|
+
}
|
|
6120
|
+
getMethod(type) {
|
|
6121
|
+
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
5819
6122
|
}
|
|
5820
6123
|
resetState() {
|
|
5821
|
-
|
|
6124
|
+
eventMap = reactive({});
|
|
6125
|
+
methodMap = reactive({});
|
|
5822
6126
|
}
|
|
5823
6127
|
destroy() {
|
|
5824
6128
|
this.resetState();
|
|
@@ -5826,7 +6130,252 @@ class ComponentList extends BaseService {
|
|
|
5826
6130
|
this.removeAllPlugins();
|
|
5827
6131
|
}
|
|
5828
6132
|
}
|
|
5829
|
-
const
|
|
6133
|
+
const eventsService = new Events();
|
|
6134
|
+
|
|
6135
|
+
const editorProps = {
|
|
6136
|
+
modelValue: {
|
|
6137
|
+
type: Object,
|
|
6138
|
+
default: () => ({}),
|
|
6139
|
+
require: true
|
|
6140
|
+
},
|
|
6141
|
+
componentGroupList: {
|
|
6142
|
+
type: Array,
|
|
6143
|
+
default: () => []
|
|
6144
|
+
},
|
|
6145
|
+
sidebar: {
|
|
6146
|
+
type: Object
|
|
6147
|
+
},
|
|
6148
|
+
menu: {
|
|
6149
|
+
type: Object,
|
|
6150
|
+
default: () => ({ left: [], right: [] })
|
|
6151
|
+
},
|
|
6152
|
+
layerContentMenu: {
|
|
6153
|
+
type: Array,
|
|
6154
|
+
default: () => []
|
|
6155
|
+
},
|
|
6156
|
+
stageContentMenu: {
|
|
6157
|
+
type: Array,
|
|
6158
|
+
default: () => []
|
|
6159
|
+
},
|
|
6160
|
+
render: {
|
|
6161
|
+
type: Function
|
|
6162
|
+
},
|
|
6163
|
+
runtimeUrl: String,
|
|
6164
|
+
autoScrollIntoView: Boolean,
|
|
6165
|
+
propsConfigs: {
|
|
6166
|
+
type: Object,
|
|
6167
|
+
default: () => ({})
|
|
6168
|
+
},
|
|
6169
|
+
propsValues: {
|
|
6170
|
+
type: Object,
|
|
6171
|
+
default: () => ({})
|
|
6172
|
+
},
|
|
6173
|
+
eventMethodList: {
|
|
6174
|
+
type: Object,
|
|
6175
|
+
default: () => ({})
|
|
6176
|
+
},
|
|
6177
|
+
moveableOptions: {
|
|
6178
|
+
type: [Object, Function]
|
|
6179
|
+
},
|
|
6180
|
+
defaultSelected: {
|
|
6181
|
+
type: [Number, String]
|
|
6182
|
+
},
|
|
6183
|
+
canSelect: {
|
|
6184
|
+
type: Function,
|
|
6185
|
+
default: (el) => Boolean(el.id)
|
|
6186
|
+
},
|
|
6187
|
+
isContainer: {
|
|
6188
|
+
type: Function,
|
|
6189
|
+
default: (el) => el.classList.contains("magic-ui-container")
|
|
6190
|
+
},
|
|
6191
|
+
containerHighlightClassName: {
|
|
6192
|
+
type: String,
|
|
6193
|
+
default: CONTAINER_HIGHLIGHT_CLASS_NAME
|
|
6194
|
+
},
|
|
6195
|
+
containerHighlightDuration: {
|
|
6196
|
+
type: Number,
|
|
6197
|
+
default: 800
|
|
6198
|
+
},
|
|
6199
|
+
containerHighlightType: {
|
|
6200
|
+
type: String,
|
|
6201
|
+
default: ContainerHighlightType.DEFAULT
|
|
6202
|
+
},
|
|
6203
|
+
stageRect: {
|
|
6204
|
+
type: [String, Object]
|
|
6205
|
+
},
|
|
6206
|
+
codeOptions: {
|
|
6207
|
+
type: Object,
|
|
6208
|
+
default: () => ({})
|
|
6209
|
+
},
|
|
6210
|
+
updateDragEl: {
|
|
6211
|
+
type: Function
|
|
6212
|
+
},
|
|
6213
|
+
disabledDragStart: {
|
|
6214
|
+
type: Boolean
|
|
6215
|
+
}
|
|
6216
|
+
};
|
|
6217
|
+
|
|
6218
|
+
const createCodeBlockTarget = (id, codeBlock) => new Target({
|
|
6219
|
+
type: "code-block",
|
|
6220
|
+
id,
|
|
6221
|
+
name: codeBlock.name,
|
|
6222
|
+
isTarget: (key, value) => {
|
|
6223
|
+
if (value?.hookType === HookType.CODE && !isEmpty(value.hookData)) {
|
|
6224
|
+
const index = value.hookData.findIndex((item) => item.codeId === id);
|
|
6225
|
+
return Boolean(index > -1);
|
|
6226
|
+
}
|
|
6227
|
+
return false;
|
|
6228
|
+
}
|
|
6229
|
+
});
|
|
6230
|
+
|
|
6231
|
+
const initServiceState = (props, {
|
|
6232
|
+
editorService,
|
|
6233
|
+
historyService,
|
|
6234
|
+
componentListService,
|
|
6235
|
+
propsService,
|
|
6236
|
+
eventsService,
|
|
6237
|
+
uiService,
|
|
6238
|
+
codeBlockService
|
|
6239
|
+
}) => {
|
|
6240
|
+
watch(
|
|
6241
|
+
() => props.modelValue,
|
|
6242
|
+
(modelValue) => {
|
|
6243
|
+
editorService.set("root", modelValue);
|
|
6244
|
+
},
|
|
6245
|
+
{
|
|
6246
|
+
immediate: true
|
|
6247
|
+
}
|
|
6248
|
+
);
|
|
6249
|
+
watch(
|
|
6250
|
+
() => props.componentGroupList,
|
|
6251
|
+
(componentGroupList) => componentListService.setList(componentGroupList),
|
|
6252
|
+
{
|
|
6253
|
+
immediate: true
|
|
6254
|
+
}
|
|
6255
|
+
);
|
|
6256
|
+
watch(
|
|
6257
|
+
() => props.propsConfigs,
|
|
6258
|
+
(configs) => propsService.setPropsConfigs(configs),
|
|
6259
|
+
{
|
|
6260
|
+
immediate: true
|
|
6261
|
+
}
|
|
6262
|
+
);
|
|
6263
|
+
watch(
|
|
6264
|
+
() => props.propsValues,
|
|
6265
|
+
(values) => propsService.setPropsValues(values),
|
|
6266
|
+
{
|
|
6267
|
+
immediate: true
|
|
6268
|
+
}
|
|
6269
|
+
);
|
|
6270
|
+
watch(
|
|
6271
|
+
() => props.eventMethodList,
|
|
6272
|
+
(eventMethodList) => {
|
|
6273
|
+
const eventsList = {};
|
|
6274
|
+
const methodsList = {};
|
|
6275
|
+
Object.keys(eventMethodList).forEach((type) => {
|
|
6276
|
+
eventsList[type] = eventMethodList[type].events;
|
|
6277
|
+
methodsList[type] = eventMethodList[type].methods;
|
|
6278
|
+
});
|
|
6279
|
+
eventsService.setEvents(eventsList);
|
|
6280
|
+
eventsService.setMethods(methodsList);
|
|
6281
|
+
},
|
|
6282
|
+
{
|
|
6283
|
+
immediate: true
|
|
6284
|
+
}
|
|
6285
|
+
);
|
|
6286
|
+
watch(
|
|
6287
|
+
() => props.defaultSelected,
|
|
6288
|
+
(defaultSelected) => defaultSelected && editorService.select(defaultSelected),
|
|
6289
|
+
{
|
|
6290
|
+
immediate: true
|
|
6291
|
+
}
|
|
6292
|
+
);
|
|
6293
|
+
watch(
|
|
6294
|
+
() => props.stageRect,
|
|
6295
|
+
(stageRect) => stageRect && uiService.set("stageRect", stageRect),
|
|
6296
|
+
{
|
|
6297
|
+
immediate: true
|
|
6298
|
+
}
|
|
6299
|
+
);
|
|
6300
|
+
onUnmounted(() => {
|
|
6301
|
+
editorService.resetState();
|
|
6302
|
+
historyService.resetState();
|
|
6303
|
+
propsService.resetState();
|
|
6304
|
+
uiService.resetState();
|
|
6305
|
+
componentListService.resetState();
|
|
6306
|
+
codeBlockService.resetState();
|
|
6307
|
+
});
|
|
6308
|
+
};
|
|
6309
|
+
const initServiceEvents = (props, emit, { editorService, codeBlockService, depService }) => {
|
|
6310
|
+
const rootChangeHandler = async (value, preValue) => {
|
|
6311
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
6312
|
+
let node;
|
|
6313
|
+
if (nodeId) {
|
|
6314
|
+
node = editorService.getNodeById(nodeId);
|
|
6315
|
+
}
|
|
6316
|
+
if (node && node !== value) {
|
|
6317
|
+
await editorService.select(node.id);
|
|
6318
|
+
} else if (value?.items?.length) {
|
|
6319
|
+
await editorService.select(value.items[0]);
|
|
6320
|
+
} else if (value?.id) {
|
|
6321
|
+
editorService.set("nodes", [value]);
|
|
6322
|
+
editorService.set("parent", null);
|
|
6323
|
+
editorService.set("page", null);
|
|
6324
|
+
}
|
|
6325
|
+
if (toRaw(value) !== toRaw(preValue)) {
|
|
6326
|
+
emit("update:modelValue", value);
|
|
6327
|
+
}
|
|
6328
|
+
value.codeBlocks = value.codeBlocks || {};
|
|
6329
|
+
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
6330
|
+
depService.removeTargets("code-block");
|
|
6331
|
+
Object.entries(value.codeBlocks).forEach(([id, code]) => {
|
|
6332
|
+
depService.addTarget(createCodeBlockTarget(id, code));
|
|
6333
|
+
});
|
|
6334
|
+
if (value && Array.isArray(value.items)) {
|
|
6335
|
+
depService.collect(value.items, true);
|
|
6336
|
+
} else {
|
|
6337
|
+
depService.clear();
|
|
6338
|
+
}
|
|
6339
|
+
};
|
|
6340
|
+
const nodeAddHandler = (nodes) => {
|
|
6341
|
+
depService.collect(nodes);
|
|
6342
|
+
};
|
|
6343
|
+
const nodeUpdateHandler = (nodes) => {
|
|
6344
|
+
depService.collect(nodes);
|
|
6345
|
+
};
|
|
6346
|
+
const nodeRemoveHandler = (nodes) => {
|
|
6347
|
+
depService.clear(nodes);
|
|
6348
|
+
};
|
|
6349
|
+
const historyChangeHandler = (page) => {
|
|
6350
|
+
depService.collect([page], true);
|
|
6351
|
+
};
|
|
6352
|
+
editorService.on("history-change", historyChangeHandler);
|
|
6353
|
+
editorService.on("root-change", rootChangeHandler);
|
|
6354
|
+
editorService.on("add", nodeAddHandler);
|
|
6355
|
+
editorService.on("remove", nodeRemoveHandler);
|
|
6356
|
+
editorService.on("update", nodeUpdateHandler);
|
|
6357
|
+
const codeBlockAddOrUpdateHandler = (id, codeBlock) => {
|
|
6358
|
+
if (depService.hasTarget(id)) {
|
|
6359
|
+
depService.getTarget(id).name = codeBlock.name;
|
|
6360
|
+
return;
|
|
6361
|
+
}
|
|
6362
|
+
depService.addTarget(createCodeBlockTarget(id, codeBlock));
|
|
6363
|
+
};
|
|
6364
|
+
const codeBlockRemoveHandler = (id) => {
|
|
6365
|
+
depService.removeTarget(id);
|
|
6366
|
+
};
|
|
6367
|
+
codeBlockService.on("addOrUpdate", codeBlockAddOrUpdateHandler);
|
|
6368
|
+
codeBlockService.on("remove", codeBlockRemoveHandler);
|
|
6369
|
+
onUnmounted(() => {
|
|
6370
|
+
editorService.off("history-change", historyChangeHandler);
|
|
6371
|
+
editorService.off("root-change", rootChangeHandler);
|
|
6372
|
+
editorService.off("add", nodeAddHandler);
|
|
6373
|
+
editorService.off("remove", nodeRemoveHandler);
|
|
6374
|
+
editorService.off("update", nodeUpdateHandler);
|
|
6375
|
+
codeBlockService.off("addOrUpdate", codeBlockAddOrUpdateHandler);
|
|
6376
|
+
codeBlockService.off("remove", codeBlockRemoveHandler);
|
|
6377
|
+
});
|
|
6378
|
+
};
|
|
5830
6379
|
|
|
5831
6380
|
const _sfc_main = defineComponent({
|
|
5832
6381
|
name: "m-editor",
|
|
@@ -5837,181 +6386,9 @@ const _sfc_main = defineComponent({
|
|
|
5837
6386
|
PropsPanel: _sfc_main$i,
|
|
5838
6387
|
Framework: _sfc_main$l
|
|
5839
6388
|
},
|
|
5840
|
-
props:
|
|
5841
|
-
modelValue: {
|
|
5842
|
-
type: Object,
|
|
5843
|
-
default: () => ({}),
|
|
5844
|
-
require: true
|
|
5845
|
-
},
|
|
5846
|
-
componentGroupList: {
|
|
5847
|
-
type: Array,
|
|
5848
|
-
default: () => []
|
|
5849
|
-
},
|
|
5850
|
-
sidebar: {
|
|
5851
|
-
type: Object
|
|
5852
|
-
},
|
|
5853
|
-
menu: {
|
|
5854
|
-
type: Object,
|
|
5855
|
-
default: () => ({ left: [], right: [] })
|
|
5856
|
-
},
|
|
5857
|
-
layerContentMenu: {
|
|
5858
|
-
type: Array,
|
|
5859
|
-
default: () => []
|
|
5860
|
-
},
|
|
5861
|
-
stageContentMenu: {
|
|
5862
|
-
type: Array,
|
|
5863
|
-
default: () => []
|
|
5864
|
-
},
|
|
5865
|
-
render: {
|
|
5866
|
-
type: Function
|
|
5867
|
-
},
|
|
5868
|
-
runtimeUrl: String,
|
|
5869
|
-
autoScrollIntoView: Boolean,
|
|
5870
|
-
propsConfigs: {
|
|
5871
|
-
type: Object,
|
|
5872
|
-
default: () => ({})
|
|
5873
|
-
},
|
|
5874
|
-
propsValues: {
|
|
5875
|
-
type: Object,
|
|
5876
|
-
default: () => ({})
|
|
5877
|
-
},
|
|
5878
|
-
eventMethodList: {
|
|
5879
|
-
type: Object,
|
|
5880
|
-
default: () => ({})
|
|
5881
|
-
},
|
|
5882
|
-
moveableOptions: {
|
|
5883
|
-
type: [Object, Function]
|
|
5884
|
-
},
|
|
5885
|
-
defaultSelected: {
|
|
5886
|
-
type: [Number, String]
|
|
5887
|
-
},
|
|
5888
|
-
canSelect: {
|
|
5889
|
-
type: Function,
|
|
5890
|
-
default: (el) => Boolean(el.id)
|
|
5891
|
-
},
|
|
5892
|
-
isContainer: {
|
|
5893
|
-
type: Function,
|
|
5894
|
-
default: (el) => el.classList.contains("magic-ui-container")
|
|
5895
|
-
},
|
|
5896
|
-
containerHighlightClassName: {
|
|
5897
|
-
type: String,
|
|
5898
|
-
default: CONTAINER_HIGHLIGHT_CLASS_NAME
|
|
5899
|
-
},
|
|
5900
|
-
containerHighlightDuration: {
|
|
5901
|
-
type: Number,
|
|
5902
|
-
default: 800
|
|
5903
|
-
},
|
|
5904
|
-
containerHighlightType: {
|
|
5905
|
-
type: String,
|
|
5906
|
-
default: ContainerHighlightType.DEFAULT
|
|
5907
|
-
},
|
|
5908
|
-
stageRect: {
|
|
5909
|
-
type: [String, Object]
|
|
5910
|
-
},
|
|
5911
|
-
codeOptions: {
|
|
5912
|
-
type: Object,
|
|
5913
|
-
default: () => ({})
|
|
5914
|
-
},
|
|
5915
|
-
updateDragEl: {
|
|
5916
|
-
type: Function
|
|
5917
|
-
},
|
|
5918
|
-
disabledDragStart: {
|
|
5919
|
-
type: Boolean
|
|
5920
|
-
}
|
|
5921
|
-
},
|
|
6389
|
+
props: editorProps,
|
|
5922
6390
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
5923
6391
|
setup(props, { emit }) {
|
|
5924
|
-
const rootChangeHandler = (value, preValue) => {
|
|
5925
|
-
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
5926
|
-
let node;
|
|
5927
|
-
if (nodeId) {
|
|
5928
|
-
node = editorService.getNodeById(nodeId);
|
|
5929
|
-
}
|
|
5930
|
-
if (node && node !== value) {
|
|
5931
|
-
editorService.select(node.id);
|
|
5932
|
-
} else if (value?.items?.length) {
|
|
5933
|
-
editorService.select(value.items[0]);
|
|
5934
|
-
} else if (value?.id) {
|
|
5935
|
-
editorService.set("nodes", [value]);
|
|
5936
|
-
editorService.set("parent", null);
|
|
5937
|
-
editorService.set("page", null);
|
|
5938
|
-
}
|
|
5939
|
-
if (toRaw(value) !== toRaw(preValue)) {
|
|
5940
|
-
emit("update:modelValue", value);
|
|
5941
|
-
}
|
|
5942
|
-
value.codeBlocks = value.codeBlocks || {};
|
|
5943
|
-
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
5944
|
-
};
|
|
5945
|
-
editorService.on("root-change", rootChangeHandler);
|
|
5946
|
-
watch(
|
|
5947
|
-
() => props.modelValue,
|
|
5948
|
-
(modelValue) => {
|
|
5949
|
-
editorService.set("root", modelValue);
|
|
5950
|
-
},
|
|
5951
|
-
{
|
|
5952
|
-
immediate: true
|
|
5953
|
-
}
|
|
5954
|
-
);
|
|
5955
|
-
watch(
|
|
5956
|
-
() => props.componentGroupList,
|
|
5957
|
-
(componentGroupList) => componentListService.setList(componentGroupList),
|
|
5958
|
-
{
|
|
5959
|
-
immediate: true
|
|
5960
|
-
}
|
|
5961
|
-
);
|
|
5962
|
-
watch(
|
|
5963
|
-
() => props.propsConfigs,
|
|
5964
|
-
(configs) => propsService.setPropsConfigs(configs),
|
|
5965
|
-
{
|
|
5966
|
-
immediate: true
|
|
5967
|
-
}
|
|
5968
|
-
);
|
|
5969
|
-
watch(
|
|
5970
|
-
() => props.propsValues,
|
|
5971
|
-
(values) => propsService.setPropsValues(values),
|
|
5972
|
-
{
|
|
5973
|
-
immediate: true
|
|
5974
|
-
}
|
|
5975
|
-
);
|
|
5976
|
-
watch(
|
|
5977
|
-
() => props.eventMethodList,
|
|
5978
|
-
(eventMethodList) => {
|
|
5979
|
-
const eventsList = {};
|
|
5980
|
-
const methodsList = {};
|
|
5981
|
-
Object.keys(eventMethodList).forEach((type) => {
|
|
5982
|
-
eventsList[type] = eventMethodList[type].events;
|
|
5983
|
-
methodsList[type] = eventMethodList[type].methods;
|
|
5984
|
-
});
|
|
5985
|
-
eventsService.setEvents(eventsList);
|
|
5986
|
-
eventsService.setMethods(methodsList);
|
|
5987
|
-
},
|
|
5988
|
-
{
|
|
5989
|
-
immediate: true
|
|
5990
|
-
}
|
|
5991
|
-
);
|
|
5992
|
-
watch(
|
|
5993
|
-
() => props.defaultSelected,
|
|
5994
|
-
(defaultSelected) => defaultSelected && editorService.select(defaultSelected),
|
|
5995
|
-
{
|
|
5996
|
-
immediate: true
|
|
5997
|
-
}
|
|
5998
|
-
);
|
|
5999
|
-
watch(
|
|
6000
|
-
() => props.stageRect,
|
|
6001
|
-
(stageRect) => stageRect && uiService.set("stageRect", stageRect),
|
|
6002
|
-
{
|
|
6003
|
-
immediate: true
|
|
6004
|
-
}
|
|
6005
|
-
);
|
|
6006
|
-
onUnmounted(() => {
|
|
6007
|
-
editorService.resetState();
|
|
6008
|
-
historyService.resetState();
|
|
6009
|
-
propsService.resetState();
|
|
6010
|
-
uiService.resetState();
|
|
6011
|
-
componentListService.resetState();
|
|
6012
|
-
codeBlockService.resetState();
|
|
6013
|
-
editorService.off("root-change", rootChangeHandler);
|
|
6014
|
-
});
|
|
6015
6392
|
const services = {
|
|
6016
6393
|
componentListService,
|
|
6017
6394
|
eventsService,
|
|
@@ -6020,8 +6397,11 @@ const _sfc_main = defineComponent({
|
|
|
6020
6397
|
editorService,
|
|
6021
6398
|
uiService,
|
|
6022
6399
|
storageService,
|
|
6023
|
-
codeBlockService
|
|
6400
|
+
codeBlockService,
|
|
6401
|
+
depService
|
|
6024
6402
|
};
|
|
6403
|
+
initServiceEvents(props, emit, services);
|
|
6404
|
+
initServiceState(props, services);
|
|
6025
6405
|
provide("services", services);
|
|
6026
6406
|
provide("codeOptions", props.codeOptions);
|
|
6027
6407
|
provide(
|
|
@@ -6040,7 +6420,6 @@ const _sfc_main = defineComponent({
|
|
|
6040
6420
|
disabledDragStart: props.disabledDragStart
|
|
6041
6421
|
})
|
|
6042
6422
|
);
|
|
6043
|
-
codeBlockService.addCodeRelationListener();
|
|
6044
6423
|
return services;
|
|
6045
6424
|
}
|
|
6046
6425
|
});
|
|
@@ -6151,12 +6530,14 @@ const index = {
|
|
|
6151
6530
|
setConfig(option);
|
|
6152
6531
|
app.component(Editor.name, Editor);
|
|
6153
6532
|
app.component("m-fields-ui-select", _sfc_main$q);
|
|
6154
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
6155
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
6533
|
+
app.component("m-fields-code-link", _sfc_main$v);
|
|
6534
|
+
app.component("m-fields-vs-code", _sfc_main$w);
|
|
6156
6535
|
app.component("magic-code-editor", _sfc_main$p);
|
|
6157
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
6536
|
+
app.component("m-fields-code-select", _sfc_main$t);
|
|
6537
|
+
app.component("m-fields-code-select-col", _sfc_main$s);
|
|
6538
|
+
app.component("m-fields-event-select", _sfc_main$r);
|
|
6158
6539
|
}
|
|
6159
6540
|
};
|
|
6160
6541
|
|
|
6161
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, _sfc_main$
|
|
6542
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$e as CodeBlockList, CodeDeleteErrorType, _sfc_main$t as CodeSelect, _sfc_main$s as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$r as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$u as Icon, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$n as LayoutContainer, _sfc_main$i as PropsPanel, _sfc_main$p as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$k as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, debug, index as default, depService, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
|
|
6162
6543
|
//# sourceMappingURL=tmagic-editor.js.map
|