@tmagic/editor 1.2.12 → 1.2.14

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.
Files changed (99) hide show
  1. package/dist/style.css +61 -39
  2. package/dist/tmagic-editor.js +890 -518
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +909 -544
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +14 -13
  7. package/src/components/CodeDraftEditor.vue +20 -17
  8. package/src/components/ContentMenu.vue +1 -1
  9. package/src/components/FunctionEditor.vue +10 -10
  10. package/src/components/Layout.vue +1 -1
  11. package/src/components/ScrollViewer.vue +2 -2
  12. package/src/components/SearchInput.vue +26 -0
  13. package/src/fields/CodeSelect.vue +18 -101
  14. package/src/fields/CodeSelectCol.vue +21 -3
  15. package/src/fields/EventSelect.vue +5 -3
  16. package/src/fields/UISelect.vue +1 -1
  17. package/src/icons/AppManageIcon.vue +11 -0
  18. package/src/icons/CodeIcon.vue +35 -0
  19. package/src/layouts/AddPageBox.vue +3 -3
  20. package/src/layouts/Framework.vue +4 -4
  21. package/src/layouts/NavMenu.vue +2 -2
  22. package/src/layouts/PropsPanel.vue +1 -1
  23. package/src/layouts/sidebar/ComponentListPanel.vue +11 -12
  24. package/src/layouts/sidebar/LayerMenu.vue +2 -2
  25. package/src/layouts/sidebar/LayerPanel.vue +6 -15
  26. package/src/layouts/sidebar/Sidebar.vue +3 -3
  27. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +22 -10
  28. package/src/layouts/sidebar/code-block/CodeBlockList.vue +56 -51
  29. package/src/layouts/workspace/Breadcrumb.vue +1 -1
  30. package/src/layouts/workspace/PageBar.vue +2 -2
  31. package/src/layouts/workspace/PageBarScrollContainer.vue +3 -3
  32. package/src/layouts/workspace/Stage.vue +3 -3
  33. package/src/layouts/workspace/ViewerMenu.vue +4 -4
  34. package/src/layouts/workspace/Workspace.vue +1 -1
  35. package/src/services/BaseService.ts +1 -1
  36. package/src/services/codeBlock.ts +10 -13
  37. package/src/services/componentList.ts +1 -1
  38. package/src/services/editor.ts +6 -6
  39. package/src/services/events.ts +1 -1
  40. package/src/services/history.ts +2 -2
  41. package/src/services/props.ts +2 -2
  42. package/src/services/ui.ts +2 -2
  43. package/src/theme/code-block.scss +42 -11
  44. package/src/theme/component-list-panel.scss +0 -15
  45. package/src/theme/event.scss +12 -0
  46. package/src/theme/layer-panel.scss +0 -14
  47. package/src/theme/search-input.scss +14 -0
  48. package/src/theme/theme.scss +1 -0
  49. package/src/utils/config.ts +1 -1
  50. package/src/utils/dep.ts +2 -2
  51. package/src/utils/editor.ts +1 -1
  52. package/src/utils/operator.ts +4 -4
  53. package/src/utils/stage.ts +3 -3
  54. package/tsconfig.build.json +4 -1
  55. package/types/components/CodeDraftEditor.vue.d.ts +7 -4
  56. package/types/components/ContentMenu.vue.d.ts +3 -3
  57. package/types/components/FunctionEditor.vue.d.ts +140 -8
  58. package/types/components/Icon.vue.d.ts +2 -2
  59. package/types/components/Layout.vue.d.ts +28 -113
  60. package/types/components/ScrollBar.vue.d.ts +2 -2
  61. package/types/components/ScrollViewer.vue.d.ts +32 -135
  62. package/types/components/SearchInput.vue.d.ts +4 -0
  63. package/types/components/ToolButton.vue.d.ts +3 -3
  64. package/types/fields/Code.vue.d.ts +2 -2
  65. package/types/fields/CodeLink.vue.d.ts +2 -2
  66. package/types/fields/CodeSelect.vue.d.ts +8 -27
  67. package/types/fields/CodeSelectCol.vue.d.ts +3 -3
  68. package/types/fields/EventSelect.vue.d.ts +3 -3
  69. package/types/fields/UISelect.vue.d.ts +2 -2
  70. package/types/icons/AppManageIcon.vue.d.ts +2 -0
  71. package/types/icons/CodeIcon.vue.d.ts +2 -0
  72. package/types/layouts/CodeEditor.vue.d.ts +4 -4
  73. package/types/layouts/Framework.vue.d.ts +23 -74
  74. package/types/layouts/NavMenu.vue.d.ts +3 -3
  75. package/types/layouts/PropsPanel.vue.d.ts +11 -60
  76. package/types/layouts/Resizer.vue.d.ts +9 -54
  77. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +11 -50
  78. package/types/layouts/sidebar/LayerMenu.vue.d.ts +2 -2
  79. package/types/layouts/sidebar/LayerPanel.vue.d.ts +17 -60
  80. package/types/layouts/sidebar/Sidebar.vue.d.ts +39 -104
  81. package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +15 -58
  82. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +21 -66
  83. package/types/layouts/workspace/PageBar.vue.d.ts +13 -52
  84. package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +8 -48
  85. package/types/layouts/workspace/Stage.vue.d.ts +2 -2
  86. package/types/layouts/workspace/ViewerMenu.vue.d.ts +3 -3
  87. package/types/layouts/workspace/Workspace.vue.d.ts +20 -63
  88. package/types/services/codeBlock.d.ts +4 -4
  89. package/types/services/componentList.d.ts +1 -1
  90. package/types/services/dep.d.ts +2 -2
  91. package/types/services/editor.d.ts +1 -1
  92. package/types/services/events.d.ts +1 -1
  93. package/types/services/history.d.ts +2 -2
  94. package/types/services/props.d.ts +78 -1
  95. package/types/services/storage.d.ts +1 -1
  96. package/types/services/ui.d.ts +2 -2
  97. package/types/type.d.ts +8 -8
  98. package/types/utils/operator.d.ts +1 -1
  99. package/types/utils/props.d.ts +78 -1
@@ -1,13 +1,10 @@
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('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';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('lodash-es'), require('@tmagic/design'), require('@tmagic/schema'), require('@element-plus/icons-vue'), require('@tmagic/form'), require('monaco-editor'), require('gesto'), require('@tmagic/utils'), require('keycon'), require('@tmagic/stage'), require('events'), require('@tmagic/core')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'lodash-es', '@tmagic/design', '@tmagic/schema', '@element-plus/icons-vue', '@tmagic/form', 'monaco-editor', 'gesto', '@tmagic/utils', 'keycon', '@tmagic/stage', 'events', '@tmagic/core'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.lodashEs, global.design, global.schema, global.iconsVue, global.form, global.monaco, global.Gesto, global.utils, global.KeyController, global.StageCore, global.events, global.core));
5
+ })(this, (function (exports, vue, serialize, lodashEs, design, schema, iconsVue, form, monaco, Gesto, utils, KeyController, StageCore, events, core) { 'use strict';
6
6
 
7
- const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
8
-
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
7
+ function _interopNamespaceDefault(e) {
11
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
12
9
  if (e) {
13
10
  for (const k in e) {
@@ -24,16 +21,12 @@
24
21
  return Object.freeze(n);
25
22
  }
26
23
 
27
- const serialize__default = /*#__PURE__*/_interopDefaultLegacy(serialize);
28
- const monaco__namespace = /*#__PURE__*/_interopNamespace(monaco);
29
- const Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
30
- const StageCore__default = /*#__PURE__*/_interopDefaultLegacy(StageCore);
31
- const KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
24
+ const monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
32
25
 
33
26
  const __default__$v = vue.defineComponent({
34
27
  name: "MEditorCode"
35
28
  });
36
- const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
29
+ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
37
30
  ...__default__$v,
38
31
  props: {
39
32
  model: null,
@@ -66,7 +59,7 @@
66
59
  const __default__$u = vue.defineComponent({
67
60
  name: "MEditorCodeLink"
68
61
  });
69
- const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
62
+ const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
70
63
  ...__default__$u,
71
64
  props: {
72
65
  config: null,
@@ -104,7 +97,7 @@
104
97
  () => props.model[props.name],
105
98
  (value) => {
106
99
  modelValue.form = {
107
- [props.name]: serialize__default.default(value, {
100
+ [props.name]: serialize(value, {
108
101
  space: 2,
109
102
  unsafe: true
110
103
  }).replace(/"(\w+)":\s/g, "$1: ")
@@ -136,58 +129,13 @@
136
129
  }
137
130
  });
138
131
 
139
- const _hoisted_1$h = ["src"];
140
132
  const __default__$t = vue.defineComponent({
141
- name: "MEditorIcon"
142
- });
143
- const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
144
- ...__default__$t,
145
- props: {
146
- icon: null
147
- },
148
- setup(__props) {
149
- return (_ctx, _cache) => {
150
- return !__props.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
151
- key: 0,
152
- class: "magic-editor-icon"
153
- }, {
154
- default: vue.withCtx(() => [
155
- vue.createVNode(vue.unref(iconsVue.Edit))
156
- ]),
157
- _: 1
158
- })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
159
- key: 1,
160
- class: "magic-editor-icon"
161
- }, {
162
- default: vue.withCtx(() => [
163
- vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$h)
164
- ]),
165
- _: 1
166
- })) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
167
- key: 2,
168
- class: vue.normalizeClass(["magic-editor-icon", __props.icon])
169
- }, null, 2)) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
170
- key: 3,
171
- class: "magic-editor-icon"
172
- }, {
173
- default: vue.withCtx(() => [
174
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(__props.icon))))
175
- ]),
176
- _: 1
177
- }));
178
- };
179
- }
180
- });
181
-
182
- const __default__$s = vue.defineComponent({
183
133
  name: "MEditorCodeSelect"
184
134
  });
185
- const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
186
- ...__default__$s,
135
+ const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
136
+ ...__default__$t,
187
137
  props: {
188
- config: { default: () => ({
189
- editable: true
190
- }) },
138
+ config: null,
191
139
  model: null,
192
140
  prop: null,
193
141
  name: null,
@@ -196,55 +144,16 @@
196
144
  emits: ["change"],
197
145
  setup(__props, { emit }) {
198
146
  const props = __props;
199
- const services = vue.inject("services");
200
- const mForm = vue.inject("mForm");
201
- const codeDsl = vue.computed(() => services?.codeBlockService.getCodeDsl());
202
- const tableConfig = vue.computed(() => {
203
- const defaultConfig = {
204
- dropSort: false,
205
- enableFullscreen: false,
206
- border: true,
207
- operateColWidth: 60,
208
- items: [
209
- {
210
- type: "select",
211
- label: "\u4EE3\u7801\u5757",
212
- name: "codeId",
213
- width: "200px",
214
- options: () => {
215
- if (codeDsl.value) {
216
- return lodashEs.map(codeDsl.value, (value, key) => ({
217
- text: `${value.name}\uFF08${key}\uFF09`,
218
- label: `${value.name}\uFF08${key}\uFF09`,
219
- value: key
220
- }));
221
- }
222
- return [];
223
- },
224
- onChange: (formState, codeId, { model }) => {
225
- model.params = {};
226
- }
227
- },
228
- {
229
- name: "params",
230
- label: "\u53C2\u6570",
231
- defaultValue: {},
232
- itemsFunction: (row) => {
233
- const paramsConfig = getParamsConfig(row.codeId);
234
- if (!row.params || lodashEs.isEmpty(row.params)) {
235
- form.createValues(mForm, paramsConfig, {}, row.params);
236
- }
237
- return paramsConfig;
238
- }
239
- }
240
- ]
241
- };
242
- return {
243
- ...defaultConfig,
244
- ...props.config.tableConfig
245
- };
246
- });
247
- const editable = vue.computed(() => services?.codeBlockService.getEditStatus());
147
+ const codeConfig = vue.computed(() => ({
148
+ type: "group-list",
149
+ name: "hookData",
150
+ enableToggleMode: false,
151
+ items: [
152
+ {
153
+ type: "code-select-col"
154
+ }
155
+ ]
156
+ }));
248
157
  vue.watch(
249
158
  () => props.model[props.name],
250
159
  (value) => {
@@ -262,56 +171,75 @@
262
171
  const changeHandler = async () => {
263
172
  emit("change", props.model[props.name]);
264
173
  };
265
- const getParamsConfig = (codeId) => {
266
- if (!codeDsl.value)
267
- return [];
268
- const paramStatements = codeDsl.value[codeId]?.params;
269
- if (lodashEs.isEmpty(paramStatements))
270
- return [];
271
- return paramStatements.map((paramState) => ({
272
- labelWidth: "100px",
273
- text: paramState.name,
274
- inline: true,
275
- ...paramState
276
- }));
277
- };
278
- const editCode = (codeId) => {
279
- services?.codeBlockService.setCodeEditorContent(true, codeId);
280
- };
281
174
  return (_ctx, _cache) => {
282
- const _component_m_form_table = vue.resolveComponent("m-form-table");
175
+ const _component_m_form_container = vue.resolveComponent("m-form-container");
283
176
  return vue.openBlock(), vue.createElementBlock("div", {
284
177
  class: vue.normalizeClass(["m-fields-code-select", __props.config.className])
285
178
  }, [
286
- vue.createVNode(_component_m_form_table, {
287
- config: vue.unref(tableConfig),
288
- model: __props.model[__props.name],
289
- name: "hookData",
290
- enableToggleMode: false,
291
- prop: __props.prop,
292
- size: __props.size,
293
- onChange: changeHandler
294
- }, {
295
- operateCol: vue.withCtx(({ scope }) => [
296
- scope.row.codeId && __props.config.editable ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
297
- key: 0,
298
- icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
299
- class: "edit-icon",
300
- onClick: ($event) => editCode(scope.row.codeId)
301
- }, null, 8, ["icon", "onClick"])) : vue.createCommentVNode("", true)
179
+ vue.createVNode(vue.unref(design.TMagicCard), null, {
180
+ default: vue.withCtx(() => [
181
+ vue.createVNode(_component_m_form_container, {
182
+ config: vue.unref(codeConfig),
183
+ model: __props.model[__props.name],
184
+ onChange: changeHandler
185
+ }, null, 8, ["config", "model"])
302
186
  ]),
303
187
  _: 1
304
- }, 8, ["config", "model", "prop", "size"])
188
+ })
305
189
  ], 2);
306
190
  };
307
191
  }
308
192
  });
309
193
 
310
- const _hoisted_1$g = { class: "m-fields-code-select-col" };
194
+ const _hoisted_1$j = ["src"];
195
+ const __default__$s = vue.defineComponent({
196
+ name: "MEditorIcon"
197
+ });
198
+ const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
199
+ ...__default__$s,
200
+ props: {
201
+ icon: null
202
+ },
203
+ setup(__props) {
204
+ return (_ctx, _cache) => {
205
+ return !__props.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
206
+ key: 0,
207
+ class: "magic-editor-icon"
208
+ }, {
209
+ default: vue.withCtx(() => [
210
+ vue.createVNode(vue.unref(iconsVue.Edit))
211
+ ]),
212
+ _: 1
213
+ })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
214
+ key: 1,
215
+ class: "magic-editor-icon"
216
+ }, {
217
+ default: vue.withCtx(() => [
218
+ vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$j)
219
+ ]),
220
+ _: 1
221
+ })) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
222
+ key: 2,
223
+ class: vue.normalizeClass(["magic-editor-icon", __props.icon])
224
+ }, null, 2)) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
225
+ key: 3,
226
+ class: "magic-editor-icon"
227
+ }, {
228
+ default: vue.withCtx(() => [
229
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(__props.icon))))
230
+ ]),
231
+ _: 1
232
+ }));
233
+ };
234
+ }
235
+ });
236
+
237
+ const _hoisted_1$i = { class: "m-fields-code-select-col" };
238
+ const _hoisted_2$a = { class: "code-select-container" };
311
239
  const __default__$r = vue.defineComponent({
312
240
  name: "MEditorCodeSelectCol"
313
241
  });
314
- const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
242
+ const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
315
243
  ...__default__$r,
316
244
  props: {
317
245
  config: null,
@@ -326,24 +254,25 @@
326
254
  const services = vue.inject("services");
327
255
  const mForm = vue.inject("mForm");
328
256
  const codeDsl = vue.computed(() => services?.codeBlockService.getCodeDsl());
257
+ const editable = vue.computed(() => services?.codeBlockService.getEditStatus());
329
258
  const codeParamsConfig = vue.ref({
330
259
  type: "fieldset",
331
260
  items: [],
332
- legend: "\u53C2\u6570",
261
+ legend: "参数",
333
262
  labelWidth: "70px",
334
263
  name: "params",
335
264
  display: false
336
265
  });
337
266
  const selectConfig = {
338
267
  type: "select",
339
- text: "\u4EE3\u7801\u5757",
268
+ text: "代码块",
340
269
  name: "codeId",
341
270
  labelWidth: "70px",
342
271
  options: () => {
343
272
  if (codeDsl.value) {
344
273
  return lodashEs.map(codeDsl.value, (value, key) => ({
345
- text: `${value.name}\uFF08${key}\uFF09`,
346
- label: `${value.name}\uFF08${key}\uFF09`,
274
+ text: `${value.name}(${key})`,
275
+ label: `${value.name}(${key})`,
347
276
  value: key
348
277
  }));
349
278
  }
@@ -374,7 +303,7 @@
374
303
  codeParamsConfig.value = {
375
304
  type: "fieldset",
376
305
  items: paramsConfig,
377
- legend: "\u53C2\u6570",
306
+ legend: "参数",
378
307
  labelWidth: "70px",
379
308
  name: "params",
380
309
  display: !lodashEs.isEmpty(paramsConfig)
@@ -394,14 +323,25 @@
394
323
  immediate: true
395
324
  }
396
325
  );
326
+ const editCode = () => {
327
+ services?.codeBlockService.setCodeEditorContent(true, props.model.codeId);
328
+ };
397
329
  return (_ctx, _cache) => {
398
330
  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"]),
331
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$i, [
332
+ vue.createElementVNode("div", _hoisted_2$a, [
333
+ vue.createVNode(_component_m_form_container, {
334
+ class: "select",
335
+ config: selectConfig,
336
+ model: __props.model,
337
+ onChange: onParamsChangeHandler
338
+ }, null, 8, ["model"]),
339
+ vue.createVNode(_sfc_main$w, {
340
+ class: "icon",
341
+ icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
342
+ onClick: editCode
343
+ }, null, 8, ["icon"])
344
+ ]),
405
345
  vue.createVNode(_component_m_form_container, {
406
346
  config: codeParamsConfig.value,
407
347
  model: __props.model,
@@ -412,16 +352,16 @@
412
352
  }
413
353
  });
414
354
 
415
- const _hoisted_1$f = { class: "m-fields-event-select" };
416
- const _hoisted_2$7 = {
355
+ const _hoisted_1$h = { class: "m-fields-event-select" };
356
+ const _hoisted_2$9 = {
417
357
  key: 1,
418
358
  class: "fullWidth"
419
359
  };
420
- const _hoisted_3$4 = /* @__PURE__ */ vue.createTextVNode("\u6DFB\u52A0\u4E8B\u4EF6");
360
+ const _hoisted_3$5 = /* @__PURE__ */ vue.createTextVNode("添加事件");
421
361
  const __default__$q = vue.defineComponent({
422
362
  name: "MEditorEventSelect"
423
363
  });
424
- const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
364
+ const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
425
365
  ...__default__$q,
426
366
  props: {
427
367
  config: null,
@@ -437,7 +377,7 @@
437
377
  const eventNameConfig = vue.computed(() => {
438
378
  const defaultEventNameConfig = {
439
379
  name: "name",
440
- text: "\u4E8B\u4EF6",
380
+ text: "事件",
441
381
  type: "select",
442
382
  labelWidth: "40px",
443
383
  options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
@@ -450,19 +390,19 @@
450
390
  const actionTypeConfig = vue.computed(() => {
451
391
  const defaultActionTypeConfig = {
452
392
  name: "actionType",
453
- text: "\u8054\u52A8\u7C7B\u578B",
393
+ text: "联动类型",
454
394
  labelWidth: "70px",
455
395
  type: "select",
456
396
  defaultValue: schema.ActionType.COMP,
457
397
  options: () => [
458
398
  {
459
- text: "\u7EC4\u4EF6",
460
- label: "\u7EC4\u4EF6",
399
+ text: "组件",
400
+ label: "组件",
461
401
  value: schema.ActionType.COMP
462
402
  },
463
403
  {
464
- text: "\u4EE3\u7801",
465
- label: "\u4EE3\u7801",
404
+ text: "代码",
405
+ label: "代码",
466
406
  value: schema.ActionType.CODE
467
407
  }
468
408
  ]
@@ -472,7 +412,7 @@
472
412
  const targetCompConfig = vue.computed(() => {
473
413
  const defaultTargetCompConfig = {
474
414
  name: "to",
475
- text: "\u8054\u52A8\u7EC4\u4EF6",
415
+ text: "联动组件",
476
416
  labelWidth: "70px",
477
417
  type: "ui-select",
478
418
  display: (mForm, { model }) => model.actionType === schema.ActionType.COMP
@@ -482,7 +422,7 @@
482
422
  const compActionConfig = vue.computed(() => {
483
423
  const defaultCompActionConfig = {
484
424
  name: "method",
485
- text: "\u52A8\u4F5C",
425
+ text: "动作",
486
426
  labelWidth: "70px",
487
427
  type: "select",
488
428
  display: (mForm, { model }) => model.actionType === schema.ActionType.COMP,
@@ -511,7 +451,7 @@
511
451
  items: [
512
452
  {
513
453
  name: "name",
514
- label: "\u4E8B\u4EF6\u540D",
454
+ label: "事件名",
515
455
  type: eventNameConfig.value.type,
516
456
  options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
517
457
  text: option.label,
@@ -520,12 +460,12 @@
520
460
  },
521
461
  {
522
462
  name: "to",
523
- label: "\u8054\u52A8\u7EC4\u4EF6",
463
+ label: "联动组件",
524
464
  type: "ui-select"
525
465
  },
526
466
  {
527
467
  name: "method",
528
- label: "\u52A8\u4F5C",
468
+ label: "动作",
529
469
  type: compActionConfig.value.type,
530
470
  options: (mForm, { model }) => {
531
471
  const node = services?.editorService.getNodeById(model.to);
@@ -575,17 +515,19 @@
575
515
  emit("change", props.model);
576
516
  };
577
517
  return (_ctx, _cache) => {
518
+ const _component_m_form_table = vue.resolveComponent("m-form-table");
578
519
  const _component_m_form_container = vue.resolveComponent("m-form-container");
579
520
  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, {
521
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, [
522
+ vue.unref(isOldVersion) ? (vue.openBlock(), vue.createBlock(_component_m_form_table, {
582
523
  key: 0,
583
524
  ref: "eventForm",
584
525
  size: props.size,
585
526
  model: __props.model,
527
+ name: "events",
586
528
  config: vue.unref(tableConfig),
587
529
  onChange: onChangeHandler
588
- }, null, 8, ["size", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$7, [
530
+ }, null, 8, ["size", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$9, [
589
531
  vue.createVNode(vue.unref(design.TMagicButton), {
590
532
  class: "create-button",
591
533
  type: "primary",
@@ -593,7 +535,7 @@
593
535
  onClick: _cache[0] || (_cache[0] = ($event) => addEvent())
594
536
  }, {
595
537
  default: vue.withCtx(() => [
596
- _hoisted_3$4
538
+ _hoisted_3$5
597
539
  ]),
598
540
  _: 1
599
541
  }),
@@ -627,11 +569,11 @@
627
569
  }
628
570
  });
629
571
 
630
- const _hoisted_1$e = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
572
+ const _hoisted_1$g = /* @__PURE__ */ vue.createTextVNode("取消");
631
573
  const __default__$p = vue.defineComponent({
632
574
  name: "MEditorUISelect"
633
575
  });
634
- const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
576
+ const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
635
577
  ...__default__$p,
636
578
  props: {
637
579
  config: null,
@@ -694,7 +636,7 @@
694
636
  style: { "padding": "0" }
695
637
  }, {
696
638
  default: vue.withCtx(() => [
697
- _hoisted_1$e
639
+ _hoisted_1$g
698
640
  ]),
699
641
  _: 1
700
642
  }, 8, ["icon"])
@@ -706,7 +648,7 @@
706
648
  }, [
707
649
  vue.unref(val) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
708
650
  key: 0,
709
- content: "\u6E05\u9664"
651
+ content: "清除"
710
652
  }, {
711
653
  default: vue.withCtx(() => [
712
654
  vue.createVNode(vue.unref(design.TMagicButton), {
@@ -720,7 +662,7 @@
720
662
  _: 1
721
663
  })) : vue.createCommentVNode("", true),
722
664
  vue.createVNode(vue.unref(design.TMagicTooltip), {
723
- content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
665
+ content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "点击此处选择"
724
666
  }, {
725
667
  default: vue.withCtx(() => [
726
668
  vue.createVNode(vue.unref(design.TMagicButton), {
@@ -728,7 +670,7 @@
728
670
  style: { "padding": "0", "margin": "0" }
729
671
  }, {
730
672
  default: vue.withCtx(() => [
731
- vue.createTextVNode(vue.toDisplayString(vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"), 1)
673
+ vue.createTextVNode(vue.toDisplayString(vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "点击此处选择"), 1)
732
674
  ]),
733
675
  _: 1
734
676
  })
@@ -745,7 +687,7 @@
745
687
  const __default__$o = vue.defineComponent({
746
688
  name: "MEditorCodeEditor"
747
689
  });
748
- const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
690
+ const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
749
691
  ...__default__$o,
750
692
  props: {
751
693
  initValues: null,
@@ -763,7 +705,7 @@
763
705
  const toString = (v, language) => {
764
706
  let value = "";
765
707
  if (typeof v !== "string") {
766
- value = serialize__default.default(v, {
708
+ value = serialize(v, {
767
709
  space: 2,
768
710
  unsafe: true
769
711
  }).replace(/"(\w+)":\s/g, "$1: ");
@@ -878,7 +820,7 @@
878
820
  const __default__$n = vue.defineComponent({
879
821
  name: "MEditorResizer"
880
822
  });
881
- const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
823
+ const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
882
824
  ...__default__$n,
883
825
  emits: ["change"],
884
826
  setup(__props, { emit }) {
@@ -887,7 +829,7 @@
887
829
  vue.onMounted(() => {
888
830
  if (!target.value)
889
831
  return;
890
- getso = new Gesto__default.default(target.value, {
832
+ getso = new Gesto(target.value, {
891
833
  container: window,
892
834
  pinchOutside: true
893
835
  }).on("drag", (e) => {
@@ -914,7 +856,7 @@
914
856
  const __default__$m = vue.defineComponent({
915
857
  name: "MEditorLayout"
916
858
  });
917
- const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
859
+ const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
918
860
  ...__default__$m,
919
861
  props: {
920
862
  left: null,
@@ -1023,7 +965,7 @@
1023
965
  }, [
1024
966
  vue.renderSlot(_ctx.$slots, "left")
1025
967
  ], 6),
1026
- vue.createVNode(_sfc_main$o, { onChange: changeLeft })
968
+ vue.createVNode(_sfc_main$r, { onChange: changeLeft })
1027
969
  ], 64)) : vue.createCommentVNode("", true),
1028
970
  vue.createElementVNode("div", {
1029
971
  class: vue.normalizeClass(["m-editor-layout-center", __props.centerClass]),
@@ -1032,7 +974,7 @@
1032
974
  vue.renderSlot(_ctx.$slots, "center")
1033
975
  ], 6),
1034
976
  vue.unref(hasRight) ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
1035
- vue.createVNode(_sfc_main$o, { onChange: changeRight }),
977
+ vue.createVNode(_sfc_main$r, { onChange: changeRight }),
1036
978
  vue.createElementVNode("div", {
1037
979
  class: vue.normalizeClass(["m-editor-layout-right", __props.rightClass]),
1038
980
  style: vue.normalizeStyle(`width: ${__props.right}px`)
@@ -1050,14 +992,16 @@
1050
992
  type: "tab",
1051
993
  items: [
1052
994
  {
1053
- title: "\u5C5E\u6027",
995
+ title: "属性",
1054
996
  labelWidth: "80px",
1055
997
  items: [
998
+ // 组件类型,必须要有
1056
999
  {
1057
1000
  text: "type",
1058
1001
  name: "type",
1059
1002
  type: "hidden"
1060
1003
  },
1004
+ // 组件id,必须要有
1061
1005
  {
1062
1006
  name: "id",
1063
1007
  type: "display",
@@ -1065,13 +1009,13 @@
1065
1009
  },
1066
1010
  {
1067
1011
  name: "name",
1068
- text: "\u7EC4\u4EF6\u540D\u79F0"
1012
+ text: "组件名称"
1069
1013
  },
1070
1014
  ...config
1071
1015
  ]
1072
1016
  },
1073
1017
  {
1074
- title: "\u6837\u5F0F",
1018
+ title: "样式",
1075
1019
  labelWidth: "80px",
1076
1020
  items: [
1077
1021
  {
@@ -1079,7 +1023,7 @@
1079
1023
  items: [
1080
1024
  {
1081
1025
  type: "fieldset",
1082
- legend: "\u4F4D\u7F6E",
1026
+ legend: "位置",
1083
1027
  items: [
1084
1028
  {
1085
1029
  name: "position",
@@ -1087,7 +1031,7 @@
1087
1031
  activeValue: "fixed",
1088
1032
  inactiveValue: "absolute",
1089
1033
  defaultValue: "absolute",
1090
- text: "\u56FA\u5B9A\u5B9A\u4F4D"
1034
+ text: "固定定位"
1091
1035
  },
1092
1036
  {
1093
1037
  name: "left",
@@ -1111,34 +1055,34 @@
1111
1055
  },
1112
1056
  {
1113
1057
  type: "fieldset",
1114
- legend: "\u76D2\u5B50",
1058
+ legend: "盒子",
1115
1059
  items: [
1116
1060
  {
1117
1061
  name: "width",
1118
- text: "\u5BBD\u5EA6"
1062
+ text: "宽度"
1119
1063
  },
1120
1064
  {
1121
1065
  name: "height",
1122
- text: "\u9AD8\u5EA6"
1066
+ text: "高度"
1123
1067
  }
1124
1068
  ]
1125
1069
  },
1126
1070
  {
1127
1071
  type: "fieldset",
1128
- legend: "\u80CC\u666F",
1072
+ legend: "背景",
1129
1073
  items: [
1130
1074
  {
1131
1075
  name: "backgroundImage",
1132
- text: "\u80CC\u666F\u56FE"
1076
+ text: "背景图"
1133
1077
  },
1134
1078
  {
1135
1079
  name: "backgroundColor",
1136
- text: "\u80CC\u666F\u989C\u8272",
1080
+ text: "背景颜色",
1137
1081
  type: "colorPicker"
1138
1082
  },
1139
1083
  {
1140
1084
  name: "backgroundRepeat",
1141
- text: "\u80CC\u666F\u56FE\u91CD\u590D",
1085
+ text: "背景图重复",
1142
1086
  type: "select",
1143
1087
  defaultValue: "no-repeat",
1144
1088
  options: [
@@ -1151,42 +1095,42 @@
1151
1095
  },
1152
1096
  {
1153
1097
  name: "backgroundSize",
1154
- text: "\u80CC\u666F\u56FE\u5927\u5C0F",
1098
+ text: "背景图大小",
1155
1099
  defaultValue: "100% 100%"
1156
1100
  }
1157
1101
  ]
1158
1102
  },
1159
1103
  {
1160
1104
  type: "fieldset",
1161
- legend: "\u5B57\u4F53",
1105
+ legend: "字体",
1162
1106
  items: [
1163
1107
  {
1164
1108
  name: "color",
1165
- text: "\u989C\u8272",
1109
+ text: "颜色",
1166
1110
  type: "colorPicker"
1167
1111
  },
1168
1112
  {
1169
1113
  name: "fontSize",
1170
- text: "\u5927\u5C0F"
1114
+ text: "大小"
1171
1115
  },
1172
1116
  {
1173
1117
  name: "fontWeight",
1174
- text: "\u7C97\u7EC6"
1118
+ text: "粗细"
1175
1119
  }
1176
1120
  ]
1177
1121
  },
1178
1122
  {
1179
1123
  type: "fieldset",
1180
- legend: "\u53D8\u5F62",
1124
+ legend: "变形",
1181
1125
  name: "transform",
1182
1126
  items: [
1183
1127
  {
1184
1128
  name: "rotate",
1185
- text: "\u65CB\u8F6C\u89D2\u5EA6"
1129
+ text: "旋转角度"
1186
1130
  },
1187
1131
  {
1188
1132
  name: "scale",
1189
- text: "\u7F29\u653E"
1133
+ text: "缩放"
1190
1134
  }
1191
1135
  ]
1192
1136
  }
@@ -1195,7 +1139,7 @@
1195
1139
  ]
1196
1140
  },
1197
1141
  {
1198
- title: "\u4E8B\u4EF6",
1142
+ title: "事件",
1199
1143
  items: [
1200
1144
  {
1201
1145
  name: "events",
@@ -1204,7 +1148,7 @@
1204
1148
  ]
1205
1149
  },
1206
1150
  {
1207
- title: "\u9AD8\u7EA7",
1151
+ title: "高级",
1208
1152
  lazy: true,
1209
1153
  items: [
1210
1154
  {
@@ -1437,7 +1381,7 @@
1437
1381
  left: fixNodeLeft(config, parent, stage?.renderer.contentWindow?.document)
1438
1382
  };
1439
1383
  };
1440
- const serializeConfig = (config) => serialize__default.default(config, {
1384
+ const serializeConfig = (config) => serialize(config, {
1441
1385
  space: 2,
1442
1386
  unsafe: true
1443
1387
  }).replace(/"(\w+)":\s/g, "$1: ");
@@ -1463,6 +1407,7 @@
1463
1407
  canUndo() {
1464
1408
  return this.listCursor > 1;
1465
1409
  }
1410
+ // 返回undo后的当前元素
1466
1411
  undo() {
1467
1412
  if (!this.canUndo()) {
1468
1413
  return null;
@@ -1473,6 +1418,7 @@
1473
1418
  canRedo() {
1474
1419
  return this.elementList.length > this.listCursor;
1475
1420
  }
1421
+ // 返回redo后的当前元素
1476
1422
  redo() {
1477
1423
  if (!this.canRedo()) {
1478
1424
  return null;
@@ -1490,17 +1436,17 @@
1490
1436
 
1491
1437
  const compose = (middleware) => {
1492
1438
  if (!Array.isArray(middleware))
1493
- throw new TypeError("Middleware \u5FC5\u987B\u662F\u4E00\u4E2A\u6570\u7EC4!");
1439
+ throw new TypeError("Middleware 必须是一个数组!");
1494
1440
  for (const fn of middleware) {
1495
1441
  if (typeof fn !== "function")
1496
- throw new TypeError("Middleware \u5FC5\u987B\u7531\u51FD\u6570\u7EC4\u6210!");
1442
+ throw new TypeError("Middleware 必须由函数组成!");
1497
1443
  }
1498
1444
  return (args, next) => {
1499
1445
  let index = -1;
1500
1446
  return dispatch(0);
1501
1447
  function dispatch(i) {
1502
1448
  if (i <= index)
1503
- return Promise.reject(new Error("next() \u88AB\u591A\u6B21\u8C03\u7528"));
1449
+ return Promise.reject(new Error("next() 被多次调用"));
1504
1450
  index = i;
1505
1451
  let fn = middleware[i];
1506
1452
  if (i === middleware.length && next)
@@ -1705,16 +1651,32 @@
1705
1651
  constructor() {
1706
1652
  super(["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]);
1707
1653
  }
1654
+ /**
1655
+ * 获取数据存储对象,可以通过
1656
+ * const storageService = new StorageService();
1657
+ * storageService.usePlugin({
1658
+ * // 替换存储对象为 sessionStorage
1659
+ * async afterGetStorage(): Promise<Storage> {
1660
+ * return window.sessionStorage;
1661
+ * },
1662
+ * });
1663
+ */
1708
1664
  async getStorage() {
1709
1665
  return this.storage;
1710
1666
  }
1711
1667
  async getNamespace() {
1712
1668
  return this.namespace;
1713
1669
  }
1670
+ /**
1671
+ * 清理,支持storageService.usePlugin
1672
+ */
1714
1673
  async clear() {
1715
1674
  const storage2 = await this.getStorage();
1716
1675
  storage2.clear();
1717
1676
  }
1677
+ /**
1678
+ * 获取存储项,支持storageService.usePlugin
1679
+ */
1718
1680
  async getItem(key, options = {}) {
1719
1681
  const [storage, namespace] = await Promise.all([this.getStorage(), this.getNamespace()]);
1720
1682
  const { protocol = options.protocol, item } = this.getValueAndProtocol(
@@ -1735,14 +1697,23 @@
1735
1697
  return item;
1736
1698
  }
1737
1699
  }
1700
+ /**
1701
+ * 获取指定索引位置的key
1702
+ */
1738
1703
  async key(index) {
1739
1704
  const storage2 = await this.getStorage();
1740
1705
  return storage2.key(index);
1741
1706
  }
1707
+ /**
1708
+ * 移除存储项,支持storageService.usePlugin
1709
+ */
1742
1710
  async removeItem(key2, options2 = {}) {
1743
1711
  const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
1744
1712
  storage2.removeItem(`${options2.namespace || namespace2}:${key2}`);
1745
1713
  }
1714
+ /**
1715
+ * 设置存储项,支持storageService.usePlugin
1716
+ */
1746
1717
  async setItem(key2, value, options2 = {}) {
1747
1718
  const [storage2, namespace2] = await Promise.all([this.getStorage(), this.getNamespace()]);
1748
1719
  let item2 = value;
@@ -1750,7 +1721,7 @@
1750
1721
  if (typeof value === "string" /* STRING */ || typeof value === "number" /* NUMBER */) {
1751
1722
  item2 = `${protocol2}${value}`;
1752
1723
  } else {
1753
- item2 = `${protocol2}${serialize__default.default(value)}`;
1724
+ item2 = `${protocol2}${serialize(value)}`;
1754
1725
  }
1755
1726
  storage2.setItem(`${options2.namespace || namespace2}:${key2}`, item2);
1756
1727
  }
@@ -1804,9 +1775,19 @@
1804
1775
  async fillConfig(config) {
1805
1776
  return fillConfig(config);
1806
1777
  }
1778
+ /**
1779
+ * 为指定类型组件设置组件属性表单配置
1780
+ * @param type 组件类型
1781
+ * @param config 组件属性表单配置
1782
+ */
1807
1783
  async setPropsConfig(type, config) {
1808
1784
  this.state.propsConfigMap[type] = await this.fillConfig(Array.isArray(config) ? config : [config]);
1809
1785
  }
1786
+ /**
1787
+ * 获取指点类型的组件属性表单配置
1788
+ * @param type 组件类型
1789
+ * @returns 组件属性表单配置
1790
+ */
1810
1791
  async getPropsConfig(type) {
1811
1792
  if (type === "area") {
1812
1793
  return await this.getPropsConfig("button");
@@ -1818,9 +1799,19 @@
1818
1799
  this.setPropsValue(utils.toLine(type), values[type]);
1819
1800
  });
1820
1801
  }
1802
+ /**
1803
+ * 为指点类型组件设置组件初始值
1804
+ * @param type 组件类型
1805
+ * @param value 组件初始值
1806
+ */
1821
1807
  async setPropsValue(type, value) {
1822
1808
  this.state.propsValueMap[type] = value;
1823
1809
  }
1810
+ /**
1811
+ * 获取指定类型的组件初始值
1812
+ * @param type 组件类型
1813
+ * @returns 组件初始值
1814
+ */
1824
1815
  async getPropsValue(type, { inputEvent, ...defaultValue } = {}) {
1825
1816
  if (type === "area") {
1826
1817
  const value = await this.getPropsValue("button");
@@ -1850,6 +1841,11 @@
1850
1841
  async createId(type) {
1851
1842
  return `${type}_${this.guid()}`;
1852
1843
  }
1844
+ /**
1845
+ * 将组件与组件的子元素配置中的id都设置成一个新的ID
1846
+ * @param {Object} config 组件配置
1847
+ */
1848
+ /* eslint no-param-reassign: ["error", { "props": false }] */
1853
1849
  async setNewItemId(config) {
1854
1850
  config.id = await this.createId(config.type || "component");
1855
1851
  if (config.items && Array.isArray(config.items)) {
@@ -1859,6 +1855,11 @@
1859
1855
  }
1860
1856
  return config;
1861
1857
  }
1858
+ /**
1859
+ * 获取默认属性配置
1860
+ * @param type 组件类型
1861
+ * @returns Object
1862
+ */
1862
1863
  async getDefaultPropsValue(type) {
1863
1864
  return ["page", "container"].includes(type) ? {
1864
1865
  type,
@@ -1881,6 +1882,11 @@
1881
1882
  this.removeAllListeners();
1882
1883
  this.removeAllPlugins();
1883
1884
  }
1885
+ /**
1886
+ * 生成指定位数的GUID,无【-】格式
1887
+ * @param digit 位数,默认值8
1888
+ * @returns
1889
+ */
1884
1890
  guid(digit = 8) {
1885
1891
  return "x".repeat(digit).replace(/[xy]/g, (c) => {
1886
1892
  const r = Math.random() * 16 | 0;
@@ -1963,7 +1969,7 @@
1963
1969
  return newNode;
1964
1970
  };
1965
1971
 
1966
- class Editor$1 extends BaseService {
1972
+ let Editor$1 = class Editor extends BaseService {
1967
1973
  state = vue.reactive({
1968
1974
  root: null,
1969
1975
  page: null,
@@ -2000,9 +2006,15 @@
2000
2006
  "redo",
2001
2007
  "highlight"
2002
2008
  ],
2009
+ // 需要注意循环依赖问题,如果函数间有相互调用的话,不能设置为串行调用
2003
2010
  ["select", "update", "moveLayer"]
2004
2011
  );
2005
2012
  }
2013
+ /**
2014
+ * 设置当前指点节点配置
2015
+ * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength'
2016
+ * @param value MNode
2017
+ */
2006
2018
  set(name, value) {
2007
2019
  const preValue = this.state[name];
2008
2020
  this.state[name] = value;
@@ -2011,9 +2023,9 @@
2011
2023
  }
2012
2024
  if (name === "root") {
2013
2025
  if (Array.isArray(value)) {
2014
- throw new Error("root \u4E0D\u80FD\u4E3A\u6570\u7EC4");
2026
+ throw new Error("root 不能为数组");
2015
2027
  }
2016
- if (value && lodashEs.isObject(value) && !(value instanceof StageCore__default.default) && !(value instanceof Map)) {
2028
+ if (value && lodashEs.isObject(value) && !(value instanceof StageCore) && !(value instanceof Map)) {
2017
2029
  this.state.pageLength = value.items?.length || 0;
2018
2030
  } else {
2019
2031
  this.state.pageLength = 0;
@@ -2021,9 +2033,20 @@
2021
2033
  this.emit("root-change", value, preValue);
2022
2034
  }
2023
2035
  }
2036
+ /**
2037
+ * 获取当前指点节点配置
2038
+ * @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'pageLength'
2039
+ * @returns MNode
2040
+ */
2024
2041
  get(name) {
2025
2042
  return this.state[name];
2026
2043
  }
2044
+ /**
2045
+ * 根据id获取组件、组件的父组件以及组件所属的页面节点
2046
+ * @param {number | string} id 组件id
2047
+ * @param {boolean} raw 是否使用toRaw
2048
+ * @returns {EditorNodeInfo}
2049
+ */
2027
2050
  getNodeInfo(id, raw = true) {
2028
2051
  let root = this.get("root");
2029
2052
  if (raw) {
@@ -2054,14 +2077,29 @@
2054
2077
  });
2055
2078
  return info;
2056
2079
  }
2080
+ /**
2081
+ * 根据ID获取指点节点配置
2082
+ * @param id 组件ID
2083
+ * @param {boolean} raw 是否使用toRaw
2084
+ * @returns 组件节点配置
2085
+ */
2057
2086
  getNodeById(id, raw = true) {
2058
2087
  const { node } = this.getNodeInfo(id, raw);
2059
2088
  return node;
2060
2089
  }
2090
+ /**
2091
+ * 根据ID获取指点节点的父节点配置
2092
+ * @param id 组件ID
2093
+ * @param {boolean} raw 是否使用toRaw
2094
+ * @returns 指点组件的父节点配置
2095
+ */
2061
2096
  getParentById(id, raw = true) {
2062
2097
  const { parent } = this.getNodeInfo(id, raw);
2063
2098
  return parent;
2064
2099
  }
2100
+ /**
2101
+ * 只有容器拥有布局
2102
+ */
2065
2103
  async getLayout(parent, node) {
2066
2104
  if (node && typeof node !== "function" && isFixed(node))
2067
2105
  return Layout.FIXED;
@@ -2073,6 +2111,11 @@
2073
2111
  }
2074
2112
  return Layout.ABSOLUTE;
2075
2113
  }
2114
+ /**
2115
+ * 选中指定节点(将指定节点设置成当前选中状态)
2116
+ * @param config 指定节点配置或者ID
2117
+ * @returns 当前选中的节点配置
2118
+ */
2076
2119
  async select(config) {
2077
2120
  const { node, page, parent } = this.selectedConfigExceptionHandler(config);
2078
2121
  this.set("nodes", node ? [node] : []);
@@ -2114,15 +2157,20 @@
2114
2157
  const root = vue.toRaw(this.get("root"));
2115
2158
  const page = vue.toRaw(this.get("page"));
2116
2159
  if (!page)
2117
- throw new Error("page\u4E0D\u80FD\u4E3A\u7A7A");
2160
+ throw new Error("page不能为空");
2118
2161
  if (!root)
2119
- throw new Error("root\u4E0D\u80FD\u4E3A\u7A7A");
2162
+ throw new Error("root不能为空");
2120
2163
  const index = getNodeIndex(page, root);
2121
2164
  const nextPage = root.items[index + 1] || root.items[0];
2122
2165
  await this.select(nextPage);
2123
2166
  this.get("stage")?.select(nextPage.id);
2124
2167
  return nextPage;
2125
2168
  }
2169
+ /**
2170
+ * 高亮指定节点
2171
+ * @param config 指定节点配置或者ID
2172
+ * @returns 当前高亮的节点配置
2173
+ */
2126
2174
  highlight(config) {
2127
2175
  const { node } = this.selectedConfigExceptionHandler(config);
2128
2176
  const currentHighlightNode = this.get("highlightNode");
@@ -2130,6 +2178,11 @@
2130
2178
  return;
2131
2179
  this.set("highlightNode", node);
2132
2180
  }
2181
+ /**
2182
+ * 多选
2183
+ * @param ids 指定节点ID
2184
+ * @returns 加入多选的节点配置
2185
+ */
2133
2186
  multiSelect(ids) {
2134
2187
  const nodes = [];
2135
2188
  const idsUnique = lodashEs.uniq(ids);
@@ -2144,13 +2197,13 @@
2144
2197
  async doAdd(node, parent) {
2145
2198
  const root = this.get("root");
2146
2199
  if (!root)
2147
- throw new Error("root\u4E3A\u7A7A");
2200
+ throw new Error("root为空");
2148
2201
  const curNode = this.get("node");
2149
2202
  const stage = this.get("stage");
2150
2203
  if (!curNode)
2151
- throw new Error("\u5F53\u524D\u9009\u4E2D\u8282\u70B9\u4E3A\u7A7A");
2204
+ throw new Error("当前选中节点为空");
2152
2205
  if ((parent.type === schema.NodeType.ROOT || curNode?.type === schema.NodeType.ROOT) && node.type !== schema.NodeType.PAGE) {
2153
- throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
2206
+ throw new Error("app下不能添加组件");
2154
2207
  }
2155
2208
  if (parent.id !== curNode.id && node.type !== schema.NodeType.PAGE) {
2156
2209
  const index = parent.items.indexOf(curNode);
@@ -2174,13 +2227,19 @@
2174
2227
  this.addModifiedNodeId(node.id);
2175
2228
  return node;
2176
2229
  }
2230
+ /**
2231
+ * 向指点容器添加组件节点
2232
+ * @param addConfig 将要添加的组件节点配置
2233
+ * @param parent 要添加到的容器组件节点配置,如果不设置,默认为当前选中的组件的父节点
2234
+ * @returns 添加后的节点
2235
+ */
2177
2236
  async add(addNode, parent) {
2178
2237
  const stage = this.get("stage");
2179
2238
  const addNodes = [];
2180
2239
  if (!Array.isArray(addNode)) {
2181
2240
  const { type, inputEvent, ...config } = addNode;
2182
2241
  if (!type)
2183
- throw new Error("\u7EC4\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
2242
+ throw new Error("组件类型不能为空");
2184
2243
  addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
2185
2244
  } else {
2186
2245
  addNodes.push(...addNode);
@@ -2193,7 +2252,7 @@
2193
2252
  }
2194
2253
  const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
2195
2254
  if (!parentNode)
2196
- throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
2255
+ throw new Error("未找到父元素");
2197
2256
  return this.doAdd(node, parentNode);
2198
2257
  })
2199
2258
  );
@@ -2218,13 +2277,13 @@
2218
2277
  async doRemove(node) {
2219
2278
  const root = this.get("root");
2220
2279
  if (!root)
2221
- throw new Error("root\u4E0D\u80FD\u4E3A\u7A7A");
2280
+ throw new Error("root不能为空");
2222
2281
  const { parent, node: curNode } = this.getNodeInfo(node.id);
2223
2282
  if (!parent || !curNode)
2224
- throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
2283
+ throw new Error("找不要删除的节点");
2225
2284
  const index = getNodeIndex(curNode, parent);
2226
2285
  if (typeof index !== "number" || index === -1)
2227
- throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
2286
+ throw new Error("找不要删除的节点");
2228
2287
  parent.items?.splice(index, 1);
2229
2288
  const stage = this.get("stage");
2230
2289
  stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
@@ -2249,6 +2308,10 @@
2249
2308
  }
2250
2309
  this.addModifiedNodeId(parent.id);
2251
2310
  }
2311
+ /**
2312
+ * 删除组件
2313
+ * @param {Object} node
2314
+ */
2252
2315
  async remove(nodeOrNodeList) {
2253
2316
  const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
2254
2317
  await Promise.all(nodes.map((node) => this.doRemove(node)));
@@ -2260,12 +2323,12 @@
2260
2323
  async doUpdate(config) {
2261
2324
  const root = this.get("root");
2262
2325
  if (!root)
2263
- throw new Error("root\u4E3A\u7A7A");
2326
+ throw new Error("root为空");
2264
2327
  if (!config?.id)
2265
- throw new Error("\u6CA1\u6709\u914D\u7F6E\u6216\u8005\u914D\u7F6E\u7F3A\u5C11id\u503C");
2328
+ throw new Error("没有配置或者配置缺少id值");
2266
2329
  const info = this.getNodeInfo(config.id, false);
2267
2330
  if (!info.node)
2268
- throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config.id}\u7684\u8282\u70B9`);
2331
+ throw new Error(`获取不到id为${config.id}的节点`);
2269
2332
  const node = lodashEs.cloneDeep(vue.toRaw(info.node));
2270
2333
  let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, root);
2271
2334
  newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue) => {
@@ -2277,18 +2340,18 @@
2277
2340
  }
2278
2341
  });
2279
2342
  if (!newConfig.type)
2280
- throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
2343
+ throw new Error("配置缺少type值");
2281
2344
  if (newConfig.type === schema.NodeType.ROOT) {
2282
2345
  this.set("root", newConfig);
2283
2346
  return newConfig;
2284
2347
  }
2285
2348
  const { parent } = info;
2286
2349
  if (!parent)
2287
- throw new Error("\u83B7\u53D6\u4E0D\u5230\u7236\u7EA7\u8282\u70B9");
2350
+ throw new Error("获取不到父级节点");
2288
2351
  const parentNodeItems = parent.items;
2289
2352
  const index = getNodeIndex(newConfig, parent);
2290
2353
  if (!parentNodeItems || typeof index === "undefined" || index === -1)
2291
- throw new Error("\u66F4\u65B0\u7684\u8282\u70B9\u672A\u627E\u5230");
2354
+ throw new Error("更新的节点未找到");
2292
2355
  const newLayout = await this.getLayout(newConfig);
2293
2356
  const layout = await this.getLayout(node);
2294
2357
  if (newLayout !== layout) {
@@ -2310,6 +2373,11 @@
2310
2373
  this.addModifiedNodeId(newConfig.id);
2311
2374
  return newConfig;
2312
2375
  }
2376
+ /**
2377
+ * 更新节点
2378
+ * @param config 新的节点配置,配置中需要有id信息
2379
+ * @returns 更新后的节点配置
2380
+ */
2313
2381
  async update(config) {
2314
2382
  const nodes = Array.isArray(config) ? config : [config];
2315
2383
  const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
@@ -2317,16 +2385,22 @@
2317
2385
  this.emit("update", newNodes);
2318
2386
  return Array.isArray(config) ? newNodes : newNodes[0];
2319
2387
  }
2388
+ /**
2389
+ * 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
2390
+ * @param id1 组件ID
2391
+ * @param id2 组件ID
2392
+ * @returns void
2393
+ */
2320
2394
  async sort(id1, id2) {
2321
2395
  const root = this.get("root");
2322
2396
  if (!root)
2323
- throw new Error("root\u4E3A\u7A7A");
2397
+ throw new Error("root为空");
2324
2398
  const node = this.get("node");
2325
2399
  if (!node)
2326
- throw new Error("\u5F53\u524D\u8282\u70B9\u4E3A\u7A7A");
2400
+ throw new Error("当前节点为空");
2327
2401
  const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
2328
2402
  if (!parent)
2329
- throw new Error("\u7236\u8282\u70B9\u4E3A\u7A7A");
2403
+ throw new Error("父节点为空");
2330
2404
  const index2 = parent.items.findIndex((node2) => `${node2.id}` === `${id2}`);
2331
2405
  if (index2 < 0)
2332
2406
  return;
@@ -2342,11 +2416,21 @@
2342
2416
  this.addModifiedNodeId(parent.id);
2343
2417
  this.pushHistoryState();
2344
2418
  }
2419
+ /**
2420
+ * 将组将节点配置转化成string,然后存储到localStorage中
2421
+ * @param config 组件节点配置
2422
+ * @returns 组件节点配置
2423
+ */
2345
2424
  async copy(config) {
2346
2425
  await storageService.setItem(COPY_STORAGE_KEY, Array.isArray(config) ? config : [config], {
2347
2426
  protocol: Protocol.OBJECT
2348
2427
  });
2349
2428
  }
2429
+ /**
2430
+ * 从localStorage中获取节点,然后添加到当前容器中
2431
+ * @param position 粘贴的坐标
2432
+ * @returns 添加后的组件节点配置
2433
+ */
2350
2434
  async paste(position = {}) {
2351
2435
  const config = await storageService.getItem(COPY_STORAGE_KEY);
2352
2436
  if (!Array.isArray(config))
@@ -2369,7 +2453,7 @@
2369
2453
  async doAlignCenter(config) {
2370
2454
  const parent = this.getParentById(config.id);
2371
2455
  if (!parent)
2372
- throw new Error("\u627E\u4E0D\u5230\u7236\u8282\u70B9");
2456
+ throw new Error("找不到父节点");
2373
2457
  const node = lodashEs.cloneDeep(vue.toRaw(config));
2374
2458
  const layout = await this.getLayout(parent, node);
2375
2459
  if (layout === Layout.RELATIVE) {
@@ -2390,6 +2474,11 @@
2390
2474
  }
2391
2475
  return node;
2392
2476
  }
2477
+ /**
2478
+ * 将指点节点设置居中
2479
+ * @param config 组件节点配置
2480
+ * @returns 当前组件节点配置
2481
+ */
2393
2482
  async alignCenter(config) {
2394
2483
  const nodes = Array.isArray(config) ? config : [config];
2395
2484
  const stage = this.get("stage");
@@ -2402,16 +2491,20 @@
2402
2491
  }
2403
2492
  return newNode;
2404
2493
  }
2494
+ /**
2495
+ * 移动当前选中节点位置
2496
+ * @param offset 偏移量
2497
+ */
2405
2498
  async moveLayer(offset) {
2406
2499
  const root = this.get("root");
2407
2500
  if (!root)
2408
- throw new Error("root\u4E3A\u7A7A");
2501
+ throw new Error("root为空");
2409
2502
  const parent = this.get("parent");
2410
2503
  if (!parent)
2411
- throw new Error("\u7236\u8282\u70B9\u4E3A\u7A7A");
2504
+ throw new Error("父节点为空");
2412
2505
  const node = this.get("node");
2413
2506
  if (!node)
2414
- throw new Error("\u5F53\u524D\u8282\u70B9\u4E3A\u7A7A");
2507
+ throw new Error("当前节点为空");
2415
2508
  const brothers = parent.items || [];
2416
2509
  const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
2417
2510
  const layout = await this.getLayout(parent, node);
@@ -2433,6 +2526,11 @@
2433
2526
  this.addModifiedNodeId(parent.id);
2434
2527
  this.pushHistoryState();
2435
2528
  }
2529
+ /**
2530
+ * 移动到指定容器中
2531
+ * @param config 需要移动的节点
2532
+ * @param targetId 容器ID
2533
+ */
2436
2534
  async moveToContainer(config, targetId) {
2437
2535
  const root = lodashEs.cloneDeep(this.get("root"));
2438
2536
  const { node, parent } = this.getNodeInfo(config.id, false);
@@ -2461,11 +2559,19 @@
2461
2559
  return newConfig;
2462
2560
  }
2463
2561
  }
2562
+ /**
2563
+ * 撤销当前操作
2564
+ * @returns 上一次数据
2565
+ */
2464
2566
  async undo() {
2465
2567
  const value = historyService.undo();
2466
2568
  await this.changeHistoryState(value);
2467
2569
  return value;
2468
2570
  }
2571
+ /**
2572
+ * 恢复到下一步
2573
+ * @returns 下一步数据
2574
+ */
2469
2575
  async redo() {
2470
2576
  const value = historyService.redo();
2471
2577
  await this.changeHistoryState(value);
@@ -2561,13 +2667,13 @@
2561
2667
  id = config.id;
2562
2668
  }
2563
2669
  if (!id) {
2564
- throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
2670
+ throw new Error("没有ID,无法选中");
2565
2671
  }
2566
2672
  const { node, parent, page } = this.getNodeInfo(id);
2567
2673
  if (!node)
2568
- throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
2674
+ throw new Error("获取不到组件信息");
2569
2675
  if (node.id === this.state.root?.id) {
2570
- throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
2676
+ throw new Error("不能选根节点");
2571
2677
  }
2572
2678
  return {
2573
2679
  node,
@@ -2575,7 +2681,7 @@
2575
2681
  page
2576
2682
  };
2577
2683
  }
2578
- }
2684
+ };
2579
2685
  const editorService = new Editor$1();
2580
2686
 
2581
2687
  const state = vue.reactive({
@@ -2668,7 +2774,7 @@
2668
2774
  const uiSelectMode = vue.computed(() => uiService.get("uiSelectMode"));
2669
2775
  const getGuideLineKey = (key) => `${key}_${root.value?.id}_${page.value?.id}`;
2670
2776
  const useStage = (stageOptions) => {
2671
- const stage = new StageCore__default.default({
2777
+ const stage = new StageCore({
2672
2778
  render: stageOptions.render,
2673
2779
  runtimeUrl: stageOptions.runtimeUrl,
2674
2780
  zoom: zoom.value,
@@ -2726,7 +2832,7 @@
2726
2832
  stage.on("select-parent", () => {
2727
2833
  const parent = editorService.get("parent");
2728
2834
  if (!parent)
2729
- throw new Error("\u7236\u8282\u70B9\u4E3A\u7A7A");
2835
+ throw new Error("父节点为空");
2730
2836
  editorService.select(parent);
2731
2837
  editorService.get("stage")?.select(parent.id);
2732
2838
  });
@@ -2746,13 +2852,13 @@
2746
2852
  return stage;
2747
2853
  };
2748
2854
 
2749
- const _hoisted_1$d = { class: "m-editor-empty-panel" };
2750
- const _hoisted_2$6 = { class: "m-editor-empty-content" };
2751
- const _hoisted_3$3 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2855
+ const _hoisted_1$f = { class: "m-editor-empty-panel" };
2856
+ const _hoisted_2$8 = { class: "m-editor-empty-content" };
2857
+ const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "新增页面", -1);
2752
2858
  const __default__$l = vue.defineComponent({
2753
2859
  name: "MEditorAddPageBox"
2754
2860
  });
2755
- const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
2861
+ const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
2756
2862
  ...__default__$l,
2757
2863
  setup(__props) {
2758
2864
  const services = vue.inject("services");
@@ -2762,23 +2868,23 @@
2762
2868
  return;
2763
2869
  const root = vue.toRaw(editorService.get("root"));
2764
2870
  if (!root)
2765
- throw new Error("root \u4E0D\u80FD\u4E3A\u7A7A");
2871
+ throw new Error("root 不能为空");
2766
2872
  editorService.add({
2767
2873
  type: schema.NodeType.PAGE,
2768
2874
  name: generatePageNameByApp(root)
2769
2875
  });
2770
2876
  };
2771
2877
  return (_ctx, _cache) => {
2772
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, [
2773
- vue.createElementVNode("div", _hoisted_2$6, [
2878
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$f, [
2879
+ vue.createElementVNode("div", _hoisted_2$8, [
2774
2880
  vue.createElementVNode("div", {
2775
2881
  class: "m-editor-empty-button",
2776
2882
  onClick: clickHandler
2777
2883
  }, [
2778
2884
  vue.createElementVNode("div", null, [
2779
- vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
2885
+ vue.createVNode(_sfc_main$w, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
2780
2886
  ]),
2781
- _hoisted_3$3
2887
+ _hoisted_3$4
2782
2888
  ])
2783
2889
  ])
2784
2890
  ]);
@@ -2786,11 +2892,11 @@
2786
2892
  }
2787
2893
  });
2788
2894
 
2789
- const _hoisted_1$c = { class: "m-editor" };
2895
+ const _hoisted_1$e = { class: "m-editor" };
2790
2896
  const __default__$k = vue.defineComponent({
2791
2897
  name: "MEditorFramework"
2792
2898
  });
2793
- const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
2899
+ const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
2794
2900
  ...__default__$k,
2795
2901
  props: {
2796
2902
  codeOptions: { default: () => ({}) }
@@ -2860,7 +2966,7 @@
2860
2966
  };
2861
2967
  return (_ctx, _cache) => {
2862
2968
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
2863
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
2969
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
2864
2970
  vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2865
2971
  vue.unref(showSrc) ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
2866
2972
  key: 0,
@@ -2868,7 +2974,7 @@
2868
2974
  "init-values": vue.unref(root),
2869
2975
  options: __props.codeOptions,
2870
2976
  onSave: saveCode
2871
- }, null, 8, ["init-values", "options"])) : (vue.openBlock(), vue.createBlock(_sfc_main$n, {
2977
+ }, null, 8, ["init-values", "options"])) : (vue.openBlock(), vue.createBlock(_sfc_main$q, {
2872
2978
  key: 1,
2873
2979
  class: "m-editor-content",
2874
2980
  "left-class": "m-editor-framework-left",
@@ -2878,8 +2984,8 @@
2878
2984
  "onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
2879
2985
  right: columnWidth.value.right,
2880
2986
  "onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
2881
- "min-left": 45,
2882
- "min-right": 1,
2987
+ "min-left": 65,
2988
+ "min-right": 20,
2883
2989
  onChange: columnWidthChange
2884
2990
  }, vue.createSlots({
2885
2991
  left: vue.withCtx(() => [
@@ -2887,7 +2993,7 @@
2887
2993
  ]),
2888
2994
  center: vue.withCtx(() => [
2889
2995
  vue.unref(pageLength) > 0 ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
2890
- vue.createVNode(_sfc_main$m)
2996
+ vue.createVNode(_sfc_main$p)
2891
2997
  ])
2892
2998
  ]),
2893
2999
  _: 2
@@ -2909,15 +3015,15 @@
2909
3015
  }
2910
3016
  });
2911
3017
 
2912
- const _hoisted_1$b = {
3018
+ const _hoisted_1$d = {
2913
3019
  key: 1,
2914
3020
  class: "menu-item-text"
2915
3021
  };
2916
- const _hoisted_2$5 = { class: "el-dropdown-link menubar-menu-button" };
3022
+ const _hoisted_2$7 = { class: "el-dropdown-link menubar-menu-button" };
2917
3023
  const __default__$j = vue.defineComponent({
2918
3024
  name: "MEditorToolButton"
2919
3025
  });
2920
- const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
3026
+ const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
2921
3027
  ...__default__$j,
2922
3028
  props: {
2923
3029
  data: { default: () => ({
@@ -2993,7 +3099,7 @@
2993
3099
  __props.data.type === "divider" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDivider), {
2994
3100
  key: 0,
2995
3101
  direction: __props.data.direction || "vertical"
2996
- }, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, vue.toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
3102
+ }, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, vue.toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
2997
3103
  __props.data.tooltip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
2998
3104
  key: 0,
2999
3105
  effect: "dark",
@@ -3007,7 +3113,7 @@
3007
3113
  disabled: vue.unref(disabled)
3008
3114
  }, {
3009
3115
  default: vue.withCtx(() => [
3010
- __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
3116
+ __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$w, {
3011
3117
  key: 0,
3012
3118
  icon: __props.data.icon
3013
3119
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -3024,7 +3130,7 @@
3024
3130
  disabled: vue.unref(disabled)
3025
3131
  }, {
3026
3132
  default: vue.withCtx(() => [
3027
- __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
3133
+ __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$w, {
3028
3134
  key: 0,
3029
3135
  icon: __props.data.icon
3030
3136
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -3057,7 +3163,7 @@
3057
3163
  })) : vue.createCommentVNode("", true)
3058
3164
  ]),
3059
3165
  default: vue.withCtx(() => [
3060
- vue.createElementVNode("span", _hoisted_2$5, [
3166
+ vue.createElementVNode("span", _hoisted_2$7, [
3061
3167
  vue.createTextVNode(vue.toDisplayString(__props.data.text), 1),
3062
3168
  vue.createVNode(vue.unref(design.TMagicIcon), { class: "el-icon--right" }, {
3063
3169
  default: vue.withCtx(() => [
@@ -3077,7 +3183,7 @@
3077
3183
  const __default__$i = vue.defineComponent({
3078
3184
  name: "MEditorNavMenu"
3079
3185
  });
3080
- const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
3186
+ const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
3081
3187
  ...__default__$i,
3082
3188
  props: {
3083
3189
  data: { default: () => ({}) },
@@ -3120,7 +3226,7 @@
3120
3226
  type: "button",
3121
3227
  className: "delete",
3122
3228
  icon: vue.markRaw(iconsVue.Delete),
3123
- tooltip: `\u522A\u9664(Delete)`,
3229
+ tooltip: `刪除(Delete)`,
3124
3230
  disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
3125
3231
  handler: () => {
3126
3232
  const node = services?.editorService.get("node");
@@ -3133,7 +3239,7 @@
3133
3239
  type: "button",
3134
3240
  className: "undo",
3135
3241
  icon: vue.markRaw(iconsVue.Back),
3136
- tooltip: `\u540E\u9000(${ctrl}+z)`,
3242
+ tooltip: `后退(${ctrl}+z)`,
3137
3243
  disabled: () => !services?.historyService.state.canUndo,
3138
3244
  handler: () => services?.editorService.undo()
3139
3245
  });
@@ -3143,7 +3249,7 @@
3143
3249
  type: "button",
3144
3250
  className: "redo",
3145
3251
  icon: vue.markRaw(iconsVue.Right),
3146
- tooltip: `\u524D\u8FDB(${ctrl}+Shift+z)`,
3252
+ tooltip: `前进(${ctrl}+Shift+z)`,
3147
3253
  disabled: () => !services?.historyService.state.canRedo,
3148
3254
  handler: () => services?.editorService.redo()
3149
3255
  });
@@ -3153,7 +3259,7 @@
3153
3259
  type: "button",
3154
3260
  className: "zoom-in",
3155
3261
  icon: vue.markRaw(iconsVue.ZoomIn),
3156
- tooltip: `\u653E\u5927(${ctrl}+=)`,
3262
+ tooltip: `放大(${ctrl}+=)`,
3157
3263
  handler: () => uiService?.zoom(0.1)
3158
3264
  });
3159
3265
  break;
@@ -3162,7 +3268,7 @@
3162
3268
  type: "button",
3163
3269
  className: "zoom-out",
3164
3270
  icon: vue.markRaw(iconsVue.ZoomOut),
3165
- tooltip: `\u7E2E\u5C0F(${ctrl}+-)`,
3271
+ tooltip: `縮小(${ctrl}+-)`,
3166
3272
  handler: () => uiService?.zoom(-0.1)
3167
3273
  });
3168
3274
  break;
@@ -3171,7 +3277,7 @@
3171
3277
  type: "button",
3172
3278
  className: "scale-to-original",
3173
3279
  icon: vue.markRaw(iconsVue.ScaleToOriginal),
3174
- tooltip: `\u7F29\u653E\u5230\u5B9E\u9645\u5927\u5C0F(${ctrl}+1)`,
3280
+ tooltip: `缩放到实际大小(${ctrl}+1)`,
3175
3281
  handler: () => uiService?.set("zoom", 1)
3176
3282
  });
3177
3283
  break;
@@ -3180,7 +3286,7 @@
3180
3286
  type: "button",
3181
3287
  className: "scale-to-fit",
3182
3288
  icon: vue.markRaw(iconsVue.FullScreen),
3183
- tooltip: `\u7F29\u653E\u4EE5\u9002\u5E94(${ctrl}+0)`,
3289
+ tooltip: `缩放以适应(${ctrl}+0)`,
3184
3290
  handler: async () => uiService?.set("zoom", await uiService.calcZoom())
3185
3291
  });
3186
3292
  break;
@@ -3189,7 +3295,7 @@
3189
3295
  type: "button",
3190
3296
  className: "rule",
3191
3297
  icon: vue.markRaw(iconsVue.Memo),
3192
- tooltip: showRule.value ? "\u9690\u85CF\u6807\u5C3A" : "\u663E\u793A\u6807\u5C3A",
3298
+ tooltip: showRule.value ? "隐藏标尺" : "显示标尺",
3193
3299
  handler: () => uiService?.set("showRule", !showRule.value)
3194
3300
  });
3195
3301
  break;
@@ -3198,7 +3304,7 @@
3198
3304
  type: "button",
3199
3305
  className: "guides",
3200
3306
  icon: vue.markRaw(iconsVue.Grid),
3201
- tooltip: showGuides.value ? "\u9690\u85CF\u53C2\u8003\u7EBF" : "\u663E\u793A\u53C2\u8003\u7EBF",
3307
+ tooltip: showGuides.value ? "隐藏参考线" : "显示参考线",
3202
3308
  handler: () => uiService?.set("showGuides", !showGuides.value)
3203
3309
  });
3204
3310
  break;
@@ -3236,7 +3342,7 @@
3236
3342
  style: vue.normalizeStyle(`width: ${vue.unref(columnWidth)?.[key]}px`)
3237
3343
  }, [
3238
3344
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(buttons)[key], (item, index) => {
3239
- return vue.openBlock(), vue.createBlock(_sfc_main$k, {
3345
+ return vue.openBlock(), vue.createBlock(_sfc_main$n, {
3240
3346
  data: item,
3241
3347
  key: index
3242
3348
  }, null, 8, ["data"]);
@@ -3248,11 +3354,11 @@
3248
3354
  }
3249
3355
  });
3250
3356
 
3251
- const _hoisted_1$a = { class: "m-editor-props-panel" };
3357
+ const _hoisted_1$c = { class: "m-editor-props-panel" };
3252
3358
  const __default__$h = vue.defineComponent({
3253
3359
  name: "MEditorPropsPanel"
3254
3360
  });
3255
- const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
3361
+ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
3256
3362
  ...__default__$h,
3257
3363
  emits: ["mounted"],
3258
3364
  setup(__props, { expose, emit }) {
@@ -3298,7 +3404,7 @@
3298
3404
  };
3299
3405
  expose({ submit });
3300
3406
  return (_ctx, _cache) => {
3301
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
3407
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
3302
3408
  vue.renderSlot(_ctx.$slots, "props-panel-header"),
3303
3409
  vue.createVNode(vue.unref(form.MForm), {
3304
3410
  ref_key: "configForm",
@@ -3315,17 +3421,94 @@
3315
3421
  }
3316
3422
  });
3317
3423
 
3424
+ const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
3425
+ __name: "SearchInput",
3426
+ emits: ["search"],
3427
+ setup(__props, { emit }) {
3428
+ const filterText = vue.ref("");
3429
+ const filterTextChangeHandler = () => {
3430
+ emit("search", filterText.value);
3431
+ };
3432
+ return (_ctx, _cache) => {
3433
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInput), {
3434
+ modelValue: filterText.value,
3435
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
3436
+ class: "search-input",
3437
+ size: "small",
3438
+ placeholder: "输入关键字进行过滤",
3439
+ clearable: "",
3440
+ "prefix-icon": vue.unref(iconsVue.Search),
3441
+ onInput: filterTextChangeHandler
3442
+ }, null, 8, ["modelValue", "prefix-icon"]);
3443
+ };
3444
+ }
3445
+ });
3446
+
3447
+ const _export_sfc = (sfc, props) => {
3448
+ const target = sfc.__vccOpts || sfc;
3449
+ for (const [key, val] of props) {
3450
+ target[key] = val;
3451
+ }
3452
+ return target;
3453
+ };
3454
+
3455
+ const _sfc_main$j = {};
3456
+
3457
+ const _hoisted_1$b = {
3458
+ width: "16px",
3459
+ height: "16px",
3460
+ xmlns: "http://www.w3.org/2000/svg"
3461
+ };
3462
+ const _hoisted_2$6 = /*#__PURE__*/vue.createElementVNode("g", {
3463
+ fill: "#7C878E",
3464
+ "fill-rule": "evenodd"
3465
+ }, [
3466
+ /*#__PURE__*/vue.createElementVNode("path", {
3467
+ d: "M15.3,5.5 L8,0 L0.7,5.5 L8,11 L15.3,5.5 Z M8,2.5 L12,5.5 L8,8.5 L4,5.5 L8,2.5 Z",
3468
+ "fill-rule": "nonzero"
3469
+ }),
3470
+ /*#__PURE__*/vue.createElementVNode("path", { d: "M8 13.5L2.3 9.2 0.7 10.5 8 16 15.3 10.5 13.7 9.2z" })
3471
+ ], -1);
3472
+ const _hoisted_3$3 = [
3473
+ _hoisted_2$6
3474
+ ];
3475
+
3476
+ function _sfc_render$2(_ctx, _cache) {
3477
+ return (vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$b, _hoisted_3$3))
3478
+ }
3479
+ const AppManageIcon = /*#__PURE__*/_export_sfc(_sfc_main$j, [['render',_sfc_render$2]]);
3480
+
3481
+ const _sfc_main$i = {};
3482
+
3483
+ const _hoisted_1$a = {
3484
+ width: "32px",
3485
+ height: "32px",
3486
+ viewBox: "0 0 32 32",
3487
+ version: "1.1",
3488
+ xmlns: "http://www.w3.org/2000/svg",
3489
+ "xmlns:xlink": "http://www.w3.org/1999/xlink"
3490
+ };
3491
+ const _hoisted_2$5 = /*#__PURE__*/vue.createStaticVNode("<title>gsd-icon-line-Universal-code</title><desc>Created with Sketch.</desc><defs><rect id=\"path-1\" x=\"0\" y=\"0\" width=\"32\" height=\"32\"></rect></defs><g id=\"组件规范\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"03图标\" transform=\"translate(-561.000000, -2356.000000)\"><g id=\"icon/line/Universal/code\" transform=\"translate(561.000000, 2356.000000)\"><g id=\"路径\"><mask id=\"mask-2\" fill=\"white\"><use xlink:href=\"#path-1\"></use></mask><use id=\"蒙版\" fill=\"#D8D8D8\" opacity=\"0\" xlink:href=\"#path-1\"></use><path d=\"M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z\" id=\"形状\" fill=\"#1D1F24\" mask=\"url(#mask-2)\"></path></g></g><g id=\"icon切图\" transform=\"translate(226.000000, 1782.000000)\"></g></g></g>", 4);
3492
+ const _hoisted_6 = [
3493
+ _hoisted_2$5
3494
+ ];
3495
+
3496
+ function _sfc_render$1(_ctx, _cache) {
3497
+ return (vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$a, _hoisted_6))
3498
+ }
3499
+ const CodeIcon = /*#__PURE__*/_export_sfc(_sfc_main$i, [['render',_sfc_render$1]]);
3500
+
3318
3501
  const _hoisted_1$9 = {
3319
3502
  key: 0,
3320
3503
  class: "m-editor-content-bottom"
3321
3504
  };
3322
- const _hoisted_2$4 = /* @__PURE__ */ vue.createTextVNode("\u786E\u8BA4");
3323
- const _hoisted_3$2 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3505
+ const _hoisted_2$4 = /* @__PURE__ */ vue.createTextVNode("确认");
3506
+ const _hoisted_3$2 = /* @__PURE__ */ vue.createTextVNode("关闭");
3324
3507
  const _hoisted_4$2 = {
3325
3508
  key: 1,
3326
3509
  class: "m-editor-content-bottom"
3327
3510
  };
3328
- const _hoisted_5$1 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3511
+ const _hoisted_5$1 = /* @__PURE__ */ vue.createTextVNode("关闭");
3329
3512
  const __default__$g = vue.defineComponent({
3330
3513
  name: "MEditorCodeDraftEditor"
3331
3514
  });
@@ -3340,7 +3523,7 @@
3340
3523
  language: null
3341
3524
  },
3342
3525
  emits: ["close", "saveAndClose"],
3343
- setup(__props, { emit }) {
3526
+ setup(__props, { expose, emit }) {
3344
3527
  const props = __props;
3345
3528
  const services = vue.inject("services");
3346
3529
  const codeContent = vue.ref("");
@@ -3370,7 +3553,7 @@
3370
3553
  return;
3371
3554
  }
3372
3555
  services?.codeBlockService.setCodeDraft(props.id, codeValue);
3373
- design.tMagicMessage.success(`\u4EE3\u7801\u8349\u7A3F\u4FDD\u5B58\u6210\u529F ${utils.datetimeFormatter(new Date())}`);
3556
+ design.tMagicMessage.success(`代码草稿成功保存到本地 ${utils.datetimeFormatter( new Date())}`);
3374
3557
  };
3375
3558
  const saveAndClose = () => {
3376
3559
  if (!codeEditor.value || !props.editable)
@@ -3381,19 +3564,20 @@
3381
3564
  const close = async () => {
3382
3565
  const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
3383
3566
  if (codeDraft) {
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", {
3385
- confirmButtonText: "\u4FDD\u5B58\u5E76\u5173\u95ED",
3386
- cancelButtonText: "\u76F4\u63A5\u5173\u95ED",
3387
- type: "warning",
3388
- distinguishCancelAndClose: true
3389
- }).then(async () => {
3567
+ try {
3568
+ await design.tMagicMessageBox.confirm("您有代码修改未保存,是否保存后再关闭?", "提示", {
3569
+ confirmButtonText: "保存并关闭",
3570
+ cancelButtonText: "直接关闭",
3571
+ type: "warning",
3572
+ distinguishCancelAndClose: true
3573
+ });
3390
3574
  saveAndClose();
3391
- }).catch((action) => {
3575
+ } catch (action) {
3392
3576
  if (action === "cancel") {
3393
3577
  services?.codeBlockService.removeCodeDraft(props.id);
3394
3578
  emit("close");
3395
3579
  }
3396
- });
3580
+ }
3397
3581
  } else {
3398
3582
  emit("close");
3399
3583
  }
@@ -3404,11 +3588,15 @@
3404
3588
  codeEditor.value.focus();
3405
3589
  }
3406
3590
  };
3591
+ expose({
3592
+ saveAndClose,
3593
+ close
3594
+ });
3407
3595
  return (_ctx, _cache) => {
3408
3596
  return vue.openBlock(), vue.createElementBlock("div", {
3409
3597
  class: vue.normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
3410
3598
  }, [
3411
- vue.createVNode(_sfc_main$p, {
3599
+ vue.createVNode(_sfc_main$s, {
3412
3600
  ref_key: "codeEditor",
3413
3601
  ref: codeEditor,
3414
3602
  class: "m-editor-container",
@@ -3424,7 +3612,7 @@
3424
3612
  onClick: toggleFullScreen
3425
3613
  }, {
3426
3614
  default: vue.withCtx(() => [
3427
- vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
3615
+ vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "退出全屏" : "全屏"), 1)
3428
3616
  ]),
3429
3617
  _: 1
3430
3618
  }),
@@ -3455,7 +3643,7 @@
3455
3643
  onClick: toggleFullScreen
3456
3644
  }, {
3457
3645
  default: vue.withCtx(() => [
3458
- vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F"), 1)
3646
+ vue.createTextVNode(vue.toDisplayString(isFullScreen.value ? "退出全屏" : "全屏"), 1)
3459
3647
  ]),
3460
3648
  _: 1
3461
3649
  }),
@@ -3476,9 +3664,9 @@
3476
3664
  });
3477
3665
 
3478
3666
  const _hoisted_1$8 = { class: "code-name-wrapper" };
3479
- const _hoisted_2$3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
3667
+ const _hoisted_2$3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
3480
3668
  const _hoisted_3$1 = { class: "code-name-wrapper" };
3481
- const _hoisted_4$1 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "\u53C2\u6570", -1);
3669
+ const _hoisted_4$1 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "参数", -1);
3482
3670
  const __default__$f = vue.defineComponent({
3483
3671
  name: "MEditorFunctionEditor"
3484
3672
  });
@@ -3493,27 +3681,26 @@
3493
3681
  codeOptions: null,
3494
3682
  paramsColConfig: null
3495
3683
  },
3496
- emits: ["change", "field-input"],
3497
- setup(__props, { emit }) {
3684
+ setup(__props, { expose }) {
3498
3685
  const props = __props;
3499
3686
  const defaultParamColConfig = {
3500
3687
  type: "row",
3501
- label: "\u53C2\u6570\u7C7B\u578B",
3688
+ label: "参数类型",
3502
3689
  items: [
3503
3690
  {
3504
- text: "\u53C2\u6570\u7C7B\u578B",
3691
+ text: "参数类型",
3505
3692
  labelWidth: "70px",
3506
3693
  type: "select",
3507
3694
  name: "type",
3508
3695
  options: [
3509
3696
  {
3510
- text: "\u6570\u5B57",
3511
- label: "\u6570\u5B57",
3697
+ text: "数字",
3698
+ label: "数字",
3512
3699
  value: "number"
3513
3700
  },
3514
3701
  {
3515
- text: "\u5B57\u7B26\u4E32",
3516
- label: "\u5B57\u7B26\u4E32",
3702
+ text: "字符串",
3703
+ label: "字符串",
3517
3704
  value: "text"
3518
3705
  }
3519
3706
  ]
@@ -3531,13 +3718,13 @@
3531
3718
  items: [
3532
3719
  {
3533
3720
  type: "text",
3534
- label: "\u53C2\u6570\u540D",
3721
+ label: "参数名",
3535
3722
  name: "name",
3536
3723
  width: 200
3537
3724
  },
3538
3725
  {
3539
3726
  type: "text",
3540
- label: "\u53C2\u6570\u6CE8\u91CA",
3727
+ label: "参数注释",
3541
3728
  name: "tip",
3542
3729
  width: 200
3543
3730
  },
@@ -3548,11 +3735,6 @@
3548
3735
  const codeName = vue.ref("");
3549
3736
  const codeContent = vue.ref("");
3550
3737
  const evalRes = vue.ref(true);
3551
- vue.provide("mForm", {
3552
- $emit: emit,
3553
- setField: () => {
3554
- }
3555
- });
3556
3738
  const tableModel = vue.ref();
3557
3739
  vue.watchEffect(() => {
3558
3740
  codeName.value = props.name;
@@ -3586,7 +3768,7 @@
3586
3768
  content: codeValue2,
3587
3769
  params: tableModel.value?.params || []
3588
3770
  });
3589
- design.tMagicMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
3771
+ design.tMagicMessage.success("代码成功保存到本地");
3590
3772
  services?.codeBlockService.removeCodeDraft(props.id);
3591
3773
  }
3592
3774
  };
@@ -3599,6 +3781,10 @@
3599
3781
  const close = () => {
3600
3782
  services?.codeBlockService.setCodeEditorShowStatus(false);
3601
3783
  };
3784
+ const codeDraftEditor = vue.ref();
3785
+ expose({
3786
+ codeDraftEditor
3787
+ });
3602
3788
  return (_ctx, _cache) => {
3603
3789
  const _component_m_form_table = vue.resolveComponent("m-form-table");
3604
3790
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCard), { shadow: "never" }, {
@@ -3627,6 +3813,8 @@
3627
3813
  ]),
3628
3814
  default: vue.withCtx(() => [
3629
3815
  vue.createVNode(_sfc_main$h, {
3816
+ ref_key: "codeDraftEditor",
3817
+ ref: codeDraftEditor,
3630
3818
  id: __props.id,
3631
3819
  content: codeContent.value,
3632
3820
  editable: __props.editable,
@@ -3658,6 +3846,7 @@
3658
3846
  setup(__props) {
3659
3847
  const services = vue.inject("services");
3660
3848
  const codeOptions = vue.inject("codeOptions", {});
3849
+ const size = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
3661
3850
  const left = vue.ref(200);
3662
3851
  const currentTitle = vue.ref("");
3663
3852
  const codeConfig = vue.ref(null);
@@ -3686,18 +3875,24 @@
3686
3875
  });
3687
3876
  currentTitle.value = state.codeList[0]?.name || "";
3688
3877
  });
3878
+ const functionEditor = vue.ref();
3879
+ const handleClose = async () => {
3880
+ await functionEditor.value?.codeDraftEditor?.close();
3881
+ };
3689
3882
  return (_ctx, _cache) => {
3690
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDialog), {
3691
- "model-value": true,
3883
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDrawer), {
3692
3884
  class: "code-editor-dialog",
3885
+ "model-value": true,
3693
3886
  title: currentTitle.value,
3694
- fullscreen: true,
3695
- "close-on-press-escape": false,
3887
+ "close-on-press-escape": true,
3696
3888
  "append-to-body": true,
3697
- "show-close": false
3889
+ "show-close": false,
3890
+ "close-on-click-modal": true,
3891
+ size: vue.unref(size),
3892
+ "before-close": handleClose
3698
3893
  }, {
3699
3894
  default: vue.withCtx(() => [
3700
- vue.createVNode(_sfc_main$n, {
3895
+ vue.createVNode(_sfc_main$q, {
3701
3896
  left: left.value,
3702
3897
  "onUpdate:left": _cache[0] || (_cache[0] = ($event) => left.value = $event),
3703
3898
  "min-left": 45,
@@ -3708,6 +3903,8 @@
3708
3903
  vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: vue.unref(id) }),
3709
3904
  codeConfig.value ? (vue.openBlock(), vue.createBlock(_sfc_main$g, {
3710
3905
  key: 0,
3906
+ ref_key: "functionEditor",
3907
+ ref: functionEditor,
3711
3908
  id: vue.unref(id),
3712
3909
  name: codeConfig.value.name,
3713
3910
  content: codeConfig.value.content,
@@ -3722,19 +3919,17 @@
3722
3919
  }, 8, ["left"])
3723
3920
  ]),
3724
3921
  _: 3
3725
- }, 8, ["title"]);
3922
+ }, 8, ["title", "size"]);
3726
3923
  };
3727
3924
  }
3728
3925
  });
3729
3926
 
3730
- const _hoisted_1$6 = { class: "m-editor-code-block-list" };
3731
- const _hoisted_2$2 = { class: "code-header-wrapper" };
3732
- const _hoisted_3 = /* @__PURE__ */ vue.createTextVNode("\u65B0\u589E");
3733
- const _hoisted_4 = ["id"];
3734
- const _hoisted_5 = { class: "list-item" };
3735
- const _hoisted_6 = { class: "code-name" };
3736
- const _hoisted_7 = {
3737
- key: 0,
3927
+ const _hoisted_1$6 = { class: "code-header-wrapper" };
3928
+ const _hoisted_2$2 = /* @__PURE__ */ vue.createTextVNode("新增");
3929
+ const _hoisted_3 = ["id"];
3930
+ const _hoisted_4 = { class: "list-item" };
3931
+ const _hoisted_5 = {
3932
+ key: 2,
3738
3933
  class: "right-tool"
3739
3934
  };
3740
3935
  const __default__$d = vue.defineComponent({
@@ -3750,27 +3945,32 @@
3750
3945
  const props = __props;
3751
3946
  const { codeBlockService, depService, editorService } = vue.inject("services") || {};
3752
3947
  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]) => ({
3948
+ () => Object.values(depService?.targets["code-block"] || {}).map((target) => {
3949
+ const compNodes = Object.entries(target.deps).map(([id, dep]) => ({
3758
3950
  name: dep.name,
3759
3951
  type: "node",
3760
3952
  id,
3761
3953
  children: dep.keys.map((key) => ({ name: key, id: key, type: "key" }))
3762
- }))
3763
- }))
3954
+ }));
3955
+ return {
3956
+ id: target.id,
3957
+ name: target.name,
3958
+ type: "code",
3959
+ codeBlockContent: codeBlockService?.getCodeContentById(target.id),
3960
+ children: compNodes
3961
+ };
3962
+ })
3764
3963
  );
3964
+ const expandedKeys = vue.computed(() => codeList.value.map((item) => item.id));
3765
3965
  const editable = vue.computed(() => codeBlockService?.getEditStatus());
3766
3966
  const isShowCodeBlockEditor = vue.computed(() => codeBlockService?.getCodeEditorShowStatus() || false);
3767
3967
  const createCodeBlock = async () => {
3768
3968
  if (!codeBlockService) {
3769
- design.tMagicMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
3969
+ design.tMagicMessage.error("新增代码块失败");
3770
3970
  return;
3771
3971
  }
3772
3972
  const codeConfig = {
3773
- name: "\u4EE3\u7801\u5757",
3973
+ name: "代码块",
3774
3974
  content: `({app, params}) => {
3775
3975
  // place your code here
3776
3976
  }`,
@@ -3793,11 +3993,10 @@
3793
3993
  if (typeof props.customError === "function") {
3794
3994
  props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
3795
3995
  } else {
3796
- design.tMagicMessage.error("\u4EE3\u7801\u5757\u5220\u9664\u5931\u8D25");
3996
+ design.tMagicMessage.error("代码块删除失败");
3797
3997
  }
3798
3998
  }
3799
3999
  };
3800
- const filterText = vue.ref("");
3801
4000
  const tree = vue.ref();
3802
4001
  const filterNode = (value, data) => {
3803
4002
  if (!value) {
@@ -3821,107 +4020,107 @@
3821
4020
  }
3822
4021
  };
3823
4022
  return (_ctx, _cache) => {
3824
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
3825
- vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
3826
- vue.createElementVNode("div", _hoisted_2$2, [
3827
- vue.createVNode(vue.unref(design.TMagicInput), {
3828
- class: vue.normalizeClass([vue.unref(editable) ? "code-filter-input" : "code-filter-input-no-btn"]),
3829
- size: "small",
3830
- placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
3831
- clearable: "",
3832
- modelValue: filterText.value,
3833
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
3834
- onInput: filterTextChangeHandler
3835
- }, null, 8, ["class", "modelValue"]),
3836
- vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
3837
- key: 0,
3838
- class: "create-code-button",
3839
- type: "primary",
3840
- size: "small",
3841
- onClick: createCodeBlock
3842
- }, {
3843
- default: vue.withCtx(() => [
3844
- _hoisted_3
3845
- ]),
3846
- _: 1
3847
- })) : vue.createCommentVNode("", true)
3848
- ])
3849
- ]),
3850
- vue.createVNode(vue.unref(design.TMagicScrollbar), null, {
3851
- default: vue.withCtx(() => [
3852
- vue.createVNode(vue.unref(design.TMagicTree), {
3853
- ref_key: "tree",
3854
- ref: tree,
3855
- class: "magic-editor-layer-tree",
3856
- "node-key": "id",
3857
- "empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
3858
- "default-expand-all": "",
3859
- "expand-on-click-node": false,
3860
- data: vue.unref(codeList),
3861
- "highlight-current": true,
3862
- "filter-node-method": filterNode,
3863
- onNodeClick: clickHandler
3864
- }, {
3865
- default: vue.withCtx(({ data }) => [
3866
- vue.createElementVNode("div", {
3867
- id: data.id,
3868
- class: "list-container"
3869
- }, [
3870
- vue.createElementVNode("div", _hoisted_5, [
3871
- vue.createElementVNode("span", _hoisted_6, vue.toDisplayString(data.name) + "\uFF08" + vue.toDisplayString(data.id) + "\uFF09", 1),
3872
- data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
3873
- vue.createVNode(vue.unref(design.TMagicTooltip), {
3874
- effect: "dark",
3875
- content: vue.unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
3876
- placement: "bottom"
3877
- }, {
3878
- default: vue.withCtx(() => [
3879
- vue.createVNode(_sfc_main$u, {
3880
- icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
3881
- class: "edit-icon",
3882
- onClick: vue.withModifiers(($event) => editCode(`${data.id}`), ["stop"])
3883
- }, null, 8, ["icon", "onClick"])
3884
- ]),
3885
- _: 2
3886
- }, 1032, ["content"]),
3887
- vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3888
- key: 0,
3889
- effect: "dark",
3890
- content: "\u5220\u9664",
3891
- placement: "bottom"
3892
- }, {
3893
- default: vue.withCtx(() => [
3894
- vue.createVNode(_sfc_main$u, {
3895
- icon: vue.unref(iconsVue.Close),
3896
- class: "edit-icon",
3897
- onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
3898
- }, null, 8, ["icon", "onClick"])
3899
- ]),
3900
- _: 2
3901
- }, 1024)) : vue.createCommentVNode("", true),
3902
- vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
3903
- id: data.id,
3904
- data: data.codeBlockContent
3905
- })
3906
- ])) : vue.createCommentVNode("", true)
3907
- ])
3908
- ], 8, _hoisted_4)
3909
- ]),
3910
- _: 3
3911
- }, 8, ["data"])
3912
- ]),
3913
- _: 3
3914
- }),
3915
- vue.unref(isShowCodeBlockEditor) ? (vue.openBlock(), vue.createBlock(_sfc_main$f, {
3916
- key: 0,
3917
- paramsColConfig: __props.paramsColConfig
3918
- }, {
3919
- "code-block-edit-panel-header": vue.withCtx(({ id }) => [
3920
- vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
4023
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "m-editor-code-block-list" }, {
4024
+ default: vue.withCtx(() => [
4025
+ vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
4026
+ vue.createElementVNode("div", _hoisted_1$6, [
4027
+ vue.createVNode(_sfc_main$k, { onSearch: filterTextChangeHandler }),
4028
+ vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
4029
+ key: 0,
4030
+ class: "create-code-button",
4031
+ type: "primary",
4032
+ size: "small",
4033
+ onClick: createCodeBlock
4034
+ }, {
4035
+ default: vue.withCtx(() => [
4036
+ _hoisted_2$2
4037
+ ]),
4038
+ _: 1
4039
+ })) : vue.createCommentVNode("", true)
4040
+ ])
3921
4041
  ]),
3922
- _: 3
3923
- }, 8, ["paramsColConfig"])) : vue.createCommentVNode("", true)
3924
- ]);
4042
+ vue.createVNode(vue.unref(design.TMagicTree), {
4043
+ ref_key: "tree",
4044
+ ref: tree,
4045
+ class: "magic-editor-layer-tree",
4046
+ "node-key": "id",
4047
+ "empty-text": "暂无代码块",
4048
+ "default-expanded-keys": vue.unref(expandedKeys),
4049
+ "expand-on-click-node": false,
4050
+ data: vue.unref(codeList),
4051
+ "highlight-current": true,
4052
+ "filter-node-method": filterNode,
4053
+ onNodeClick: clickHandler
4054
+ }, {
4055
+ default: vue.withCtx(({ data }) => [
4056
+ vue.createElementVNode("div", {
4057
+ id: data.id,
4058
+ class: "list-container"
4059
+ }, [
4060
+ vue.createElementVNode("div", _hoisted_4, [
4061
+ data.type === "code" ? (vue.openBlock(), vue.createBlock(CodeIcon, {
4062
+ key: 0,
4063
+ class: "codeIcon"
4064
+ })) : vue.createCommentVNode("", true),
4065
+ data.type === "node" ? (vue.openBlock(), vue.createBlock(AppManageIcon, {
4066
+ key: 1,
4067
+ class: "compIcon"
4068
+ })) : vue.createCommentVNode("", true),
4069
+ vue.createElementVNode("span", {
4070
+ class: vue.normalizeClass(["code-name", { code: data.type === "code", hook: data.type === "key" }])
4071
+ }, vue.toDisplayString(data.name) + "(" + vue.toDisplayString(data.id) + ")", 3),
4072
+ data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
4073
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
4074
+ effect: "dark",
4075
+ content: vue.unref(editable) ? "编辑" : "查看",
4076
+ placement: "bottom"
4077
+ }, {
4078
+ default: vue.withCtx(() => [
4079
+ vue.createVNode(_sfc_main$w, {
4080
+ icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
4081
+ class: "edit-icon",
4082
+ onClick: vue.withModifiers(($event) => editCode(`${data.id}`), ["stop"])
4083
+ }, null, 8, ["icon", "onClick"])
4084
+ ]),
4085
+ _: 2
4086
+ }, 1032, ["content"]),
4087
+ vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
4088
+ key: 0,
4089
+ effect: "dark",
4090
+ content: "删除",
4091
+ placement: "bottom"
4092
+ }, {
4093
+ default: vue.withCtx(() => [
4094
+ vue.createVNode(_sfc_main$w, {
4095
+ icon: vue.unref(iconsVue.Close),
4096
+ class: "edit-icon",
4097
+ onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
4098
+ }, null, 8, ["icon", "onClick"])
4099
+ ]),
4100
+ _: 2
4101
+ }, 1024)) : vue.createCommentVNode("", true),
4102
+ vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
4103
+ id: data.id,
4104
+ data: data.codeBlockContent
4105
+ })
4106
+ ])) : vue.createCommentVNode("", true)
4107
+ ])
4108
+ ], 8, _hoisted_3)
4109
+ ]),
4110
+ _: 3
4111
+ }, 8, ["default-expanded-keys", "data"]),
4112
+ vue.unref(isShowCodeBlockEditor) ? (vue.openBlock(), vue.createBlock(_sfc_main$f, {
4113
+ key: 0,
4114
+ paramsColConfig: __props.paramsColConfig
4115
+ }, {
4116
+ "code-block-edit-panel-header": vue.withCtx(({ id }) => [
4117
+ vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
4118
+ ]),
4119
+ _: 3
4120
+ }, 8, ["paramsColConfig"])) : vue.createCommentVNode("", true)
4121
+ ]),
4122
+ _: 3
4123
+ });
3925
4124
  };
3926
4125
  }
3927
4126
  });
@@ -3934,6 +4133,9 @@
3934
4133
  ...__default__$c,
3935
4134
  setup(__props) {
3936
4135
  const searchText = vue.ref("");
4136
+ const filterTextChangeHandler = (v) => {
4137
+ searchText.value = v;
4138
+ };
3937
4139
  const services = vue.inject("services");
3938
4140
  const stageOptions = vue.inject("stageOptions");
3939
4141
  const stage = vue.computed(() => services?.editorService.get("stage"));
@@ -3961,7 +4163,7 @@
3961
4163
  e.dataTransfer.effectAllowed = "move";
3962
4164
  e.dataTransfer.setData(
3963
4165
  "data",
3964
- serialize__default.default({
4166
+ serialize({
3965
4167
  name: text,
3966
4168
  type,
3967
4169
  ...data
@@ -4004,15 +4206,7 @@
4004
4206
  "model-value": vue.unref(collapseValue)
4005
4207
  }, {
4006
4208
  default: vue.withCtx(() => [
4007
- vue.createVNode(vue.unref(design.TMagicInput), {
4008
- placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
4009
- class: "search-input",
4010
- size: "small",
4011
- clearable: "",
4012
- "prefix-icon": vue.unref(iconsVue.Search),
4013
- modelValue: searchText.value,
4014
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
4015
- }, null, 8, ["prefix-icon", "modelValue"]),
4209
+ vue.createVNode(_sfc_main$k, { onSearch: filterTextChangeHandler }),
4016
4210
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(list), (group, index) => {
4017
4211
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
4018
4212
  group.items && group.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCollapseItem), {
@@ -4020,7 +4214,7 @@
4020
4214
  name: `${index}`
4021
4215
  }, {
4022
4216
  title: vue.withCtx(() => [
4023
- vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
4217
+ vue.createVNode(_sfc_main$w, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
4024
4218
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
4025
4219
  ]),
4026
4220
  default: vue.withCtx(() => [
@@ -4035,7 +4229,7 @@
4035
4229
  onDrag: dragHandler
4036
4230
  }, [
4037
4231
  vue.renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
4038
- vue.createVNode(_sfc_main$u, {
4232
+ vue.createVNode(_sfc_main$w, {
4039
4233
  icon: item.icon
4040
4234
  }, null, 8, ["icon"]),
4041
4235
  vue.createVNode(vue.unref(design.TMagicTooltip), {
@@ -4158,7 +4352,7 @@
4158
4352
  }, [
4159
4353
  vue.createElementVNode("div", null, [
4160
4354
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
4161
- return vue.openBlock(), vue.createBlock(_sfc_main$k, {
4355
+ return vue.openBlock(), vue.createBlock(_sfc_main$n, {
4162
4356
  "event-type": "mouseup",
4163
4357
  data: item,
4164
4358
  key: index,
@@ -4216,7 +4410,7 @@
4216
4410
  if (node.value?.type === "tabs") {
4217
4411
  return [
4218
4412
  {
4219
- text: "\u6807\u7B7E\u9875",
4413
+ text: "标签页",
4220
4414
  type: "button",
4221
4415
  icon: iconsVue.Files,
4222
4416
  handler: () => {
@@ -4246,14 +4440,14 @@
4246
4440
  const menuData = vue.computed(() => [
4247
4441
  {
4248
4442
  type: "button",
4249
- text: "\u65B0\u589E",
4443
+ text: "新增",
4250
4444
  icon: vue.markRaw(iconsVue.Plus),
4251
4445
  display: () => node.value?.items,
4252
4446
  items: getSubMenuData.value
4253
4447
  },
4254
4448
  {
4255
4449
  type: "button",
4256
- text: "\u590D\u5236",
4450
+ text: "复制",
4257
4451
  icon: vue.markRaw(iconsVue.CopyDocument),
4258
4452
  display: () => !isRoot.value,
4259
4453
  handler: () => {
@@ -4262,7 +4456,7 @@
4262
4456
  },
4263
4457
  {
4264
4458
  type: "button",
4265
- text: "\u5220\u9664",
4459
+ text: "删除",
4266
4460
  icon: vue.markRaw(iconsVue.Delete),
4267
4461
  display: () => !isRoot.value && !isPage.value,
4268
4462
  handler: () => {
@@ -4305,7 +4499,6 @@
4305
4499
  const menu = vue.ref();
4306
4500
  const checkedKeys = vue.ref([]);
4307
4501
  const isCtrlKeyDown = vue.ref(false);
4308
- const filterText = vue.ref("");
4309
4502
  const expandedKeys = vue.ref([]);
4310
4503
  const currentNodeKey = vue.ref();
4311
4504
  const clicked = vue.ref(false);
@@ -4327,7 +4520,7 @@
4327
4520
  const highlightNode = vue.computed(() => editorService?.get("highlightNode"));
4328
4521
  const select = async (data) => {
4329
4522
  if (!data.id) {
4330
- throw new Error("\u6CA1\u6709id");
4523
+ throw new Error("没有id");
4331
4524
  }
4332
4525
  await editorService?.select(data);
4333
4526
  editorService?.get("stage")?.select(data.id);
@@ -4338,7 +4531,7 @@
4338
4531
  };
4339
4532
  const highlight = (data) => {
4340
4533
  if (!data?.id) {
4341
- throw new Error("\u6CA1\u6709id");
4534
+ throw new Error("没有id");
4342
4535
  }
4343
4536
  editorService?.highlight(data);
4344
4537
  editorService?.get("stage")?.highlight(data.id);
@@ -4351,7 +4544,7 @@
4351
4544
  return false;
4352
4545
  if (ingType === schema.NodeType.PAGE && data.type !== schema.NodeType.PAGE)
4353
4546
  return false;
4354
- if (!data || !data.type)
4547
+ if (!data?.type)
4355
4548
  return false;
4356
4549
  if (["prev", "next"].includes(type))
4357
4550
  return true;
@@ -4436,7 +4629,7 @@
4436
4629
  let keycon;
4437
4630
  vue.onMounted(() => {
4438
4631
  editorService?.on("remove", editorServiceRemoveHandler);
4439
- keycon = new KeyController__default.default();
4632
+ keycon = new KeyController();
4440
4633
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
4441
4634
  const ctrl = isMac ? "meta" : "ctrl";
4442
4635
  keycon.keydown((e) => {
@@ -4490,23 +4683,14 @@
4490
4683
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
4491
4684
  default: vue.withCtx(() => [
4492
4685
  vue.renderSlot(_ctx.$slots, "layer-panel-header"),
4493
- vue.createVNode(vue.unref(design.TMagicInput), {
4494
- modelValue: filterText.value,
4495
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
4496
- class: "search-input",
4497
- size: "small",
4498
- placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
4499
- clearable: "",
4500
- "prefix-icon": vue.unref(iconsVue.Search),
4501
- onChange: filterTextChangeHandler
4502
- }, null, 8, ["modelValue", "prefix-icon"]),
4686
+ vue.createVNode(_sfc_main$k, { onSearch: filterTextChangeHandler }),
4503
4687
  vue.unref(values).length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
4504
4688
  key: 0,
4505
4689
  class: "magic-editor-layer-tree",
4506
4690
  ref_key: "tree",
4507
4691
  ref: tree,
4508
4692
  "node-key": "id",
4509
- "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
4693
+ "empty-text": "页面空荡荡的",
4510
4694
  draggable: "",
4511
4695
  "default-expanded-keys": expandedKeys.value,
4512
4696
  "default-checked-keys": checkedKeys.value,
@@ -4568,7 +4752,7 @@
4568
4752
  const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
4569
4753
  ...__default__$8,
4570
4754
  props: {
4571
- data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) },
4755
+ data: { default: () => ({ type: "tabs", status: "组件", items: ["component-list", "layer", "code-block"] }) },
4572
4756
  layerContentMenu: null
4573
4757
  },
4574
4758
  setup(__props, { expose }) {
@@ -4581,7 +4765,7 @@
4581
4765
  $key: "component-list",
4582
4766
  type: "component",
4583
4767
  icon: iconsVue.Coin,
4584
- text: "\u7EC4\u4EF6",
4768
+ text: "组件",
4585
4769
  component: _sfc_main$d,
4586
4770
  slots: {}
4587
4771
  },
@@ -4589,7 +4773,7 @@
4589
4773
  $key: "layer",
4590
4774
  type: "component",
4591
4775
  icon: iconsVue.Files,
4592
- text: "\u5DF2\u9009\u7EC4\u4EF6",
4776
+ text: "已选组件",
4593
4777
  props: {
4594
4778
  layerContentMenu: props.layerContentMenu
4595
4779
  },
@@ -4600,7 +4784,7 @@
4600
4784
  $key: "code-block",
4601
4785
  type: "component",
4602
4786
  icon: iconsVue.EditPen,
4603
- text: "\u4EE3\u7801\u7F16\u8F91",
4787
+ text: "代码编辑",
4604
4788
  component: _sfc_main$e,
4605
4789
  slots: {}
4606
4790
  }
@@ -4636,7 +4820,7 @@
4636
4820
  (vue.openBlock(), vue.createElementBlock("div", {
4637
4821
  key: config.text
4638
4822
  }, [
4639
- config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
4823
+ config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$w, {
4640
4824
  key: 0,
4641
4825
  icon: config.icon
4642
4826
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -4838,7 +5022,7 @@
4838
5022
  return;
4839
5023
  const root = vue.toRaw(editorService.get("root"));
4840
5024
  if (!root)
4841
- throw new Error("root \u4E0D\u80FD\u4E3A\u7A7A");
5025
+ throw new Error("root 不能为空");
4842
5026
  const pageConfig = {
4843
5027
  type: schema.NodeType.PAGE,
4844
5028
  name: generatePageNameByApp(root)
@@ -4857,14 +5041,14 @@
4857
5041
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
4858
5042
  onClick: addPage
4859
5043
  }, [
4860
- vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
5044
+ vue.createVNode(_sfc_main$w, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
4861
5045
  ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1)),
4862
5046
  canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
4863
5047
  key: 2,
4864
5048
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
4865
5049
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
4866
5050
  }, [
4867
- vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
5051
+ vue.createVNode(_sfc_main$w, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
4868
5052
  ])) : vue.createCommentVNode("", true),
4869
5053
  vue.unref(pageLength) ? (vue.openBlock(), vue.createElementBlock("div", {
4870
5054
  key: 3,
@@ -4880,7 +5064,7 @@
4880
5064
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
4881
5065
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
4882
5066
  }, [
4883
- vue.createVNode(_sfc_main$u, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
5067
+ vue.createVNode(_sfc_main$w, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
4884
5068
  ])) : vue.createCommentVNode("", true)
4885
5069
  ], 512);
4886
5070
  };
@@ -4952,18 +5136,18 @@
4952
5136
  default: vue.withCtx(() => [
4953
5137
  vue.createElementVNode("div", null, [
4954
5138
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
4955
- vue.createVNode(_sfc_main$k, {
5139
+ vue.createVNode(_sfc_main$n, {
4956
5140
  data: {
4957
5141
  type: "button",
4958
- text: "\u590D\u5236",
5142
+ text: "复制",
4959
5143
  icon: vue.unref(iconsVue.DocumentCopy),
4960
5144
  handler: () => copy(item)
4961
5145
  }
4962
5146
  }, null, 8, ["data"]),
4963
- vue.createVNode(_sfc_main$k, {
5147
+ vue.createVNode(_sfc_main$n, {
4964
5148
  data: {
4965
5149
  type: "button",
4966
- text: "\u5220\u9664",
5150
+ text: "删除",
4967
5151
  icon: vue.unref(iconsVue.Delete),
4968
5152
  handler: () => remove(item)
4969
5153
  }
@@ -5137,7 +5321,7 @@
5137
5321
  if (!thumb.value)
5138
5322
  return;
5139
5323
  const thumbEl = thumb.value;
5140
- gesto = new Gesto__default.default(thumbEl, {
5324
+ gesto = new Gesto(thumbEl, {
5141
5325
  container: window
5142
5326
  });
5143
5327
  gesto.on("dragStart", (e) => {
@@ -5328,7 +5512,7 @@
5328
5512
  const menuData = vue.computed(() => [
5329
5513
  {
5330
5514
  type: "button",
5331
- text: "\u6C34\u5E73\u5C45\u4E2D",
5515
+ text: "水平居中",
5332
5516
  display: () => canCenter.value,
5333
5517
  handler: () => {
5334
5518
  if (!nodes.value)
@@ -5338,7 +5522,7 @@
5338
5522
  },
5339
5523
  {
5340
5524
  type: "button",
5341
- text: "\u590D\u5236",
5525
+ text: "复制",
5342
5526
  icon: vue.markRaw(iconsVue.CopyDocument),
5343
5527
  handler: () => {
5344
5528
  nodes.value && editorService?.copy(nodes.value);
@@ -5347,7 +5531,7 @@
5347
5531
  },
5348
5532
  {
5349
5533
  type: "button",
5350
- text: "\u7C98\u8D34",
5534
+ text: "粘贴",
5351
5535
  icon: vue.markRaw(iconsVue.DocumentCopy),
5352
5536
  display: () => canPaste.value,
5353
5537
  handler: () => {
@@ -5371,7 +5555,7 @@
5371
5555
  },
5372
5556
  {
5373
5557
  type: "button",
5374
- text: "\u4E0A\u79FB\u4E00\u5C42",
5558
+ text: "上移一层",
5375
5559
  icon: vue.markRaw(iconsVue.Top),
5376
5560
  display: () => !utils.isPage(node.value) && !props.isMultiSelect,
5377
5561
  handler: () => {
@@ -5380,7 +5564,7 @@
5380
5564
  },
5381
5565
  {
5382
5566
  type: "button",
5383
- text: "\u4E0B\u79FB\u4E00\u5C42",
5567
+ text: "下移一层",
5384
5568
  icon: vue.markRaw(iconsVue.Bottom),
5385
5569
  display: () => !utils.isPage(node.value) && !props.isMultiSelect,
5386
5570
  handler: () => {
@@ -5389,7 +5573,7 @@
5389
5573
  },
5390
5574
  {
5391
5575
  type: "button",
5392
- text: "\u7F6E\u9876",
5576
+ text: "置顶",
5393
5577
  display: () => !utils.isPage(node.value) && !props.isMultiSelect,
5394
5578
  handler: () => {
5395
5579
  editorService?.moveLayer(LayerOffset.TOP);
@@ -5397,7 +5581,7 @@
5397
5581
  },
5398
5582
  {
5399
5583
  type: "button",
5400
- text: "\u7F6E\u5E95",
5584
+ text: "置底",
5401
5585
  display: () => !utils.isPage(node.value) && !props.isMultiSelect,
5402
5586
  handler: () => {
5403
5587
  editorService?.moveLayer(LayerOffset.BOTTOM);
@@ -5410,7 +5594,7 @@
5410
5594
  },
5411
5595
  {
5412
5596
  type: "button",
5413
- text: "\u5220\u9664",
5597
+ text: "删除",
5414
5598
  icon: iconsVue.Delete,
5415
5599
  display: () => !utils.isPage(node.value),
5416
5600
  handler: () => {
@@ -5423,7 +5607,7 @@
5423
5607
  },
5424
5608
  {
5425
5609
  type: "button",
5426
- text: "\u6E05\u7A7A\u53C2\u8003\u7EBF",
5610
+ text: "清空参考线",
5427
5611
  handler: () => {
5428
5612
  editorService?.get("stage")?.clearGuides();
5429
5613
  }
@@ -5649,7 +5833,7 @@
5649
5833
  vue.onMounted(() => {
5650
5834
  workspace.value?.addEventListener("mouseenter", mouseenterHandler);
5651
5835
  workspace.value?.addEventListener("mouseleave", mouseleaveHandler);
5652
- keycon = new KeyController__default.default(workspace.value);
5836
+ keycon = new KeyController(workspace.value);
5653
5837
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
5654
5838
  const ctrl = isMac ? "meta" : "ctrl";
5655
5839
  keycon.keyup("delete", (e) => {
@@ -5775,9 +5959,6 @@
5775
5959
  });
5776
5960
  constructor() {
5777
5961
  super([
5778
- "getCodeContentById",
5779
- "getCodeDslByIds",
5780
- "getCurrentDsl",
5781
5962
  "setCodeDslById",
5782
5963
  "setCodeEditorShowStatus",
5783
5964
  "setEditStatus",
@@ -5786,26 +5967,48 @@
5786
5967
  "deleteCodeDslByIds"
5787
5968
  ]);
5788
5969
  }
5970
+ /**
5971
+ * 设置活动的代码块dsl数据源
5972
+ * @param {CodeBlockDSL} codeDsl 代码DSL
5973
+ * @returns {void}
5974
+ */
5789
5975
  async setCodeDsl(codeDsl2) {
5790
5976
  this.state.codeDsl = codeDsl2;
5791
5977
  info("[code-block]:code-dsl-change", this.state.codeDsl);
5792
5978
  this.emit("code-dsl-change", this.state.codeDsl);
5793
5979
  }
5980
+ /**
5981
+ * 获取活动的代码块dsl数据源(默认从dsl中的codeBlocks字段读取)
5982
+ * 方法要支持钩子添加扩展,会被重写为异步方法,因此这里显示写为异步以提醒调用者需以异步形式调用
5983
+ * @param {boolean} forceRefresh 是否强制从活动dsl拉取刷新
5984
+ * @returns {CodeBlockDSL | null}
5985
+ */
5794
5986
  getCodeDsl() {
5795
5987
  return this.state.codeDsl;
5796
5988
  }
5797
- async getCodeContentById(id2) {
5989
+ /**
5990
+ * 根据代码块id获取代码块内容
5991
+ * @param {Id} id 代码块id
5992
+ * @returns {CodeBlockContent | null}
5993
+ */
5994
+ getCodeContentById(id2) {
5798
5995
  if (!id2)
5799
5996
  return null;
5800
- const totalCodeDsl = await this.getCodeDsl();
5997
+ const totalCodeDsl = this.getCodeDsl();
5801
5998
  if (!totalCodeDsl)
5802
5999
  return null;
5803
6000
  return totalCodeDsl[id2] ?? null;
5804
6001
  }
6002
+ /**
6003
+ * 设置代码块ID和代码内容到源dsl
6004
+ * @param {Id} id 代码块id
6005
+ * @param {CodeBlockContent} codeConfig 代码块内容配置信息
6006
+ * @returns {void}
6007
+ */
5805
6008
  async setCodeDslById(id, codeConfig) {
5806
- const codeDsl = await this.getCodeDsl();
6009
+ const codeDsl = this.getCodeDsl();
5807
6010
  if (!codeDsl) {
5808
- throw new Error("dsl\u4E2D\u6CA1\u6709codeBlocks");
6011
+ throw new Error("dsl中没有codeBlocks");
5809
6012
  }
5810
6013
  const codeConfigProcessed = codeConfig;
5811
6014
  if (codeConfig.content) {
@@ -5818,60 +6021,133 @@
5818
6021
  };
5819
6022
  this.emit("addOrUpdate", id, codeDsl[id]);
5820
6023
  }
5821
- async getCodeDslByIds(ids) {
5822
- const codeDsl2 = await this.getCodeDsl();
6024
+ /**
6025
+ * 根据代码块id数组获取代码dsl
6026
+ * @param {string[]} ids 代码块id数组
6027
+ * @returns {CodeBlockDSL}
6028
+ */
6029
+ getCodeDslByIds(ids) {
6030
+ const codeDsl2 = this.getCodeDsl();
5823
6031
  return lodashEs.pick(codeDsl2, ids);
5824
6032
  }
6033
+ /**
6034
+ * 设置代码编辑面板展示状态
6035
+ * @param {boolean} status 是否展示代码编辑面板
6036
+ * @returns {void}
6037
+ */
5825
6038
  async setCodeEditorShowStatus(status) {
5826
6039
  this.state.isShowCodeEditor = status;
5827
6040
  }
6041
+ /**
6042
+ * 获取代码编辑面板展示状态
6043
+ * @returns {boolean} 是否展示代码编辑面板
6044
+ */
5828
6045
  getCodeEditorShowStatus() {
5829
6046
  return this.state.isShowCodeEditor;
5830
6047
  }
6048
+ /**
6049
+ * 设置代码编辑面板展示状态及展示内容
6050
+ * @param {boolean} status 是否展示代码编辑面板
6051
+ * @param {Id} id 代码块id
6052
+ * @returns {void}
6053
+ */
5831
6054
  setCodeEditorContent(status, id2) {
5832
6055
  if (!id2)
5833
6056
  return;
5834
6057
  this.setId(id2);
5835
6058
  this.state.isShowCodeEditor = status;
5836
6059
  }
5837
- async getCurrentDsl() {
5838
- return await this.getCodeContentById(this.state.id);
5839
- }
6060
+ /**
6061
+ * 获取当前选中的代码块内容
6062
+ * @returns {CodeBlockContent | null}
6063
+ */
6064
+ getCurrentDsl() {
6065
+ return this.getCodeContentById(this.state.id);
6066
+ }
6067
+ /**
6068
+ * 获取编辑状态
6069
+ * @returns {boolean} 是否可编辑
6070
+ */
5840
6071
  getEditStatus() {
5841
6072
  return this.state.editable;
5842
6073
  }
6074
+ /**
6075
+ * 设置编辑状态
6076
+ * @param {boolean} status 是否可编辑
6077
+ * @returns {void}
6078
+ */
5843
6079
  async setEditStatus(status) {
5844
6080
  this.state.editable = status;
5845
6081
  }
6082
+ /**
6083
+ * 设置当前选中的代码块ID
6084
+ * @param {Id} id 代码块id
6085
+ * @returns {void}
6086
+ */
5846
6087
  setId(id2) {
5847
6088
  if (!id2)
5848
6089
  return;
5849
6090
  this.state.id = id2;
5850
6091
  }
6092
+ /**
6093
+ * 获取当前选中的代码块ID
6094
+ * @returns {Id} id 代码块id
6095
+ */
5851
6096
  getId() {
5852
6097
  return this.state.id;
5853
6098
  }
6099
+ /**
6100
+ * 设置当前选中组件已关联绑定的代码块id数组
6101
+ * @param {string[]} ids 代码块id数组
6102
+ * @returns {void}
6103
+ */
5854
6104
  async setCombineIds(ids) {
5855
6105
  this.state.combineIds = ids;
5856
6106
  }
6107
+ /**
6108
+ * 获取当前选中组件已关联绑定的代码块id数组
6109
+ * @returns {string[]}
6110
+ */
5857
6111
  getCombineIds() {
5858
6112
  return this.state.combineIds;
5859
6113
  }
6114
+ /**
6115
+ * 获取不可删除列表
6116
+ * @returns {Id[]}
6117
+ */
5860
6118
  getUndeletableList() {
5861
6119
  return this.state.undeletableList;
5862
6120
  }
6121
+ /**
6122
+ * 设置不可删除列表:为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除)
6123
+ * @param {Id[]} codeIds 代码块id数组
6124
+ * @returns {void}
6125
+ */
5863
6126
  async setUndeleteableList(codeIds) {
5864
6127
  this.state.undeletableList = codeIds;
5865
6128
  }
6129
+ /**
6130
+ * 设置代码草稿
6131
+ */
5866
6132
  setCodeDraft(codeId, content) {
5867
6133
  globalThis.localStorage.setItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`, content);
5868
6134
  }
6135
+ /**
6136
+ * 获取代码草稿
6137
+ */
5869
6138
  getCodeDraft(codeId) {
5870
6139
  return globalThis.localStorage.getItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`);
5871
6140
  }
6141
+ /**
6142
+ * 删除代码草稿
6143
+ */
5872
6144
  removeCodeDraft(codeId) {
5873
6145
  globalThis.localStorage.removeItem(`${CODE_DRAFT_STORAGE_KEY}_${codeId}`);
5874
6146
  }
6147
+ /**
6148
+ * 在dsl数据源中删除指定id的代码块
6149
+ * @param {Id[]} codeIds 需要删除的代码块id数组
6150
+ */
5875
6151
  async deleteCodeDslByIds(codeIds) {
5876
6152
  const currentDsl = await this.getCodeDsl();
5877
6153
  if (!currentDsl)
@@ -5881,6 +6157,10 @@
5881
6157
  this.emit("remove", id2);
5882
6158
  });
5883
6159
  }
6160
+ /**
6161
+ * 生成代码块唯一id
6162
+ * @returns {Id} 代码块唯一id
6163
+ */
5884
6164
  async getUniqueId() {
5885
6165
  const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
5886
6166
  const dsl = await this.getCodeDsl();
@@ -5912,6 +6192,9 @@
5912
6192
  constructor() {
5913
6193
  super([]);
5914
6194
  }
6195
+ /**
6196
+ * @param componentGroupList 组件列表配置
6197
+ */
5915
6198
  setList(componentGroupList) {
5916
6199
  this.state.list = componentGroupList;
5917
6200
  }
@@ -5930,10 +6213,27 @@
5930
6213
  const componentListService = new ComponentList();
5931
6214
 
5932
6215
  class Target extends events.EventEmitter {
6216
+ /**
6217
+ * 如何识别目标
6218
+ */
5933
6219
  isTarget;
6220
+ /**
6221
+ * 目标id,不可重复
6222
+ * 例如目标是代码块,则为代码块id
6223
+ */
5934
6224
  id;
6225
+ /**
6226
+ * 目标名称,用于显示在依赖列表中
6227
+ */
5935
6228
  name;
6229
+ /**
6230
+ * 不同的目标可以进行分类,例如代码块,数据源可以为两个不同的type
6231
+ */
5936
6232
  type = "default";
6233
+ /**
6234
+ * 依赖详情
6235
+ * 实例:{ 'node_id': { name: 'node_name', keys: [ created, mounted ] } }
6236
+ */
5937
6237
  deps = vue.reactive({});
5938
6238
  constructor(options) {
5939
6239
  super();
@@ -5944,6 +6244,11 @@
5944
6244
  this.type = options.type;
5945
6245
  }
5946
6246
  }
6247
+ /**
6248
+ * 更新依赖
6249
+ * @param node 节点配置
6250
+ * @param key 哪个key配置了这个目标的id
6251
+ */
5947
6252
  updateDep(node, key) {
5948
6253
  const dep = this.deps[node.id] || {
5949
6254
  name: node.name,
@@ -5958,6 +6263,12 @@
5958
6263
  }
5959
6264
  this.emit("change");
5960
6265
  }
6266
+ /**
6267
+ * 删除依赖
6268
+ * @param node 哪个节点的依赖需要移除,如果为空,则移除所有依赖
6269
+ * @param key 节点下哪个key需要移除,如果为空,则移除改节点下的所有依赖key
6270
+ * @returns void
6271
+ */
5961
6272
  removeDep(node, key) {
5962
6273
  if (!node) {
5963
6274
  Object.keys(this.deps).forEach((depKey) => {
@@ -5980,6 +6291,12 @@
5980
6291
  }
5981
6292
  this.emit("change");
5982
6293
  }
6294
+ /**
6295
+ * 判断指定节点下的指定key是否存在在依赖列表中
6296
+ * @param node 哪个节点
6297
+ * @param key 哪个key
6298
+ * @returns boolean
6299
+ */
5983
6300
  hasDep(node, key) {
5984
6301
  const dep = this.deps[node.id];
5985
6302
  return Boolean(dep?.keys.find((d) => d === key));
@@ -5990,15 +6307,29 @@
5990
6307
  }
5991
6308
  class Watcher extends events.EventEmitter {
5992
6309
  targets = vue.reactive({});
6310
+ /**
6311
+ * 获取指定类型中的所有target
6312
+ * @param type 分类
6313
+ * @returns Target[]
6314
+ */
5993
6315
  getTargets(type = "default") {
5994
6316
  return this.targets[type] || {};
5995
6317
  }
6318
+ /**
6319
+ * 添加新的目标
6320
+ * @param target Target
6321
+ */
5996
6322
  addTarget(target) {
5997
6323
  const targets = this.getTargets(target.type) || {};
5998
6324
  this.targets[target.type] = targets;
5999
6325
  targets[target.id] = target;
6000
6326
  this.emit("add-target", target);
6001
6327
  }
6328
+ /**
6329
+ * 获取指定id的target
6330
+ * @param id target id
6331
+ * @returns Target
6332
+ */
6002
6333
  getTarget(id) {
6003
6334
  const allTargets = Object.values(this.targets);
6004
6335
  for (const targets of allTargets) {
@@ -6007,6 +6338,11 @@
6007
6338
  }
6008
6339
  }
6009
6340
  }
6341
+ /**
6342
+ * 判断是否存在指定id的target
6343
+ * @param id target id
6344
+ * @returns boolean
6345
+ */
6010
6346
  hasTarget(id) {
6011
6347
  const allTargets = Object.values(this.targets);
6012
6348
  for (const targets of allTargets) {
@@ -6016,6 +6352,10 @@
6016
6352
  }
6017
6353
  return false;
6018
6354
  }
6355
+ /**
6356
+ * 删除指定id的target
6357
+ * @param id target id
6358
+ */
6019
6359
  removeTarget(id) {
6020
6360
  const allTargets = Object.values(this.targets);
6021
6361
  for (const targets of allTargets) {
@@ -6026,6 +6366,11 @@
6026
6366
  }
6027
6367
  this.emit("remove-target");
6028
6368
  }
6369
+ /**
6370
+ * 删除指定分类的所有target
6371
+ * @param type 分类
6372
+ * @returns void
6373
+ */
6029
6374
  removeTargets(type = "default") {
6030
6375
  const targets = this.targets[type];
6031
6376
  if (!targets)
@@ -6036,11 +6381,19 @@
6036
6381
  delete this.targets[type];
6037
6382
  this.emit("remove-target");
6038
6383
  }
6384
+ /**
6385
+ * 删除所有target
6386
+ */
6039
6387
  clearTargets() {
6040
6388
  Object.keys(this.targets).forEach((key) => {
6041
6389
  delete this.targets[key];
6042
6390
  });
6043
6391
  }
6392
+ /**
6393
+ * 收集依赖
6394
+ * @param nodes 需要收集的节点
6395
+ * @param deep 是否需要收集子节点
6396
+ */
6044
6397
  collect(nodes, deep = false) {
6045
6398
  Object.values(this.targets).forEach((targets) => {
6046
6399
  Object.values(targets).forEach((target) => {
@@ -6051,6 +6404,10 @@
6051
6404
  });
6052
6405
  });
6053
6406
  }
6407
+ /**
6408
+ * 清除依赖
6409
+ * @param nodes 需要清除依赖的节点
6410
+ */
6054
6411
  clear(nodes) {
6055
6412
  Object.values(this.targets).forEach((targets) => {
6056
6413
  Object.values(targets).forEach((target) => {
@@ -6150,50 +6507,64 @@
6150
6507
  const eventsService = new Events();
6151
6508
 
6152
6509
  const editorProps = {
6510
+ /** 页面初始值 */
6153
6511
  modelValue: {
6154
6512
  type: Object,
6155
6513
  default: () => ({}),
6156
6514
  require: true
6157
6515
  },
6516
+ /** 左侧面板中的组件列表 */
6158
6517
  componentGroupList: {
6159
6518
  type: Array,
6160
6519
  default: () => []
6161
6520
  },
6521
+ /** 左侧面板配置 */
6162
6522
  sidebar: {
6163
6523
  type: Object
6164
6524
  },
6525
+ /** 顶部工具栏配置 */
6165
6526
  menu: {
6166
6527
  type: Object,
6167
6528
  default: () => ({ left: [], right: [] })
6168
6529
  },
6530
+ /** 组件树右键菜单 */
6169
6531
  layerContentMenu: {
6170
6532
  type: Array,
6171
6533
  default: () => []
6172
6534
  },
6535
+ /** 画布右键菜单 */
6173
6536
  stageContentMenu: {
6174
6537
  type: Array,
6175
6538
  default: () => []
6176
6539
  },
6540
+ /** 中间工作区域中画布渲染的内容 */
6177
6541
  render: {
6178
6542
  type: Function
6179
6543
  },
6544
+ /** 中间工作区域中画布通过iframe渲染时的页面url */
6180
6545
  runtimeUrl: String,
6546
+ /** 选中时是否自动滚动到可视区域 */
6181
6547
  autoScrollIntoView: Boolean,
6548
+ /** 组件的属性配置表单的dsl */
6182
6549
  propsConfigs: {
6183
6550
  type: Object,
6184
6551
  default: () => ({})
6185
6552
  },
6553
+ /** 添加组件时的默认值 */
6186
6554
  propsValues: {
6187
6555
  type: Object,
6188
6556
  default: () => ({})
6189
6557
  },
6558
+ /** 组件联动事件选项列表 */
6190
6559
  eventMethodList: {
6191
6560
  type: Object,
6192
6561
  default: () => ({})
6193
6562
  },
6563
+ /** 画布中组件选中框的移动范围 */
6194
6564
  moveableOptions: {
6195
6565
  type: [Object, Function]
6196
6566
  },
6567
+ /** 编辑器初始化时默认选中的组件ID */
6197
6568
  defaultSelected: {
6198
6569
  type: [Number, String]
6199
6570
  },
@@ -6397,11 +6768,11 @@
6397
6768
  const _sfc_main = vue.defineComponent({
6398
6769
  name: "m-editor",
6399
6770
  components: {
6400
- TMagicNavMenu: _sfc_main$j,
6771
+ TMagicNavMenu: _sfc_main$m,
6401
6772
  Sidebar: _sfc_main$9,
6402
6773
  Workspace: _sfc_main$1,
6403
- PropsPanel: _sfc_main$i,
6404
- Framework: _sfc_main$l
6774
+ PropsPanel: _sfc_main$l,
6775
+ Framework: _sfc_main$o
6405
6776
  },
6406
6777
  props: editorProps,
6407
6778
  emits: ["props-panel-mounted", "update:modelValue"],
@@ -6441,14 +6812,6 @@
6441
6812
  }
6442
6813
  });
6443
6814
 
6444
- const _export_sfc = (sfc, props) => {
6445
- const target = sfc.__vccOpts || sfc;
6446
- for (const [key, val] of props) {
6447
- target[key] = val;
6448
- }
6449
- return target;
6450
- };
6451
-
6452
6815
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
6453
6816
  const _component_TMagicNavMenu = vue.resolveComponent("TMagicNavMenu");
6454
6817
  const _component_Sidebar = vue.resolveComponent("Sidebar");
@@ -6539,20 +6902,22 @@
6539
6902
 
6540
6903
  const index$1 = '';
6541
6904
 
6542
- const defaultInstallOpt = {};
6905
+ const defaultInstallOpt = {
6906
+ // @todo, 自定义图片上传方法等编辑器依赖的外部选项
6907
+ };
6543
6908
  const index = {
6544
6909
  install: (app, opt) => {
6545
6910
  const option = Object.assign(defaultInstallOpt, opt || {});
6546
6911
  app.config.globalProperties.$TMAGIC_EDITOR = option;
6547
6912
  setConfig(option);
6548
6913
  app.component(Editor.name, Editor);
6549
- app.component("m-fields-ui-select", _sfc_main$q);
6550
- app.component("m-fields-code-link", _sfc_main$v);
6551
- app.component("m-fields-vs-code", _sfc_main$w);
6552
- app.component("magic-code-editor", _sfc_main$p);
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);
6914
+ app.component("m-fields-ui-select", _sfc_main$t);
6915
+ app.component("m-fields-code-link", _sfc_main$y);
6916
+ app.component("m-fields-vs-code", _sfc_main$z);
6917
+ app.component("magic-code-editor", _sfc_main$s);
6918
+ app.component("m-fields-code-select", _sfc_main$x);
6919
+ app.component("m-fields-code-select-col", _sfc_main$v);
6920
+ app.component("m-fields-event-select", _sfc_main$u);
6556
6921
  }
6557
6922
  };
6558
6923
 
@@ -6560,24 +6925,24 @@
6560
6925
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
6561
6926
  exports.CodeBlockList = _sfc_main$e;
6562
6927
  exports.CodeDeleteErrorType = CodeDeleteErrorType;
6563
- exports.CodeSelect = _sfc_main$t;
6564
- exports.CodeSelectCol = _sfc_main$s;
6928
+ exports.CodeSelect = _sfc_main$x;
6929
+ exports.CodeSelectCol = _sfc_main$v;
6565
6930
  exports.ColumnLayout = ColumnLayout;
6566
6931
  exports.ComponentListPanel = _sfc_main$d;
6567
6932
  exports.ContentMenu = _sfc_main$c;
6568
- exports.EventSelect = _sfc_main$r;
6933
+ exports.EventSelect = _sfc_main$u;
6569
6934
  exports.Fixed2Other = Fixed2Other;
6570
6935
  exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
6571
- exports.Icon = _sfc_main$u;
6936
+ exports.Icon = _sfc_main$w;
6572
6937
  exports.Keys = Keys;
6573
6938
  exports.LayerOffset = LayerOffset;
6574
6939
  exports.LayerPanel = _sfc_main$a;
6575
6940
  exports.Layout = Layout;
6576
- exports.LayoutContainer = _sfc_main$n;
6577
- exports.PropsPanel = _sfc_main$i;
6578
- exports.TMagicCodeEditor = _sfc_main$p;
6941
+ exports.LayoutContainer = _sfc_main$q;
6942
+ exports.PropsPanel = _sfc_main$l;
6943
+ exports.TMagicCodeEditor = _sfc_main$s;
6579
6944
  exports.TMagicEditor = Editor;
6580
- exports.ToolButton = _sfc_main$k;
6945
+ exports.ToolButton = _sfc_main$n;
6581
6946
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
6582
6947
  exports.beforePaste = beforePaste;
6583
6948
  exports.change2Fixed = change2Fixed;