@tmagic/editor 1.3.0-beta.1 → 1.3.0-beta.3

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 (81) hide show
  1. package/dist/style.css +67 -75
  2. package/dist/tmagic-editor.js +1667 -1062
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +1692 -1084
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +10 -10
  7. package/src/Editor.vue +70 -65
  8. package/src/components/ContentMenu.vue +5 -1
  9. package/src/components/SearchInput.vue +5 -1
  10. package/src/components/ToolButton.vue +1 -1
  11. package/src/editorProps.ts +51 -129
  12. package/src/fields/Code.vue +9 -3
  13. package/src/fields/DataSourceFieldSelect.vue +28 -16
  14. package/src/fields/DataSourceFields.vue +95 -7
  15. package/src/fields/DataSourceMethodSelect.vue +23 -14
  16. package/src/fields/DataSourceMocks.vue +237 -0
  17. package/src/fields/EventSelect.vue +30 -11
  18. package/src/index.ts +4 -1
  19. package/src/initService.ts +50 -20
  20. package/src/layouts/CodeEditor.vue +20 -4
  21. package/src/layouts/Framework.vue +3 -1
  22. package/src/layouts/PropsPanel.vue +3 -1
  23. package/src/layouts/sidebar/ComponentListPanel.vue +18 -8
  24. package/src/layouts/sidebar/Sidebar.vue +7 -10
  25. package/src/layouts/sidebar/code-block/CodeBlockList.vue +3 -1
  26. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +3 -1
  27. package/src/layouts/sidebar/layer/LayerNode.vue +206 -0
  28. package/src/layouts/sidebar/layer/LayerNodeTool.vue +32 -0
  29. package/src/layouts/sidebar/layer/LayerPanel.vue +85 -0
  30. package/src/layouts/sidebar/layer/use-drag.ts +157 -0
  31. package/src/layouts/sidebar/layer/use-filter.ts +70 -0
  32. package/src/layouts/sidebar/layer/use-keybinding.ts +47 -0
  33. package/src/layouts/sidebar/layer/use-node-status.ts +103 -0
  34. package/src/layouts/workspace/Workspace.vue +3 -1
  35. package/src/layouts/workspace/viewer/NodeListMenu.vue +16 -9
  36. package/src/layouts/workspace/viewer/Stage.vue +19 -17
  37. package/src/layouts/workspace/viewer/ViewerMenu.vue +1 -1
  38. package/src/services/dataSource.ts +21 -0
  39. package/src/services/editor.ts +45 -5
  40. package/src/theme/common/var.scss +2 -2
  41. package/src/theme/content-menu.scss +22 -20
  42. package/src/theme/framework.scss +2 -0
  43. package/src/theme/layer-panel.scss +63 -63
  44. package/src/theme/props-panel.scss +8 -0
  45. package/src/theme/sidebar.scss +1 -5
  46. package/src/type.ts +61 -0
  47. package/src/utils/data-source/index.ts +23 -0
  48. package/src/utils/dep.ts +26 -11
  49. package/src/utils/editor.ts +14 -3
  50. package/src/utils/props.ts +4 -0
  51. package/types/editorProps.d.ts +61 -107
  52. package/types/fields/Code.vue.d.ts +10 -6
  53. package/types/fields/DataSourceMocks.vue.d.ts +32 -0
  54. package/types/index.d.ts +2 -1
  55. package/types/initService.d.ts +5 -4
  56. package/types/layouts/CodeEditor.vue.d.ts +5 -0
  57. package/types/layouts/Framework.vue.d.ts +2 -12
  58. package/types/layouts/PropsPanel.vue.d.ts +2 -3
  59. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +2 -7
  60. package/types/layouts/sidebar/Sidebar.vue.d.ts +2 -17
  61. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +2 -7
  62. package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +2 -9
  63. package/types/layouts/sidebar/{LayerMenu.vue.d.ts → layer/LayerMenu.vue.d.ts} +1 -1
  64. package/types/layouts/sidebar/layer/LayerNode.vue.d.ts +50 -0
  65. package/types/layouts/sidebar/{LayerNode.vue.d.ts → layer/LayerNodeTool.vue.d.ts} +1 -1
  66. package/types/layouts/sidebar/{LayerPanel.vue.d.ts → layer/LayerPanel.vue.d.ts} +2 -8
  67. package/types/layouts/sidebar/layer/use-drag.d.ts +14 -0
  68. package/types/layouts/sidebar/layer/use-filter.d.ts +8 -0
  69. package/types/layouts/sidebar/layer/use-keybinding.d.ts +4 -0
  70. package/types/layouts/sidebar/layer/use-node-status.d.ts +7 -0
  71. package/types/layouts/workspace/Workspace.vue.d.ts +2 -11
  72. package/types/layouts/workspace/viewer/Stage.vue.d.ts +1 -1
  73. package/types/services/dataSource.d.ts +7 -0
  74. package/types/services/editor.d.ts +1 -0
  75. package/types/type.d.ts +61 -0
  76. package/types/utils/dep.d.ts +1 -1
  77. package/types/utils/editor.d.ts +3 -2
  78. package/src/layouts/sidebar/LayerNode.vue +0 -40
  79. package/src/layouts/sidebar/LayerPanel.vue +0 -369
  80. package/types/Editor.vue.d.ts +0 -233
  81. /package/src/layouts/sidebar/{LayerMenu.vue → layer/LayerMenu.vue} +0 -0
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('serialize-javascript'), require('@tmagic/design'), require('@tmagic/schema'), require('@tmagic/form'), require('@tmagic/table'), require('gesto'), require('@tmagic/utils'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', 'serialize-javascript', '@tmagic/design', '@tmagic/schema', '@tmagic/form', '@tmagic/table', 'gesto', '@tmagic/utils', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.monaco, global.serialize, global.design, global.schema, global.form, global.table, global.Gesto, global.utils, global.StageCore, global.events, global.core, global.KeyController));
5
- })(this, (function (exports, vue, iconsVue, lodashEs, monaco, serialize, design, schema, form, table, Gesto, utils, StageCore, events, core, KeyController) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('serialize-javascript'), require('@tmagic/design'), require('@tmagic/schema'), require('@tmagic/form'), require('@tmagic/table'), require('@tmagic/utils'), require('gesto'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', 'serialize-javascript', '@tmagic/design', '@tmagic/schema', '@tmagic/form', '@tmagic/table', '@tmagic/utils', 'gesto', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.monaco, global.serialize, global.design, global.schema, global.form, global.table, global.utils, global.Gesto, global.StageCore, global.events, global.core, global.KeyController));
5
+ })(this, (function (exports, vue, iconsVue, lodashEs, monaco, serialize, design, schema, form, table, utils, Gesto, StageCore, events, core, KeyController) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -23,10 +23,16 @@
23
23
 
24
24
  const monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
25
25
 
26
+ let $TMAGIC_EDITOR = {};
27
+ const setConfig = (option) => {
28
+ $TMAGIC_EDITOR = option;
29
+ };
30
+ const getConfig = (key) => $TMAGIC_EDITOR[key];
31
+
26
32
  const _hoisted_1$w = {
27
33
  class: /* @__PURE__ */ vue.normalizeClass(`magic-code-editor`)
28
34
  };
29
- const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
35
+ const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
30
36
  ...{
31
37
  name: "MEditorCodeEditor"
32
38
  },
@@ -40,7 +46,8 @@
40
46
  tabSize: 2
41
47
  }) },
42
48
  height: {},
43
- autoSave: { type: Boolean, default: true }
49
+ autoSave: { type: Boolean, default: true },
50
+ parse: { type: Boolean, default: false }
44
51
  },
45
52
  emits: ["initd", "save"],
46
53
  setup(__props, { expose: __expose, emit }) {
@@ -48,7 +55,7 @@
48
55
  const toString = (v, language) => {
49
56
  let value = "";
50
57
  if (typeof v !== "string") {
51
- if (props.language.toLocaleLowerCase() === "json") {
58
+ if (language === "json") {
52
59
  value = JSON.stringify(v, null, 2);
53
60
  } else {
54
61
  value = serialize(v, {
@@ -64,6 +71,15 @@
64
71
  }
65
72
  return value;
66
73
  };
74
+ const parse = (v, language) => {
75
+ if (typeof v !== "string") {
76
+ return v;
77
+ }
78
+ if (language === "json") {
79
+ return JSON.parse(v);
80
+ }
81
+ return getConfig("parseDSL")(v);
82
+ };
67
83
  let vsEditor = null;
68
84
  let vsDiffEditor = null;
69
85
  const values = vue.ref("");
@@ -76,7 +92,7 @@
76
92
  }, 300)
77
93
  );
78
94
  const setEditorValue = (v, m) => {
79
- values.value = toString(v, props.language);
95
+ values.value = toString(v, props.language.toLocaleLowerCase());
80
96
  if (props.type === "diff") {
81
97
  const originalModel = monaco__namespace.editor.createModel(values.value, "text/javascript");
82
98
  const modifiedModel = monaco__namespace.editor.createModel(toString(m, props.language), "text/javascript");
@@ -111,7 +127,7 @@
111
127
  e.stopPropagation();
112
128
  const newValue = getEditorValue();
113
129
  values.value = newValue;
114
- emit("save", newValue);
130
+ emit("save", props.parse ? parse(newValue, props.language) : newValue);
115
131
  }
116
132
  });
117
133
  if (props.type !== "diff" && props.autoSave) {
@@ -119,7 +135,7 @@
119
135
  const newValue = getEditorValue();
120
136
  if (values.value !== newValue) {
121
137
  values.value = newValue;
122
- emit("save", newValue);
138
+ emit("save", props.parse ? parse(newValue, props.language) : newValue);
123
139
  }
124
140
  });
125
141
  }
@@ -201,7 +217,7 @@
201
217
  }
202
218
  });
203
219
 
204
- const _sfc_main$P = /* @__PURE__ */ vue.defineComponent({
220
+ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
205
221
  ...{
206
222
  name: "MEditorCode"
207
223
  },
@@ -225,7 +241,7 @@
225
241
  emit("change", v);
226
242
  };
227
243
  return (_ctx, _cache) => {
228
- return vue.openBlock(), vue.createBlock(_sfc_main$Q, {
244
+ return vue.openBlock(), vue.createBlock(_sfc_main$S, {
229
245
  height: _ctx.config.height,
230
246
  "init-values": _ctx.model[_ctx.name],
231
247
  language: _ctx.config.language,
@@ -233,19 +249,14 @@
233
249
  ..._ctx.config.options,
234
250
  readOnly: _ctx.disabled
235
251
  },
252
+ parse: _ctx.config.parse,
236
253
  onSave: save
237
- }, null, 8, ["height", "init-values", "language", "options"]);
254
+ }, null, 8, ["height", "init-values", "language", "options", "parse"]);
238
255
  };
239
256
  }
240
257
  });
241
258
 
242
- let $TMAGIC_EDITOR = {};
243
- const setConfig = (option) => {
244
- $TMAGIC_EDITOR = option;
245
- };
246
- const getConfig = (key) => $TMAGIC_EDITOR[key];
247
-
248
- const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
259
+ const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
249
260
  ...{
250
261
  name: "MEditorCodeLink"
251
262
  },
@@ -324,7 +335,7 @@
324
335
  }
325
336
  });
326
337
 
327
- const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
338
+ const _sfc_main$P = /* @__PURE__ */ vue.defineComponent({
328
339
  ...{
329
340
  name: "MEditorCodeSelect"
330
341
  },
@@ -397,10 +408,10 @@
397
408
  });
398
409
 
399
410
  const _hoisted_1$v = { style: { "display": "flex", "margin-bottom": "10px" } };
400
- const _hoisted_2$n = { style: { "flex": "1" } };
401
- const _hoisted_3$a = { style: { "flex": "1" } };
402
- const _hoisted_4$6 = { class: "dialog-footer" };
403
- const _sfc_main$M = /* @__PURE__ */ vue.defineComponent({
411
+ const _hoisted_2$p = { style: { "flex": "1" } };
412
+ const _hoisted_3$b = { style: { "flex": "1" } };
413
+ const _hoisted_4$7 = { class: "dialog-footer" };
414
+ const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
404
415
  ...{
405
416
  name: "MEditorCodeBlockEditor"
406
417
  },
@@ -619,7 +630,7 @@
619
630
  fullscreen: ""
620
631
  }, {
621
632
  footer: vue.withCtx(() => [
622
- vue.createElementVNode("span", _hoisted_4$6, [
633
+ vue.createElementVNode("span", _hoisted_4$7, [
623
634
  vue.createVNode(vue.unref(design.TMagicButton), {
624
635
  size: "small",
625
636
  onClick: _cache[1] || (_cache[1] = ($event) => difVisible.value = false)
@@ -643,7 +654,7 @@
643
654
  ]),
644
655
  default: vue.withCtx(() => [
645
656
  vue.createElementVNode("div", _hoisted_1$v, [
646
- vue.createElementVNode("div", _hoisted_2$n, [
657
+ vue.createElementVNode("div", _hoisted_2$p, [
647
658
  vue.createVNode(vue.unref(design.TMagicTag), {
648
659
  size: "small",
649
660
  type: "info"
@@ -654,7 +665,7 @@
654
665
  _: 1
655
666
  })
656
667
  ]),
657
- vue.createElementVNode("div", _hoisted_3$a, [
668
+ vue.createElementVNode("div", _hoisted_3$b, [
658
669
  vue.createVNode(vue.unref(design.TMagicTag), {
659
670
  size: "small",
660
671
  type: "success"
@@ -666,7 +677,7 @@
666
677
  })
667
678
  ])
668
679
  ]),
669
- difVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$Q, {
680
+ difVisible.value ? (vue.openBlock(), vue.createBlock(_sfc_main$S, {
670
681
  key: 0,
671
682
  ref_key: "magicVsEditor",
672
683
  ref: magicVsEditor,
@@ -795,6 +806,29 @@
795
806
  defaultValue: () => []
796
807
  }
797
808
  ]
809
+ },
810
+ {
811
+ type: "panel",
812
+ title: "事件配置",
813
+ display: false,
814
+ items: [
815
+ {
816
+ name: "events",
817
+ src: "datasource",
818
+ type: "event-select"
819
+ }
820
+ ]
821
+ },
822
+ {
823
+ type: "panel",
824
+ title: "mock数据",
825
+ items: [
826
+ {
827
+ name: "mocks",
828
+ type: "data-source-mocks",
829
+ defaultValue: () => []
830
+ }
831
+ ]
798
832
  }
799
833
  ];
800
834
  const getFormConfig = (type, configs) => {
@@ -975,7 +1009,9 @@
975
1009
  dataSources: [],
976
1010
  editable: true,
977
1011
  configs: {},
978
- values: {}
1012
+ values: {},
1013
+ events: {},
1014
+ methods: {}
979
1015
  });
980
1016
  set(name, value) {
981
1017
  this.state[name] = value;
@@ -995,6 +1031,18 @@
995
1031
  setFormValue(type, value) {
996
1032
  this.get("values")[type] = value;
997
1033
  }
1034
+ getFormEvent(type = "base") {
1035
+ return this.get("events")[type] || [];
1036
+ }
1037
+ setFormEvent(type, value = []) {
1038
+ this.get("events")[type] = value;
1039
+ }
1040
+ getFormMethod(type = "base") {
1041
+ return this.get("methods")[type] || [];
1042
+ }
1043
+ setFormMethod(type, value = []) {
1044
+ this.get("methods")[type] = value;
1045
+ }
998
1046
  add(config) {
999
1047
  const newConfig = {
1000
1048
  ...config,
@@ -1211,6 +1259,7 @@
1211
1259
  items: [
1212
1260
  {
1213
1261
  name: "events",
1262
+ src: "component",
1214
1263
  type: "event-select"
1215
1264
  }
1216
1265
  ]
@@ -1240,6 +1289,8 @@
1240
1289
  {
1241
1290
  type: "groupList",
1242
1291
  name: "displayConds",
1292
+ titlePrefix: "条件组",
1293
+ expandAll: true,
1243
1294
  items: [
1244
1295
  {
1245
1296
  type: "table",
@@ -1248,6 +1299,7 @@
1248
1299
  {
1249
1300
  type: "data-source-field-select",
1250
1301
  name: "field",
1302
+ value: "key",
1251
1303
  label: "字段"
1252
1304
  },
1253
1305
  {
@@ -1433,6 +1485,11 @@
1433
1485
  DepTargetType2["DATA_SOURCE_COND"] = "data-source-cond";
1434
1486
  return DepTargetType2;
1435
1487
  })(DepTargetType || {});
1488
+ var DragType = /* @__PURE__ */ ((DragType2) => {
1489
+ DragType2["COMPONENT_LIST"] = "component-list";
1490
+ DragType2["LAYER_TREE"] = "layer-tree";
1491
+ return DragType2;
1492
+ })(DragType || {});
1436
1493
 
1437
1494
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
1438
1495
  const getPageList = (app) => {
@@ -1455,9 +1512,9 @@
1455
1512
  };
1456
1513
  const generatePageNameByApp = (app) => generatePageName(getPageNameList(getPageList(app)));
1457
1514
  const isFixed = (node) => node.style?.position === "fixed";
1458
- const getNodeIndex = (node, parent) => {
1515
+ const getNodeIndex = (id, parent) => {
1459
1516
  const items = parent?.items || [];
1460
- return items.findIndex((item) => `${item.id}` === `${node.id}`);
1517
+ return items.findIndex((item) => `${item.id}` === `${id}`);
1461
1518
  };
1462
1519
  const getRelativeStyle = (style = {}) => ({
1463
1520
  ...style,
@@ -1593,6 +1650,15 @@
1593
1650
  space: 2,
1594
1651
  unsafe: true
1595
1652
  }).replace(/"(\w+)":\s/g, "$1: ");
1653
+ const traverseNode = (node, cb, parents = []) => {
1654
+ cb(node, parents);
1655
+ if (node.items?.length) {
1656
+ parents.push(node);
1657
+ node.items.forEach((item) => {
1658
+ traverseNode(item, cb, parents);
1659
+ });
1660
+ }
1661
+ };
1596
1662
 
1597
1663
  class UndoRedo {
1598
1664
  elementList;
@@ -1971,7 +2037,7 @@
1971
2037
  }
1972
2038
  const propsService = new Props();
1973
2039
 
1974
- let Editor$1 = class Editor extends BaseService {
2040
+ class Editor extends BaseService {
1975
2041
  state = vue.reactive({
1976
2042
  root: null,
1977
2043
  page: null,
@@ -2006,7 +2072,8 @@
2006
2072
  "move",
2007
2073
  "undo",
2008
2074
  "redo",
2009
- "highlight"
2075
+ "highlight",
2076
+ "dragTo"
2010
2077
  ],
2011
2078
  // 需要注意循环依赖问题,如果函数间有相互调用的话,不能设置为串行调用
2012
2079
  ["select", "update", "moveLayer"]
@@ -2149,7 +2216,7 @@
2149
2216
  const parent = vue.toRaw(this.getParentById(node.id));
2150
2217
  if (!parent)
2151
2218
  return node;
2152
- const index = getNodeIndex(node, parent);
2219
+ const index = getNodeIndex(node.id, parent);
2153
2220
  const nextNode = parent.items[index + 1] || parent.items[0];
2154
2221
  await this.select(nextNode);
2155
2222
  this.get("stage")?.select(nextNode.id);
@@ -2162,7 +2229,7 @@
2162
2229
  throw new Error("page不能为空");
2163
2230
  if (!root)
2164
2231
  throw new Error("root不能为空");
2165
- const index = getNodeIndex(page, root);
2232
+ const index = getNodeIndex(page.id, root);
2166
2233
  const nextPage = root.items[index + 1] || root.items[0];
2167
2234
  await this.select(nextPage);
2168
2235
  this.get("stage")?.select(nextPage.id);
@@ -2283,7 +2350,7 @@
2283
2350
  const { parent, node: curNode } = this.getNodeInfo(node.id);
2284
2351
  if (!parent || !curNode)
2285
2352
  throw new Error("找不要删除的节点");
2286
- const index = getNodeIndex(curNode, parent);
2353
+ const index = getNodeIndex(curNode.id, parent);
2287
2354
  if (typeof index !== "number" || index === -1)
2288
2355
  throw new Error("找不要删除的节点");
2289
2356
  parent.items?.splice(index, 1);
@@ -2351,7 +2418,7 @@
2351
2418
  if (!parent)
2352
2419
  throw new Error("获取不到父级节点");
2353
2420
  const parentNodeItems = parent.items;
2354
- const index = getNodeIndex(newConfig, parent);
2421
+ const index = getNodeIndex(newConfig.id, parent);
2355
2422
  if (!parentNodeItems || typeof index === "undefined" || index === -1)
2356
2423
  throw new Error("更新的节点未找到");
2357
2424
  const newLayout = await this.getLayout(newConfig);
@@ -2541,7 +2608,7 @@
2541
2608
  const target = this.getNodeById(targetId, false);
2542
2609
  const stage = this.get("stage");
2543
2610
  if (root && node && parent && stage) {
2544
- const index = getNodeIndex(node, parent);
2611
+ const index = getNodeIndex(node.id, parent);
2545
2612
  parent.items?.splice(index, 1);
2546
2613
  await stage.remove({ id: node.id, parentId: parent.id, root });
2547
2614
  const layout = await this.getLayout(target);
@@ -2563,6 +2630,38 @@
2563
2630
  return newConfig;
2564
2631
  }
2565
2632
  }
2633
+ async dragTo(config, targetParent, targetIndex) {
2634
+ if (!targetParent || !Array.isArray(targetParent.items))
2635
+ return;
2636
+ const { parent, node: curNode } = this.getNodeInfo(config.id, false);
2637
+ if (!parent || !curNode)
2638
+ throw new Error("找不要删除的节点");
2639
+ const index = getNodeIndex(curNode.id, parent);
2640
+ if (typeof index !== "number" || index === -1)
2641
+ throw new Error("找不要删除的节点");
2642
+ if (parent.id === targetParent.id) {
2643
+ if (index === targetIndex)
2644
+ return;
2645
+ if (index < targetIndex) {
2646
+ targetIndex -= 1;
2647
+ }
2648
+ }
2649
+ parent.items?.splice(index, 1);
2650
+ targetParent.items?.splice(targetIndex, 0, config);
2651
+ const page = this.get("page");
2652
+ const root = this.get("root");
2653
+ const stage = this.get("stage");
2654
+ if (stage && page && root) {
2655
+ stage.update({
2656
+ config: lodashEs.cloneDeep(page),
2657
+ parentId: root.id,
2658
+ root: lodashEs.cloneDeep(root)
2659
+ });
2660
+ }
2661
+ this.addModifiedNodeId(config.id);
2662
+ this.addModifiedNodeId(parent.id);
2663
+ this.pushHistoryState();
2664
+ }
2566
2665
  /**
2567
2666
  * 撤销当前操作
2568
2667
  * @returns 上一次数据
@@ -2707,8 +2806,8 @@
2707
2806
  page
2708
2807
  };
2709
2808
  }
2710
- };
2711
- const editorService = new Editor$1();
2809
+ }
2810
+ const editorService = new Editor();
2712
2811
 
2713
2812
  const beforePaste = async (position, config) => {
2714
2813
  if (!config[0]?.style)
@@ -2782,7 +2881,7 @@
2782
2881
  return newNode;
2783
2882
  };
2784
2883
 
2785
- const _sfc_main$L = /* @__PURE__ */ vue.defineComponent({
2884
+ const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
2786
2885
  ...{
2787
2886
  name: "MEditorCodeParams"
2788
2887
  },
@@ -2832,7 +2931,7 @@
2832
2931
  });
2833
2932
 
2834
2933
  const _hoisted_1$u = ["src"];
2835
- const _sfc_main$K = /* @__PURE__ */ vue.defineComponent({
2934
+ const _sfc_main$M = /* @__PURE__ */ vue.defineComponent({
2836
2935
  ...{
2837
2936
  name: "MEditorIcon"
2838
2937
  },
@@ -2933,8 +3032,8 @@
2933
3032
  };
2934
3033
 
2935
3034
  const _hoisted_1$t = { class: "m-fields-code-select-col" };
2936
- const _hoisted_2$m = { class: "code-select-container" };
2937
- const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
3035
+ const _hoisted_2$o = { class: "code-select-container" };
3036
+ const _sfc_main$L = /* @__PURE__ */ vue.defineComponent({
2938
3037
  ...{
2939
3038
  name: "MEditorCodeSelectCol"
2940
3039
  },
@@ -3009,21 +3108,21 @@
3009
3108
  return (_ctx, _cache) => {
3010
3109
  const _component_m_form_container = vue.resolveComponent("m-form-container");
3011
3110
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$t, [
3012
- vue.createElementVNode("div", _hoisted_2$m, [
3111
+ vue.createElementVNode("div", _hoisted_2$o, [
3013
3112
  vue.createVNode(_component_m_form_container, {
3014
3113
  class: "select",
3015
3114
  config: selectConfig,
3016
3115
  model: _ctx.model,
3017
3116
  onChange: onParamsChangeHandler
3018
3117
  }, null, 8, ["model"]),
3019
- _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$K, {
3118
+ _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
3020
3119
  key: 0,
3021
3120
  class: "icon",
3022
3121
  icon: !_ctx.disabled ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
3023
3122
  onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(editCode)(_ctx.model[_ctx.name]))
3024
3123
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
3025
3124
  ]),
3026
- paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$L, {
3125
+ paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
3027
3126
  key: 0,
3028
3127
  name: "params",
3029
3128
  model: _ctx.model,
@@ -3031,7 +3130,7 @@
3031
3130
  "params-config": paramsConfig.value,
3032
3131
  onChange: onParamsChangeHandler
3033
3132
  }, null, 8, ["model", "size", "params-config"])) : vue.createCommentVNode("", true),
3034
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
3133
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
3035
3134
  key: 1,
3036
3135
  ref_key: "codeBlockEditor",
3037
3136
  ref: codeBlockEditor,
@@ -3045,8 +3144,8 @@
3045
3144
  });
3046
3145
 
3047
3146
  const _hoisted_1$s = { class: "m-editor-data-source-fields" };
3048
- const _hoisted_2$l = { class: "m-editor-data-source-fields-footer" };
3049
- const _sfc_main$I = /* @__PURE__ */ vue.defineComponent({
3147
+ const _hoisted_2$n = { class: "m-editor-data-source-fields-footer" };
3148
+ const _sfc_main$K = /* @__PURE__ */ vue.defineComponent({
3050
3149
  ...{
3051
3150
  name: "MEditorDataSourceFields"
3052
3151
  },
@@ -3068,11 +3167,11 @@
3068
3167
  const services = vue.inject("services");
3069
3168
  const addDialog = vue.ref();
3070
3169
  const fieldValues = vue.ref({});
3071
- const filedTitle = vue.ref("");
3170
+ const fieldTitle = vue.ref("");
3072
3171
  const width = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
3073
3172
  const newHandler = () => {
3074
3173
  fieldValues.value = {};
3075
- filedTitle.value = "新增属性";
3174
+ fieldTitle.value = "新增属性";
3076
3175
  addDialog.value?.show();
3077
3176
  };
3078
3177
  const fieldChange = ({ index, ...value }) => {
@@ -3112,7 +3211,7 @@
3112
3211
  ...row,
3113
3212
  index
3114
3213
  };
3115
- filedTitle.value = `编辑${row.title}`;
3214
+ fieldTitle.value = `编辑${row.title}`;
3116
3215
  addDialog.value?.show();
3117
3216
  }
3118
3217
  },
@@ -3182,12 +3281,16 @@
3182
3281
  {
3183
3282
  name: "defaultValue",
3184
3283
  text: "默认值",
3284
+ height: "200px",
3285
+ parse: true,
3185
3286
  type: (mForm, { model }) => {
3186
3287
  if (model.type === "number")
3187
3288
  return "number";
3188
3289
  if (model.type === "boolean")
3189
3290
  return "select";
3190
- return "string";
3291
+ if (model.type === "string")
3292
+ return "text";
3293
+ return "vs-code";
3191
3294
  },
3192
3295
  options: [
3193
3296
  { text: "true", value: true },
@@ -3204,22 +3307,98 @@
3204
3307
  name: "fields",
3205
3308
  type: "data-source-fields",
3206
3309
  defaultValue: [],
3207
- display: (formState, { model }) => model.type === "object"
3310
+ display: (formState, { model }) => model.type === "object" || model.type === "array"
3311
+ }
3312
+ ];
3313
+ const addFromJsonDialog = vue.ref();
3314
+ const jsonFromConfig = [
3315
+ {
3316
+ name: "data",
3317
+ type: "vs-code",
3318
+ labelWidth: "0",
3319
+ language: "json",
3320
+ height: "600px",
3321
+ options: vue.inject("codeOptions", {})
3208
3322
  }
3209
3323
  ];
3324
+ const jsonFromValues = vue.ref({
3325
+ data: {}
3326
+ });
3327
+ const newFromJsonHandler = () => {
3328
+ addFromJsonDialog.value?.show();
3329
+ };
3330
+ const getValueType = (value) => {
3331
+ if (Array.isArray(value))
3332
+ return "array";
3333
+ if (value === null)
3334
+ return "null";
3335
+ if (typeof value === "object")
3336
+ return "object";
3337
+ if (typeof value === "number")
3338
+ return "number";
3339
+ if (typeof value === "boolean")
3340
+ return "boolean";
3341
+ if (typeof value === "string")
3342
+ return "string";
3343
+ return "any";
3344
+ };
3345
+ const getFieldsConfig = (value) => {
3346
+ if (!value || typeof value !== "object")
3347
+ throw new Error("数据格式错误");
3348
+ const fields = [];
3349
+ Object.entries(value).forEach(([key, value2]) => {
3350
+ const type = getValueType(value2);
3351
+ let childFields = [];
3352
+ if (Array.isArray(value2) && value2.length > 0) {
3353
+ childFields = getFieldsConfig(value2[0]);
3354
+ } else if (type === "object") {
3355
+ childFields = getFieldsConfig(value2);
3356
+ }
3357
+ fields.push({
3358
+ name: key,
3359
+ title: key,
3360
+ type,
3361
+ defaultValue: value2,
3362
+ fields: childFields
3363
+ });
3364
+ });
3365
+ return fields;
3366
+ };
3367
+ const addFromJsonFromChange = ({ data }) => {
3368
+ console.log(data);
3369
+ try {
3370
+ const value = JSON.parse(data);
3371
+ props.model[props.name] = getFieldsConfig(value);
3372
+ addFromJsonDialog.value?.hide();
3373
+ emit("change", props.model[props.name]);
3374
+ } catch (e) {
3375
+ design.tMagicMessage.error(e.message);
3376
+ }
3377
+ };
3210
3378
  return (_ctx, _cache) => {
3211
3379
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
3212
3380
  vue.createVNode(vue.unref(table.MagicTable), {
3213
3381
  data: _ctx.model[_ctx.name],
3214
3382
  columns: fieldColumns
3215
3383
  }, null, 8, ["data"]),
3216
- vue.createElementVNode("div", _hoisted_2$l, [
3384
+ vue.createElementVNode("div", _hoisted_2$n, [
3385
+ vue.createVNode(vue.unref(design.TMagicButton), {
3386
+ size: "small",
3387
+ disabled: _ctx.disabled,
3388
+ plain: "",
3389
+ onClick: _cache[0] || (_cache[0] = ($event) => newFromJsonHandler())
3390
+ }, {
3391
+ default: vue.withCtx(() => [
3392
+ vue.createTextVNode("快速添加")
3393
+ ]),
3394
+ _: 1
3395
+ }, 8, ["disabled"]),
3217
3396
  vue.createVNode(vue.unref(design.TMagicButton), {
3218
3397
  size: "small",
3219
3398
  type: "primary",
3220
3399
  disabled: _ctx.disabled,
3221
3400
  plain: "",
3222
- onClick: _cache[0] || (_cache[0] = ($event) => newHandler())
3401
+ onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
3223
3402
  }, {
3224
3403
  default: vue.withCtx(() => [
3225
3404
  vue.createTextVNode("添加")
@@ -3231,20 +3410,30 @@
3231
3410
  ref_key: "addDialog",
3232
3411
  ref: addDialog,
3233
3412
  "label-width": "80px",
3234
- title: filedTitle.value,
3413
+ title: fieldTitle.value,
3235
3414
  config: dataSourceFieldsConfig,
3236
3415
  values: fieldValues.value,
3237
3416
  parentValues: _ctx.model[_ctx.name],
3238
3417
  disabled: _ctx.disabled,
3239
3418
  width: width.value,
3240
3419
  onSubmit: fieldChange
3241
- }, null, 8, ["title", "values", "parentValues", "disabled", "width"])
3420
+ }, null, 8, ["title", "values", "parentValues", "disabled", "width"]),
3421
+ vue.createVNode(vue.unref(form.MFormDrawer), {
3422
+ ref_key: "addFromJsonDialog",
3423
+ ref: addFromJsonDialog,
3424
+ title: "快速添加数据定义",
3425
+ config: jsonFromConfig,
3426
+ values: jsonFromValues.value,
3427
+ disabled: _ctx.disabled,
3428
+ width: width.value,
3429
+ onSubmit: addFromJsonFromChange
3430
+ }, null, 8, ["values", "disabled", "width"])
3242
3431
  ]);
3243
3432
  };
3244
3433
  }
3245
3434
  });
3246
3435
 
3247
- const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
3436
+ const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
3248
3437
  __name: "DataSourceFieldSelect",
3249
3438
  props: {
3250
3439
  config: {},
@@ -3262,18 +3451,25 @@
3262
3451
  const props = __props;
3263
3452
  const services = vue.inject("services");
3264
3453
  const dataSources = vue.computed(() => services?.dataSourceService.get("dataSources"));
3265
- const cascaderConfig = {
3266
- type: "cascader",
3267
- name: props.name,
3268
- options: () => dataSources.value?.filter((ds) => ds.fields?.length)?.map((ds) => ({
3269
- label: ds.title || ds.id,
3270
- value: ds.id,
3271
- children: ds.fields?.map((field) => ({
3272
- label: field.title,
3273
- value: field.name
3274
- }))
3275
- })) || []
3276
- };
3454
+ const getOptionChildren = (fields = []) => fields.map((field) => ({
3455
+ label: field.title || field.name,
3456
+ value: field.name,
3457
+ children: field.type === "array" ? [] : getOptionChildren(field.fields)
3458
+ }));
3459
+ const cascaderConfig = vue.computed(() => {
3460
+ const valueIsKey = props.config.value === "key";
3461
+ return {
3462
+ type: "cascader",
3463
+ name: props.name,
3464
+ checkStrictly: !valueIsKey,
3465
+ text: "",
3466
+ options: () => dataSources.value?.filter((ds) => ds.fields?.length)?.map((ds) => ({
3467
+ label: ds.title || ds.id,
3468
+ value: valueIsKey ? ds.id : `${utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX}${ds.id}`,
3469
+ children: getOptionChildren(ds.fields)
3470
+ })) || []
3471
+ };
3472
+ });
3277
3473
  const onChangeHandler = (value) => {
3278
3474
  emit("change", value);
3279
3475
  };
@@ -3282,7 +3478,7 @@
3282
3478
  return vue.openBlock(), vue.createBlock(_component_m_form_container, {
3283
3479
  config: {
3284
3480
  ..._ctx.config,
3285
- ...cascaderConfig
3481
+ ...cascaderConfig.value
3286
3482
  },
3287
3483
  model: _ctx.model,
3288
3484
  onChange: onChangeHandler
@@ -3292,9 +3488,9 @@
3292
3488
  });
3293
3489
 
3294
3490
  const _hoisted_1$r = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
3295
- const _hoisted_2$k = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
3296
- const _hoisted_3$9 = { class: "el-input__inner" };
3297
- const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
3491
+ const _hoisted_2$m = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
3492
+ const _hoisted_3$a = { class: "el-input__inner" };
3493
+ const _sfc_main$I = /* @__PURE__ */ vue.defineComponent({
3298
3494
  ...{
3299
3495
  name: "MEditorDataSourceInput"
3300
3496
  },
@@ -3483,12 +3679,12 @@
3483
3679
  }
3484
3680
  ), {
3485
3681
  suffix: vue.withCtx(() => [
3486
- vue.createVNode(_sfc_main$K, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
3682
+ vue.createVNode(_sfc_main$M, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
3487
3683
  ]),
3488
3684
  default: vue.withCtx(({ item }) => [
3489
3685
  vue.createElementVNode("div", _hoisted_1$r, [
3490
3686
  vue.createElementVNode("div", null, vue.toDisplayString(item.text), 1),
3491
- vue.createElementVNode("span", _hoisted_2$k, vue.toDisplayString(item.value), 1)
3687
+ vue.createElementVNode("span", _hoisted_2$m, vue.toDisplayString(item.value), 1)
3492
3688
  ])
3493
3689
  ]),
3494
3690
  _: 1
@@ -3500,7 +3696,7 @@
3500
3696
  vue.createElementVNode("div", {
3501
3697
  class: vue.normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
3502
3698
  }, [
3503
- vue.createElementVNode("div", _hoisted_3$9, [
3699
+ vue.createElementVNode("div", _hoisted_3$a, [
3504
3700
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(displayState.value, (item, index) => {
3505
3701
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
3506
3702
  item.type === "text" ? (vue.openBlock(), vue.createElementBlock("span", {
@@ -3518,7 +3714,7 @@
3518
3714
  }, 1032, ["size"])) : vue.createCommentVNode("", true)
3519
3715
  ], 64);
3520
3716
  }), 256)),
3521
- vue.createVNode(_sfc_main$K, {
3717
+ vue.createVNode(_sfc_main$M, {
3522
3718
  class: "tmagic-data-source-input-icon",
3523
3719
  icon: vue.unref(iconsVue.Coin)
3524
3720
  }, null, 8, ["icon"])
@@ -3602,8 +3798,8 @@
3602
3798
  };
3603
3799
 
3604
3800
  const _hoisted_1$q = { class: "m-editor-data-source-methods" };
3605
- const _hoisted_2$j = { class: "m-editor-data-source-methods-footer" };
3606
- const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
3801
+ const _hoisted_2$l = { class: "m-editor-data-source-methods-footer" };
3802
+ const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
3607
3803
  ...{
3608
3804
  name: "MEditorDataSourceMethods"
3609
3805
  },
@@ -3677,7 +3873,7 @@
3677
3873
  data: _ctx.model[_ctx.name],
3678
3874
  columns: methodColumns
3679
3875
  }, null, 8, ["data"]),
3680
- vue.createElementVNode("div", _hoisted_2$j, [
3876
+ vue.createElementVNode("div", _hoisted_2$l, [
3681
3877
  vue.createVNode(vue.unref(design.TMagicButton), {
3682
3878
  size: "small",
3683
3879
  type: "primary",
@@ -3691,7 +3887,7 @@
3691
3887
  _: 1
3692
3888
  }, 8, ["disabled"])
3693
3889
  ]),
3694
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
3890
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
3695
3891
  key: 0,
3696
3892
  ref_key: "codeBlockEditor",
3697
3893
  ref: codeBlockEditor,
@@ -3707,8 +3903,8 @@
3707
3903
  });
3708
3904
 
3709
3905
  const _hoisted_1$p = { class: "m-fields-data-source-method-select" };
3710
- const _hoisted_2$i = { class: "data-source-method-select-container" };
3711
- const _sfc_main$E = /* @__PURE__ */ vue.defineComponent({
3906
+ const _hoisted_2$k = { class: "data-source-method-select-container" };
3907
+ const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
3712
3908
  ...{
3713
3909
  name: "MEditorDataSourceMethodSelect"
3714
3910
  },
@@ -3728,7 +3924,8 @@
3728
3924
  setup(__props, { emit }) {
3729
3925
  const props = __props;
3730
3926
  const services = vue.inject("services");
3731
- const dataSources = vue.computed(() => services?.dataSourceService.get("dataSources"));
3927
+ const dataSourceService = services?.dataSourceService;
3928
+ const dataSources = vue.computed(() => dataSourceService?.get("dataSources"));
3732
3929
  const getParamItemsConfig = ([dataSourceId, medthodName] = ["", ""]) => {
3733
3930
  if (!dataSourceId)
3734
3931
  return [];
@@ -3750,24 +3947,30 @@
3750
3947
  props.model.params = {};
3751
3948
  }
3752
3949
  };
3753
- const cascaderConfig = {
3950
+ const methodsOptions = vue.computed(
3951
+ () => dataSources.value?.filter((ds) => ds.methods?.length || dataSourceService?.getFormMethod(ds.type).length)?.map((ds) => ({
3952
+ label: ds.title || ds.id,
3953
+ value: ds.id,
3954
+ children: [
3955
+ ...dataSourceService?.getFormMethod(ds.type) || [],
3956
+ ...(ds.methods || []).map((method) => ({
3957
+ label: method.name,
3958
+ value: method.name
3959
+ }))
3960
+ ]
3961
+ })) || []
3962
+ );
3963
+ const cascaderConfig = vue.computed(() => ({
3754
3964
  type: "cascader",
3755
3965
  text: "数据源方法",
3756
3966
  name: props.name,
3757
3967
  labelWidth: "80px",
3758
- options: () => dataSources.value?.filter((ds) => ds.methods?.length)?.map((ds) => ({
3759
- label: ds.title || ds.id,
3760
- value: ds.id,
3761
- children: ds.methods?.map((method) => ({
3762
- label: method.name,
3763
- value: method.name
3764
- }))
3765
- })) || [],
3968
+ options: methodsOptions.value,
3766
3969
  onChange: (formState, dataSourceMethod) => {
3767
3970
  setParamsConfig(dataSourceMethod, formState);
3768
3971
  return dataSourceMethod;
3769
3972
  }
3770
- };
3973
+ }));
3771
3974
  const onChangeHandler = (value) => {
3772
3975
  props.model.params = value.params;
3773
3976
  emit("change", props.model);
@@ -3775,7 +3978,7 @@
3775
3978
  const { codeBlockEditor, codeConfig, editCode, submitCode } = useDataSourceMethod();
3776
3979
  const editCodeHandler = () => {
3777
3980
  const [id, name] = props.model[props.name];
3778
- const dataSource = services?.dataSourceService.getDataSourceById(id);
3981
+ const dataSource = dataSourceService?.getDataSourceById(id);
3779
3982
  if (!dataSource)
3780
3983
  return;
3781
3984
  editCode(dataSource, name);
@@ -3787,21 +3990,21 @@
3787
3990
  return (_ctx, _cache) => {
3788
3991
  const _component_m_form_container = vue.resolveComponent("m-form-container");
3789
3992
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$p, [
3790
- vue.createElementVNode("div", _hoisted_2$i, [
3993
+ vue.createElementVNode("div", _hoisted_2$k, [
3791
3994
  vue.createVNode(_component_m_form_container, {
3792
3995
  class: "select",
3793
- config: cascaderConfig,
3996
+ config: cascaderConfig.value,
3794
3997
  model: _ctx.model,
3795
3998
  onChange: onChangeHandler
3796
- }, null, 8, ["model"]),
3797
- _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$K, {
3999
+ }, null, 8, ["config", "model"]),
4000
+ _ctx.model[_ctx.name] ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
3798
4001
  key: 0,
3799
4002
  class: "icon",
3800
4003
  icon: !_ctx.disabled ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
3801
4004
  onClick: editCodeHandler
3802
4005
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true)
3803
4006
  ]),
3804
- paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$L, {
4007
+ paramsConfig.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
3805
4008
  key: 0,
3806
4009
  name: "params",
3807
4010
  model: _ctx.model,
@@ -3810,7 +4013,7 @@
3810
4013
  "params-config": paramsConfig.value,
3811
4014
  onChange: onChangeHandler
3812
4015
  }, null, 8, ["model", "size", "disabled", "params-config"])) : vue.createCommentVNode("", true),
3813
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
4016
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
3814
4017
  key: 1,
3815
4018
  ref_key: "codeBlockEditor",
3816
4019
  ref: codeBlockEditor,
@@ -3823,11 +4026,13 @@
3823
4026
  }
3824
4027
  });
3825
4028
 
3826
- const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
4029
+ const _hoisted_1$o = { class: "m-editor-data-source-fields" };
4030
+ const _hoisted_2$j = { class: "m-editor-data-source-fields-footer" };
4031
+ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
3827
4032
  ...{
3828
- name: "MEditorDataSourceSelect"
4033
+ name: "MEditorDataSourceMocks"
3829
4034
  },
3830
- __name: "DataSourceSelect",
4035
+ __name: "DataSourceMocks",
3831
4036
  props: {
3832
4037
  config: {},
3833
4038
  model: {},
@@ -3840,122 +4045,367 @@
3840
4045
  lastValues: {}
3841
4046
  },
3842
4047
  emits: ["change"],
3843
- setup(__props, { emit }) {
3844
- const props = __props;
3845
- const { dataSourceService } = vue.inject("services") || {};
3846
- const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
3847
- const selectConfig = vue.computed(() => {
3848
- const { type, dataSourceType, ...config } = props.config;
3849
- return {
3850
- ...config,
3851
- type: "select",
3852
- valueKey: "dataSourceId",
3853
- options: dataSources.value.filter((ds) => !dataSourceType || ds.type === dataSourceType).map((ds) => ({
3854
- value: {
3855
- isBindDataSource: true,
3856
- dataSourceType: ds.type,
3857
- dataSourceId: ds.id
3858
- },
3859
- text: ds.title || ds.id
3860
- }))
3861
- };
3862
- });
3863
- const changeHandler = (value) => {
3864
- emit("change", value);
3865
- };
3866
- return (_ctx, _cache) => {
3867
- return vue.openBlock(), vue.createBlock(vue.unref(form.MSelect), {
3868
- model: _ctx.model,
3869
- name: _ctx.name,
3870
- size: _ctx.size,
3871
- prop: _ctx.prop,
3872
- disabled: _ctx.disabled,
3873
- config: selectConfig.value,
3874
- "last-values": _ctx.lastValues,
3875
- onChange: changeHandler
3876
- }, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]);
3877
- };
3878
- }
3879
- });
3880
-
3881
- const _hoisted_1$o = { class: "m-fields-event-select" };
3882
- const _hoisted_2$h = {
3883
- key: 1,
3884
- class: "fullWidth"
3885
- };
3886
- const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
3887
- ...{
3888
- name: "MEditorEventSelect"
3889
- },
3890
- __name: "EventSelect",
3891
- props: {
3892
- config: {},
3893
- model: {},
3894
- initValues: {},
3895
- values: {},
3896
- name: {},
3897
- prop: {},
3898
- disabled: { type: Boolean },
3899
- size: {},
3900
- lastValues: {}
3901
- },
3902
- emits: ["change"],
3903
4048
  setup(__props, { emit }) {
3904
4049
  const props = __props;
3905
4050
  const services = vue.inject("services");
3906
- const eventNameConfig = vue.computed(() => {
3907
- const defaultEventNameConfig = {
3908
- name: "name",
3909
- text: "事件",
3910
- type: "select",
3911
- labelWidth: "40px",
3912
- options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
3913
- text: option.label,
3914
- value: option.value
3915
- }))
3916
- };
3917
- return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
3918
- });
3919
- const actionTypeConfig = vue.computed(() => {
3920
- const defaultActionTypeConfig = {
3921
- name: "actionType",
3922
- text: "联动类型",
3923
- labelWidth: "80px",
3924
- type: "select",
3925
- defaultValue: schema.ActionType.COMP,
3926
- options: () => [
3927
- {
3928
- text: "组件",
3929
- label: "组件",
3930
- value: schema.ActionType.COMP
3931
- },
4051
+ const width = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
4052
+ const addDialog = vue.ref();
4053
+ const drawerTitle = vue.ref("");
4054
+ const formValues = vue.ref({});
4055
+ const formConfig = [
4056
+ { name: "index", type: "hidden", filter: "number", defaultValue: -1 },
4057
+ {
4058
+ name: "title",
4059
+ text: "名称",
4060
+ rules: [
3932
4061
  {
3933
- text: "代码",
3934
- label: "代码",
3935
- disabled: !Object.keys(services?.codeBlockService.getCodeDsl() || {}).length,
3936
- value: schema.ActionType.CODE
4062
+ required: true,
4063
+ message: "请输入字段名称"
3937
4064
  },
3938
4065
  {
3939
- text: "数据源",
3940
- label: "数据源",
3941
- disabled: !services?.dataSourceService.get("dataSources")?.filter((ds) => ds.methods?.length).length,
3942
- value: schema.ActionType.DATA_SOURCE
4066
+ required: true,
4067
+ message: "请输入名称"
3943
4068
  }
3944
4069
  ]
3945
- };
3946
- return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
3947
- });
3948
- const targetCompConfig = vue.computed(() => {
3949
- const defaultTargetCompConfig = {
3950
- name: "to",
3951
- text: "联动组件",
3952
- labelWidth: "80px",
3953
- type: "ui-select",
3954
- display: (mForm, { model }) => model.actionType === schema.ActionType.COMP
3955
- };
3956
- return { ...defaultTargetCompConfig, ...props.config.targetCompConfig };
3957
- });
3958
- const compActionConfig = vue.computed(() => {
4070
+ },
4071
+ {
4072
+ name: "description",
4073
+ text: "描述"
4074
+ },
4075
+ {
4076
+ name: "enable",
4077
+ text: "启用",
4078
+ type: "switch"
4079
+ },
4080
+ {
4081
+ name: "useInEditor",
4082
+ text: "编辑器中使用",
4083
+ type: "switch"
4084
+ },
4085
+ {
4086
+ name: "data",
4087
+ text: "mock数据",
4088
+ type: "vs-code",
4089
+ language: "json",
4090
+ options: vue.inject("codeOptions", {}),
4091
+ defaultValue: "{}",
4092
+ height: "400px",
4093
+ onChange: (formState, v) => {
4094
+ if (typeof v !== "string")
4095
+ return v;
4096
+ return JSON.parse(v);
4097
+ },
4098
+ rules: [
4099
+ {
4100
+ validator: ({ value, callback }) => {
4101
+ if (typeof value !== "string")
4102
+ return callback();
4103
+ try {
4104
+ JSON.parse(value);
4105
+ callback();
4106
+ } catch (error) {
4107
+ callback(error);
4108
+ }
4109
+ }
4110
+ }
4111
+ ]
4112
+ }
4113
+ ];
4114
+ const columns = [
4115
+ {
4116
+ type: "expand",
4117
+ component: _sfc_main$S,
4118
+ props: (row) => ({
4119
+ initValues: row.data,
4120
+ language: "json",
4121
+ height: "150px",
4122
+ options: {
4123
+ readOnly: true
4124
+ }
4125
+ })
4126
+ },
4127
+ {
4128
+ label: "名称",
4129
+ prop: "title"
4130
+ },
4131
+ {
4132
+ label: "描述",
4133
+ prop: "description"
4134
+ },
4135
+ {
4136
+ label: "是否启用",
4137
+ prop: "enable",
4138
+ type: "component",
4139
+ component: design.TMagicSwitch,
4140
+ props: (row) => ({
4141
+ modelValue: row.enable,
4142
+ activeValue: true,
4143
+ inactiveValue: false
4144
+ }),
4145
+ listeners: (row, index) => ({
4146
+ "update:modelValue": (v) => {
4147
+ toggleValue(row, "enable", v, index);
4148
+ }
4149
+ })
4150
+ },
4151
+ {
4152
+ label: "编辑器中使用",
4153
+ prop: "useInEditor",
4154
+ type: "component",
4155
+ component: design.TMagicSwitch,
4156
+ props: (row) => ({
4157
+ modelValue: row.useInEditor,
4158
+ activeValue: true,
4159
+ inactiveValue: false
4160
+ }),
4161
+ listeners: (row, index) => ({
4162
+ "update:modelValue": (v) => {
4163
+ toggleValue(row, "useInEditor", v, index);
4164
+ }
4165
+ })
4166
+ },
4167
+ {
4168
+ label: "操作",
4169
+ fixed: "right",
4170
+ actions: [
4171
+ {
4172
+ text: "编辑",
4173
+ handler: (row, index) => {
4174
+ formValues.value = {
4175
+ ...row,
4176
+ index
4177
+ };
4178
+ drawerTitle.value = `编辑${row.title}`;
4179
+ addDialog.value?.show();
4180
+ }
4181
+ },
4182
+ {
4183
+ text: "删除",
4184
+ buttonType: "danger",
4185
+ handler: async (row, index) => {
4186
+ await design.tMagicMessageBox.confirm(`确定删除${row.title}?`, "提示");
4187
+ props.model[props.name].splice(index, 1);
4188
+ emit("change", props.model[props.name]);
4189
+ }
4190
+ }
4191
+ ]
4192
+ }
4193
+ ];
4194
+ const newHandler = () => {
4195
+ const isFirstRow = props.model[props.name].length === 0;
4196
+ formValues.value = {
4197
+ data: utils.getDefaultValueFromFields(props.model.fields || []),
4198
+ useInEditor: isFirstRow,
4199
+ enable: isFirstRow
4200
+ };
4201
+ drawerTitle.value = "新增Mock";
4202
+ addDialog.value?.show();
4203
+ };
4204
+ const formChangeHandler = ({ index, ...value }) => {
4205
+ if (index > -1) {
4206
+ props.model[props.name][index] = value;
4207
+ } else {
4208
+ props.model[props.name].push(value);
4209
+ }
4210
+ addDialog.value?.hide();
4211
+ emit("change", props.model[props.name]);
4212
+ };
4213
+ const toggleValue = (row, key, value, index) => {
4214
+ if (value) {
4215
+ props.model[props.name].forEach((item) => {
4216
+ item[key] = false;
4217
+ });
4218
+ }
4219
+ formChangeHandler({
4220
+ ...row,
4221
+ [key]: value,
4222
+ index
4223
+ });
4224
+ };
4225
+ return (_ctx, _cache) => {
4226
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$o, [
4227
+ vue.createVNode(vue.unref(table.MagicTable), {
4228
+ data: _ctx.model[_ctx.name],
4229
+ columns
4230
+ }, null, 8, ["data"]),
4231
+ vue.createElementVNode("div", _hoisted_2$j, [
4232
+ vue.createVNode(vue.unref(design.TMagicButton), {
4233
+ size: "small",
4234
+ type: "primary",
4235
+ disabled: _ctx.disabled,
4236
+ plain: "",
4237
+ onClick: _cache[0] || (_cache[0] = ($event) => newHandler())
4238
+ }, {
4239
+ default: vue.withCtx(() => [
4240
+ vue.createTextVNode("添加")
4241
+ ]),
4242
+ _: 1
4243
+ }, 8, ["disabled"])
4244
+ ]),
4245
+ vue.createVNode(vue.unref(form.MFormDrawer), {
4246
+ ref_key: "addDialog",
4247
+ ref: addDialog,
4248
+ "label-width": "120px",
4249
+ title: drawerTitle.value,
4250
+ config: formConfig,
4251
+ values: formValues.value,
4252
+ parentValues: _ctx.model[_ctx.name],
4253
+ disabled: _ctx.disabled,
4254
+ width: width.value,
4255
+ onSubmit: formChangeHandler
4256
+ }, null, 8, ["title", "values", "parentValues", "disabled", "width"])
4257
+ ]);
4258
+ };
4259
+ }
4260
+ });
4261
+
4262
+ const _sfc_main$E = /* @__PURE__ */ vue.defineComponent({
4263
+ ...{
4264
+ name: "MEditorDataSourceSelect"
4265
+ },
4266
+ __name: "DataSourceSelect",
4267
+ props: {
4268
+ config: {},
4269
+ model: {},
4270
+ initValues: {},
4271
+ values: {},
4272
+ name: {},
4273
+ prop: {},
4274
+ disabled: { type: Boolean, default: false },
4275
+ size: {},
4276
+ lastValues: {}
4277
+ },
4278
+ emits: ["change"],
4279
+ setup(__props, { emit }) {
4280
+ const props = __props;
4281
+ const { dataSourceService } = vue.inject("services") || {};
4282
+ const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
4283
+ const selectConfig = vue.computed(() => {
4284
+ const { type, dataSourceType, ...config } = props.config;
4285
+ return {
4286
+ ...config,
4287
+ type: "select",
4288
+ valueKey: "dataSourceId",
4289
+ options: dataSources.value.filter((ds) => !dataSourceType || ds.type === dataSourceType).map((ds) => ({
4290
+ value: {
4291
+ isBindDataSource: true,
4292
+ dataSourceType: ds.type,
4293
+ dataSourceId: ds.id
4294
+ },
4295
+ text: ds.title || ds.id
4296
+ }))
4297
+ };
4298
+ });
4299
+ const changeHandler = (value) => {
4300
+ emit("change", value);
4301
+ };
4302
+ return (_ctx, _cache) => {
4303
+ return vue.openBlock(), vue.createBlock(vue.unref(form.MSelect), {
4304
+ model: _ctx.model,
4305
+ name: _ctx.name,
4306
+ size: _ctx.size,
4307
+ prop: _ctx.prop,
4308
+ disabled: _ctx.disabled,
4309
+ config: selectConfig.value,
4310
+ "last-values": _ctx.lastValues,
4311
+ onChange: changeHandler
4312
+ }, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]);
4313
+ };
4314
+ }
4315
+ });
4316
+
4317
+ const _hoisted_1$n = { class: "m-fields-event-select" };
4318
+ const _hoisted_2$i = {
4319
+ key: 1,
4320
+ class: "fullWidth"
4321
+ };
4322
+ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
4323
+ ...{
4324
+ name: "MEditorEventSelect"
4325
+ },
4326
+ __name: "EventSelect",
4327
+ props: {
4328
+ config: {},
4329
+ model: {},
4330
+ initValues: {},
4331
+ values: {},
4332
+ name: {},
4333
+ prop: {},
4334
+ disabled: { type: Boolean },
4335
+ size: {},
4336
+ lastValues: {}
4337
+ },
4338
+ emits: ["change"],
4339
+ setup(__props, { emit }) {
4340
+ const props = __props;
4341
+ const services = vue.inject("services");
4342
+ const editorService = services?.editorService;
4343
+ const dataSourceService = services?.dataSourceService;
4344
+ const eventsService = services?.eventsService;
4345
+ const codeBlockService = services?.codeBlockService;
4346
+ const eventNameConfig = vue.computed(() => {
4347
+ const defaultEventNameConfig = {
4348
+ name: "name",
4349
+ text: "事件",
4350
+ type: "select",
4351
+ labelWidth: "40px",
4352
+ options: (mForm, { formValue }) => {
4353
+ let events = [];
4354
+ if (!eventsService || !dataSourceService)
4355
+ return events;
4356
+ if (props.config.src === "component") {
4357
+ events = eventsService.getEvent(formValue.type);
4358
+ } else if (props.config.src === "datasource") {
4359
+ events = dataSourceService.getFormEvent(formValue.type);
4360
+ }
4361
+ return events.map((option) => ({
4362
+ text: option.label,
4363
+ value: option.value
4364
+ }));
4365
+ }
4366
+ };
4367
+ return { ...defaultEventNameConfig, ...props.config.eventNameConfig };
4368
+ });
4369
+ const actionTypeConfig = vue.computed(() => {
4370
+ const defaultActionTypeConfig = {
4371
+ name: "actionType",
4372
+ text: "联动类型",
4373
+ labelWidth: "80px",
4374
+ type: "select",
4375
+ defaultValue: schema.ActionType.COMP,
4376
+ options: () => [
4377
+ {
4378
+ text: "组件",
4379
+ label: "组件",
4380
+ value: schema.ActionType.COMP
4381
+ },
4382
+ {
4383
+ text: "代码",
4384
+ label: "代码",
4385
+ disabled: !Object.keys(codeBlockService?.getCodeDsl() || {}).length,
4386
+ value: schema.ActionType.CODE
4387
+ },
4388
+ {
4389
+ text: "数据源",
4390
+ label: "数据源",
4391
+ disabled: !dataSourceService?.get("dataSources")?.filter((ds) => ds.methods?.length || dataSourceService?.getFormMethod(ds.type).length).length,
4392
+ value: schema.ActionType.DATA_SOURCE
4393
+ }
4394
+ ]
4395
+ };
4396
+ return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
4397
+ });
4398
+ const targetCompConfig = vue.computed(() => {
4399
+ const defaultTargetCompConfig = {
4400
+ name: "to",
4401
+ text: "联动组件",
4402
+ labelWidth: "80px",
4403
+ type: "ui-select",
4404
+ display: (mForm, { model }) => model.actionType === schema.ActionType.COMP
4405
+ };
4406
+ return { ...defaultTargetCompConfig, ...props.config.targetCompConfig };
4407
+ });
4408
+ const compActionConfig = vue.computed(() => {
3959
4409
  const defaultCompActionConfig = {
3960
4410
  name: "method",
3961
4411
  text: "动作",
@@ -3963,10 +4413,10 @@
3963
4413
  type: "select",
3964
4414
  display: (mForm, { model }) => model.actionType === schema.ActionType.COMP,
3965
4415
  options: (mForm, { model }) => {
3966
- const node = services?.editorService.getNodeById(model.to);
4416
+ const node = editorService?.getNodeById(model.to);
3967
4417
  if (!node?.type)
3968
4418
  return [];
3969
- return services?.eventsService.getMethod(node.type).map((option) => ({
4419
+ return eventsService?.getMethod(node.type).map((option) => ({
3970
4420
  text: option.label,
3971
4421
  value: option.value
3972
4422
  }));
@@ -3979,7 +4429,7 @@
3979
4429
  type: "code-select-col",
3980
4430
  labelWidth: 0,
3981
4431
  name: "codeId",
3982
- disabled: () => !services?.codeBlockService.getEditStatus(),
4432
+ disabled: () => !codeBlockService?.getEditStatus(),
3983
4433
  display: (mForm, { model }) => model.actionType === schema.ActionType.CODE
3984
4434
  };
3985
4435
  return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
@@ -4001,7 +4451,7 @@
4001
4451
  name: "name",
4002
4452
  label: "事件名",
4003
4453
  type: eventNameConfig.value.type,
4004
- options: (mForm, { formValue }) => services?.eventsService.getEvent(formValue.type).map((option) => ({
4454
+ options: (mForm, { formValue }) => eventsService?.getEvent(formValue.type).map((option) => ({
4005
4455
  text: option.label,
4006
4456
  value: option.value
4007
4457
  }))
@@ -4016,10 +4466,10 @@
4016
4466
  label: "动作",
4017
4467
  type: compActionConfig.value.type,
4018
4468
  options: (mForm, { model }) => {
4019
- const node = services?.editorService.getNodeById(model.to);
4469
+ const node = editorService?.getNodeById(model.to);
4020
4470
  if (!node?.type)
4021
4471
  return [];
4022
- return services?.eventsService.getMethod(node.type).map((option) => ({
4472
+ return eventsService?.getMethod(node.type).map((option) => ({
4023
4473
  text: option.label,
4024
4474
  value: option.value
4025
4475
  }));
@@ -4073,7 +4523,7 @@
4073
4523
  const _component_m_form_table = vue.resolveComponent("m-form-table");
4074
4524
  const _component_m_form_container = vue.resolveComponent("m-form-container");
4075
4525
  const _component_m_form_panel = vue.resolveComponent("m-form-panel");
4076
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$o, [
4526
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$n, [
4077
4527
  isOldVersion.value ? (vue.openBlock(), vue.createBlock(_component_m_form_table, {
4078
4528
  key: 0,
4079
4529
  ref: "eventForm",
@@ -4083,7 +4533,7 @@
4083
4533
  model: _ctx.model,
4084
4534
  config: tableConfig.value,
4085
4535
  onChange: onChangeHandler
4086
- }, null, 8, ["size", "disabled", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$h, [
4536
+ }, null, 8, ["size", "disabled", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$i, [
4087
4537
  vue.createVNode(vue.unref(design.TMagicButton), {
4088
4538
  class: "create-button",
4089
4539
  type: "primary",
@@ -4132,9 +4582,9 @@
4132
4582
  }
4133
4583
  });
4134
4584
 
4135
- const _hoisted_1$n = { class: "m-fields-key-value" };
4136
- const _hoisted_2$g = /* @__PURE__ */ vue.createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
4137
- const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
4585
+ const _hoisted_1$m = { class: "m-fields-key-value" };
4586
+ const _hoisted_2$h = /* @__PURE__ */ vue.createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
4587
+ const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
4138
4588
  ...{
4139
4589
  name: "MEditorKeyValue"
4140
4590
  },
@@ -4179,7 +4629,7 @@
4179
4629
  records.value.splice(index, 1);
4180
4630
  };
4181
4631
  return (_ctx, _cache) => {
4182
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$n, [
4632
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
4183
4633
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(records.value, (item, index) => {
4184
4634
  return vue.openBlock(), vue.createElementBlock("div", {
4185
4635
  class: "m-fields-key-value-item",
@@ -4193,7 +4643,7 @@
4193
4643
  size: _ctx.size,
4194
4644
  onChange: keyChangeHandler
4195
4645
  }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "size"]),
4196
- _hoisted_2$g,
4646
+ _hoisted_2$h,
4197
4647
  vue.createVNode(vue.unref(design.TMagicInput), {
4198
4648
  placeholder: "value",
4199
4649
  modelValue: records.value[index][1],
@@ -4232,12 +4682,12 @@
4232
4682
  }
4233
4683
  });
4234
4684
 
4235
- const _hoisted_1$m = {
4685
+ const _hoisted_1$l = {
4236
4686
  key: 1,
4237
4687
  class: "m-fields-ui-select",
4238
4688
  style: { "display": "flex" }
4239
4689
  };
4240
- const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
4690
+ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
4241
4691
  ...{
4242
4692
  name: "MEditorUISelect"
4243
4693
  },
@@ -4326,7 +4776,7 @@
4326
4776
  ]),
4327
4777
  _: 1
4328
4778
  }, 8, ["icon", "disabled", "size"])
4329
- ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
4779
+ ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
4330
4780
  val.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
4331
4781
  vue.createVNode(vue.unref(design.TMagicTooltip), {
4332
4782
  content: "清除",
@@ -4423,7 +4873,7 @@
4423
4873
  };
4424
4874
  };
4425
4875
 
4426
- const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
4876
+ const _sfc_main$A = /* @__PURE__ */ vue.defineComponent({
4427
4877
  ...{
4428
4878
  name: "MEditorResizer"
4429
4879
  },
@@ -4444,7 +4894,7 @@
4444
4894
  }
4445
4895
  });
4446
4896
 
4447
- const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
4897
+ const _sfc_main$z = /* @__PURE__ */ vue.defineComponent({
4448
4898
  ...{
4449
4899
  name: "MEditorLayout"
4450
4900
  },
@@ -4556,7 +5006,7 @@
4556
5006
  }, [
4557
5007
  vue.renderSlot(_ctx.$slots, "left")
4558
5008
  ], 6),
4559
- vue.createVNode(_sfc_main$z, { onChange: changeLeft })
5009
+ vue.createVNode(_sfc_main$A, { onChange: changeLeft })
4560
5010
  ], 64)) : vue.createCommentVNode("", true),
4561
5011
  vue.createElementVNode("div", {
4562
5012
  class: vue.normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
@@ -4565,7 +5015,7 @@
4565
5015
  vue.renderSlot(_ctx.$slots, "center")
4566
5016
  ], 6),
4567
5017
  hasRight.value && _ctx.$slots.right ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
4568
- vue.createVNode(_sfc_main$z, { onChange: changeRight }),
5018
+ vue.createVNode(_sfc_main$A, { onChange: changeRight }),
4569
5019
  vue.createElementVNode("div", {
4570
5020
  class: vue.normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
4571
5021
  style: vue.normalizeStyle(`width: ${_ctx.right}px`)
@@ -4578,10 +5028,10 @@
4578
5028
  }
4579
5029
  });
4580
5030
 
4581
- const _hoisted_1$l = { class: "m-editor-empty-panel" };
4582
- const _hoisted_2$f = { class: "m-editor-empty-content" };
4583
- const _hoisted_3$8 = /* @__PURE__ */ vue.createElementVNode("p", null, "新增页面", -1);
4584
- const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
5031
+ const _hoisted_1$k = { class: "m-editor-empty-panel" };
5032
+ const _hoisted_2$g = { class: "m-editor-empty-content" };
5033
+ const _hoisted_3$9 = /* @__PURE__ */ vue.createElementVNode("p", null, "新增页面", -1);
5034
+ const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
4585
5035
  ...{
4586
5036
  name: "MEditorAddPageBox"
4587
5037
  },
@@ -4601,16 +5051,16 @@
4601
5051
  });
4602
5052
  };
4603
5053
  return (_ctx, _cache) => {
4604
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
4605
- vue.createElementVNode("div", _hoisted_2$f, [
5054
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, [
5055
+ vue.createElementVNode("div", _hoisted_2$g, [
4606
5056
  vue.createElementVNode("div", {
4607
5057
  class: "m-editor-empty-button",
4608
5058
  onClick: clickHandler
4609
5059
  }, [
4610
5060
  vue.createElementVNode("div", null, [
4611
- vue.createVNode(_sfc_main$K, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
5061
+ vue.createVNode(_sfc_main$M, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
4612
5062
  ]),
4613
- _hoisted_3$8
5063
+ _hoisted_3$9
4614
5064
  ])
4615
5065
  ])
4616
5066
  ]);
@@ -4622,7 +5072,7 @@
4622
5072
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
4623
5073
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
4624
5074
  const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
4625
- const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
5075
+ const _sfc_main$x = /* @__PURE__ */ vue.defineComponent({
4626
5076
  ...{
4627
5077
  name: "MEditorFramework"
4628
5078
  },
@@ -4699,13 +5149,13 @@
4699
5149
  vue.renderSlot(_ctx.$slots, "nav"),
4700
5150
  vue.renderSlot(_ctx.$slots, "content-before"),
4701
5151
  showSrc.value ? vue.renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
4702
- vue.createVNode(_sfc_main$Q, {
5152
+ vue.createVNode(_sfc_main$S, {
4703
5153
  class: "m-editor-content",
4704
5154
  "init-values": root.value,
4705
5155
  options: vue.unref(codeOptions),
4706
5156
  onSave: saveCode
4707
5157
  }, null, 8, ["init-values", "options"])
4708
- ]) : (vue.openBlock(), vue.createBlock(_sfc_main$y, {
5158
+ ]) : (vue.openBlock(), vue.createBlock(_sfc_main$z, {
4709
5159
  key: 1,
4710
5160
  class: "m-editor-content",
4711
5161
  "left-class": "m-editor-framework-left",
@@ -4724,7 +5174,7 @@
4724
5174
  ]),
4725
5175
  center: vue.withCtx(() => [
4726
5176
  pageLength.value > 0 ? vue.renderSlot(_ctx.$slots, "workspace", { key: 0 }) : vue.renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
4727
- vue.createVNode(_sfc_main$x)
5177
+ vue.createVNode(_sfc_main$y)
4728
5178
  ])
4729
5179
  ]),
4730
5180
  _: 2
@@ -4749,12 +5199,12 @@
4749
5199
  }
4750
5200
  });
4751
5201
 
4752
- const _hoisted_1$k = {
5202
+ const _hoisted_1$j = {
4753
5203
  key: 1,
4754
5204
  class: "menu-item-text"
4755
5205
  };
4756
- const _hoisted_2$e = { class: "el-dropdown-link menubar-menu-button" };
4757
- const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
5206
+ const _hoisted_2$f = { class: "el-dropdown-link menubar-menu-button" };
5207
+ const _sfc_main$w = /* @__PURE__ */ vue.defineComponent({
4758
5208
  ...{
4759
5209
  name: "MEditorToolButton"
4760
5210
  },
@@ -4833,7 +5283,7 @@
4833
5283
  _ctx.data.type === "divider" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDivider), {
4834
5284
  key: 0,
4835
5285
  direction: _ctx.data.direction || "vertical"
4836
- }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, vue.toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
5286
+ }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$j, vue.toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
4837
5287
  _ctx.data.tooltip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
4838
5288
  key: 0,
4839
5289
  effect: "dark",
@@ -4847,7 +5297,7 @@
4847
5297
  disabled: disabled.value
4848
5298
  }, {
4849
5299
  default: vue.withCtx(() => [
4850
- _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$K, {
5300
+ _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
4851
5301
  key: 0,
4852
5302
  icon: _ctx.data.icon
4853
5303
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -4861,17 +5311,18 @@
4861
5311
  key: 1,
4862
5312
  size: "small",
4863
5313
  text: "",
4864
- disabled: disabled.value
5314
+ disabled: disabled.value,
5315
+ title: _ctx.data.text
4865
5316
  }, {
4866
5317
  default: vue.withCtx(() => [
4867
- _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$K, {
5318
+ _ctx.data.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
4868
5319
  key: 0,
4869
5320
  icon: _ctx.data.icon
4870
5321
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
4871
5322
  vue.createElementVNode("span", null, vue.toDisplayString(_ctx.data.text), 1)
4872
5323
  ]),
4873
5324
  _: 1
4874
- }, 8, ["disabled"]))
5325
+ }, 8, ["disabled", "title"]))
4875
5326
  ], 64)) : _ctx.data.type === "dropdown" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDropdown), {
4876
5327
  key: 3,
4877
5328
  trigger: "click",
@@ -4897,7 +5348,7 @@
4897
5348
  })) : vue.createCommentVNode("", true)
4898
5349
  ]),
4899
5350
  default: vue.withCtx(() => [
4900
- vue.createElementVNode("span", _hoisted_2$e, [
5351
+ vue.createElementVNode("span", _hoisted_2$f, [
4901
5352
  vue.createTextVNode(vue.toDisplayString(_ctx.data.text), 1),
4902
5353
  vue.createVNode(vue.unref(design.TMagicIcon), { class: "el-icon--right" }, {
4903
5354
  default: vue.withCtx(() => [
@@ -4914,7 +5365,7 @@
4914
5365
  }
4915
5366
  });
4916
5367
 
4917
- const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
5368
+ const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
4918
5369
  ...{
4919
5370
  name: "MEditorNavMenu"
4920
5371
  },
@@ -5076,7 +5527,7 @@
5076
5527
  style: vue.normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
5077
5528
  }, [
5078
5529
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(buttons.value[key], (item, index) => {
5079
- return vue.openBlock(), vue.createBlock(_sfc_main$v, {
5530
+ return vue.openBlock(), vue.createBlock(_sfc_main$w, {
5080
5531
  data: item,
5081
5532
  key: index
5082
5533
  }, null, 8, ["data"]);
@@ -5088,8 +5539,8 @@
5088
5539
  }
5089
5540
  });
5090
5541
 
5091
- const _hoisted_1$j = { class: "m-editor-props-panel" };
5092
- const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
5542
+ const _hoisted_1$i = { class: "m-editor-props-panel" };
5543
+ const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
5093
5544
  ...{
5094
5545
  name: "MEditorPropsPanel"
5095
5546
  },
@@ -5142,7 +5593,7 @@
5142
5593
  };
5143
5594
  __expose({ configForm, submit });
5144
5595
  return (_ctx, _cache) => {
5145
- return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", _hoisted_1$j, [
5596
+ return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", _hoisted_1$i, [
5146
5597
  vue.renderSlot(_ctx.$slots, "props-panel-header"),
5147
5598
  vue.createVNode(vue.unref(form.MForm), {
5148
5599
  ref_key: "configForm",
@@ -5162,7 +5613,7 @@
5162
5613
  }
5163
5614
  });
5164
5615
 
5165
- const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
5616
+ const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
5166
5617
  ...{
5167
5618
  name: "MEditorSearchInput"
5168
5619
  },
@@ -5170,8 +5621,12 @@
5170
5621
  emits: ["search"],
5171
5622
  setup(__props, { emit }) {
5172
5623
  const filterText = vue.ref("");
5624
+ let timer = null;
5173
5625
  const filterTextChangeHandler = () => {
5174
- emit("search", filterText.value);
5626
+ timer && clearTimeout(timer);
5627
+ timer = setTimeout(() => {
5628
+ emit("search", filterText.value);
5629
+ }, 300);
5175
5630
  };
5176
5631
  return (_ctx, _cache) => {
5177
5632
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInput), {
@@ -5197,8 +5652,8 @@
5197
5652
  }
5198
5653
  });
5199
5654
 
5200
- const _hoisted_1$i = { xmlns: "http://www.w3.org/2000/svg" };
5201
- const _hoisted_2$d = /* @__PURE__ */ vue.createElementVNode("g", {
5655
+ const _hoisted_1$h = { xmlns: "http://www.w3.org/2000/svg" };
5656
+ const _hoisted_2$e = /* @__PURE__ */ vue.createElementVNode("g", {
5202
5657
  fill: "#7C878E",
5203
5658
  "fill-rule": "evenodd"
5204
5659
  }, [
@@ -5208,50 +5663,50 @@
5208
5663
  }),
5209
5664
  /* @__PURE__ */ vue.createElementVNode("path", { d: "M8 13.5L2.3 9.2 0.7 10.5 8 16 15.3 10.5 13.7 9.2z" })
5210
5665
  ], -1);
5211
- const _hoisted_3$7 = [
5212
- _hoisted_2$d
5666
+ const _hoisted_3$8 = [
5667
+ _hoisted_2$e
5213
5668
  ];
5214
- const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
5669
+ const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
5215
5670
  ...{
5216
5671
  name: "MEditorAppManageIcon"
5217
5672
  },
5218
5673
  __name: "AppManageIcon",
5219
5674
  setup(__props) {
5220
5675
  return (_ctx, _cache) => {
5221
- return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$i, _hoisted_3$7);
5676
+ return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$h, _hoisted_3$8);
5222
5677
  };
5223
5678
  }
5224
5679
  });
5225
5680
 
5226
- const _hoisted_1$h = {
5681
+ const _hoisted_1$g = {
5227
5682
  viewBox: "0 0 32 32",
5228
5683
  version: "1.1",
5229
5684
  xmlns: "http://www.w3.org/2000/svg",
5230
5685
  "xmlns:xlink": "http://www.w3.org/1999/xlink"
5231
5686
  };
5232
- const _hoisted_2$c = /* @__PURE__ */ vue.createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2);
5233
- const _hoisted_4$5 = [
5234
- _hoisted_2$c
5687
+ const _hoisted_2$d = /* @__PURE__ */ vue.createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2);
5688
+ const _hoisted_4$6 = [
5689
+ _hoisted_2$d
5235
5690
  ];
5236
- const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
5691
+ const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
5237
5692
  ...{
5238
5693
  name: "MEditorCodeIcon"
5239
5694
  },
5240
5695
  __name: "CodeIcon",
5241
5696
  setup(__props) {
5242
5697
  return (_ctx, _cache) => {
5243
- return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$h, _hoisted_4$5);
5698
+ return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$g, _hoisted_4$6);
5244
5699
  };
5245
5700
  }
5246
5701
  });
5247
5702
 
5248
- const _hoisted_1$g = ["id"];
5249
- const _hoisted_2$b = { class: "list-item" };
5250
- const _hoisted_3$6 = {
5703
+ const _hoisted_1$f = ["id"];
5704
+ const _hoisted_2$c = { class: "list-item" };
5705
+ const _hoisted_3$7 = {
5251
5706
  key: 2,
5252
5707
  class: "right-tool"
5253
5708
  };
5254
- const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
5709
+ const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
5255
5710
  ...{
5256
5711
  name: "MEditorCodeBlockList"
5257
5712
  },
@@ -5352,26 +5807,26 @@
5352
5807
  id: data.id,
5353
5808
  class: "list-container"
5354
5809
  }, [
5355
- vue.createElementVNode("div", _hoisted_2$b, [
5356
- data.type === "code" ? (vue.openBlock(), vue.createBlock(_sfc_main$q, {
5810
+ vue.createElementVNode("div", _hoisted_2$c, [
5811
+ data.type === "code" ? (vue.openBlock(), vue.createBlock(_sfc_main$r, {
5357
5812
  key: 0,
5358
5813
  class: "codeIcon"
5359
5814
  })) : vue.createCommentVNode("", true),
5360
- data.type === "node" ? (vue.openBlock(), vue.createBlock(_sfc_main$r, {
5815
+ data.type === "node" ? (vue.openBlock(), vue.createBlock(_sfc_main$s, {
5361
5816
  key: 1,
5362
5817
  class: "compIcon"
5363
5818
  })) : vue.createCommentVNode("", true),
5364
5819
  vue.createElementVNode("span", {
5365
5820
  class: vue.normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
5366
5821
  }, vue.toDisplayString(data.name) + " (" + vue.toDisplayString(data.id) + ")", 3),
5367
- data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$6, [
5822
+ data.type === "code" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$7, [
5368
5823
  vue.createVNode(vue.unref(design.TMagicTooltip), {
5369
5824
  effect: "dark",
5370
5825
  content: editable.value ? "编辑" : "查看",
5371
5826
  placement: "bottom"
5372
5827
  }, {
5373
5828
  default: vue.withCtx(() => [
5374
- vue.createVNode(_sfc_main$K, {
5829
+ vue.createVNode(_sfc_main$M, {
5375
5830
  icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
5376
5831
  class: "edit-icon",
5377
5832
  onClick: vue.withModifiers(($event) => editCode(data.id), ["stop"])
@@ -5386,7 +5841,7 @@
5386
5841
  placement: "bottom"
5387
5842
  }, {
5388
5843
  default: vue.withCtx(() => [
5389
- vue.createVNode(_sfc_main$K, {
5844
+ vue.createVNode(_sfc_main$M, {
5390
5845
  icon: vue.unref(iconsVue.Close),
5391
5846
  class: "edit-icon",
5392
5847
  onClick: vue.withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
@@ -5400,7 +5855,7 @@
5400
5855
  })
5401
5856
  ])) : vue.createCommentVNode("", true)
5402
5857
  ])
5403
- ], 8, _hoisted_1$g)
5858
+ ], 8, _hoisted_1$f)
5404
5859
  ]),
5405
5860
  _: 3
5406
5861
  }, 8, ["default-expanded-keys", "data"]);
@@ -5408,8 +5863,8 @@
5408
5863
  }
5409
5864
  });
5410
5865
 
5411
- const _hoisted_1$f = { class: "search-wrapper" };
5412
- const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
5866
+ const _hoisted_1$e = { class: "search-wrapper" };
5867
+ const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
5413
5868
  ...{
5414
5869
  name: "MEditorCodeBlockListPanel"
5415
5870
  },
@@ -5429,8 +5884,8 @@
5429
5884
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
5430
5885
  default: vue.withCtx(() => [
5431
5886
  vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
5432
- vue.createElementVNode("div", _hoisted_1$f, [
5433
- vue.createVNode(_sfc_main$s, { onSearch: filterTextChangeHandler }),
5887
+ vue.createElementVNode("div", _hoisted_1$e, [
5888
+ vue.createVNode(_sfc_main$t, { onSearch: filterTextChangeHandler }),
5434
5889
  editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5435
5890
  key: 0,
5436
5891
  class: "create-code-button",
@@ -5446,7 +5901,7 @@
5446
5901
  vue.renderSlot(_ctx.$slots, "code-block-panel-search")
5447
5902
  ])
5448
5903
  ]),
5449
- vue.createVNode(_sfc_main$p, {
5904
+ vue.createVNode(_sfc_main$q, {
5450
5905
  ref_key: "codeBlockList",
5451
5906
  ref: codeBlockList,
5452
5907
  "custom-error": _ctx.customError,
@@ -5461,7 +5916,7 @@
5461
5916
  ]),
5462
5917
  _: 3
5463
5918
  }, 8, ["custom-error", "onEdit", "onRemove"]),
5464
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
5919
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
5465
5920
  key: 0,
5466
5921
  ref_key: "codeBlockEditor",
5467
5922
  ref: codeBlockEditor,
@@ -5476,7 +5931,7 @@
5476
5931
  }
5477
5932
  });
5478
5933
 
5479
- const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
5934
+ const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
5480
5935
  ...{
5481
5936
  name: "MEditorDataSourceConfigPanel"
5482
5937
  },
@@ -5530,13 +5985,13 @@
5530
5985
  }
5531
5986
  });
5532
5987
 
5533
- const _hoisted_1$e = ["id"];
5534
- const _hoisted_2$a = { class: "list-item" };
5535
- const _hoisted_3$5 = {
5988
+ const _hoisted_1$d = ["id"];
5989
+ const _hoisted_2$b = { class: "list-item" };
5990
+ const _hoisted_3$6 = {
5536
5991
  key: 2,
5537
5992
  class: "right-tool"
5538
5993
  };
5539
- const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
5994
+ const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
5540
5995
  ...{
5541
5996
  name: "MEditorDataSourceList"
5542
5997
  },
@@ -5631,13 +6086,13 @@
5631
6086
  id: data.id,
5632
6087
  class: "list-container"
5633
6088
  }, [
5634
- vue.createElementVNode("div", _hoisted_2$a, [
5635
- data.type === "code" ? (vue.openBlock(), vue.createBlock(_sfc_main$K, {
6089
+ vue.createElementVNode("div", _hoisted_2$b, [
6090
+ data.type === "code" ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
5636
6091
  key: 0,
5637
6092
  class: "codeIcon",
5638
6093
  icon: vue.unref(iconsVue.Coin)
5639
6094
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
5640
- data.type === "node" ? (vue.openBlock(), vue.createBlock(_sfc_main$K, {
6095
+ data.type === "node" ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
5641
6096
  key: 1,
5642
6097
  class: "compIcon",
5643
6098
  icon: vue.unref(iconsVue.Aim)
@@ -5645,14 +6100,14 @@
5645
6100
  vue.createElementVNode("span", {
5646
6101
  class: vue.normalizeClass(["name", { code: data.type === "ds", hook: data.type === "key" }])
5647
6102
  }, vue.toDisplayString(data.type === "key" ? data.name : `${data.name}(${data.id})`), 3),
5648
- data.type === "ds" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$5, [
6103
+ data.type === "ds" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$6, [
5649
6104
  vue.createVNode(vue.unref(design.TMagicTooltip), {
5650
6105
  effect: "dark",
5651
6106
  content: editable.value ? "编辑" : "查看",
5652
6107
  placement: "bottom"
5653
6108
  }, {
5654
6109
  default: vue.withCtx(() => [
5655
- vue.createVNode(_sfc_main$K, {
6110
+ vue.createVNode(_sfc_main$M, {
5656
6111
  icon: editable.value ? vue.unref(iconsVue.Edit) : vue.unref(iconsVue.View),
5657
6112
  class: "edit-icon",
5658
6113
  onClick: vue.withModifiers(($event) => editHandler(`${data.id}`), ["stop"])
@@ -5667,7 +6122,7 @@
5667
6122
  placement: "bottom"
5668
6123
  }, {
5669
6124
  default: vue.withCtx(() => [
5670
- vue.createVNode(_sfc_main$K, {
6125
+ vue.createVNode(_sfc_main$M, {
5671
6126
  icon: vue.unref(iconsVue.Close),
5672
6127
  class: "edit-icon",
5673
6128
  onClick: vue.withModifiers(($event) => removeHandler(`${data.id}`), ["stop"])
@@ -5681,7 +6136,7 @@
5681
6136
  })
5682
6137
  ])) : vue.createCommentVNode("", true)
5683
6138
  ])
5684
- ], 8, _hoisted_1$e)
6139
+ ], 8, _hoisted_1$d)
5685
6140
  ]),
5686
6141
  _: 3
5687
6142
  }, 8, ["data"]);
@@ -5689,9 +6144,9 @@
5689
6144
  }
5690
6145
  });
5691
6146
 
5692
- const _hoisted_1$d = { class: "search-wrapper" };
5693
- const _hoisted_2$9 = { class: "data-source-list-panel-add-menu" };
5694
- const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
6147
+ const _hoisted_1$c = { class: "search-wrapper" };
6148
+ const _hoisted_2$a = { class: "data-source-list-panel-add-menu" };
6149
+ const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
5695
6150
  ...{
5696
6151
  name: "MEditorDataSourceListPanel"
5697
6152
  },
@@ -5751,8 +6206,8 @@
5751
6206
  return (_ctx, _cache) => {
5752
6207
  return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
5753
6208
  default: vue.withCtx(() => [
5754
- vue.createElementVNode("div", _hoisted_1$d, [
5755
- vue.createVNode(_sfc_main$s, { onSearch: filterTextChangeHandler }),
6209
+ vue.createElementVNode("div", _hoisted_1$c, [
6210
+ vue.createVNode(_sfc_main$t, { onSearch: filterTextChangeHandler }),
5756
6211
  editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicPopover), {
5757
6212
  key: 0,
5758
6213
  placement: "right"
@@ -5769,9 +6224,9 @@
5769
6224
  })
5770
6225
  ]),
5771
6226
  default: vue.withCtx(() => [
5772
- vue.createElementVNode("div", _hoisted_2$9, [
6227
+ vue.createElementVNode("div", _hoisted_2$a, [
5773
6228
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(datasourceTypeList.value, (item, index) => {
5774
- return vue.openBlock(), vue.createBlock(_sfc_main$v, {
6229
+ return vue.openBlock(), vue.createBlock(_sfc_main$w, {
5775
6230
  data: {
5776
6231
  type: "button",
5777
6232
  text: item.text,
@@ -5787,11 +6242,11 @@
5787
6242
  _: 1
5788
6243
  })) : vue.createCommentVNode("", true)
5789
6244
  ]),
5790
- vue.createVNode(_sfc_main$m, {
6245
+ vue.createVNode(_sfc_main$n, {
5791
6246
  onEdit: editHandler,
5792
6247
  onRemove: removeHandler
5793
6248
  }),
5794
- vue.createVNode(_sfc_main$n, {
6249
+ vue.createVNode(_sfc_main$o, {
5795
6250
  ref_key: "editDialog",
5796
6251
  ref: editDialog,
5797
6252
  disabled: !editable.value,
@@ -5806,136 +6261,7 @@
5806
6261
  }
5807
6262
  });
5808
6263
 
5809
- const _hoisted_1$c = ["onClick", "onDragstart"];
5810
- const _hoisted_2$8 = ["title"];
5811
- const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
5812
- ...{
5813
- name: "MEditorComponentListPanel"
5814
- },
5815
- __name: "ComponentListPanel",
5816
- setup(__props) {
5817
- const searchText = vue.ref("");
5818
- const filterTextChangeHandler = (v) => {
5819
- searchText.value = v;
5820
- };
5821
- const services = vue.inject("services");
5822
- const stageOptions = vue.inject("stageOptions");
5823
- const stage = vue.computed(() => services?.editorService.get("stage"));
5824
- const list = vue.computed(
5825
- () => services?.componentListService.getList().map((group) => ({
5826
- ...group,
5827
- items: group.items.filter((item) => item.text.includes(searchText.value))
5828
- }))
5829
- );
5830
- const collapseValue = vue.computed(
5831
- () => Array(list.value?.length).fill(1).map((x, i) => `${i}`)
5832
- );
5833
- let timeout;
5834
- let clientX;
5835
- let clientY;
5836
- const appendComponent = ({ text, type, data = {} }) => {
5837
- services?.editorService.add({
5838
- name: text,
5839
- type,
5840
- ...data
5841
- });
5842
- };
5843
- const dragstartHandler = ({ text, type, data = {} }, e) => {
5844
- if (e.dataTransfer) {
5845
- e.dataTransfer.setData(
5846
- "text/json",
5847
- serialize({
5848
- name: text,
5849
- type,
5850
- ...data
5851
- })
5852
- );
5853
- }
5854
- };
5855
- const dragendHandler = () => {
5856
- if (timeout) {
5857
- globalThis.clearTimeout(timeout);
5858
- timeout = void 0;
5859
- }
5860
- const doc = stage.value?.renderer.contentWindow?.document;
5861
- if (doc && stageOptions) {
5862
- utils.removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
5863
- }
5864
- clientX = 0;
5865
- clientY = 0;
5866
- };
5867
- const dragHandler = (e) => {
5868
- if (e.clientX !== clientX || e.clientY !== clientY) {
5869
- clientX = e.clientX;
5870
- clientY = e.clientY;
5871
- if (timeout) {
5872
- globalThis.clearTimeout(timeout);
5873
- timeout = void 0;
5874
- }
5875
- return;
5876
- }
5877
- if (timeout || !stage.value)
5878
- return;
5879
- timeout = stage.value.delayedMarkContainer(e);
5880
- };
5881
- return (_ctx, _cache) => {
5882
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), null, {
5883
- default: vue.withCtx(() => [
5884
- vue.renderSlot(_ctx.$slots, "component-list-panel-header"),
5885
- vue.createVNode(vue.unref(design.TMagicCollapse), {
5886
- class: "ui-component-panel",
5887
- "model-value": collapseValue.value
5888
- }, {
5889
- default: vue.withCtx(() => [
5890
- vue.createVNode(_sfc_main$s, { onSearch: filterTextChangeHandler }),
5891
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.value, (group, index) => {
5892
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
5893
- group.items && group.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCollapseItem), {
5894
- key: index,
5895
- name: `${index}`
5896
- }, {
5897
- title: vue.withCtx(() => [
5898
- vue.createVNode(_sfc_main$K, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
5899
- vue.createTextVNode(vue.toDisplayString(group.title), 1)
5900
- ]),
5901
- default: vue.withCtx(() => [
5902
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.items, (item) => {
5903
- return vue.openBlock(), vue.createElementBlock("div", {
5904
- class: "component-item",
5905
- draggable: "true",
5906
- key: item.type,
5907
- onClick: ($event) => appendComponent(item),
5908
- onDragstart: ($event) => dragstartHandler(item, $event),
5909
- onDragend: dragendHandler,
5910
- onDrag: dragHandler
5911
- }, [
5912
- vue.renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
5913
- vue.createVNode(_sfc_main$K, {
5914
- title: item.text,
5915
- icon: item.icon
5916
- }, null, 8, ["title", "icon"]),
5917
- vue.createElementVNode("span", {
5918
- title: item.text
5919
- }, vue.toDisplayString(item.text), 9, _hoisted_2$8)
5920
- ])
5921
- ], 40, _hoisted_1$c);
5922
- }), 128))
5923
- ]),
5924
- _: 2
5925
- }, 1032, ["name"])) : vue.createCommentVNode("", true)
5926
- ], 64);
5927
- }), 256))
5928
- ]),
5929
- _: 3
5930
- }, 8, ["model-value"])
5931
- ]),
5932
- _: 3
5933
- });
5934
- };
5935
- }
5936
- });
5937
-
5938
- const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
6264
+ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
5939
6265
  ...{
5940
6266
  name: "MEditorContentMenu"
5941
6267
  },
@@ -6012,11 +6338,14 @@
6012
6338
  };
6013
6339
  const showSubMenu = (item, index) => {
6014
6340
  const menuItem = item;
6015
- if (typeof item !== "object" || !menuItem.items?.length) {
6341
+ if (typeof item !== "object") {
6016
6342
  return;
6017
6343
  }
6018
6344
  subMenuData.value = menuItem.items || [];
6019
6345
  setTimeout(() => {
6346
+ if (!visible.value) {
6347
+ return;
6348
+ }
6020
6349
  if (menu.value) {
6021
6350
  let y = menu.value.offsetTop;
6022
6351
  if (buttons.value?.[index].$el) {
@@ -6065,7 +6394,7 @@
6065
6394
  vue.renderSlot(_ctx.$slots, "title"),
6066
6395
  vue.createElementVNode("div", null, [
6067
6396
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.menuData, (item, index) => {
6068
- return vue.openBlock(), vue.createBlock(_sfc_main$v, {
6397
+ return vue.openBlock(), vue.createBlock(_sfc_main$w, {
6069
6398
  "event-type": "mouseup",
6070
6399
  ref_for: true,
6071
6400
  ref_key: "buttons",
@@ -6108,26 +6437,26 @@
6108
6437
  fill: "currentColor",
6109
6438
  xmlns: "http://www.w3.org/2000/svg"
6110
6439
  };
6111
- const _hoisted_2$7 = /* @__PURE__ */ vue.createElementVNode("path", {
6440
+ const _hoisted_2$9 = /* @__PURE__ */ vue.createElementVNode("path", {
6112
6441
  "fill-rule": "evenodd",
6113
6442
  d: "M9.828 4H2.19a1 1 0 0 0-.996 1.09l.637 7a1 1 0 0 0 .995.91H9v1H2.826a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31L.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181L15.546 8H14.54l.265-2.91A1 1 0 0 0 13.81 4H9.828zm-2.95-1.707L7.587 3H2.19c-.24 0-.47.042-.684.12L1.5 2.98a1 1 0 0 1 1-.98h3.672a1 1 0 0 1 .707.293z"
6114
6443
  }, null, -1);
6115
- const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("path", {
6444
+ const _hoisted_3$5 = /* @__PURE__ */ vue.createElementVNode("path", {
6116
6445
  "fill-rule": "evenodd",
6117
6446
  d: "M11 11.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5z"
6118
6447
  }, null, -1);
6119
- const _hoisted_4$4 = [
6120
- _hoisted_2$7,
6121
- _hoisted_3$4
6448
+ const _hoisted_4$5 = [
6449
+ _hoisted_2$9,
6450
+ _hoisted_3$5
6122
6451
  ];
6123
- const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
6452
+ const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
6124
6453
  ...{
6125
6454
  name: "MEditorFolderMinusIcon"
6126
6455
  },
6127
6456
  __name: "FolderMinusIcon",
6128
6457
  setup(__props) {
6129
6458
  return (_ctx, _cache) => {
6130
- return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$b, _hoisted_4$4);
6459
+ return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$b, _hoisted_4$5);
6131
6460
  };
6132
6461
  }
6133
6462
  });
@@ -6207,7 +6536,7 @@
6207
6536
  };
6208
6537
  };
6209
6538
 
6210
- const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
6539
+ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
6211
6540
  ...{
6212
6541
  name: "MEditorLayerMenu"
6213
6542
  },
@@ -6270,7 +6599,7 @@
6270
6599
  {
6271
6600
  type: "button",
6272
6601
  text: "全部折叠",
6273
- icon: _sfc_main$i,
6602
+ icon: _sfc_main$k,
6274
6603
  display: () => utils.isPage(node.value),
6275
6604
  handler: () => {
6276
6605
  emit("collapse-all");
@@ -6296,7 +6625,7 @@
6296
6625
  show
6297
6626
  });
6298
6627
  return (_ctx, _cache) => {
6299
- return vue.openBlock(), vue.createBlock(_sfc_main$j, {
6628
+ return vue.openBlock(), vue.createBlock(_sfc_main$l, {
6300
6629
  "menu-data": menuData.value,
6301
6630
  ref_key: "menu",
6302
6631
  ref: menu,
@@ -6306,9 +6635,8 @@
6306
6635
  }
6307
6636
  });
6308
6637
 
6309
- const _hoisted_1$a = { class: "layer-node-tool" };
6310
- const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
6311
- __name: "LayerNode",
6638
+ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
6639
+ __name: "LayerNodeTool",
6312
6640
  props: {
6313
6641
  data: {}
6314
6642
  },
@@ -6325,342 +6653,673 @@
6325
6653
  });
6326
6654
  };
6327
6655
  return (_ctx, _cache) => {
6328
- const _component_el_icon = vue.resolveComponent("el-icon");
6329
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
6330
- vue.createElementVNode("div", null, vue.toDisplayString(`${_ctx.data.name} (${_ctx.data.id})`), 1),
6331
- vue.createElementVNode("div", _hoisted_1$a, [
6332
- _ctx.data.type !== "page" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
6333
- _ctx.data.visible === false ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
6334
- key: 0,
6335
- onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => setNodeVisible(true), ["stop"])),
6336
- title: "点击显示"
6337
- }, {
6338
- default: vue.withCtx(() => [
6339
- vue.createVNode(vue.unref(iconsVue.Hide))
6340
- ]),
6341
- _: 1
6342
- })) : (vue.openBlock(), vue.createBlock(_component_el_icon, {
6343
- key: 1,
6344
- onClick: _cache[1] || (_cache[1] = vue.withModifiers(($event) => setNodeVisible(false), ["stop"])),
6345
- class: "node-lock",
6346
- title: "点击隐藏"
6347
- }, {
6348
- default: vue.withCtx(() => [
6349
- vue.createVNode(vue.unref(iconsVue.View))
6350
- ]),
6351
- _: 1
6352
- }))
6353
- ], 64)) : vue.createCommentVNode("", true)
6354
- ])
6355
- ], 64);
6656
+ return _ctx.data.type !== "page" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
6657
+ _ctx.data.visible === false ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
6658
+ key: 0,
6659
+ icon: vue.unref(iconsVue.Hide),
6660
+ onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => setNodeVisible(true), ["stop"])),
6661
+ title: "点击显示"
6662
+ }, null, 8, ["icon"])) : (vue.openBlock(), vue.createBlock(_sfc_main$M, {
6663
+ key: 1,
6664
+ icon: vue.unref(iconsVue.View),
6665
+ onClick: _cache[1] || (_cache[1] = vue.withModifiers(($event) => setNodeVisible(false), ["stop"])),
6666
+ class: "node-lock",
6667
+ title: "点击隐藏"
6668
+ }, null, 8, ["icon"]))
6669
+ ], 64)) : vue.createCommentVNode("", true);
6356
6670
  };
6357
6671
  }
6358
6672
  });
6359
6673
 
6360
- const _hoisted_1$9 = ["id", "onMouseenter"];
6361
- const throttleTime = 150;
6362
- const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
6674
+ const dragState = {
6675
+ dragOverNodeId: "",
6676
+ dropType: "",
6677
+ container: null
6678
+ };
6679
+ const getNodeEl = (el) => {
6680
+ if (el.dataset.nodeId) {
6681
+ return el;
6682
+ }
6683
+ if (el.parentElement) {
6684
+ return getNodeEl(el.parentElement);
6685
+ }
6686
+ };
6687
+ const removeStatusClass = (el) => {
6688
+ if (!el)
6689
+ return;
6690
+ ["drag-before", "drag-after", "drag-inner"].forEach((className) => {
6691
+ el.querySelectorAll(`.${className}`).forEach((el2) => {
6692
+ utils.removeClassName(el2, className);
6693
+ });
6694
+ });
6695
+ };
6696
+ const useDrag = (services) => {
6697
+ const handleDragStart = (event) => {
6698
+ if (!event.dataTransfer || !event.target || !event.currentTarget)
6699
+ return;
6700
+ const targetEl = getNodeEl(event.target);
6701
+ if (!targetEl || targetEl !== event.currentTarget)
6702
+ return;
6703
+ event.dataTransfer.effectAllowed = "move";
6704
+ try {
6705
+ event.dataTransfer.setData(
6706
+ "text/json",
6707
+ JSON.stringify({
6708
+ dragType: DragType.LAYER_TREE
6709
+ })
6710
+ );
6711
+ } catch {
6712
+ }
6713
+ };
6714
+ const handleDragOver = (event) => {
6715
+ if (!event.target)
6716
+ return;
6717
+ const targetEl = getNodeEl(event.target);
6718
+ if (!targetEl)
6719
+ return;
6720
+ const labelEl = targetEl.children[0];
6721
+ if (!labelEl)
6722
+ return;
6723
+ const { top: targetTop, height: targetHeight } = labelEl.getBoundingClientRect();
6724
+ const distance = event.clientY - targetTop;
6725
+ const isContainer = targetEl.dataset.isContainer === "true";
6726
+ if (distance < targetHeight / 3) {
6727
+ dragState.dropType = "before";
6728
+ utils.addClassName(labelEl, globalThis.document, "drag-before");
6729
+ utils.removeClassName(labelEl, "drag-after", "drag-inner");
6730
+ } else if (distance > targetHeight * 2 / 3) {
6731
+ dragState.dropType = "after";
6732
+ utils.addClassName(labelEl, globalThis.document, "drag-after");
6733
+ utils.removeClassName(labelEl, "drag-before", "drag-inner");
6734
+ } else if (isContainer) {
6735
+ dragState.dropType = "inner";
6736
+ utils.addClassName(labelEl, globalThis.document, "drag-inner");
6737
+ utils.removeClassName(labelEl, "drag-before", "drag-after");
6738
+ }
6739
+ if (!dragState.dropType) {
6740
+ return;
6741
+ }
6742
+ dragState.dragOverNodeId = targetEl.dataset.nodeId || "";
6743
+ dragState.container = event.currentTarget;
6744
+ event.preventDefault();
6745
+ };
6746
+ const handleDragLeave = (event) => {
6747
+ if (!event.target || !event.currentTarget)
6748
+ return;
6749
+ const targetEl = getNodeEl(event.target);
6750
+ if (!targetEl || targetEl !== event.currentTarget)
6751
+ return;
6752
+ const labelEl = targetEl.children[0];
6753
+ utils.removeClassName(labelEl, "drag-before", "drag-after", "drag-inner");
6754
+ };
6755
+ const handleDragEnd = (event, node) => {
6756
+ if (!event.target || !event.currentTarget)
6757
+ return;
6758
+ const targetEl = getNodeEl(event.target);
6759
+ if (!targetEl || targetEl !== event.currentTarget)
6760
+ return;
6761
+ removeStatusClass(dragState.container);
6762
+ if (node && dragState.dragOverNodeId && dragState.dropType && services) {
6763
+ const targetInfo = services.editorService.getNodeInfo(dragState.dragOverNodeId, false);
6764
+ const targetNode = targetInfo.node;
6765
+ let targetParent = targetInfo.parent;
6766
+ if (!targetParent || !targetNode)
6767
+ return;
6768
+ let targetIndex = -1;
6769
+ if (Array.isArray(targetNode.items) && dragState.dropType === "inner") {
6770
+ targetIndex = targetNode.items.length;
6771
+ targetParent = targetNode;
6772
+ } else {
6773
+ targetIndex = getNodeIndex(dragState.dragOverNodeId, targetParent);
6774
+ }
6775
+ if (dragState.dropType === "after") {
6776
+ targetIndex += 1;
6777
+ }
6778
+ services?.editorService.dragTo(node, targetParent, targetIndex);
6779
+ }
6780
+ dragState.dragOverNodeId = "";
6781
+ dragState.dropType = "";
6782
+ dragState.container = null;
6783
+ };
6784
+ return {
6785
+ handleDragStart,
6786
+ handleDragEnd,
6787
+ handleDragLeave,
6788
+ handleDragOver
6789
+ };
6790
+ };
6791
+
6792
+ const updateStatus = (nodeStatusMap, id, status) => {
6793
+ const nodeStatus = nodeStatusMap.get(id);
6794
+ if (!nodeStatus)
6795
+ return;
6796
+ utils.getKeys(status).forEach((key) => {
6797
+ if (nodeStatus[key] !== void 0 && status[key] !== void 0) {
6798
+ nodeStatus[key] = Boolean(status[key]);
6799
+ }
6800
+ });
6801
+ };
6802
+ const useFilter = (nodeStatusMap, page) => {
6803
+ const filterIsMatch = (value, data) => {
6804
+ if (!value) {
6805
+ return true;
6806
+ }
6807
+ let name = "";
6808
+ if (data.name) {
6809
+ name = data.name;
6810
+ } else if (data.items) {
6811
+ name = "container";
6812
+ }
6813
+ return `${data.id}${name}${data.type}`.includes(value);
6814
+ };
6815
+ const filterNode = (text) => (node, parents) => {
6816
+ if (!nodeStatusMap.value)
6817
+ return;
6818
+ const visible = filterIsMatch(text, node);
6819
+ if (visible && parents.length) {
6820
+ parents.forEach((parent) => {
6821
+ updateStatus(nodeStatusMap.value, parent.id, {
6822
+ visible,
6823
+ expand: true
6824
+ });
6825
+ });
6826
+ }
6827
+ updateStatus(nodeStatusMap.value, node.id, {
6828
+ visible
6829
+ });
6830
+ };
6831
+ const filter = (text) => {
6832
+ if (!page.value?.items?.length)
6833
+ return;
6834
+ page.value.items.forEach((node) => {
6835
+ traverseNode(node, filterNode(text));
6836
+ });
6837
+ };
6838
+ return {
6839
+ filterText: vue.ref(""),
6840
+ filterTextChangeHandler(text) {
6841
+ filter(text);
6842
+ }
6843
+ };
6844
+ };
6845
+
6846
+ const _hoisted_1$a = ["draggable", "data-node-id", "data-is-container"];
6847
+ const _hoisted_2$8 = { class: "layer-node-label" };
6848
+ const _hoisted_3$4 = { class: "layer-node-tool" };
6849
+ const _hoisted_4$4 = {
6850
+ key: 0,
6851
+ class: "magic-editor-layer-node-children"
6852
+ };
6853
+ const throttleTime = 300;
6854
+ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
6363
6855
  ...{
6364
- name: "MEditorLayerPanel"
6856
+ name: "MEditorLayerNode"
6365
6857
  },
6366
- __name: "LayerPanel",
6858
+ __name: "LayerNode",
6367
6859
  props: {
6368
- layerContentMenu: {}
6860
+ data: {},
6861
+ parent: {},
6862
+ indent: { default: 0 },
6863
+ filterText: { default: "" },
6864
+ isCtrlKeyDown: { type: Boolean, default: false }
6369
6865
  },
6370
- setup(__props) {
6866
+ emits: ["node-contextmenu"],
6867
+ setup(__props, { emit }) {
6868
+ const props = __props;
6371
6869
  const services = vue.inject("services");
6870
+ const nodeStatusMap = vue.inject("nodeStatusMap");
6372
6871
  const editorService = services?.editorService;
6373
- const keybindingService = services?.keybindingService;
6374
- const tree = vue.ref();
6375
- const menu = vue.ref();
6376
- const checkedKeys = vue.ref([]);
6377
- const isCtrlKeyDown = vue.ref(false);
6378
- const expandedKeys = vue.ref([]);
6379
- const currentNodeKey = vue.ref();
6380
- const clicked = vue.ref(false);
6381
- const treeProps = {
6382
- children: "items",
6383
- label: "name",
6384
- value: "id",
6385
- disabled: (data) => Boolean(data.items?.length),
6386
- class: (data) => {
6387
- if (clicked.value || utils.isPage(data))
6388
- return "";
6389
- if (data.id === highlightNode?.value?.id && !checkedKeys.value.includes(data.id)) {
6390
- return "cus-tree-node-hover";
6391
- }
6872
+ const uiService = services?.uiService;
6873
+ const nodeStatus = vue.computed(
6874
+ () => nodeStatusMap?.value?.get(props.data.id) || {
6875
+ selected: false,
6876
+ expand: false,
6877
+ visible: false
6392
6878
  }
6879
+ );
6880
+ const expanded = vue.computed(() => nodeStatus.value.expand);
6881
+ const selected = vue.computed(() => nodeStatus.value.selected);
6882
+ const visible = vue.computed(() => nodeStatus.value.visible);
6883
+ const hasChilren = vue.computed(() => props.data.items?.length > 0);
6884
+ const nodeEl = vue.ref();
6885
+ const { handleDragStart, handleDragEnd, handleDragLeave } = useDrag(services);
6886
+ const expandHandler = () => {
6887
+ if (!nodeStatusMap?.value)
6888
+ return;
6889
+ updateStatus(nodeStatusMap.value, props.data.id, {
6890
+ expand: !expanded.value
6891
+ });
6892
+ };
6893
+ const nodeClickHandler = () => {
6894
+ if (!nodeStatusMap?.value)
6895
+ return;
6896
+ if (uiService?.get("uiSelectMode")) {
6897
+ document.dispatchEvent(new CustomEvent("ui-select", { detail: props.data }));
6898
+ return;
6899
+ }
6900
+ if (hasChilren.value && !props.isCtrlKeyDown) {
6901
+ updateStatus(nodeStatusMap.value, props.data.id, {
6902
+ expand: true
6903
+ });
6904
+ }
6905
+ vue.nextTick(() => {
6906
+ select(props.data);
6907
+ });
6908
+ };
6909
+ const contextmenuHandler = (event) => {
6910
+ event.preventDefault();
6911
+ nodeClickHandler();
6912
+ emit("node-contextmenu", event, props.data);
6913
+ };
6914
+ const nodeContentmenuHandler = (event, node) => {
6915
+ emit("node-contextmenu", event, node);
6393
6916
  };
6394
- const isMultiSelect = vue.computed(() => isCtrlKeyDown.value || checkedKeys.value.length > 1);
6395
- const nodes = vue.computed(() => editorService?.get("nodes") || []);
6396
- const page = vue.computed(() => editorService?.get("page"));
6397
- const values = vue.computed(() => page.value ? [page.value] : []);
6398
- const highlightNode = vue.computed(() => editorService?.get("highlightNode"));
6399
6917
  const select = async (data) => {
6400
6918
  if (!data.id) {
6401
6919
  throw new Error("没有id");
6402
6920
  }
6403
- await editorService?.select(data);
6404
- editorService?.get("stage")?.select(data.id);
6921
+ if (props.isCtrlKeyDown) {
6922
+ multiSelect(data);
6923
+ } else {
6924
+ await editorService?.select(data);
6925
+ editorService?.get("stage")?.select(data.id);
6926
+ }
6405
6927
  };
6406
6928
  const multiSelect = async (data) => {
6407
- await editorService?.multiSelect(data);
6408
- editorService?.get("stage")?.multiSelect(data);
6409
- };
6410
- const highlight = (data) => {
6411
- if (!data?.id) {
6412
- throw new Error("没有id");
6929
+ const nodes = editorService?.get("nodes") || [];
6930
+ const newNodes = [];
6931
+ let isCancel = false;
6932
+ nodes.forEach((node) => {
6933
+ if (node.id === data.id) {
6934
+ isCancel = true;
6935
+ return;
6936
+ }
6937
+ newNodes.push(node.id);
6938
+ });
6939
+ if (!isCancel || newNodes.length === 0) {
6940
+ newNodes.push(data.id);
6413
6941
  }
6414
- editorService?.highlight(data);
6415
- editorService?.get("stage")?.highlight(data.id);
6942
+ await editorService?.multiSelect(newNodes);
6943
+ editorService?.get("stage")?.multiSelect(newNodes);
6416
6944
  };
6417
- const allowDrop = (draggingNode, dropNode, type) => {
6418
- const { data } = dropNode || {};
6419
- const { data: ingData } = draggingNode;
6420
- const { type: ingType } = ingData;
6421
- if (ingType !== schema.NodeType.PAGE && data.type === schema.NodeType.PAGE)
6422
- return false;
6423
- if (ingType === schema.NodeType.PAGE && data.type !== schema.NodeType.PAGE)
6424
- return false;
6425
- if (!data?.type)
6426
- return false;
6427
- if (["prev", "next"].includes(type))
6428
- return true;
6429
- if (data.items || data.type === "container")
6430
- return true;
6431
- return false;
6945
+ const highlightHandler = lodashEs.throttle(() => {
6946
+ highlight();
6947
+ }, throttleTime);
6948
+ const highlight = () => {
6949
+ editorService?.highlight(props.data);
6950
+ editorService?.get("stage")?.highlight(props.data.id);
6432
6951
  };
6433
- const handleDragEnd = async (e) => {
6434
- if (!tree.value)
6435
- return;
6436
- const { data: node } = e;
6437
- const parent = editorService?.getParentById(node.id, false);
6438
- const layout = await editorService?.getLayout(parent, node);
6439
- node.style.position = layout;
6440
- if (layout === Layout.RELATIVE) {
6441
- node.style.top = 0;
6442
- node.style.left = 0;
6443
- }
6444
- const data = tree.value.getData();
6445
- const [page2] = data;
6446
- editorService?.update(page2);
6447
- };
6448
- const handleCollapse = (data) => {
6449
- expandedKeys.value = expandedKeys.value.filter((id) => id !== data.id);
6450
- };
6451
- const handleExpand = (data) => {
6452
- if (!page.value) {
6453
- expandedKeys.value = [];
6454
- return;
6455
- }
6456
- expandedKeys.value = lodashEs.union(
6457
- expandedKeys.value,
6458
- utils.getNodePath(data.id, [page.value]).map((node) => node.id)
6459
- );
6952
+ return (_ctx, _cache) => {
6953
+ const _component_LayerNode = vue.resolveComponent("LayerNode", true);
6954
+ return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
6955
+ class: "magic-editor-layer-node",
6956
+ ref_key: "nodeEl",
6957
+ ref: nodeEl,
6958
+ draggable: !vue.unref(utils.isPage)(_ctx.data),
6959
+ "data-node-id": _ctx.data.id,
6960
+ "data-is-container": Array.isArray(_ctx.data.items),
6961
+ onDragstart: _cache[1] || (_cache[1] = //@ts-ignore
6962
+ (...args) => vue.unref(handleDragStart) && vue.unref(handleDragStart)(...args)),
6963
+ onDragleave: _cache[2] || (_cache[2] = //@ts-ignore
6964
+ (...args) => vue.unref(handleDragLeave) && vue.unref(handleDragLeave)(...args)),
6965
+ onDragend: _cache[3] || (_cache[3] = ($event) => vue.unref(handleDragEnd)($event, _ctx.data))
6966
+ }, [
6967
+ vue.createElementVNode("div", {
6968
+ class: vue.normalizeClass(["layer-node", { selected: selected.value, expanded: expanded.value }]),
6969
+ style: vue.normalizeStyle(`padding-left: ${_ctx.indent}px`),
6970
+ onContextmenu: contextmenuHandler,
6971
+ onMouseenter: _cache[0] || (_cache[0] = ($event) => vue.unref(highlightHandler)())
6972
+ }, [
6973
+ vue.createVNode(_sfc_main$M, {
6974
+ class: "expand-icon",
6975
+ style: vue.normalizeStyle(hasChilren.value ? "" : "color: transparent; cursor: default"),
6976
+ icon: expanded.value ? vue.unref(iconsVue.ArrowDown) : vue.unref(iconsVue.ArrowRight),
6977
+ onClick: expandHandler
6978
+ }, null, 8, ["style", "icon"]),
6979
+ vue.createElementVNode("div", {
6980
+ class: "layer-node-content",
6981
+ onClick: nodeClickHandler
6982
+ }, [
6983
+ vue.renderSlot(_ctx.$slots, "layer-node-content", { data: _ctx.data }, () => [
6984
+ vue.createElementVNode("div", _hoisted_2$8, vue.toDisplayString(`${_ctx.data.name} (${_ctx.data.id})`), 1),
6985
+ vue.createElementVNode("div", _hoisted_3$4, [
6986
+ vue.createVNode(_sfc_main$i, { data: _ctx.data }, null, 8, ["data"])
6987
+ ])
6988
+ ])
6989
+ ])
6990
+ ], 38),
6991
+ hasChilren.value && expanded.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$4, [
6992
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.data.items, (item) => {
6993
+ return vue.openBlock(), vue.createBlock(_component_LayerNode, {
6994
+ data: item,
6995
+ parent: _ctx.data,
6996
+ key: item.id,
6997
+ indent: _ctx.indent + 11,
6998
+ "filter-text": _ctx.filterText,
6999
+ "is-ctrl-key-down": _ctx.isCtrlKeyDown,
7000
+ onNodeContextmenu: nodeContentmenuHandler
7001
+ }, {
7002
+ "layer-node-content": vue.withCtx(({ data: nodeData }) => [
7003
+ vue.renderSlot(_ctx.$slots, "layer-node-content", { data: nodeData })
7004
+ ]),
7005
+ _: 2
7006
+ }, 1032, ["data", "parent", "indent", "filter-text", "is-ctrl-key-down"]);
7007
+ }), 128))
7008
+ ])) : vue.createCommentVNode("", true)
7009
+ ], 40, _hoisted_1$a)), [
7010
+ [vue.vShow, visible.value]
7011
+ ]);
6460
7012
  };
6461
- const filterNode = (value, data) => {
6462
- if (!value) {
6463
- return true;
7013
+ }
7014
+ });
7015
+
7016
+ const useKeybinding = (services) => {
7017
+ const keybindingService = services?.keybindingService;
7018
+ const isCtrlKeyDown = vue.ref(false);
7019
+ const windowBlurHandler = () => {
7020
+ isCtrlKeyDown.value = false;
7021
+ };
7022
+ keybindingService?.registeCommand("layer-panel-global-keyup", () => {
7023
+ isCtrlKeyDown.value = false;
7024
+ });
7025
+ keybindingService?.registeCommand("layer-panel-global-keydwon", () => {
7026
+ isCtrlKeyDown.value = true;
7027
+ });
7028
+ keybindingService?.registe([
7029
+ {
7030
+ command: "layer-panel-global-keydwon",
7031
+ keybinding: "ctrl",
7032
+ when: [["global", "keydown"]]
7033
+ },
7034
+ {
7035
+ command: "layer-panel-global-keyup",
7036
+ keybinding: "ctrl",
7037
+ when: [["global", "keyup"]]
7038
+ }
7039
+ ]);
7040
+ vue.onMounted(() => {
7041
+ globalThis.addEventListener("blur", windowBlurHandler);
7042
+ });
7043
+ vue.onBeforeUnmount(() => {
7044
+ globalThis.removeEventListener("blur", windowBlurHandler);
7045
+ });
7046
+ return {
7047
+ isCtrlKeyDown
7048
+ };
7049
+ };
7050
+
7051
+ const createPageNodeStatus = (services, pageId) => {
7052
+ const map = /* @__PURE__ */ new Map();
7053
+ map.set(pageId, {
7054
+ visible: true,
7055
+ expand: true,
7056
+ selected: true
7057
+ });
7058
+ services?.editorService.getNodeById(pageId)?.items.forEach(
7059
+ (node) => traverseNode(node, (node2) => {
7060
+ map.set(node2.id, {
7061
+ visible: true,
7062
+ expand: false,
7063
+ selected: false
7064
+ });
7065
+ })
7066
+ );
7067
+ return map;
7068
+ };
7069
+ const useNodeStatus = (services, page) => {
7070
+ const nodes = vue.computed(() => services?.editorService.get("nodes") || []);
7071
+ const nodeStatusMaps = vue.ref(/* @__PURE__ */ new Map());
7072
+ const nodeStatusMap = vue.computed(
7073
+ () => page.value ? nodeStatusMaps.value.get(page.value.id) : /* @__PURE__ */ new Map()
7074
+ );
7075
+ vue.watch(
7076
+ () => page.value?.id,
7077
+ (pageId) => {
7078
+ if (!pageId || nodeStatusMaps.value.has(pageId)) {
7079
+ return;
6464
7080
  }
6465
- let name = "";
6466
- if (data.name) {
6467
- name = data.name;
6468
- } else if (data.items) {
6469
- name = "container";
7081
+ nodeStatusMaps.value.set(pageId, createPageNodeStatus(services, pageId));
7082
+ },
7083
+ {
7084
+ immediate: true
7085
+ }
7086
+ );
7087
+ vue.watch(
7088
+ nodes,
7089
+ (nodes2) => {
7090
+ if (!nodeStatusMap.value)
7091
+ return;
7092
+ for (const [id, status] of nodeStatusMap.value.entries()) {
7093
+ status.selected = nodes2.some((node) => node.id === id);
7094
+ if (status.selected) {
7095
+ utils.getNodePath(id, page.value?.items).forEach((node) => {
7096
+ updateStatus(nodeStatusMap.value, node.id, {
7097
+ expand: true
7098
+ });
7099
+ });
7100
+ }
6470
7101
  }
6471
- return `${data.id}${name}${data.type}`.indexOf(value) !== -1;
6472
- };
6473
- const filterTextChangeHandler = (val) => {
6474
- tree.value?.filter(val);
6475
- };
6476
- vue.watch(nodes, (nodes2) => {
6477
- const ids = nodes2?.map((node) => node.id) || [];
6478
- const idsLength = ids.length;
6479
- const checkedKeysLength = checkedKeys.value.length;
6480
- if (lodashEs.difference(
6481
- idsLength > checkedKeysLength ? ids : checkedKeys.value,
6482
- idsLength > checkedKeysLength ? checkedKeys.value : ids
6483
- ).length) {
6484
- tree.value?.setCheckedKeys([], false);
6485
- checkedKeys.value = ids.filter((id) => id !== page.value?.id);
6486
- expandedKeys.value = lodashEs.union(expandedKeys.value, ids);
6487
- }
6488
- [currentNodeKey.value] = ids;
6489
- setTimeout(() => {
6490
- tree.value?.setCurrentKey(currentNodeKey.value);
7102
+ },
7103
+ {
7104
+ immediate: true
7105
+ }
7106
+ );
7107
+ services?.editorService.on("add", (newNodes) => {
7108
+ newNodes.forEach((node) => {
7109
+ nodeStatusMap.value?.set(node.id, {
7110
+ visible: true,
7111
+ expand: Array.isArray(node.items),
7112
+ selected: true
6491
7113
  });
6492
7114
  });
6493
- vue.watch(isMultiSelect, (isMultiSelect2) => {
6494
- if (!isMultiSelect2) {
6495
- currentNodeKey.value = editorService?.get("node")?.id;
6496
- tree.value?.setCurrentKey(currentNodeKey.value);
6497
- }
7115
+ });
7116
+ services?.editorService.on("remove", (nodes2) => {
7117
+ nodes2.forEach((node) => {
7118
+ nodeStatusMap.value?.delete(node.id);
6498
7119
  });
6499
- const editorServiceRemoveHandler = () => {
6500
- setTimeout(() => {
6501
- tree.value?.getNode(editorService?.get("node")?.id)?.updateChildren();
6502
- }, 0);
7120
+ });
7121
+ return {
7122
+ nodeStatusMaps,
7123
+ nodeStatusMap
7124
+ };
7125
+ };
7126
+
7127
+ const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
7128
+ ...{
7129
+ name: "MEditorLayerPanel"
7130
+ },
7131
+ __name: "LayerPanel",
7132
+ props: {
7133
+ layerContentMenu: {}
7134
+ },
7135
+ setup(__props) {
7136
+ const services = vue.inject("services");
7137
+ const editorService = services?.editorService;
7138
+ const page = vue.computed(() => editorService?.get("page"));
7139
+ const root = vue.computed(() => editorService?.get("root"));
7140
+ const { nodeStatusMap } = useNodeStatus(services, page);
7141
+ const { isCtrlKeyDown } = useKeybinding(services);
7142
+ vue.provide("nodeStatusMap", nodeStatusMap);
7143
+ const { filterText, filterTextChangeHandler } = useFilter(nodeStatusMap, page);
7144
+ const collapseAllHandler = () => {
7145
+ if (!page.value || !nodeStatusMap.value)
7146
+ return;
7147
+ const items = nodeStatusMap.value.entries();
7148
+ for (const [id, status] of items) {
7149
+ if (id === page.value.id) {
7150
+ continue;
7151
+ }
7152
+ status.expand = false;
7153
+ }
7154
+ };
7155
+ const menu = vue.ref();
7156
+ const contextmenu = (event) => {
7157
+ event.preventDefault();
7158
+ menu.value?.show(event);
6503
7159
  };
6504
- const windowBlurHandler = () => {
6505
- isCtrlKeyDown.value = false;
7160
+ const { handleDragOver } = useDrag(services);
7161
+ return (_ctx, _cache) => {
7162
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
7163
+ default: vue.withCtx(() => [
7164
+ vue.renderSlot(_ctx.$slots, "layer-panel-header"),
7165
+ vue.createVNode(_sfc_main$t, { onSearch: vue.unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
7166
+ vue.createElementVNode("div", {
7167
+ class: "magic-editor-layer-tree",
7168
+ tabindex: "-1",
7169
+ onDragover: _cache[0] || (_cache[0] = //@ts-ignore
7170
+ (...args) => vue.unref(handleDragOver) && vue.unref(handleDragOver)(...args))
7171
+ }, [
7172
+ page.value && root.value ? (vue.openBlock(), vue.createBlock(_sfc_main$h, {
7173
+ key: 0,
7174
+ data: page.value,
7175
+ "filter-text": vue.unref(filterText),
7176
+ "is-ctrl-key-down": vue.unref(isCtrlKeyDown),
7177
+ onNodeContextmenu: contextmenu
7178
+ }, {
7179
+ "layer-node-content": vue.withCtx(({ data: nodeData }) => [
7180
+ vue.renderSlot(_ctx.$slots, "layer-node-content", { data: nodeData })
7181
+ ]),
7182
+ _: 3
7183
+ }, 8, ["data", "filter-text", "is-ctrl-key-down"])) : vue.createCommentVNode("", true)
7184
+ ], 32),
7185
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
7186
+ vue.createVNode(_sfc_main$j, {
7187
+ ref_key: "menu",
7188
+ ref: menu,
7189
+ "layer-content-menu": _ctx.layerContentMenu,
7190
+ onCollapseAll: collapseAllHandler
7191
+ }, null, 8, ["layer-content-menu"])
7192
+ ]))
7193
+ ]),
7194
+ _: 3
7195
+ });
7196
+ };
7197
+ }
7198
+ });
7199
+
7200
+ const _hoisted_1$9 = ["onClick", "onDragstart"];
7201
+ const _hoisted_2$7 = ["title"];
7202
+ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
7203
+ ...{
7204
+ name: "MEditorComponentListPanel"
7205
+ },
7206
+ __name: "ComponentListPanel",
7207
+ setup(__props) {
7208
+ const searchText = vue.ref("");
7209
+ const filterTextChangeHandler = (v) => {
7210
+ searchText.value = v;
7211
+ };
7212
+ const services = vue.inject("services");
7213
+ const stageOptions = vue.inject("stageOptions");
7214
+ const stage = vue.computed(() => services?.editorService.get("stage"));
7215
+ const list = vue.computed(
7216
+ () => services?.componentListService.getList().map((group) => ({
7217
+ ...group,
7218
+ items: group.items.filter((item) => item.text.includes(searchText.value))
7219
+ }))
7220
+ );
7221
+ const collapseValue = vue.computed(
7222
+ () => Array(list.value?.length).fill(1).map((x, i) => `${i}`)
7223
+ );
7224
+ let timeout;
7225
+ let clientX;
7226
+ let clientY;
7227
+ const appendComponent = ({ text, type, data = {} }) => {
7228
+ services?.editorService.add({
7229
+ name: text,
7230
+ type,
7231
+ ...data
7232
+ });
6506
7233
  };
6507
- keybindingService?.registeCommand("layer-panel-not-ctrl-keydown", (e) => {
6508
- if (e.key !== keybindingService.ctrlKey) {
6509
- isCtrlKeyDown.value = false;
6510
- }
6511
- });
6512
- keybindingService?.registeCommand("layer-panel-ctrl-keydown", () => {
6513
- isCtrlKeyDown.value = true;
6514
- });
6515
- keybindingService?.registeCommand("layer-panel-ctrl-keyup", () => {
6516
- isCtrlKeyDown.value = false;
6517
- });
6518
- keybindingService?.registeCommand("layer-panel-global-keydwon", () => {
6519
- if (!tree.value?.$el.contains(document.activeElement)) {
6520
- isCtrlKeyDown.value = false;
6521
- }
6522
- });
6523
- keybindingService?.registe([
6524
- {
6525
- command: "layer-panel-not-ctrl-keydown",
6526
- when: [["layer-panel", "keydown"]]
6527
- },
6528
- {
6529
- command: "layer-panel-ctrl-keydown",
6530
- keybinding: "ctrl",
6531
- when: [["layer-panel", "keydown"]]
6532
- },
6533
- {
6534
- command: "layer-panel-ctrl-keyup",
6535
- keybinding: "ctrl",
6536
- when: [["layer-panel", "keyup"]]
6537
- },
6538
- {
6539
- command: "layer-panel-global-keydwon",
6540
- keybinding: "ctrl",
6541
- when: [["global", "keydown"]]
6542
- }
6543
- ]);
6544
- vue.watch(tree, () => {
6545
- if (tree.value?.$el) {
6546
- keybindingService?.registeEl("layer-panel", tree.value.$el);
6547
- tree.value.$el.addEventListener("blur", windowBlurHandler);
6548
- } else {
6549
- keybindingService?.unregisteEl("layer-panel");
6550
- }
6551
- });
6552
- vue.onMounted(() => {
6553
- editorService?.on("remove", editorServiceRemoveHandler);
6554
- globalThis.addEventListener("blur", windowBlurHandler);
6555
- });
6556
- vue.onBeforeUnmount(() => {
6557
- tree.value?.$el.removeEventListener("blur", windowBlurHandler);
6558
- });
6559
- vue.onUnmounted(() => {
6560
- editorService?.off("remove", editorServiceRemoveHandler);
6561
- globalThis.removeEventListener("blur", windowBlurHandler);
6562
- });
6563
- const highlightHandler = lodashEs.throttle((data) => {
6564
- highlight(data);
6565
- }, throttleTime);
6566
- const toggleClickFlag = () => {
6567
- clicked.value = !clicked.value;
7234
+ const dragstartHandler = ({ text, type, data = {} }, e) => {
7235
+ e.dataTransfer?.setData(
7236
+ "text/json",
7237
+ serialize({
7238
+ dragType: DragType.COMPONENT_LIST,
7239
+ data: {
7240
+ name: text,
7241
+ type,
7242
+ ...data
7243
+ }
7244
+ })
7245
+ );
6568
7246
  };
6569
- const checkHandler = (data, { checkedNodes }) => {
6570
- if (!isCtrlKeyDown.value && nodes.value.length < 2) {
6571
- return;
7247
+ const dragendHandler = () => {
7248
+ if (timeout) {
7249
+ globalThis.clearTimeout(timeout);
7250
+ timeout = void 0;
6572
7251
  }
6573
- if (checkedNodes.length > 0) {
6574
- multiSelect(checkedNodes.map((node) => node.id));
6575
- } else {
6576
- multiSelect(nodes.value.map((node) => node.id));
7252
+ const doc = stage.value?.renderer.contentWindow?.document;
7253
+ if (doc && stageOptions) {
7254
+ utils.removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
6577
7255
  }
7256
+ clientX = 0;
7257
+ clientY = 0;
6578
7258
  };
6579
- const clickHandler = (data) => {
6580
- if (isCtrlKeyDown.value) {
6581
- return;
6582
- }
6583
- if (services?.uiService.get("uiSelectMode")) {
6584
- document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
7259
+ const dragHandler = (e) => {
7260
+ if (e.clientX !== clientX || e.clientY !== clientY) {
7261
+ clientX = e.clientX;
7262
+ clientY = e.clientY;
7263
+ if (timeout) {
7264
+ globalThis.clearTimeout(timeout);
7265
+ timeout = void 0;
7266
+ }
6585
7267
  return;
6586
7268
  }
6587
- select(data);
6588
- };
6589
- const contextmenu = async (event, data) => {
6590
- event.preventDefault();
6591
- if (nodes.value.length < 2) {
6592
- await select(data);
6593
- }
6594
- menu.value?.show(event);
6595
- };
6596
- const collapseAllHandler = () => {
6597
- const page2 = editorService?.get("page");
6598
- if (!tree.value || !page2)
7269
+ if (timeout || !stage.value)
6599
7270
  return;
6600
- const rootNode = tree.value.getNode(page2.id);
6601
- rootNode.childNodes.forEach((node) => {
6602
- node.collapse();
6603
- handleCollapse(node.data);
6604
- });
7271
+ timeout = stage.value.delayedMarkContainer(e);
6605
7272
  };
6606
7273
  return (_ctx, _cache) => {
6607
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
7274
+ return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), null, {
6608
7275
  default: vue.withCtx(() => [
6609
- vue.renderSlot(_ctx.$slots, "layer-panel-header"),
6610
- vue.createVNode(_sfc_main$s, { onSearch: filterTextChangeHandler }),
6611
- values.value.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTree), {
6612
- key: 0,
6613
- class: "magic-editor-layer-tree",
6614
- ref_key: "tree",
6615
- ref: tree,
6616
- "node-key": "id",
6617
- "empty-text": "页面空荡荡的",
6618
- tabindex: "-1",
6619
- draggable: "",
6620
- "default-expanded-keys": expandedKeys.value,
6621
- "default-checked-keys": checkedKeys.value,
6622
- "current-node-key": currentNodeKey.value,
6623
- data: values.value,
6624
- "expand-on-click-node": false,
6625
- "highlight-current": !isMultiSelect.value,
6626
- "check-on-click-node": true,
6627
- props: treeProps,
6628
- "filter-node-method": filterNode,
6629
- "allow-drop": allowDrop,
6630
- "show-checkbox": isMultiSelect.value,
6631
- onNodeClick: clickHandler,
6632
- onNodeContextmenu: contextmenu,
6633
- onNodeDragEnd: handleDragEnd,
6634
- onNodeCollapse: handleCollapse,
6635
- onNodeExpand: handleExpand,
6636
- onCheck: checkHandler,
6637
- onMousedown: toggleClickFlag,
6638
- onMouseup: toggleClickFlag
7276
+ vue.renderSlot(_ctx.$slots, "component-list-panel-header"),
7277
+ vue.createVNode(vue.unref(design.TMagicCollapse), {
7278
+ class: "ui-component-panel",
7279
+ "model-value": collapseValue.value
6639
7280
  }, {
6640
- default: vue.withCtx(({ node, data }) => [
6641
- vue.createElementVNode("div", {
6642
- class: "cus-tree-node",
6643
- id: data.id,
6644
- onMouseenter: ($event) => vue.unref(highlightHandler)(data)
6645
- }, [
6646
- vue.renderSlot(_ctx.$slots, "layer-node-content", {
6647
- node,
6648
- data
6649
- }, () => [
6650
- vue.createVNode(_sfc_main$g, { data }, null, 8, ["data"])
6651
- ])
6652
- ], 40, _hoisted_1$9)
7281
+ default: vue.withCtx(() => [
7282
+ vue.createVNode(_sfc_main$t, { onSearch: filterTextChangeHandler }),
7283
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.value, (group, index) => {
7284
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
7285
+ group.items && group.items.length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCollapseItem), {
7286
+ key: index,
7287
+ name: `${index}`
7288
+ }, {
7289
+ title: vue.withCtx(() => [
7290
+ vue.createVNode(_sfc_main$M, { icon: vue.unref(iconsVue.Grid) }, null, 8, ["icon"]),
7291
+ vue.createTextVNode(vue.toDisplayString(group.title), 1)
7292
+ ]),
7293
+ default: vue.withCtx(() => [
7294
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.items, (item) => {
7295
+ return vue.openBlock(), vue.createElementBlock("div", {
7296
+ class: "component-item",
7297
+ draggable: "true",
7298
+ key: item.type,
7299
+ onClick: ($event) => appendComponent(item),
7300
+ onDragstart: ($event) => dragstartHandler(item, $event),
7301
+ onDragend: dragendHandler,
7302
+ onDrag: dragHandler
7303
+ }, [
7304
+ vue.renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
7305
+ vue.createVNode(_sfc_main$M, {
7306
+ title: item.text,
7307
+ icon: item.icon
7308
+ }, null, 8, ["title", "icon"]),
7309
+ vue.createElementVNode("span", {
7310
+ title: item.text
7311
+ }, vue.toDisplayString(item.text), 9, _hoisted_2$7)
7312
+ ])
7313
+ ], 40, _hoisted_1$9);
7314
+ }), 128))
7315
+ ]),
7316
+ _: 2
7317
+ }, 1032, ["name"])) : vue.createCommentVNode("", true)
7318
+ ], 64);
7319
+ }), 256))
6653
7320
  ]),
6654
7321
  _: 3
6655
- }, 8, ["default-expanded-keys", "default-checked-keys", "current-node-key", "data", "highlight-current", "show-checkbox"])) : vue.createCommentVNode("", true),
6656
- (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
6657
- vue.createVNode(_sfc_main$h, {
6658
- ref_key: "menu",
6659
- ref: menu,
6660
- "layer-content-menu": _ctx.layerContentMenu,
6661
- onCollapseAll: collapseAllHandler
6662
- }, null, 8, ["layer-content-menu"])
6663
- ]))
7322
+ }, 8, ["model-value"])
6664
7323
  ]),
6665
7324
  _: 3
6666
7325
  });
@@ -6697,7 +7356,7 @@
6697
7356
  type: "component",
6698
7357
  icon: iconsVue.Goods,
6699
7358
  text: "组件",
6700
- component: _sfc_main$k,
7359
+ component: _sfc_main$f,
6701
7360
  slots: {}
6702
7361
  },
6703
7362
  layer: {
@@ -6708,7 +7367,7 @@
6708
7367
  props: {
6709
7368
  layerContentMenu: props.layerContentMenu
6710
7369
  },
6711
- component: _sfc_main$f,
7370
+ component: _sfc_main$g,
6712
7371
  slots: {}
6713
7372
  },
6714
7373
  "code-block": {
@@ -6716,7 +7375,7 @@
6716
7375
  type: "component",
6717
7376
  icon: iconsVue.EditPen,
6718
7377
  text: "代码编辑",
6719
- component: _sfc_main$o,
7378
+ component: _sfc_main$p,
6720
7379
  slots: {}
6721
7380
  },
6722
7381
  "data-source": {
@@ -6724,7 +7383,7 @@
6724
7383
  type: "component",
6725
7384
  icon: iconsVue.Coin,
6726
7385
  text: "数据源",
6727
- component: _sfc_main$l,
7386
+ component: _sfc_main$m,
6728
7387
  slots: {}
6729
7388
  }
6730
7389
  };
@@ -6749,7 +7408,7 @@
6749
7408
  key: config.$key ?? index,
6750
7409
  onClick: ($event) => activeTabName.value = config.text || `${index}`
6751
7410
  }, [
6752
- config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$K, {
7411
+ config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$M, {
6753
7412
  key: 0,
6754
7413
  icon: config.icon
6755
7414
  }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
@@ -6810,16 +7469,14 @@
6810
7469
  } : void 0,
6811
7470
  config.$key === "layer" || config.slots?.layerNodeContent ? {
6812
7471
  name: "layer-node-content",
6813
- fn: vue.withCtx(({ data: nodeData, node }) => [
7472
+ fn: vue.withCtx(({ data: nodeData }) => [
6814
7473
  config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-content", {
6815
7474
  key: 0,
6816
- data: nodeData,
6817
- node
7475
+ data: nodeData
6818
7476
  }) : config.slots?.layerNodeContent ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerNodeContent), {
6819
7477
  key: 1,
6820
- data: nodeData,
6821
- node
6822
- }, null, 8, ["data", "node"])) : vue.createCommentVNode("", true)
7478
+ data: nodeData
7479
+ }, null, 8, ["data"])) : vue.createCommentVNode("", true)
6823
7480
  ]),
6824
7481
  key: "5"
6825
7482
  } : void 0
@@ -7449,7 +8106,7 @@
7449
8106
  content: _ctx.pinned ? "取消置于顶层自动隐藏" : "置于顶层不消失"
7450
8107
  }, {
7451
8108
  default: vue.withCtx(() => [
7452
- vue.createVNode(_sfc_main$K, {
8109
+ vue.createVNode(_sfc_main$M, {
7453
8110
  style: { "margin-left": "10px", "cursor": "pointer" },
7454
8111
  icon: _ctx.pinned ? _sfc_main$a : _sfc_main$b,
7455
8112
  onClick: pinHandler
@@ -7465,7 +8122,7 @@
7465
8122
  onClick: closeHandler
7466
8123
  }, {
7467
8124
  default: vue.withCtx(() => [
7468
- vue.createVNode(_sfc_main$K, { icon: vue.unref(iconsVue.Close) }, null, 8, ["icon"])
8125
+ vue.createVNode(_sfc_main$M, { icon: vue.unref(iconsVue.Close) }, null, 8, ["icon"])
7469
8126
  ]),
7470
8127
  _: 1
7471
8128
  })
@@ -7502,6 +8159,13 @@
7502
8159
  nodeList.value = [];
7503
8160
  menu.value?.hide();
7504
8161
  };
8162
+ const clearTimeoutLazy = () => {
8163
+ globalThis.setTimeout(() => {
8164
+ if (timeout) {
8165
+ globalThis.clearTimeout(timeout);
8166
+ }
8167
+ }, 300);
8168
+ };
7505
8169
  const unWatch = vue.watch(
7506
8170
  stage,
7507
8171
  (stage2) => {
@@ -7516,7 +8180,7 @@
7516
8180
  return;
7517
8181
  }
7518
8182
  timeout = globalThis.setTimeout(() => {
7519
- const els = stage2?.renderer.getElementsFromPoint(event);
8183
+ const els = stage2.renderer.getElementsFromPoint(event) || [];
7520
8184
  const nodes = utils.getNodes(
7521
8185
  els.map((el) => el.id),
7522
8186
  page.value?.items
@@ -7531,7 +8195,7 @@
7531
8195
  }, 1500);
7532
8196
  });
7533
8197
  stage2.on("mouseleave", () => {
7534
- cancel();
8198
+ clearTimeoutLazy();
7535
8199
  });
7536
8200
  unWatch();
7537
8201
  },
@@ -7570,11 +8234,7 @@
7570
8234
  })
7571
8235
  );
7572
8236
  const mouseenterHandler = () => {
7573
- globalThis.setTimeout(() => {
7574
- if (timeout) {
7575
- globalThis.clearTimeout(timeout);
7576
- }
7577
- }, 300);
8237
+ clearTimeoutLazy();
7578
8238
  };
7579
8239
  const dragMenuHandler = ({ deltaY, deltaX }) => {
7580
8240
  if (!menu.value)
@@ -7589,9 +8249,11 @@
7589
8249
  menu.value?.hide();
7590
8250
  };
7591
8251
  return (_ctx, _cache) => {
7592
- return vue.openBlock(), vue.createBlock(_sfc_main$j, {
8252
+ return vue.openBlock(), vue.createBlock(_sfc_main$l, {
7593
8253
  ref_key: "menu",
7594
8254
  ref: menu,
8255
+ class: "magic-editor-node-list-menu",
8256
+ style: { "max-width": "280px" },
7595
8257
  "menu-data": menuData.value,
7596
8258
  active: node.value?.id,
7597
8259
  "auto-hide": !pinned.value,
@@ -7773,7 +8435,7 @@
7773
8435
  };
7774
8436
  __expose({ show });
7775
8437
  return (_ctx, _cache) => {
7776
- return vue.openBlock(), vue.createBlock(_sfc_main$j, {
8438
+ return vue.openBlock(), vue.createBlock(_sfc_main$l, {
7777
8439
  "menu-data": menuData.value,
7778
8440
  ref_key: "menu",
7779
8441
  ref: menu
@@ -7868,17 +8530,26 @@
7868
8530
  services?.editorService.set("stage", null);
7869
8531
  services?.keybindingService.unregisteEl("stage");
7870
8532
  });
8533
+ const parseDSL = getConfig("parseDSL");
7871
8534
  const contextmenuHandler = (e) => {
7872
8535
  e.preventDefault();
7873
8536
  menu.value?.show(e);
7874
8537
  };
7875
8538
  const dragoverHandler = (e) => {
7876
- e.preventDefault();
7877
8539
  if (!e.dataTransfer)
7878
8540
  return;
8541
+ e.preventDefault();
7879
8542
  e.dataTransfer.dropEffect = "move";
7880
8543
  };
7881
8544
  const dropHandler = async (e) => {
8545
+ if (!e.dataTransfer)
8546
+ return;
8547
+ const data = e.dataTransfer.getData("text/json");
8548
+ if (!data)
8549
+ return;
8550
+ const config = parseDSL(`(${data})`);
8551
+ if (!config || config.dragType !== DragType.COMPONENT_LIST)
8552
+ return;
7882
8553
  e.preventDefault();
7883
8554
  const doc = stage?.renderer.contentWindow?.document;
7884
8555
  const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
@@ -7886,18 +8557,11 @@
7886
8557
  if (parentEl) {
7887
8558
  parent = services?.editorService.getNodeById(parentEl.id, false);
7888
8559
  }
7889
- if (e.dataTransfer && parent && stageContainer.value && stage) {
7890
- const parseDSL = getConfig("parseDSL");
7891
- const data = e.dataTransfer.getData("text/json");
7892
- if (!data)
7893
- return;
7894
- const config = parseDSL(`(${data})`);
7895
- if (!config)
7896
- return;
8560
+ if (parent && stageContainer.value && stage) {
7897
8561
  const layout = await services?.editorService.getLayout(parent);
7898
8562
  const containerRect = stageContainer.value.getBoundingClientRect();
7899
8563
  const { scrollTop, scrollLeft } = stage.mask;
7900
- const { style = {} } = config;
8564
+ const { style = {} } = config.data;
7901
8565
  let top = 0;
7902
8566
  let left = 0;
7903
8567
  let position = "relative";
@@ -7911,14 +8575,14 @@
7911
8575
  top = top - StageCore.calcValueByFontsize(doc, parentTop);
7912
8576
  }
7913
8577
  }
7914
- config.style = {
8578
+ config.data.style = {
7915
8579
  ...style,
7916
8580
  position,
7917
8581
  top: top / zoom.value,
7918
8582
  left: left / zoom.value
7919
8583
  };
7920
- config.inputEvent = e;
7921
- services?.editorService.add(config, parent);
8584
+ config.data.inputEvent = e;
8585
+ services?.editorService.add(config.data, parent);
7922
8586
  }
7923
8587
  };
7924
8588
  return (_ctx, _cache) => {
@@ -8104,14 +8768,14 @@
8104
8768
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
8105
8769
  onClick: addPage
8106
8770
  }, [
8107
- vue.createVNode(_sfc_main$K, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
8771
+ vue.createVNode(_sfc_main$M, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
8108
8772
  ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2)),
8109
8773
  canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
8110
8774
  key: 2,
8111
8775
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
8112
8776
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
8113
8777
  }, [
8114
- vue.createVNode(_sfc_main$K, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
8778
+ vue.createVNode(_sfc_main$M, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
8115
8779
  ])) : vue.createCommentVNode("", true),
8116
8780
  pageLength.value ? (vue.openBlock(), vue.createElementBlock("div", {
8117
8781
  key: 3,
@@ -8127,7 +8791,7 @@
8127
8791
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
8128
8792
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
8129
8793
  }, [
8130
- vue.createVNode(_sfc_main$K, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
8794
+ vue.createVNode(_sfc_main$M, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
8131
8795
  ])) : vue.createCommentVNode("", true)
8132
8796
  ], 512);
8133
8797
  };
@@ -8199,7 +8863,7 @@
8199
8863
  default: vue.withCtx(() => [
8200
8864
  vue.createElementVNode("div", null, [
8201
8865
  vue.renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
8202
- vue.createVNode(_sfc_main$v, {
8866
+ vue.createVNode(_sfc_main$w, {
8203
8867
  data: {
8204
8868
  type: "button",
8205
8869
  text: "复制",
@@ -8207,7 +8871,7 @@
8207
8871
  handler: () => copy(item)
8208
8872
  }
8209
8873
  }, null, 8, ["data"]),
8210
- vue.createVNode(_sfc_main$v, {
8874
+ vue.createVNode(_sfc_main$w, {
8211
8875
  data: {
8212
8876
  type: "button",
8213
8877
  text: "删除",
@@ -9048,119 +9712,23 @@
9048
9712
  }
9049
9713
  ];
9050
9714
 
9051
- const editorProps = {
9052
- /** 页面初始值 */
9053
- modelValue: {
9054
- type: Object,
9055
- default: () => ({}),
9056
- require: true
9057
- },
9058
- /** 左侧面板中的组件列表 */
9059
- componentGroupList: {
9060
- type: Array,
9061
- default: () => []
9062
- },
9063
- /** 左侧面板中的组件列表 */
9064
- datasourceList: {
9065
- type: Array,
9066
- default: () => []
9067
- },
9068
- /** 左侧面板配置 */
9069
- sidebar: {
9070
- type: Object
9071
- },
9072
- /** 顶部工具栏配置 */
9073
- menu: {
9074
- type: Object,
9075
- default: () => ({ left: [], right: [] })
9076
- },
9077
- /** 组件树右键菜单 */
9078
- layerContentMenu: {
9079
- type: Array,
9080
- default: () => []
9081
- },
9082
- /** 画布右键菜单 */
9083
- stageContentMenu: {
9084
- type: Array,
9085
- default: () => []
9086
- },
9087
- /** 中间工作区域中画布渲染的内容 */
9088
- render: {
9089
- type: Function
9090
- },
9091
- /** 中间工作区域中画布通过iframe渲染时的页面url */
9092
- runtimeUrl: String,
9093
- /** 选中时是否自动滚动到可视区域 */
9094
- autoScrollIntoView: Boolean,
9095
- /** 组件的属性配置表单的dsl */
9096
- propsConfigs: {
9097
- type: Object,
9098
- default: () => ({})
9099
- },
9100
- /** 添加组件时的默认值 */
9101
- propsValues: {
9102
- type: Object,
9103
- default: () => ({})
9104
- },
9105
- /** 组件联动事件选项列表 */
9106
- eventMethodList: {
9107
- type: Object,
9108
- default: () => ({})
9109
- },
9110
- /** 添加数据源时的默认值 */
9111
- datasourceValues: {
9112
- type: Object,
9113
- default: () => ({})
9114
- },
9115
- /** 数据源的属性配置表单的dsl */
9116
- datasourceConfigs: {
9117
- type: Object,
9118
- default: () => ({})
9119
- },
9120
- /** 画布中组件选中框的移动范围 */
9121
- moveableOptions: {
9122
- type: [Object, Function]
9123
- },
9124
- /** 编辑器初始化时默认选中的组件ID */
9125
- defaultSelected: {
9126
- type: [Number, String]
9127
- },
9128
- canSelect: {
9129
- type: Function,
9130
- default: (el) => Boolean(el.id)
9131
- },
9132
- isContainer: {
9133
- type: Function,
9134
- default: (el) => el.classList.contains("magic-ui-container")
9135
- },
9136
- containerHighlightClassName: {
9137
- type: String,
9138
- default: StageCore.CONTAINER_HIGHLIGHT_CLASS_NAME
9139
- },
9140
- containerHighlightDuration: {
9141
- type: Number,
9142
- default: 800
9143
- },
9144
- containerHighlightType: {
9145
- type: String,
9146
- default: StageCore.ContainerHighlightType.DEFAULT
9147
- },
9148
- stageRect: {
9149
- type: [String, Object]
9150
- },
9151
- codeOptions: {
9152
- type: Object,
9153
- default: () => ({})
9154
- },
9155
- updateDragEl: {
9156
- type: Function
9157
- },
9158
- disabledDragStart: {
9159
- type: Boolean
9160
- },
9161
- extendFormState: {
9162
- type: Function
9163
- }
9715
+ const defaultEditorProps = {
9716
+ componentGroupList: () => [],
9717
+ datasourceList: () => [],
9718
+ menu: () => ({ left: [], right: [] }),
9719
+ layerContentMenu: () => [],
9720
+ stageContentMenu: () => [],
9721
+ propsConfigs: () => ({}),
9722
+ propsValues: () => ({}),
9723
+ eventMethodList: () => ({}),
9724
+ datasourceValues: () => ({}),
9725
+ datasourceConfigs: () => ({}),
9726
+ canSelect: (el) => Boolean(el.id),
9727
+ isContainer: (el) => el.classList.contains("magic-ui-container"),
9728
+ containerHighlightClassName: StageCore.CONTAINER_HIGHLIGHT_CLASS_NAME,
9729
+ containerHighlightDuration: 800,
9730
+ containerHighlightType: StageCore.ContainerHighlightType.DEFAULT,
9731
+ codeOptions: () => ({})
9164
9732
  };
9165
9733
 
9166
9734
  const createCodeBlockTarget = (id, codeBlock) => new Target({
@@ -9181,20 +9749,26 @@
9181
9749
  const createDataSourceTarget = (id) => new Target({
9182
9750
  type: DepTargetType.DATA_SOURCE,
9183
9751
  id,
9184
- isTarget: (key, value) => (
9185
- // 关联数据源对象或者在模板在使用数据源
9186
- value?.isBindDataSource && value.dataSourceId || typeof value === "string" && value.includes(`${id}`)
9187
- )
9752
+ isTarget: (key, value) => {
9753
+ if (value?.isBindDataSource && value.dataSourceId || typeof value === "string" && value.includes(`${id}`)) {
9754
+ return true;
9755
+ }
9756
+ if (!Array.isArray(value) || typeof value[0] !== "string") {
9757
+ return false;
9758
+ }
9759
+ const [prefixId] = value;
9760
+ const prefixIndex = prefixId.indexOf(utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);
9761
+ if (prefixIndex === -1) {
9762
+ return false;
9763
+ }
9764
+ const dsId = prefixId.substring(prefixIndex + utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length);
9765
+ return dsId === id && Boolean(dataSourceService.getDataSourceById(id));
9766
+ }
9188
9767
  });
9189
9768
  const createDataSourceCondTarget = (id) => new Target({
9190
9769
  type: DepTargetType.DATA_SOURCE_COND,
9191
9770
  id,
9192
- isTarget: (key, value) => {
9193
- if (!Array.isArray(value) || value[0] !== id)
9194
- return false;
9195
- const ds = dataSourceService.getDataSourceById(id);
9196
- return Boolean(ds?.fields?.find((field) => field.name === value[1]));
9197
- }
9771
+ isTarget: (key, value) => Array.isArray(value) && value[0] === id && Boolean(dataSourceService.getDataSourceById(id))
9198
9772
  });
9199
9773
  const createDataSourceMethodTarget = (id) => new Target({
9200
9774
  type: DepTargetType.DATA_SOURCE_METHOD,
@@ -9221,7 +9795,7 @@
9221
9795
  vue.watch(
9222
9796
  () => props.modelValue,
9223
9797
  (modelValue) => {
9224
- editorService.set("root", modelValue);
9798
+ editorService.set("root", modelValue || null);
9225
9799
  },
9226
9800
  {
9227
9801
  immediate: true
@@ -9229,28 +9803,28 @@
9229
9803
  );
9230
9804
  vue.watch(
9231
9805
  () => props.componentGroupList,
9232
- (componentGroupList) => componentListService.setList(componentGroupList),
9806
+ (componentGroupList) => componentGroupList && componentListService.setList(componentGroupList),
9233
9807
  {
9234
9808
  immediate: true
9235
9809
  }
9236
9810
  );
9237
9811
  vue.watch(
9238
9812
  () => props.datasourceList,
9239
- (datasourceList) => dataSourceService.set("datasourceTypeList", datasourceList),
9813
+ (datasourceList) => datasourceList && dataSourceService.set("datasourceTypeList", datasourceList),
9240
9814
  {
9241
9815
  immediate: true
9242
9816
  }
9243
9817
  );
9244
9818
  vue.watch(
9245
9819
  () => props.propsConfigs,
9246
- (configs) => propsService.setPropsConfigs(configs),
9820
+ (configs) => configs && propsService.setPropsConfigs(configs),
9247
9821
  {
9248
9822
  immediate: true
9249
9823
  }
9250
9824
  );
9251
9825
  vue.watch(
9252
9826
  () => props.propsValues,
9253
- (values) => propsService.setPropsValues(values),
9827
+ (values) => values && propsService.setPropsValues(values),
9254
9828
  {
9255
9829
  immediate: true
9256
9830
  }
@@ -9260,7 +9834,7 @@
9260
9834
  (eventMethodList) => {
9261
9835
  const eventsList = {};
9262
9836
  const methodsList = {};
9263
- Object.keys(eventMethodList).forEach((type) => {
9837
+ eventMethodList && Object.keys(eventMethodList).forEach((type) => {
9264
9838
  eventsList[type] = eventMethodList[type].events;
9265
9839
  methodsList[type] = eventMethodList[type].methods;
9266
9840
  });
@@ -9274,7 +9848,7 @@
9274
9848
  vue.watch(
9275
9849
  () => props.datasourceConfigs,
9276
9850
  (configs) => {
9277
- Object.entries(configs).forEach(([key, value]) => {
9851
+ configs && Object.entries(configs).forEach(([key, value]) => {
9278
9852
  dataSourceService.setFormConfig(key, value);
9279
9853
  });
9280
9854
  },
@@ -9285,7 +9859,7 @@
9285
9859
  vue.watch(
9286
9860
  () => props.datasourceValues,
9287
9861
  (values) => {
9288
- Object.entries(values).forEach(([key, value]) => {
9862
+ values && Object.entries(values).forEach(([key, value]) => {
9289
9863
  dataSourceService.setFormValue(key, value);
9290
9864
  });
9291
9865
  },
@@ -9293,6 +9867,26 @@
9293
9867
  immediate: true
9294
9868
  }
9295
9869
  );
9870
+ vue.watch(
9871
+ () => props.datasourceEventMethodList,
9872
+ (eventMethodList) => {
9873
+ const eventsList = {};
9874
+ const methodsList = {};
9875
+ eventMethodList && Object.keys(eventMethodList).forEach((type) => {
9876
+ eventsList[type] = eventMethodList[type].events;
9877
+ methodsList[type] = eventMethodList[type].methods;
9878
+ });
9879
+ Object.entries(eventsList).forEach(([key, value]) => {
9880
+ dataSourceService.setFormEvent(key, value);
9881
+ });
9882
+ Object.entries(methodsList).forEach(([key, value]) => {
9883
+ dataSourceService.setFormMethod(key, value);
9884
+ });
9885
+ },
9886
+ {
9887
+ immediate: true
9888
+ }
9889
+ );
9296
9890
  vue.watch(
9297
9891
  () => props.defaultSelected,
9298
9892
  (defaultSelected) => defaultSelected && editorService.select(defaultSelected),
@@ -9414,6 +10008,8 @@
9414
10008
  if (vue.toRaw(value) !== vue.toRaw(preValue)) {
9415
10009
  emit("update:modelValue", value);
9416
10010
  }
10011
+ if (!value)
10012
+ return;
9417
10013
  value.codeBlocks = value.codeBlocks || {};
9418
10014
  value.dataSources = value.dataSources || [];
9419
10015
  codeBlockService.setCodeDsl(value.codeBlocks);
@@ -9496,18 +10092,44 @@
9496
10092
  });
9497
10093
  };
9498
10094
 
9499
- const _sfc_main = vue.defineComponent({
9500
- name: "MEditor",
9501
- components: {
9502
- TMagicNavMenu: _sfc_main$u,
9503
- Sidebar: _sfc_main$e,
9504
- Workspace: _sfc_main$1,
9505
- PropsPanel: _sfc_main$t,
9506
- Framework: _sfc_main$w
9507
- },
9508
- props: editorProps,
10095
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
10096
+ ...{
10097
+ name: "MEditor"
10098
+ },
10099
+ __name: "Editor",
10100
+ props: vue.mergeDefaults({
10101
+ modelValue: {},
10102
+ componentGroupList: {},
10103
+ datasourceList: {},
10104
+ sidebar: {},
10105
+ menu: {},
10106
+ layerContentMenu: {},
10107
+ stageContentMenu: {},
10108
+ render: { type: Function },
10109
+ runtimeUrl: {},
10110
+ autoScrollIntoView: { type: Boolean },
10111
+ propsConfigs: {},
10112
+ propsValues: {},
10113
+ eventMethodList: {},
10114
+ datasourceValues: {},
10115
+ datasourceConfigs: {},
10116
+ datasourceEventMethodList: {},
10117
+ moveableOptions: { type: Function },
10118
+ defaultSelected: {},
10119
+ canSelect: { type: Function },
10120
+ isContainer: { type: Function },
10121
+ containerHighlightClassName: {},
10122
+ containerHighlightDuration: {},
10123
+ containerHighlightType: {},
10124
+ stageRect: {},
10125
+ codeOptions: {},
10126
+ updateDragEl: { type: Function },
10127
+ disabledDragStart: { type: Boolean },
10128
+ extendFormState: { type: Function }
10129
+ }, defaultEditorProps),
9509
10130
  emits: ["props-panel-mounted", "update:modelValue"],
9510
- setup(props, { emit }) {
10131
+ setup(__props, { expose: __expose, emit }) {
10132
+ const props = __props;
9511
10133
  const services = {
9512
10134
  componentListService,
9513
10135
  eventsService,
@@ -9543,119 +10165,101 @@
9543
10165
  disabledDragStart: props.disabledDragStart
9544
10166
  })
9545
10167
  );
9546
- return services;
10168
+ __expose(services);
10169
+ return (_ctx, _cache) => {
10170
+ return vue.openBlock(), vue.createBlock(_sfc_main$x, null, {
10171
+ header: vue.withCtx(() => [
10172
+ vue.renderSlot(_ctx.$slots, "header")
10173
+ ]),
10174
+ nav: vue.withCtx(() => [
10175
+ vue.renderSlot(_ctx.$slots, "nav", { editorService: vue.unref(editorService) }, () => [
10176
+ vue.createVNode(_sfc_main$v, { data: _ctx.menu }, null, 8, ["data"])
10177
+ ])
10178
+ ]),
10179
+ "content-before": vue.withCtx(() => [
10180
+ vue.renderSlot(_ctx.$slots, "content-before")
10181
+ ]),
10182
+ "src-code": vue.withCtx(() => [
10183
+ vue.renderSlot(_ctx.$slots, "src-code", { editorService: vue.unref(editorService) })
10184
+ ]),
10185
+ sidebar: vue.withCtx(() => [
10186
+ vue.renderSlot(_ctx.$slots, "sidebar", { editorService: vue.unref(editorService) }, () => [
10187
+ vue.createVNode(_sfc_main$e, {
10188
+ data: _ctx.sidebar,
10189
+ "layer-content-menu": _ctx.layerContentMenu
10190
+ }, {
10191
+ "layer-panel-header": vue.withCtx(() => [
10192
+ vue.renderSlot(_ctx.$slots, "layer-panel-header")
10193
+ ]),
10194
+ "layer-node-content": vue.withCtx(({ data }) => [
10195
+ vue.renderSlot(_ctx.$slots, "layer-node-content", { data })
10196
+ ]),
10197
+ "component-list-panel-header": vue.withCtx(() => [
10198
+ vue.renderSlot(_ctx.$slots, "component-list-panel-header")
10199
+ ]),
10200
+ "component-list-item": vue.withCtx(({ component }) => [
10201
+ vue.renderSlot(_ctx.$slots, "component-list-item", { component })
10202
+ ]),
10203
+ "code-block-panel-header": vue.withCtx(() => [
10204
+ vue.renderSlot(_ctx.$slots, "code-block-panel-header")
10205
+ ]),
10206
+ "code-block-panel-tool": vue.withCtx(({ id, data }) => [
10207
+ vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
10208
+ id,
10209
+ data
10210
+ })
10211
+ ]),
10212
+ _: 3
10213
+ }, 8, ["data", "layer-content-menu"])
10214
+ ])
10215
+ ]),
10216
+ workspace: vue.withCtx(() => [
10217
+ vue.renderSlot(_ctx.$slots, "workspace", { editorService: vue.unref(editorService) }, () => [
10218
+ vue.createVNode(_sfc_main$1, { "stage-content-menu": _ctx.stageContentMenu }, {
10219
+ stage: vue.withCtx(() => [
10220
+ vue.renderSlot(_ctx.$slots, "stage")
10221
+ ]),
10222
+ "workspace-content": vue.withCtx(() => [
10223
+ vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: vue.unref(editorService) })
10224
+ ]),
10225
+ "page-bar-title": vue.withCtx(({ page }) => [
10226
+ vue.renderSlot(_ctx.$slots, "page-bar-title", { page })
10227
+ ]),
10228
+ "page-bar-popover": vue.withCtx(({ page }) => [
10229
+ vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
10230
+ ]),
10231
+ _: 3
10232
+ }, 8, ["stage-content-menu"])
10233
+ ])
10234
+ ]),
10235
+ "props-panel": vue.withCtx(() => [
10236
+ vue.renderSlot(_ctx.$slots, "props-panel", {}, () => [
10237
+ vue.createVNode(_sfc_main$u, {
10238
+ "extend-state": _ctx.extendFormState,
10239
+ onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
10240
+ }, {
10241
+ "props-panel-header": vue.withCtx(() => [
10242
+ vue.renderSlot(_ctx.$slots, "props-panel-header")
10243
+ ]),
10244
+ _: 3
10245
+ }, 8, ["extend-state"])
10246
+ ])
10247
+ ]),
10248
+ empty: vue.withCtx(() => [
10249
+ vue.renderSlot(_ctx.$slots, "empty", { editorService: vue.unref(editorService) })
10250
+ ]),
10251
+ "content-after": vue.withCtx(() => [
10252
+ vue.renderSlot(_ctx.$slots, "content-after")
10253
+ ]),
10254
+ footer: vue.withCtx(() => [
10255
+ vue.renderSlot(_ctx.$slots, "footer")
10256
+ ]),
10257
+ _: 3
10258
+ });
10259
+ };
9547
10260
  }
9548
10261
  });
9549
10262
 
9550
- const _export_sfc = (sfc, props) => {
9551
- const target = sfc.__vccOpts || sfc;
9552
- for (const [key, val] of props) {
9553
- target[key] = val;
9554
- }
9555
- return target;
9556
- };
9557
-
9558
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
9559
- const _component_TMagicNavMenu = vue.resolveComponent("TMagicNavMenu");
9560
- const _component_Sidebar = vue.resolveComponent("Sidebar");
9561
- const _component_Workspace = vue.resolveComponent("Workspace");
9562
- const _component_PropsPanel = vue.resolveComponent("PropsPanel");
9563
- const _component_Framework = vue.resolveComponent("Framework");
9564
- return vue.openBlock(), vue.createBlock(_component_Framework, null, {
9565
- header: vue.withCtx(() => [
9566
- vue.renderSlot(_ctx.$slots, "header")
9567
- ]),
9568
- nav: vue.withCtx(() => [
9569
- vue.renderSlot(_ctx.$slots, "nav", { editorService: _ctx.editorService }, () => [
9570
- vue.createVNode(_component_TMagicNavMenu, { data: _ctx.menu }, null, 8, ["data"])
9571
- ])
9572
- ]),
9573
- "content-before": vue.withCtx(() => [
9574
- vue.renderSlot(_ctx.$slots, "content-before")
9575
- ]),
9576
- "src-code": vue.withCtx(() => [
9577
- vue.renderSlot(_ctx.$slots, "src-code", { editorService: _ctx.editorService })
9578
- ]),
9579
- sidebar: vue.withCtx(() => [
9580
- vue.renderSlot(_ctx.$slots, "sidebar", { editorService: _ctx.editorService }, () => [
9581
- vue.createVNode(_component_Sidebar, {
9582
- data: _ctx.sidebar,
9583
- "layer-content-menu": _ctx.layerContentMenu
9584
- }, {
9585
- "layer-panel-header": vue.withCtx(() => [
9586
- vue.renderSlot(_ctx.$slots, "layer-panel-header")
9587
- ]),
9588
- "layer-node-content": vue.withCtx(({ node, data }) => [
9589
- vue.renderSlot(_ctx.$slots, "layer-node-content", {
9590
- data,
9591
- node
9592
- })
9593
- ]),
9594
- "component-list-panel-header": vue.withCtx(() => [
9595
- vue.renderSlot(_ctx.$slots, "component-list-panel-header")
9596
- ]),
9597
- "component-list-item": vue.withCtx(({ component }) => [
9598
- vue.renderSlot(_ctx.$slots, "component-list-item", { component })
9599
- ]),
9600
- "code-block-panel-header": vue.withCtx(() => [
9601
- vue.renderSlot(_ctx.$slots, "code-block-panel-header")
9602
- ]),
9603
- "code-block-panel-tool": vue.withCtx(({ id, data }) => [
9604
- vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
9605
- id,
9606
- data
9607
- })
9608
- ]),
9609
- _: 3
9610
- }, 8, ["data", "layer-content-menu"])
9611
- ])
9612
- ]),
9613
- workspace: vue.withCtx(() => [
9614
- vue.renderSlot(_ctx.$slots, "workspace", { editorService: _ctx.editorService }, () => [
9615
- vue.createVNode(_component_Workspace, { "stage-content-menu": _ctx.stageContentMenu }, {
9616
- stage: vue.withCtx(() => [
9617
- vue.renderSlot(_ctx.$slots, "stage")
9618
- ]),
9619
- "workspace-content": vue.withCtx(() => [
9620
- vue.renderSlot(_ctx.$slots, "workspace-content", { editorService: _ctx.editorService })
9621
- ]),
9622
- "page-bar-title": vue.withCtx(({ page }) => [
9623
- vue.renderSlot(_ctx.$slots, "page-bar-title", { page })
9624
- ]),
9625
- "page-bar-popover": vue.withCtx(({ page }) => [
9626
- vue.renderSlot(_ctx.$slots, "page-bar-popover", { page })
9627
- ]),
9628
- _: 3
9629
- }, 8, ["stage-content-menu"])
9630
- ])
9631
- ]),
9632
- "props-panel": vue.withCtx(() => [
9633
- vue.renderSlot(_ctx.$slots, "props-panel", {}, () => [
9634
- vue.createVNode(_component_PropsPanel, {
9635
- "extend-state": _ctx.extendFormState,
9636
- onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance))
9637
- }, {
9638
- "props-panel-header": vue.withCtx(() => [
9639
- vue.renderSlot(_ctx.$slots, "props-panel-header")
9640
- ]),
9641
- _: 3
9642
- }, 8, ["extend-state"])
9643
- ])
9644
- ]),
9645
- empty: vue.withCtx(() => [
9646
- vue.renderSlot(_ctx.$slots, "empty", { editorService: _ctx.editorService })
9647
- ]),
9648
- "content-after": vue.withCtx(() => [
9649
- vue.renderSlot(_ctx.$slots, "content-after")
9650
- ]),
9651
- footer: vue.withCtx(() => [
9652
- vue.renderSlot(_ctx.$slots, "footer")
9653
- ]),
9654
- _: 3
9655
- });
9656
- }
9657
- const Editor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
9658
-
9659
10263
  const index$1 = '';
9660
10264
 
9661
10265
  const defaultInstallOpt = {
@@ -9667,59 +10271,62 @@
9667
10271
  const option = Object.assign(defaultInstallOpt, opt || {});
9668
10272
  app.config.globalProperties.$TMAGIC_EDITOR = option;
9669
10273
  setConfig(option);
9670
- app.component(Editor.name, Editor);
9671
- app.component("m-fields-ui-select", _sfc_main$A);
9672
- app.component("m-fields-code-link", _sfc_main$O);
9673
- app.component("m-fields-vs-code", _sfc_main$P);
9674
- app.component("magic-code-editor", _sfc_main$Q);
9675
- app.component("m-fields-code-select", _sfc_main$N);
9676
- app.component("m-fields-code-select-col", _sfc_main$J);
9677
- app.component("m-fields-event-select", _sfc_main$C);
9678
- app.component("m-fields-data-source-fields", _sfc_main$I);
9679
- app.component("m-fields-key-value", _sfc_main$B);
9680
- app.component("m-fields-data-source-input", _sfc_main$G);
9681
- app.component("m-fields-data-source-select", _sfc_main$D);
9682
- app.component("m-fields-data-source-methods", _sfc_main$F);
9683
- app.component("m-fields-data-source-method-select", _sfc_main$E);
9684
- app.component("m-fields-data-source-field-select", _sfc_main$H);
10274
+ app.component(_sfc_main.name, _sfc_main);
10275
+ app.component("m-fields-ui-select", _sfc_main$B);
10276
+ app.component("m-fields-code-link", _sfc_main$Q);
10277
+ app.component("m-fields-vs-code", _sfc_main$R);
10278
+ app.component("magic-code-editor", _sfc_main$S);
10279
+ app.component("m-fields-code-select", _sfc_main$P);
10280
+ app.component("m-fields-code-select-col", _sfc_main$L);
10281
+ app.component("m-fields-event-select", _sfc_main$D);
10282
+ app.component("m-fields-data-source-fields", _sfc_main$K);
10283
+ app.component("m-fields-data-source-mocks", _sfc_main$F);
10284
+ app.component("m-fields-key-value", _sfc_main$C);
10285
+ app.component("m-fields-data-source-input", _sfc_main$I);
10286
+ app.component("m-fields-data-source-select", _sfc_main$E);
10287
+ app.component("m-fields-data-source-methods", _sfc_main$H);
10288
+ app.component("m-fields-data-source-method-select", _sfc_main$G);
10289
+ app.component("m-fields-data-source-field-select", _sfc_main$J);
9685
10290
  }
9686
10291
  };
9687
10292
 
9688
10293
  exports.CODE_DRAFT_STORAGE_KEY = CODE_DRAFT_STORAGE_KEY;
9689
10294
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
9690
- exports.CodeBlockEditor = _sfc_main$M;
9691
- exports.CodeBlockList = _sfc_main$p;
9692
- exports.CodeBlockListPanel = _sfc_main$o;
10295
+ exports.CodeBlockEditor = _sfc_main$O;
10296
+ exports.CodeBlockList = _sfc_main$q;
10297
+ exports.CodeBlockListPanel = _sfc_main$p;
9693
10298
  exports.CodeDeleteErrorType = CodeDeleteErrorType;
9694
- exports.CodeSelect = _sfc_main$N;
9695
- exports.CodeSelectCol = _sfc_main$J;
10299
+ exports.CodeSelect = _sfc_main$P;
10300
+ exports.CodeSelectCol = _sfc_main$L;
9696
10301
  exports.ColumnLayout = ColumnLayout;
9697
- exports.ComponentListPanel = _sfc_main$k;
9698
- exports.ContentMenu = _sfc_main$j;
9699
- exports.DataSourceFieldSelect = _sfc_main$H;
9700
- exports.DataSourceFields = _sfc_main$I;
9701
- exports.DataSourceInput = _sfc_main$G;
9702
- exports.DataSourceMethodSelect = _sfc_main$E;
9703
- exports.DataSourceMethods = _sfc_main$F;
9704
- exports.DataSourceSelect = _sfc_main$D;
10302
+ exports.ComponentListPanel = _sfc_main$f;
10303
+ exports.ContentMenu = _sfc_main$l;
10304
+ exports.DataSourceFieldSelect = _sfc_main$J;
10305
+ exports.DataSourceFields = _sfc_main$K;
10306
+ exports.DataSourceInput = _sfc_main$I;
10307
+ exports.DataSourceMethodSelect = _sfc_main$G;
10308
+ exports.DataSourceMethods = _sfc_main$H;
10309
+ exports.DataSourceMocks = _sfc_main$F;
10310
+ exports.DataSourceSelect = _sfc_main$E;
9705
10311
  exports.DepTargetType = DepTargetType;
9706
- exports.EventSelect = _sfc_main$C;
10312
+ exports.DragType = DragType;
10313
+ exports.EventSelect = _sfc_main$D;
9707
10314
  exports.Fixed2Other = Fixed2Other;
9708
10315
  exports.H_GUIDE_LINE_STORAGE_KEY = H_GUIDE_LINE_STORAGE_KEY;
9709
- exports.Icon = _sfc_main$K;
10316
+ exports.Icon = _sfc_main$M;
9710
10317
  exports.KeyBindingCommand = KeyBindingCommand;
9711
- exports.KeyValue = _sfc_main$B;
10318
+ exports.KeyValue = _sfc_main$C;
9712
10319
  exports.Keys = Keys;
9713
10320
  exports.LayerOffset = LayerOffset;
9714
- exports.LayerPanel = _sfc_main$f;
10321
+ exports.LayerPanel = _sfc_main$g;
9715
10322
  exports.Layout = Layout;
9716
- exports.LayoutContainer = _sfc_main$y;
9717
- exports.PropsPanel = _sfc_main$t;
9718
- exports.Resizer = _sfc_main$z;
9719
- exports.SplitView = _sfc_main$y;
9720
- exports.TMagicCodeEditor = _sfc_main$Q;
9721
- exports.TMagicEditor = Editor;
9722
- exports.ToolButton = _sfc_main$v;
10323
+ exports.LayoutContainer = _sfc_main$z;
10324
+ exports.PropsPanel = _sfc_main$u;
10325
+ exports.Resizer = _sfc_main$A;
10326
+ exports.SplitView = _sfc_main$z;
10327
+ exports.TMagicCodeEditor = _sfc_main$S;
10328
+ exports.TMagicEditor = _sfc_main;
10329
+ exports.ToolButton = _sfc_main$w;
9723
10330
  exports.V_GUIDE_LINE_STORAGE_KEY = V_GUIDE_LINE_STORAGE_KEY;
9724
10331
  exports.advancedTabConfig = advancedTabConfig;
9725
10332
  exports.beforePaste = beforePaste;
@@ -9761,6 +10368,7 @@
9761
10368
  exports.setLayout = setLayout;
9762
10369
  exports.storageService = storageService;
9763
10370
  exports.styleTabConfig = styleTabConfig;
10371
+ exports.traverseNode = traverseNode;
9764
10372
  exports.uiService = uiService;
9765
10373
  exports.useCodeBlockEdit = useCodeBlockEdit;
9766
10374
  exports.useDataSourceMethod = useDataSourceMethod;