@tmagic/editor 1.2.9 → 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 +1694 -1342
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +1699 -1344
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +9 -9
- package/src/Editor.vue +10 -240
- package/src/components/CodeDraftEditor.vue +10 -6
- package/src/components/FunctionEditor.vue +1 -1
- package/src/editorProps.ts +135 -0
- package/src/fields/CodeSelect.vue +24 -13
- 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 +29 -150
- package/src/services/dep.ts +328 -0
- package/src/services/editor.ts +2 -28
- 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 +3 -36
- package/types/services/dep.d.ts +130 -0
- package/types/services/editor.d.ts +1 -13
- 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,
|
|
@@ -197,7 +198,7 @@
|
|
|
197
198
|
const props = __props;
|
|
198
199
|
const services = vue.inject("services");
|
|
199
200
|
const mForm = vue.inject("mForm");
|
|
200
|
-
const codeDsl = vue.computed(() => services?.codeBlockService.
|
|
201
|
+
const codeDsl = vue.computed(() => services?.codeBlockService.getCodeDsl());
|
|
201
202
|
const tableConfig = vue.computed(() => {
|
|
202
203
|
const defaultConfig = {
|
|
203
204
|
dropSort: false,
|
|
@@ -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,146 +1442,482 @@
|
|
|
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
|
-
|
|
1390
|
-
|
|
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;
|
|
1920
|
+
}
|
|
1391
1921
|
pasteConfig.style = {
|
|
1392
1922
|
...pasteConfig.style,
|
|
1393
1923
|
...pastePosition
|
|
@@ -1468,9 +1998,7 @@
|
|
|
1468
1998
|
"move",
|
|
1469
1999
|
"undo",
|
|
1470
2000
|
"redo",
|
|
1471
|
-
"highlight"
|
|
1472
|
-
"getCodeDsl",
|
|
1473
|
-
"setCodeDsl"
|
|
2001
|
+
"highlight"
|
|
1474
2002
|
],
|
|
1475
2003
|
["select", "update", "moveLayer"]
|
|
1476
2004
|
);
|
|
@@ -1556,7 +2084,7 @@
|
|
|
1556
2084
|
historyService.resetState();
|
|
1557
2085
|
}
|
|
1558
2086
|
if (node?.id) {
|
|
1559
|
-
this.get("stage")?.renderer.runtime?.getApp?.()
|
|
2087
|
+
this.get("stage")?.renderer.runtime?.getApp?.()?.page?.emit(
|
|
1560
2088
|
"editor:select",
|
|
1561
2089
|
{
|
|
1562
2090
|
node,
|
|
@@ -1921,436 +2449,134 @@
|
|
|
1921
2449
|
}
|
|
1922
2450
|
});
|
|
1923
2451
|
newConfig.style = getInitPositionStyle(newConfig.style, layout);
|
|
1924
|
-
target.items.push(newConfig);
|
|
1925
|
-
await stage.select(targetId);
|
|
1926
|
-
const targetParent = this.getParentById(target.id);
|
|
1927
|
-
await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root });
|
|
1928
|
-
await this.select(newConfig);
|
|
1929
|
-
stage.select(newConfig.id);
|
|
1930
|
-
this.addModifiedNodeId(target.id);
|
|
1931
|
-
this.addModifiedNodeId(parent.id);
|
|
1932
|
-
this.pushHistoryState();
|
|
1933
|
-
return newConfig;
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
async undo() {
|
|
1937
|
-
const value = historyService.undo();
|
|
1938
|
-
await this.changeHistoryState(value);
|
|
1939
|
-
return value;
|
|
1940
|
-
}
|
|
1941
|
-
async redo() {
|
|
1942
|
-
const value = historyService.redo();
|
|
1943
|
-
await this.changeHistoryState(value);
|
|
1944
|
-
return value;
|
|
1945
|
-
}
|
|
1946
|
-
async move(left, top) {
|
|
1947
|
-
const node = vue.toRaw(this.get("node"));
|
|
1948
|
-
if (!node || utils.isPage(node))
|
|
1949
|
-
return;
|
|
1950
|
-
const { style, id, type } = node;
|
|
1951
|
-
if (!style || style.position !== "absolute")
|
|
1952
|
-
return;
|
|
1953
|
-
if (top && !utils.isNumber(style.top))
|
|
1954
|
-
return;
|
|
1955
|
-
if (left && !utils.isNumber(style.left))
|
|
1956
|
-
return;
|
|
1957
|
-
this.update({
|
|
1958
|
-
id,
|
|
1959
|
-
type,
|
|
1960
|
-
style: {
|
|
1961
|
-
...style,
|
|
1962
|
-
left: Number(style.left) + left,
|
|
1963
|
-
top: Number(style.top) + top
|
|
1964
|
-
}
|
|
1965
|
-
});
|
|
1966
|
-
}
|
|
1967
|
-
resetState() {
|
|
1968
|
-
this.set("root", null);
|
|
1969
|
-
this.set("node", null);
|
|
1970
|
-
this.set("nodes", []);
|
|
1971
|
-
this.set("page", null);
|
|
1972
|
-
this.set("parent", null);
|
|
1973
|
-
this.set("stage", null);
|
|
1974
|
-
this.set("highlightNode", null);
|
|
1975
|
-
this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
|
|
1976
|
-
this.set("pageLength", 0);
|
|
1977
|
-
}
|
|
1978
|
-
destroy() {
|
|
1979
|
-
this.removeAllListeners();
|
|
1980
|
-
this.resetState();
|
|
1981
|
-
this.removeAllPlugins();
|
|
1982
|
-
}
|
|
1983
|
-
resetModifiedNodeId() {
|
|
1984
|
-
this.get("modifiedNodeIds").clear();
|
|
1985
|
-
}
|
|
1986
|
-
async getCodeDsl() {
|
|
1987
|
-
const root = this.get("root");
|
|
1988
|
-
return root?.codeBlocks || null;
|
|
1989
|
-
}
|
|
1990
|
-
getCodeDslSync() {
|
|
1991
|
-
const root = this.get("root");
|
|
1992
|
-
return root?.codeBlocks || null;
|
|
1993
|
-
}
|
|
1994
|
-
async setCodeDsl(codeDsl) {
|
|
1995
|
-
if (!this.state.root)
|
|
1996
|
-
return;
|
|
1997
|
-
this.state.root.codeBlocks = codeDsl;
|
|
1998
|
-
}
|
|
1999
|
-
addModifiedNodeId(id) {
|
|
2000
|
-
if (!this.isHistoryStateChange) {
|
|
2001
|
-
this.get("modifiedNodeIds").set(id, id);
|
|
2002
|
-
}
|
|
2003
|
-
}
|
|
2004
|
-
pushHistoryState() {
|
|
2005
|
-
const curNode = lodashEs.cloneDeep(vue.toRaw(this.get("node")));
|
|
2006
|
-
const page = this.get("page");
|
|
2007
|
-
if (!this.isHistoryStateChange && curNode && page) {
|
|
2008
|
-
historyService.push({
|
|
2009
|
-
data: lodashEs.cloneDeep(vue.toRaw(page)),
|
|
2010
|
-
modifiedNodeIds: this.get("modifiedNodeIds"),
|
|
2011
|
-
nodeId: curNode.id
|
|
2012
|
-
});
|
|
2013
|
-
}
|
|
2014
|
-
this.isHistoryStateChange = false;
|
|
2015
|
-
}
|
|
2016
|
-
async changeHistoryState(value) {
|
|
2017
|
-
if (!value)
|
|
2018
|
-
return;
|
|
2019
|
-
this.isHistoryStateChange = true;
|
|
2020
|
-
await this.update(value.data);
|
|
2021
|
-
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
2022
|
-
setTimeout(async () => {
|
|
2023
|
-
if (!value.nodeId)
|
|
2024
|
-
return;
|
|
2025
|
-
await this.select(value.nodeId);
|
|
2026
|
-
this.get("stage")?.select(value.nodeId);
|
|
2027
|
-
}, 0);
|
|
2028
|
-
this.emit("history-change", value.data);
|
|
2029
|
-
}
|
|
2030
|
-
async toggleFixedPosition(dist, src, root) {
|
|
2031
|
-
const newConfig = lodashEs.cloneDeep(dist);
|
|
2032
|
-
if (!utils.isPop(src) && newConfig.style?.position) {
|
|
2033
|
-
if (isFixed(newConfig) && !isFixed(src)) {
|
|
2034
|
-
newConfig.style = change2Fixed(newConfig, root);
|
|
2035
|
-
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
2036
|
-
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
2037
|
-
}
|
|
2038
|
-
}
|
|
2039
|
-
return newConfig;
|
|
2040
|
-
}
|
|
2041
|
-
selectedConfigExceptionHandler(config) {
|
|
2042
|
-
let id;
|
|
2043
|
-
if (typeof config === "string" || typeof config === "number") {
|
|
2044
|
-
id = config;
|
|
2045
|
-
} else {
|
|
2046
|
-
id = config.id;
|
|
2047
|
-
}
|
|
2048
|
-
if (!id) {
|
|
2049
|
-
throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
|
|
2050
|
-
}
|
|
2051
|
-
const { node, parent, page } = this.getNodeInfo(id);
|
|
2052
|
-
if (!node)
|
|
2053
|
-
throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
|
|
2054
|
-
if (node.id === this.state.root?.id) {
|
|
2055
|
-
throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
|
|
2056
|
-
}
|
|
2057
|
-
return {
|
|
2058
|
-
node,
|
|
2059
|
-
parent,
|
|
2060
|
-
page
|
|
2061
|
-
};
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
const editorService = new Editor$1();
|
|
2065
|
-
|
|
2066
|
-
let eventMap = vue.reactive({});
|
|
2067
|
-
let methodMap = vue.reactive({});
|
|
2068
|
-
class Events extends BaseService {
|
|
2069
|
-
constructor() {
|
|
2070
|
-
super([]);
|
|
2071
|
-
}
|
|
2072
|
-
init(componentGroupList) {
|
|
2073
|
-
componentGroupList.forEach((group) => {
|
|
2074
|
-
group.items.forEach((element) => {
|
|
2075
|
-
const type = utils.toLine(element.type);
|
|
2076
|
-
if (!this.getEvent(type)) {
|
|
2077
|
-
this.setEvent(type, core.DEFAULT_EVENTS);
|
|
2078
|
-
}
|
|
2079
|
-
if (!this.getMethod(type)) {
|
|
2080
|
-
this.setMethod(type, core.DEFAULT_METHODS);
|
|
2081
|
-
}
|
|
2082
|
-
});
|
|
2083
|
-
});
|
|
2084
|
-
}
|
|
2085
|
-
setEvents(events) {
|
|
2086
|
-
Object.keys(events).forEach((type) => {
|
|
2087
|
-
this.setEvent(utils.toLine(type), events[type] || []);
|
|
2088
|
-
});
|
|
2089
|
-
}
|
|
2090
|
-
setEvent(type, events) {
|
|
2091
|
-
eventMap[type] = [...core.DEFAULT_EVENTS, ...events];
|
|
2092
|
-
}
|
|
2093
|
-
getEvent(type) {
|
|
2094
|
-
return lodashEs.cloneDeep(eventMap[type] || core.DEFAULT_EVENTS);
|
|
2095
|
-
}
|
|
2096
|
-
setMethods(methods) {
|
|
2097
|
-
Object.keys(methods).forEach((type) => {
|
|
2098
|
-
this.setMethod(utils.toLine(type), methods[type] || []);
|
|
2099
|
-
});
|
|
2100
|
-
}
|
|
2101
|
-
setMethod(type, method) {
|
|
2102
|
-
methodMap[type] = [...core.DEFAULT_METHODS, ...method];
|
|
2103
|
-
}
|
|
2104
|
-
getMethod(type) {
|
|
2105
|
-
return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
|
|
2106
|
-
}
|
|
2107
|
-
resetState() {
|
|
2108
|
-
eventMap = vue.reactive({});
|
|
2109
|
-
methodMap = vue.reactive({});
|
|
2110
|
-
}
|
|
2111
|
-
destroy() {
|
|
2112
|
-
this.resetState();
|
|
2113
|
-
this.removeAllListeners();
|
|
2114
|
-
this.removeAllPlugins();
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
const eventsService = new Events();
|
|
2118
|
-
|
|
2119
|
-
const fillConfig = (config = []) => [
|
|
2120
|
-
{
|
|
2121
|
-
type: "tab",
|
|
2122
|
-
items: [
|
|
2123
|
-
{
|
|
2124
|
-
title: "\u5C5E\u6027",
|
|
2125
|
-
labelWidth: "80px",
|
|
2126
|
-
items: [
|
|
2127
|
-
{
|
|
2128
|
-
text: "type",
|
|
2129
|
-
name: "type",
|
|
2130
|
-
type: "hidden"
|
|
2131
|
-
},
|
|
2132
|
-
{
|
|
2133
|
-
name: "id",
|
|
2134
|
-
type: "display",
|
|
2135
|
-
text: "id"
|
|
2136
|
-
},
|
|
2137
|
-
{
|
|
2138
|
-
name: "name",
|
|
2139
|
-
text: "\u7EC4\u4EF6\u540D\u79F0"
|
|
2140
|
-
},
|
|
2141
|
-
...config
|
|
2142
|
-
]
|
|
2143
|
-
},
|
|
2144
|
-
{
|
|
2145
|
-
title: "\u6837\u5F0F",
|
|
2146
|
-
labelWidth: "80px",
|
|
2147
|
-
items: [
|
|
2148
|
-
{
|
|
2149
|
-
name: "style",
|
|
2150
|
-
items: [
|
|
2151
|
-
{
|
|
2152
|
-
type: "fieldset",
|
|
2153
|
-
legend: "\u4F4D\u7F6E",
|
|
2154
|
-
items: [
|
|
2155
|
-
{
|
|
2156
|
-
name: "position",
|
|
2157
|
-
type: "checkbox",
|
|
2158
|
-
activeValue: "fixed",
|
|
2159
|
-
inactiveValue: "absolute",
|
|
2160
|
-
defaultValue: "absolute",
|
|
2161
|
-
text: "\u56FA\u5B9A\u5B9A\u4F4D"
|
|
2162
|
-
},
|
|
2163
|
-
{
|
|
2164
|
-
name: "left",
|
|
2165
|
-
text: "left"
|
|
2166
|
-
},
|
|
2167
|
-
{
|
|
2168
|
-
name: "top",
|
|
2169
|
-
text: "top",
|
|
2170
|
-
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedBottom"
|
|
2171
|
-
},
|
|
2172
|
-
{
|
|
2173
|
-
name: "right",
|
|
2174
|
-
text: "right"
|
|
2175
|
-
},
|
|
2176
|
-
{
|
|
2177
|
-
name: "bottom",
|
|
2178
|
-
text: "bottom",
|
|
2179
|
-
disabled: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedTop"
|
|
2180
|
-
}
|
|
2181
|
-
]
|
|
2182
|
-
},
|
|
2183
|
-
{
|
|
2184
|
-
type: "fieldset",
|
|
2185
|
-
legend: "\u76D2\u5B50",
|
|
2186
|
-
items: [
|
|
2187
|
-
{
|
|
2188
|
-
name: "width",
|
|
2189
|
-
text: "\u5BBD\u5EA6"
|
|
2190
|
-
},
|
|
2191
|
-
{
|
|
2192
|
-
name: "height",
|
|
2193
|
-
text: "\u9AD8\u5EA6"
|
|
2194
|
-
}
|
|
2195
|
-
]
|
|
2196
|
-
},
|
|
2197
|
-
{
|
|
2198
|
-
type: "fieldset",
|
|
2199
|
-
legend: "\u80CC\u666F",
|
|
2200
|
-
items: [
|
|
2201
|
-
{
|
|
2202
|
-
name: "backgroundImage",
|
|
2203
|
-
text: "\u80CC\u666F\u56FE"
|
|
2204
|
-
},
|
|
2205
|
-
{
|
|
2206
|
-
name: "backgroundColor",
|
|
2207
|
-
text: "\u80CC\u666F\u989C\u8272",
|
|
2208
|
-
type: "colorPicker"
|
|
2209
|
-
},
|
|
2210
|
-
{
|
|
2211
|
-
name: "backgroundRepeat",
|
|
2212
|
-
text: "\u80CC\u666F\u56FE\u91CD\u590D",
|
|
2213
|
-
type: "select",
|
|
2214
|
-
defaultValue: "no-repeat",
|
|
2215
|
-
options: [
|
|
2216
|
-
{ text: "repeat", value: "repeat" },
|
|
2217
|
-
{ text: "repeat-x", value: "repeat-x" },
|
|
2218
|
-
{ text: "repeat-y", value: "repeat-y" },
|
|
2219
|
-
{ text: "no-repeat", value: "no-repeat" },
|
|
2220
|
-
{ text: "inherit", value: "inherit" }
|
|
2221
|
-
]
|
|
2222
|
-
},
|
|
2223
|
-
{
|
|
2224
|
-
name: "backgroundSize",
|
|
2225
|
-
text: "\u80CC\u666F\u56FE\u5927\u5C0F",
|
|
2226
|
-
defaultValue: "100% 100%"
|
|
2227
|
-
}
|
|
2228
|
-
]
|
|
2229
|
-
},
|
|
2230
|
-
{
|
|
2231
|
-
type: "fieldset",
|
|
2232
|
-
legend: "\u5B57\u4F53",
|
|
2233
|
-
items: [
|
|
2234
|
-
{
|
|
2235
|
-
name: "color",
|
|
2236
|
-
text: "\u989C\u8272",
|
|
2237
|
-
type: "colorPicker"
|
|
2238
|
-
},
|
|
2239
|
-
{
|
|
2240
|
-
name: "fontSize",
|
|
2241
|
-
text: "\u5927\u5C0F"
|
|
2242
|
-
},
|
|
2243
|
-
{
|
|
2244
|
-
name: "fontWeight",
|
|
2245
|
-
text: "\u7C97\u7EC6"
|
|
2246
|
-
}
|
|
2247
|
-
]
|
|
2248
|
-
},
|
|
2249
|
-
{
|
|
2250
|
-
type: "fieldset",
|
|
2251
|
-
legend: "\u53D8\u5F62",
|
|
2252
|
-
name: "transform",
|
|
2253
|
-
items: [
|
|
2254
|
-
{
|
|
2255
|
-
name: "rotate",
|
|
2256
|
-
text: "\u65CB\u8F6C\u89D2\u5EA6"
|
|
2257
|
-
},
|
|
2258
|
-
{
|
|
2259
|
-
name: "scale",
|
|
2260
|
-
text: "\u7F29\u653E"
|
|
2261
|
-
}
|
|
2262
|
-
]
|
|
2263
|
-
}
|
|
2264
|
-
]
|
|
2265
|
-
}
|
|
2266
|
-
]
|
|
2267
|
-
},
|
|
2268
|
-
{
|
|
2269
|
-
title: "\u4E8B\u4EF6",
|
|
2270
|
-
items: [
|
|
2271
|
-
{
|
|
2272
|
-
type: "table",
|
|
2273
|
-
name: "events",
|
|
2274
|
-
items: [
|
|
2275
|
-
{
|
|
2276
|
-
name: "name",
|
|
2277
|
-
label: "\u4E8B\u4EF6\u540D",
|
|
2278
|
-
type: "select",
|
|
2279
|
-
options: (mForm, { formValue }) => eventsService.getEvent(formValue.type).map((option) => ({
|
|
2280
|
-
text: option.label,
|
|
2281
|
-
value: option.value
|
|
2282
|
-
}))
|
|
2283
|
-
},
|
|
2284
|
-
{
|
|
2285
|
-
name: "to",
|
|
2286
|
-
label: "\u8054\u52A8\u7EC4\u4EF6",
|
|
2287
|
-
type: "ui-select"
|
|
2288
|
-
},
|
|
2289
|
-
{
|
|
2290
|
-
name: "method",
|
|
2291
|
-
label: "\u52A8\u4F5C",
|
|
2292
|
-
type: "select",
|
|
2293
|
-
options: (mForm, { model }) => {
|
|
2294
|
-
const node = editorService.getNodeById(model.to);
|
|
2295
|
-
if (!node?.type)
|
|
2296
|
-
return [];
|
|
2297
|
-
return eventsService.getMethod(node.type).map((option) => ({
|
|
2298
|
-
text: option.label,
|
|
2299
|
-
value: option.value
|
|
2300
|
-
}));
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
]
|
|
2304
|
-
}
|
|
2305
|
-
]
|
|
2306
|
-
},
|
|
2307
|
-
{
|
|
2308
|
-
title: "\u9AD8\u7EA7",
|
|
2309
|
-
lazy: true,
|
|
2310
|
-
items: [
|
|
2311
|
-
{
|
|
2312
|
-
name: "created",
|
|
2313
|
-
text: "created",
|
|
2314
|
-
labelWidth: "100px",
|
|
2315
|
-
type: "code-select"
|
|
2316
|
-
},
|
|
2317
|
-
{
|
|
2318
|
-
name: "mounted",
|
|
2319
|
-
text: "mounted",
|
|
2320
|
-
labelWidth: "100px",
|
|
2321
|
-
type: "code-select"
|
|
2322
|
-
}
|
|
2323
|
-
]
|
|
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
|
|
2324
2492
|
}
|
|
2325
|
-
|
|
2493
|
+
});
|
|
2326
2494
|
}
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
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);
|
|
2332
2505
|
}
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2506
|
+
destroy() {
|
|
2507
|
+
this.removeAllListeners();
|
|
2508
|
+
this.resetState();
|
|
2509
|
+
this.removeAllPlugins();
|
|
2337
2510
|
}
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
if (process.env.NODE_ENV === "development") {
|
|
2341
|
-
console.warn("magic editor: ", ...args);
|
|
2511
|
+
resetModifiedNodeId() {
|
|
2512
|
+
this.get("modifiedNodeIds").clear();
|
|
2342
2513
|
}
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2514
|
+
addModifiedNodeId(id) {
|
|
2515
|
+
if (!this.isHistoryStateChange) {
|
|
2516
|
+
this.get("modifiedNodeIds").set(id, id);
|
|
2517
|
+
}
|
|
2347
2518
|
}
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
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;
|
|
2352
2530
|
}
|
|
2353
|
-
|
|
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();
|
|
2354
2580
|
|
|
2355
2581
|
const state = vue.reactive({
|
|
2356
2582
|
uiSelectMode: false,
|
|
@@ -2550,7 +2776,7 @@
|
|
|
2550
2776
|
onClick: clickHandler
|
|
2551
2777
|
}, [
|
|
2552
2778
|
vue.createElementVNode("div", null, [
|
|
2553
|
-
vue.createVNode(_sfc_main$
|
|
2779
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
2554
2780
|
]),
|
|
2555
2781
|
_hoisted_3$3
|
|
2556
2782
|
])
|
|
@@ -2781,7 +3007,7 @@
|
|
|
2781
3007
|
disabled: vue.unref(disabled)
|
|
2782
3008
|
}, {
|
|
2783
3009
|
default: vue.withCtx(() => [
|
|
2784
|
-
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3010
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
|
|
2785
3011
|
key: 0,
|
|
2786
3012
|
icon: __props.data.icon
|
|
2787
3013
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -2798,7 +3024,7 @@
|
|
|
2798
3024
|
disabled: vue.unref(disabled)
|
|
2799
3025
|
}, {
|
|
2800
3026
|
default: vue.withCtx(() => [
|
|
2801
|
-
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
3027
|
+
__props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
|
|
2802
3028
|
key: 0,
|
|
2803
3029
|
icon: __props.data.icon
|
|
2804
3030
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -3156,14 +3382,17 @@
|
|
|
3156
3382
|
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
3157
3383
|
if (codeDraft) {
|
|
3158
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", {
|
|
3159
|
-
confirmButtonText: "\
|
|
3160
|
-
cancelButtonText: "\
|
|
3161
|
-
type: "warning"
|
|
3385
|
+
confirmButtonText: "\u4FDD\u5B58\u5E76\u5173\u95ED",
|
|
3386
|
+
cancelButtonText: "\u76F4\u63A5\u5173\u95ED",
|
|
3387
|
+
type: "warning",
|
|
3388
|
+
distinguishCancelAndClose: true
|
|
3162
3389
|
}).then(async () => {
|
|
3163
3390
|
saveAndClose();
|
|
3164
|
-
}).catch(() => {
|
|
3165
|
-
|
|
3166
|
-
|
|
3391
|
+
}).catch((action) => {
|
|
3392
|
+
if (action === "cancel") {
|
|
3393
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
3394
|
+
emit("close");
|
|
3395
|
+
}
|
|
3167
3396
|
});
|
|
3168
3397
|
} else {
|
|
3169
3398
|
emit("close");
|
|
@@ -3330,7 +3559,7 @@
|
|
|
3330
3559
|
codeContent.value = props.content;
|
|
3331
3560
|
});
|
|
3332
3561
|
const initTableModel = () => {
|
|
3333
|
-
const codeDsl = lodashEs.cloneDeep(services?.codeBlockService.
|
|
3562
|
+
const codeDsl = lodashEs.cloneDeep(services?.codeBlockService.getCodeDsl());
|
|
3334
3563
|
if (!codeDsl)
|
|
3335
3564
|
return;
|
|
3336
3565
|
tableModel.value = {
|
|
@@ -3504,22 +3733,10 @@
|
|
|
3504
3733
|
const _hoisted_4 = ["id"];
|
|
3505
3734
|
const _hoisted_5 = { class: "list-item" };
|
|
3506
3735
|
const _hoisted_6 = { class: "code-name" };
|
|
3507
|
-
const _hoisted_7 = {
|
|
3508
|
-
const _hoisted_8 = {
|
|
3736
|
+
const _hoisted_7 = {
|
|
3509
3737
|
key: 0,
|
|
3510
|
-
class: "
|
|
3738
|
+
class: "right-tool"
|
|
3511
3739
|
};
|
|
3512
|
-
const _hoisted_9 = /* @__PURE__ */ vue.createElementVNode("svg", {
|
|
3513
|
-
class: "arrow-left",
|
|
3514
|
-
viewBox: "0 0 1024 1024",
|
|
3515
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3516
|
-
"data-v-029747aa": ""
|
|
3517
|
-
}, [
|
|
3518
|
-
/* @__PURE__ */ vue.createElementVNode("path", {
|
|
3519
|
-
fill: "currentColor",
|
|
3520
|
-
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"
|
|
3521
|
-
})
|
|
3522
|
-
], -1);
|
|
3523
3740
|
const __default__$d = vue.defineComponent({
|
|
3524
3741
|
name: "MEditorCodeBlockList"
|
|
3525
3742
|
});
|
|
@@ -3531,64 +3748,23 @@
|
|
|
3531
3748
|
},
|
|
3532
3749
|
setup(__props) {
|
|
3533
3750
|
const props = __props;
|
|
3534
|
-
const
|
|
3535
|
-
const
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
bindsComp.push({
|
|
3548
|
-
compId,
|
|
3549
|
-
compName: getCompName(compId)
|
|
3550
|
-
});
|
|
3551
|
-
}
|
|
3552
|
-
});
|
|
3553
|
-
return bindsComp;
|
|
3554
|
-
};
|
|
3555
|
-
const refreshCodeList = async () => {
|
|
3556
|
-
const codeDsl = lodashEs.cloneDeep(await services?.codeBlockService.getCodeDsl()) || null;
|
|
3557
|
-
codeCombineInfo.value = lodashEs.cloneDeep(services?.codeBlockService.getCombineInfo()) || null;
|
|
3558
|
-
if (!codeDsl || !codeCombineInfo.value)
|
|
3559
|
-
return;
|
|
3560
|
-
state.codeList = [];
|
|
3561
|
-
lodashEs.forIn(codeDsl, (value, codeId) => {
|
|
3562
|
-
state.codeList.push({
|
|
3563
|
-
id: codeId,
|
|
3564
|
-
name: value.name,
|
|
3565
|
-
codeBlockContent: value,
|
|
3566
|
-
showRelation: true,
|
|
3567
|
-
combineInfo: getBindCompsByCodeId(codeId)
|
|
3568
|
-
});
|
|
3569
|
-
});
|
|
3570
|
-
};
|
|
3571
|
-
vue.watch(
|
|
3572
|
-
() => services?.editorService.get("root"),
|
|
3573
|
-
() => {
|
|
3574
|
-
services?.codeBlockService.refreshAllRelations();
|
|
3575
|
-
refreshCodeList();
|
|
3576
|
-
},
|
|
3577
|
-
{
|
|
3578
|
-
immediate: true
|
|
3579
|
-
}
|
|
3580
|
-
);
|
|
3581
|
-
vue.watch(
|
|
3582
|
-
[() => services?.codeBlockService.getCodeDslSync(), () => services?.codeBlockService.getCombineInfo()],
|
|
3583
|
-
() => {
|
|
3584
|
-
refreshCodeList();
|
|
3585
|
-
},
|
|
3586
|
-
{
|
|
3587
|
-
deep: true
|
|
3588
|
-
}
|
|
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
|
+
}))
|
|
3589
3764
|
);
|
|
3765
|
+
const editable = vue.computed(() => codeBlockService?.getEditStatus());
|
|
3766
|
+
const isShowCodeBlockEditor = vue.computed(() => codeBlockService?.getCodeEditorShowStatus() || false);
|
|
3590
3767
|
const createCodeBlock = async () => {
|
|
3591
|
-
const { codeBlockService } = services || {};
|
|
3592
3768
|
if (!codeBlockService) {
|
|
3593
3769
|
design.tMagicMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
|
|
3594
3770
|
return;
|
|
@@ -3605,14 +3781,14 @@
|
|
|
3605
3781
|
codeBlockService.setCodeEditorContent(true, id);
|
|
3606
3782
|
};
|
|
3607
3783
|
const editCode = async (key) => {
|
|
3608
|
-
|
|
3784
|
+
codeBlockService?.setCodeEditorContent(true, key);
|
|
3609
3785
|
};
|
|
3610
3786
|
const deleteCode = (key) => {
|
|
3611
|
-
const currentCode =
|
|
3612
|
-
const existBinds =
|
|
3613
|
-
const undeleteableList =
|
|
3787
|
+
const currentCode = codeList.value.find((codeItem) => codeItem.id === key);
|
|
3788
|
+
const existBinds = Boolean(currentCode?.children.length);
|
|
3789
|
+
const undeleteableList = codeBlockService?.getUndeletableList() || [];
|
|
3614
3790
|
if (!existBinds && !undeleteableList.includes(key)) {
|
|
3615
|
-
|
|
3791
|
+
codeBlockService?.deleteCodeDslByIds([key]);
|
|
3616
3792
|
} else {
|
|
3617
3793
|
if (typeof props.customError === "function") {
|
|
3618
3794
|
props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
|
|
@@ -3627,27 +3803,23 @@
|
|
|
3627
3803
|
if (!value) {
|
|
3628
3804
|
return true;
|
|
3629
3805
|
}
|
|
3630
|
-
return `${data.name}${data.id}`.indexOf(value) !== -1;
|
|
3806
|
+
return `${data.name}${data.id}`.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) !== -1;
|
|
3631
3807
|
};
|
|
3632
3808
|
const filterTextChangeHandler = (val) => {
|
|
3633
3809
|
tree.value?.filter(val);
|
|
3634
3810
|
};
|
|
3635
|
-
const toggleCombineRelation = (data) => {
|
|
3636
|
-
const { id } = data;
|
|
3637
|
-
const currentCode = state.codeList.find((item) => item.id === id);
|
|
3638
|
-
if (!currentCode)
|
|
3639
|
-
return;
|
|
3640
|
-
currentCode.showRelation = !currentCode?.showRelation;
|
|
3641
|
-
};
|
|
3642
|
-
const getCompName = (compId) => {
|
|
3643
|
-
const node = services?.editorService.getNodeById(compId);
|
|
3644
|
-
return node?.name || String(compId);
|
|
3645
|
-
};
|
|
3646
3811
|
const selectComp = (compId) => {
|
|
3647
|
-
const stage =
|
|
3648
|
-
|
|
3812
|
+
const stage = editorService?.get("stage");
|
|
3813
|
+
editorService?.select(compId);
|
|
3649
3814
|
stage?.select(compId);
|
|
3650
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
|
+
};
|
|
3651
3823
|
return (_ctx, _cache) => {
|
|
3652
3824
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
|
|
3653
3825
|
vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
@@ -3677,16 +3849,18 @@
|
|
|
3677
3849
|
]),
|
|
3678
3850
|
vue.createVNode(vue.unref(design.TMagicScrollbar), null, {
|
|
3679
3851
|
default: vue.withCtx(() => [
|
|
3680
|
-
|
|
3681
|
-
key: 0,
|
|
3852
|
+
vue.createVNode(vue.unref(design.TMagicTree), {
|
|
3682
3853
|
ref_key: "tree",
|
|
3683
3854
|
ref: tree,
|
|
3855
|
+
class: "magic-editor-layer-tree",
|
|
3684
3856
|
"node-key": "id",
|
|
3685
3857
|
"empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
|
|
3686
|
-
|
|
3858
|
+
"default-expand-all": "",
|
|
3859
|
+
"expand-on-click-node": false,
|
|
3860
|
+
data: vue.unref(codeList),
|
|
3687
3861
|
"highlight-current": true,
|
|
3688
3862
|
"filter-node-method": filterNode,
|
|
3689
|
-
onNodeClick:
|
|
3863
|
+
onNodeClick: clickHandler
|
|
3690
3864
|
}, {
|
|
3691
3865
|
default: vue.withCtx(({ data }) => [
|
|
3692
3866
|
vue.createElementVNode("div", {
|
|
@@ -3695,14 +3869,14 @@
|
|
|
3695
3869
|
}, [
|
|
3696
3870
|
vue.createElementVNode("div", _hoisted_5, [
|
|
3697
3871
|
vue.createElementVNode("span", _hoisted_6, vue.toDisplayString(data.name) + "\uFF08" + vue.toDisplayString(data.id) + "\uFF09", 1),
|
|
3698
|
-
vue.
|
|
3872
|
+
data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
|
|
3699
3873
|
vue.createVNode(vue.unref(design.TMagicTooltip), {
|
|
3700
3874
|
effect: "dark",
|
|
3701
3875
|
content: vue.unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
|
|
3702
3876
|
placement: "bottom"
|
|
3703
3877
|
}, {
|
|
3704
3878
|
default: vue.withCtx(() => [
|
|
3705
|
-
vue.createVNode(_sfc_main$
|
|
3879
|
+
vue.createVNode(_sfc_main$u, {
|
|
3706
3880
|
icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
|
|
3707
3881
|
class: "edit-icon",
|
|
3708
3882
|
onClick: vue.withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
@@ -3710,29 +3884,14 @@
|
|
|
3710
3884
|
]),
|
|
3711
3885
|
_: 2
|
|
3712
3886
|
}, 1032, ["content"]),
|
|
3713
|
-
data.combineInfo && data.combineInfo.length > 0 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
3714
|
-
key: 0,
|
|
3715
|
-
effect: "dark",
|
|
3716
|
-
content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
|
|
3717
|
-
placement: "bottom"
|
|
3718
|
-
}, {
|
|
3719
|
-
default: vue.withCtx(() => [
|
|
3720
|
-
vue.createVNode(_sfc_main$s, {
|
|
3721
|
-
icon: vue.unref(iconsVue.Link),
|
|
3722
|
-
class: "edit-icon",
|
|
3723
|
-
onClick: vue.withModifiers(($event) => toggleCombineRelation(data), ["stop"])
|
|
3724
|
-
}, null, 8, ["icon", "onClick"])
|
|
3725
|
-
]),
|
|
3726
|
-
_: 2
|
|
3727
|
-
}, 1024)) : vue.createCommentVNode("", true),
|
|
3728
3887
|
vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
3729
|
-
key:
|
|
3888
|
+
key: 0,
|
|
3730
3889
|
effect: "dark",
|
|
3731
3890
|
content: "\u5220\u9664",
|
|
3732
3891
|
placement: "bottom"
|
|
3733
3892
|
}, {
|
|
3734
3893
|
default: vue.withCtx(() => [
|
|
3735
|
-
vue.createVNode(_sfc_main$
|
|
3894
|
+
vue.createVNode(_sfc_main$u, {
|
|
3736
3895
|
icon: vue.unref(iconsVue.Close),
|
|
3737
3896
|
class: "edit-icon",
|
|
3738
3897
|
onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
@@ -3744,29 +3903,12 @@
|
|
|
3744
3903
|
id: data.id,
|
|
3745
3904
|
data: data.codeBlockContent
|
|
3746
3905
|
})
|
|
3747
|
-
])
|
|
3748
|
-
])
|
|
3749
|
-
data.showRelation && data.combineInfo && data.combineInfo.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
|
|
3750
|
-
_hoisted_9,
|
|
3751
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(data.combineInfo, (comp, index) => {
|
|
3752
|
-
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
3753
|
-
key: index,
|
|
3754
|
-
class: "code-comp",
|
|
3755
|
-
size: "small",
|
|
3756
|
-
plain: true,
|
|
3757
|
-
onClick: vue.withModifiers(($event) => selectComp(comp.compId), ["stop"])
|
|
3758
|
-
}, {
|
|
3759
|
-
default: vue.withCtx(() => [
|
|
3760
|
-
vue.createTextVNode(vue.toDisplayString(comp.compName), 1)
|
|
3761
|
-
]),
|
|
3762
|
-
_: 2
|
|
3763
|
-
}, 1032, ["onClick"]);
|
|
3764
|
-
}), 128))
|
|
3765
|
-
])) : vue.createCommentVNode("", true)
|
|
3906
|
+
])) : vue.createCommentVNode("", true)
|
|
3907
|
+
])
|
|
3766
3908
|
], 8, _hoisted_4)
|
|
3767
3909
|
]),
|
|
3768
3910
|
_: 3
|
|
3769
|
-
}, 8, ["data"])
|
|
3911
|
+
}, 8, ["data"])
|
|
3770
3912
|
]),
|
|
3771
3913
|
_: 3
|
|
3772
3914
|
}),
|
|
@@ -3878,7 +4020,7 @@
|
|
|
3878
4020
|
name: `${index}`
|
|
3879
4021
|
}, {
|
|
3880
4022
|
title: vue.withCtx(() => [
|
|
3881
|
-
vue.createVNode(_sfc_main$
|
|
4023
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
|
|
3882
4024
|
vue.createTextVNode(vue.toDisplayString(group.title), 1)
|
|
3883
4025
|
]),
|
|
3884
4026
|
default: vue.withCtx(() => [
|
|
@@ -3893,7 +4035,7 @@
|
|
|
3893
4035
|
onDrag: dragHandler
|
|
3894
4036
|
}, [
|
|
3895
4037
|
vue.renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
|
|
3896
|
-
vue.createVNode(_sfc_main$
|
|
4038
|
+
vue.createVNode(_sfc_main$u, {
|
|
3897
4039
|
icon: item.icon
|
|
3898
4040
|
}, null, 8, ["icon"]),
|
|
3899
4041
|
vue.createVNode(vue.unref(design.TMagicTooltip), {
|
|
@@ -4494,7 +4636,7 @@
|
|
|
4494
4636
|
(vue.openBlock(), vue.createElementBlock("div", {
|
|
4495
4637
|
key: config.text
|
|
4496
4638
|
}, [
|
|
4497
|
-
config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$
|
|
4639
|
+
config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
|
|
4498
4640
|
key: 0,
|
|
4499
4641
|
icon: config.icon
|
|
4500
4642
|
}, null, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
@@ -4715,14 +4857,14 @@
|
|
|
4715
4857
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4716
4858
|
onClick: addPage
|
|
4717
4859
|
}, [
|
|
4718
|
-
vue.createVNode(_sfc_main$
|
|
4860
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
|
|
4719
4861
|
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1)),
|
|
4720
4862
|
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
4721
4863
|
key: 2,
|
|
4722
4864
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4723
4865
|
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
4724
4866
|
}, [
|
|
4725
|
-
vue.createVNode(_sfc_main$
|
|
4867
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
|
|
4726
4868
|
])) : vue.createCommentVNode("", true),
|
|
4727
4869
|
vue.unref(pageLength) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
4728
4870
|
key: 3,
|
|
@@ -4738,7 +4880,7 @@
|
|
|
4738
4880
|
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
4739
4881
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
4740
4882
|
}, [
|
|
4741
|
-
vue.createVNode(_sfc_main$
|
|
4883
|
+
vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
|
|
4742
4884
|
])) : vue.createCommentVNode("", true)
|
|
4743
4885
|
], 512);
|
|
4744
4886
|
};
|
|
@@ -5629,13 +5771,10 @@
|
|
|
5629
5771
|
id: "",
|
|
5630
5772
|
editable: true,
|
|
5631
5773
|
combineIds: [],
|
|
5632
|
-
undeletableList: []
|
|
5633
|
-
relations: {}
|
|
5774
|
+
undeletableList: []
|
|
5634
5775
|
});
|
|
5635
5776
|
constructor() {
|
|
5636
5777
|
super([
|
|
5637
|
-
"setCodeDsl",
|
|
5638
|
-
"getCodeDsl",
|
|
5639
5778
|
"getCodeContentById",
|
|
5640
5779
|
"getCodeDslByIds",
|
|
5641
5780
|
"getCurrentDsl",
|
|
@@ -5649,17 +5788,10 @@
|
|
|
5649
5788
|
}
|
|
5650
5789
|
async setCodeDsl(codeDsl2) {
|
|
5651
5790
|
this.state.codeDsl = codeDsl2;
|
|
5652
|
-
await editorService.setCodeDsl(this.state.codeDsl);
|
|
5653
5791
|
info("[code-block]:code-dsl-change", this.state.codeDsl);
|
|
5654
5792
|
this.emit("code-dsl-change", this.state.codeDsl);
|
|
5655
5793
|
}
|
|
5656
|
-
|
|
5657
|
-
return this.getCodeDslSync(forceRefresh);
|
|
5658
|
-
}
|
|
5659
|
-
getCodeDslSync(forceRefresh = false) {
|
|
5660
|
-
if (!this.state.codeDsl || forceRefresh) {
|
|
5661
|
-
this.state.codeDsl = editorService.getCodeDslSync();
|
|
5662
|
-
}
|
|
5794
|
+
getCodeDsl() {
|
|
5663
5795
|
return this.state.codeDsl;
|
|
5664
5796
|
}
|
|
5665
5797
|
async getCodeContentById(id2) {
|
|
@@ -5671,28 +5803,20 @@
|
|
|
5671
5803
|
return totalCodeDsl[id2] ?? null;
|
|
5672
5804
|
}
|
|
5673
5805
|
async setCodeDslById(id, codeConfig) {
|
|
5674
|
-
|
|
5806
|
+
const codeDsl = await this.getCodeDsl();
|
|
5807
|
+
if (!codeDsl) {
|
|
5808
|
+
throw new Error("dsl\u4E2D\u6CA1\u6709codeBlocks");
|
|
5809
|
+
}
|
|
5675
5810
|
const codeConfigProcessed = codeConfig;
|
|
5676
5811
|
if (codeConfig.content) {
|
|
5677
5812
|
codeConfigProcessed.content = eval(codeConfig.content);
|
|
5678
5813
|
}
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
} else {
|
|
5686
|
-
const existContent = codeDsl[id] || {};
|
|
5687
|
-
codeDsl = {
|
|
5688
|
-
...codeDsl,
|
|
5689
|
-
[id]: {
|
|
5690
|
-
...existContent,
|
|
5691
|
-
...codeConfigProcessed
|
|
5692
|
-
}
|
|
5693
|
-
};
|
|
5694
|
-
}
|
|
5695
|
-
await this.setCodeDsl(codeDsl);
|
|
5814
|
+
const existContent = codeDsl[id] || {};
|
|
5815
|
+
codeDsl[id] = {
|
|
5816
|
+
...existContent,
|
|
5817
|
+
...codeConfigProcessed
|
|
5818
|
+
};
|
|
5819
|
+
this.emit("addOrUpdate", id, codeDsl[id]);
|
|
5696
5820
|
}
|
|
5697
5821
|
async getCodeDslByIds(ids) {
|
|
5698
5822
|
const codeDsl2 = await this.getCodeDsl();
|
|
@@ -5733,39 +5857,6 @@
|
|
|
5733
5857
|
getCombineIds() {
|
|
5734
5858
|
return this.state.combineIds;
|
|
5735
5859
|
}
|
|
5736
|
-
addCodeRelationListener() {
|
|
5737
|
-
editorService.on("update", (nodes) => {
|
|
5738
|
-
const relations = lodashEs.cloneDeep(this.state.relations);
|
|
5739
|
-
nodes.forEach((node) => {
|
|
5740
|
-
if (node?.id) {
|
|
5741
|
-
relations[node.id] = [];
|
|
5742
|
-
this.getNodeRelation(node, relations);
|
|
5743
|
-
}
|
|
5744
|
-
});
|
|
5745
|
-
this.state.relations = { ...relations };
|
|
5746
|
-
});
|
|
5747
|
-
editorService.on("remove", (nodes) => {
|
|
5748
|
-
nodes.forEach((node) => {
|
|
5749
|
-
this.state.relations = this.deleteNodeRelation(node, this.state.relations);
|
|
5750
|
-
});
|
|
5751
|
-
});
|
|
5752
|
-
editorService.on("history-change", (page) => {
|
|
5753
|
-
const relations = {};
|
|
5754
|
-
this.getNodeRelation(page, relations, true);
|
|
5755
|
-
this.state.relations = relations;
|
|
5756
|
-
});
|
|
5757
|
-
}
|
|
5758
|
-
refreshAllRelations() {
|
|
5759
|
-
const root = editorService.get("root");
|
|
5760
|
-
if (!root)
|
|
5761
|
-
return;
|
|
5762
|
-
const relations = {};
|
|
5763
|
-
this.getNodeRelation(root, relations, true);
|
|
5764
|
-
this.state.relations = relations;
|
|
5765
|
-
}
|
|
5766
|
-
getCombineInfo() {
|
|
5767
|
-
return this.state.relations;
|
|
5768
|
-
}
|
|
5769
5860
|
getUndeletableList() {
|
|
5770
5861
|
return this.state.undeletableList;
|
|
5771
5862
|
}
|
|
@@ -5783,90 +5874,272 @@
|
|
|
5783
5874
|
}
|
|
5784
5875
|
async deleteCodeDslByIds(codeIds) {
|
|
5785
5876
|
const currentDsl = await this.getCodeDsl();
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5877
|
+
if (!currentDsl)
|
|
5878
|
+
return;
|
|
5879
|
+
codeIds.forEach((id2) => {
|
|
5880
|
+
delete currentDsl[id2];
|
|
5881
|
+
this.emit("remove", id2);
|
|
5882
|
+
});
|
|
5883
|
+
}
|
|
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;
|
|
5789
5917
|
}
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
const dsl = await this.getCodeDsl();
|
|
5793
|
-
const existedIds = lodashEs.keys(dsl);
|
|
5794
|
-
if (!existedIds.includes(newId))
|
|
5795
|
-
return newId;
|
|
5796
|
-
return await this.getUniqueId();
|
|
5918
|
+
getList() {
|
|
5919
|
+
return this.state.list;
|
|
5797
5920
|
}
|
|
5798
5921
|
resetState() {
|
|
5799
|
-
this.state.
|
|
5800
|
-
this.state.codeDsl = null;
|
|
5801
|
-
this.state.id = "";
|
|
5802
|
-
this.state.editable = true;
|
|
5803
|
-
this.state.combineIds = [];
|
|
5804
|
-
this.state.undeletableList = [];
|
|
5922
|
+
this.state.list = [];
|
|
5805
5923
|
}
|
|
5806
5924
|
destroy() {
|
|
5807
5925
|
this.resetState();
|
|
5808
5926
|
this.removeAllListeners();
|
|
5809
5927
|
this.removeAllPlugins();
|
|
5810
5928
|
}
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
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];
|
|
5820
5977
|
}
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
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];
|
|
5826
6007
|
}
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
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;
|
|
5833
6015
|
}
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
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];
|
|
5838
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
|
+
});
|
|
5839
6052
|
});
|
|
5840
6053
|
}
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
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
|
+
}
|
|
5848
6067
|
});
|
|
5849
|
-
}
|
|
5850
|
-
|
|
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);
|
|
5851
6095
|
}
|
|
5852
6096
|
}
|
|
5853
|
-
const
|
|
6097
|
+
const depService = new Watcher();
|
|
5854
6098
|
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
});
|
|
6099
|
+
let eventMap = vue.reactive({});
|
|
6100
|
+
let methodMap = vue.reactive({});
|
|
6101
|
+
class Events extends BaseService {
|
|
5859
6102
|
constructor() {
|
|
5860
6103
|
super([]);
|
|
5861
6104
|
}
|
|
5862
|
-
|
|
5863
|
-
|
|
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
|
+
});
|
|
5864
6117
|
}
|
|
5865
|
-
|
|
5866
|
-
|
|
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);
|
|
5867
6139
|
}
|
|
5868
6140
|
resetState() {
|
|
5869
|
-
|
|
6141
|
+
eventMap = vue.reactive({});
|
|
6142
|
+
methodMap = vue.reactive({});
|
|
5870
6143
|
}
|
|
5871
6144
|
destroy() {
|
|
5872
6145
|
this.resetState();
|
|
@@ -5874,7 +6147,252 @@
|
|
|
5874
6147
|
this.removeAllPlugins();
|
|
5875
6148
|
}
|
|
5876
6149
|
}
|
|
5877
|
-
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
|
+
};
|
|
5878
6396
|
|
|
5879
6397
|
const _sfc_main = vue.defineComponent({
|
|
5880
6398
|
name: "m-editor",
|
|
@@ -5885,179 +6403,9 @@
|
|
|
5885
6403
|
PropsPanel: _sfc_main$i,
|
|
5886
6404
|
Framework: _sfc_main$l
|
|
5887
6405
|
},
|
|
5888
|
-
props:
|
|
5889
|
-
modelValue: {
|
|
5890
|
-
type: Object,
|
|
5891
|
-
default: () => ({}),
|
|
5892
|
-
require: true
|
|
5893
|
-
},
|
|
5894
|
-
componentGroupList: {
|
|
5895
|
-
type: Array,
|
|
5896
|
-
default: () => []
|
|
5897
|
-
},
|
|
5898
|
-
sidebar: {
|
|
5899
|
-
type: Object
|
|
5900
|
-
},
|
|
5901
|
-
menu: {
|
|
5902
|
-
type: Object,
|
|
5903
|
-
default: () => ({ left: [], right: [] })
|
|
5904
|
-
},
|
|
5905
|
-
layerContentMenu: {
|
|
5906
|
-
type: Array,
|
|
5907
|
-
default: () => []
|
|
5908
|
-
},
|
|
5909
|
-
stageContentMenu: {
|
|
5910
|
-
type: Array,
|
|
5911
|
-
default: () => []
|
|
5912
|
-
},
|
|
5913
|
-
render: {
|
|
5914
|
-
type: Function
|
|
5915
|
-
},
|
|
5916
|
-
runtimeUrl: String,
|
|
5917
|
-
autoScrollIntoView: Boolean,
|
|
5918
|
-
propsConfigs: {
|
|
5919
|
-
type: Object,
|
|
5920
|
-
default: () => ({})
|
|
5921
|
-
},
|
|
5922
|
-
propsValues: {
|
|
5923
|
-
type: Object,
|
|
5924
|
-
default: () => ({})
|
|
5925
|
-
},
|
|
5926
|
-
eventMethodList: {
|
|
5927
|
-
type: Object,
|
|
5928
|
-
default: () => ({})
|
|
5929
|
-
},
|
|
5930
|
-
moveableOptions: {
|
|
5931
|
-
type: [Object, Function]
|
|
5932
|
-
},
|
|
5933
|
-
defaultSelected: {
|
|
5934
|
-
type: [Number, String]
|
|
5935
|
-
},
|
|
5936
|
-
canSelect: {
|
|
5937
|
-
type: Function,
|
|
5938
|
-
default: (el) => Boolean(el.id)
|
|
5939
|
-
},
|
|
5940
|
-
isContainer: {
|
|
5941
|
-
type: Function,
|
|
5942
|
-
default: (el) => el.classList.contains("magic-ui-container")
|
|
5943
|
-
},
|
|
5944
|
-
containerHighlightClassName: {
|
|
5945
|
-
type: String,
|
|
5946
|
-
default: StageCore.CONTAINER_HIGHLIGHT_CLASS_NAME
|
|
5947
|
-
},
|
|
5948
|
-
containerHighlightDuration: {
|
|
5949
|
-
type: Number,
|
|
5950
|
-
default: 800
|
|
5951
|
-
},
|
|
5952
|
-
containerHighlightType: {
|
|
5953
|
-
type: String,
|
|
5954
|
-
default: StageCore.ContainerHighlightType.DEFAULT
|
|
5955
|
-
},
|
|
5956
|
-
stageRect: {
|
|
5957
|
-
type: [String, Object]
|
|
5958
|
-
},
|
|
5959
|
-
codeOptions: {
|
|
5960
|
-
type: Object,
|
|
5961
|
-
default: () => ({})
|
|
5962
|
-
},
|
|
5963
|
-
updateDragEl: {
|
|
5964
|
-
type: Function
|
|
5965
|
-
},
|
|
5966
|
-
disabledDragStart: {
|
|
5967
|
-
type: Boolean
|
|
5968
|
-
}
|
|
5969
|
-
},
|
|
6406
|
+
props: editorProps,
|
|
5970
6407
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
5971
6408
|
setup(props, { emit }) {
|
|
5972
|
-
const rootChangeHandler = (value, preValue) => {
|
|
5973
|
-
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
5974
|
-
let node;
|
|
5975
|
-
if (nodeId) {
|
|
5976
|
-
node = editorService.getNodeById(nodeId);
|
|
5977
|
-
}
|
|
5978
|
-
if (node && node !== value) {
|
|
5979
|
-
editorService.select(node.id);
|
|
5980
|
-
} else if (value?.items?.length) {
|
|
5981
|
-
editorService.select(value.items[0]);
|
|
5982
|
-
} else if (value?.id) {
|
|
5983
|
-
editorService.set("nodes", [value]);
|
|
5984
|
-
editorService.set("parent", null);
|
|
5985
|
-
editorService.set("page", null);
|
|
5986
|
-
}
|
|
5987
|
-
if (vue.toRaw(value) !== vue.toRaw(preValue)) {
|
|
5988
|
-
emit("update:modelValue", value);
|
|
5989
|
-
}
|
|
5990
|
-
};
|
|
5991
|
-
editorService.on("root-change", rootChangeHandler);
|
|
5992
|
-
vue.watch(
|
|
5993
|
-
() => props.modelValue,
|
|
5994
|
-
(modelValue) => {
|
|
5995
|
-
editorService.set("root", modelValue);
|
|
5996
|
-
},
|
|
5997
|
-
{
|
|
5998
|
-
immediate: true
|
|
5999
|
-
}
|
|
6000
|
-
);
|
|
6001
|
-
vue.watch(
|
|
6002
|
-
() => props.componentGroupList,
|
|
6003
|
-
(componentGroupList) => componentListService.setList(componentGroupList),
|
|
6004
|
-
{
|
|
6005
|
-
immediate: true
|
|
6006
|
-
}
|
|
6007
|
-
);
|
|
6008
|
-
vue.watch(
|
|
6009
|
-
() => props.propsConfigs,
|
|
6010
|
-
(configs) => propsService.setPropsConfigs(configs),
|
|
6011
|
-
{
|
|
6012
|
-
immediate: true
|
|
6013
|
-
}
|
|
6014
|
-
);
|
|
6015
|
-
vue.watch(
|
|
6016
|
-
() => props.propsValues,
|
|
6017
|
-
(values) => propsService.setPropsValues(values),
|
|
6018
|
-
{
|
|
6019
|
-
immediate: true
|
|
6020
|
-
}
|
|
6021
|
-
);
|
|
6022
|
-
vue.watch(
|
|
6023
|
-
() => props.eventMethodList,
|
|
6024
|
-
(eventMethodList) => {
|
|
6025
|
-
const eventsList = {};
|
|
6026
|
-
const methodsList = {};
|
|
6027
|
-
Object.keys(eventMethodList).forEach((type) => {
|
|
6028
|
-
eventsList[type] = eventMethodList[type].events;
|
|
6029
|
-
methodsList[type] = eventMethodList[type].methods;
|
|
6030
|
-
});
|
|
6031
|
-
eventsService.setEvents(eventsList);
|
|
6032
|
-
eventsService.setMethods(methodsList);
|
|
6033
|
-
},
|
|
6034
|
-
{
|
|
6035
|
-
immediate: true
|
|
6036
|
-
}
|
|
6037
|
-
);
|
|
6038
|
-
vue.watch(
|
|
6039
|
-
() => props.defaultSelected,
|
|
6040
|
-
(defaultSelected) => defaultSelected && editorService.select(defaultSelected),
|
|
6041
|
-
{
|
|
6042
|
-
immediate: true
|
|
6043
|
-
}
|
|
6044
|
-
);
|
|
6045
|
-
vue.watch(
|
|
6046
|
-
() => props.stageRect,
|
|
6047
|
-
(stageRect) => stageRect && uiService.set("stageRect", stageRect),
|
|
6048
|
-
{
|
|
6049
|
-
immediate: true
|
|
6050
|
-
}
|
|
6051
|
-
);
|
|
6052
|
-
vue.onUnmounted(() => {
|
|
6053
|
-
editorService.resetState();
|
|
6054
|
-
historyService.resetState();
|
|
6055
|
-
propsService.resetState();
|
|
6056
|
-
uiService.resetState();
|
|
6057
|
-
componentListService.resetState();
|
|
6058
|
-
codeBlockService.resetState();
|
|
6059
|
-
editorService.off("root-change", rootChangeHandler);
|
|
6060
|
-
});
|
|
6061
6409
|
const services = {
|
|
6062
6410
|
componentListService,
|
|
6063
6411
|
eventsService,
|
|
@@ -6066,8 +6414,11 @@
|
|
|
6066
6414
|
editorService,
|
|
6067
6415
|
uiService,
|
|
6068
6416
|
storageService,
|
|
6069
|
-
codeBlockService
|
|
6417
|
+
codeBlockService,
|
|
6418
|
+
depService
|
|
6070
6419
|
};
|
|
6420
|
+
initServiceEvents(props, emit, services);
|
|
6421
|
+
initServiceState(props, services);
|
|
6071
6422
|
vue.provide("services", services);
|
|
6072
6423
|
vue.provide("codeOptions", props.codeOptions);
|
|
6073
6424
|
vue.provide(
|
|
@@ -6086,7 +6437,6 @@
|
|
|
6086
6437
|
disabledDragStart: props.disabledDragStart
|
|
6087
6438
|
})
|
|
6088
6439
|
);
|
|
6089
|
-
codeBlockService.addCodeRelationListener();
|
|
6090
6440
|
return services;
|
|
6091
6441
|
}
|
|
6092
6442
|
});
|
|
@@ -6197,10 +6547,12 @@
|
|
|
6197
6547
|
setConfig(option);
|
|
6198
6548
|
app.component(Editor.name, Editor);
|
|
6199
6549
|
app.component("m-fields-ui-select", _sfc_main$q);
|
|
6200
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
6201
|
-
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);
|
|
6202
6552
|
app.component("magic-code-editor", _sfc_main$p);
|
|
6203
|
-
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);
|
|
6204
6556
|
}
|
|
6205
6557
|
};
|
|
6206
6558
|
|
|
@@ -6208,13 +6560,15 @@
|
|
|
6208
6560
|
exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
|
|
6209
6561
|
exports.CodeBlockList = _sfc_main$e;
|
|
6210
6562
|
exports.CodeDeleteErrorType = CodeDeleteErrorType;
|
|
6211
|
-
exports.CodeSelect = _sfc_main$
|
|
6563
|
+
exports.CodeSelect = _sfc_main$t;
|
|
6564
|
+
exports.CodeSelectCol = _sfc_main$s;
|
|
6212
6565
|
exports.ColumnLayout = ColumnLayout;
|
|
6213
6566
|
exports.ComponentListPanel = _sfc_main$d;
|
|
6214
6567
|
exports.ContentMenu = _sfc_main$c;
|
|
6568
|
+
exports.EventSelect = _sfc_main$r;
|
|
6215
6569
|
exports.Fixed2Other = Fixed2Other;
|
|
6216
6570
|
exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
|
|
6217
|
-
exports.Icon = _sfc_main$
|
|
6571
|
+
exports.Icon = _sfc_main$u;
|
|
6218
6572
|
exports.Keys = Keys;
|
|
6219
6573
|
exports.LayerOffset = LayerOffset;
|
|
6220
6574
|
exports.LayerPanel = _sfc_main$a;
|
|
@@ -6230,6 +6584,7 @@
|
|
|
6230
6584
|
exports.codeBlockService = codeBlockService;
|
|
6231
6585
|
exports.debug = debug;
|
|
6232
6586
|
exports.default = index;
|
|
6587
|
+
exports.depService = depService;
|
|
6233
6588
|
exports.editorService = editorService;
|
|
6234
6589
|
exports.error = error;
|
|
6235
6590
|
exports.eventsService = eventsService;
|