@tmagic/editor 1.2.10 → 1.2.11
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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons-vue'), require('lodash-es'), require('@tmagic/form'), require('@tmagic/schema'), require('@tmagic/design'), require('monaco-editor'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons-vue', 'lodash-es', '@tmagic/form', '@tmagic/schema', '@tmagic/design', 'monaco-editor', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.iconsVue, global.lodashEs, global.form, global.schema, global.design, global.monaco, global.
|
|
5
|
-
})(this, (function (exports, vue, serialize, iconsVue, lodashEs, form, schema, design, monaco,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons-vue'), require('lodash-es'), require('@tmagic/form'), require('@tmagic/schema'), require('@tmagic/design'), require('monaco-editor'), require('gesto'), require('@tmagic/utils'), require('@tmagic/stage'), require('events'), require('keycon'), require('@tmagic/core')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons-vue', 'lodash-es', '@tmagic/form', '@tmagic/schema', '@tmagic/design', 'monaco-editor', 'gesto', '@tmagic/utils', '@tmagic/stage', 'events', 'keycon', '@tmagic/core'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.iconsVue, global.lodashEs, global.form, global.schema, global.design, global.monaco, global.Gesto, global.utils, global.StageCore, global.events, global.KeyController, global.core));
|
|
5
|
+
})(this, (function (exports, vue, serialize, iconsVue, lodashEs, form, schema, design, monaco, Gesto, utils, StageCore, events, KeyController, core) { 'use strict';
|
|
6
6
|
|
|
7
7
|
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
|
8
8
|
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
|
|
27
27
|
const serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
|
|
28
28
|
const monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
|
|
29
|
-
const StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
|
|
30
29
|
const Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
|
|
30
|
+
const StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
|
|
31
31
|
const KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
|
|
32
32
|
|
|
33
|
-
const __default__$
|
|
33
|
+
const __default__$v = vue.defineComponent({
|
|
34
34
|
name: "MEditorCode"
|
|
35
35
|
});
|
|
36
|
-
const _sfc_main$
|
|
37
|
-
...__default__$
|
|
36
|
+
const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
|
|
37
|
+
...__default__$v,
|
|
38
38
|
props: {
|
|
39
39
|
model: null,
|
|
40
40
|
name: null,
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
const __default__$
|
|
66
|
+
const __default__$u = vue.defineComponent({
|
|
67
67
|
name: "MEditorCodeLink"
|
|
68
68
|
});
|
|
69
|
-
const _sfc_main$
|
|
70
|
-
...__default__$
|
|
69
|
+
const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
|
|
70
|
+
...__default__$u,
|
|
71
71
|
props: {
|
|
72
72
|
config: null,
|
|
73
73
|
model: null,
|
|
@@ -136,12 +136,12 @@
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
const _hoisted_1$
|
|
140
|
-
const __default__$
|
|
139
|
+
const _hoisted_1$h = ["src"];
|
|
140
|
+
const __default__$t = vue.defineComponent({
|
|
141
141
|
name: "MEditorIcon"
|
|
142
142
|
});
|
|
143
|
-
const _sfc_main$
|
|
144
|
-
...__default__$
|
|
143
|
+
const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
|
|
144
|
+
...__default__$t,
|
|
145
145
|
props: {
|
|
146
146
|
icon: null
|
|
147
147
|
},
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
class: "magic-editor-icon"
|
|
161
161
|
}, {
|
|
162
162
|
default: vue.withCtx(() => [
|
|
163
|
-
vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$
|
|
163
|
+
vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$h)
|
|
164
164
|
]),
|
|
165
165
|
_: 1
|
|
166
166
|
})) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
|
|
@@ -179,14 +179,15 @@
|
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
const
|
|
183
|
-
const __default__$q = vue.defineComponent({
|
|
182
|
+
const __default__$s = vue.defineComponent({
|
|
184
183
|
name: "MEditorCodeSelect"
|
|
185
184
|
});
|
|
186
|
-
const _sfc_main$
|
|
187
|
-
...__default__$
|
|
185
|
+
const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
|
|
186
|
+
...__default__$s,
|
|
188
187
|
props: {
|
|
189
|
-
config:
|
|
188
|
+
config: { default: () => ({
|
|
189
|
+
editable: true
|
|
190
|
+
}) },
|
|
190
191
|
model: null,
|
|
191
192
|
prop: null,
|
|
192
193
|
name: null,
|
|
@@ -230,7 +231,7 @@
|
|
|
230
231
|
defaultValue: {},
|
|
231
232
|
itemsFunction: (row) => {
|
|
232
233
|
const paramsConfig = getParamsConfig(row.codeId);
|
|
233
|
-
if (
|
|
234
|
+
if (!row.params || lodashEs.isEmpty(row.params)) {
|
|
234
235
|
form.createValues(mForm, paramsConfig, {}, row.params);
|
|
235
236
|
}
|
|
236
237
|
return paramsConfig;
|
|
@@ -270,6 +271,7 @@
|
|
|
270
271
|
return paramStatements.map((paramState) => ({
|
|
271
272
|
labelWidth: "100px",
|
|
272
273
|
text: paramState.name,
|
|
274
|
+
inline: true,
|
|
273
275
|
...paramState
|
|
274
276
|
}));
|
|
275
277
|
};
|
|
@@ -278,7 +280,9 @@
|
|
|
278
280
|
};
|
|
279
281
|
return (_ctx, _cache) => {
|
|
280
282
|
const _component_m_form_table = vue.resolveComponent("m-form-table");
|
|
281
|
-
return vue.openBlock(), vue.createElementBlock("div",
|
|
283
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
284
|
+
class: vue.normalizeClass(["m-fields-code-select", __props.config.className])
|
|
285
|
+
}, [
|
|
282
286
|
vue.createVNode(_component_m_form_table, {
|
|
283
287
|
config: vue.unref(tableConfig),
|
|
284
288
|
model: __props.model[__props.name],
|
|
@@ -289,7 +293,7 @@
|
|
|
289
293
|
onChange: changeHandler
|
|
290
294
|
}, {
|
|
291
295
|
operateCol: vue.withCtx(({ scope }) => [
|
|
292
|
-
scope.row.codeId ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
296
|
+
scope.row.codeId && __props.config.editable ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
|
|
293
297
|
key: 0,
|
|
294
298
|
icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
|
|
295
299
|
class: "edit-icon",
|
|
@@ -298,6 +302,326 @@
|
|
|
298
302
|
]),
|
|
299
303
|
_: 1
|
|
300
304
|
}, 8, ["config", "model", "prop", "size"])
|
|
305
|
+
], 2);
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const _hoisted_1$g = { class: "m-fields-code-select-col" };
|
|
311
|
+
const __default__$r = vue.defineComponent({
|
|
312
|
+
name: "MEditorCodeSelectCol"
|
|
313
|
+
});
|
|
314
|
+
const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
|
|
315
|
+
...__default__$r,
|
|
316
|
+
props: {
|
|
317
|
+
config: null,
|
|
318
|
+
model: null,
|
|
319
|
+
prop: null,
|
|
320
|
+
name: null,
|
|
321
|
+
size: null
|
|
322
|
+
},
|
|
323
|
+
emits: ["change"],
|
|
324
|
+
setup(__props, { emit }) {
|
|
325
|
+
const props = __props;
|
|
326
|
+
const services = vue.inject("services");
|
|
327
|
+
const mForm = vue.inject("mForm");
|
|
328
|
+
const codeDsl = vue.computed(() => services?.codeBlockService.getCodeDsl());
|
|
329
|
+
const codeParamsConfig = vue.ref({
|
|
330
|
+
type: "fieldset",
|
|
331
|
+
items: [],
|
|
332
|
+
legend: "\u53C2\u6570",
|
|
333
|
+
labelWidth: "70px",
|
|
334
|
+
name: "params",
|
|
335
|
+
display: false
|
|
336
|
+
});
|
|
337
|
+
const selectConfig = {
|
|
338
|
+
type: "select",
|
|
339
|
+
text: "\u4EE3\u7801\u5757",
|
|
340
|
+
name: "codeId",
|
|
341
|
+
labelWidth: "70px",
|
|
342
|
+
options: () => {
|
|
343
|
+
if (codeDsl.value) {
|
|
344
|
+
return lodashEs.map(codeDsl.value, (value, key) => ({
|
|
345
|
+
text: `${value.name}\uFF08${key}\uFF09`,
|
|
346
|
+
label: `${value.name}\uFF08${key}\uFF09`,
|
|
347
|
+
value: key
|
|
348
|
+
}));
|
|
349
|
+
}
|
|
350
|
+
return [];
|
|
351
|
+
},
|
|
352
|
+
onChange: (formState, codeId, { model }) => {
|
|
353
|
+
model.params = {};
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
const getParamItemsConfig = (codeId) => {
|
|
357
|
+
if (!codeDsl.value)
|
|
358
|
+
return [];
|
|
359
|
+
const paramStatements = codeDsl.value[codeId]?.params;
|
|
360
|
+
if (lodashEs.isEmpty(paramStatements))
|
|
361
|
+
return [];
|
|
362
|
+
return paramStatements.map((paramState) => ({
|
|
363
|
+
labelWidth: "100px",
|
|
364
|
+
text: paramState.name,
|
|
365
|
+
...paramState
|
|
366
|
+
}));
|
|
367
|
+
};
|
|
368
|
+
const getCodeParamsConfig = (codeId) => {
|
|
369
|
+
const paramsConfig = getParamItemsConfig(codeId);
|
|
370
|
+
if (!props.model.params || lodashEs.isEmpty(props.model.params)) {
|
|
371
|
+
props.model.params = {};
|
|
372
|
+
form.createValues(mForm, paramsConfig, {}, props.model.params);
|
|
373
|
+
}
|
|
374
|
+
codeParamsConfig.value = {
|
|
375
|
+
type: "fieldset",
|
|
376
|
+
items: paramsConfig,
|
|
377
|
+
legend: "\u53C2\u6570",
|
|
378
|
+
labelWidth: "70px",
|
|
379
|
+
name: "params",
|
|
380
|
+
display: !lodashEs.isEmpty(paramsConfig)
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
const onParamsChangeHandler = () => {
|
|
384
|
+
emit("change", props.model);
|
|
385
|
+
};
|
|
386
|
+
vue.watch(
|
|
387
|
+
() => props.model.codeId,
|
|
388
|
+
(codeId) => {
|
|
389
|
+
if (!codeId)
|
|
390
|
+
return;
|
|
391
|
+
getCodeParamsConfig(codeId);
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
immediate: true
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
return (_ctx, _cache) => {
|
|
398
|
+
const _component_m_form_container = vue.resolveComponent("m-form-container");
|
|
399
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$g, [
|
|
400
|
+
vue.createVNode(_component_m_form_container, {
|
|
401
|
+
config: selectConfig,
|
|
402
|
+
model: __props.model,
|
|
403
|
+
onChange: onParamsChangeHandler
|
|
404
|
+
}, null, 8, ["model"]),
|
|
405
|
+
vue.createVNode(_component_m_form_container, {
|
|
406
|
+
config: codeParamsConfig.value,
|
|
407
|
+
model: __props.model,
|
|
408
|
+
onChange: onParamsChangeHandler
|
|
409
|
+
}, null, 8, ["config", "model"])
|
|
410
|
+
]);
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
const _hoisted_1$f = { class: "m-fields-event-select" };
|
|
416
|
+
const _hoisted_2$7 = {
|
|
417
|
+
key: 1,
|
|
418
|
+
class: "fullWidth"
|
|
419
|
+
};
|
|
420
|
+
const _hoisted_3$4 = /* @__PURE__ */ vue.createTextVNode("\u6DFB\u52A0\u4E8B\u4EF6");
|
|
421
|
+
const __default__$q = vue.defineComponent({
|
|
422
|
+
name: "MEditorEventSelect"
|
|
423
|
+
});
|
|
424
|
+
const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
|
|
425
|
+
...__default__$q,
|
|
426
|
+
props: {
|
|
427
|
+
config: null,
|
|
428
|
+
model: null,
|
|
429
|
+
prop: null,
|
|
430
|
+
name: null,
|
|
431
|
+
size: null
|
|
432
|
+
},
|
|
433
|
+
emits: ["change"],
|
|
434
|
+
setup(__props, { emit }) {
|
|
435
|
+
const props = __props;
|
|
436
|
+
const services = vue.inject("services");
|
|
437
|
+
const eventNameConfig = vue.computed(() => {
|
|
438
|
+
const defaultEventNameConfig = {
|
|
439
|
+
name: "name",
|
|
440
|
+
text: "\u4E8B\u4EF6",
|
|
441
|
+
type: "select",
|
|
442
|
+
labelWidth: "40px",
|
|
443
|
+
options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
|
|
444
|
+
text: option.label,
|
|
445
|
+
value: option.value
|
|
446
|
+
}))
|
|
447
|
+
};
|
|
448
|
+
return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
|
|
449
|
+
});
|
|
450
|
+
const actionTypeConfig = vue.computed(() => {
|
|
451
|
+
const defaultActionTypeConfig = {
|
|
452
|
+
name: "actionType",
|
|
453
|
+
text: "\u8054\u52A8\u7C7B\u578B",
|
|
454
|
+
labelWidth: "70px",
|
|
455
|
+
type: "select",
|
|
456
|
+
defaultValue: schema.ActionType.COMP,
|
|
457
|
+
options: () => [
|
|
458
|
+
{
|
|
459
|
+
text: "\u7EC4\u4EF6",
|
|
460
|
+
label: "\u7EC4\u4EF6",
|
|
461
|
+
value: schema.ActionType.COMP
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
text: "\u4EE3\u7801",
|
|
465
|
+
label: "\u4EE3\u7801",
|
|
466
|
+
value: schema.ActionType.CODE
|
|
467
|
+
}
|
|
468
|
+
]
|
|
469
|
+
};
|
|
470
|
+
return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
|
|
471
|
+
});
|
|
472
|
+
const targetCompConfig = vue.computed(() => {
|
|
473
|
+
const defaultTargetCompConfig = {
|
|
474
|
+
name: "to",
|
|
475
|
+
text: "\u8054\u52A8\u7EC4\u4EF6",
|
|
476
|
+
labelWidth: "70px",
|
|
477
|
+
type: "ui-select",
|
|
478
|
+
display: (mForm, { model }) => model.actionType === schema.ActionType.COMP
|
|
479
|
+
};
|
|
480
|
+
return { ...defaultTargetCompConfig, ...props.config.targetCompConfig };
|
|
481
|
+
});
|
|
482
|
+
const compActionConfig = vue.computed(() => {
|
|
483
|
+
const defaultCompActionConfig = {
|
|
484
|
+
name: "method",
|
|
485
|
+
text: "\u52A8\u4F5C",
|
|
486
|
+
labelWidth: "70px",
|
|
487
|
+
type: "select",
|
|
488
|
+
display: (mForm, { model }) => model.actionType === schema.ActionType.COMP,
|
|
489
|
+
options: (mForm, { model }) => {
|
|
490
|
+
const node = services?.editorService.getNodeById(model.to);
|
|
491
|
+
if (!node?.type)
|
|
492
|
+
return [];
|
|
493
|
+
return services?.eventsService.getMethod(node.type).map((option) => ({
|
|
494
|
+
text: option.label,
|
|
495
|
+
value: option.value
|
|
496
|
+
}));
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
return { ...defaultCompActionConfig, ...props.config.compActionConfig };
|
|
500
|
+
});
|
|
501
|
+
const codeActionConfig = vue.computed(() => {
|
|
502
|
+
const defaultCodeActionConfig = {
|
|
503
|
+
type: "code-select-col",
|
|
504
|
+
display: (mForm, { model }) => model.actionType === schema.ActionType.CODE
|
|
505
|
+
};
|
|
506
|
+
return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
|
|
507
|
+
});
|
|
508
|
+
const tableConfig = vue.computed(() => ({
|
|
509
|
+
type: "table",
|
|
510
|
+
name: "events",
|
|
511
|
+
items: [
|
|
512
|
+
{
|
|
513
|
+
name: "name",
|
|
514
|
+
label: "\u4E8B\u4EF6\u540D",
|
|
515
|
+
type: eventNameConfig.value.type,
|
|
516
|
+
options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
|
|
517
|
+
text: option.label,
|
|
518
|
+
value: option.value
|
|
519
|
+
}))
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
name: "to",
|
|
523
|
+
label: "\u8054\u52A8\u7EC4\u4EF6",
|
|
524
|
+
type: "ui-select"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
name: "method",
|
|
528
|
+
label: "\u52A8\u4F5C",
|
|
529
|
+
type: compActionConfig.value.type,
|
|
530
|
+
options: (mForm, { model }) => {
|
|
531
|
+
const node = services?.editorService.getNodeById(model.to);
|
|
532
|
+
if (!node?.type)
|
|
533
|
+
return [];
|
|
534
|
+
return services?.eventsService.getMethod(node.type).map((option) => ({
|
|
535
|
+
text: option.label,
|
|
536
|
+
value: option.value
|
|
537
|
+
}));
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
]
|
|
541
|
+
}));
|
|
542
|
+
const actionsConfig = vue.computed(() => ({
|
|
543
|
+
items: [
|
|
544
|
+
{
|
|
545
|
+
type: "group-list",
|
|
546
|
+
name: "actions",
|
|
547
|
+
enableToggleMode: false,
|
|
548
|
+
items: [actionTypeConfig.value, targetCompConfig.value, compActionConfig.value, codeActionConfig.value]
|
|
549
|
+
}
|
|
550
|
+
]
|
|
551
|
+
}));
|
|
552
|
+
const isOldVersion = vue.computed(() => {
|
|
553
|
+
if (props.model[props.name].length === 0)
|
|
554
|
+
return false;
|
|
555
|
+
return !lodashEs.has(props.model[props.name][0], "actions");
|
|
556
|
+
});
|
|
557
|
+
const addEvent = () => {
|
|
558
|
+
const defaultEvent = {
|
|
559
|
+
name: "",
|
|
560
|
+
actions: []
|
|
561
|
+
};
|
|
562
|
+
if (!props.model[props.name]) {
|
|
563
|
+
props.model[props.name] = [];
|
|
564
|
+
}
|
|
565
|
+
props.model[props.name].push(defaultEvent);
|
|
566
|
+
onChangeHandler();
|
|
567
|
+
};
|
|
568
|
+
const removeEvent = (index) => {
|
|
569
|
+
if (!props.name)
|
|
570
|
+
return;
|
|
571
|
+
props.model[props.name].splice(index, 1);
|
|
572
|
+
onChangeHandler();
|
|
573
|
+
};
|
|
574
|
+
const onChangeHandler = () => {
|
|
575
|
+
emit("change", props.model);
|
|
576
|
+
};
|
|
577
|
+
return (_ctx, _cache) => {
|
|
578
|
+
const _component_m_form_container = vue.resolveComponent("m-form-container");
|
|
579
|
+
const _component_m_form_panel = vue.resolveComponent("m-form-panel");
|
|
580
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$f, [
|
|
581
|
+
vue.unref(isOldVersion) ? (vue.openBlock(), vue.createBlock(_component_m_form_container, {
|
|
582
|
+
key: 0,
|
|
583
|
+
ref: "eventForm",
|
|
584
|
+
size: props.size,
|
|
585
|
+
model: __props.model,
|
|
586
|
+
config: vue.unref(tableConfig),
|
|
587
|
+
onChange: onChangeHandler
|
|
588
|
+
}, null, 8, ["size", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$7, [
|
|
589
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
590
|
+
class: "create-button",
|
|
591
|
+
type: "primary",
|
|
592
|
+
size: "small",
|
|
593
|
+
onClick: _cache[0] || (_cache[0] = ($event) => addEvent())
|
|
594
|
+
}, {
|
|
595
|
+
default: vue.withCtx(() => [
|
|
596
|
+
_hoisted_3$4
|
|
597
|
+
]),
|
|
598
|
+
_: 1
|
|
599
|
+
}),
|
|
600
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.model[__props.name], (cardItem, index) => {
|
|
601
|
+
return vue.openBlock(), vue.createBlock(_component_m_form_panel, {
|
|
602
|
+
key: index,
|
|
603
|
+
config: vue.unref(actionsConfig),
|
|
604
|
+
model: cardItem,
|
|
605
|
+
onChange: onChangeHandler
|
|
606
|
+
}, {
|
|
607
|
+
header: vue.withCtx(() => [
|
|
608
|
+
vue.createVNode(_component_m_form_container, {
|
|
609
|
+
class: "fullWidth",
|
|
610
|
+
config: vue.unref(eventNameConfig),
|
|
611
|
+
model: cardItem,
|
|
612
|
+
onChange: onChangeHandler
|
|
613
|
+
}, null, 8, ["config", "model"]),
|
|
614
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
615
|
+
style: { "color": "#f56c6c" },
|
|
616
|
+
text: "",
|
|
617
|
+
icon: vue.unref(iconsVue.Delete),
|
|
618
|
+
onClick: ($event) => removeEvent(index)
|
|
619
|
+
}, null, 8, ["icon", "onClick"])
|
|
620
|
+
]),
|
|
621
|
+
_: 2
|
|
622
|
+
}, 1032, ["config", "model"]);
|
|
623
|
+
}), 128))
|
|
624
|
+
]))
|
|
301
625
|
]);
|
|
302
626
|
};
|
|
303
627
|
}
|
|
@@ -721,341 +1045,211 @@
|
|
|
721
1045
|
}
|
|
722
1046
|
});
|
|
723
1047
|
|
|
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
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
1048
|
+
const fillConfig = (config = []) => [
|
|
1049
|
+
{
|
|
1050
|
+
type: "tab",
|
|
1051
|
+
items: [
|
|
1052
|
+
{
|
|
1053
|
+
title: "\u5C5E\u6027",
|
|
1054
|
+
labelWidth: "80px",
|
|
1055
|
+
items: [
|
|
1056
|
+
{
|
|
1057
|
+
text: "type",
|
|
1058
|
+
name: "type",
|
|
1059
|
+
type: "hidden"
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
name: "id",
|
|
1063
|
+
type: "display",
|
|
1064
|
+
text: "id"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
name: "name",
|
|
1068
|
+
text: "\u7EC4\u4EF6\u540D\u79F0"
|
|
1069
|
+
},
|
|
1070
|
+
...config
|
|
1071
|
+
]
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
title: "\u6837\u5F0F",
|
|
1075
|
+
labelWidth: "80px",
|
|
1076
|
+
items: [
|
|
1077
|
+
{
|
|
1078
|
+
name: "style",
|
|
1079
|
+
items: [
|
|
1080
|
+
{
|
|
1081
|
+
type: "fieldset",
|
|
1082
|
+
legend: "\u4F4D\u7F6E",
|
|
1083
|
+
items: [
|
|
1084
|
+
{
|
|
1085
|
+
name: "position",
|
|
1086
|
+
type: "checkbox",
|
|
1087
|
+
activeValue: "fixed",
|
|
1088
|
+
inactiveValue: "absolute",
|
|
1089
|
+
defaultValue: "absolute",
|
|
1090
|
+
text: "\u56FA\u5B9A\u5B9A\u4F4D"
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
name: "left",
|
|
1094
|
+
text: "left"
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
name: "top",
|
|
1098
|
+
text: "top",
|
|
1099
|
+
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedBottom"
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
name: "right",
|
|
1103
|
+
text: "right"
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
name: "bottom",
|
|
1107
|
+
text: "bottom",
|
|
1108
|
+
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedTop"
|
|
1109
|
+
}
|
|
1110
|
+
]
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
type: "fieldset",
|
|
1114
|
+
legend: "\u76D2\u5B50",
|
|
1115
|
+
items: [
|
|
1116
|
+
{
|
|
1117
|
+
name: "width",
|
|
1118
|
+
text: "\u5BBD\u5EA6"
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
name: "height",
|
|
1122
|
+
text: "\u9AD8\u5EA6"
|
|
1123
|
+
}
|
|
1124
|
+
]
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
type: "fieldset",
|
|
1128
|
+
legend: "\u80CC\u666F",
|
|
1129
|
+
items: [
|
|
1130
|
+
{
|
|
1131
|
+
name: "backgroundImage",
|
|
1132
|
+
text: "\u80CC\u666F\u56FE"
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
name: "backgroundColor",
|
|
1136
|
+
text: "\u80CC\u666F\u989C\u8272",
|
|
1137
|
+
type: "colorPicker"
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
name: "backgroundRepeat",
|
|
1141
|
+
text: "\u80CC\u666F\u56FE\u91CD\u590D",
|
|
1142
|
+
type: "select",
|
|
1143
|
+
defaultValue: "no-repeat",
|
|
1144
|
+
options: [
|
|
1145
|
+
{ text: "repeat", value: "repeat" },
|
|
1146
|
+
{ text: "repeat-x", value: "repeat-x" },
|
|
1147
|
+
{ text: "repeat-y", value: "repeat-y" },
|
|
1148
|
+
{ text: "no-repeat", value: "no-repeat" },
|
|
1149
|
+
{ text: "inherit", value: "inherit" }
|
|
1150
|
+
]
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
name: "backgroundSize",
|
|
1154
|
+
text: "\u80CC\u666F\u56FE\u5927\u5C0F",
|
|
1155
|
+
defaultValue: "100% 100%"
|
|
1156
|
+
}
|
|
1157
|
+
]
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
type: "fieldset",
|
|
1161
|
+
legend: "\u5B57\u4F53",
|
|
1162
|
+
items: [
|
|
1163
|
+
{
|
|
1164
|
+
name: "color",
|
|
1165
|
+
text: "\u989C\u8272",
|
|
1166
|
+
type: "colorPicker"
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
name: "fontSize",
|
|
1170
|
+
text: "\u5927\u5C0F"
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
name: "fontWeight",
|
|
1174
|
+
text: "\u7C97\u7EC6"
|
|
1175
|
+
}
|
|
1176
|
+
]
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
type: "fieldset",
|
|
1180
|
+
legend: "\u53D8\u5F62",
|
|
1181
|
+
name: "transform",
|
|
1182
|
+
items: [
|
|
1183
|
+
{
|
|
1184
|
+
name: "rotate",
|
|
1185
|
+
text: "\u65CB\u8F6C\u89D2\u5EA6"
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
name: "scale",
|
|
1189
|
+
text: "\u7F29\u653E"
|
|
1190
|
+
}
|
|
1191
|
+
]
|
|
850
1192
|
}
|
|
851
|
-
|
|
852
|
-
});
|
|
853
|
-
if (!this.doingTask) {
|
|
854
|
-
this.doTask();
|
|
1193
|
+
]
|
|
855
1194
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
1195
|
+
]
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
title: "\u4E8B\u4EF6",
|
|
1199
|
+
items: [
|
|
1200
|
+
{
|
|
1201
|
+
name: "events",
|
|
1202
|
+
type: "event-select"
|
|
1203
|
+
}
|
|
1204
|
+
]
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
title: "\u9AD8\u7EA7",
|
|
1208
|
+
lazy: true,
|
|
1209
|
+
items: [
|
|
1210
|
+
{
|
|
1211
|
+
name: "created",
|
|
1212
|
+
text: "created",
|
|
1213
|
+
labelWidth: "100px",
|
|
1214
|
+
type: "code-select"
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
name: "mounted",
|
|
1218
|
+
text: "mounted",
|
|
1219
|
+
labelWidth: "100px",
|
|
1220
|
+
type: "code-select"
|
|
1221
|
+
}
|
|
1222
|
+
]
|
|
1223
|
+
}
|
|
1224
|
+
]
|
|
860
1225
|
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
1226
|
+
];
|
|
1227
|
+
|
|
1228
|
+
const log = (...args) => {
|
|
1229
|
+
if (process.env.NODE_ENV === "development") {
|
|
1230
|
+
console.log("magic editor: ", ...args);
|
|
866
1231
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
});
|
|
1232
|
+
};
|
|
1233
|
+
const info = (...args) => {
|
|
1234
|
+
if (process.env.NODE_ENV === "development") {
|
|
1235
|
+
console.info("magic editor: ", ...args);
|
|
872
1236
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
Object.keys(this.middleware).forEach((key) => {
|
|
878
|
-
this.middleware[key] = [];
|
|
879
|
-
});
|
|
1237
|
+
};
|
|
1238
|
+
const warn = (...args) => {
|
|
1239
|
+
if (process.env.NODE_ENV === "development") {
|
|
1240
|
+
console.warn("magic editor: ", ...args);
|
|
880
1241
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
await task();
|
|
886
|
-
task = this.taskList.shift();
|
|
887
|
-
}
|
|
888
|
-
this.doingTask = false;
|
|
1242
|
+
};
|
|
1243
|
+
const debug = (...args) => {
|
|
1244
|
+
if (process.env.NODE_ENV === "development") {
|
|
1245
|
+
console.debug("magic editor: ", ...args);
|
|
889
1246
|
}
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
pageSteps: {},
|
|
895
|
-
pageId: void 0,
|
|
896
|
-
canRedo: false,
|
|
897
|
-
canUndo: false
|
|
898
|
-
});
|
|
899
|
-
constructor() {
|
|
900
|
-
super([]);
|
|
901
|
-
this.on("change", this.setCanUndoRedo);
|
|
902
|
-
}
|
|
903
|
-
reset() {
|
|
904
|
-
this.state.pageSteps = {};
|
|
905
|
-
this.state.pageId = void 0;
|
|
906
|
-
this.state.canRedo = false;
|
|
907
|
-
this.state.canUndo = false;
|
|
908
|
-
}
|
|
909
|
-
changePage(page) {
|
|
910
|
-
if (!page)
|
|
911
|
-
return;
|
|
912
|
-
this.state.pageId = page.id;
|
|
913
|
-
if (!this.state.pageSteps[this.state.pageId]) {
|
|
914
|
-
const undoRedo = new UndoRedo();
|
|
915
|
-
undoRedo.pushElement({
|
|
916
|
-
data: page,
|
|
917
|
-
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
918
|
-
nodeId: page.id
|
|
919
|
-
});
|
|
920
|
-
this.state.pageSteps[this.state.pageId] = undoRedo;
|
|
921
|
-
}
|
|
922
|
-
this.setCanUndoRedo();
|
|
923
|
-
this.emit("page-change", this.state.pageSteps[this.state.pageId]);
|
|
924
|
-
}
|
|
925
|
-
resetState() {
|
|
926
|
-
this.state.pageId = void 0;
|
|
927
|
-
this.state.pageSteps = {};
|
|
928
|
-
this.state.canRedo = false;
|
|
929
|
-
this.state.canUndo = false;
|
|
930
|
-
}
|
|
931
|
-
push(state) {
|
|
932
|
-
const undoRedo = this.getUndoRedo();
|
|
933
|
-
if (!undoRedo)
|
|
934
|
-
return null;
|
|
935
|
-
undoRedo.pushElement(state);
|
|
936
|
-
this.emit("change", state);
|
|
937
|
-
return state;
|
|
938
|
-
}
|
|
939
|
-
undo() {
|
|
940
|
-
const undoRedo = this.getUndoRedo();
|
|
941
|
-
if (!undoRedo)
|
|
942
|
-
return null;
|
|
943
|
-
const state = undoRedo.undo();
|
|
944
|
-
this.emit("change", state);
|
|
945
|
-
return state;
|
|
946
|
-
}
|
|
947
|
-
redo() {
|
|
948
|
-
const undoRedo = this.getUndoRedo();
|
|
949
|
-
if (!undoRedo)
|
|
950
|
-
return null;
|
|
951
|
-
const state = undoRedo.redo();
|
|
952
|
-
this.emit("change", state);
|
|
953
|
-
return state;
|
|
954
|
-
}
|
|
955
|
-
destroy() {
|
|
956
|
-
this.resetState();
|
|
957
|
-
this.removeAllListeners();
|
|
958
|
-
this.removeAllPlugins();
|
|
959
|
-
}
|
|
960
|
-
getUndoRedo() {
|
|
961
|
-
if (!this.state.pageId)
|
|
962
|
-
return null;
|
|
963
|
-
return this.state.pageSteps[this.state.pageId];
|
|
964
|
-
}
|
|
965
|
-
setCanUndoRedo() {
|
|
966
|
-
const undoRedo = this.getUndoRedo();
|
|
967
|
-
this.state.canRedo = undoRedo?.canRedo() || false;
|
|
968
|
-
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
const historyService = new History();
|
|
972
|
-
|
|
973
|
-
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
974
|
-
Protocol2["OBJECT"] = "object";
|
|
975
|
-
Protocol2["JSON"] = "json";
|
|
976
|
-
Protocol2["STRING"] = "string";
|
|
977
|
-
Protocol2["NUMBER"] = "number";
|
|
978
|
-
Protocol2["BOOLEAN"] = "boolean";
|
|
979
|
-
return Protocol2;
|
|
980
|
-
})(Protocol || {});
|
|
981
|
-
class WebStorage extends BaseService {
|
|
982
|
-
storage = globalThis.localStorage;
|
|
983
|
-
namespace = "tmagic";
|
|
984
|
-
constructor() {
|
|
985
|
-
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
986
|
-
}
|
|
987
|
-
async getStorage() {
|
|
988
|
-
return this.storage;
|
|
989
|
-
}
|
|
990
|
-
async getNamespace() {
|
|
991
|
-
return this.namespace;
|
|
992
|
-
}
|
|
993
|
-
async clear() {
|
|
994
|
-
const storage2 = await this.getStorage();
|
|
995
|
-
storage2.clear();
|
|
996
|
-
}
|
|
997
|
-
async getItem(key, options = {}) {
|
|
998
|
-
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
999
|
-
const { protocol = options.protocol, item } = this.getValueAndProtocol(
|
|
1000
|
-
storage.getItem(`${options.namespace || namespace}:${key}`)
|
|
1001
|
-
);
|
|
1002
|
-
if (item === null)
|
|
1003
|
-
return null;
|
|
1004
|
-
switch (protocol) {
|
|
1005
|
-
case "object" /* OBJECT */:
|
|
1006
|
-
return eval(`(${item})`);
|
|
1007
|
-
case "json" /* JSON */:
|
|
1008
|
-
return JSON.parse(item);
|
|
1009
|
-
case "number" /* NUMBER */:
|
|
1010
|
-
return Number(item);
|
|
1011
|
-
case "boolean" /* BOOLEAN */:
|
|
1012
|
-
return Boolean(item);
|
|
1013
|
-
default:
|
|
1014
|
-
return item;
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
async key(index) {
|
|
1018
|
-
const storage2 = await this.getStorage();
|
|
1019
|
-
return storage2.key(index);
|
|
1020
|
-
}
|
|
1021
|
-
async removeItem(key2, options2 = {}) {
|
|
1022
|
-
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1023
|
-
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
1024
|
-
}
|
|
1025
|
-
async setItem(key2, value, options2 = {}) {
|
|
1026
|
-
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1027
|
-
let item2 = value;
|
|
1028
|
-
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
1029
|
-
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
1030
|
-
item2 = `${protocol2}${value}`;
|
|
1031
|
-
} else {
|
|
1032
|
-
item2 = `${protocol2}${serialize__default.default(value)}`;
|
|
1033
|
-
}
|
|
1034
|
-
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
1035
|
-
}
|
|
1036
|
-
destroy() {
|
|
1037
|
-
this.removeAllListeners();
|
|
1038
|
-
this.removeAllPlugins();
|
|
1039
|
-
}
|
|
1040
|
-
getValueAndProtocol(value) {
|
|
1041
|
-
let protocol2 = "";
|
|
1042
|
-
if (value === null) {
|
|
1043
|
-
return {
|
|
1044
|
-
item: value,
|
|
1045
|
-
protocol: protocol2
|
|
1046
|
-
};
|
|
1047
|
-
}
|
|
1048
|
-
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
1049
|
-
protocol2 = $1;
|
|
1050
|
-
return $3;
|
|
1051
|
-
});
|
|
1052
|
-
return {
|
|
1053
|
-
protocol: protocol2,
|
|
1054
|
-
item: item2
|
|
1055
|
-
};
|
|
1247
|
+
};
|
|
1248
|
+
const error = (...args) => {
|
|
1249
|
+
if (process.env.NODE_ENV === "development") {
|
|
1250
|
+
console.error("magic editor: ", ...args);
|
|
1056
1251
|
}
|
|
1057
|
-
}
|
|
1058
|
-
const storageService = new WebStorage();
|
|
1252
|
+
};
|
|
1059
1253
|
|
|
1060
1254
|
var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
1061
1255
|
ColumnLayout2["LEFT"] = "left";
|
|
@@ -1248,145 +1442,481 @@
|
|
|
1248
1442
|
unsafe: true
|
|
1249
1443
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1250
1444
|
|
|
1251
|
-
class
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
"setPropsValue",
|
|
1261
|
-
"getPropsValue",
|
|
1262
|
-
"createId",
|
|
1263
|
-
"setNewItemId",
|
|
1264
|
-
"fillConfig",
|
|
1265
|
-
"getDefaultPropsValue"
|
|
1266
|
-
]);
|
|
1267
|
-
}
|
|
1268
|
-
setPropsConfigs(configs) {
|
|
1269
|
-
Object.keys(configs).forEach((type) => {
|
|
1270
|
-
this.setPropsConfig(utils.toLine(type), configs[type]);
|
|
1271
|
-
});
|
|
1272
|
-
this.emit("props-configs-change");
|
|
1445
|
+
class UndoRedo {
|
|
1446
|
+
elementList;
|
|
1447
|
+
listCursor;
|
|
1448
|
+
listMaxSize;
|
|
1449
|
+
constructor(listMaxSize = 200) {
|
|
1450
|
+
const minListMaxSize = 2;
|
|
1451
|
+
this.elementList = [];
|
|
1452
|
+
this.listCursor = 0;
|
|
1453
|
+
this.listMaxSize = listMaxSize > minListMaxSize ? listMaxSize : minListMaxSize;
|
|
1273
1454
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1455
|
+
pushElement(element) {
|
|
1456
|
+
this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, lodashEs.cloneDeep(element));
|
|
1457
|
+
this.listCursor += 1;
|
|
1458
|
+
if (this.elementList.length > this.listMaxSize) {
|
|
1459
|
+
this.elementList.shift();
|
|
1460
|
+
this.listCursor -= 1;
|
|
1461
|
+
}
|
|
1276
1462
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1463
|
+
canUndo() {
|
|
1464
|
+
return this.listCursor > 1;
|
|
1279
1465
|
}
|
|
1280
|
-
|
|
1281
|
-
if (
|
|
1282
|
-
return
|
|
1466
|
+
undo() {
|
|
1467
|
+
if (!this.canUndo()) {
|
|
1468
|
+
return null;
|
|
1283
1469
|
}
|
|
1284
|
-
|
|
1470
|
+
this.listCursor -= 1;
|
|
1471
|
+
return this.getCurrentElement();
|
|
1285
1472
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
this.setPropsValue(utils.toLine(type), values[type]);
|
|
1289
|
-
});
|
|
1473
|
+
canRedo() {
|
|
1474
|
+
return this.elementList.length > this.listCursor;
|
|
1290
1475
|
}
|
|
1291
|
-
|
|
1292
|
-
this.
|
|
1476
|
+
redo() {
|
|
1477
|
+
if (!this.canRedo()) {
|
|
1478
|
+
return null;
|
|
1479
|
+
}
|
|
1480
|
+
this.listCursor += 1;
|
|
1481
|
+
return this.getCurrentElement();
|
|
1293
1482
|
}
|
|
1294
|
-
|
|
1295
|
-
if (
|
|
1296
|
-
|
|
1297
|
-
value.className = "action-area";
|
|
1298
|
-
value.text = "";
|
|
1299
|
-
if (value.style) {
|
|
1300
|
-
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
1301
|
-
}
|
|
1302
|
-
return value;
|
|
1483
|
+
getCurrentElement() {
|
|
1484
|
+
if (this.listCursor < 1) {
|
|
1485
|
+
return null;
|
|
1303
1486
|
}
|
|
1304
|
-
|
|
1305
|
-
this.createId(type),
|
|
1306
|
-
this.getDefaultPropsValue(type),
|
|
1307
|
-
this.setNewItemId(
|
|
1308
|
-
lodashEs.cloneDeep({
|
|
1309
|
-
type,
|
|
1310
|
-
...defaultValue
|
|
1311
|
-
})
|
|
1312
|
-
)
|
|
1313
|
-
]);
|
|
1314
|
-
return {
|
|
1315
|
-
id,
|
|
1316
|
-
...defaultPropsValue,
|
|
1317
|
-
...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
1318
|
-
};
|
|
1487
|
+
return lodashEs.cloneDeep(this.elementList[this.listCursor - 1]);
|
|
1319
1488
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
const compose = (middleware) => {
|
|
1492
|
+
if (!Array.isArray(middleware))
|
|
1493
|
+
throw new TypeError("Middleware \u5FC5\u987B\u662F\u4E00\u4E2A\u6570\u7EC4!");
|
|
1494
|
+
for (const fn of middleware) {
|
|
1495
|
+
if (typeof fn !== "function")
|
|
1496
|
+
throw new TypeError("Middleware \u5FC5\u987B\u7531\u51FD\u6570\u7EC4\u6210!");
|
|
1322
1497
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1498
|
+
return (args, next) => {
|
|
1499
|
+
let index = -1;
|
|
1500
|
+
return dispatch(0);
|
|
1501
|
+
function dispatch(i) {
|
|
1502
|
+
if (i <= index)
|
|
1503
|
+
return Promise.reject(new Error("next() \u88AB\u591A\u6B21\u8C03\u7528"));
|
|
1504
|
+
index = i;
|
|
1505
|
+
let fn = middleware[i];
|
|
1506
|
+
if (i === middleware.length && next)
|
|
1507
|
+
fn = next;
|
|
1508
|
+
if (!fn)
|
|
1509
|
+
return Promise.resolve();
|
|
1510
|
+
try {
|
|
1511
|
+
return Promise.resolve(fn(...args, dispatch.bind(null, i + 1)));
|
|
1512
|
+
} catch (err) {
|
|
1513
|
+
return Promise.reject(err);
|
|
1328
1514
|
}
|
|
1329
1515
|
}
|
|
1330
|
-
|
|
1516
|
+
};
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
const methodName = (prefix, name) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
|
|
1520
|
+
const isError = (error) => Object.prototype.toString.call(error) === "[object Error]";
|
|
1521
|
+
const doAction = async (args, scope, sourceMethod, beforeMethodName, afterMethodName, fn) => {
|
|
1522
|
+
try {
|
|
1523
|
+
let beforeArgs = args;
|
|
1524
|
+
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
1525
|
+
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
1526
|
+
if (isError(beforeArgs))
|
|
1527
|
+
throw beforeArgs;
|
|
1528
|
+
if (!Array.isArray(beforeArgs)) {
|
|
1529
|
+
beforeArgs = [beforeArgs];
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
1533
|
+
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
1534
|
+
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
1535
|
+
if (isError(returnValue))
|
|
1536
|
+
throw returnValue;
|
|
1537
|
+
}
|
|
1538
|
+
return returnValue;
|
|
1539
|
+
} catch (error) {
|
|
1540
|
+
throw error;
|
|
1331
1541
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1542
|
+
};
|
|
1543
|
+
class BaseService extends events.EventEmitter {
|
|
1544
|
+
pluginOptionsList = {};
|
|
1545
|
+
middleware = {};
|
|
1546
|
+
taskList = [];
|
|
1547
|
+
doingTask = false;
|
|
1548
|
+
constructor(methods = [], serialMethods = []) {
|
|
1549
|
+
super();
|
|
1550
|
+
methods.forEach((propertyName) => {
|
|
1551
|
+
const scope = this;
|
|
1552
|
+
const sourceMethod = scope[propertyName];
|
|
1553
|
+
const beforeMethodName = methodName("before", propertyName);
|
|
1554
|
+
const afterMethodName = methodName("after", propertyName);
|
|
1555
|
+
this.pluginOptionsList[beforeMethodName] = [];
|
|
1556
|
+
this.pluginOptionsList[afterMethodName] = [];
|
|
1557
|
+
this.middleware[propertyName] = [];
|
|
1558
|
+
const fn = compose(this.middleware[propertyName]);
|
|
1559
|
+
Object.defineProperty(scope, propertyName, {
|
|
1560
|
+
value: async (...args) => {
|
|
1561
|
+
if (!serialMethods.includes(propertyName)) {
|
|
1562
|
+
return doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
1563
|
+
}
|
|
1564
|
+
const promise = new Promise((resolve, reject) => {
|
|
1565
|
+
this.taskList.push(async () => {
|
|
1566
|
+
try {
|
|
1567
|
+
const value = await doAction(args, scope, sourceMethod, beforeMethodName, afterMethodName, fn);
|
|
1568
|
+
resolve(value);
|
|
1569
|
+
} catch (e) {
|
|
1570
|
+
reject(e);
|
|
1571
|
+
}
|
|
1572
|
+
});
|
|
1573
|
+
});
|
|
1574
|
+
if (!this.doingTask) {
|
|
1575
|
+
this.doTask();
|
|
1576
|
+
}
|
|
1577
|
+
return promise;
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
use(options) {
|
|
1583
|
+
Object.entries(options).forEach(([methodName2, method]) => {
|
|
1584
|
+
if (typeof method === "function")
|
|
1585
|
+
this.middleware[methodName2].push(method);
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
usePlugin(options) {
|
|
1589
|
+
Object.entries(options).forEach(([methodName2, method]) => {
|
|
1590
|
+
if (typeof method === "function")
|
|
1591
|
+
this.pluginOptionsList[methodName2].push(method);
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
removeAllPlugins() {
|
|
1595
|
+
Object.keys(this.pluginOptionsList).forEach((key) => {
|
|
1596
|
+
this.pluginOptionsList[key] = [];
|
|
1597
|
+
});
|
|
1598
|
+
Object.keys(this.middleware).forEach((key) => {
|
|
1599
|
+
this.middleware[key] = [];
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
async doTask() {
|
|
1603
|
+
this.doingTask = true;
|
|
1604
|
+
let task = this.taskList.shift();
|
|
1605
|
+
while (task) {
|
|
1606
|
+
await task();
|
|
1607
|
+
task = this.taskList.shift();
|
|
1608
|
+
}
|
|
1609
|
+
this.doingTask = false;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
class History extends BaseService {
|
|
1614
|
+
state = vue.reactive({
|
|
1615
|
+
pageSteps: {},
|
|
1616
|
+
pageId: void 0,
|
|
1617
|
+
canRedo: false,
|
|
1618
|
+
canUndo: false
|
|
1619
|
+
});
|
|
1620
|
+
constructor() {
|
|
1621
|
+
super([]);
|
|
1622
|
+
this.on("change", this.setCanUndoRedo);
|
|
1623
|
+
}
|
|
1624
|
+
reset() {
|
|
1625
|
+
this.state.pageSteps = {};
|
|
1626
|
+
this.state.pageId = void 0;
|
|
1627
|
+
this.state.canRedo = false;
|
|
1628
|
+
this.state.canUndo = false;
|
|
1629
|
+
}
|
|
1630
|
+
changePage(page) {
|
|
1631
|
+
if (!page)
|
|
1632
|
+
return;
|
|
1633
|
+
this.state.pageId = page.id;
|
|
1634
|
+
if (!this.state.pageSteps[this.state.pageId]) {
|
|
1635
|
+
const undoRedo = new UndoRedo();
|
|
1636
|
+
undoRedo.pushElement({
|
|
1637
|
+
data: page,
|
|
1638
|
+
modifiedNodeIds: /* @__PURE__ */ new Map(),
|
|
1639
|
+
nodeId: page.id
|
|
1640
|
+
});
|
|
1641
|
+
this.state.pageSteps[this.state.pageId] = undoRedo;
|
|
1642
|
+
}
|
|
1643
|
+
this.setCanUndoRedo();
|
|
1644
|
+
this.emit("page-change", this.state.pageSteps[this.state.pageId]);
|
|
1344
1645
|
}
|
|
1345
1646
|
resetState() {
|
|
1346
|
-
this.state.
|
|
1347
|
-
this.state.
|
|
1647
|
+
this.state.pageId = void 0;
|
|
1648
|
+
this.state.pageSteps = {};
|
|
1649
|
+
this.state.canRedo = false;
|
|
1650
|
+
this.state.canUndo = false;
|
|
1651
|
+
}
|
|
1652
|
+
push(state) {
|
|
1653
|
+
const undoRedo = this.getUndoRedo();
|
|
1654
|
+
if (!undoRedo)
|
|
1655
|
+
return null;
|
|
1656
|
+
undoRedo.pushElement(state);
|
|
1657
|
+
this.emit("change", state);
|
|
1658
|
+
return state;
|
|
1659
|
+
}
|
|
1660
|
+
undo() {
|
|
1661
|
+
const undoRedo = this.getUndoRedo();
|
|
1662
|
+
if (!undoRedo)
|
|
1663
|
+
return null;
|
|
1664
|
+
const state = undoRedo.undo();
|
|
1665
|
+
this.emit("change", state);
|
|
1666
|
+
return state;
|
|
1667
|
+
}
|
|
1668
|
+
redo() {
|
|
1669
|
+
const undoRedo = this.getUndoRedo();
|
|
1670
|
+
if (!undoRedo)
|
|
1671
|
+
return null;
|
|
1672
|
+
const state = undoRedo.redo();
|
|
1673
|
+
this.emit("change", state);
|
|
1674
|
+
return state;
|
|
1348
1675
|
}
|
|
1349
1676
|
destroy() {
|
|
1350
1677
|
this.resetState();
|
|
1351
1678
|
this.removeAllListeners();
|
|
1352
1679
|
this.removeAllPlugins();
|
|
1353
1680
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1681
|
+
getUndoRedo() {
|
|
1682
|
+
if (!this.state.pageId)
|
|
1683
|
+
return null;
|
|
1684
|
+
return this.state.pageSteps[this.state.pageId];
|
|
1685
|
+
}
|
|
1686
|
+
setCanUndoRedo() {
|
|
1687
|
+
const undoRedo = this.getUndoRedo();
|
|
1688
|
+
this.state.canRedo = undoRedo?.canRedo() || false;
|
|
1689
|
+
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
1360
1690
|
}
|
|
1361
1691
|
}
|
|
1362
|
-
const
|
|
1692
|
+
const historyService = new History();
|
|
1363
1693
|
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1694
|
+
var Protocol = /* @__PURE__ */ ((Protocol2) => {
|
|
1695
|
+
Protocol2["OBJECT"] = "object";
|
|
1696
|
+
Protocol2["JSON"] = "json";
|
|
1697
|
+
Protocol2["STRING"] = "string";
|
|
1698
|
+
Protocol2["NUMBER"] = "number";
|
|
1699
|
+
Protocol2["BOOLEAN"] = "boolean";
|
|
1700
|
+
return Protocol2;
|
|
1701
|
+
})(Protocol || {});
|
|
1702
|
+
class WebStorage extends BaseService {
|
|
1703
|
+
storage = globalThis.localStorage;
|
|
1704
|
+
namespace = "tmagic";
|
|
1705
|
+
constructor() {
|
|
1706
|
+
super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
|
|
1707
|
+
}
|
|
1708
|
+
async getStorage() {
|
|
1709
|
+
return this.storage;
|
|
1710
|
+
}
|
|
1711
|
+
async getNamespace() {
|
|
1712
|
+
return this.namespace;
|
|
1713
|
+
}
|
|
1714
|
+
async clear() {
|
|
1715
|
+
const storage2 = await this.getStorage();
|
|
1716
|
+
storage2.clear();
|
|
1717
|
+
}
|
|
1718
|
+
async getItem(key, options = {}) {
|
|
1719
|
+
const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1720
|
+
const { protocol = options.protocol, item } = this.getValueAndProtocol(
|
|
1721
|
+
storage.getItem(`${options.namespace || namespace}:${key}`)
|
|
1722
|
+
);
|
|
1723
|
+
if (item === null)
|
|
1724
|
+
return null;
|
|
1725
|
+
switch (protocol) {
|
|
1726
|
+
case "object" /* OBJECT */:
|
|
1727
|
+
return eval(`(${item})`);
|
|
1728
|
+
case "json" /* JSON */:
|
|
1729
|
+
return JSON.parse(item);
|
|
1730
|
+
case "number" /* NUMBER */:
|
|
1731
|
+
return Number(item);
|
|
1732
|
+
case "boolean" /* BOOLEAN */:
|
|
1733
|
+
return Boolean(item);
|
|
1734
|
+
default:
|
|
1735
|
+
return item;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
async key(index) {
|
|
1739
|
+
const storage2 = await this.getStorage();
|
|
1740
|
+
return storage2.key(index);
|
|
1741
|
+
}
|
|
1742
|
+
async removeItem(key2, options2 = {}) {
|
|
1743
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1744
|
+
storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
|
|
1745
|
+
}
|
|
1746
|
+
async setItem(key2, value, options2 = {}) {
|
|
1747
|
+
const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
|
|
1748
|
+
let item2 = value;
|
|
1749
|
+
const protocol2 = options2.protocol ? `${options2.protocol}:` : "";
|
|
1750
|
+
if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
|
|
1751
|
+
item2 = `${protocol2}${value}`;
|
|
1752
|
+
} else {
|
|
1753
|
+
item2 = `${protocol2}${serialize__default.default(value)}`;
|
|
1754
|
+
}
|
|
1755
|
+
storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
|
|
1756
|
+
}
|
|
1757
|
+
destroy() {
|
|
1758
|
+
this.removeAllListeners();
|
|
1759
|
+
this.removeAllPlugins();
|
|
1760
|
+
}
|
|
1761
|
+
getValueAndProtocol(value) {
|
|
1762
|
+
let protocol2 = "";
|
|
1763
|
+
if (value === null) {
|
|
1764
|
+
return {
|
|
1765
|
+
item: value,
|
|
1766
|
+
protocol: protocol2
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
const item2 = value.replace(new RegExp(`^(${Object.values(Protocol).join("|")})(:)(.+)`), (_$0, $1, _$2, $3) => {
|
|
1770
|
+
protocol2 = $1;
|
|
1771
|
+
return $3;
|
|
1772
|
+
});
|
|
1773
|
+
return {
|
|
1774
|
+
protocol: protocol2,
|
|
1775
|
+
item: item2
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
const storageService = new WebStorage();
|
|
1780
|
+
|
|
1781
|
+
class Props extends BaseService {
|
|
1782
|
+
state = vue.reactive({
|
|
1783
|
+
propsConfigMap: {},
|
|
1784
|
+
propsValueMap: {}
|
|
1785
|
+
});
|
|
1786
|
+
constructor() {
|
|
1787
|
+
super([
|
|
1788
|
+
"setPropsConfig",
|
|
1789
|
+
"getPropsConfig",
|
|
1790
|
+
"setPropsValue",
|
|
1791
|
+
"getPropsValue",
|
|
1792
|
+
"createId",
|
|
1793
|
+
"setNewItemId",
|
|
1794
|
+
"fillConfig",
|
|
1795
|
+
"getDefaultPropsValue"
|
|
1796
|
+
]);
|
|
1797
|
+
}
|
|
1798
|
+
setPropsConfigs(configs) {
|
|
1799
|
+
Object.keys(configs).forEach((type) => {
|
|
1800
|
+
this.setPropsConfig(utils.toLine(type), configs[type]);
|
|
1801
|
+
});
|
|
1802
|
+
this.emit("props-configs-change");
|
|
1803
|
+
}
|
|
1804
|
+
async fillConfig(config) {
|
|
1805
|
+
return fillConfig(config);
|
|
1806
|
+
}
|
|
1807
|
+
async setPropsConfig(type, config) {
|
|
1808
|
+
this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
|
|
1809
|
+
}
|
|
1810
|
+
async getPropsConfig(type) {
|
|
1811
|
+
if (type === "area") {
|
|
1812
|
+
return await this.getPropsConfig("button");
|
|
1813
|
+
}
|
|
1814
|
+
return lodashEs.cloneDeep(this.state.propsConfigMap[type] || await this.fillConfig([]));
|
|
1815
|
+
}
|
|
1816
|
+
setPropsValues(values) {
|
|
1817
|
+
Object.keys(values).forEach((type) => {
|
|
1818
|
+
this.setPropsValue(utils.toLine(type), values[type]);
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
async setPropsValue(type, value) {
|
|
1822
|
+
this.state.propsValueMap[type] = value;
|
|
1823
|
+
}
|
|
1824
|
+
async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
|
|
1825
|
+
if (type === "area") {
|
|
1826
|
+
const value = await this.getPropsValue("button");
|
|
1827
|
+
value.className = "action-area";
|
|
1828
|
+
value.text = "";
|
|
1829
|
+
if (value.style) {
|
|
1830
|
+
value.style.backgroundColor = "rgba(255, 255, 255, 0)";
|
|
1831
|
+
}
|
|
1832
|
+
return value;
|
|
1833
|
+
}
|
|
1834
|
+
const [id, defaultPropsValue, data] = await Promise.all([
|
|
1835
|
+
this.createId(type),
|
|
1836
|
+
this.getDefaultPropsValue(type),
|
|
1837
|
+
this.setNewItemId(
|
|
1838
|
+
lodashEs.cloneDeep({
|
|
1839
|
+
type,
|
|
1840
|
+
...defaultValue
|
|
1841
|
+
})
|
|
1842
|
+
)
|
|
1843
|
+
]);
|
|
1844
|
+
return {
|
|
1845
|
+
id,
|
|
1846
|
+
...defaultPropsValue,
|
|
1847
|
+
...lodashEs.mergeWith({}, lodashEs.cloneDeep(this.state.propsValueMap[type] || {}), data)
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
async createId(type) {
|
|
1851
|
+
return `${type}_${this.guid()}`;
|
|
1852
|
+
}
|
|
1853
|
+
async setNewItemId(config) {
|
|
1854
|
+
config.id = await this.createId(config.type || "component");
|
|
1855
|
+
if (config.items && Array.isArray(config.items)) {
|
|
1856
|
+
for (const item of config.items) {
|
|
1857
|
+
await this.setNewItemId(item);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
return config;
|
|
1861
|
+
}
|
|
1862
|
+
async getDefaultPropsValue(type) {
|
|
1863
|
+
return ["page", "container"].includes(type) ? {
|
|
1864
|
+
type,
|
|
1865
|
+
layout: "absolute",
|
|
1866
|
+
style: {},
|
|
1867
|
+
name: type,
|
|
1868
|
+
items: []
|
|
1869
|
+
} : {
|
|
1870
|
+
type,
|
|
1871
|
+
style: {},
|
|
1872
|
+
name: type
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
resetState() {
|
|
1876
|
+
this.state.propsConfigMap = {};
|
|
1877
|
+
this.state.propsValueMap = {};
|
|
1878
|
+
}
|
|
1879
|
+
destroy() {
|
|
1880
|
+
this.resetState();
|
|
1881
|
+
this.removeAllListeners();
|
|
1882
|
+
this.removeAllPlugins();
|
|
1883
|
+
}
|
|
1884
|
+
guid(digit = 8) {
|
|
1885
|
+
return "x".repeat(digit).replace(/[xy]/g, (c) => {
|
|
1886
|
+
const r = Math.random() * 16 | 0;
|
|
1887
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
1888
|
+
return v.toString(16);
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
const propsService = new Props();
|
|
1893
|
+
|
|
1894
|
+
const beforePaste = async (position, config) => {
|
|
1895
|
+
if (!config[0]?.style)
|
|
1896
|
+
return config;
|
|
1897
|
+
const curNode = editorService.get("node");
|
|
1898
|
+
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
1899
|
+
const pasteConfigs = await Promise.all(
|
|
1900
|
+
config.map(async (configItem) => {
|
|
1901
|
+
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
1902
|
+
let pastePosition = positionClone;
|
|
1903
|
+
if (!lodashEs.isEmpty(pastePosition) && curNode?.items) {
|
|
1904
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
1905
|
+
}
|
|
1906
|
+
if (pastePosition.left && configItem.style?.left) {
|
|
1907
|
+
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
1908
|
+
}
|
|
1909
|
+
if (pastePosition.top && configItem.style?.top) {
|
|
1910
|
+
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
|
1911
|
+
}
|
|
1912
|
+
const pasteConfig = await propsService.setNewItemId(configItem);
|
|
1913
|
+
if (pasteConfig.style) {
|
|
1914
|
+
const { left, top } = pasteConfig.style;
|
|
1915
|
+
if (typeof left === "number" || !!left && !isNaN(Number(left))) {
|
|
1916
|
+
pasteConfig.style.left = Number(left) + offsetX;
|
|
1917
|
+
}
|
|
1918
|
+
if (typeof top === "number" || !!top && !isNaN(Number(top))) {
|
|
1919
|
+
pasteConfig.style.top = Number(top) + offsetY;
|
|
1390
1920
|
}
|
|
1391
1921
|
pasteConfig.style = {
|
|
1392
1922
|
...pasteConfig.style,
|
|
@@ -1554,7 +2084,7 @@
|
|
|
1554
2084
|
historyService.resetState();
|
|
1555
2085
|
}
|
|
1556
2086
|
if (node?.id) {
|
|
1557
|
-
this.get("stage")?.renderer.runtime?.getApp?.()
|
|
2087
|
+
this.get("stage")?.renderer.runtime?.getApp?.()?.page?.emit(
|
|
1558
2088
|
"editor:select",
|
|
1559
2089
|
{
|
|
1560
2090
|
node,
|
|
@@ -1905,437 +2435,148 @@
|
|
|
1905
2435
|
}
|
|
1906
2436
|
async moveToContainer(config, targetId) {
|
|
1907
2437
|
const root = lodashEs.cloneDeep(this.get("root"));
|
|
1908
|
-
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
1909
|
-
const target = this.getNodeById(targetId, false);
|
|
1910
|
-
const stage = this.get("stage");
|
|
1911
|
-
if (root && node && parent && stage) {
|
|
1912
|
-
const index = getNodeIndex(node, parent);
|
|
1913
|
-
parent.items?.splice(index, 1);
|
|
1914
|
-
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
1915
|
-
const layout = await this.getLayout(target);
|
|
1916
|
-
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
|
|
1917
|
-
if (Array.isArray(srcValue)) {
|
|
1918
|
-
return srcValue;
|
|
1919
|
-
}
|
|
1920
|
-
});
|
|
1921
|
-
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1922
|
-
target.items.push(newConfig);
|
|
1923
|
-
await stage.select(targetId);
|
|
1924
|
-
const targetParent = this.getParentById(target.id);
|
|
1925
|
-
await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root });
|
|
1926
|
-
await this.select(newConfig);
|
|
1927
|
-
stage.select(newConfig.id);
|
|
1928
|
-
this.addModifiedNodeId(target.id);
|
|
1929
|
-
this.addModifiedNodeId(parent.id);
|
|
1930
|
-
this.pushHistoryState();
|
|
1931
|
-
return newConfig;
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
async undo() {
|
|
1935
|
-
const value = historyService.undo();
|
|
1936
|
-
await this.changeHistoryState(value);
|
|
1937
|
-
return value;
|
|
1938
|
-
}
|
|
1939
|
-
async redo() {
|
|
1940
|
-
const value = historyService.redo();
|
|
1941
|
-
await this.changeHistoryState(value);
|
|
1942
|
-
return value;
|
|
1943
|
-
}
|
|
1944
|
-
async move(left, top) {
|
|
1945
|
-
const node = vue.toRaw(this.get("node"));
|
|
1946
|
-
if (!node || utils.isPage(node))
|
|
1947
|
-
return;
|
|
1948
|
-
const { style, id, type } = node;
|
|
1949
|
-
if (!style || style.position !== "absolute")
|
|
1950
|
-
return;
|
|
1951
|
-
if (top && !utils.isNumber(style.top))
|
|
1952
|
-
return;
|
|
1953
|
-
if (left && !utils.isNumber(style.left))
|
|
1954
|
-
return;
|
|
1955
|
-
this.update({
|
|
1956
|
-
id,
|
|
1957
|
-
type,
|
|
1958
|
-
style: {
|
|
1959
|
-
...style,
|
|
1960
|
-
left: Number(style.left) + left,
|
|
1961
|
-
top: Number(style.top) + top
|
|
1962
|
-
}
|
|
1963
|
-
});
|
|
1964
|
-
}
|
|
1965
|
-
resetState() {
|
|
1966
|
-
this.set("root", null);
|
|
1967
|
-
this.set("node", null);
|
|
1968
|
-
this.set("nodes", []);
|
|
1969
|
-
this.set("page", null);
|
|
1970
|
-
this.set("parent", null);
|
|
1971
|
-
this.set("stage", null);
|
|
1972
|
-
this.set("highlightNode", null);
|
|
1973
|
-
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
1974
|
-
this.set("pageLength", 0);
|
|
1975
|
-
}
|
|
1976
|
-
destroy() {
|
|
1977
|
-
this.removeAllListeners();
|
|
1978
|
-
this.resetState();
|
|
1979
|
-
this.removeAllPlugins();
|
|
1980
|
-
}
|
|
1981
|
-
resetModifiedNodeId() {
|
|
1982
|
-
this.get("modifiedNodeIds").clear();
|
|
1983
|
-
}
|
|
1984
|
-
addModifiedNodeId(id) {
|
|
1985
|
-
if (!this.isHistoryStateChange) {
|
|
1986
|
-
this.get("modifiedNodeIds").set(id, id);
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
pushHistoryState() {
|
|
1990
|
-
const curNode = lodashEs.cloneDeep(vue.toRaw(this.get("node")));
|
|
1991
|
-
const page = this.get("page");
|
|
1992
|
-
if (!this.isHistoryStateChange && curNode && page) {
|
|
1993
|
-
historyService.push({
|
|
1994
|
-
data: lodashEs.cloneDeep(vue.toRaw(page)),
|
|
1995
|
-
modifiedNodeIds: this.get("modifiedNodeIds"),
|
|
1996
|
-
nodeId: curNode.id
|
|
1997
|
-
});
|
|
1998
|
-
}
|
|
1999
|
-
this.isHistoryStateChange = false;
|
|
2000
|
-
}
|
|
2001
|
-
async changeHistoryState(value) {
|
|
2002
|
-
if (!value)
|
|
2003
|
-
return;
|
|
2004
|
-
this.isHistoryStateChange = true;
|
|
2005
|
-
await this.update(value.data);
|
|
2006
|
-
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
2007
|
-
setTimeout(async () => {
|
|
2008
|
-
if (!value.nodeId)
|
|
2009
|
-
return;
|
|
2010
|
-
await this.select(value.nodeId);
|
|
2011
|
-
this.get("stage")?.select(value.nodeId);
|
|
2012
|
-
}, 0);
|
|
2013
|
-
this.emit("history-change", value.data);
|
|
2014
|
-
}
|
|
2015
|
-
async toggleFixedPosition(dist, src, root) {
|
|
2016
|
-
const newConfig = lodashEs.cloneDeep(dist);
|
|
2017
|
-
if (!utils.isPop(src) && newConfig.style?.position) {
|
|
2018
|
-
if (isFixed(newConfig) && !isFixed(src)) {
|
|
2019
|
-
newConfig.style = change2Fixed(newConfig, root);
|
|
2020
|
-
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
2021
|
-
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
return newConfig;
|
|
2025
|
-
}
|
|
2026
|
-
selectedConfigExceptionHandler(config) {
|
|
2027
|
-
let id;
|
|
2028
|
-
if (typeof config === "string" || typeof config === "number") {
|
|
2029
|
-
id = config;
|
|
2030
|
-
} else {
|
|
2031
|
-
id = config.id;
|
|
2032
|
-
}
|
|
2033
|
-
if (!id) {
|
|
2034
|
-
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
2035
|
-
}
|
|
2036
|
-
const { node, parent, page } = this.getNodeInfo(id);
|
|
2037
|
-
if (!node)
|
|
2038
|
-
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
2039
|
-
if (node.id === this.state.root?.id) {
|
|
2040
|
-
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
2041
|
-
}
|
|
2042
|
-
return {
|
|
2043
|
-
node,
|
|
2044
|
-
parent,
|
|
2045
|
-
page
|
|
2046
|
-
};
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
const editorService = new Editor$1();
|
|
2050
|
-
|
|
2051
|
-
let eventMap = vue.reactive({});
|
|
2052
|
-
let methodMap = vue.reactive({});
|
|
2053
|
-
class Events extends BaseService {
|
|
2054
|
-
constructor() {
|
|
2055
|
-
super([]);
|
|
2056
|
-
}
|
|
2057
|
-
init(componentGroupList) {
|
|
2058
|
-
componentGroupList.forEach((group) => {
|
|
2059
|
-
group.items.forEach((element) => {
|
|
2060
|
-
const type = utils.toLine(element.type);
|
|
2061
|
-
if (!this.getEvent(type)) {
|
|
2062
|
-
this.setEvent(type, core.DEFAULT_EVENTS);
|
|
2063
|
-
}
|
|
2064
|
-
if (!this.getMethod(type)) {
|
|
2065
|
-
this.setMethod(type, core.DEFAULT_METHODS);
|
|
2066
|
-
}
|
|
2067
|
-
});
|
|
2068
|
-
});
|
|
2069
|
-
}
|
|
2070
|
-
setEvents(events) {
|
|
2071
|
-
Object.keys(events).forEach((type) => {
|
|
2072
|
-
this.setEvent(utils.toLine(type), events[type] || []);
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
setEvent(type, events) {
|
|
2076
|
-
eventMap[type] = [...core.DEFAULT_EVENTS, ...events];
|
|
2077
|
-
}
|
|
2078
|
-
getEvent(type) {
|
|
2079
|
-
return lodashEs.cloneDeep(eventMap[type] || core.DEFAULT_EVENTS);
|
|
2080
|
-
}
|
|
2081
|
-
setMethods(methods) {
|
|
2082
|
-
Object.keys(methods).forEach((type) => {
|
|
2083
|
-
this.setMethod(utils.toLine(type), methods[type] || []);
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
setMethod(type, method) {
|
|
2087
|
-
methodMap[type] = [...core.DEFAULT_METHODS, ...method];
|
|
2088
|
-
}
|
|
2089
|
-
getMethod(type) {
|
|
2090
|
-
return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
|
|
2091
|
-
}
|
|
2092
|
-
resetState() {
|
|
2093
|
-
eventMap = vue.reactive({});
|
|
2094
|
-
methodMap = vue.reactive({});
|
|
2095
|
-
}
|
|
2096
|
-
destroy() {
|
|
2097
|
-
this.resetState();
|
|
2098
|
-
this.removeAllListeners();
|
|
2099
|
-
this.removeAllPlugins();
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
const eventsService = new Events();
|
|
2103
|
-
|
|
2104
|
-
const fillConfig = (config = []) => [
|
|
2105
|
-
{
|
|
2106
|
-
type: "tab",
|
|
2107
|
-
items: [
|
|
2108
|
-
{
|
|
2109
|
-
title: "\u5C5E\u6027",
|
|
2110
|
-
labelWidth: "80px",
|
|
2111
|
-
items: [
|
|
2112
|
-
{
|
|
2113
|
-
text: "type",
|
|
2114
|
-
name: "type",
|
|
2115
|
-
type: "hidden"
|
|
2116
|
-
},
|
|
2117
|
-
{
|
|
2118
|
-
name: "id",
|
|
2119
|
-
type: "display",
|
|
2120
|
-
text: "id"
|
|
2121
|
-
},
|
|
2122
|
-
{
|
|
2123
|
-
name: "name",
|
|
2124
|
-
text: "\u7EC4\u4EF6\u540D\u79F0"
|
|
2125
|
-
},
|
|
2126
|
-
...config
|
|
2127
|
-
]
|
|
2128
|
-
},
|
|
2129
|
-
{
|
|
2130
|
-
title: "\u6837\u5F0F",
|
|
2131
|
-
labelWidth: "80px",
|
|
2132
|
-
items: [
|
|
2133
|
-
{
|
|
2134
|
-
name: "style",
|
|
2135
|
-
items: [
|
|
2136
|
-
{
|
|
2137
|
-
type: "fieldset",
|
|
2138
|
-
legend: "\u4F4D\u7F6E",
|
|
2139
|
-
items: [
|
|
2140
|
-
{
|
|
2141
|
-
name: "position",
|
|
2142
|
-
type: "checkbox",
|
|
2143
|
-
activeValue: "fixed",
|
|
2144
|
-
inactiveValue: "absolute",
|
|
2145
|
-
defaultValue: "absolute",
|
|
2146
|
-
text: "\u56FA\u5B9A\u5B9A\u4F4D"
|
|
2147
|
-
},
|
|
2148
|
-
{
|
|
2149
|
-
name: "left",
|
|
2150
|
-
text: "left"
|
|
2151
|
-
},
|
|
2152
|
-
{
|
|
2153
|
-
name: "top",
|
|
2154
|
-
text: "top",
|
|
2155
|
-
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedBottom"
|
|
2156
|
-
},
|
|
2157
|
-
{
|
|
2158
|
-
name: "right",
|
|
2159
|
-
text: "right"
|
|
2160
|
-
},
|
|
2161
|
-
{
|
|
2162
|
-
name: "bottom",
|
|
2163
|
-
text: "bottom",
|
|
2164
|
-
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedTop"
|
|
2165
|
-
}
|
|
2166
|
-
]
|
|
2167
|
-
},
|
|
2168
|
-
{
|
|
2169
|
-
type: "fieldset",
|
|
2170
|
-
legend: "\u76D2\u5B50",
|
|
2171
|
-
items: [
|
|
2172
|
-
{
|
|
2173
|
-
name: "width",
|
|
2174
|
-
text: "\u5BBD\u5EA6"
|
|
2175
|
-
},
|
|
2176
|
-
{
|
|
2177
|
-
name: "height",
|
|
2178
|
-
text: "\u9AD8\u5EA6"
|
|
2179
|
-
}
|
|
2180
|
-
]
|
|
2181
|
-
},
|
|
2182
|
-
{
|
|
2183
|
-
type: "fieldset",
|
|
2184
|
-
legend: "\u80CC\u666F",
|
|
2185
|
-
items: [
|
|
2186
|
-
{
|
|
2187
|
-
name: "backgroundImage",
|
|
2188
|
-
text: "\u80CC\u666F\u56FE"
|
|
2189
|
-
},
|
|
2190
|
-
{
|
|
2191
|
-
name: "backgroundColor",
|
|
2192
|
-
text: "\u80CC\u666F\u989C\u8272",
|
|
2193
|
-
type: "colorPicker"
|
|
2194
|
-
},
|
|
2195
|
-
{
|
|
2196
|
-
name: "backgroundRepeat",
|
|
2197
|
-
text: "\u80CC\u666F\u56FE\u91CD\u590D",
|
|
2198
|
-
type: "select",
|
|
2199
|
-
defaultValue: "no-repeat",
|
|
2200
|
-
options: [
|
|
2201
|
-
{ text: "repeat", value: "repeat" },
|
|
2202
|
-
{ text: "repeat-x", value: "repeat-x" },
|
|
2203
|
-
{ text: "repeat-y", value: "repeat-y" },
|
|
2204
|
-
{ text: "no-repeat", value: "no-repeat" },
|
|
2205
|
-
{ text: "inherit", value: "inherit" }
|
|
2206
|
-
]
|
|
2207
|
-
},
|
|
2208
|
-
{
|
|
2209
|
-
name: "backgroundSize",
|
|
2210
|
-
text: "\u80CC\u666F\u56FE\u5927\u5C0F",
|
|
2211
|
-
defaultValue: "100% 100%"
|
|
2212
|
-
}
|
|
2213
|
-
]
|
|
2214
|
-
},
|
|
2215
|
-
{
|
|
2216
|
-
type: "fieldset",
|
|
2217
|
-
legend: "\u5B57\u4F53",
|
|
2218
|
-
items: [
|
|
2219
|
-
{
|
|
2220
|
-
name: "color",
|
|
2221
|
-
text: "\u989C\u8272",
|
|
2222
|
-
type: "colorPicker"
|
|
2223
|
-
},
|
|
2224
|
-
{
|
|
2225
|
-
name: "fontSize",
|
|
2226
|
-
text: "\u5927\u5C0F"
|
|
2227
|
-
},
|
|
2228
|
-
{
|
|
2229
|
-
name: "fontWeight",
|
|
2230
|
-
text: "\u7C97\u7EC6"
|
|
2231
|
-
}
|
|
2232
|
-
]
|
|
2233
|
-
},
|
|
2234
|
-
{
|
|
2235
|
-
type: "fieldset",
|
|
2236
|
-
legend: "\u53D8\u5F62",
|
|
2237
|
-
name: "transform",
|
|
2238
|
-
items: [
|
|
2239
|
-
{
|
|
2240
|
-
name: "rotate",
|
|
2241
|
-
text: "\u65CB\u8F6C\u89D2\u5EA6"
|
|
2242
|
-
},
|
|
2243
|
-
{
|
|
2244
|
-
name: "scale",
|
|
2245
|
-
text: "\u7F29\u653E"
|
|
2246
|
-
}
|
|
2247
|
-
]
|
|
2248
|
-
}
|
|
2249
|
-
]
|
|
2250
|
-
}
|
|
2251
|
-
]
|
|
2252
|
-
},
|
|
2253
|
-
{
|
|
2254
|
-
title: "\u4E8B\u4EF6",
|
|
2255
|
-
items: [
|
|
2256
|
-
{
|
|
2257
|
-
type: "table",
|
|
2258
|
-
name: "events",
|
|
2259
|
-
items: [
|
|
2260
|
-
{
|
|
2261
|
-
name: "name",
|
|
2262
|
-
label: "\u4E8B\u4EF6\u540D",
|
|
2263
|
-
type: "select",
|
|
2264
|
-
options: (mForm, { formValue }) => eventsService.getEvent(formValue.type).map((option) => ({
|
|
2265
|
-
text: option.label,
|
|
2266
|
-
value: option.value
|
|
2267
|
-
}))
|
|
2268
|
-
},
|
|
2269
|
-
{
|
|
2270
|
-
name: "to",
|
|
2271
|
-
label: "\u8054\u52A8\u7EC4\u4EF6",
|
|
2272
|
-
type: "ui-select"
|
|
2273
|
-
},
|
|
2274
|
-
{
|
|
2275
|
-
name: "method",
|
|
2276
|
-
label: "\u52A8\u4F5C",
|
|
2277
|
-
type: "select",
|
|
2278
|
-
options: (mForm, { model }) => {
|
|
2279
|
-
const node = editorService.getNodeById(model.to);
|
|
2280
|
-
if (!node?.type)
|
|
2281
|
-
return [];
|
|
2282
|
-
return eventsService.getMethod(node.type).map((option) => ({
|
|
2283
|
-
text: option.label,
|
|
2284
|
-
value: option.value
|
|
2285
|
-
}));
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
]
|
|
2289
|
-
}
|
|
2290
|
-
]
|
|
2291
|
-
},
|
|
2292
|
-
{
|
|
2293
|
-
title: "\u9AD8\u7EA7",
|
|
2294
|
-
lazy: true,
|
|
2295
|
-
items: [
|
|
2296
|
-
{
|
|
2297
|
-
name: "created",
|
|
2298
|
-
text: "created",
|
|
2299
|
-
labelWidth: "100px",
|
|
2300
|
-
type: "code-select"
|
|
2301
|
-
},
|
|
2302
|
-
{
|
|
2303
|
-
name: "mounted",
|
|
2304
|
-
text: "mounted",
|
|
2305
|
-
labelWidth: "100px",
|
|
2306
|
-
type: "code-select"
|
|
2307
|
-
}
|
|
2308
|
-
]
|
|
2438
|
+
const { node, parent } = this.getNodeInfo(config.id, false);
|
|
2439
|
+
const target = this.getNodeById(targetId, false);
|
|
2440
|
+
const stage = this.get("stage");
|
|
2441
|
+
if (root && node && parent && stage) {
|
|
2442
|
+
const index = getNodeIndex(node, parent);
|
|
2443
|
+
parent.items?.splice(index, 1);
|
|
2444
|
+
await stage.remove({ id: node.id, parentId: parent.id, root });
|
|
2445
|
+
const layout = await this.getLayout(target);
|
|
2446
|
+
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
|
|
2447
|
+
if (Array.isArray(srcValue)) {
|
|
2448
|
+
return srcValue;
|
|
2449
|
+
}
|
|
2450
|
+
});
|
|
2451
|
+
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
2452
|
+
target.items.push(newConfig);
|
|
2453
|
+
await stage.select(targetId);
|
|
2454
|
+
const targetParent = this.getParentById(target.id);
|
|
2455
|
+
await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root });
|
|
2456
|
+
await this.select(newConfig);
|
|
2457
|
+
stage.select(newConfig.id);
|
|
2458
|
+
this.addModifiedNodeId(target.id);
|
|
2459
|
+
this.addModifiedNodeId(parent.id);
|
|
2460
|
+
this.pushHistoryState();
|
|
2461
|
+
return newConfig;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
async undo() {
|
|
2465
|
+
const value = historyService.undo();
|
|
2466
|
+
await this.changeHistoryState(value);
|
|
2467
|
+
return value;
|
|
2468
|
+
}
|
|
2469
|
+
async redo() {
|
|
2470
|
+
const value = historyService.redo();
|
|
2471
|
+
await this.changeHistoryState(value);
|
|
2472
|
+
return value;
|
|
2473
|
+
}
|
|
2474
|
+
async move(left, top) {
|
|
2475
|
+
const node = vue.toRaw(this.get("node"));
|
|
2476
|
+
if (!node || utils.isPage(node))
|
|
2477
|
+
return;
|
|
2478
|
+
const { style, id, type } = node;
|
|
2479
|
+
if (!style || style.position !== "absolute")
|
|
2480
|
+
return;
|
|
2481
|
+
if (top && !utils.isNumber(style.top))
|
|
2482
|
+
return;
|
|
2483
|
+
if (left && !utils.isNumber(style.left))
|
|
2484
|
+
return;
|
|
2485
|
+
this.update({
|
|
2486
|
+
id,
|
|
2487
|
+
type,
|
|
2488
|
+
style: {
|
|
2489
|
+
...style,
|
|
2490
|
+
left: Number(style.left) + left,
|
|
2491
|
+
top: Number(style.top) + top
|
|
2309
2492
|
}
|
|
2310
|
-
|
|
2493
|
+
});
|
|
2311
2494
|
}
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2495
|
+
resetState() {
|
|
2496
|
+
this.set("root", null);
|
|
2497
|
+
this.set("node", null);
|
|
2498
|
+
this.set("nodes", []);
|
|
2499
|
+
this.set("page", null);
|
|
2500
|
+
this.set("parent", null);
|
|
2501
|
+
this.set("stage", null);
|
|
2502
|
+
this.set("highlightNode", null);
|
|
2503
|
+
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
2504
|
+
this.set("pageLength", 0);
|
|
2317
2505
|
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2506
|
+
destroy() {
|
|
2507
|
+
this.removeAllListeners();
|
|
2508
|
+
this.resetState();
|
|
2509
|
+
this.removeAllPlugins();
|
|
2322
2510
|
}
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
if (process.env.NODE_ENV === "development") {
|
|
2326
|
-
console.warn("magic editor: ", ...args);
|
|
2511
|
+
resetModifiedNodeId() {
|
|
2512
|
+
this.get("modifiedNodeIds").clear();
|
|
2327
2513
|
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2514
|
+
addModifiedNodeId(id) {
|
|
2515
|
+
if (!this.isHistoryStateChange) {
|
|
2516
|
+
this.get("modifiedNodeIds").set(id, id);
|
|
2517
|
+
}
|
|
2332
2518
|
}
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2519
|
+
pushHistoryState() {
|
|
2520
|
+
const curNode = lodashEs.cloneDeep(vue.toRaw(this.get("node")));
|
|
2521
|
+
const page = this.get("page");
|
|
2522
|
+
if (!this.isHistoryStateChange && curNode && page) {
|
|
2523
|
+
historyService.push({
|
|
2524
|
+
data: lodashEs.cloneDeep(vue.toRaw(page)),
|
|
2525
|
+
modifiedNodeIds: this.get("modifiedNodeIds"),
|
|
2526
|
+
nodeId: curNode.id
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
this.isHistoryStateChange = false;
|
|
2337
2530
|
}
|
|
2338
|
-
|
|
2531
|
+
async changeHistoryState(value) {
|
|
2532
|
+
if (!value)
|
|
2533
|
+
return;
|
|
2534
|
+
this.isHistoryStateChange = true;
|
|
2535
|
+
await this.update(value.data);
|
|
2536
|
+
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
2537
|
+
setTimeout(async () => {
|
|
2538
|
+
if (!value.nodeId)
|
|
2539
|
+
return;
|
|
2540
|
+
await this.select(value.nodeId);
|
|
2541
|
+
this.get("stage")?.select(value.nodeId);
|
|
2542
|
+
}, 0);
|
|
2543
|
+
this.emit("history-change", value.data);
|
|
2544
|
+
}
|
|
2545
|
+
async toggleFixedPosition(dist, src, root) {
|
|
2546
|
+
const newConfig = lodashEs.cloneDeep(dist);
|
|
2547
|
+
if (!utils.isPop(src) && newConfig.style?.position) {
|
|
2548
|
+
if (isFixed(newConfig) && !isFixed(src)) {
|
|
2549
|
+
newConfig.style = change2Fixed(newConfig, root);
|
|
2550
|
+
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
2551
|
+
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
return newConfig;
|
|
2555
|
+
}
|
|
2556
|
+
selectedConfigExceptionHandler(config) {
|
|
2557
|
+
let id;
|
|
2558
|
+
if (typeof config === "string" || typeof config === "number") {
|
|
2559
|
+
id = config;
|
|
2560
|
+
} else {
|
|
2561
|
+
id = config.id;
|
|
2562
|
+
}
|
|
2563
|
+
if (!id) {
|
|
2564
|
+
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
2565
|
+
}
|
|
2566
|
+
const { node, parent, page } = this.getNodeInfo(id);
|
|
2567
|
+
if (!node)
|
|
2568
|
+
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
2569
|
+
if (node.id === this.state.root?.id) {
|
|
2570
|
+
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
2571
|
+
}
|
|
2572
|
+
return {
|
|
2573
|
+
node,
|
|
2574
|
+
parent,
|
|
2575
|
+
page
|
|
2576
|
+
};
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
const editorService = new Editor$1();
|
|
2339
2580
|
|
|
2340
2581
|
const state = vue.reactive({
|
|
2341
2582
|
uiSelectMode: false,
|
|
@@ -2535,7 +2776,7 @@
|
|
|
2535
2776
|
onClick: clickHandler
|
|
2536
2777
|
}, [
|
|
2537
2778
|
vue.createElementVNode("div", null, [
|
|
2538
|
-
vue.createVNode(_sfc_main$
|
|
2779
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
2539
2780
|
]),
|
|
2540
2781
|
_hoisted_3$3
|
|
2541
2782
|
])
|
|
@@ -2766,7 +3007,7 @@
|
|
|
2766
3007
|
disabled: vue.unref(disabled)
|
|
2767
3008
|
}, {
|
|
2768
3009
|
default: vue.withCtx(() => [
|
|
2769
|
-
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3010
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
|
|
2770
3011
|
key: 0,
|
|
2771
3012
|
icon: __props.data.icon
|
|
2772
3013
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -2783,7 +3024,7 @@
|
|
|
2783
3024
|
disabled: vue.unref(disabled)
|
|
2784
3025
|
}, {
|
|
2785
3026
|
default: vue.withCtx(() => [
|
|
2786
|
-
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3027
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
|
|
2787
3028
|
key: 0,
|
|
2788
3029
|
icon: __props.data.icon
|
|
2789
3030
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -3141,14 +3382,17 @@
|
|
|
3141
3382
|
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3142
3383
|
if (codeDraft) {
|
|
3143
3384
|
design.tMagicMessageBox.confirm("\u60A8\u6709\u4EE3\u7801\u4FEE\u6539\u672A\u4FDD\u5B58\uFF0C\u662F\u5426\u4FDD\u5B58\u540E\u518D\u5173\u95ED\uFF1F", "\u63D0\u793A", {
|
|
3144
|
-
confirmButtonText: "\
|
|
3145
|
-
cancelButtonText: "\
|
|
3146
|
-
type: "warning"
|
|
3385
|
+
confirmButtonText: "\u4FDD\u5B58\u5E76\u5173\u95ED",
|
|
3386
|
+
cancelButtonText: "\u76F4\u63A5\u5173\u95ED",
|
|
3387
|
+
type: "warning",
|
|
3388
|
+
distinguishCancelAndClose: true
|
|
3147
3389
|
}).then(async () => {
|
|
3148
3390
|
saveAndClose();
|
|
3149
|
-
}).catch(() => {
|
|
3150
|
-
|
|
3151
|
-
|
|
3391
|
+
}).catch((action) => {
|
|
3392
|
+
if (action === "cancel") {
|
|
3393
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3394
|
+
emit("close");
|
|
3395
|
+
}
|
|
3152
3396
|
});
|
|
3153
3397
|
} else {
|
|
3154
3398
|
emit("close");
|
|
@@ -3489,22 +3733,10 @@
|
|
|
3489
3733
|
const _hoisted_4 = ["id"];
|
|
3490
3734
|
const _hoisted_5 = { class: "list-item" };
|
|
3491
3735
|
const _hoisted_6 = { class: "code-name" };
|
|
3492
|
-
const _hoisted_7 = {
|
|
3493
|
-
const _hoisted_8 = {
|
|
3736
|
+
const _hoisted_7 = {
|
|
3494
3737
|
key: 0,
|
|
3495
|
-
class: "
|
|
3738
|
+
class: "right-tool"
|
|
3496
3739
|
};
|
|
3497
|
-
const _hoisted_9 = /* @__PURE__ */ vue.createElementVNode("svg", {
|
|
3498
|
-
class: "arrow-left",
|
|
3499
|
-
viewBox: "0 0 1024 1024",
|
|
3500
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3501
|
-
"data-v-029747aa": ""
|
|
3502
|
-
}, [
|
|
3503
|
-
/* @__PURE__ */ vue.createElementVNode("path", {
|
|
3504
|
-
fill: "currentColor",
|
|
3505
|
-
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"
|
|
3506
|
-
})
|
|
3507
|
-
], -1);
|
|
3508
3740
|
const __default__$d = vue.defineComponent({
|
|
3509
3741
|
name: "MEditorCodeBlockList"
|
|
3510
3742
|
});
|
|
@@ -3516,64 +3748,23 @@
|
|
|
3516
3748
|
},
|
|
3517
3749
|
setup(__props) {
|
|
3518
3750
|
const props = __props;
|
|
3519
|
-
const
|
|
3520
|
-
const
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
bindsComp.push({
|
|
3533
|
-
compId,
|
|
3534
|
-
compName: getCompName(compId)
|
|
3535
|
-
});
|
|
3536
|
-
}
|
|
3537
|
-
});
|
|
3538
|
-
return bindsComp;
|
|
3539
|
-
};
|
|
3540
|
-
const refreshCodeList = async () => {
|
|
3541
|
-
const codeDsl = lodashEs.cloneDeep(await services?.codeBlockService.getCodeDsl()) || null;
|
|
3542
|
-
codeCombineInfo.value = lodashEs.cloneDeep(services?.codeBlockService.getCombineInfo()) || null;
|
|
3543
|
-
if (!codeDsl || !codeCombineInfo.value)
|
|
3544
|
-
return;
|
|
3545
|
-
state.codeList = [];
|
|
3546
|
-
lodashEs.forIn(codeDsl, (value, codeId) => {
|
|
3547
|
-
state.codeList.push({
|
|
3548
|
-
id: codeId,
|
|
3549
|
-
name: value.name,
|
|
3550
|
-
codeBlockContent: value,
|
|
3551
|
-
showRelation: true,
|
|
3552
|
-
combineInfo: getBindCompsByCodeId(codeId)
|
|
3553
|
-
});
|
|
3554
|
-
});
|
|
3555
|
-
};
|
|
3556
|
-
vue.watch(
|
|
3557
|
-
() => services?.editorService.get("root"),
|
|
3558
|
-
() => {
|
|
3559
|
-
services?.codeBlockService.refreshAllRelations();
|
|
3560
|
-
refreshCodeList();
|
|
3561
|
-
},
|
|
3562
|
-
{
|
|
3563
|
-
immediate: true
|
|
3564
|
-
}
|
|
3565
|
-
);
|
|
3566
|
-
vue.watch(
|
|
3567
|
-
[() => services?.codeBlockService.getCodeDsl(), () => services?.codeBlockService.getCombineInfo()],
|
|
3568
|
-
() => {
|
|
3569
|
-
refreshCodeList();
|
|
3570
|
-
},
|
|
3571
|
-
{
|
|
3572
|
-
deep: true
|
|
3573
|
-
}
|
|
3751
|
+
const { codeBlockService, depService, editorService } = vue.inject("services") || {};
|
|
3752
|
+
const codeList = vue.computed(
|
|
3753
|
+
() => Object.values(depService?.targets["code-block"] || {}).map((target) => ({
|
|
3754
|
+
id: target.id,
|
|
3755
|
+
name: target.name,
|
|
3756
|
+
type: "code",
|
|
3757
|
+
children: Object.entries(target.deps).map(([id, dep]) => ({
|
|
3758
|
+
name: dep.name,
|
|
3759
|
+
type: "node",
|
|
3760
|
+
id,
|
|
3761
|
+
children: dep.keys.map((key) => ({ name: key, id: key, type: "key" }))
|
|
3762
|
+
}))
|
|
3763
|
+
}))
|
|
3574
3764
|
);
|
|
3765
|
+
const editable = vue.computed(() => codeBlockService?.getEditStatus());
|
|
3766
|
+
const isShowCodeBlockEditor = vue.computed(() => codeBlockService?.getCodeEditorShowStatus() || false);
|
|
3575
3767
|
const createCodeBlock = async () => {
|
|
3576
|
-
const { codeBlockService } = services || {};
|
|
3577
3768
|
if (!codeBlockService) {
|
|
3578
3769
|
design.tMagicMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
|
|
3579
3770
|
return;
|
|
@@ -3590,14 +3781,14 @@
|
|
|
3590
3781
|
codeBlockService.setCodeEditorContent(true, id);
|
|
3591
3782
|
};
|
|
3592
3783
|
const editCode = async (key) => {
|
|
3593
|
-
|
|
3784
|
+
codeBlockService?.setCodeEditorContent(true, key);
|
|
3594
3785
|
};
|
|
3595
3786
|
const deleteCode = (key) => {
|
|
3596
|
-
const currentCode =
|
|
3597
|
-
const existBinds =
|
|
3598
|
-
const undeleteableList =
|
|
3787
|
+
const currentCode = codeList.value.find((codeItem) => codeItem.id === key);
|
|
3788
|
+
const existBinds = Boolean(currentCode?.children.length);
|
|
3789
|
+
const undeleteableList = codeBlockService?.getUndeletableList() || [];
|
|
3599
3790
|
if (!existBinds && !undeleteableList.includes(key)) {
|
|
3600
|
-
|
|
3791
|
+
codeBlockService?.deleteCodeDslByIds([key]);
|
|
3601
3792
|
} else {
|
|
3602
3793
|
if (typeof props.customError === "function") {
|
|
3603
3794
|
props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
|
|
@@ -3612,27 +3803,23 @@
|
|
|
3612
3803
|
if (!value) {
|
|
3613
3804
|
return true;
|
|
3614
3805
|
}
|
|
3615
|
-
return `${data.name}${data.id}`.indexOf(value) !== -1;
|
|
3806
|
+
return `${data.name}${data.id}`.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) !== -1;
|
|
3616
3807
|
};
|
|
3617
3808
|
const filterTextChangeHandler = (val) => {
|
|
3618
3809
|
tree.value?.filter(val);
|
|
3619
3810
|
};
|
|
3620
|
-
const toggleCombineRelation = (data) => {
|
|
3621
|
-
const { id } = data;
|
|
3622
|
-
const currentCode = state.codeList.find((item) => item.id === id);
|
|
3623
|
-
if (!currentCode)
|
|
3624
|
-
return;
|
|
3625
|
-
currentCode.showRelation = !currentCode?.showRelation;
|
|
3626
|
-
};
|
|
3627
|
-
const getCompName = (compId) => {
|
|
3628
|
-
const node = services?.editorService.getNodeById(compId);
|
|
3629
|
-
return node?.name || String(compId);
|
|
3630
|
-
};
|
|
3631
3811
|
const selectComp = (compId) => {
|
|
3632
|
-
const stage =
|
|
3633
|
-
|
|
3812
|
+
const stage = editorService?.get("stage");
|
|
3813
|
+
editorService?.select(compId);
|
|
3634
3814
|
stage?.select(compId);
|
|
3635
3815
|
};
|
|
3816
|
+
const clickHandler = (data, node) => {
|
|
3817
|
+
if (data.type === "node") {
|
|
3818
|
+
selectComp(data.id);
|
|
3819
|
+
} else if (data.type === "key") {
|
|
3820
|
+
selectComp(node.parent.data.id);
|
|
3821
|
+
}
|
|
3822
|
+
};
|
|
3636
3823
|
return (_ctx, _cache) => {
|
|
3637
3824
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
3638
3825
|
vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
@@ -3662,16 +3849,18 @@
|
|
|
3662
3849
|
]),
|
|
3663
3850
|
vue.createVNode(vue.unref(design.TMagicScrollbar), null, {
|
|
3664
3851
|
default: vue.withCtx(() => [
|
|
3665
|
-
|
|
3666
|
-
key: 0,
|
|
3852
|
+
vue.createVNode(vue.unref(design.TMagicTree), {
|
|
3667
3853
|
ref_key: "tree",
|
|
3668
3854
|
ref: tree,
|
|
3855
|
+
class: "magic-editor-layer-tree",
|
|
3669
3856
|
"node-key": "id",
|
|
3670
3857
|
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3671
|
-
|
|
3858
|
+
"default-expand-all": "",
|
|
3859
|
+
"expand-on-click-node": false,
|
|
3860
|
+
data: vue.unref(codeList),
|
|
3672
3861
|
"highlight-current": true,
|
|
3673
3862
|
"filter-node-method": filterNode,
|
|
3674
|
-
onNodeClick:
|
|
3863
|
+
onNodeClick: clickHandler
|
|
3675
3864
|
}, {
|
|
3676
3865
|
default: vue.withCtx(({ data }) => [
|
|
3677
3866
|
vue.createElementVNode("div", {
|
|
@@ -3680,14 +3869,14 @@
|
|
|
3680
3869
|
}, [
|
|
3681
3870
|
vue.createElementVNode("div", _hoisted_5, [
|
|
3682
3871
|
vue.createElementVNode("span", _hoisted_6, vue.toDisplayString(data.name) + "\uFF08" + vue.toDisplayString(data.id) + "\uFF09", 1),
|
|
3683
|
-
vue.
|
|
3872
|
+
data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
|
|
3684
3873
|
vue.createVNode(vue.unref(design.TMagicTooltip), {
|
|
3685
3874
|
effect: "dark",
|
|
3686
3875
|
content: vue.unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
|
|
3687
3876
|
placement: "bottom"
|
|
3688
3877
|
}, {
|
|
3689
3878
|
default: vue.withCtx(() => [
|
|
3690
|
-
vue.createVNode(_sfc_main$
|
|
3879
|
+
vue.createVNode(_sfc_main$u, {
|
|
3691
3880
|
icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
|
|
3692
3881
|
class: "edit-icon",
|
|
3693
3882
|
onClick: vue.withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
@@ -3695,29 +3884,14 @@
|
|
|
3695
3884
|
]),
|
|
3696
3885
|
_: 2
|
|
3697
3886
|
}, 1032, ["content"]),
|
|
3698
|
-
data.combineInfo && data.combineInfo.length > 0 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
3699
|
-
key: 0,
|
|
3700
|
-
effect: "dark",
|
|
3701
|
-
content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
|
|
3702
|
-
placement: "bottom"
|
|
3703
|
-
}, {
|
|
3704
|
-
default: vue.withCtx(() => [
|
|
3705
|
-
vue.createVNode(_sfc_main$s, {
|
|
3706
|
-
icon: vue.unref(iconsVue.Link),
|
|
3707
|
-
class: "edit-icon",
|
|
3708
|
-
onClick: vue.withModifiers(($event) => toggleCombineRelation(data), ["stop"])
|
|
3709
|
-
}, null, 8, ["icon", "onClick"])
|
|
3710
|
-
]),
|
|
3711
|
-
_: 2
|
|
3712
|
-
}, 1024)) : vue.createCommentVNode("", true),
|
|
3713
3887
|
vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
3714
|
-
key:
|
|
3888
|
+
key: 0,
|
|
3715
3889
|
effect: "dark",
|
|
3716
3890
|
content: "\u5220\u9664",
|
|
3717
3891
|
placement: "bottom"
|
|
3718
3892
|
}, {
|
|
3719
3893
|
default: vue.withCtx(() => [
|
|
3720
|
-
vue.createVNode(_sfc_main$
|
|
3894
|
+
vue.createVNode(_sfc_main$u, {
|
|
3721
3895
|
icon: vue.unref(iconsVue.Close),
|
|
3722
3896
|
class: "edit-icon",
|
|
3723
3897
|
onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
@@ -3729,29 +3903,12 @@
|
|
|
3729
3903
|
id: data.id,
|
|
3730
3904
|
data: data.codeBlockContent
|
|
3731
3905
|
})
|
|
3732
|
-
])
|
|
3733
|
-
])
|
|
3734
|
-
data.showRelation && data.combineInfo && data.combineInfo.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
|
|
3735
|
-
_hoisted_9,
|
|
3736
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(data.combineInfo, (comp, index) => {
|
|
3737
|
-
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
3738
|
-
key: index,
|
|
3739
|
-
class: "code-comp",
|
|
3740
|
-
size: "small",
|
|
3741
|
-
plain: true,
|
|
3742
|
-
onClick: vue.withModifiers(($event) => selectComp(comp.compId), ["stop"])
|
|
3743
|
-
}, {
|
|
3744
|
-
default: vue.withCtx(() => [
|
|
3745
|
-
vue.createTextVNode(vue.toDisplayString(comp.compName), 1)
|
|
3746
|
-
]),
|
|
3747
|
-
_: 2
|
|
3748
|
-
}, 1032, ["onClick"]);
|
|
3749
|
-
}), 128))
|
|
3750
|
-
])) : vue.createCommentVNode("", true)
|
|
3906
|
+
])) : vue.createCommentVNode("", true)
|
|
3907
|
+
])
|
|
3751
3908
|
], 8, _hoisted_4)
|
|
3752
3909
|
]),
|
|
3753
3910
|
_: 3
|
|
3754
|
-
}, 8, ["data"])
|
|
3911
|
+
}, 8, ["data"])
|
|
3755
3912
|
]),
|
|
3756
3913
|
_: 3
|
|
3757
3914
|
}),
|
|
@@ -3863,7 +4020,7 @@
|
|
|
3863
4020
|
name: `${index}`
|
|
3864
4021
|
}, {
|
|
3865
4022
|
title: vue.withCtx(() => [
|
|
3866
|
-
vue.createVNode(_sfc_main$
|
|
4023
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
|
|
3867
4024
|
vue.createTextVNode(vue.toDisplayString(group.title), 1)
|
|
3868
4025
|
]),
|
|
3869
4026
|
default: vue.withCtx(() => [
|
|
@@ -3878,7 +4035,7 @@
|
|
|
3878
4035
|
onDrag: dragHandler
|
|
3879
4036
|
}, [
|
|
3880
4037
|
vue.renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
3881
|
-
vue.createVNode(_sfc_main$
|
|
4038
|
+
vue.createVNode(_sfc_main$u, {
|
|
3882
4039
|
icon: item.icon
|
|
3883
4040
|
}, null, 8, ["icon"]),
|
|
3884
4041
|
vue.createVNode(vue.unref(design.TMagicTooltip), {
|
|
@@ -4479,7 +4636,7 @@
|
|
|
4479
4636
|
(vue.openBlock(), vue.createElementBlock("div", {
|
|
4480
4637
|
key: config.text
|
|
4481
4638
|
}, [
|
|
4482
|
-
config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
4639
|
+
config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
|
|
4483
4640
|
key: 0,
|
|
4484
4641
|
icon: config.icon
|
|
4485
4642
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -4700,14 +4857,14 @@
|
|
|
4700
4857
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4701
4858
|
onClick: addPage
|
|
4702
4859
|
}, [
|
|
4703
|
-
vue.createVNode(_sfc_main$
|
|
4860
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
4704
4861
|
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1)),
|
|
4705
4862
|
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
4706
4863
|
key: 2,
|
|
4707
4864
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4708
4865
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
4709
4866
|
}, [
|
|
4710
|
-
vue.createVNode(_sfc_main$
|
|
4867
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
|
|
4711
4868
|
])) : vue.createCommentVNode("", true),
|
|
4712
4869
|
vue.unref(pageLength) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
4713
4870
|
key: 3,
|
|
@@ -4723,7 +4880,7 @@
|
|
|
4723
4880
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4724
4881
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
4725
4882
|
}, [
|
|
4726
|
-
vue.createVNode(_sfc_main$
|
|
4883
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
|
|
4727
4884
|
])) : vue.createCommentVNode("", true)
|
|
4728
4885
|
], 512);
|
|
4729
4886
|
};
|
|
@@ -5614,8 +5771,7 @@
|
|
|
5614
5771
|
id: "",
|
|
5615
5772
|
editable: true,
|
|
5616
5773
|
combineIds: [],
|
|
5617
|
-
undeletableList: []
|
|
5618
|
-
relations: {}
|
|
5774
|
+
undeletableList: []
|
|
5619
5775
|
});
|
|
5620
5776
|
constructor() {
|
|
5621
5777
|
super([
|
|
@@ -5660,6 +5816,7 @@
|
|
|
5660
5816
|
...existContent,
|
|
5661
5817
|
...codeConfigProcessed
|
|
5662
5818
|
};
|
|
5819
|
+
this.emit("addOrUpdate", id, codeDsl[id]);
|
|
5663
5820
|
}
|
|
5664
5821
|
async getCodeDslByIds(ids) {
|
|
5665
5822
|
const codeDsl2 = await this.getCodeDsl();
|
|
@@ -5700,39 +5857,6 @@
|
|
|
5700
5857
|
getCombineIds() {
|
|
5701
5858
|
return this.state.combineIds;
|
|
5702
5859
|
}
|
|
5703
|
-
addCodeRelationListener() {
|
|
5704
|
-
editorService.on("update", (nodes) => {
|
|
5705
|
-
const relations = lodashEs.cloneDeep(this.state.relations);
|
|
5706
|
-
nodes.forEach((node) => {
|
|
5707
|
-
if (node?.id) {
|
|
5708
|
-
relations[node.id] = [];
|
|
5709
|
-
this.getNodeRelation(node, relations);
|
|
5710
|
-
}
|
|
5711
|
-
});
|
|
5712
|
-
this.state.relations = { ...relations };
|
|
5713
|
-
});
|
|
5714
|
-
editorService.on("remove", (nodes) => {
|
|
5715
|
-
nodes.forEach((node) => {
|
|
5716
|
-
this.state.relations = this.deleteNodeRelation(node, this.state.relations);
|
|
5717
|
-
});
|
|
5718
|
-
});
|
|
5719
|
-
editorService.on("history-change", (page) => {
|
|
5720
|
-
const relations = {};
|
|
5721
|
-
this.getNodeRelation(page, relations, true);
|
|
5722
|
-
this.state.relations = relations;
|
|
5723
|
-
});
|
|
5724
|
-
}
|
|
5725
|
-
refreshAllRelations() {
|
|
5726
|
-
const root = editorService.get("root");
|
|
5727
|
-
if (!root)
|
|
5728
|
-
return;
|
|
5729
|
-
const relations = {};
|
|
5730
|
-
this.getNodeRelation(root, relations, true);
|
|
5731
|
-
this.state.relations = relations;
|
|
5732
|
-
}
|
|
5733
|
-
getCombineInfo() {
|
|
5734
|
-
return this.state.relations;
|
|
5735
|
-
}
|
|
5736
5860
|
getUndeletableList() {
|
|
5737
5861
|
return this.state.undeletableList;
|
|
5738
5862
|
}
|
|
@@ -5754,88 +5878,268 @@
|
|
|
5754
5878
|
return;
|
|
5755
5879
|
codeIds.forEach((id2) => {
|
|
5756
5880
|
delete currentDsl[id2];
|
|
5881
|
+
this.emit("remove", id2);
|
|
5757
5882
|
});
|
|
5758
5883
|
}
|
|
5759
|
-
async getUniqueId() {
|
|
5760
|
-
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
5761
|
-
const dsl = await this.getCodeDsl();
|
|
5762
|
-
const existedIds = lodashEs.keys(dsl);
|
|
5763
|
-
if (!existedIds.includes(newId))
|
|
5764
|
-
return newId;
|
|
5765
|
-
return await this.getUniqueId();
|
|
5884
|
+
async getUniqueId() {
|
|
5885
|
+
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
5886
|
+
const dsl = await this.getCodeDsl();
|
|
5887
|
+
const existedIds = lodashEs.keys(dsl);
|
|
5888
|
+
if (!existedIds.includes(newId))
|
|
5889
|
+
return newId;
|
|
5890
|
+
return await this.getUniqueId();
|
|
5891
|
+
}
|
|
5892
|
+
resetState() {
|
|
5893
|
+
this.state.isShowCodeEditor = false;
|
|
5894
|
+
this.state.codeDsl = null;
|
|
5895
|
+
this.state.id = "";
|
|
5896
|
+
this.state.editable = true;
|
|
5897
|
+
this.state.combineIds = [];
|
|
5898
|
+
this.state.undeletableList = [];
|
|
5899
|
+
}
|
|
5900
|
+
destroy() {
|
|
5901
|
+
this.resetState();
|
|
5902
|
+
this.removeAllListeners();
|
|
5903
|
+
this.removeAllPlugins();
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
5906
|
+
const codeBlockService = new CodeBlock();
|
|
5907
|
+
|
|
5908
|
+
class ComponentList extends BaseService {
|
|
5909
|
+
state = vue.reactive({
|
|
5910
|
+
list: []
|
|
5911
|
+
});
|
|
5912
|
+
constructor() {
|
|
5913
|
+
super([]);
|
|
5914
|
+
}
|
|
5915
|
+
setList(componentGroupList) {
|
|
5916
|
+
this.state.list = componentGroupList;
|
|
5917
|
+
}
|
|
5918
|
+
getList() {
|
|
5919
|
+
return this.state.list;
|
|
5766
5920
|
}
|
|
5767
5921
|
resetState() {
|
|
5768
|
-
this.state.
|
|
5769
|
-
this.state.codeDsl = null;
|
|
5770
|
-
this.state.id = "";
|
|
5771
|
-
this.state.editable = true;
|
|
5772
|
-
this.state.combineIds = [];
|
|
5773
|
-
this.state.undeletableList = [];
|
|
5922
|
+
this.state.list = [];
|
|
5774
5923
|
}
|
|
5775
5924
|
destroy() {
|
|
5776
5925
|
this.resetState();
|
|
5777
5926
|
this.removeAllListeners();
|
|
5778
5927
|
this.removeAllPlugins();
|
|
5779
5928
|
}
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5929
|
+
}
|
|
5930
|
+
const componentListService = new ComponentList();
|
|
5931
|
+
|
|
5932
|
+
class Target extends events.EventEmitter {
|
|
5933
|
+
isTarget;
|
|
5934
|
+
id;
|
|
5935
|
+
name;
|
|
5936
|
+
type = "default";
|
|
5937
|
+
deps = vue.reactive({});
|
|
5938
|
+
constructor(options) {
|
|
5939
|
+
super();
|
|
5940
|
+
this.isTarget = options.isTarget;
|
|
5941
|
+
this.id = options.id;
|
|
5942
|
+
this.name = options.name;
|
|
5943
|
+
if (options.type) {
|
|
5944
|
+
this.type = options.type;
|
|
5945
|
+
}
|
|
5946
|
+
}
|
|
5947
|
+
updateDep(node, key) {
|
|
5948
|
+
const dep = this.deps[node.id] || {
|
|
5949
|
+
name: node.name,
|
|
5950
|
+
keys: []
|
|
5951
|
+
};
|
|
5952
|
+
if (node.name) {
|
|
5953
|
+
dep.name = node.name;
|
|
5954
|
+
}
|
|
5955
|
+
this.deps[node.id] = dep;
|
|
5956
|
+
if (dep.keys.indexOf(key) === -1) {
|
|
5957
|
+
dep.keys.push(key);
|
|
5958
|
+
}
|
|
5959
|
+
this.emit("change");
|
|
5960
|
+
}
|
|
5961
|
+
removeDep(node, key) {
|
|
5962
|
+
if (!node) {
|
|
5963
|
+
Object.keys(this.deps).forEach((depKey) => {
|
|
5964
|
+
delete this.deps[depKey];
|
|
5965
|
+
});
|
|
5966
|
+
this.emit("change");
|
|
5967
|
+
return;
|
|
5968
|
+
}
|
|
5969
|
+
const dep = this.deps[node.id];
|
|
5970
|
+
if (!dep)
|
|
5971
|
+
return;
|
|
5972
|
+
if (key) {
|
|
5973
|
+
const index = dep.keys.indexOf(key);
|
|
5974
|
+
dep.keys.splice(index, 1);
|
|
5975
|
+
if (dep.keys.length === 0) {
|
|
5976
|
+
delete this.deps[node.id];
|
|
5789
5977
|
}
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5978
|
+
} else {
|
|
5979
|
+
delete this.deps[node.id];
|
|
5980
|
+
}
|
|
5981
|
+
this.emit("change");
|
|
5982
|
+
}
|
|
5983
|
+
hasDep(node, key) {
|
|
5984
|
+
const dep = this.deps[node.id];
|
|
5985
|
+
return Boolean(dep?.keys.find((d) => d === key));
|
|
5986
|
+
}
|
|
5987
|
+
destroy() {
|
|
5988
|
+
this.removeAllListeners();
|
|
5989
|
+
}
|
|
5990
|
+
}
|
|
5991
|
+
class Watcher extends events.EventEmitter {
|
|
5992
|
+
targets = vue.reactive({});
|
|
5993
|
+
getTargets(type = "default") {
|
|
5994
|
+
return this.targets[type] || {};
|
|
5995
|
+
}
|
|
5996
|
+
addTarget(target) {
|
|
5997
|
+
const targets = this.getTargets(target.type) || {};
|
|
5998
|
+
this.targets[target.type] = targets;
|
|
5999
|
+
targets[target.id] = target;
|
|
6000
|
+
this.emit("add-target", target);
|
|
6001
|
+
}
|
|
6002
|
+
getTarget(id) {
|
|
6003
|
+
const allTargets = Object.values(this.targets);
|
|
6004
|
+
for (const targets of allTargets) {
|
|
6005
|
+
if (targets[id]) {
|
|
6006
|
+
return targets[id];
|
|
5795
6007
|
}
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
6008
|
+
}
|
|
6009
|
+
}
|
|
6010
|
+
hasTarget(id) {
|
|
6011
|
+
const allTargets = Object.values(this.targets);
|
|
6012
|
+
for (const targets of allTargets) {
|
|
6013
|
+
if (targets[id]) {
|
|
6014
|
+
return true;
|
|
5802
6015
|
}
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
6016
|
+
}
|
|
6017
|
+
return false;
|
|
6018
|
+
}
|
|
6019
|
+
removeTarget(id) {
|
|
6020
|
+
const allTargets = Object.values(this.targets);
|
|
6021
|
+
for (const targets of allTargets) {
|
|
6022
|
+
if (targets[id]) {
|
|
6023
|
+
targets[id].destroy();
|
|
6024
|
+
delete targets[id];
|
|
5807
6025
|
}
|
|
6026
|
+
}
|
|
6027
|
+
this.emit("remove-target");
|
|
6028
|
+
}
|
|
6029
|
+
removeTargets(type = "default") {
|
|
6030
|
+
const targets = this.targets[type];
|
|
6031
|
+
if (!targets)
|
|
6032
|
+
return;
|
|
6033
|
+
for (const target of Object.values(targets)) {
|
|
6034
|
+
target.destroy();
|
|
6035
|
+
}
|
|
6036
|
+
delete this.targets[type];
|
|
6037
|
+
this.emit("remove-target");
|
|
6038
|
+
}
|
|
6039
|
+
clearTargets() {
|
|
6040
|
+
Object.keys(this.targets).forEach((key) => {
|
|
6041
|
+
delete this.targets[key];
|
|
6042
|
+
});
|
|
6043
|
+
}
|
|
6044
|
+
collect(nodes, deep = false) {
|
|
6045
|
+
Object.values(this.targets).forEach((targets) => {
|
|
6046
|
+
Object.values(targets).forEach((target) => {
|
|
6047
|
+
nodes.forEach((node) => {
|
|
6048
|
+
target.removeDep(node);
|
|
6049
|
+
this.collectItem(node, target, deep);
|
|
6050
|
+
});
|
|
6051
|
+
});
|
|
5808
6052
|
});
|
|
5809
6053
|
}
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
6054
|
+
clear(nodes) {
|
|
6055
|
+
Object.values(this.targets).forEach((targets) => {
|
|
6056
|
+
Object.values(targets).forEach((target) => {
|
|
6057
|
+
if (nodes) {
|
|
6058
|
+
nodes.forEach((node) => {
|
|
6059
|
+
target.removeDep(node);
|
|
6060
|
+
if (Array.isArray(node.items)) {
|
|
6061
|
+
this.clear(node.items);
|
|
6062
|
+
}
|
|
6063
|
+
});
|
|
6064
|
+
} else {
|
|
6065
|
+
target.removeDep();
|
|
6066
|
+
}
|
|
5817
6067
|
});
|
|
5818
|
-
}
|
|
5819
|
-
|
|
6068
|
+
});
|
|
6069
|
+
}
|
|
6070
|
+
collectItem(node, target, deep = false) {
|
|
6071
|
+
const collectTarget = (config, prop = "") => {
|
|
6072
|
+
const doCollect = (key, value) => {
|
|
6073
|
+
const keyIsItems = key === "items";
|
|
6074
|
+
const fullKey = prop ? `${prop}.${key}` : key;
|
|
6075
|
+
if (target.isTarget(key, value)) {
|
|
6076
|
+
target.updateDep(node, fullKey);
|
|
6077
|
+
} else if (!keyIsItems && Array.isArray(value)) {
|
|
6078
|
+
value.forEach((item, index) => {
|
|
6079
|
+
collectTarget(item, `${fullKey}.${index}`);
|
|
6080
|
+
});
|
|
6081
|
+
} else if (Object.prototype.toString.call(value) === "[object Object]") {
|
|
6082
|
+
collectTarget(value, fullKey);
|
|
6083
|
+
}
|
|
6084
|
+
if (keyIsItems && deep && Array.isArray(value)) {
|
|
6085
|
+
value.forEach((child) => {
|
|
6086
|
+
this.collectItem(child, target, deep);
|
|
6087
|
+
});
|
|
6088
|
+
}
|
|
6089
|
+
};
|
|
6090
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
6091
|
+
doCollect(key, value);
|
|
6092
|
+
});
|
|
6093
|
+
};
|
|
6094
|
+
collectTarget(node);
|
|
5820
6095
|
}
|
|
5821
6096
|
}
|
|
5822
|
-
const
|
|
6097
|
+
const depService = new Watcher();
|
|
5823
6098
|
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
});
|
|
6099
|
+
let eventMap = vue.reactive({});
|
|
6100
|
+
let methodMap = vue.reactive({});
|
|
6101
|
+
class Events extends BaseService {
|
|
5828
6102
|
constructor() {
|
|
5829
6103
|
super([]);
|
|
5830
6104
|
}
|
|
5831
|
-
|
|
5832
|
-
|
|
6105
|
+
init(componentGroupList) {
|
|
6106
|
+
componentGroupList.forEach((group) => {
|
|
6107
|
+
group.items.forEach((element) => {
|
|
6108
|
+
const type = utils.toLine(element.type);
|
|
6109
|
+
if (!this.getEvent(type)) {
|
|
6110
|
+
this.setEvent(type, core.DEFAULT_EVENTS);
|
|
6111
|
+
}
|
|
6112
|
+
if (!this.getMethod(type)) {
|
|
6113
|
+
this.setMethod(type, core.DEFAULT_METHODS);
|
|
6114
|
+
}
|
|
6115
|
+
});
|
|
6116
|
+
});
|
|
5833
6117
|
}
|
|
5834
|
-
|
|
5835
|
-
|
|
6118
|
+
setEvents(events) {
|
|
6119
|
+
Object.keys(events).forEach((type) => {
|
|
6120
|
+
this.setEvent(utils.toLine(type), events[type] || []);
|
|
6121
|
+
});
|
|
6122
|
+
}
|
|
6123
|
+
setEvent(type, events) {
|
|
6124
|
+
eventMap[type] = [...core.DEFAULT_EVENTS, ...events];
|
|
6125
|
+
}
|
|
6126
|
+
getEvent(type) {
|
|
6127
|
+
return lodashEs.cloneDeep(eventMap[type] || core.DEFAULT_EVENTS);
|
|
6128
|
+
}
|
|
6129
|
+
setMethods(methods) {
|
|
6130
|
+
Object.keys(methods).forEach((type) => {
|
|
6131
|
+
this.setMethod(utils.toLine(type), methods[type] || []);
|
|
6132
|
+
});
|
|
6133
|
+
}
|
|
6134
|
+
setMethod(type, method) {
|
|
6135
|
+
methodMap[type] = [...core.DEFAULT_METHODS, ...method];
|
|
6136
|
+
}
|
|
6137
|
+
getMethod(type) {
|
|
6138
|
+
return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
|
|
5836
6139
|
}
|
|
5837
6140
|
resetState() {
|
|
5838
|
-
|
|
6141
|
+
eventMap = vue.reactive({});
|
|
6142
|
+
methodMap = vue.reactive({});
|
|
5839
6143
|
}
|
|
5840
6144
|
destroy() {
|
|
5841
6145
|
this.resetState();
|
|
@@ -5843,7 +6147,252 @@
|
|
|
5843
6147
|
this.removeAllPlugins();
|
|
5844
6148
|
}
|
|
5845
6149
|
}
|
|
5846
|
-
const
|
|
6150
|
+
const eventsService = new Events();
|
|
6151
|
+
|
|
6152
|
+
const editorProps = {
|
|
6153
|
+
modelValue: {
|
|
6154
|
+
type: Object,
|
|
6155
|
+
default: () => ({}),
|
|
6156
|
+
require: true
|
|
6157
|
+
},
|
|
6158
|
+
componentGroupList: {
|
|
6159
|
+
type: Array,
|
|
6160
|
+
default: () => []
|
|
6161
|
+
},
|
|
6162
|
+
sidebar: {
|
|
6163
|
+
type: Object
|
|
6164
|
+
},
|
|
6165
|
+
menu: {
|
|
6166
|
+
type: Object,
|
|
6167
|
+
default: () => ({ left: [], right: [] })
|
|
6168
|
+
},
|
|
6169
|
+
layerContentMenu: {
|
|
6170
|
+
type: Array,
|
|
6171
|
+
default: () => []
|
|
6172
|
+
},
|
|
6173
|
+
stageContentMenu: {
|
|
6174
|
+
type: Array,
|
|
6175
|
+
default: () => []
|
|
6176
|
+
},
|
|
6177
|
+
render: {
|
|
6178
|
+
type: Function
|
|
6179
|
+
},
|
|
6180
|
+
runtimeUrl: String,
|
|
6181
|
+
autoScrollIntoView: Boolean,
|
|
6182
|
+
propsConfigs: {
|
|
6183
|
+
type: Object,
|
|
6184
|
+
default: () => ({})
|
|
6185
|
+
},
|
|
6186
|
+
propsValues: {
|
|
6187
|
+
type: Object,
|
|
6188
|
+
default: () => ({})
|
|
6189
|
+
},
|
|
6190
|
+
eventMethodList: {
|
|
6191
|
+
type: Object,
|
|
6192
|
+
default: () => ({})
|
|
6193
|
+
},
|
|
6194
|
+
moveableOptions: {
|
|
6195
|
+
type: [Object, Function]
|
|
6196
|
+
},
|
|
6197
|
+
defaultSelected: {
|
|
6198
|
+
type: [Number, String]
|
|
6199
|
+
},
|
|
6200
|
+
canSelect: {
|
|
6201
|
+
type: Function,
|
|
6202
|
+
default: (el) => Boolean(el.id)
|
|
6203
|
+
},
|
|
6204
|
+
isContainer: {
|
|
6205
|
+
type: Function,
|
|
6206
|
+
default: (el) => el.classList.contains("magic-ui-container")
|
|
6207
|
+
},
|
|
6208
|
+
containerHighlightClassName: {
|
|
6209
|
+
type: String,
|
|
6210
|
+
default: StageCore.CONTAINER_HIGHLIGHT_CLASS_NAME
|
|
6211
|
+
},
|
|
6212
|
+
containerHighlightDuration: {
|
|
6213
|
+
type: Number,
|
|
6214
|
+
default: 800
|
|
6215
|
+
},
|
|
6216
|
+
containerHighlightType: {
|
|
6217
|
+
type: String,
|
|
6218
|
+
default: StageCore.ContainerHighlightType.DEFAULT
|
|
6219
|
+
},
|
|
6220
|
+
stageRect: {
|
|
6221
|
+
type: [String, Object]
|
|
6222
|
+
},
|
|
6223
|
+
codeOptions: {
|
|
6224
|
+
type: Object,
|
|
6225
|
+
default: () => ({})
|
|
6226
|
+
},
|
|
6227
|
+
updateDragEl: {
|
|
6228
|
+
type: Function
|
|
6229
|
+
},
|
|
6230
|
+
disabledDragStart: {
|
|
6231
|
+
type: Boolean
|
|
6232
|
+
}
|
|
6233
|
+
};
|
|
6234
|
+
|
|
6235
|
+
const createCodeBlockTarget = (id, codeBlock) => new Target({
|
|
6236
|
+
type: "code-block",
|
|
6237
|
+
id,
|
|
6238
|
+
name: codeBlock.name,
|
|
6239
|
+
isTarget: (key, value) => {
|
|
6240
|
+
if (value?.hookType === schema.HookType.CODE && !lodashEs.isEmpty(value.hookData)) {
|
|
6241
|
+
const index = value.hookData.findIndex((item) => item.codeId === id);
|
|
6242
|
+
return Boolean(index > -1);
|
|
6243
|
+
}
|
|
6244
|
+
return false;
|
|
6245
|
+
}
|
|
6246
|
+
});
|
|
6247
|
+
|
|
6248
|
+
const initServiceState = (props, {
|
|
6249
|
+
editorService,
|
|
6250
|
+
historyService,
|
|
6251
|
+
componentListService,
|
|
6252
|
+
propsService,
|
|
6253
|
+
eventsService,
|
|
6254
|
+
uiService,
|
|
6255
|
+
codeBlockService
|
|
6256
|
+
}) => {
|
|
6257
|
+
vue.watch(
|
|
6258
|
+
() => props.modelValue,
|
|
6259
|
+
(modelValue) => {
|
|
6260
|
+
editorService.set("root", modelValue);
|
|
6261
|
+
},
|
|
6262
|
+
{
|
|
6263
|
+
immediate: true
|
|
6264
|
+
}
|
|
6265
|
+
);
|
|
6266
|
+
vue.watch(
|
|
6267
|
+
() => props.componentGroupList,
|
|
6268
|
+
(componentGroupList) => componentListService.setList(componentGroupList),
|
|
6269
|
+
{
|
|
6270
|
+
immediate: true
|
|
6271
|
+
}
|
|
6272
|
+
);
|
|
6273
|
+
vue.watch(
|
|
6274
|
+
() => props.propsConfigs,
|
|
6275
|
+
(configs) => propsService.setPropsConfigs(configs),
|
|
6276
|
+
{
|
|
6277
|
+
immediate: true
|
|
6278
|
+
}
|
|
6279
|
+
);
|
|
6280
|
+
vue.watch(
|
|
6281
|
+
() => props.propsValues,
|
|
6282
|
+
(values) => propsService.setPropsValues(values),
|
|
6283
|
+
{
|
|
6284
|
+
immediate: true
|
|
6285
|
+
}
|
|
6286
|
+
);
|
|
6287
|
+
vue.watch(
|
|
6288
|
+
() => props.eventMethodList,
|
|
6289
|
+
(eventMethodList) => {
|
|
6290
|
+
const eventsList = {};
|
|
6291
|
+
const methodsList = {};
|
|
6292
|
+
Object.keys(eventMethodList).forEach((type) => {
|
|
6293
|
+
eventsList[type] = eventMethodList[type].events;
|
|
6294
|
+
methodsList[type] = eventMethodList[type].methods;
|
|
6295
|
+
});
|
|
6296
|
+
eventsService.setEvents(eventsList);
|
|
6297
|
+
eventsService.setMethods(methodsList);
|
|
6298
|
+
},
|
|
6299
|
+
{
|
|
6300
|
+
immediate: true
|
|
6301
|
+
}
|
|
6302
|
+
);
|
|
6303
|
+
vue.watch(
|
|
6304
|
+
() => props.defaultSelected,
|
|
6305
|
+
(defaultSelected) => defaultSelected && editorService.select(defaultSelected),
|
|
6306
|
+
{
|
|
6307
|
+
immediate: true
|
|
6308
|
+
}
|
|
6309
|
+
);
|
|
6310
|
+
vue.watch(
|
|
6311
|
+
() => props.stageRect,
|
|
6312
|
+
(stageRect) => stageRect && uiService.set("stageRect", stageRect),
|
|
6313
|
+
{
|
|
6314
|
+
immediate: true
|
|
6315
|
+
}
|
|
6316
|
+
);
|
|
6317
|
+
vue.onUnmounted(() => {
|
|
6318
|
+
editorService.resetState();
|
|
6319
|
+
historyService.resetState();
|
|
6320
|
+
propsService.resetState();
|
|
6321
|
+
uiService.resetState();
|
|
6322
|
+
componentListService.resetState();
|
|
6323
|
+
codeBlockService.resetState();
|
|
6324
|
+
});
|
|
6325
|
+
};
|
|
6326
|
+
const initServiceEvents = (props, emit, { editorService, codeBlockService, depService }) => {
|
|
6327
|
+
const rootChangeHandler = async (value, preValue) => {
|
|
6328
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
6329
|
+
let node;
|
|
6330
|
+
if (nodeId) {
|
|
6331
|
+
node = editorService.getNodeById(nodeId);
|
|
6332
|
+
}
|
|
6333
|
+
if (node && node !== value) {
|
|
6334
|
+
await editorService.select(node.id);
|
|
6335
|
+
} else if (value?.items?.length) {
|
|
6336
|
+
await editorService.select(value.items[0]);
|
|
6337
|
+
} else if (value?.id) {
|
|
6338
|
+
editorService.set("nodes", [value]);
|
|
6339
|
+
editorService.set("parent", null);
|
|
6340
|
+
editorService.set("page", null);
|
|
6341
|
+
}
|
|
6342
|
+
if (vue.toRaw(value) !== vue.toRaw(preValue)) {
|
|
6343
|
+
emit("update:modelValue", value);
|
|
6344
|
+
}
|
|
6345
|
+
value.codeBlocks = value.codeBlocks || {};
|
|
6346
|
+
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
6347
|
+
depService.removeTargets("code-block");
|
|
6348
|
+
Object.entries(value.codeBlocks).forEach(([id, code]) => {
|
|
6349
|
+
depService.addTarget(createCodeBlockTarget(id, code));
|
|
6350
|
+
});
|
|
6351
|
+
if (value && Array.isArray(value.items)) {
|
|
6352
|
+
depService.collect(value.items, true);
|
|
6353
|
+
} else {
|
|
6354
|
+
depService.clear();
|
|
6355
|
+
}
|
|
6356
|
+
};
|
|
6357
|
+
const nodeAddHandler = (nodes) => {
|
|
6358
|
+
depService.collect(nodes);
|
|
6359
|
+
};
|
|
6360
|
+
const nodeUpdateHandler = (nodes) => {
|
|
6361
|
+
depService.collect(nodes);
|
|
6362
|
+
};
|
|
6363
|
+
const nodeRemoveHandler = (nodes) => {
|
|
6364
|
+
depService.clear(nodes);
|
|
6365
|
+
};
|
|
6366
|
+
const historyChangeHandler = (page) => {
|
|
6367
|
+
depService.collect([page], true);
|
|
6368
|
+
};
|
|
6369
|
+
editorService.on("history-change", historyChangeHandler);
|
|
6370
|
+
editorService.on("root-change", rootChangeHandler);
|
|
6371
|
+
editorService.on("add", nodeAddHandler);
|
|
6372
|
+
editorService.on("remove", nodeRemoveHandler);
|
|
6373
|
+
editorService.on("update", nodeUpdateHandler);
|
|
6374
|
+
const codeBlockAddOrUpdateHandler = (id, codeBlock) => {
|
|
6375
|
+
if (depService.hasTarget(id)) {
|
|
6376
|
+
depService.getTarget(id).name = codeBlock.name;
|
|
6377
|
+
return;
|
|
6378
|
+
}
|
|
6379
|
+
depService.addTarget(createCodeBlockTarget(id, codeBlock));
|
|
6380
|
+
};
|
|
6381
|
+
const codeBlockRemoveHandler = (id) => {
|
|
6382
|
+
depService.removeTarget(id);
|
|
6383
|
+
};
|
|
6384
|
+
codeBlockService.on("addOrUpdate", codeBlockAddOrUpdateHandler);
|
|
6385
|
+
codeBlockService.on("remove", codeBlockRemoveHandler);
|
|
6386
|
+
vue.onUnmounted(() => {
|
|
6387
|
+
editorService.off("history-change", historyChangeHandler);
|
|
6388
|
+
editorService.off("root-change", rootChangeHandler);
|
|
6389
|
+
editorService.off("add", nodeAddHandler);
|
|
6390
|
+
editorService.off("remove", nodeRemoveHandler);
|
|
6391
|
+
editorService.off("update", nodeUpdateHandler);
|
|
6392
|
+
codeBlockService.off("addOrUpdate", codeBlockAddOrUpdateHandler);
|
|
6393
|
+
codeBlockService.off("remove", codeBlockRemoveHandler);
|
|
6394
|
+
});
|
|
6395
|
+
};
|
|
5847
6396
|
|
|
5848
6397
|
const _sfc_main = vue.defineComponent({
|
|
5849
6398
|
name: "m-editor",
|
|
@@ -5854,181 +6403,9 @@
|
|
|
5854
6403
|
PropsPanel: _sfc_main$i,
|
|
5855
6404
|
Framework: _sfc_main$l
|
|
5856
6405
|
},
|
|
5857
|
-
props:
|
|
5858
|
-
modelValue: {
|
|
5859
|
-
type: Object,
|
|
5860
|
-
default: () => ({}),
|
|
5861
|
-
require: true
|
|
5862
|
-
},
|
|
5863
|
-
componentGroupList: {
|
|
5864
|
-
type: Array,
|
|
5865
|
-
default: () => []
|
|
5866
|
-
},
|
|
5867
|
-
sidebar: {
|
|
5868
|
-
type: Object
|
|
5869
|
-
},
|
|
5870
|
-
menu: {
|
|
5871
|
-
type: Object,
|
|
5872
|
-
default: () => ({ left: [], right: [] })
|
|
5873
|
-
},
|
|
5874
|
-
layerContentMenu: {
|
|
5875
|
-
type: Array,
|
|
5876
|
-
default: () => []
|
|
5877
|
-
},
|
|
5878
|
-
stageContentMenu: {
|
|
5879
|
-
type: Array,
|
|
5880
|
-
default: () => []
|
|
5881
|
-
},
|
|
5882
|
-
render: {
|
|
5883
|
-
type: Function
|
|
5884
|
-
},
|
|
5885
|
-
runtimeUrl: String,
|
|
5886
|
-
autoScrollIntoView: Boolean,
|
|
5887
|
-
propsConfigs: {
|
|
5888
|
-
type: Object,
|
|
5889
|
-
default: () => ({})
|
|
5890
|
-
},
|
|
5891
|
-
propsValues: {
|
|
5892
|
-
type: Object,
|
|
5893
|
-
default: () => ({})
|
|
5894
|
-
},
|
|
5895
|
-
eventMethodList: {
|
|
5896
|
-
type: Object,
|
|
5897
|
-
default: () => ({})
|
|
5898
|
-
},
|
|
5899
|
-
moveableOptions: {
|
|
5900
|
-
type: [Object, Function]
|
|
5901
|
-
},
|
|
5902
|
-
defaultSelected: {
|
|
5903
|
-
type: [Number, String]
|
|
5904
|
-
},
|
|
5905
|
-
canSelect: {
|
|
5906
|
-
type: Function,
|
|
5907
|
-
default: (el) => Boolean(el.id)
|
|
5908
|
-
},
|
|
5909
|
-
isContainer: {
|
|
5910
|
-
type: Function,
|
|
5911
|
-
default: (el) => el.classList.contains("magic-ui-container")
|
|
5912
|
-
},
|
|
5913
|
-
containerHighlightClassName: {
|
|
5914
|
-
type: String,
|
|
5915
|
-
default: StageCore.CONTAINER_HIGHLIGHT_CLASS_NAME
|
|
5916
|
-
},
|
|
5917
|
-
containerHighlightDuration: {
|
|
5918
|
-
type: Number,
|
|
5919
|
-
default: 800
|
|
5920
|
-
},
|
|
5921
|
-
containerHighlightType: {
|
|
5922
|
-
type: String,
|
|
5923
|
-
default: StageCore.ContainerHighlightType.DEFAULT
|
|
5924
|
-
},
|
|
5925
|
-
stageRect: {
|
|
5926
|
-
type: [String, Object]
|
|
5927
|
-
},
|
|
5928
|
-
codeOptions: {
|
|
5929
|
-
type: Object,
|
|
5930
|
-
default: () => ({})
|
|
5931
|
-
},
|
|
5932
|
-
updateDragEl: {
|
|
5933
|
-
type: Function
|
|
5934
|
-
},
|
|
5935
|
-
disabledDragStart: {
|
|
5936
|
-
type: Boolean
|
|
5937
|
-
}
|
|
5938
|
-
},
|
|
6406
|
+
props: editorProps,
|
|
5939
6407
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
5940
6408
|
setup(props, { emit }) {
|
|
5941
|
-
const rootChangeHandler = (value, preValue) => {
|
|
5942
|
-
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
5943
|
-
let node;
|
|
5944
|
-
if (nodeId) {
|
|
5945
|
-
node = editorService.getNodeById(nodeId);
|
|
5946
|
-
}
|
|
5947
|
-
if (node && node !== value) {
|
|
5948
|
-
editorService.select(node.id);
|
|
5949
|
-
} else if (value?.items?.length) {
|
|
5950
|
-
editorService.select(value.items[0]);
|
|
5951
|
-
} else if (value?.id) {
|
|
5952
|
-
editorService.set("nodes", [value]);
|
|
5953
|
-
editorService.set("parent", null);
|
|
5954
|
-
editorService.set("page", null);
|
|
5955
|
-
}
|
|
5956
|
-
if (vue.toRaw(value) !== vue.toRaw(preValue)) {
|
|
5957
|
-
emit("update:modelValue", value);
|
|
5958
|
-
}
|
|
5959
|
-
value.codeBlocks = value.codeBlocks || {};
|
|
5960
|
-
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
5961
|
-
};
|
|
5962
|
-
editorService.on("root-change", rootChangeHandler);
|
|
5963
|
-
vue.watch(
|
|
5964
|
-
() => props.modelValue,
|
|
5965
|
-
(modelValue) => {
|
|
5966
|
-
editorService.set("root", modelValue);
|
|
5967
|
-
},
|
|
5968
|
-
{
|
|
5969
|
-
immediate: true
|
|
5970
|
-
}
|
|
5971
|
-
);
|
|
5972
|
-
vue.watch(
|
|
5973
|
-
() => props.componentGroupList,
|
|
5974
|
-
(componentGroupList) => componentListService.setList(componentGroupList),
|
|
5975
|
-
{
|
|
5976
|
-
immediate: true
|
|
5977
|
-
}
|
|
5978
|
-
);
|
|
5979
|
-
vue.watch(
|
|
5980
|
-
() => props.propsConfigs,
|
|
5981
|
-
(configs) => propsService.setPropsConfigs(configs),
|
|
5982
|
-
{
|
|
5983
|
-
immediate: true
|
|
5984
|
-
}
|
|
5985
|
-
);
|
|
5986
|
-
vue.watch(
|
|
5987
|
-
() => props.propsValues,
|
|
5988
|
-
(values) => propsService.setPropsValues(values),
|
|
5989
|
-
{
|
|
5990
|
-
immediate: true
|
|
5991
|
-
}
|
|
5992
|
-
);
|
|
5993
|
-
vue.watch(
|
|
5994
|
-
() => props.eventMethodList,
|
|
5995
|
-
(eventMethodList) => {
|
|
5996
|
-
const eventsList = {};
|
|
5997
|
-
const methodsList = {};
|
|
5998
|
-
Object.keys(eventMethodList).forEach((type) => {
|
|
5999
|
-
eventsList[type] = eventMethodList[type].events;
|
|
6000
|
-
methodsList[type] = eventMethodList[type].methods;
|
|
6001
|
-
});
|
|
6002
|
-
eventsService.setEvents(eventsList);
|
|
6003
|
-
eventsService.setMethods(methodsList);
|
|
6004
|
-
},
|
|
6005
|
-
{
|
|
6006
|
-
immediate: true
|
|
6007
|
-
}
|
|
6008
|
-
);
|
|
6009
|
-
vue.watch(
|
|
6010
|
-
() => props.defaultSelected,
|
|
6011
|
-
(defaultSelected) => defaultSelected && editorService.select(defaultSelected),
|
|
6012
|
-
{
|
|
6013
|
-
immediate: true
|
|
6014
|
-
}
|
|
6015
|
-
);
|
|
6016
|
-
vue.watch(
|
|
6017
|
-
() => props.stageRect,
|
|
6018
|
-
(stageRect) => stageRect && uiService.set("stageRect", stageRect),
|
|
6019
|
-
{
|
|
6020
|
-
immediate: true
|
|
6021
|
-
}
|
|
6022
|
-
);
|
|
6023
|
-
vue.onUnmounted(() => {
|
|
6024
|
-
editorService.resetState();
|
|
6025
|
-
historyService.resetState();
|
|
6026
|
-
propsService.resetState();
|
|
6027
|
-
uiService.resetState();
|
|
6028
|
-
componentListService.resetState();
|
|
6029
|
-
codeBlockService.resetState();
|
|
6030
|
-
editorService.off("root-change", rootChangeHandler);
|
|
6031
|
-
});
|
|
6032
6409
|
const services = {
|
|
6033
6410
|
componentListService,
|
|
6034
6411
|
eventsService,
|
|
@@ -6037,8 +6414,11 @@
|
|
|
6037
6414
|
editorService,
|
|
6038
6415
|
uiService,
|
|
6039
6416
|
storageService,
|
|
6040
|
-
codeBlockService
|
|
6417
|
+
codeBlockService,
|
|
6418
|
+
depService
|
|
6041
6419
|
};
|
|
6420
|
+
initServiceEvents(props, emit, services);
|
|
6421
|
+
initServiceState(props, services);
|
|
6042
6422
|
vue.provide("services", services);
|
|
6043
6423
|
vue.provide("codeOptions", props.codeOptions);
|
|
6044
6424
|
vue.provide(
|
|
@@ -6057,7 +6437,6 @@
|
|
|
6057
6437
|
disabledDragStart: props.disabledDragStart
|
|
6058
6438
|
})
|
|
6059
6439
|
);
|
|
6060
|
-
codeBlockService.addCodeRelationListener();
|
|
6061
6440
|
return services;
|
|
6062
6441
|
}
|
|
6063
6442
|
});
|
|
@@ -6168,10 +6547,12 @@
|
|
|
6168
6547
|
setConfig(option);
|
|
6169
6548
|
app.component(Editor.name, Editor);
|
|
6170
6549
|
app.component("m-fields-ui-select", _sfc_main$q);
|
|
6171
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
6172
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
6550
|
+
app.component("m-fields-code-link", _sfc_main$v);
|
|
6551
|
+
app.component("m-fields-vs-code", _sfc_main$w);
|
|
6173
6552
|
app.component("magic-code-editor", _sfc_main$p);
|
|
6174
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
6553
|
+
app.component("m-fields-code-select", _sfc_main$t);
|
|
6554
|
+
app.component("m-fields-code-select-col", _sfc_main$s);
|
|
6555
|
+
app.component("m-fields-event-select", _sfc_main$r);
|
|
6175
6556
|
}
|
|
6176
6557
|
};
|
|
6177
6558
|
|
|
@@ -6179,13 +6560,15 @@
|
|
|
6179
6560
|
exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
|
|
6180
6561
|
exports.CodeBlockList = _sfc_main$e;
|
|
6181
6562
|
exports.CodeDeleteErrorType = CodeDeleteErrorType;
|
|
6182
|
-
exports.CodeSelect = _sfc_main$
|
|
6563
|
+
exports.CodeSelect = _sfc_main$t;
|
|
6564
|
+
exports.CodeSelectCol = _sfc_main$s;
|
|
6183
6565
|
exports.ColumnLayout = ColumnLayout;
|
|
6184
6566
|
exports.ComponentListPanel = _sfc_main$d;
|
|
6185
6567
|
exports.ContentMenu = _sfc_main$c;
|
|
6568
|
+
exports.EventSelect = _sfc_main$r;
|
|
6186
6569
|
exports.Fixed2Other = Fixed2Other;
|
|
6187
6570
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
6188
|
-
exports.Icon = _sfc_main$
|
|
6571
|
+
exports.Icon = _sfc_main$u;
|
|
6189
6572
|
exports.Keys = Keys;
|
|
6190
6573
|
exports.LayerOffset = LayerOffset;
|
|
6191
6574
|
exports.LayerPanel = _sfc_main$a;
|
|
@@ -6201,6 +6584,7 @@
|
|
|
6201
6584
|
exports.codeBlockService = codeBlockService;
|
|
6202
6585
|
exports.debug = debug;
|
|
6203
6586
|
exports.default = index;
|
|
6587
|
+
exports.depService = depService;
|
|
6204
6588
|
exports.editorService = editorService;
|
|
6205
6589
|
exports.error = error;
|
|
6206
6590
|
exports.eventsService = eventsService;
|