@tmagic/editor 1.1.6 → 1.2.0-beta.10

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 (82) hide show
  1. package/dist/style.css +191 -8
  2. package/dist/tmagic-editor.mjs +2104 -1027
  3. package/dist/tmagic-editor.mjs.map +1 -1
  4. package/dist/tmagic-editor.umd.js +2136 -1053
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/package.json +11 -10
  7. package/src/Editor.vue +27 -12
  8. package/src/components/ContentMenu.vue +4 -4
  9. package/src/components/Icon.vue +7 -5
  10. package/src/{layouts → components}/Layout.vue +15 -5
  11. package/src/components/ScrollBar.vue +1 -1
  12. package/src/components/ScrollViewer.vue +10 -1
  13. package/src/components/ToolButton.vue +30 -15
  14. package/src/fields/Code.vue +5 -2
  15. package/src/fields/CodeLink.vue +20 -12
  16. package/src/fields/CodeSelect.vue +131 -0
  17. package/src/fields/UISelect.vue +9 -8
  18. package/src/index.ts +7 -2
  19. package/src/layouts/AddPageBox.vue +13 -20
  20. package/src/layouts/CodeEditor.vue +106 -120
  21. package/src/layouts/Framework.vue +62 -40
  22. package/src/layouts/NavMenu.vue +1 -1
  23. package/src/layouts/PropsPanel.vue +5 -10
  24. package/src/layouts/Resizer.vue +1 -1
  25. package/src/layouts/sidebar/ComponentListPanel.vue +15 -13
  26. package/src/layouts/sidebar/LayerMenu.vue +89 -92
  27. package/src/layouts/sidebar/LayerPanel.vue +273 -178
  28. package/src/layouts/sidebar/Sidebar.vue +129 -37
  29. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +169 -0
  30. package/src/layouts/sidebar/code-block/CodeBlockList.vue +267 -0
  31. package/src/layouts/workspace/Breadcrumb.vue +32 -0
  32. package/src/layouts/workspace/PageBar.vue +12 -11
  33. package/src/layouts/workspace/PageBarScrollContainer.vue +1 -1
  34. package/src/layouts/workspace/Stage.vue +15 -7
  35. package/src/layouts/workspace/ViewerMenu.vue +8 -7
  36. package/src/layouts/workspace/Workspace.vue +10 -3
  37. package/src/services/codeBlock.ts +415 -0
  38. package/src/services/editor.ts +35 -5
  39. package/src/theme/breadcrumb.scss +6 -0
  40. package/src/theme/code-block.scss +184 -0
  41. package/src/theme/component-list-panel.scss +3 -7
  42. package/src/theme/index.scss +1 -13
  43. package/src/theme/layer-panel.scss +7 -2
  44. package/src/theme/layout.scss +5 -0
  45. package/src/theme/theme.scss +16 -0
  46. package/src/type.ts +88 -1
  47. package/src/utils/props.ts +9 -3
  48. package/src/utils/scroll-viewer.ts +18 -2
  49. package/src/utils/stage.ts +7 -0
  50. package/types/Editor.vue.d.ts +2 -2
  51. package/types/components/ContentMenu.vue.d.ts +1 -3
  52. package/types/components/Icon.vue.d.ts +1 -3
  53. package/types/{layouts → components}/Layout.vue.d.ts +0 -0
  54. package/types/components/ScrollBar.vue.d.ts +1 -3
  55. package/types/components/ScrollViewer.vue.d.ts +45 -1
  56. package/types/components/ToolButton.vue.d.ts +1 -3
  57. package/types/fields/Code.vue.d.ts +9 -3
  58. package/types/fields/CodeLink.vue.d.ts +5 -3
  59. package/types/fields/CodeSelect.vue.d.ts +94 -0
  60. package/types/fields/UISelect.vue.d.ts +1 -3
  61. package/types/index.d.ts +4 -0
  62. package/types/layouts/AddPageBox.vue.d.ts +43 -3
  63. package/types/layouts/CodeEditor.vue.d.ts +158 -45
  64. package/types/layouts/NavMenu.vue.d.ts +1 -3
  65. package/types/layouts/sidebar/LayerMenu.vue.d.ts +31 -63
  66. package/types/layouts/sidebar/LayerPanel.vue.d.ts +38 -1074
  67. package/types/layouts/sidebar/Sidebar.vue.d.ts +119 -17
  68. package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +50 -0
  69. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +73 -0
  70. package/types/layouts/workspace/Breadcrumb.vue.d.ts +44 -0
  71. package/types/layouts/workspace/Stage.vue.d.ts +23 -7
  72. package/types/layouts/workspace/ViewerMenu.vue.d.ts +6 -3
  73. package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
  74. package/types/services/codeBlock.d.ts +155 -0
  75. package/types/services/editor.d.ts +12 -1
  76. package/types/services/props.d.ts +12 -0
  77. package/types/services/ui.d.ts +1 -1
  78. package/types/type.d.ts +78 -1
  79. package/types/utils/props.d.ts +12 -0
  80. package/types/utils/scroll-viewer.d.ts +5 -0
  81. package/src/layouts/sidebar/TabPane.vue +0 -99
  82. package/types/layouts/sidebar/TabPane.vue.d.ts +0 -14
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('@tmagic/stage'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('gesto'), require('element-plus'), require('keycon')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', '@tmagic/stage', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'gesto', 'element-plus', 'keycon'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.iconsVue, global.lodashEs, global.monaco, global.StageCore, global.schema, global.utils, global.events, global.core, global.Gesto, global.ElementPlus, global.KeyController));
5
- })(this, (function (exports, vue, serialize, iconsVue, lodashEs, monaco, StageCore, schema, utils, events, core, Gesto, elementPlus, KeyController) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('lodash-es'), require('@tmagic/design'), require('@element-plus/icons-vue'), require('monaco-editor'), require('@tmagic/stage'), require('gesto'), require('@tmagic/schema'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('keycon')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'lodash-es', '@tmagic/design', '@element-plus/icons-vue', 'monaco-editor', '@tmagic/stage', 'gesto', '@tmagic/schema', '@tmagic/utils', 'events', '@tmagic/core', 'keycon'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.serialize, global.lodashEs, global.design, global.iconsVue, global.monaco, global.StageCore, global.Gesto, global.schema, global.utils, global.events, global.core, global.KeyController));
5
+ })(this, (function (exports, vue, serialize, lodashEs, design, iconsVue, monaco, StageCore, Gesto, schema, utils, events, core, KeyController) { 'use strict';
6
6
 
7
7
  const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
8
8
 
@@ -30,8 +30,11 @@
30
30
  const Gesto__default = /*#__PURE__*/_interopDefaultLegacy(Gesto);
31
31
  const KeyController__default = /*#__PURE__*/_interopDefaultLegacy(KeyController);
32
32
 
33
- const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
34
- __name: "Code",
33
+ const __default__$r = vue.defineComponent({
34
+ name: "MEditorCode"
35
+ });
36
+ const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
37
+ ...__default__$r,
35
38
  props: {
36
39
  model: null,
37
40
  name: null,
@@ -42,7 +45,7 @@
42
45
  setup(__props, { emit }) {
43
46
  const props = __props;
44
47
  const language = vue.computed(() => props.config.language || "javascript");
45
- const height = vue.computed(() => `${document.body.clientHeight - 168}px`);
48
+ const height = vue.computed(() => props.config.height || `${document.body.clientHeight - 168}px`);
46
49
  const save = (v) => {
47
50
  props.model[props.name] = v;
48
51
  emit("change", v);
@@ -53,14 +56,18 @@
53
56
  style: vue.normalizeStyle(`height: ${vue.unref(height)}`),
54
57
  "init-values": __props.model[__props.name],
55
58
  language: vue.unref(language),
59
+ options: __props.config.options,
56
60
  onSave: save
57
- }, null, 8, ["style", "init-values", "language"]);
61
+ }, null, 8, ["style", "init-values", "language", "options"]);
58
62
  };
59
63
  }
60
64
  });
61
65
 
62
- const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
63
- __name: "CodeLink",
66
+ const __default__$q = vue.defineComponent({
67
+ name: "MEditorCodeLink"
68
+ });
69
+ const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
70
+ ...__default__$q,
64
71
  props: {
65
72
  config: null,
66
73
  model: null,
@@ -70,17 +77,24 @@
70
77
  emits: ["change"],
71
78
  setup(__props, { emit }) {
72
79
  const props = __props;
73
- const formConfig = vue.computed(() => ({
74
- ...props.config,
75
- text: "",
76
- type: "link",
77
- form: [
78
- {
79
- name: props.name,
80
- type: "vs-code"
81
- }
82
- ]
83
- }));
80
+ const formConfig = vue.computed(() => {
81
+ const { codeOptions, ...config } = props.config;
82
+ return {
83
+ ...config,
84
+ text: "",
85
+ type: "link",
86
+ form: [
87
+ {
88
+ name: props.name,
89
+ type: "vs-code",
90
+ options: {
91
+ tabSize: 2,
92
+ ...codeOptions || {}
93
+ }
94
+ }
95
+ ]
96
+ };
97
+ });
84
98
  const modelValue = vue.reactive({
85
99
  form: {
86
100
  [props.name]: ""
@@ -122,9 +136,187 @@
122
136
  }
123
137
  });
124
138
 
125
- const _hoisted_1$b = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
126
- const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
127
- __name: "UISelect",
139
+ var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
140
+ ColumnLayout2["LEFT"] = "left";
141
+ ColumnLayout2["CENTER"] = "center";
142
+ ColumnLayout2["RIGHT"] = "right";
143
+ return ColumnLayout2;
144
+ })(ColumnLayout || {});
145
+ var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
146
+ LayerOffset2["TOP"] = "top";
147
+ LayerOffset2["BOTTOM"] = "bottom";
148
+ return LayerOffset2;
149
+ })(LayerOffset || {});
150
+ var Layout = /* @__PURE__ */ ((Layout2) => {
151
+ Layout2["FLEX"] = "flex";
152
+ Layout2["FIXED"] = "fixed";
153
+ Layout2["RELATIVE"] = "relative";
154
+ Layout2["ABSOLUTE"] = "absolute";
155
+ return Layout2;
156
+ })(Layout || {});
157
+ var Keys = /* @__PURE__ */ ((Keys2) => {
158
+ Keys2["ESCAPE"] = "Space";
159
+ return Keys2;
160
+ })(Keys || {});
161
+ const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
162
+ const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
163
+ var CodeEditorMode = /* @__PURE__ */ ((CodeEditorMode2) => {
164
+ CodeEditorMode2["LIST"] = "list";
165
+ CodeEditorMode2["EDITOR"] = "editor";
166
+ return CodeEditorMode2;
167
+ })(CodeEditorMode || {});
168
+ var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
169
+ CodeDeleteErrorType2["UNDELETEABLE"] = "undeleteable";
170
+ CodeDeleteErrorType2["BIND"] = "bind";
171
+ return CodeDeleteErrorType2;
172
+ })(CodeDeleteErrorType || {});
173
+ var CodeSelectOp = /* @__PURE__ */ ((CodeSelectOp2) => {
174
+ CodeSelectOp2["ADD"] = "add";
175
+ CodeSelectOp2["DELETE"] = "delete";
176
+ CodeSelectOp2["CHANGE"] = "change";
177
+ return CodeSelectOp2;
178
+ })(CodeSelectOp || {});
179
+
180
+ const _hoisted_1$e = { class: "tool-bar" };
181
+ const _hoisted_2$6 = /* @__PURE__ */ vue.createElementVNode("path", {
182
+ fill: "currentColor",
183
+ d: "m23 12l-7.071 7.071l-1.414-1.414L20.172 12l-5.657-5.657l1.414-1.414L23 12zM3.828 12l5.657 5.657l-1.414 1.414L1 12l7.071-7.071l1.414 1.414L3.828 12z"
184
+ }, null, -1);
185
+ const _hoisted_3$3 = [
186
+ _hoisted_2$6
187
+ ];
188
+ const __default__$p = vue.defineComponent({
189
+ name: "MEditorCodeSelect"
190
+ });
191
+ const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
192
+ ...__default__$p,
193
+ props: {
194
+ config: null,
195
+ model: null,
196
+ prop: null,
197
+ name: null,
198
+ size: null
199
+ },
200
+ emits: ["change"],
201
+ setup(__props, { emit }) {
202
+ const props = __props;
203
+ const services = vue.inject("services");
204
+ const form = vue.inject("mForm");
205
+ const selectConfig = vue.computed(() => {
206
+ const defaultConfig = {
207
+ multiple: true,
208
+ options: async () => {
209
+ const codeDsl = await services?.codeBlockService.getCodeDsl();
210
+ if (codeDsl) {
211
+ return lodashEs.map(codeDsl, (value, key) => ({
212
+ text: `${value.name}\uFF08${key}\uFF09`,
213
+ label: `${value.name}\uFF08${key}\uFF09`,
214
+ value: key
215
+ }));
216
+ }
217
+ return [];
218
+ }
219
+ };
220
+ return {
221
+ ...defaultConfig,
222
+ ...props.config.selectConfig
223
+ };
224
+ });
225
+ const fieldKey = vue.ref("");
226
+ const multiple = vue.ref(true);
227
+ const lastTagSnapshot = vue.ref([]);
228
+ vue.watchEffect(async () => {
229
+ if (!props.model[props.name])
230
+ return;
231
+ const combineNames = await Promise.all(
232
+ props.model[props.name].map(async (id) => {
233
+ const { name = "" } = await services?.codeBlockService.getCodeContentById(id) || {};
234
+ return name;
235
+ })
236
+ );
237
+ fieldKey.value = combineNames.join("-");
238
+ });
239
+ const changeHandler = async (value) => {
240
+ let codeIds = value;
241
+ if (typeof value === "string") {
242
+ multiple.value = false;
243
+ codeIds = value ? [value] : [];
244
+ }
245
+ await setCombineRelation(codeIds);
246
+ emit("change", value);
247
+ };
248
+ const setCombineRelation = async (codeIds) => {
249
+ const { id = "" } = services?.editorService.get("node") || {};
250
+ let opFlag = CodeSelectOp.CHANGE;
251
+ let diffValues = codeIds;
252
+ if (multiple.value) {
253
+ lastTagSnapshot.value = form?.initValues[props.name] || [];
254
+ opFlag = codeIds.length < lastTagSnapshot.value.length ? CodeSelectOp.DELETE : CodeSelectOp.ADD;
255
+ diffValues = lodashEs.xor(codeIds, lastTagSnapshot.value);
256
+ }
257
+ await services?.codeBlockService.setCombineRelation(id, diffValues, opFlag, props.prop);
258
+ };
259
+ const viewHandler = async () => {
260
+ if (props.model[props.name].length === 0) {
261
+ design.tMagicMessage.error("\u8BF7\u5148\u7ED1\u5B9A\u4EE3\u7801\u5757");
262
+ return;
263
+ }
264
+ await services?.codeBlockService.setCombineIds(props.model[props.name]);
265
+ await services?.codeBlockService.setMode(CodeEditorMode.LIST);
266
+ services?.codeBlockService.setCodeEditorContent(true, props.model[props.name][0]);
267
+ };
268
+ return (_ctx, _cache) => {
269
+ const _component_m_fields_select = vue.resolveComponent("m-fields-select");
270
+ return vue.openBlock(), vue.createElementBlock("div", {
271
+ class: "m-fields-code-select",
272
+ key: fieldKey.value
273
+ }, [
274
+ vue.createVNode(vue.unref(design.TMagicCard), { shadow: "never" }, {
275
+ header: vue.withCtx(() => [
276
+ vue.createVNode(_component_m_fields_select, {
277
+ config: vue.unref(selectConfig),
278
+ model: __props.model,
279
+ prop: __props.prop,
280
+ name: __props.name,
281
+ size: __props.size,
282
+ onChange: changeHandler
283
+ }, null, 8, ["config", "model", "prop", "name", "size"])
284
+ ]),
285
+ default: vue.withCtx(() => [
286
+ vue.createElementVNode("div", _hoisted_1$e, [
287
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
288
+ class: "tool-item",
289
+ effect: "dark",
290
+ content: "\u67E5\u770B\u4EE3\u7801\u5757",
291
+ placement: "top"
292
+ }, {
293
+ default: vue.withCtx(() => [
294
+ (vue.openBlock(), vue.createElementBlock("svg", {
295
+ onClick: viewHandler,
296
+ preserveAspectRatio: "xMidYMid meet",
297
+ viewBox: "0 0 24 24",
298
+ width: "15px",
299
+ height: "15px",
300
+ "data-v-65a7fb6c": ""
301
+ }, _hoisted_3$3))
302
+ ]),
303
+ _: 1
304
+ })
305
+ ])
306
+ ]),
307
+ _: 1
308
+ })
309
+ ]);
310
+ };
311
+ }
312
+ });
313
+
314
+ const _hoisted_1$d = /* @__PURE__ */ vue.createTextVNode("\u53D6\u6D88");
315
+ const __default__$o = vue.defineComponent({
316
+ name: "MEditorUISelect"
317
+ });
318
+ const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
319
+ ...__default__$o,
128
320
  props: {
129
321
  config: null,
130
322
  model: null,
@@ -174,21 +366,19 @@
174
366
  }
175
367
  };
176
368
  return (_ctx, _cache) => {
177
- const _component_el_button = vue.resolveComponent("el-button");
178
- const _component_el_tooltip = vue.resolveComponent("el-tooltip");
179
369
  return uiSelectMode.value ? (vue.openBlock(), vue.createElementBlock("div", {
180
370
  key: 0,
181
371
  class: "m-fields-ui-select",
182
372
  onClick: cancelHandler
183
373
  }, [
184
- vue.createVNode(_component_el_button, {
374
+ vue.createVNode(vue.unref(design.TMagicButton), {
185
375
  type: "danger",
186
376
  icon: vue.unref(iconsVue.Delete),
187
377
  text: "",
188
378
  style: { "padding": "0" }
189
379
  }, {
190
380
  default: vue.withCtx(() => [
191
- _hoisted_1$b
381
+ _hoisted_1$d
192
382
  ]),
193
383
  _: 1
194
384
  }, 8, ["icon"])
@@ -198,12 +388,12 @@
198
388
  onClick: startSelect,
199
389
  style: { "display": "flex" }
200
390
  }, [
201
- vue.unref(val) ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
391
+ vue.unref(val) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
202
392
  key: 0,
203
393
  content: "\u6E05\u9664"
204
394
  }, {
205
395
  default: vue.withCtx(() => [
206
- vue.createVNode(_component_el_button, {
396
+ vue.createVNode(vue.unref(design.TMagicButton), {
207
397
  style: { "padding": "0" },
208
398
  type: "danger",
209
399
  icon: vue.unref(iconsVue.Close),
@@ -213,11 +403,11 @@
213
403
  ]),
214
404
  _: 1
215
405
  })) : vue.createCommentVNode("", true),
216
- vue.createVNode(_component_el_tooltip, {
406
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
217
407
  content: vue.unref(val) ? vue.unref(toName) + "_" + vue.unref(val) : "\u70B9\u51FB\u6B64\u5904\u9009\u62E9"
218
408
  }, {
219
409
  default: vue.withCtx(() => [
220
- vue.createVNode(_component_el_button, {
410
+ vue.createVNode(vue.unref(design.TMagicButton), {
221
411
  text: "",
222
412
  style: { "padding": "0", "margin": "0" }
223
413
  }, {
@@ -236,45 +426,39 @@
236
426
 
237
427
  const UISelect_vue_vue_type_style_index_0_lang = '';
238
428
 
239
- const toString = (v, language) => {
240
- let value = "";
241
- if (typeof v !== "string") {
242
- value = serialize__default.default(v, {
243
- space: 2,
244
- unsafe: true
245
- }).replace(/"(\w+)":\s/g, "$1: ");
246
- } else {
247
- value = v;
248
- }
249
- if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
250
- value = `(${value})`;
251
- }
252
- return value;
253
- };
254
- const _sfc_main$m = vue.defineComponent({
255
- name: "magic-code-editor",
429
+ const __default__$n = vue.defineComponent({
430
+ name: "MEditorCodeEditor"
431
+ });
432
+ const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
433
+ ...__default__$n,
256
434
  props: {
257
- initValues: {
258
- type: [String, Object]
259
- },
260
- modifiedValues: {
261
- type: [String, Object]
262
- },
263
- type: {
264
- type: String,
265
- default: () => ""
266
- },
267
- language: {
268
- type: String,
269
- default: () => "javascript"
270
- },
271
- options: {
272
- type: Object,
273
- default: () => ({})
274
- }
435
+ initValues: null,
436
+ modifiedValues: null,
437
+ type: { default: "" },
438
+ language: { default: "javascript" },
439
+ options: { default: () => ({
440
+ tabSize: 2
441
+ }) },
442
+ autoSave: { type: Boolean, default: true }
275
443
  },
276
444
  emits: ["initd", "save"],
277
- setup(props, { emit }) {
445
+ setup(__props, { expose, emit }) {
446
+ const props = __props;
447
+ const toString = (v, language) => {
448
+ let value = "";
449
+ if (typeof v !== "string") {
450
+ value = serialize__default.default(v, {
451
+ space: 2,
452
+ unsafe: true
453
+ }).replace(/"(\w+)":\s/g, "$1: ");
454
+ } else {
455
+ value = v;
456
+ }
457
+ if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
458
+ value = `(${value})`;
459
+ }
460
+ return value;
461
+ };
278
462
  let vsEditor = null;
279
463
  let vsDiffEditor = null;
280
464
  const values = vue.ref("");
@@ -323,7 +507,7 @@
323
507
  emit("save", getEditorValue());
324
508
  }
325
509
  });
326
- if (props.type !== "diff") {
510
+ if (props.type !== "diff" && props.autoSave) {
327
511
  vsEditor?.onDidBlurEditorWidget(() => {
328
512
  emit("save", getEditorValue());
329
513
  });
@@ -349,10 +533,7 @@
349
533
  vue.onUnmounted(() => {
350
534
  resizeObserver.disconnect();
351
535
  });
352
- return {
353
- values,
354
- loading,
355
- codeEditor,
536
+ expose({
356
537
  getEditor() {
357
538
  return vsEditor || vsDiffEditor;
358
539
  },
@@ -361,105 +542,258 @@
361
542
  vsEditor?.focus();
362
543
  vsDiffEditor?.focus();
363
544
  }
545
+ });
546
+ return (_ctx, _cache) => {
547
+ return vue.openBlock(), vue.createElementBlock("div", {
548
+ ref_key: "codeEditor",
549
+ ref: codeEditor,
550
+ class: "magic-code-editor"
551
+ }, null, 512);
364
552
  };
365
553
  }
366
554
  });
367
555
 
368
- const _export_sfc = (sfc, props) => {
369
- const target = sfc.__vccOpts || sfc;
370
- for (const [key, val] of props) {
371
- target[key] = val;
372
- }
373
- return target;
374
- };
375
-
376
- const _hoisted_1$a = {
377
- ref: "codeEditor",
378
- class: "magic-code-editor"
379
- };
380
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
381
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, null, 512);
382
- }
383
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["render", _sfc_render$6]]);
384
-
385
556
  let $TMAGIC_EDITOR = {};
386
557
  const setConfig = (option) => {
387
558
  $TMAGIC_EDITOR = option;
388
559
  };
389
560
  const getConfig = (key) => $TMAGIC_EDITOR[key];
390
561
 
391
- class UndoRedo {
392
- elementList;
393
- listCursor;
394
- listMaxSize;
395
- constructor(listMaxSize = 200) {
396
- const minListMaxSize = 2;
397
- this.elementList = [];
398
- this.listCursor = 0;
399
- this.listMaxSize = listMaxSize > minListMaxSize ? listMaxSize : minListMaxSize;
400
- }
401
- pushElement(element) {
402
- this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, lodashEs.cloneDeep(element));
403
- this.listCursor += 1;
404
- if (this.elementList.length > this.listMaxSize) {
405
- this.elementList.shift();
406
- this.listCursor -= 1;
407
- }
408
- }
409
- canUndo() {
410
- return this.listCursor > 1;
411
- }
412
- undo() {
413
- if (!this.canUndo()) {
414
- return null;
415
- }
416
- this.listCursor -= 1;
417
- return this.getCurrentElement();
418
- }
419
- canRedo() {
420
- return this.elementList.length > this.listCursor;
421
- }
422
- redo() {
423
- if (!this.canRedo()) {
424
- return null;
425
- }
426
- this.listCursor += 1;
427
- return this.getCurrentElement();
428
- }
429
- getCurrentElement() {
430
- if (this.listCursor < 1) {
431
- return null;
432
- }
433
- return lodashEs.cloneDeep(this.elementList[this.listCursor - 1]);
562
+ const __default__$m = vue.defineComponent({
563
+ name: "MEditorResizer"
564
+ });
565
+ const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
566
+ ...__default__$m,
567
+ emits: ["change"],
568
+ setup(__props, { emit }) {
569
+ const target = vue.ref();
570
+ let getso;
571
+ vue.onMounted(() => {
572
+ if (!target.value)
573
+ return;
574
+ getso = new Gesto__default.default(target.value, {
575
+ container: window,
576
+ pinchOutside: true
577
+ }).on("drag", (e) => {
578
+ if (!target.value)
579
+ return;
580
+ emit("change", e.deltaX);
581
+ });
582
+ });
583
+ vue.onUnmounted(() => {
584
+ getso?.unset();
585
+ });
586
+ return (_ctx, _cache) => {
587
+ return vue.openBlock(), vue.createElementBlock("span", {
588
+ ref_key: "target",
589
+ ref: target,
590
+ class: "m-editor-resizer"
591
+ }, [
592
+ vue.renderSlot(_ctx.$slots, "default")
593
+ ], 512);
594
+ };
434
595
  }
435
- }
596
+ });
436
597
 
437
- const compose = (middleware) => {
438
- if (!Array.isArray(middleware))
439
- throw new TypeError("Middleware \u5FC5\u987B\u662F\u4E00\u4E2A\u6570\u7EC4!");
440
- for (const fn of middleware) {
441
- if (typeof fn !== "function")
442
- throw new TypeError("Middleware \u5FC5\u987B\u7531\u51FD\u6570\u7EC4\u6210!");
443
- }
444
- return (args, next) => {
445
- let index = -1;
446
- return dispatch(0);
447
- function dispatch(i) {
448
- if (i <= index)
449
- return Promise.reject(new Error("next() \u88AB\u591A\u6B21\u8C03\u7528"));
450
- index = i;
451
- let fn = middleware[i];
452
- if (i === middleware.length && next)
453
- fn = next;
454
- if (!fn)
455
- return Promise.resolve();
456
- try {
457
- return Promise.resolve(fn(...args, dispatch.bind(null, i + 1)));
458
- } catch (err) {
459
- return Promise.reject(err);
598
+ const __default__$l = vue.defineComponent({
599
+ name: "MEditorLayout"
600
+ });
601
+ const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
602
+ ...__default__$l,
603
+ props: {
604
+ left: null,
605
+ right: null,
606
+ minLeft: { default: 1 },
607
+ minRight: { default: 1 },
608
+ leftClass: null,
609
+ rightClass: null,
610
+ centerClass: null
611
+ },
612
+ emits: ["update:left", "change", "update:right"],
613
+ setup(__props, { emit }) {
614
+ const props = __props;
615
+ const el = vue.ref();
616
+ let clientWidth = 0;
617
+ const resizerObserver = new ResizeObserver((entries) => {
618
+ for (const { contentRect } of entries) {
619
+ clientWidth = contentRect.width;
620
+ center.value = clientWidth - (props.left || 0) - (props.right || 0);
621
+ emit("change", {
622
+ left: props.left,
623
+ center: center.value,
624
+ right: props.right
625
+ });
460
626
  }
461
- }
462
- };
627
+ });
628
+ vue.onMounted(() => {
629
+ if (el.value) {
630
+ resizerObserver.observe(el.value);
631
+ }
632
+ });
633
+ vue.onUnmounted(() => {
634
+ resizerObserver.disconnect();
635
+ });
636
+ const center = vue.ref(0);
637
+ const changeLeft = (deltaX) => {
638
+ if (typeof props.left === "undefined")
639
+ return;
640
+ let left = Math.max(props.left + deltaX, props.minLeft) || 0;
641
+ emit("update:left", left);
642
+ if (clientWidth - left - (props.right || 0) <= 0) {
643
+ left = props.left;
644
+ }
645
+ center.value = clientWidth - left - (props.right || 0);
646
+ emit("change", {
647
+ left,
648
+ center: center.value,
649
+ right: props.right
650
+ });
651
+ };
652
+ const changeRight = (deltaX) => {
653
+ if (typeof props.right === "undefined")
654
+ return;
655
+ let right = Math.max(props.right - deltaX, props.minRight) || 0;
656
+ emit("update:right", right);
657
+ if (clientWidth - (props.left || 0) - right <= 0) {
658
+ right = props.right;
659
+ }
660
+ center.value = clientWidth - (props.left || 0) - right;
661
+ emit("change", {
662
+ left: props.left,
663
+ center: center.value,
664
+ right
665
+ });
666
+ };
667
+ return (_ctx, _cache) => {
668
+ return vue.openBlock(), vue.createElementBlock("div", {
669
+ ref_key: "el",
670
+ ref: el,
671
+ class: "m-editor-layout"
672
+ }, [
673
+ typeof props.left !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
674
+ vue.createElementVNode("div", {
675
+ class: vue.normalizeClass(["m-editor-layout-left", __props.leftClass]),
676
+ style: vue.normalizeStyle(`width: ${__props.left}px`)
677
+ }, [
678
+ vue.renderSlot(_ctx.$slots, "left")
679
+ ], 6),
680
+ vue.createVNode(_sfc_main$n, { onChange: changeLeft })
681
+ ], 64)) : vue.createCommentVNode("", true),
682
+ vue.createElementVNode("div", {
683
+ class: vue.normalizeClass(["m-editor-layout-center", __props.centerClass]),
684
+ style: vue.normalizeStyle(`width: ${center.value}px`)
685
+ }, [
686
+ vue.renderSlot(_ctx.$slots, "center")
687
+ ], 6),
688
+ typeof props.right !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
689
+ vue.createVNode(_sfc_main$n, { onChange: changeRight }),
690
+ vue.createElementVNode("div", {
691
+ class: vue.normalizeClass(["m-editor-layout-right", __props.rightClass]),
692
+ style: vue.normalizeStyle(`width: ${__props.right}px`)
693
+ }, [
694
+ vue.renderSlot(_ctx.$slots, "right")
695
+ ], 6)
696
+ ], 64)) : vue.createCommentVNode("", true)
697
+ ], 512);
698
+ };
699
+ }
700
+ });
701
+
702
+ const _hoisted_1$c = ["src"];
703
+ const __default__$k = vue.defineComponent({
704
+ name: "MEditorIcon"
705
+ });
706
+ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
707
+ ...__default__$k,
708
+ props: {
709
+ icon: null
710
+ },
711
+ setup(__props) {
712
+ return (_ctx, _cache) => {
713
+ return !__props.icon ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
714
+ key: 0,
715
+ class: "magic-editor-icon"
716
+ }, {
717
+ default: vue.withCtx(() => [
718
+ vue.createVNode(vue.unref(iconsVue.Edit))
719
+ ]),
720
+ _: 1
721
+ })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
722
+ key: 1,
723
+ class: "magic-editor-icon"
724
+ }, {
725
+ default: vue.withCtx(() => [
726
+ vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$c)
727
+ ]),
728
+ _: 1
729
+ })) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
730
+ key: 2,
731
+ class: vue.normalizeClass(["magic-editor-icon", __props.icon])
732
+ }, null, 2)) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicIcon), {
733
+ key: 3,
734
+ class: "magic-editor-icon"
735
+ }, {
736
+ default: vue.withCtx(() => [
737
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(__props.icon))))
738
+ ]),
739
+ _: 1
740
+ }));
741
+ };
742
+ }
743
+ });
744
+
745
+ const log = (...args) => {
746
+ if (process.env.NODE_ENV === "development") {
747
+ console.log("magic editor: ", ...args);
748
+ }
749
+ };
750
+ const info = (...args) => {
751
+ if (process.env.NODE_ENV === "development") {
752
+ console.info("magic editor: ", ...args);
753
+ }
754
+ };
755
+ const warn = (...args) => {
756
+ if (process.env.NODE_ENV === "development") {
757
+ console.warn("magic editor: ", ...args);
758
+ }
759
+ };
760
+ const debug = (...args) => {
761
+ if (process.env.NODE_ENV === "development") {
762
+ console.debug("magic editor: ", ...args);
763
+ }
764
+ };
765
+ const error = (...args) => {
766
+ if (process.env.NODE_ENV === "development") {
767
+ console.error("magic editor: ", ...args);
768
+ }
769
+ };
770
+
771
+ const compose = (middleware) => {
772
+ if (!Array.isArray(middleware))
773
+ throw new TypeError("Middleware \u5FC5\u987B\u662F\u4E00\u4E2A\u6570\u7EC4!");
774
+ for (const fn of middleware) {
775
+ if (typeof fn !== "function")
776
+ throw new TypeError("Middleware \u5FC5\u987B\u7531\u51FD\u6570\u7EC4\u6210!");
777
+ }
778
+ return (args, next) => {
779
+ let index = -1;
780
+ return dispatch(0);
781
+ function dispatch(i) {
782
+ if (i <= index)
783
+ return Promise.reject(new Error("next() \u88AB\u591A\u6B21\u8C03\u7528"));
784
+ index = i;
785
+ let fn = middleware[i];
786
+ if (i === middleware.length && next)
787
+ fn = next;
788
+ if (!fn)
789
+ return Promise.resolve();
790
+ try {
791
+ return Promise.resolve(fn(...args, dispatch.bind(null, i + 1)));
792
+ } catch (err) {
793
+ return Promise.reject(err);
794
+ }
795
+ }
796
+ };
463
797
  };
464
798
 
465
799
  const methodName = (prefix, name) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
@@ -548,6 +882,269 @@
548
882
  }
549
883
  }
550
884
 
885
+ class CodeBlock extends BaseService {
886
+ state = vue.reactive({
887
+ isShowCodeEditor: false,
888
+ codeDsl: null,
889
+ id: "",
890
+ editable: true,
891
+ mode: CodeEditorMode.EDITOR,
892
+ combineIds: [],
893
+ undeletableList: []
894
+ });
895
+ constructor() {
896
+ super([
897
+ "setCodeDsl",
898
+ "getCodeDsl",
899
+ "getCodeContentById",
900
+ "getCodeDslByIds",
901
+ "getCurrentDsl",
902
+ "setCodeDslById",
903
+ "setCodeEditorShowStatus",
904
+ "setEditStatus",
905
+ "setMode",
906
+ "setCombineIds",
907
+ "setUndeleteableList",
908
+ "deleteCodeDslByIds"
909
+ ]);
910
+ }
911
+ async setCodeDsl(codeDsl) {
912
+ this.state.codeDsl = codeDsl;
913
+ await editorService.setCodeDsl(this.state.codeDsl);
914
+ info("[code-block]:code-dsl-change", this.state.codeDsl);
915
+ this.emit("code-dsl-change", this.state.codeDsl);
916
+ }
917
+ async getCodeDsl(forceRefresh = false) {
918
+ if (!this.state.codeDsl || forceRefresh) {
919
+ this.state.codeDsl = await editorService.getCodeDsl();
920
+ }
921
+ return this.state.codeDsl;
922
+ }
923
+ async getCodeContentById(id) {
924
+ if (!id)
925
+ return null;
926
+ const totalCodeDsl = await this.getCodeDsl();
927
+ if (!totalCodeDsl)
928
+ return null;
929
+ return totalCodeDsl[id] ?? null;
930
+ }
931
+ async setCodeDslById(id, codeConfig) {
932
+ let codeDsl = await this.getCodeDsl();
933
+ if (!codeDsl) {
934
+ codeDsl = {
935
+ [id]: codeConfig
936
+ };
937
+ } else {
938
+ const existContent = codeDsl[id] || {};
939
+ codeDsl = {
940
+ ...codeDsl,
941
+ [id]: {
942
+ ...existContent,
943
+ ...codeConfig
944
+ }
945
+ };
946
+ }
947
+ await this.setCodeDsl(codeDsl);
948
+ }
949
+ async getCodeDslByIds(ids) {
950
+ const codeDsl = await this.getCodeDsl();
951
+ return lodashEs.pick(codeDsl, ids);
952
+ }
953
+ async setCodeEditorShowStatus(status) {
954
+ this.state.isShowCodeEditor = status;
955
+ }
956
+ getCodeEditorShowStatus() {
957
+ return this.state.isShowCodeEditor;
958
+ }
959
+ setCodeEditorContent(status, id) {
960
+ if (!id)
961
+ return;
962
+ this.setId(id);
963
+ this.state.isShowCodeEditor = status;
964
+ }
965
+ async getCurrentDsl() {
966
+ return await this.getCodeContentById(this.state.id);
967
+ }
968
+ getEditStatus() {
969
+ return this.state.editable;
970
+ }
971
+ async setEditStatus(status) {
972
+ this.state.editable = status;
973
+ }
974
+ setId(id) {
975
+ if (!id)
976
+ return;
977
+ this.state.id = id;
978
+ }
979
+ getId() {
980
+ return this.state.id;
981
+ }
982
+ getMode() {
983
+ return this.state.mode;
984
+ }
985
+ async setMode(mode) {
986
+ this.state.mode = mode;
987
+ }
988
+ async setCombineIds(ids) {
989
+ this.state.combineIds = ids;
990
+ }
991
+ getCombineIds() {
992
+ return this.state.combineIds;
993
+ }
994
+ async setCombineRelation(compId, diffCodeIds, opFlag, hook) {
995
+ const codeDsl = lodashEs.cloneDeep(await this.getCodeDsl());
996
+ if (!codeDsl)
997
+ return;
998
+ if (opFlag === CodeSelectOp.DELETE) {
999
+ try {
1000
+ diffCodeIds.forEach((codeId) => {
1001
+ const compsContent = codeDsl[codeId].comps;
1002
+ const index = compsContent?.[compId].findIndex((item) => item === hook);
1003
+ if (typeof index !== "undefined" && index !== -1) {
1004
+ compsContent?.[compId].splice(index, 1);
1005
+ }
1006
+ });
1007
+ } catch (e) {
1008
+ error(e);
1009
+ throw new Error("\u89E3\u7ED1\u4EE3\u7801\u5757\u5931\u8D25");
1010
+ }
1011
+ } else if (opFlag === CodeSelectOp.ADD) {
1012
+ try {
1013
+ diffCodeIds.forEach((codeId) => {
1014
+ const compsContent = codeDsl[codeId].comps;
1015
+ const existHooks = compsContent?.[compId];
1016
+ if (lodashEs.isEmpty(existHooks)) {
1017
+ codeDsl[codeId].comps = {
1018
+ ...codeDsl[codeId].comps || {},
1019
+ [compId]: [hook]
1020
+ };
1021
+ } else {
1022
+ existHooks?.push(hook);
1023
+ }
1024
+ });
1025
+ } catch (e) {
1026
+ error(e);
1027
+ throw new Error("\u7ED1\u5B9A\u4EE3\u7801\u5757\u5931\u8D25");
1028
+ }
1029
+ } else if (opFlag === CodeSelectOp.CHANGE) {
1030
+ lodashEs.forIn(codeDsl, (codeBlockContent, codeId) => {
1031
+ if (codeId === diffCodeIds[0]) {
1032
+ codeBlockContent.comps = {
1033
+ ...codeBlockContent?.comps || {},
1034
+ [compId]: [hook]
1035
+ };
1036
+ } else if (lodashEs.isEmpty(diffCodeIds) || codeId !== diffCodeIds[0]) {
1037
+ const compHooks = codeBlockContent?.comps?.[compId];
1038
+ if (!compHooks)
1039
+ return true;
1040
+ const index = compHooks.findIndex((hookName) => hookName === hook);
1041
+ if (index !== -1) {
1042
+ compHooks.splice(index, 1);
1043
+ return false;
1044
+ }
1045
+ }
1046
+ });
1047
+ }
1048
+ this.setCodeDsl(codeDsl);
1049
+ }
1050
+ getUndeletableList() {
1051
+ return this.state.undeletableList;
1052
+ }
1053
+ async setUndeleteableList(codeIds) {
1054
+ this.state.undeletableList = codeIds;
1055
+ }
1056
+ async deleteCodeDslByIds(codeIds) {
1057
+ const currentDsl = await this.getCodeDsl();
1058
+ const newDsl = lodashEs.omit(currentDsl, codeIds);
1059
+ await this.setCodeDsl(newDsl);
1060
+ return newDsl;
1061
+ }
1062
+ async getUniqueId() {
1063
+ const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
1064
+ const dsl = await this.getCodeDsl();
1065
+ const existedIds = lodashEs.keys(dsl);
1066
+ if (!existedIds.includes(newId))
1067
+ return newId;
1068
+ return await this.getUniqueId();
1069
+ }
1070
+ async deleteCompsInRelation(node) {
1071
+ const codeDsl = lodashEs.cloneDeep(await this.getCodeDsl());
1072
+ if (!codeDsl)
1073
+ return;
1074
+ this.recurseNodes(node, codeDsl);
1075
+ this.setCodeDsl(codeDsl);
1076
+ }
1077
+ destroy() {
1078
+ this.state.isShowCodeEditor = false;
1079
+ this.state.codeDsl = null;
1080
+ this.state.id = "";
1081
+ this.state.editable = true;
1082
+ this.state.mode = CodeEditorMode.EDITOR;
1083
+ this.state.combineIds = [];
1084
+ this.state.undeletableList = [];
1085
+ }
1086
+ recurseNodes(node, codeDsl) {
1087
+ if (!node.id)
1088
+ return;
1089
+ lodashEs.forIn(codeDsl, (codeBlockContent) => {
1090
+ const compsContent = codeBlockContent.comps || {};
1091
+ codeBlockContent.comps = lodashEs.omit(compsContent, node.id);
1092
+ });
1093
+ if (!lodashEs.isEmpty(node.items)) {
1094
+ node.items.forEach((item) => {
1095
+ this.recurseNodes(item, codeDsl);
1096
+ });
1097
+ }
1098
+ }
1099
+ }
1100
+ const codeBlockService = new CodeBlock();
1101
+
1102
+ class UndoRedo {
1103
+ elementList;
1104
+ listCursor;
1105
+ listMaxSize;
1106
+ constructor(listMaxSize = 200) {
1107
+ const minListMaxSize = 2;
1108
+ this.elementList = [];
1109
+ this.listCursor = 0;
1110
+ this.listMaxSize = listMaxSize > minListMaxSize ? listMaxSize : minListMaxSize;
1111
+ }
1112
+ pushElement(element) {
1113
+ this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, lodashEs.cloneDeep(element));
1114
+ this.listCursor += 1;
1115
+ if (this.elementList.length > this.listMaxSize) {
1116
+ this.elementList.shift();
1117
+ this.listCursor -= 1;
1118
+ }
1119
+ }
1120
+ canUndo() {
1121
+ return this.listCursor > 1;
1122
+ }
1123
+ undo() {
1124
+ if (!this.canUndo()) {
1125
+ return null;
1126
+ }
1127
+ this.listCursor -= 1;
1128
+ return this.getCurrentElement();
1129
+ }
1130
+ canRedo() {
1131
+ return this.elementList.length > this.listCursor;
1132
+ }
1133
+ redo() {
1134
+ if (!this.canRedo()) {
1135
+ return null;
1136
+ }
1137
+ this.listCursor += 1;
1138
+ return this.getCurrentElement();
1139
+ }
1140
+ getCurrentElement() {
1141
+ if (this.listCursor < 1) {
1142
+ return null;
1143
+ }
1144
+ return lodashEs.cloneDeep(this.elementList[this.listCursor - 1]);
1145
+ }
1146
+ }
1147
+
551
1148
  class History extends BaseService {
552
1149
  state = vue.reactive({
553
1150
  pageSteps: {},
@@ -713,31 +1310,6 @@
713
1310
  }
714
1311
  const storageService = new WebStorage();
715
1312
 
716
- var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
717
- ColumnLayout2["LEFT"] = "left";
718
- ColumnLayout2["CENTER"] = "center";
719
- ColumnLayout2["RIGHT"] = "right";
720
- return ColumnLayout2;
721
- })(ColumnLayout || {});
722
- var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
723
- LayerOffset2["TOP"] = "top";
724
- LayerOffset2["BOTTOM"] = "bottom";
725
- return LayerOffset2;
726
- })(LayerOffset || {});
727
- var Layout = /* @__PURE__ */ ((Layout2) => {
728
- Layout2["FLEX"] = "flex";
729
- Layout2["FIXED"] = "fixed";
730
- Layout2["RELATIVE"] = "relative";
731
- Layout2["ABSOLUTE"] = "absolute";
732
- return Layout2;
733
- })(Layout || {});
734
- var Keys = /* @__PURE__ */ ((Keys2) => {
735
- Keys2["ESCAPE"] = "Space";
736
- return Keys2;
737
- })(Keys || {});
738
- const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
739
- const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
740
-
741
1313
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
742
1314
  const getPageList = (app) => {
743
1315
  if (app.items && Array.isArray(app.items)) {
@@ -1091,14 +1663,16 @@
1091
1663
  "copy",
1092
1664
  "paste",
1093
1665
  "doPaste",
1094
- "duAlignCenter",
1666
+ "doAlignCenter",
1095
1667
  "alignCenter",
1096
1668
  "moveLayer",
1097
1669
  "moveToContainer",
1098
1670
  "move",
1099
1671
  "undo",
1100
1672
  "redo",
1101
- "highlight"
1673
+ "highlight",
1674
+ "getCodeDsl",
1675
+ "setCodeDsl"
1102
1676
  ],
1103
1677
  ["select", "update", "moveLayer"]
1104
1678
  );
@@ -1323,6 +1897,7 @@
1323
1897
  stage?.select(parent.id);
1324
1898
  }
1325
1899
  this.addModifiedNodeId(parent.id);
1900
+ codeBlockService.deleteCompsInRelation(node);
1326
1901
  }
1327
1902
  async remove(nodeOrNodeList) {
1328
1903
  const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
@@ -1362,10 +1937,10 @@
1362
1937
  newConfig = setLayout(newConfig, newLayout);
1363
1938
  }
1364
1939
  parentNodeItems[index] = newConfig;
1365
- const nodes = this.get("nodes");
1940
+ const nodes = this.get("nodes") || [];
1366
1941
  const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
1367
1942
  nodes.splice(targetIndex, 1, newConfig);
1368
- this.set("nodes", nodes);
1943
+ this.set("nodes", [...nodes]);
1369
1944
  this.get("stage")?.update({
1370
1945
  config: lodashEs.cloneDeep(newConfig),
1371
1946
  parentId: parent.id,
@@ -1447,7 +2022,11 @@
1447
2022
  const stage = this.get("stage");
1448
2023
  const newNodes = await Promise.all(nodes.map((node) => this.doAlignCenter(node)));
1449
2024
  const newNode = await this.update(newNodes);
1450
- await stage?.multiSelect(newNodes.map((node) => node.id));
2025
+ if (newNodes.length > 1) {
2026
+ await stage?.multiSelect(newNodes.map((node) => node.id));
2027
+ } else {
2028
+ await stage?.select(newNodes[0].id);
2029
+ }
1451
2030
  return newNode;
1452
2031
  }
1453
2032
  async moveLayer(offset) {
@@ -1548,6 +2127,17 @@
1548
2127
  resetModifiedNodeId() {
1549
2128
  this.get("modifiedNodeIds").clear();
1550
2129
  }
2130
+ async getCodeDsl() {
2131
+ const root = this.get("root");
2132
+ if (!root)
2133
+ return null;
2134
+ return root.codeBlocks || null;
2135
+ }
2136
+ async setCodeDsl(codeDsl) {
2137
+ if (!this.state.root)
2138
+ return;
2139
+ this.state.root.codeBlocks = codeDsl;
2140
+ }
1551
2141
  addModifiedNodeId(id) {
1552
2142
  if (!this.isHistoryStateChange) {
1553
2143
  this.get("modifiedNodeIds").set(id, id);
@@ -1841,56 +2431,36 @@
1841
2431
  if (!node?.type)
1842
2432
  return [];
1843
2433
  return eventsService.getMethod(node.type).map((option) => ({
1844
- text: option.label,
1845
- value: option.value
1846
- }));
1847
- }
1848
- }
1849
- ]
1850
- }
1851
- ]
1852
- },
1853
- {
1854
- title: "\u9AD8\u7EA7",
1855
- labelWidth: "80px",
1856
- items: [
1857
- {
1858
- type: "code-link",
1859
- name: "created",
1860
- text: "created",
1861
- formTitle: "created"
1862
- }
1863
- ]
1864
- }
1865
- ]
1866
- }
1867
- ];
1868
-
1869
- const log = (...args) => {
1870
- if (process.env.NODE_ENV === "development") {
1871
- console.log("magic editor: ", ...args);
1872
- }
1873
- };
1874
- const info = (...args) => {
1875
- if (process.env.NODE_ENV === "development") {
1876
- console.info("magic editor: ", ...args);
1877
- }
1878
- };
1879
- const warn = (...args) => {
1880
- if (process.env.NODE_ENV === "development") {
1881
- console.warn("magic editor: ", ...args);
1882
- }
1883
- };
1884
- const debug = (...args) => {
1885
- if (process.env.NODE_ENV === "development") {
1886
- console.debug("magic editor: ", ...args);
1887
- }
1888
- };
1889
- const error = (...args) => {
1890
- if (process.env.NODE_ENV === "development") {
1891
- console.error("magic editor: ", ...args);
2434
+ text: option.label,
2435
+ value: option.value
2436
+ }));
2437
+ }
2438
+ }
2439
+ ]
2440
+ }
2441
+ ]
2442
+ },
2443
+ {
2444
+ title: "\u9AD8\u7EA7",
2445
+ lazy: true,
2446
+ items: [
2447
+ {
2448
+ name: "created",
2449
+ text: "created",
2450
+ type: "code-select",
2451
+ labelWidth: "100px"
2452
+ },
2453
+ {
2454
+ name: "mounted",
2455
+ text: "mounted",
2456
+ type: "code-select",
2457
+ labelWidth: "100px"
2458
+ }
2459
+ ]
2460
+ }
2461
+ ]
1892
2462
  }
1893
- };
2463
+ ];
1894
2464
 
1895
2465
  const state = vue.reactive({
1896
2466
  uiSelectMode: false,
@@ -1996,6 +2566,8 @@
1996
2566
  getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY))
1997
2567
  ]);
1998
2568
  stage.on("select", (el) => {
2569
+ if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
2570
+ return;
1999
2571
  editorService.select(el.id);
2000
2572
  });
2001
2573
  stage.on("highlight", (el) => {
@@ -2016,6 +2588,11 @@
2016
2588
  stage.on("sort", (ev) => {
2017
2589
  editorService.sort(ev.src, ev.dist);
2018
2590
  });
2591
+ stage.on("select-parent", () => {
2592
+ const parent = editorService.get("parent");
2593
+ editorService.select(parent);
2594
+ editorService.get("stage").select(parent.id);
2595
+ });
2019
2596
  stage.on("changeGuides", (e) => {
2020
2597
  uiService.set("showGuides", true);
2021
2598
  if (!root.value || !page.value)
@@ -2032,181 +2609,49 @@
2032
2609
  return stage;
2033
2610
  };
2034
2611
 
2035
- const _sfc_main$l = vue.defineComponent({
2036
- components: { Plus: iconsVue.Plus },
2037
- setup() {
2038
- const services = vue.inject("services");
2039
- return {
2040
- clickHandler() {
2041
- const { editorService } = services || {};
2042
- if (!editorService)
2043
- return;
2044
- editorService.add({
2045
- type: schema.NodeType.PAGE,
2046
- name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
2047
- });
2048
- }
2049
- };
2050
- }
2612
+ const _hoisted_1$b = { class: "m-editor-empty-panel" };
2613
+ const _hoisted_2$5 = { class: "m-editor-empty-content" };
2614
+ const _hoisted_3$2 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2615
+ const __default__$j = vue.defineComponent({
2616
+ name: "MEditorAddPageBox"
2051
2617
  });
2052
-
2053
- const _hoisted_1$9 = { class: "m-editor-empty-panel" };
2054
- const _hoisted_2$3 = { class: "m-editor-empty-content" };
2055
- const _hoisted_3 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2056
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2057
- const _component_plus = vue.resolveComponent("plus");
2058
- const _component_el_icon = vue.resolveComponent("el-icon");
2059
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
2060
- vue.createElementVNode("div", _hoisted_2$3, [
2061
- vue.createElementVNode("div", {
2062
- class: "m-editor-empty-button",
2063
- onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickHandler && _ctx.clickHandler(...args))
2064
- }, [
2065
- vue.createElementVNode("div", null, [
2066
- vue.createVNode(_component_el_icon, null, {
2067
- default: vue.withCtx(() => [
2068
- vue.createVNode(_component_plus)
2069
- ]),
2070
- _: 1
2071
- })
2072
- ]),
2073
- _hoisted_3
2074
- ])
2075
- ])
2076
- ]);
2077
- }
2078
- const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$5]]);
2079
-
2080
2618
  const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
2081
- __name: "Resizer",
2082
- emits: ["change"],
2083
- setup(__props, { emit }) {
2084
- const target = vue.ref();
2085
- let getso;
2086
- vue.onMounted(() => {
2087
- if (!target.value)
2088
- return;
2089
- getso = new Gesto__default.default(target.value, {
2090
- container: window,
2091
- pinchOutside: true
2092
- }).on("drag", (e) => {
2093
- if (!target.value)
2094
- return;
2095
- emit("change", e.deltaX);
2096
- });
2097
- });
2098
- vue.onUnmounted(() => {
2099
- getso?.unset();
2100
- });
2101
- return (_ctx, _cache) => {
2102
- return vue.openBlock(), vue.createElementBlock("span", {
2103
- ref_key: "target",
2104
- ref: target,
2105
- class: "m-editor-resizer"
2106
- }, [
2107
- vue.renderSlot(_ctx.$slots, "default")
2108
- ], 512);
2109
- };
2110
- }
2111
- });
2112
-
2113
- const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
2114
- __name: "Layout",
2115
- props: {
2116
- left: null,
2117
- right: null,
2118
- minLeft: { default: 1 },
2119
- minRight: { default: 1 },
2120
- leftClass: null,
2121
- rightClass: null,
2122
- centerClass: null
2123
- },
2124
- emits: ["update:left", "change", "update:right"],
2125
- setup(__props, { emit }) {
2126
- const props = __props;
2127
- const el = vue.ref();
2128
- let clientWidth = 0;
2129
- const resizerObserver = new ResizeObserver((entries) => {
2130
- for (const { contentRect } of entries) {
2131
- clientWidth = contentRect.width;
2132
- center.value = clientWidth - (props.left || 0) - (props.right || 0);
2133
- emit("change", {
2134
- left: props.left,
2135
- center: center.value,
2136
- right: props.right
2137
- });
2138
- }
2139
- });
2140
- vue.onMounted(() => {
2141
- if (el.value) {
2142
- resizerObserver.observe(el.value);
2143
- }
2144
- });
2145
- vue.onUnmounted(() => {
2146
- resizerObserver.disconnect();
2147
- });
2148
- const center = vue.ref(0);
2149
- const changeLeft = (deltaX) => {
2150
- if (typeof props.left === "undefined")
2151
- return;
2152
- const left = Math.max(props.left + deltaX, props.minLeft) || 0;
2153
- emit("update:left", left);
2154
- center.value = clientWidth - left - (props.right || 0);
2155
- emit("change", {
2156
- left,
2157
- center: center.value,
2158
- right: props.right
2159
- });
2160
- };
2161
- const changeRight = (deltaX) => {
2162
- if (typeof props.right === "undefined")
2619
+ ...__default__$j,
2620
+ setup(__props) {
2621
+ const services = vue.inject("services");
2622
+ const clickHandler = () => {
2623
+ const { editorService } = services || {};
2624
+ if (!editorService)
2163
2625
  return;
2164
- const right = Math.max(props.right - deltaX, props.minRight) || 0;
2165
- emit("update:right", right);
2166
- center.value = clientWidth - (props.left || 0) - right;
2167
- emit("change", {
2168
- left: props.left,
2169
- center: center.value,
2170
- right
2626
+ editorService.add({
2627
+ type: schema.NodeType.PAGE,
2628
+ name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
2171
2629
  });
2172
2630
  };
2173
2631
  return (_ctx, _cache) => {
2174
- return vue.openBlock(), vue.createElementBlock("div", {
2175
- ref_key: "el",
2176
- ref: el
2177
- }, [
2178
- typeof props.left !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
2179
- vue.createElementVNode("div", {
2180
- class: vue.normalizeClass(["m-editor-layout-left", __props.leftClass]),
2181
- style: vue.normalizeStyle(`width: ${__props.left}px`)
2182
- }, [
2183
- vue.renderSlot(_ctx.$slots, "left")
2184
- ], 6),
2185
- vue.createVNode(_sfc_main$k, { onChange: changeLeft })
2186
- ], 64)) : vue.createCommentVNode("", true),
2187
- vue.createElementVNode("div", {
2188
- class: vue.normalizeClass(["m-editor-layout-center", __props.centerClass]),
2189
- style: vue.normalizeStyle(`width: ${center.value}px`)
2190
- }, [
2191
- vue.renderSlot(_ctx.$slots, "center")
2192
- ], 6),
2193
- typeof props.right !== "undefined" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
2194
- vue.createVNode(_sfc_main$k, { onChange: changeRight }),
2632
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
2633
+ vue.createElementVNode("div", _hoisted_2$5, [
2195
2634
  vue.createElementVNode("div", {
2196
- class: vue.normalizeClass(["m-editor-layout-right", __props.rightClass]),
2197
- style: vue.normalizeStyle(`width: ${__props.right}px`)
2635
+ class: "m-editor-empty-button",
2636
+ onClick: clickHandler
2198
2637
  }, [
2199
- vue.renderSlot(_ctx.$slots, "right")
2200
- ], 6)
2201
- ], 64)) : vue.createCommentVNode("", true)
2202
- ], 512);
2638
+ vue.createElementVNode("div", null, [
2639
+ vue.createVNode(_sfc_main$l, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
2640
+ ]),
2641
+ _hoisted_3$2
2642
+ ])
2643
+ ])
2644
+ ]);
2203
2645
  };
2204
2646
  }
2205
2647
  });
2206
2648
 
2207
- const _hoisted_1$8 = { class: "m-editor" };
2208
- const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
2209
- __name: "Framework",
2649
+ const _hoisted_1$a = { class: "m-editor" };
2650
+ const __default__$i = vue.defineComponent({
2651
+ name: "MEditorFramework"
2652
+ });
2653
+ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
2654
+ ...__default__$i,
2210
2655
  props: {
2211
2656
  codeOptions: { default: () => ({}) }
2212
2657
  },
@@ -2215,48 +2660,64 @@
2215
2660
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
2216
2661
  const { editorService, uiService } = vue.inject("services") || {};
2217
2662
  const root = vue.computed(() => editorService?.get("root"));
2663
+ const nodes = vue.computed(() => editorService?.get("nodes") || []);
2218
2664
  const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
2219
2665
  const showSrc = vue.computed(() => uiService?.get("showSrc"));
2666
+ const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
2667
+ const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
2668
+ const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
2669
+ const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
2220
2670
  const columnWidth = vue.ref({
2221
- left: DEFAULT_LEFT_COLUMN_WIDTH,
2671
+ left: leftColumnWidthCacheData,
2222
2672
  center: 0,
2223
- right: 0
2673
+ right: RightColumnWidthCacheData
2224
2674
  });
2225
- uiService?.set("columnWidth", columnWidth.value);
2226
- vue.watchEffect(() => {
2227
- if (pageLength.value <= 0) {
2228
- columnWidth.value.right = void 0;
2229
- columnWidth.value.center = globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH;
2230
- } else {
2231
- columnWidth.value.right = columnWidth.value.right || DEFAULT_RIGHT_COLUMN_WIDTH;
2232
- columnWidth.value.center = globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH;
2675
+ vue.watch(
2676
+ pageLength,
2677
+ (length) => {
2678
+ const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
2679
+ columnWidth.value.left = left;
2680
+ if (length <= 0) {
2681
+ columnWidth.value.right = void 0;
2682
+ columnWidth.value.center = globalThis.document.body.clientWidth - left;
2683
+ } else {
2684
+ const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
2685
+ columnWidth.value.right = right;
2686
+ columnWidth.value.center = globalThis.document.body.clientWidth - left - right;
2687
+ }
2688
+ uiService?.set("columnWidth", columnWidth);
2689
+ },
2690
+ {
2691
+ immediate: true
2233
2692
  }
2234
- });
2235
- const saveCode = (value) => {
2236
- try {
2237
- editorService?.set("root", eval(value));
2238
- } catch (e) {
2239
- console.error(e);
2693
+ );
2694
+ vue.watch(
2695
+ () => columnWidth.value.right,
2696
+ (right) => {
2697
+ if (typeof right === "undefined")
2698
+ return;
2699
+ globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${right}`);
2700
+ }
2701
+ );
2702
+ vue.watch(
2703
+ () => columnWidth.value.left,
2704
+ (left) => {
2705
+ globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
2240
2706
  }
2707
+ );
2708
+ const columnWidthChange = (columnWidth2) => {
2709
+ uiService?.set("columnWidth", columnWidth2);
2241
2710
  };
2242
- const COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorColumnWidthData";
2243
- const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
2244
- if (columnWidthCacheData) {
2711
+ const saveCode = (value) => {
2245
2712
  try {
2246
- const columnWidthCache = JSON.parse(columnWidthCacheData);
2247
- columnWidth.value = columnWidthCache;
2713
+ editorService?.set("root", eval(value));
2248
2714
  } catch (e) {
2249
2715
  console.error(e);
2250
2716
  }
2251
- }
2252
- const columnWidthChange = (columnWidth2) => {
2253
- uiService?.set("columnWidth", columnWidth2);
2254
- globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth2));
2255
2717
  };
2256
2718
  return (_ctx, _cache) => {
2257
2719
  const _component_magic_code_editor = vue.resolveComponent("magic-code-editor");
2258
- const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
2259
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2720
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
2260
2721
  vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2261
2722
  vue.unref(showSrc) ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
2262
2723
  key: 0,
@@ -2264,95 +2725,57 @@
2264
2725
  "init-values": vue.unref(root),
2265
2726
  options: __props.codeOptions,
2266
2727
  onSave: saveCode
2267
- }, null, 8, ["init-values", "options"])) : (vue.openBlock(), vue.createBlock(_sfc_main$j, {
2728
+ }, null, 8, ["init-values", "options"])) : (vue.openBlock(), vue.createBlock(_sfc_main$m, {
2268
2729
  key: 1,
2269
2730
  class: "m-editor-content",
2270
2731
  "left-class": "m-editor-framework-left",
2271
2732
  "center-class": "m-editor-framework-center",
2272
- "right-class": "m-editor-framework-right",
2273
- left: columnWidth.value.left,
2274
- "onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
2275
- right: columnWidth.value.right,
2276
- "onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
2277
- "min-left": 45,
2278
- "min-right": 1,
2279
- onChange: columnWidthChange
2280
- }, vue.createSlots({
2281
- left: vue.withCtx(() => [
2282
- vue.renderSlot(_ctx.$slots, "sidebar")
2283
- ]),
2284
- center: vue.withCtx(() => [
2285
- vue.unref(pageLength) > 0 ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
2286
- vue.createVNode(AddPageBox)
2287
- ])
2288
- ]),
2289
- _: 2
2290
- }, [
2291
- vue.unref(pageLength) > 0 ? {
2292
- name: "right",
2293
- fn: vue.withCtx(() => [
2294
- vue.createVNode(_component_el_scrollbar, null, {
2295
- default: vue.withCtx(() => [
2296
- vue.renderSlot(_ctx.$slots, "props-panel")
2297
- ]),
2298
- _: 3
2299
- })
2300
- ])
2301
- } : void 0
2302
- ]), 1032, ["left", "right"]))
2303
- ]);
2304
- };
2305
- }
2306
- });
2307
-
2308
- const _hoisted_1$7 = ["src"];
2309
- const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
2310
- __name: "Icon",
2311
- props: {
2312
- icon: null
2313
- },
2314
- setup(__props) {
2315
- return (_ctx, _cache) => {
2316
- const _component_el_icon = vue.resolveComponent("el-icon");
2317
- return !__props.icon ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
2318
- key: 0,
2319
- class: "magic-editor-icon"
2320
- }, {
2321
- default: vue.withCtx(() => [
2322
- vue.createVNode(vue.unref(iconsVue.Edit))
2323
- ]),
2324
- _: 1
2325
- })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
2326
- key: 1,
2327
- class: "magic-editor-icon"
2328
- }, {
2329
- default: vue.withCtx(() => [
2330
- vue.createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$7)
2331
- ]),
2332
- _: 1
2333
- })) : typeof __props.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2334
- key: 2,
2335
- class: vue.normalizeClass(["magic-editor-icon", __props.icon])
2336
- }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, {
2337
- key: 3,
2338
- class: "magic-editor-icon"
2339
- }, {
2340
- default: vue.withCtx(() => [
2341
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.toRaw(__props.icon))))
2342
- ]),
2343
- _: 1
2344
- }));
2733
+ "right-class": "m-editor-framework-right",
2734
+ left: columnWidth.value.left,
2735
+ "onUpdate:left": _cache[0] || (_cache[0] = ($event) => columnWidth.value.left = $event),
2736
+ right: columnWidth.value.right,
2737
+ "onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
2738
+ "min-left": 45,
2739
+ "min-right": 1,
2740
+ onChange: columnWidthChange
2741
+ }, vue.createSlots({
2742
+ left: vue.withCtx(() => [
2743
+ vue.renderSlot(_ctx.$slots, "sidebar")
2744
+ ]),
2745
+ center: vue.withCtx(() => [
2746
+ vue.unref(pageLength) > 0 ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
2747
+ vue.createVNode(_sfc_main$k)
2748
+ ])
2749
+ ]),
2750
+ _: 2
2751
+ }, [
2752
+ vue.unref(pageLength) > 0 && vue.unref(nodes).length === 1 ? {
2753
+ name: "right",
2754
+ fn: vue.withCtx(() => [
2755
+ vue.createVNode(vue.unref(design.TMagicScrollbar), null, {
2756
+ default: vue.withCtx(() => [
2757
+ vue.renderSlot(_ctx.$slots, "props-panel")
2758
+ ]),
2759
+ _: 3
2760
+ })
2761
+ ])
2762
+ } : void 0
2763
+ ]), 1032, ["left", "right"]))
2764
+ ]);
2345
2765
  };
2346
2766
  }
2347
2767
  });
2348
2768
 
2349
- const _hoisted_1$6 = {
2769
+ const _hoisted_1$9 = {
2350
2770
  key: 1,
2351
2771
  class: "menu-item-text"
2352
2772
  };
2353
- const _hoisted_2$2 = { class: "el-dropdown-link menubar-menu-button" };
2354
- const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
2355
- __name: "ToolButton",
2773
+ const _hoisted_2$4 = { class: "el-dropdown-link menubar-menu-button" };
2774
+ const __default__$h = vue.defineComponent({
2775
+ name: "MEditorToolButton"
2776
+ });
2777
+ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
2778
+ ...__default__$h,
2356
2779
  props: {
2357
2780
  data: { default: () => ({
2358
2781
  type: "text",
@@ -2417,13 +2840,6 @@
2417
2840
  }
2418
2841
  };
2419
2842
  return (_ctx, _cache) => {
2420
- const _component_el_divider = vue.resolveComponent("el-divider");
2421
- const _component_el_button = vue.resolveComponent("el-button");
2422
- const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2423
- const _component_el_icon = vue.resolveComponent("el-icon");
2424
- const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
2425
- const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
2426
- const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2427
2843
  return vue.unref(display) ? (vue.openBlock(), vue.createElementBlock("div", {
2428
2844
  key: 0,
2429
2845
  class: vue.normalizeClass(["menu-item", `${__props.data.type} ${__props.data.className || ""}`]),
@@ -2431,24 +2847,24 @@
2431
2847
  onMousedown: _cache[1] || (_cache[1] = ($event) => mousedownHandler(__props.data, $event)),
2432
2848
  onMouseup: _cache[2] || (_cache[2] = ($event) => mouseupHandler(__props.data, $event))
2433
2849
  }, [
2434
- __props.data.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2850
+ __props.data.type === "divider" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDivider), {
2435
2851
  key: 0,
2436
2852
  direction: __props.data.direction || "vertical"
2437
- }, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, vue.toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
2438
- __props.data.tooltip ? (vue.openBlock(), vue.createBlock(_component_el_tooltip, {
2853
+ }, null, 8, ["direction"])) : __props.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, vue.toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
2854
+ __props.data.tooltip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
2439
2855
  key: 0,
2440
2856
  effect: "dark",
2441
2857
  placement: "bottom-start",
2442
2858
  content: __props.data.tooltip
2443
2859
  }, {
2444
2860
  default: vue.withCtx(() => [
2445
- vue.createVNode(_component_el_button, {
2861
+ vue.createVNode(vue.unref(design.TMagicButton), {
2446
2862
  size: "small",
2447
2863
  text: "",
2448
2864
  disabled: vue.unref(disabled)
2449
2865
  }, {
2450
2866
  default: vue.withCtx(() => [
2451
- __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
2867
+ __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$l, {
2452
2868
  key: 0,
2453
2869
  icon: __props.data.icon
2454
2870
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -2458,14 +2874,14 @@
2458
2874
  }, 8, ["disabled"])
2459
2875
  ]),
2460
2876
  _: 1
2461
- }, 8, ["content"])) : (vue.openBlock(), vue.createBlock(_component_el_button, {
2877
+ }, 8, ["content"])) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
2462
2878
  key: 1,
2463
2879
  size: "small",
2464
2880
  text: "",
2465
2881
  disabled: vue.unref(disabled)
2466
2882
  }, {
2467
2883
  default: vue.withCtx(() => [
2468
- __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
2884
+ __props.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$l, {
2469
2885
  key: 0,
2470
2886
  icon: __props.data.icon
2471
2887
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -2473,17 +2889,17 @@
2473
2889
  ]),
2474
2890
  _: 1
2475
2891
  }, 8, ["disabled"]))
2476
- ], 64)) : __props.data.type === "dropdown" ? (vue.openBlock(), vue.createBlock(_component_el_dropdown, {
2892
+ ], 64)) : __props.data.type === "dropdown" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDropdown), {
2477
2893
  key: 3,
2478
2894
  trigger: "click",
2479
2895
  disabled: vue.unref(disabled),
2480
2896
  onCommand: dropdownHandler
2481
2897
  }, {
2482
2898
  dropdown: vue.withCtx(() => [
2483
- __props.data.items && __props.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_dropdown_menu, { key: 0 }, {
2899
+ __props.data.items && __props.data.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDropdownMenu), { key: 0 }, {
2484
2900
  default: vue.withCtx(() => [
2485
2901
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.data.items, (subItem, index) => {
2486
- return vue.openBlock(), vue.createBlock(_component_el_dropdown_item, {
2902
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDropdownItem), {
2487
2903
  key: index,
2488
2904
  command: { data: __props.data, subItem }
2489
2905
  }, {
@@ -2498,9 +2914,9 @@
2498
2914
  })) : vue.createCommentVNode("", true)
2499
2915
  ]),
2500
2916
  default: vue.withCtx(() => [
2501
- vue.createElementVNode("span", _hoisted_2$2, [
2917
+ vue.createElementVNode("span", _hoisted_2$4, [
2502
2918
  vue.createTextVNode(vue.toDisplayString(__props.data.text), 1),
2503
- vue.createVNode(_component_el_icon, { class: "el-icon--right" }, {
2919
+ vue.createVNode(vue.unref(design.TMagicIcon), { class: "el-icon--right" }, {
2504
2920
  default: vue.withCtx(() => [
2505
2921
  vue.createVNode(vue.unref(iconsVue.ArrowDown))
2506
2922
  ]),
@@ -2515,8 +2931,11 @@
2515
2931
  }
2516
2932
  });
2517
2933
 
2518
- const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
2519
- __name: "NavMenu",
2934
+ const __default__$g = vue.defineComponent({
2935
+ name: "MEditorNavMenu"
2936
+ });
2937
+ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
2938
+ ...__default__$g,
2520
2939
  props: {
2521
2940
  data: { default: () => ({}) },
2522
2941
  height: { default: 35 }
@@ -2671,7 +3090,7 @@
2671
3090
  style: vue.normalizeStyle(`width: ${vue.unref(columnWidth)?.[key]}px`)
2672
3091
  }, [
2673
3092
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(buttons)[key], (item, index) => {
2674
- return vue.openBlock(), vue.createBlock(_sfc_main$g, {
3093
+ return vue.openBlock(), vue.createBlock(_sfc_main$i, {
2675
3094
  data: item,
2676
3095
  key: index
2677
3096
  }, null, 8, ["data"]);
@@ -2683,9 +3102,12 @@
2683
3102
  }
2684
3103
  });
2685
3104
 
2686
- const _hoisted_1$5 = { class: "`m-editor-props-panel" };
2687
- const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
2688
- __name: "PropsPanel",
3105
+ const _hoisted_1$8 = { class: "m-editor-props-panel" };
3106
+ const __default__$f = vue.defineComponent({
3107
+ name: "MEditorPropsPanel"
3108
+ });
3109
+ const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
3110
+ ...__default__$f,
2689
3111
  emits: ["mounted"],
2690
3112
  setup(__props, { expose, emit }) {
2691
3113
  const internalInstance = vue.getCurrentInstance();
@@ -2721,19 +3143,14 @@
2721
3143
  services?.editorService.update(values2);
2722
3144
  } catch (e) {
2723
3145
  console.error(e);
2724
- elementPlus.ElMessage.closeAll();
2725
- elementPlus.ElMessage.error({
2726
- duration: 1e4,
2727
- showClose: true,
2728
- message: e.message,
2729
- dangerouslyUseHTMLString: true
2730
- });
3146
+ design.tMagicMessage.closeAll();
3147
+ design.tMagicMessage.error(e.message);
2731
3148
  }
2732
3149
  };
2733
3150
  expose({ submit });
2734
3151
  return (_ctx, _cache) => {
2735
3152
  const _component_m_form = vue.resolveComponent("m-form");
2736
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
3153
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2737
3154
  vue.renderSlot(_ctx.$slots, "props-panel-header"),
2738
3155
  vue.createVNode(_component_m_form, {
2739
3156
  ref_key: "configForm",
@@ -2750,10 +3167,503 @@
2750
3167
  }
2751
3168
  });
2752
3169
 
2753
- const _hoisted_1$4 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2754
- const _hoisted_2$1 = ["onClick", "onDragstart"];
3170
+ const _hoisted_1$7 = ["id"];
3171
+ const _hoisted_2$3 = { class: "list-item" };
3172
+ const _hoisted_3$1 = { class: "code-name" };
3173
+ const _hoisted_4$1 = { class: "code-name-wrapper" };
3174
+ const _hoisted_5$1 = /* @__PURE__ */ vue.createElementVNode("div", { class: "code-name-label" }, "\u4EE3\u7801\u5757\u540D\u79F0", -1);
3175
+ const _hoisted_6$1 = { class: "m-editor-wrapper" };
3176
+ const _hoisted_7$1 = {
3177
+ key: 1,
3178
+ class: "m-editor-content-bottom"
3179
+ };
3180
+ const _hoisted_8$1 = /* @__PURE__ */ vue.createTextVNode("\u4FDD\u5B58");
3181
+ const _hoisted_9$1 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3182
+ const _hoisted_10 = {
3183
+ key: 2,
3184
+ class: "m-editor-content-bottom"
3185
+ };
3186
+ const _hoisted_11 = /* @__PURE__ */ vue.createTextVNode("\u5173\u95ED");
3187
+ const __default__$e = vue.defineComponent({
3188
+ name: "MEditorCodeBlockEditor"
3189
+ });
3190
+ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
3191
+ ...__default__$e,
3192
+ setup(__props) {
3193
+ const services = vue.inject("services");
3194
+ const codeEditor = vue.ref();
3195
+ const left = vue.ref(200);
3196
+ const currentTitle = vue.ref("");
3197
+ const codeConfig = vue.ref(null);
3198
+ const state = vue.reactive({
3199
+ codeList: []
3200
+ });
3201
+ const isShowCodeBlockEditor = vue.computed(
3202
+ () => codeConfig.value && services?.codeBlockService.getCodeEditorShowStatus() || false
3203
+ );
3204
+ const mode = vue.computed(() => services?.codeBlockService.getMode());
3205
+ const id = vue.computed(() => services?.codeBlockService.getId() || "");
3206
+ const editable = vue.computed(() => services?.codeBlockService.getEditStatus());
3207
+ const selectedIds = vue.computed(() => services?.codeBlockService.getCombineIds() || []);
3208
+ vue.watchEffect(async () => {
3209
+ codeConfig.value = await services?.codeBlockService.getCodeContentById(id.value) || null;
3210
+ });
3211
+ vue.watchEffect(async () => {
3212
+ const codeDsl = await services?.codeBlockService.getCodeDslByIds(selectedIds.value) || null;
3213
+ if (!codeDsl)
3214
+ return;
3215
+ state.codeList = [];
3216
+ lodashEs.forIn(codeDsl, (value, key) => {
3217
+ state.codeList.push({
3218
+ id: key,
3219
+ name: value.name
3220
+ });
3221
+ });
3222
+ currentTitle.value = state.codeList[0]?.name || "";
3223
+ });
3224
+ const saveCode = async () => {
3225
+ if (!codeEditor.value || !codeConfig.value || !editable.value)
3226
+ return true;
3227
+ try {
3228
+ const codeContent = codeEditor.value.getEditor()?.getValue();
3229
+ codeConfig.value.content = eval(codeContent);
3230
+ } catch (e) {
3231
+ design.tMagicMessage.error(e.stack);
3232
+ return false;
3233
+ }
3234
+ await services?.codeBlockService.setCodeDslById(id.value, {
3235
+ name: codeConfig.value.name,
3236
+ content: codeConfig.value.content
3237
+ });
3238
+ design.tMagicMessage.success("\u4EE3\u7801\u4FDD\u5B58\u6210\u529F");
3239
+ return true;
3240
+ };
3241
+ const saveAndClose = async () => {
3242
+ const saveRes = await saveCode();
3243
+ if (saveRes) {
3244
+ await services?.codeBlockService.setCodeEditorShowStatus(false);
3245
+ }
3246
+ };
3247
+ const selectHandler = (data) => {
3248
+ services?.codeBlockService.setId(data.id);
3249
+ currentTitle.value = data.name;
3250
+ };
3251
+ return (_ctx, _cache) => {
3252
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDialog), {
3253
+ modelValue: vue.unref(isShowCodeBlockEditor),
3254
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => vue.isRef(isShowCodeBlockEditor) ? isShowCodeBlockEditor.value = $event : null),
3255
+ class: "code-editor-dialog",
3256
+ title: currentTitle.value,
3257
+ fullscreen: true,
3258
+ "before-close": saveAndClose,
3259
+ "append-to-body": true
3260
+ }, {
3261
+ default: vue.withCtx(() => [
3262
+ vue.createVNode(_sfc_main$m, {
3263
+ left: left.value,
3264
+ "onUpdate:left": _cache[1] || (_cache[1] = ($event) => left.value = $event),
3265
+ "min-left": 45,
3266
+ class: "code-editor-layout"
3267
+ }, vue.createSlots({
3268
+ center: vue.withCtx(() => [
3269
+ !vue.unref(lodashEs.isEmpty)(codeConfig.value) ? (vue.openBlock(), vue.createElementBlock("div", {
3270
+ key: 0,
3271
+ class: vue.normalizeClass([
3272
+ vue.unref(mode) === vue.unref(CodeEditorMode).LIST ? "m-editor-code-block-editor-panel-list-mode" : "m-editor-code-block-editor-panel"
3273
+ ])
3274
+ }, [
3275
+ vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: vue.unref(id) }),
3276
+ vue.createVNode(vue.unref(design.TMagicCard), { shadow: "never" }, {
3277
+ header: vue.withCtx(() => [
3278
+ vue.createElementVNode("div", _hoisted_4$1, [
3279
+ _hoisted_5$1,
3280
+ codeConfig.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInput), {
3281
+ key: 0,
3282
+ class: "code-name-input",
3283
+ modelValue: codeConfig.value.name,
3284
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => codeConfig.value.name = $event),
3285
+ disabled: !vue.unref(editable)
3286
+ }, null, 8, ["modelValue", "disabled"])) : vue.createCommentVNode("", true)
3287
+ ])
3288
+ ]),
3289
+ default: vue.withCtx(() => [
3290
+ vue.createElementVNode("div", _hoisted_6$1, [
3291
+ codeConfig.value ? (vue.openBlock(), vue.createBlock(_sfc_main$o, {
3292
+ key: 0,
3293
+ ref_key: "codeEditor",
3294
+ ref: codeEditor,
3295
+ class: "m-editor-container",
3296
+ "init-values": `${codeConfig.value.content}`,
3297
+ onSave: saveCode,
3298
+ options: {
3299
+ tabSize: 2,
3300
+ fontSize: 16,
3301
+ formatOnPaste: true,
3302
+ readOnly: !vue.unref(editable)
3303
+ }
3304
+ }, null, 8, ["init-values", "options"])) : vue.createCommentVNode("", true),
3305
+ vue.unref(editable) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7$1, [
3306
+ vue.createVNode(vue.unref(design.TMagicButton), {
3307
+ type: "primary",
3308
+ class: "button",
3309
+ onClick: saveCode
3310
+ }, {
3311
+ default: vue.withCtx(() => [
3312
+ _hoisted_8$1
3313
+ ]),
3314
+ _: 1
3315
+ }),
3316
+ vue.createVNode(vue.unref(design.TMagicButton), {
3317
+ type: "primary",
3318
+ class: "button",
3319
+ onClick: saveAndClose
3320
+ }, {
3321
+ default: vue.withCtx(() => [
3322
+ _hoisted_9$1
3323
+ ]),
3324
+ _: 1
3325
+ })
3326
+ ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_10, [
3327
+ vue.createVNode(vue.unref(design.TMagicButton), {
3328
+ type: "primary",
3329
+ class: "button",
3330
+ onClick: saveAndClose
3331
+ }, {
3332
+ default: vue.withCtx(() => [
3333
+ _hoisted_11
3334
+ ]),
3335
+ _: 1
3336
+ })
3337
+ ]))
3338
+ ])
3339
+ ]),
3340
+ _: 1
3341
+ })
3342
+ ], 2)) : vue.createCommentVNode("", true)
3343
+ ]),
3344
+ _: 2
3345
+ }, [
3346
+ vue.unref(mode) === vue.unref(CodeEditorMode).LIST ? {
3347
+ name: "left",
3348
+ fn: vue.withCtx(() => [
3349
+ !vue.unref(lodashEs.isEmpty)(state.codeList) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
3350
+ key: 0,
3351
+ class: "side-tree",
3352
+ "node-key": "id",
3353
+ "empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
3354
+ data: state.codeList,
3355
+ "highlight-current": true,
3356
+ "current-node-key": state.codeList[0].id,
3357
+ onNodeClick: selectHandler
3358
+ }, {
3359
+ default: vue.withCtx(({ data }) => [
3360
+ vue.createElementVNode("div", {
3361
+ id: data.id,
3362
+ class: "list-container"
3363
+ }, [
3364
+ vue.createElementVNode("div", _hoisted_2$3, [
3365
+ vue.createElementVNode("div", _hoisted_3$1, vue.toDisplayString(data.name) + "\uFF08" + vue.toDisplayString(data.id) + "\uFF09", 1)
3366
+ ])
3367
+ ], 8, _hoisted_1$7)
3368
+ ]),
3369
+ _: 1
3370
+ }, 8, ["data", "current-node-key"])) : vue.createCommentVNode("", true)
3371
+ ])
3372
+ } : void 0
3373
+ ]), 1032, ["left"])
3374
+ ]),
3375
+ _: 3
3376
+ }, 8, ["modelValue", "title"]);
3377
+ };
3378
+ }
3379
+ });
3380
+
3381
+ const _hoisted_1$6 = { class: "m-editor-code-block-list" };
3382
+ const _hoisted_2$2 = { class: "code-header-wrapper" };
3383
+ const _hoisted_3 = /* @__PURE__ */ vue.createTextVNode("\u65B0\u589E");
3384
+ const _hoisted_4 = ["id"];
3385
+ const _hoisted_5 = { class: "list-item" };
3386
+ const _hoisted_6 = { class: "code-name" };
3387
+ const _hoisted_7 = { class: "right-tool" };
3388
+ const _hoisted_8 = {
3389
+ key: 0,
3390
+ class: "code-comp-map-wrapper"
3391
+ };
3392
+ const _hoisted_9 = /* @__PURE__ */ vue.createElementVNode("svg", {
3393
+ class: "arrow-left",
3394
+ viewBox: "0 0 1024 1024",
3395
+ xmlns: "http://www.w3.org/2000/svg",
3396
+ "data-v-029747aa": ""
3397
+ }, [
3398
+ /* @__PURE__ */ vue.createElementVNode("path", {
3399
+ fill: "currentColor",
3400
+ d: "M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"
3401
+ })
3402
+ ], -1);
3403
+ const __default__$d = vue.defineComponent({
3404
+ name: "MEditorCodeBlockList"
3405
+ });
3406
+ const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
3407
+ ...__default__$d,
3408
+ props: {
3409
+ customError: null
3410
+ },
3411
+ setup(__props) {
3412
+ const props = __props;
3413
+ const services = vue.inject("services");
3414
+ const state = vue.reactive({
3415
+ codeList: [],
3416
+ bindComps: {}
3417
+ });
3418
+ const editable = vue.computed(() => services?.codeBlockService.getEditStatus());
3419
+ const getBindCompsByCodeId = (codeId, codeBlockContent) => {
3420
+ if (lodashEs.isEmpty(codeBlockContent) || lodashEs.isEmpty(codeBlockContent.comps)) {
3421
+ state.bindComps[codeId] = [];
3422
+ return;
3423
+ }
3424
+ const compsField = codeBlockContent.comps;
3425
+ const bindCompIds = Object.keys(compsField);
3426
+ const bindCompsFiltered = bindCompIds.filter((compId) => !lodashEs.isEmpty(compsField[compId]));
3427
+ const compsInfo = bindCompsFiltered.map((compId) => ({
3428
+ id: compId,
3429
+ name: getCompName(compId)
3430
+ }));
3431
+ state.bindComps[codeId] = compsInfo;
3432
+ };
3433
+ const initList = async () => {
3434
+ const codeDsl = await services?.codeBlockService.getCodeDsl() || null;
3435
+ if (!codeDsl)
3436
+ return;
3437
+ state.codeList = [];
3438
+ lodashEs.forIn(codeDsl, (value, codeId) => {
3439
+ getBindCompsByCodeId(codeId, value);
3440
+ state.codeList.push({
3441
+ id: codeId,
3442
+ name: value.name,
3443
+ codeBlockContent: value,
3444
+ showRelation: true
3445
+ });
3446
+ });
3447
+ };
3448
+ vue.watch(
3449
+ () => services?.codeBlockService.getCodeDsl(),
3450
+ () => {
3451
+ initList();
3452
+ },
3453
+ {
3454
+ immediate: true,
3455
+ deep: true
3456
+ }
3457
+ );
3458
+ vue.watch(
3459
+ () => services?.editorService.get("node"),
3460
+ (curNode) => {
3461
+ if (!curNode?.id)
3462
+ return;
3463
+ lodashEs.forIn(state.bindComps, (bindCompInfo) => {
3464
+ bindCompInfo.forEach((comp) => {
3465
+ if (comp.id === curNode.id) {
3466
+ comp.name = curNode.name;
3467
+ }
3468
+ });
3469
+ });
3470
+ }
3471
+ );
3472
+ const createCodeBlock = async () => {
3473
+ const { codeBlockService } = services || {};
3474
+ if (!codeBlockService) {
3475
+ design.tMagicMessage.error("\u65B0\u589E\u4EE3\u7801\u5757\u5931\u8D25");
3476
+ return;
3477
+ }
3478
+ const codeConfig = {
3479
+ name: "\u4EE3\u7801\u5757",
3480
+ content: `() => {
3481
+ // place your code here
3482
+ }`
3483
+ };
3484
+ await codeBlockService.setMode(CodeEditorMode.EDITOR);
3485
+ const id = await codeBlockService.getUniqueId();
3486
+ await codeBlockService.setCodeDslById(id, codeConfig);
3487
+ codeBlockService.setCodeEditorContent(true, id);
3488
+ };
3489
+ const editCode = async (key) => {
3490
+ await services?.codeBlockService.setMode(CodeEditorMode.EDITOR);
3491
+ services?.codeBlockService.setCodeEditorContent(true, key);
3492
+ };
3493
+ const deleteCode = (key) => {
3494
+ const existBinds = !!(state.bindComps[key]?.length > 0);
3495
+ const undeleteableList = services?.codeBlockService.getUndeletableList() || [];
3496
+ if (!existBinds && !undeleteableList.includes(key)) {
3497
+ services?.codeBlockService.deleteCodeDslByIds([key]);
3498
+ } else {
3499
+ if (typeof props.customError === "function") {
3500
+ props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
3501
+ } else {
3502
+ design.tMagicMessage.error("\u4EE3\u7801\u5757\u5220\u9664\u5931\u8D25");
3503
+ }
3504
+ }
3505
+ };
3506
+ const filterText = vue.ref("");
3507
+ const tree = vue.ref();
3508
+ const filterNode = (value, data) => {
3509
+ if (!value) {
3510
+ return true;
3511
+ }
3512
+ return `${data.name}${data.id}`.indexOf(value) !== -1;
3513
+ };
3514
+ const filterTextChangeHandler = (val) => {
3515
+ tree.value?.filter(val);
3516
+ };
3517
+ const toggleCombineRelation = (data) => {
3518
+ const { id } = data;
3519
+ const currentCode = state.codeList.find((item) => item.id === id);
3520
+ if (!currentCode)
3521
+ return;
3522
+ currentCode.showRelation = !currentCode?.showRelation;
3523
+ };
3524
+ const getCompName = (compId) => {
3525
+ const node = services?.editorService.getNodeById(compId);
3526
+ return node?.name || String(compId);
3527
+ };
3528
+ const selectComp = (compId) => {
3529
+ const stage = services?.editorService.get("stage");
3530
+ services?.editorService.select(compId);
3531
+ stage?.select(compId);
3532
+ };
3533
+ return (_ctx, _cache) => {
3534
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
3535
+ vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
3536
+ vue.createElementVNode("div", _hoisted_2$2, [
3537
+ vue.createVNode(vue.unref(design.TMagicInput), {
3538
+ class: vue.normalizeClass([vue.unref(editable) ? "code-filter-input" : "code-filter-input-no-btn"]),
3539
+ size: "small",
3540
+ placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
3541
+ clearable: "",
3542
+ modelValue: filterText.value,
3543
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
3544
+ onInput: filterTextChangeHandler
3545
+ }, null, 8, ["class", "modelValue"]),
3546
+ vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
3547
+ key: 0,
3548
+ class: "create-code-button",
3549
+ type: "primary",
3550
+ size: "small",
3551
+ onClick: createCodeBlock
3552
+ }, {
3553
+ default: vue.withCtx(() => [
3554
+ _hoisted_3
3555
+ ]),
3556
+ _: 1
3557
+ })) : vue.createCommentVNode("", true)
3558
+ ])
3559
+ ]),
3560
+ !vue.unref(lodashEs.isEmpty)(state.codeList) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
3561
+ key: 0,
3562
+ ref_key: "tree",
3563
+ ref: tree,
3564
+ "node-key": "id",
3565
+ "empty-text": "\u6682\u65E0\u4EE3\u7801\u5757",
3566
+ data: state.codeList,
3567
+ "highlight-current": true,
3568
+ "filter-node-method": filterNode,
3569
+ onNodeClick: toggleCombineRelation
3570
+ }, {
3571
+ default: vue.withCtx(({ data }) => [
3572
+ vue.createElementVNode("div", {
3573
+ id: data.id,
3574
+ class: "list-container"
3575
+ }, [
3576
+ vue.createElementVNode("div", _hoisted_5, [
3577
+ vue.createElementVNode("div", _hoisted_6, vue.toDisplayString(data.name) + "\uFF08" + vue.toDisplayString(data.id) + "\uFF09", 1),
3578
+ vue.createElementVNode("div", _hoisted_7, [
3579
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
3580
+ effect: "dark",
3581
+ content: vue.unref(editable) ? "\u7F16\u8F91" : "\u67E5\u770B",
3582
+ placement: "bottom"
3583
+ }, {
3584
+ default: vue.withCtx(() => [
3585
+ vue.createVNode(_sfc_main$l, {
3586
+ icon: vue.unref(editable) ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
3587
+ class: "edit-icon",
3588
+ onClick: vue.withModifiers(($event) => editCode(`${data.id}`), ["stop"])
3589
+ }, null, 8, ["icon", "onClick"])
3590
+ ]),
3591
+ _: 2
3592
+ }, 1032, ["content"]),
3593
+ state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3594
+ key: 0,
3595
+ effect: "dark",
3596
+ content: "\u67E5\u770B\u7ED1\u5B9A\u5173\u7CFB",
3597
+ placement: "bottom"
3598
+ }, {
3599
+ default: vue.withCtx(() => [
3600
+ vue.createVNode(_sfc_main$l, {
3601
+ icon: vue.unref(iconsVue.Link),
3602
+ class: "edit-icon",
3603
+ onClick: vue.withModifiers(($event) => toggleCombineRelation(data), ["stop"])
3604
+ }, null, 8, ["icon", "onClick"])
3605
+ ]),
3606
+ _: 2
3607
+ }, 1024)) : vue.createCommentVNode("", true),
3608
+ vue.unref(editable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
3609
+ key: 1,
3610
+ effect: "dark",
3611
+ content: "\u5220\u9664",
3612
+ placement: "bottom"
3613
+ }, {
3614
+ default: vue.withCtx(() => [
3615
+ vue.createVNode(_sfc_main$l, {
3616
+ icon: vue.unref(iconsVue.Close),
3617
+ class: "edit-icon",
3618
+ onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
3619
+ }, null, 8, ["icon", "onClick"])
3620
+ ]),
3621
+ _: 2
3622
+ }, 1024)) : vue.createCommentVNode("", true),
3623
+ vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
3624
+ id: data.id,
3625
+ data: data.codeBlockContent
3626
+ })
3627
+ ])
3628
+ ]),
3629
+ data.showRelation && state.bindComps[data.id] && state.bindComps[data.id].length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
3630
+ _hoisted_9,
3631
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(state.bindComps[data.id], (comp, index) => {
3632
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
3633
+ key: index,
3634
+ class: "code-comp",
3635
+ size: "small",
3636
+ plain: true,
3637
+ onClick: vue.withModifiers(($event) => selectComp(comp.id), ["stop"])
3638
+ }, {
3639
+ default: vue.withCtx(() => [
3640
+ vue.createTextVNode(vue.toDisplayString(comp.name), 1)
3641
+ ]),
3642
+ _: 2
3643
+ }, 1032, ["onClick"]);
3644
+ }), 128))
3645
+ ])) : vue.createCommentVNode("", true)
3646
+ ], 8, _hoisted_4)
3647
+ ]),
3648
+ _: 3
3649
+ }, 8, ["data"])) : vue.createCommentVNode("", true),
3650
+ vue.createVNode(_sfc_main$f, null, {
3651
+ "code-block-edit-panel-header": vue.withCtx(({ id }) => [
3652
+ vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
3653
+ ]),
3654
+ _: 3
3655
+ })
3656
+ ]);
3657
+ };
3658
+ }
3659
+ });
3660
+
3661
+ const _hoisted_1$5 = ["onClick", "onDragstart"];
3662
+ const __default__$c = vue.defineComponent({
3663
+ name: "MEditorComponentListPanel"
3664
+ });
2755
3665
  const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
2756
- __name: "ComponentListPanel",
3666
+ ...__default__$c,
2757
3667
  setup(__props) {
2758
3668
  const searchText = vue.ref("");
2759
3669
  const services = vue.inject("services");
@@ -2766,7 +3676,7 @@
2766
3676
  }))
2767
3677
  );
2768
3678
  const collapseValue = vue.computed(
2769
- () => Array(list.value?.length).fill(1).map((x, i) => i)
3679
+ () => Array(list.value?.length).fill(1).map((x, i) => `${i}`)
2770
3680
  );
2771
3681
  let timeout;
2772
3682
  let clientX;
@@ -2818,36 +3728,31 @@
2818
3728
  timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
2819
3729
  };
2820
3730
  return (_ctx, _cache) => {
2821
- const _component_el_input = vue.resolveComponent("el-input");
2822
- const _component_el_tooltip = vue.resolveComponent("el-tooltip");
2823
- const _component_el_collapse_item = vue.resolveComponent("el-collapse-item");
2824
- const _component_el_collapse = vue.resolveComponent("el-collapse");
2825
- const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
2826
- return vue.openBlock(), vue.createBlock(_component_el_scrollbar, null, {
3731
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), null, {
2827
3732
  default: vue.withCtx(() => [
2828
3733
  vue.renderSlot(_ctx.$slots, "component-list-panel-header"),
2829
- vue.createVNode(_component_el_collapse, {
3734
+ vue.createVNode(vue.unref(design.TMagicCollapse), {
2830
3735
  class: "ui-component-panel",
2831
3736
  "model-value": vue.unref(collapseValue)
2832
3737
  }, {
2833
3738
  default: vue.withCtx(() => [
2834
- vue.createVNode(_component_el_input, {
2835
- "prefix-icon": "el-icon-search",
3739
+ vue.createVNode(vue.unref(design.TMagicInput), {
2836
3740
  placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
2837
3741
  class: "search-input",
2838
3742
  size: "small",
2839
3743
  clearable: "",
3744
+ "prefix-icon": vue.unref(iconsVue.Search),
2840
3745
  modelValue: searchText.value,
2841
3746
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
2842
- }, null, 8, ["modelValue"]),
3747
+ }, null, 8, ["prefix-icon", "modelValue"]),
2843
3748
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(list), (group, index) => {
2844
3749
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
2845
- group.items && group.items.length ? (vue.openBlock(), vue.createBlock(_component_el_collapse_item, {
3750
+ group.items && group.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCollapseItem), {
2846
3751
  key: index,
2847
- name: index
3752
+ name: `${index}`
2848
3753
  }, {
2849
3754
  title: vue.withCtx(() => [
2850
- _hoisted_1$4,
3755
+ vue.createVNode(_sfc_main$l, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
2851
3756
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
2852
3757
  ]),
2853
3758
  default: vue.withCtx(() => [
@@ -2862,10 +3767,10 @@
2862
3767
  onDrag: dragHandler
2863
3768
  }, [
2864
3769
  vue.renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
2865
- vue.createVNode(_sfc_main$h, {
3770
+ vue.createVNode(_sfc_main$l, {
2866
3771
  icon: item.icon
2867
3772
  }, null, 8, ["icon"]),
2868
- vue.createVNode(_component_el_tooltip, {
3773
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
2869
3774
  effect: "dark",
2870
3775
  placement: "bottom",
2871
3776
  content: item.text
@@ -2876,7 +3781,7 @@
2876
3781
  _: 2
2877
3782
  }, 1032, ["content"])
2878
3783
  ])
2879
- ], 40, _hoisted_2$1);
3784
+ ], 40, _hoisted_1$5);
2880
3785
  }), 128))
2881
3786
  ]),
2882
3787
  _: 2
@@ -2893,8 +3798,11 @@
2893
3798
  }
2894
3799
  });
2895
3800
 
3801
+ const __default__$b = vue.defineComponent({
3802
+ name: "MEditorContentMenu"
3803
+ });
2896
3804
  const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
2897
- __name: "ContentMenu",
3805
+ ...__default__$b,
2898
3806
  props: {
2899
3807
  menuData: { default: () => [] },
2900
3808
  isSubMenu: { type: Boolean, default: false }
@@ -2973,7 +3881,7 @@
2973
3881
  });
2974
3882
  return (_ctx, _cache) => {
2975
3883
  const _component_content_menu = vue.resolveComponent("content-menu", true);
2976
- return __props.menuData.length && visible.value ? (vue.openBlock(), vue.createElementBlock("div", {
3884
+ return __props.menuData.length ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
2977
3885
  key: 0,
2978
3886
  class: "magic-editor-content-menu",
2979
3887
  ref_key: "menu",
@@ -2982,7 +3890,7 @@
2982
3890
  }, [
2983
3891
  vue.createElementVNode("div", null, [
2984
3892
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.menuData, (item, index) => {
2985
- return vue.openBlock(), vue.createBlock(_sfc_main$g, {
3893
+ return vue.openBlock(), vue.createBlock(_sfc_main$i, {
2986
3894
  "event-type": "mouseup",
2987
3895
  data: item,
2988
3896
  key: index,
@@ -3001,21 +3909,29 @@
3001
3909
  onHide: hide
3002
3910
  }, null, 8, ["menu-data"])
3003
3911
  ]))
3004
- ], 4)) : vue.createCommentVNode("", true);
3912
+ ], 4)), [
3913
+ [vue.vShow, visible.value]
3914
+ ]) : vue.createCommentVNode("", true);
3005
3915
  };
3006
3916
  }
3007
3917
  });
3008
3918
 
3009
- const _sfc_main$b = vue.defineComponent({
3010
- components: { ContentMenu: _sfc_main$c },
3011
- setup() {
3919
+ const __default__$a = vue.defineComponent({
3920
+ name: "MEditorLayerMenu"
3921
+ });
3922
+ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
3923
+ ...__default__$a,
3924
+ props: {
3925
+ layerContentMenu: null
3926
+ },
3927
+ setup(__props, { expose }) {
3928
+ const props = __props;
3012
3929
  const services = vue.inject("services");
3013
3930
  const menu = vue.ref();
3014
3931
  const node = vue.computed(() => services?.editorService.get("node"));
3015
3932
  const isRoot = vue.computed(() => node.value?.type === schema.NodeType.ROOT);
3016
3933
  const isPage = vue.computed(() => node.value?.type === schema.NodeType.PAGE);
3017
3934
  const componentList = vue.computed(() => services?.componentListService.getList() || []);
3018
- const layerContentMenu = vue.inject("layerContentMenu", []);
3019
3935
  const createMenuItems = (group) => group.items.map((component) => ({
3020
3936
  text: component.text,
3021
3937
  type: "button",
@@ -3057,485 +3973,577 @@
3057
3973
  []
3058
3974
  ) || [];
3059
3975
  }
3060
- return [];
3061
- });
3062
- return {
3063
- menu,
3064
- menuData: vue.computed(() => [
3065
- {
3066
- type: "button",
3067
- text: "\u65B0\u589E",
3068
- icon: vue.markRaw(iconsVue.Plus),
3069
- display: () => node.value?.items,
3070
- items: getSubMenuData.value
3071
- },
3072
- {
3073
- type: "button",
3074
- text: "\u590D\u5236",
3075
- icon: vue.markRaw(iconsVue.DocumentCopy),
3076
- display: () => !isRoot.value,
3077
- handler: () => {
3078
- node.value && services?.editorService.copy(node.value);
3079
- }
3080
- },
3081
- {
3082
- type: "button",
3083
- text: "\u5220\u9664",
3084
- icon: vue.markRaw(iconsVue.Delete),
3085
- display: () => !isRoot.value && !isPage.value,
3086
- handler: () => {
3087
- node.value && services?.editorService.remove(node.value);
3088
- }
3089
- },
3090
- ...layerContentMenu
3091
- ]),
3092
- show(e) {
3093
- menu.value?.show(e);
3976
+ return [];
3977
+ });
3978
+ const menuData = vue.computed(() => [
3979
+ {
3980
+ type: "button",
3981
+ text: "\u65B0\u589E",
3982
+ icon: vue.markRaw(iconsVue.Plus),
3983
+ display: () => node.value?.items,
3984
+ items: getSubMenuData.value
3985
+ },
3986
+ {
3987
+ type: "button",
3988
+ text: "\u590D\u5236",
3989
+ icon: vue.markRaw(iconsVue.DocumentCopy),
3990
+ display: () => !isRoot.value,
3991
+ handler: () => {
3992
+ node.value && services?.editorService.copy(node.value);
3993
+ }
3994
+ },
3995
+ {
3996
+ type: "button",
3997
+ text: "\u5220\u9664",
3998
+ icon: vue.markRaw(iconsVue.Delete),
3999
+ display: () => !isRoot.value && !isPage.value,
4000
+ handler: () => {
4001
+ node.value && services?.editorService.remove(node.value);
4002
+ }
4003
+ },
4004
+ ...props.layerContentMenu
4005
+ ]);
4006
+ const show = (e) => {
4007
+ menu.value?.show(e);
4008
+ };
4009
+ expose({
4010
+ show
4011
+ });
4012
+ return (_ctx, _cache) => {
4013
+ return vue.openBlock(), vue.createBlock(_sfc_main$c, {
4014
+ "menu-data": vue.unref(menuData),
4015
+ ref_key: "menu",
4016
+ ref: menu,
4017
+ style: { "overflow": "initial" }
4018
+ }, null, 8, ["menu-data"]);
4019
+ };
4020
+ }
4021
+ });
4022
+
4023
+ const _hoisted_1$4 = ["id", "onMouseenter"];
4024
+ const __default__$9 = vue.defineComponent({
4025
+ name: "MEditorLayerPanel"
4026
+ });
4027
+ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
4028
+ ...__default__$9,
4029
+ props: {
4030
+ layerContentMenu: null
4031
+ },
4032
+ setup(__props) {
4033
+ const throttleTime = 150;
4034
+ const services = vue.inject("services");
4035
+ const tree = vue.ref();
4036
+ const menu = vue.ref();
4037
+ const editorService = services?.editorService;
4038
+ const page = vue.computed(() => editorService?.get("page"));
4039
+ const values = vue.computed(() => page.value ? [page.value] : []);
4040
+ const selectedNodes = vue.ref([]);
4041
+ const selectedIds = vue.computed(() => selectedNodes.value.map((node) => node.id));
4042
+ const isMultiSelectStatus = vue.ref(false);
4043
+ const spliceNodeKey = vue.ref();
4044
+ const filterText = vue.ref("");
4045
+ const defaultExpandedKeys = vue.computed(() => selectedIds.value.length > 0 ? selectedIds.value : []);
4046
+ editorService?.on("remove", () => {
4047
+ setTimeout(() => {
4048
+ tree.value?.getNode(editorService.get("node").id)?.updateChildren();
4049
+ }, 0);
4050
+ });
4051
+ const select = async (data) => {
4052
+ if (!data.id) {
4053
+ throw new Error("\u6CA1\u6709id");
4054
+ }
4055
+ await editorService?.select(data);
4056
+ editorService?.get("stage")?.select(data.id);
4057
+ };
4058
+ const multiSelect = async (data) => {
4059
+ await editorService?.multiSelect(data);
4060
+ editorService?.get("stage")?.multiSelect(data);
4061
+ };
4062
+ const highlight = (data) => {
4063
+ if (!data?.id) {
4064
+ throw new Error("\u6CA1\u6709id");
4065
+ }
4066
+ editorService?.highlight(data);
4067
+ editorService?.get("stage")?.highlight(data.id);
4068
+ };
4069
+ const expandedKeys = /* @__PURE__ */ new Map();
4070
+ const allowDrop = (draggingNode, dropNode, type) => {
4071
+ const { data } = dropNode || {};
4072
+ const { data: ingData } = draggingNode;
4073
+ const { type: ingType } = ingData;
4074
+ if (ingType !== schema.NodeType.PAGE && data.type === schema.NodeType.PAGE)
4075
+ return false;
4076
+ if (ingType === schema.NodeType.PAGE && data.type !== schema.NodeType.PAGE)
4077
+ return false;
4078
+ if (!data || !data.type)
4079
+ return false;
4080
+ if (["prev", "next"].includes(type))
4081
+ return true;
4082
+ if (data.items || data.type === "container")
4083
+ return true;
4084
+ return false;
4085
+ };
4086
+ const handleDragEnd = async (e) => {
4087
+ if (!tree.value)
4088
+ return;
4089
+ const { data: node } = e;
4090
+ const parent = editorService?.getParentById(node.id, false);
4091
+ const layout = await editorService?.getLayout(parent);
4092
+ node.style.position = layout;
4093
+ if (layout === Layout.RELATIVE) {
4094
+ node.style.top = 0;
4095
+ node.style.left = 0;
4096
+ }
4097
+ const data = tree.value.getData();
4098
+ const [page2] = data;
4099
+ editorService?.update(page2);
4100
+ };
4101
+ const loadItems = (node, resolve) => {
4102
+ if (Array.isArray(node.data)) {
4103
+ return resolve(node.data);
4104
+ }
4105
+ if (Array.isArray(node.data?.items)) {
4106
+ return resolve(node.data?.items);
4107
+ }
4108
+ resolve([]);
4109
+ };
4110
+ const handleCollapse = (data) => {
4111
+ expandedKeys.delete(data.id);
4112
+ };
4113
+ const handleExpand = (data) => {
4114
+ const parent = editorService?.getParentById(data.id);
4115
+ if (!parent?.id)
4116
+ return;
4117
+ expandedKeys.set(parent.id, parent.id);
4118
+ };
4119
+ const filterNode = (value, data) => {
4120
+ if (!value) {
4121
+ return true;
4122
+ }
4123
+ let name = "";
4124
+ if (data.name) {
4125
+ name = data.name;
4126
+ } else if (data.items) {
4127
+ name = "container";
3094
4128
  }
4129
+ return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
3095
4130
  };
3096
- }
3097
- });
3098
-
3099
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
3100
- const _component_content_menu = vue.resolveComponent("content-menu");
3101
- return vue.openBlock(), vue.createBlock(_component_content_menu, {
3102
- "menu-data": _ctx.menuData,
3103
- ref: "menu",
3104
- style: { "overflow": "initial" }
3105
- }, null, 8, ["menu-data"]);
3106
- }
3107
- const LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$4]]);
3108
-
3109
- const throttleTime = 150;
3110
- const select = async (data, editorService) => {
3111
- if (!data.id) {
3112
- throw new Error("\u6CA1\u6709id");
3113
- }
3114
- await editorService?.select(data);
3115
- editorService?.get("stage")?.select(data.id);
3116
- };
3117
- const highlight = (data, editorService) => {
3118
- if (!data?.id) {
3119
- throw new Error("\u6CA1\u6709id");
3120
- }
3121
- editorService?.highlight(data);
3122
- editorService?.get("stage")?.highlight(data.id);
3123
- };
3124
- const useDrop = (tree, editorService) => ({
3125
- allowDrop: (draggingNode, dropNode, type) => {
3126
- const { data } = dropNode || {};
3127
- const { data: ingData } = draggingNode;
3128
- const { type: ingType } = ingData;
3129
- if (ingType !== schema.NodeType.PAGE && data.type === schema.NodeType.PAGE)
3130
- return false;
3131
- if (ingType === schema.NodeType.PAGE && data.type !== schema.NodeType.PAGE)
3132
- return false;
3133
- if (!data || !data.type)
3134
- return false;
3135
- if (["prev", "next"].includes(type))
3136
- return true;
3137
- if (data.items || data.type === "container")
3138
- return true;
3139
- return false;
3140
- },
3141
- async handleDragEnd(e) {
3142
- if (!tree.value)
3143
- return;
3144
- const { data: node } = e;
3145
- const parent = editorService?.getParentById(node.id, false);
3146
- const layout = await editorService?.getLayout(parent);
3147
- node.style.position = layout;
3148
- if (layout === Layout.RELATIVE) {
3149
- node.style.top = 0;
3150
- node.style.left = 0;
3151
- }
3152
- const { data } = tree.value;
3153
- const [page] = data;
3154
- editorService?.update(page);
3155
- }
3156
- });
3157
- const useStatus = (tree, editorService) => {
3158
- const node = vue.ref();
3159
- const page = vue.computed(() => editorService?.get("page"));
3160
- const expandedKeys = /* @__PURE__ */ new Map();
3161
- const expandNodes = () => {
3162
- expandedKeys.forEach((key) => {
4131
+ const filterTextChangeHandler = (val) => {
4132
+ tree.value?.filter(val);
4133
+ };
4134
+ const expandNodes = async () => {
3163
4135
  if (!tree.value)
3164
4136
  return;
3165
- tree.value.getNode(key)?.expand();
3166
- });
3167
- };
3168
- vue.watchEffect(() => {
3169
- if (!tree.value)
3170
- return;
3171
- if (!editorService)
3172
- return;
3173
- node.value = editorService.get("node");
3174
- if (!node.value)
3175
- return;
3176
- tree.value.setCurrentKey(node.value.id, true);
3177
- const parent = editorService.get("parent");
3178
- if (!parent?.id)
3179
- return;
3180
- const treeNode = tree.value.getNode(parent.id);
3181
- treeNode?.updateChildren();
3182
- setTimeout(() => {
3183
- tree.value && Object.entries(tree.value.store.nodesMap).forEach(([id, node2]) => {
3184
- if (node2.expanded && node2.data.items) {
4137
+ await vue.nextTick();
4138
+ tree.value && Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]) => {
4139
+ if (node.expanded && node.data.items) {
3185
4140
  expandedKeys.set(id, id);
3186
4141
  }
3187
4142
  });
3188
- expandNodes();
3189
- });
3190
- });
3191
- return {
3192
- values: vue.computed(() => page.value ? [page.value] : []),
3193
- loadItems: (node2, resolve) => {
3194
- if (Array.isArray(node2.data)) {
3195
- return resolve(node2.data);
4143
+ expandedKeys.forEach((key) => {
4144
+ if (!tree.value)
4145
+ return;
4146
+ tree.value.getNode(key)?.expand();
4147
+ });
4148
+ };
4149
+ vue.watch(
4150
+ () => editorService?.get("nodes"),
4151
+ (nodes) => {
4152
+ selectedNodes.value = nodes ?? [];
3196
4153
  }
3197
- if (Array.isArray(node2.data?.items)) {
3198
- return resolve(node2.data?.items);
4154
+ );
4155
+ const setTreeKeyStatus = () => {
4156
+ if (!tree.value)
4157
+ return;
4158
+ if (selectedIds.value.length === 0) {
4159
+ tree.value.setCheckedKeys([]);
4160
+ tree.value.setCurrentKey();
4161
+ } else if (selectedIds.value.length === 1 && !isMultiSelectStatus.value) {
4162
+ tree.value.setCurrentKey(selectedIds.value[0], true);
4163
+ tree.value.setCheckedKeys([]);
4164
+ } else {
4165
+ tree.value.setCheckedKeys(selectedIds.value);
4166
+ tree.value.setCurrentKey();
3199
4167
  }
3200
- resolve([]);
3201
- },
3202
- highlightNode: vue.computed(() => editorService?.get("highlightNode")),
3203
- clickNode: node,
3204
- expandedKeys: vue.computed(() => node.value ? [node.value.id] : []),
3205
- handleCollapse: (data) => {
3206
- expandedKeys.delete(data.id);
3207
- },
3208
- handleExpand: (data) => {
3209
- const parent = editorService?.getParentById(data.id);
4168
+ };
4169
+ vue.watch([selectedIds, tree], async () => {
4170
+ if (!tree.value || !editorService)
4171
+ return;
4172
+ const parent = editorService.get("parent");
3210
4173
  if (!parent?.id)
3211
4174
  return;
3212
- expandedKeys.set(parent.id, parent.id);
3213
- }
3214
- };
3215
- };
3216
- const useFilter = (tree) => ({
3217
- filterText: vue.ref(""),
3218
- filterNode: (value, data) => {
3219
- if (!value) {
3220
- return true;
3221
- }
3222
- let name = "";
3223
- if (data.name) {
3224
- name = data.name;
3225
- } else if (data.items) {
3226
- name = "container";
3227
- }
3228
- return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
3229
- },
3230
- filterTextChangeHandler(val) {
3231
- tree.value?.filter(val);
3232
- }
3233
- });
3234
- const _sfc_main$a = vue.defineComponent({
3235
- name: "magic-editor-layer-panel",
3236
- components: { LayerMenu },
3237
- setup() {
3238
- const services = vue.inject("services");
3239
- const tree = vue.ref();
3240
- const menu = vue.ref();
4175
+ const treeNode = tree.value.getNode(parent.id);
4176
+ treeNode?.updateChildren();
4177
+ await expandNodes();
4178
+ setTreeKeyStatus();
4179
+ });
4180
+ const keycon = vue.ref();
4181
+ const addSelectModeListener = () => {
4182
+ const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
4183
+ const ctrl = isMac ? "meta" : "ctrl";
4184
+ keycon.value = new KeyController__default.default();
4185
+ keycon.value.keydown(ctrl, (e) => {
4186
+ e.inputEvent.preventDefault();
4187
+ isMultiSelectStatus.value = true;
4188
+ });
4189
+ keycon.value.on("blur", () => {
4190
+ isMultiSelectStatus.value = false;
4191
+ });
4192
+ keycon.value.keyup(ctrl, (e) => {
4193
+ e.inputEvent.preventDefault();
4194
+ isMultiSelectStatus.value = false;
4195
+ });
4196
+ };
4197
+ const removeSelectModeListener = () => {
4198
+ keycon.value?.destroy();
4199
+ if (selectedIds.value.length === 1)
4200
+ isMultiSelectStatus.value = false;
4201
+ };
3241
4202
  const clicked = vue.ref(false);
3242
- const editorService = services?.editorService;
4203
+ const highlightNode = vue.computed(() => editorService?.get("highlightNode"));
3243
4204
  const highlightHandler = lodashEs.throttle((data) => {
3244
- highlight(data, editorService);
4205
+ highlight(data);
3245
4206
  }, throttleTime);
3246
4207
  const toggleClickFlag = () => {
3247
4208
  clicked.value = !clicked.value;
3248
4209
  };
3249
- const statusData = useStatus(tree, editorService);
3250
- const canHighlight = vue.computed(
3251
- () => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value
3252
- );
3253
- editorService?.on("remove", () => {
3254
- setTimeout(() => {
3255
- tree.value?.getNode(editorService.get("node").id)?.updateChildren();
3256
- }, 0);
4210
+ const canHighlight = (data) => {
4211
+ if (clicked.value)
4212
+ return false;
4213
+ return data.id === highlightNode?.value?.id && !selectedIds.value.includes(data.id) && spliceNodeKey.value !== data.id;
4214
+ };
4215
+ vue.watch(isMultiSelectStatus, () => {
4216
+ if (isMultiSelectStatus.value && selectedNodes.value.length === 1 && selectedNodes.value[0].type === schema.NodeType.PAGE) {
4217
+ selectedNodes.value = [];
4218
+ }
3257
4219
  });
3258
- return {
3259
- tree,
3260
- menu,
3261
- ...statusData,
3262
- ...useDrop(tree, editorService),
3263
- ...useFilter(tree),
3264
- highlightHandler,
3265
- toggleClickFlag,
3266
- canHighlight,
3267
- clickHandler(data) {
4220
+ const multiClickHandler = (data) => {
4221
+ if (!data?.id) {
4222
+ throw new Error("\u6CA1\u6709id");
4223
+ }
4224
+ if (data.type === schema.NodeType.PAGE) {
4225
+ tree.value?.setCheckedKeys([]);
4226
+ return;
4227
+ }
4228
+ const index = selectedNodes.value.findIndex((node) => node.id === data.id);
4229
+ if (index !== -1) {
4230
+ selectedNodes.value.splice(index, 1);
4231
+ spliceNodeKey.value = data.id;
4232
+ } else {
4233
+ selectedNodes.value = [...selectedNodes.value, data];
4234
+ }
4235
+ tree.value?.setCheckedKeys(selectedIds.value);
4236
+ multiSelect(selectedIds.value);
4237
+ };
4238
+ const clickHandler = (data) => {
4239
+ if (!isMultiSelectStatus.value) {
3268
4240
  if (services?.uiService.get("uiSelectMode")) {
3269
4241
  document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
3270
4242
  return;
3271
4243
  }
3272
4244
  tree.value?.setCurrentKey(data.id);
3273
- select(data, editorService);
3274
- },
3275
- async contextmenu(event, data) {
3276
- event.preventDefault();
3277
- await select(data, editorService);
3278
- menu.value?.show(event);
4245
+ select(data);
4246
+ } else {
4247
+ multiClickHandler(data);
3279
4248
  }
3280
4249
  };
3281
- }
3282
- });
3283
-
3284
- const _hoisted_1$3 = ["id", "onMouseenter"];
3285
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3286
- const _component_el_input = vue.resolveComponent("el-input");
3287
- const _component_el_tree = vue.resolveComponent("el-tree");
3288
- const _component_layer_menu = vue.resolveComponent("layer-menu");
3289
- const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
3290
- return vue.openBlock(), vue.createBlock(_component_el_scrollbar, { class: "magic-editor-layer-panel" }, {
3291
- default: vue.withCtx(() => [
3292
- vue.renderSlot(_ctx.$slots, "layer-panel-header"),
3293
- vue.createVNode(_component_el_input, {
3294
- class: "filterInput",
3295
- size: "small",
3296
- placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
3297
- clearable: "",
3298
- modelValue: _ctx.filterText,
3299
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.filterText = $event),
3300
- onChange: _ctx.filterTextChangeHandler
3301
- }, null, 8, ["modelValue", "onChange"]),
3302
- _ctx.values.length ? (vue.openBlock(), vue.createBlock(_component_el_tree, {
3303
- key: 0,
3304
- ref: "tree",
3305
- "node-key": "id",
3306
- "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
3307
- draggable: "",
3308
- "default-expanded-keys": _ctx.expandedKeys,
3309
- load: _ctx.loadItems,
3310
- data: _ctx.values,
3311
- "expand-on-click-node": false,
3312
- "highlight-current": true,
3313
- props: {
3314
- children: "items"
3315
- },
3316
- "filter-node-method": _ctx.filterNode,
3317
- "allow-drop": _ctx.allowDrop,
3318
- onNodeClick: _ctx.clickHandler,
3319
- onNodeContextmenu: _ctx.contextmenu,
3320
- onNodeDragEnd: _ctx.handleDragEnd,
3321
- onNodeCollapse: _ctx.handleCollapse,
3322
- onNodeExpand: _ctx.handleExpand
4250
+ const contextmenu = async (event, data) => {
4251
+ event.preventDefault();
4252
+ await select(data);
4253
+ menu.value?.show(event);
4254
+ };
4255
+ return (_ctx, _cache) => {
4256
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), {
4257
+ class: "magic-editor-layer-panel",
4258
+ onMouseenter: addSelectModeListener,
4259
+ onMouseleave: removeSelectModeListener
3323
4260
  }, {
3324
- default: vue.withCtx(({ node, data }) => [
3325
- vue.createElementVNode("div", {
3326
- id: data.id,
3327
- class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
3328
- onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
3329
- onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toggleClickFlag && _ctx.toggleClickFlag(...args)),
3330
- onMouseenter: ($event) => _ctx.highlightHandler(data)
3331
- }, [
3332
- vue.renderSlot(_ctx.$slots, "layer-node-content", {
3333
- node,
3334
- data
3335
- }, () => [
3336
- vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
3337
- ])
3338
- ], 42, _hoisted_1$3)
4261
+ default: vue.withCtx(() => [
4262
+ vue.renderSlot(_ctx.$slots, "layer-panel-header"),
4263
+ vue.createVNode(vue.unref(design.TMagicInput), {
4264
+ modelValue: filterText.value,
4265
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => filterText.value = $event),
4266
+ class: "search-input",
4267
+ size: "small",
4268
+ placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
4269
+ clearable: "",
4270
+ "prefix-icon": vue.unref(iconsVue.Search),
4271
+ onChange: filterTextChangeHandler
4272
+ }, null, 8, ["modelValue", "prefix-icon"]),
4273
+ vue.unref(values).length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
4274
+ key: 0,
4275
+ class: "magic-editor-layer-tree",
4276
+ ref_key: "tree",
4277
+ ref: tree,
4278
+ "node-key": "id",
4279
+ "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684",
4280
+ draggable: "",
4281
+ "default-expanded-keys": vue.unref(defaultExpandedKeys),
4282
+ load: loadItems,
4283
+ data: vue.unref(values),
4284
+ "expand-on-click-node": false,
4285
+ "highlight-current": true,
4286
+ props: {
4287
+ children: "items"
4288
+ },
4289
+ "filter-node-method": filterNode,
4290
+ "allow-drop": allowDrop,
4291
+ "show-checkbox": isMultiSelectStatus.value || vue.unref(selectedIds).length > 1,
4292
+ onNodeClick: clickHandler,
4293
+ onNodeContextmenu: contextmenu,
4294
+ onNodeDragEnd: handleDragEnd,
4295
+ onNodeCollapse: handleCollapse,
4296
+ onNodeExpand: handleExpand,
4297
+ onCheck: multiClickHandler,
4298
+ onMousedown: toggleClickFlag,
4299
+ onMouseup: toggleClickFlag
4300
+ }, {
4301
+ default: vue.withCtx(({ node, data }) => [
4302
+ vue.createElementVNode("div", {
4303
+ id: data.id,
4304
+ class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": canHighlight(data) }]),
4305
+ onMouseenter: ($event) => vue.unref(highlightHandler)(data)
4306
+ }, [
4307
+ vue.renderSlot(_ctx.$slots, "layer-node-content", {
4308
+ node,
4309
+ data
4310
+ }, () => [
4311
+ vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
4312
+ ])
4313
+ ], 42, _hoisted_1$4)
4314
+ ]),
4315
+ _: 3
4316
+ }, 8, ["default-expanded-keys", "data", "show-checkbox"])) : vue.createCommentVNode("", true),
4317
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
4318
+ vue.createVNode(_sfc_main$b, {
4319
+ ref_key: "menu",
4320
+ ref: menu,
4321
+ "layer-content-menu": __props.layerContentMenu
4322
+ }, null, 8, ["layer-content-menu"])
4323
+ ]))
3339
4324
  ]),
3340
4325
  _: 3
3341
- }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : vue.createCommentVNode("", true),
3342
- (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
3343
- vue.createVNode(_component_layer_menu, { ref: "menu" }, null, 512)
3344
- ]))
3345
- ]),
3346
- _: 3
3347
- });
3348
- }
3349
- const LayerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$3]]);
3350
-
3351
- const _sfc_main$9 = vue.defineComponent({
3352
- components: { MIcon: _sfc_main$h },
3353
- props: {
3354
- data: {
3355
- type: [Object, String]
3356
- }
3357
- },
3358
- setup(props) {
3359
- return {
3360
- config: vue.computed(() => {
3361
- if (typeof props.data !== "string") {
3362
- return props.data;
3363
- }
3364
- switch (props.data) {
3365
- case "component-list":
3366
- return {
3367
- type: "component",
3368
- icon: iconsVue.Coin,
3369
- text: "\u7EC4\u4EF6",
3370
- component: _sfc_main$d,
3371
- slots: {}
3372
- };
3373
- case "layer":
3374
- return {
3375
- type: "component",
3376
- icon: iconsVue.Files,
3377
- text: "\u5DF2\u9009\u7EC4\u4EF6",
3378
- component: LayerPanel,
3379
- slots: {}
3380
- };
3381
- default:
3382
- return void 0;
3383
- }
3384
- })
4326
+ });
3385
4327
  };
3386
4328
  }
3387
4329
  });
3388
4330
 
3389
- const _hoisted_1$2 = {
4331
+ const _hoisted_1$3 = {
3390
4332
  key: 1,
3391
4333
  class: "magic-editor-tab-panel-title"
3392
4334
  };
3393
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3394
- const _component_m_icon = vue.resolveComponent("m-icon");
3395
- const _component_el_tab_pane = vue.resolveComponent("el-tab-pane");
3396
- return _ctx.config ? (vue.openBlock(), vue.createBlock(_component_el_tab_pane, {
3397
- key: 0,
3398
- name: _ctx.config.text
3399
- }, {
3400
- label: vue.withCtx(() => [
3401
- (vue.openBlock(), vue.createElementBlock("div", {
3402
- key: _ctx.config.text
3403
- }, [
3404
- _ctx.config.icon ? (vue.openBlock(), vue.createBlock(_component_m_icon, {
3405
- key: 0,
3406
- icon: _ctx.config.icon
3407
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
3408
- _ctx.config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, vue.toDisplayString(_ctx.config.text), 1)) : vue.createCommentVNode("", true)
3409
- ]))
3410
- ]),
3411
- default: vue.withCtx(() => [
3412
- (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.component), vue.mergeProps(_ctx.config.props || {}, vue.toHandlers(_ctx.config?.listeners || {})), vue.createSlots({ _: 2 }, [
3413
- _ctx.data === "component-list" || _ctx.config.slots?.componentListPanelHeader ? {
3414
- name: "component-list-panel-header",
3415
- fn: vue.withCtx(() => [
3416
- _ctx.data === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : _ctx.config.slots?.componentListPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.componentListPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
3417
- ])
3418
- } : void 0,
3419
- _ctx.data === "component-list" || _ctx.config.slots?.componentListItem ? {
3420
- name: "component-list-item",
3421
- fn: vue.withCtx(({ component }) => [
3422
- _ctx.data === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-item", {
3423
- key: 0,
3424
- component
3425
- }) : _ctx.config.slots?.componentListItem ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.componentListItem), {
3426
- key: 1,
3427
- component
3428
- }, null, 8, ["component"])) : vue.createCommentVNode("", true)
3429
- ])
3430
- } : void 0,
3431
- _ctx.data === "layer" || _ctx.config.slots?.layerPanelHeader ? {
3432
- name: "layer-panel-header",
3433
- fn: vue.withCtx(() => [
3434
- _ctx.data === "layer" ? vue.renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : _ctx.config.slots?.layerPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.layerPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
3435
- ])
3436
- } : void 0,
3437
- _ctx.data === "layer" || _ctx.config.slots?.layerNodeContent ? {
3438
- name: "layer-node-content",
3439
- fn: vue.withCtx(({ data: nodeData, node }) => [
3440
- _ctx.data === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-content", {
3441
- key: 0,
3442
- data: nodeData,
3443
- node
3444
- }) : _ctx.config.slots?.layerNodeContent ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.config.slots.layerNodeContent), {
3445
- key: 1,
3446
- data: nodeData,
3447
- node
3448
- }, null, 8, ["data", "node"])) : vue.createCommentVNode("", true)
3449
- ])
3450
- } : void 0
3451
- ]), 1040))
3452
- ]),
3453
- _: 3
3454
- }, 8, ["name"])) : vue.createCommentVNode("", true);
3455
- }
3456
- const TabPane = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$2]]);
3457
-
3458
- const _sfc_main$8 = vue.defineComponent({
3459
- components: { TabPane },
3460
- name: "m-sidebar",
4335
+ const __default__$8 = vue.defineComponent({
4336
+ name: "MEditorSidebar"
4337
+ });
4338
+ const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
4339
+ ...__default__$8,
3461
4340
  props: {
3462
- data: {
3463
- type: Object,
3464
- default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer"] })
3465
- }
4341
+ data: { default: () => ({ type: "tabs", status: "\u7EC4\u4EF6", items: ["component-list", "layer", "code-block"] }) },
4342
+ layerContentMenu: null
3466
4343
  },
3467
- setup(props) {
4344
+ setup(__props, { expose }) {
4345
+ const props = __props;
4346
+ const uiComponent = design.getConfig("components").tabPane;
3468
4347
  const activeTabName = vue.ref(props.data?.status);
4348
+ const getItemConfig = (data) => {
4349
+ const map = {
4350
+ "component-list": {
4351
+ $key: "component-list",
4352
+ type: "component",
4353
+ icon: iconsVue.Coin,
4354
+ text: "\u7EC4\u4EF6",
4355
+ component: _sfc_main$d,
4356
+ slots: {}
4357
+ },
4358
+ layer: {
4359
+ $key: "layer",
4360
+ type: "component",
4361
+ icon: iconsVue.Files,
4362
+ text: "\u5DF2\u9009\u7EC4\u4EF6",
4363
+ props: {
4364
+ layerContentMenu: props.layerContentMenu
4365
+ },
4366
+ component: _sfc_main$a,
4367
+ slots: {}
4368
+ },
4369
+ "code-block": {
4370
+ $key: "code-block",
4371
+ type: "component",
4372
+ icon: iconsVue.EditPen,
4373
+ text: "\u4EE3\u7801\u7F16\u8F91",
4374
+ component: _sfc_main$e,
4375
+ slots: {}
4376
+ }
4377
+ };
4378
+ return typeof data === "string" ? map[data] : data;
4379
+ };
4380
+ const sideBarItems = vue.computed(() => props.data.items.map((item) => getItemConfig(item)));
3469
4381
  vue.watch(
3470
- () => props.data?.status,
4382
+ () => props.data.status,
3471
4383
  (status) => {
3472
4384
  activeTabName.value = status || "0";
3473
4385
  }
3474
4386
  );
3475
- return {
4387
+ expose({
3476
4388
  activeTabName
4389
+ });
4390
+ return (_ctx, _cache) => {
4391
+ return __props.data.type === "tabs" && __props.data.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTabs), {
4392
+ key: 0,
4393
+ class: "m-editor-sidebar",
4394
+ modelValue: activeTabName.value,
4395
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event),
4396
+ type: "card",
4397
+ "tab-position": "left"
4398
+ }, {
4399
+ default: vue.withCtx(() => [
4400
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(sideBarItems), (config, index) => {
4401
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(uiComponent).component), {
4402
+ key: index,
4403
+ name: config.text
4404
+ }, {
4405
+ label: vue.withCtx(() => [
4406
+ (vue.openBlock(), vue.createElementBlock("div", {
4407
+ key: config.text
4408
+ }, [
4409
+ config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$l, {
4410
+ key: 0,
4411
+ icon: config.icon
4412
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
4413
+ config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, vue.toDisplayString(config.text), 1)) : vue.createCommentVNode("", true)
4414
+ ]))
4415
+ ]),
4416
+ default: vue.withCtx(() => [
4417
+ config ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({ key: 0 }, config.props || {}, vue.toHandlers(config?.listeners || {})), vue.createSlots({ _: 2 }, [
4418
+ config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
4419
+ name: "component-list-panel-header",
4420
+ fn: vue.withCtx(() => [
4421
+ config.$key === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : config.slots?.componentListPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.componentListPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
4422
+ ])
4423
+ } : void 0,
4424
+ config.$key === "component-list" || config.slots?.componentListItem ? {
4425
+ name: "component-list-item",
4426
+ fn: vue.withCtx(({ component }) => [
4427
+ config.$key === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-item", {
4428
+ key: 0,
4429
+ component
4430
+ }) : config.slots?.componentListItem ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.componentListItem), {
4431
+ key: 1,
4432
+ component
4433
+ }, null, 8, ["component"])) : vue.createCommentVNode("", true)
4434
+ ])
4435
+ } : void 0,
4436
+ config.$key === "layer" || config.slots?.layerPanelHeader ? {
4437
+ name: "layer-panel-header",
4438
+ fn: vue.withCtx(() => [
4439
+ config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : config.slots?.layerPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
4440
+ ])
4441
+ } : void 0,
4442
+ config.$key === "code-block" || config.slots?.codeBlockPanelHeader ? {
4443
+ name: "code-block-panel-header",
4444
+ fn: vue.withCtx(() => [
4445
+ config.$key === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : config.slots?.codeBlockPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.codeBlockPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
4446
+ ])
4447
+ } : void 0,
4448
+ config.$key === "code-block" || config.slots?.codeBlockPanelTool ? {
4449
+ name: "code-block-panel-tool",
4450
+ fn: vue.withCtx(({ id, data }) => [
4451
+ config.$key === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
4452
+ key: 0,
4453
+ id,
4454
+ data
4455
+ }) : config.slots?.codeBlockPanelTool ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.codeBlockPanelTool), { key: 1 })) : vue.createCommentVNode("", true)
4456
+ ])
4457
+ } : void 0,
4458
+ config.$key === "code-block" || config.slots?.codeBlockEditPanelHeader ? {
4459
+ name: "code-block-edit-panel-header",
4460
+ fn: vue.withCtx(({ id }) => [
4461
+ config.$key === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
4462
+ key: 0,
4463
+ id
4464
+ }) : config.slots?.codeBlockEditPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.codeBlockEditPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
4465
+ ])
4466
+ } : void 0,
4467
+ config.$key === "layer" || config.slots?.layerNodeContent ? {
4468
+ name: "layer-node-content",
4469
+ fn: vue.withCtx(({ data: nodeData, node }) => [
4470
+ config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-content", {
4471
+ key: 0,
4472
+ data: nodeData,
4473
+ node
4474
+ }) : config.slots?.layerNodeContent ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerNodeContent), {
4475
+ key: 1,
4476
+ data: nodeData,
4477
+ node
4478
+ }, null, 8, ["data", "node"])) : vue.createCommentVNode("", true)
4479
+ ])
4480
+ } : void 0
4481
+ ]), 1040)) : vue.createCommentVNode("", true)
4482
+ ]),
4483
+ _: 2
4484
+ }, 1032, ["name"]);
4485
+ }), 128))
4486
+ ]),
4487
+ _: 3
4488
+ }, 8, ["modelValue"])) : vue.createCommentVNode("", true);
3477
4489
  };
3478
4490
  }
3479
4491
  });
3480
4492
 
3481
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3482
- const _component_tab_pane = vue.resolveComponent("tab-pane");
3483
- const _component_el_tabs = vue.resolveComponent("el-tabs");
3484
- return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createBlock(_component_el_tabs, {
3485
- key: 0,
3486
- class: "m-editor-sidebar",
3487
- modelValue: _ctx.activeTabName,
3488
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.activeTabName = $event),
3489
- type: "card",
3490
- "tab-position": "left"
3491
- }, {
3492
- default: vue.withCtx(() => [
3493
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data.items, (item, index) => {
3494
- return vue.openBlock(), vue.createBlock(_component_tab_pane, {
3495
- key: index,
3496
- data: item
3497
- }, vue.createSlots({ _: 2 }, [
3498
- item === "layer" ? {
3499
- name: "layer-panel-header",
3500
- fn: vue.withCtx(() => [
3501
- vue.renderSlot(_ctx.$slots, "layer-panel-header")
3502
- ])
3503
- } : void 0,
3504
- item === "layer" ? {
3505
- name: "layer-node-content",
3506
- fn: vue.withCtx(({ node, data }) => [
3507
- vue.renderSlot(_ctx.$slots, "layer-node-content", {
3508
- data,
3509
- node
3510
- })
3511
- ])
3512
- } : void 0,
3513
- item === "component-list" ? {
3514
- name: "component-list-panel-header",
3515
- fn: vue.withCtx(() => [
3516
- vue.renderSlot(_ctx.$slots, "component-list-panel-header")
3517
- ])
3518
- } : void 0,
3519
- item === "component-list" ? {
3520
- name: "component-list-item",
3521
- fn: vue.withCtx(({ component }) => [
3522
- vue.renderSlot(_ctx.$slots, "component-list-item", { component })
3523
- ])
3524
- } : void 0
3525
- ]), 1032, ["data"]);
3526
- }), 128))
3527
- ]),
3528
- _: 3
3529
- }, 8, ["modelValue"])) : vue.createCommentVNode("", true);
3530
- }
3531
- const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
4493
+ const _hoisted_1$2 = {
4494
+ key: 0,
4495
+ class: "m-editor-breadcrumb"
4496
+ };
4497
+ const _hoisted_2$1 = { key: 0 };
4498
+ const __default__$7 = vue.defineComponent({
4499
+ name: "MEditorBreadcrumb"
4500
+ });
4501
+ const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
4502
+ ...__default__$7,
4503
+ setup(__props) {
4504
+ const services = vue.inject("services");
4505
+ const editorService = services?.editorService;
4506
+ const node = vue.computed(() => editorService?.get("node"));
4507
+ const nodes = vue.computed(() => editorService?.get("nodes") || []);
4508
+ const root = vue.computed(() => editorService?.get("root"));
4509
+ const path = vue.computed(() => utils.getNodePath(node.value?.id || "", root.value?.items || []));
4510
+ const select = async (node2) => {
4511
+ await editorService?.select(node2);
4512
+ editorService?.get("stage")?.select(node2.id);
4513
+ };
4514
+ return (_ctx, _cache) => {
4515
+ return vue.unref(nodes).length === 1 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
4516
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(path), (item, index) => {
4517
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, {
4518
+ key: item.id
4519
+ }, [
4520
+ vue.createVNode(vue.unref(design.TMagicButton), {
4521
+ text: "",
4522
+ disabled: item.id === vue.unref(node)?.id,
4523
+ onClick: ($event) => select(item)
4524
+ }, {
4525
+ default: vue.withCtx(() => [
4526
+ vue.createTextVNode(vue.toDisplayString(item.name), 1)
4527
+ ]),
4528
+ _: 2
4529
+ }, 1032, ["disabled", "onClick"]),
4530
+ index < vue.unref(path).length - 1 ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_2$1, "/")) : vue.createCommentVNode("", true)
4531
+ ], 64);
4532
+ }), 128))
4533
+ ])) : vue.createCommentVNode("", true);
4534
+ };
4535
+ }
4536
+ });
3532
4537
 
3533
4538
  const _hoisted_1$1 = {
3534
4539
  key: 1,
3535
4540
  style: { "width": "21px" }
3536
4541
  };
4542
+ const __default__$6 = vue.defineComponent({
4543
+ name: "MEditorPageBarScrollContainer"
4544
+ });
3537
4545
  const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
3538
- __name: "PageBarScrollContainer",
4546
+ ...__default__$6,
3539
4547
  setup(__props) {
3540
4548
  const services = vue.inject("services");
3541
4549
  const editorService = services?.editorService;
@@ -3616,14 +4624,14 @@
3616
4624
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3617
4625
  onClick: addPage
3618
4626
  }, [
3619
- vue.createVNode(_sfc_main$h, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
4627
+ vue.createVNode(_sfc_main$l, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
3620
4628
  ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1)),
3621
4629
  canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
3622
4630
  key: 2,
3623
4631
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3624
4632
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
3625
4633
  }, [
3626
- vue.createVNode(_sfc_main$h, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
4634
+ vue.createVNode(_sfc_main$l, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
3627
4635
  ])) : vue.createCommentVNode("", true),
3628
4636
  vue.unref(pageLength) ? (vue.openBlock(), vue.createElementBlock("div", {
3629
4637
  key: 3,
@@ -3639,7 +4647,7 @@
3639
4647
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3640
4648
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
3641
4649
  }, [
3642
- vue.createVNode(_sfc_main$h, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
4650
+ vue.createVNode(_sfc_main$l, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
3643
4651
  ])) : vue.createCommentVNode("", true)
3644
4652
  ], 512);
3645
4653
  };
@@ -3648,8 +4656,11 @@
3648
4656
 
3649
4657
  const _hoisted_1 = ["onClick"];
3650
4658
  const _hoisted_2 = { class: "m-editor-page-bar-title" };
4659
+ const __default__$5 = vue.defineComponent({
4660
+ name: "MEditorPageBar"
4661
+ });
3651
4662
  const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
3652
- __name: "PageBar",
4663
+ ...__default__$5,
3653
4664
  setup(__props) {
3654
4665
  const services = vue.inject("services");
3655
4666
  const editorService = services?.editorService;
@@ -3669,9 +4680,6 @@
3669
4680
  editorService?.remove(node);
3670
4681
  };
3671
4682
  return (_ctx, _cache) => {
3672
- const _component_el_tooltip = vue.resolveComponent("el-tooltip");
3673
- const _component_el_icon = vue.resolveComponent("el-icon");
3674
- const _component_el_popover = vue.resolveComponent("el-popover");
3675
4683
  return vue.openBlock(), vue.createBlock(_sfc_main$7, null, {
3676
4684
  default: vue.withCtx(() => [
3677
4685
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(root) && vue.unref(root).items || [], (item) => {
@@ -3682,7 +4690,7 @@
3682
4690
  }, [
3683
4691
  vue.createElementVNode("div", _hoisted_2, [
3684
4692
  vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3685
- vue.createVNode(_component_el_tooltip, {
4693
+ vue.createVNode(vue.unref(design.TMagicTooltip), {
3686
4694
  effect: "dark",
3687
4695
  placement: "top-start",
3688
4696
  content: item.name
@@ -3694,14 +4702,14 @@
3694
4702
  }, 1032, ["content"])
3695
4703
  ])
3696
4704
  ]),
3697
- vue.createVNode(_component_el_popover, {
4705
+ vue.createVNode(vue.unref(design.TMagicPopover), {
3698
4706
  "popper-class": "page-bar-popover",
3699
4707
  placement: "top",
3700
4708
  width: 160,
3701
4709
  trigger: "hover"
3702
4710
  }, {
3703
4711
  reference: vue.withCtx(() => [
3704
- vue.createVNode(_component_el_icon, { class: "m-editor-page-bar-menu-icon" }, {
4712
+ vue.createVNode(vue.unref(design.TMagicIcon), { class: "m-editor-page-bar-menu-icon" }, {
3705
4713
  default: vue.withCtx(() => [
3706
4714
  vue.createVNode(vue.unref(iconsVue.CaretBottom))
3707
4715
  ]),
@@ -3711,7 +4719,7 @@
3711
4719
  default: vue.withCtx(() => [
3712
4720
  vue.createElementVNode("div", null, [
3713
4721
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
3714
- vue.createVNode(_sfc_main$g, {
4722
+ vue.createVNode(_sfc_main$i, {
3715
4723
  data: {
3716
4724
  type: "button",
3717
4725
  text: "\u590D\u5236",
@@ -3719,7 +4727,7 @@
3719
4727
  handler: () => copy(item)
3720
4728
  }
3721
4729
  }, null, 8, ["data"]),
3722
- vue.createVNode(_sfc_main$g, {
4730
+ vue.createVNode(_sfc_main$i, {
3723
4731
  data: {
3724
4732
  type: "button",
3725
4733
  text: "\u5220\u9664",
@@ -3753,6 +4761,10 @@
3753
4761
  height = 0;
3754
4762
  translateXCorrectionValue = 0;
3755
4763
  translateYCorrectionValue = 0;
4764
+ correctionScrollSize = {
4765
+ width: 0,
4766
+ height: 0
4767
+ };
3756
4768
  resizeObserver = new ResizeObserver(() => {
3757
4769
  this.setSize();
3758
4770
  this.setScrollSize();
@@ -3762,6 +4774,12 @@
3762
4774
  this.container = options.container;
3763
4775
  this.target = options.target;
3764
4776
  this.zoom = options.zoom;
4777
+ if (this.correctionScrollSize) {
4778
+ this.correctionScrollSize = {
4779
+ ...this.correctionScrollSize,
4780
+ ...options.correctionScrollSize
4781
+ };
4782
+ }
3765
4783
  this.container.addEventListener("wheel", this.wheelHandler, false);
3766
4784
  this.setSize();
3767
4785
  this.setScrollSize();
@@ -3824,9 +4842,9 @@
3824
4842
  }
3825
4843
  setScrollSize = () => {
3826
4844
  const targetRect = this.target.getBoundingClientRect();
3827
- this.scrollWidth = targetRect.width * this.zoom + 100;
4845
+ this.scrollWidth = targetRect.width * this.zoom + this.correctionScrollSize.width;
3828
4846
  const targetMarginTop = Number(this.target.style.marginTop) || 0;
3829
- this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + 100;
4847
+ this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + this.correctionScrollSize.height;
3830
4848
  let left;
3831
4849
  let top;
3832
4850
  if (this.scrollWidth < this.width) {
@@ -3859,8 +4877,11 @@
3859
4877
  };
3860
4878
  }
3861
4879
 
4880
+ const __default__$4 = vue.defineComponent({
4881
+ name: "MEditorScrollBar"
4882
+ });
3862
4883
  const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
3863
- __name: "ScrollBar",
4884
+ ...__default__$4,
3864
4885
  props: {
3865
4886
  size: null,
3866
4887
  scrollSize: null,
@@ -3945,14 +4966,21 @@
3945
4966
 
3946
4967
  const ScrollBar_vue_vue_type_style_index_0_lang = '';
3947
4968
 
4969
+ const __default__$3 = vue.defineComponent({
4970
+ name: "MEditorScrollViewer"
4971
+ });
3948
4972
  const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
3949
- __name: "ScrollViewer",
4973
+ ...__default__$3,
3950
4974
  props: {
3951
4975
  width: { default: 0 },
3952
4976
  height: { default: 0 },
3953
4977
  wrapWidth: { default: 0 },
3954
4978
  wrapHeight: { default: 0 },
3955
- zoom: { default: 1 }
4979
+ zoom: { default: 1 },
4980
+ correctionScrollSize: { default: () => ({
4981
+ width: 0,
4982
+ height: 0
4983
+ }) }
3956
4984
  },
3957
4985
  setup(__props, { expose }) {
3958
4986
  const props = __props;
@@ -3975,7 +5003,8 @@
3975
5003
  scrollViewer = new ScrollViewer({
3976
5004
  container: container.value,
3977
5005
  target: el.value,
3978
- zoom: props.zoom
5006
+ zoom: props.zoom,
5007
+ correctionScrollSize: props.correctionScrollSize
3979
5008
  });
3980
5009
  scrollViewer.on("scroll", (data) => {
3981
5010
  hOffset.value = data.scrollLeft;
@@ -4043,10 +5072,14 @@
4043
5072
  }
4044
5073
  });
4045
5074
 
5075
+ const __default__$2 = vue.defineComponent({
5076
+ name: "MEditorViewerMenu"
5077
+ });
4046
5078
  const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
4047
- __name: "ViewerMenu",
5079
+ ...__default__$2,
4048
5080
  props: {
4049
- isMultiSelect: { type: Boolean, default: false }
5081
+ isMultiSelect: { type: Boolean, default: false },
5082
+ stageContentMenu: null
4050
5083
  },
4051
5084
  setup(__props, { expose }) {
4052
5085
  const props = __props;
@@ -4059,8 +5092,7 @@
4059
5092
  const nodes = vue.computed(() => editorService?.get("nodes"));
4060
5093
  const parent = vue.computed(() => editorService?.get("parent"));
4061
5094
  const stage = vue.computed(() => editorService?.get("stage"));
4062
- const stageContentMenu = vue.inject("stageContentMenu", []);
4063
- const menuData = vue.reactive([
5095
+ const menuData = vue.computed(() => [
4064
5096
  {
4065
5097
  type: "button",
4066
5098
  text: "\u6C34\u5E73\u5C45\u4E2D",
@@ -4162,7 +5194,7 @@
4162
5194
  editorService?.get("stage").clearGuides();
4163
5195
  }
4164
5196
  },
4165
- ...stageContentMenu
5197
+ ...props.stageContentMenu
4166
5198
  ]);
4167
5199
  vue.watch(
4168
5200
  parent,
@@ -4186,7 +5218,7 @@
4186
5218
  expose({ show });
4187
5219
  return (_ctx, _cache) => {
4188
5220
  return vue.openBlock(), vue.createBlock(_sfc_main$c, {
4189
- "menu-data": menuData,
5221
+ "menu-data": vue.unref(menuData),
4190
5222
  ref_key: "menu",
4191
5223
  ref: menu
4192
5224
  }, null, 8, ["menu-data"]);
@@ -4194,8 +5226,14 @@
4194
5226
  }
4195
5227
  });
4196
5228
 
5229
+ const __default__$1 = vue.defineComponent({
5230
+ name: "MEditorStage"
5231
+ });
4197
5232
  const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
4198
- __name: "Stage",
5233
+ ...__default__$1,
5234
+ props: {
5235
+ stageContentMenu: null
5236
+ },
4199
5237
  setup(__props) {
4200
5238
  let stage = null;
4201
5239
  let runtime = null;
@@ -4314,7 +5352,11 @@
4314
5352
  height: vue.unref(stageRect)?.height,
4315
5353
  "wrap-width": vue.unref(stageContainerRect)?.width,
4316
5354
  "wrap-height": vue.unref(stageContainerRect)?.height,
4317
- zoom: vue.unref(zoom)
5355
+ zoom: vue.unref(zoom),
5356
+ "correction-scroll-size": {
5357
+ width: 60,
5358
+ height: 50
5359
+ }
4318
5360
  }, {
4319
5361
  default: vue.withCtx(() => [
4320
5362
  vue.createElementVNode("div", {
@@ -4330,8 +5372,9 @@
4330
5372
  vue.createVNode(_sfc_main$3, {
4331
5373
  ref_key: "menu",
4332
5374
  ref: menu,
4333
- "is-multi-select": vue.unref(isMultiSelect)
4334
- }, null, 8, ["is-multi-select"])
5375
+ "is-multi-select": vue.unref(isMultiSelect),
5376
+ "stage-content-menu": __props.stageContentMenu
5377
+ }, null, 8, ["is-multi-select", "stage-content-menu"])
4335
5378
  ]))
4336
5379
  ]),
4337
5380
  _: 1
@@ -4340,8 +5383,14 @@
4340
5383
  }
4341
5384
  });
4342
5385
 
5386
+ const __default__ = vue.defineComponent({
5387
+ name: "MEditorWorkspace"
5388
+ });
4343
5389
  const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
4344
- __name: "Workspace",
5390
+ ...__default__,
5391
+ props: {
5392
+ stageContentMenu: null
5393
+ },
4345
5394
  setup(__props) {
4346
5395
  const services = vue.inject("services");
4347
5396
  const workspace = vue.ref();
@@ -4450,10 +5499,12 @@
4450
5499
  ref_key: "workspace",
4451
5500
  ref: workspace
4452
5501
  }, [
5502
+ vue.createVNode(_sfc_main$8),
4453
5503
  vue.renderSlot(_ctx.$slots, "stage", {}, () => [
4454
5504
  (vue.openBlock(), vue.createBlock(_sfc_main$2, {
4455
- key: vue.unref(page)?.id
4456
- }))
5505
+ key: vue.unref(page)?.id,
5506
+ "stage-content-menu": __props.stageContentMenu
5507
+ }, null, 8, ["stage-content-menu"]))
4457
5508
  ]),
4458
5509
  vue.renderSlot(_ctx.$slots, "workspace-content"),
4459
5510
  vue.createVNode(_sfc_main$6, null, {
@@ -4493,11 +5544,11 @@
4493
5544
  const _sfc_main = vue.defineComponent({
4494
5545
  name: "m-editor",
4495
5546
  components: {
4496
- NavMenu: _sfc_main$f,
4497
- Sidebar,
5547
+ NavMenu: _sfc_main$h,
5548
+ Sidebar: _sfc_main$9,
4498
5549
  Workspace: _sfc_main$1,
4499
- PropsPanel: _sfc_main$e,
4500
- Framework: _sfc_main$i
5550
+ PropsPanel: _sfc_main$g,
5551
+ Framework: _sfc_main$j
4501
5552
  },
4502
5553
  props: {
4503
5554
  modelValue: {
@@ -4592,7 +5643,9 @@
4592
5643
  });
4593
5644
  vue.watch(
4594
5645
  () => props.modelValue,
4595
- (modelValue) => editorService.set("root", modelValue),
5646
+ (modelValue) => {
5647
+ editorService.set("root", modelValue);
5648
+ },
4596
5649
  {
4597
5650
  immediate: true
4598
5651
  }
@@ -4655,6 +5708,7 @@
4655
5708
  uiService.destroy();
4656
5709
  componentListService.destroy();
4657
5710
  storageService.destroy();
5711
+ codeBlockService.destroy();
4658
5712
  });
4659
5713
  const services = {
4660
5714
  componentListService,
@@ -4663,11 +5717,10 @@
4663
5717
  propsService,
4664
5718
  editorService,
4665
5719
  uiService,
4666
- storageService
5720
+ storageService,
5721
+ codeBlockService
4667
5722
  };
4668
5723
  vue.provide("services", services);
4669
- vue.provide("layerContentMenu", props.layerContentMenu);
4670
- vue.provide("stageContentMenu", props.stageContentMenu);
4671
5724
  vue.provide(
4672
5725
  "stageOptions",
4673
5726
  vue.reactive({
@@ -4687,21 +5740,32 @@
4687
5740
  }
4688
5741
  });
4689
5742
 
5743
+ const _export_sfc = (sfc, props) => {
5744
+ const target = sfc.__vccOpts || sfc;
5745
+ for (const [key, val] of props) {
5746
+ target[key] = val;
5747
+ }
5748
+ return target;
5749
+ };
5750
+
4690
5751
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4691
- const _component_nav_menu = vue.resolveComponent("nav-menu");
4692
- const _component_sidebar = vue.resolveComponent("sidebar");
4693
- const _component_workspace = vue.resolveComponent("workspace");
4694
- const _component_props_panel = vue.resolveComponent("props-panel");
4695
- const _component_framework = vue.resolveComponent("framework");
4696
- return vue.openBlock(), vue.createBlock(_component_framework, { "code-options": _ctx.codeOptions }, {
5752
+ const _component_NavMenu = vue.resolveComponent("NavMenu");
5753
+ const _component_Sidebar = vue.resolveComponent("Sidebar");
5754
+ const _component_Workspace = vue.resolveComponent("Workspace");
5755
+ const _component_PropsPanel = vue.resolveComponent("PropsPanel");
5756
+ const _component_Framework = vue.resolveComponent("Framework");
5757
+ return vue.openBlock(), vue.createBlock(_component_Framework, { "code-options": _ctx.codeOptions }, {
4697
5758
  nav: vue.withCtx(() => [
4698
5759
  vue.renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
4699
- vue.createVNode(_component_nav_menu, { data: _ctx.menu }, null, 8, ["data"])
5760
+ vue.createVNode(_component_NavMenu, { data: _ctx.menu }, null, 8, ["data"])
4700
5761
  ])
4701
5762
  ]),
4702
5763
  sidebar: vue.withCtx(() => [
4703
5764
  vue.renderSlot(_ctx.$slots, "sidebar", { editorService: _ctx.editorService }, () => [
4704
- vue.createVNode(_component_sidebar, { data: _ctx.sidebar }, {
5765
+ vue.createVNode(_component_Sidebar, {
5766
+ data: _ctx.sidebar,
5767
+ "layer-content-menu": _ctx.layerContentMenu
5768
+ }, {
4705
5769
  "layer-panel-header": vue.withCtx(() => [
4706
5770
  vue.renderSlot(_ctx.$slots, "layer-panel-header")
4707
5771
  ]),
@@ -4717,13 +5781,25 @@
4717
5781
  "component-list-item": vue.withCtx(({ component }) => [
4718
5782
  vue.renderSlot(_ctx.$slots, "component-list-item", { component })
4719
5783
  ]),
5784
+ "code-block-panel-header": vue.withCtx(() => [
5785
+ vue.renderSlot(_ctx.$slots, "code-block-panel-header")
5786
+ ]),
5787
+ "code-block-panel-tool": vue.withCtx(({ id, data }) => [
5788
+ vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
5789
+ id,
5790
+ data
5791
+ })
5792
+ ]),
5793
+ "code-block-edit-panel-header": vue.withCtx(({ id }) => [
5794
+ vue.renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
5795
+ ]),
4720
5796
  _: 3
4721
- }, 8, ["data"])
5797
+ }, 8, ["data", "layer-content-menu"])
4722
5798
  ])
4723
5799
  ]),
4724
5800
  workspace: vue.withCtx(() => [
4725
5801
  vue.renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
4726
- vue.createVNode(_component_workspace, null, {
5802
+ vue.createVNode(_component_Workspace, { "stage-content-menu": _ctx.stageContentMenu }, {
4727
5803
  stage: vue.withCtx(() => [
4728
5804
  vue.renderSlot(_ctx.$slots, "stage")
4729
5805
  ]),
@@ -4737,12 +5813,12 @@
4737
5813
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
4738
5814
  ]),
4739
5815
  _: 3
4740
- })
5816
+ }, 8, ["stage-content-menu"])
4741
5817
  ])
4742
5818
  ]),
4743
5819
  "props-panel": vue.withCtx(() => [
4744
5820
  vue.renderSlot(_ctx.$slots, "props-panel", {}, () => [
4745
- vue.createVNode(_component_props_panel, {
5821
+ vue.createVNode(_component_PropsPanel, {
4746
5822
  onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
4747
5823
  }, {
4748
5824
  "props-panel-header": vue.withCtx(() => [
@@ -4769,30 +5845,37 @@
4769
5845
  app.config.globalProperties.$TMAGIC_EDITOR = option;
4770
5846
  setConfig(option);
4771
5847
  app.component(Editor.name, Editor);
4772
- app.component("m-fields-ui-select", _sfc_main$n);
4773
- app.component("m-fields-code-link", _sfc_main$o);
4774
- app.component("m-fields-vs-code", _sfc_main$p);
4775
- app.component(CodeEditor.name, CodeEditor);
5848
+ app.component("m-fields-ui-select", _sfc_main$p);
5849
+ app.component("m-fields-code-link", _sfc_main$r);
5850
+ app.component("m-fields-vs-code", _sfc_main$s);
5851
+ app.component("magic-code-editor", _sfc_main$o);
5852
+ app.component("m-fields-code-select", _sfc_main$q);
4776
5853
  }
4777
5854
  };
4778
5855
 
4779
5856
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
5857
+ exports.CodeBlockList = _sfc_main$e;
5858
+ exports.CodeDeleteErrorType = CodeDeleteErrorType;
5859
+ exports.CodeEditorMode = CodeEditorMode;
5860
+ exports.CodeSelect = _sfc_main$q;
5861
+ exports.CodeSelectOp = CodeSelectOp;
4780
5862
  exports.ColumnLayout = ColumnLayout;
4781
5863
  exports.ComponentListPanel = _sfc_main$d;
4782
5864
  exports.ContentMenu = _sfc_main$c;
4783
5865
  exports.Fixed2Other = Fixed2Other;
4784
5866
  exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
4785
- exports.Icon = _sfc_main$h;
5867
+ exports.Icon = _sfc_main$l;
4786
5868
  exports.Keys = Keys;
4787
5869
  exports.LayerOffset = LayerOffset;
4788
- exports.LayerPanel = LayerPanel;
4789
- exports.Layout = Layout;
4790
- exports.PropsPanel = _sfc_main$e;
4791
- exports.TMagicCodeEditor = CodeEditor;
5870
+ exports.LayerPanel = _sfc_main$a;
5871
+ exports.Layout = _sfc_main$m;
5872
+ exports.PropsPanel = _sfc_main$g;
5873
+ exports.TMagicCodeEditor = _sfc_main$o;
4792
5874
  exports.TMagicEditor = Editor;
4793
- exports.ToolButton = _sfc_main$g;
5875
+ exports.ToolButton = _sfc_main$i;
4794
5876
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
4795
5877
  exports.change2Fixed = change2Fixed;
5878
+ exports.codeBlockService = codeBlockService;
4796
5879
  exports.debug = debug;
4797
5880
  exports.default = index;
4798
5881
  exports.editorService = editorService;