@tmagic/editor 1.3.0-alpha.8 → 1.3.0-alpha.9

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.
@@ -3,8 +3,8 @@ import serialize from 'serialize-javascript';
3
3
  import { isEmpty, map, has, throttle, cloneDeep, mergeWith, isObject, uniq, forIn, difference, union, pick, keys } from 'lodash-es';
4
4
  import { TMagicCard, TMagicIcon, TMagicButton, tMagicMessageBox, getConfig as getConfig$1, TMagicTag, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, TMagicDrawer, TMagicTree, TMagicCollapse, TMagicCollapseItem, TMagicPopover } from '@tmagic/design';
5
5
  import { HookType, ActionType, NodeType } from '@tmagic/schema';
6
- import { Edit, View, Coin, Delete, Plus, Close, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Aim, Files, CopyDocument, Goods, List, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
7
- import { createValues, MFormDialog, MForm } from '@tmagic/form';
6
+ import { Edit, View, Coin, Delete, Plus, Close, ArrowDown, Grid, Memo, FullScreen, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Aim, Files, CopyDocument, Hide, Goods, List, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Top, Bottom } from '@element-plus/icons-vue';
7
+ import { createValues, MFormDialog, MSelect, MForm } from '@tmagic/form';
8
8
  import { MagicTable } from '@tmagic/table';
9
9
  import * as monaco from 'monaco-editor';
10
10
  import Gesto from 'gesto';
@@ -14,7 +14,7 @@ import { EventEmitter } from 'events';
14
14
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
15
15
  import KeyController from 'keycon';
16
16
 
17
- const _sfc_main$E = /* @__PURE__ */ defineComponent({
17
+ const _sfc_main$G = /* @__PURE__ */ defineComponent({
18
18
  ...{
19
19
  name: "MEditorCode"
20
20
  },
@@ -53,7 +53,7 @@ const setConfig = (option) => {
53
53
  };
54
54
  const getConfig = (key) => $TMAGIC_EDITOR[key];
55
55
 
56
- const _sfc_main$D = /* @__PURE__ */ defineComponent({
56
+ const _sfc_main$F = /* @__PURE__ */ defineComponent({
57
57
  ...{
58
58
  name: "MEditorCodeLink"
59
59
  },
@@ -127,7 +127,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
127
127
  }
128
128
  });
129
129
 
130
- const _sfc_main$C = /* @__PURE__ */ defineComponent({
130
+ const _sfc_main$E = /* @__PURE__ */ defineComponent({
131
131
  ...{
132
132
  name: "MEditorCodeSelect"
133
133
  },
@@ -192,8 +192,8 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
192
192
  }
193
193
  });
194
194
 
195
- const _hoisted_1$n = ["src"];
196
- const _sfc_main$B = /* @__PURE__ */ defineComponent({
195
+ const _hoisted_1$o = ["src"];
196
+ const _sfc_main$D = /* @__PURE__ */ defineComponent({
197
197
  ...{
198
198
  name: "MEditorIcon"
199
199
  },
@@ -216,7 +216,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
216
216
  class: "magic-editor-icon"
217
217
  }, {
218
218
  default: withCtx(() => [
219
- createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$n)
219
+ createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$o)
220
220
  ]),
221
221
  _: 1
222
222
  })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
@@ -235,9 +235,9 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
235
235
  }
236
236
  });
237
237
 
238
- const _hoisted_1$m = { class: "m-fields-code-select-col" };
238
+ const _hoisted_1$n = { class: "m-fields-code-select-col" };
239
239
  const _hoisted_2$e = { class: "code-select-container" };
240
- const _sfc_main$A = /* @__PURE__ */ defineComponent({
240
+ const _sfc_main$C = /* @__PURE__ */ defineComponent({
241
241
  ...{
242
242
  name: "MEditorCodeSelectCol"
243
243
  },
@@ -329,7 +329,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
329
329
  };
330
330
  return (_ctx, _cache) => {
331
331
  const _component_m_form_container = resolveComponent("m-form-container");
332
- return openBlock(), createElementBlock("div", _hoisted_1$m, [
332
+ return openBlock(), createElementBlock("div", _hoisted_1$n, [
333
333
  createElementVNode("div", _hoisted_2$e, [
334
334
  createVNode(_component_m_form_container, {
335
335
  class: "select",
@@ -337,7 +337,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
337
337
  model: _ctx.model,
338
338
  onChange: onParamsChangeHandler
339
339
  }, null, 8, ["model"]),
340
- createVNode(_sfc_main$B, {
340
+ createVNode(_sfc_main$D, {
341
341
  class: "icon",
342
342
  icon: editable.value ? unref(Edit) : unref(View),
343
343
  onClick: editCode
@@ -353,9 +353,9 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
353
353
  }
354
354
  });
355
355
 
356
- const _hoisted_1$l = { class: "m-editor-data-source-fields" };
356
+ const _hoisted_1$m = { class: "m-editor-data-source-fields" };
357
357
  const _hoisted_2$d = { class: "m-editor-data-source-fields-footer" };
358
- const _sfc_main$z = /* @__PURE__ */ defineComponent({
358
+ const _sfc_main$B = /* @__PURE__ */ defineComponent({
359
359
  ...{
360
360
  name: "MEditorDataSourceFields"
361
361
  },
@@ -501,7 +501,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
501
501
  }
502
502
  ];
503
503
  return (_ctx, _cache) => {
504
- return openBlock(), createElementBlock("div", _hoisted_1$l, [
504
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
505
505
  createVNode(unref(MagicTable), {
506
506
  data: _ctx.model[_ctx.name],
507
507
  columns: filedColumns
@@ -534,10 +534,10 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
534
534
  }
535
535
  });
536
536
 
537
- const _hoisted_1$k = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
537
+ const _hoisted_1$l = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
538
538
  const _hoisted_2$c = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
539
539
  const _hoisted_3$5 = { class: "el-input__inner" };
540
- const _sfc_main$y = /* @__PURE__ */ defineComponent({
540
+ const _sfc_main$A = /* @__PURE__ */ defineComponent({
541
541
  ...{
542
542
  name: "MEditorDataSourceInput"
543
543
  },
@@ -756,10 +756,10 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
756
756
  }
757
757
  ), {
758
758
  suffix: withCtx(() => [
759
- createVNode(_sfc_main$B, { icon: unref(Coin) }, null, 8, ["icon"])
759
+ createVNode(_sfc_main$D, { icon: unref(Coin) }, null, 8, ["icon"])
760
760
  ]),
761
761
  default: withCtx(({ item }) => [
762
- createElementVNode("div", _hoisted_1$k, [
762
+ createElementVNode("div", _hoisted_1$l, [
763
763
  createElementVNode("div", null, toDisplayString(item.text), 1),
764
764
  createElementVNode("span", _hoisted_2$c, toDisplayString(item.value), 1)
765
765
  ])
@@ -791,7 +791,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
791
791
  }, 1032, ["size"])) : createCommentVNode("", true)
792
792
  ], 64);
793
793
  }), 256)),
794
- createVNode(_sfc_main$B, {
794
+ createVNode(_sfc_main$D, {
795
795
  class: "tmagic-data-source-input-icon",
796
796
  icon: unref(Coin)
797
797
  }, null, 8, ["icon"])
@@ -802,12 +802,65 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
802
802
  }
803
803
  });
804
804
 
805
- const _hoisted_1$j = { class: "m-fields-event-select" };
805
+ const _sfc_main$z = /* @__PURE__ */ defineComponent({
806
+ ...{
807
+ name: "MEditorDataSourceSelect"
808
+ },
809
+ __name: "DataSourceSelect",
810
+ props: {
811
+ config: {},
812
+ model: {},
813
+ name: {},
814
+ prop: {},
815
+ disabled: { type: Boolean, default: false },
816
+ lastValues: {},
817
+ size: {}
818
+ },
819
+ emits: ["change"],
820
+ setup(__props, { emit }) {
821
+ const props = __props;
822
+ const { dataSourceService } = inject("services") || {};
823
+ const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
824
+ const selectConfig = computed(() => {
825
+ const { type, dataSourceType, ...config } = props.config;
826
+ return {
827
+ ...config,
828
+ type: "select",
829
+ valueKey: "dataSourceId",
830
+ options: dataSources.value.filter((ds) => !dataSourceType || ds.type === dataSourceType).map((ds) => ({
831
+ value: {
832
+ isBindDataSource: true,
833
+ dataSourceType: ds.type,
834
+ dataSourceId: ds.id
835
+ },
836
+ text: ds.title || ds.id
837
+ }))
838
+ };
839
+ });
840
+ const changeHandler = (value) => {
841
+ emit("change", value);
842
+ };
843
+ return (_ctx, _cache) => {
844
+ return openBlock(), createBlock(unref(MSelect), {
845
+ model: _ctx.model,
846
+ name: _ctx.name,
847
+ size: _ctx.size,
848
+ prop: _ctx.prop,
849
+ disabled: _ctx.disabled,
850
+ config: selectConfig.value,
851
+ "last-values": _ctx.lastValues,
852
+ onChange: changeHandler
853
+ }, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]);
854
+ };
855
+ }
856
+ });
857
+
858
+ const _hoisted_1$k = { class: "m-fields-event-select" };
806
859
  const _hoisted_2$b = {
807
860
  key: 1,
808
861
  class: "fullWidth"
809
862
  };
810
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
863
+ const _sfc_main$y = /* @__PURE__ */ defineComponent({
811
864
  ...{
812
865
  name: "MEditorEventSelect"
813
866
  },
@@ -969,7 +1022,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
969
1022
  const _component_m_form_table = resolveComponent("m-form-table");
970
1023
  const _component_m_form_container = resolveComponent("m-form-container");
971
1024
  const _component_m_form_panel = resolveComponent("m-form-panel");
972
- return openBlock(), createElementBlock("div", _hoisted_1$j, [
1025
+ return openBlock(), createElementBlock("div", _hoisted_1$k, [
973
1026
  isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
974
1027
  key: 0,
975
1028
  ref: "eventForm",
@@ -1020,9 +1073,9 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
1020
1073
  }
1021
1074
  });
1022
1075
 
1023
- const _hoisted_1$i = { class: "m-fields-key-value" };
1076
+ const _hoisted_1$j = { class: "m-fields-key-value" };
1024
1077
  const _hoisted_2$a = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
1025
- const _sfc_main$w = /* @__PURE__ */ defineComponent({
1078
+ const _sfc_main$x = /* @__PURE__ */ defineComponent({
1026
1079
  ...{
1027
1080
  name: "MEditorKeyValue"
1028
1081
  },
@@ -1065,7 +1118,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
1065
1118
  records.value.splice(index, 1);
1066
1119
  };
1067
1120
  return (_ctx, _cache) => {
1068
- return openBlock(), createElementBlock("div", _hoisted_1$i, [
1121
+ return openBlock(), createElementBlock("div", _hoisted_1$j, [
1069
1122
  (openBlock(true), createElementBlock(Fragment, null, renderList(records.value, (item, index) => {
1070
1123
  return openBlock(), createElementBlock("div", {
1071
1124
  class: "m-fields-key-value-item",
@@ -1116,7 +1169,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
1116
1169
  }
1117
1170
  });
1118
1171
 
1119
- const _sfc_main$v = /* @__PURE__ */ defineComponent({
1172
+ const _sfc_main$w = /* @__PURE__ */ defineComponent({
1120
1173
  ...{
1121
1174
  name: "MEditorUISelect"
1122
1175
  },
@@ -1230,7 +1283,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
1230
1283
 
1231
1284
  const UISelect_vue_vue_type_style_index_0_lang = '';
1232
1285
 
1233
- const _sfc_main$u = /* @__PURE__ */ defineComponent({
1286
+ const _sfc_main$v = /* @__PURE__ */ defineComponent({
1234
1287
  ...{
1235
1288
  name: "MEditorCodeEditor"
1236
1289
  },
@@ -1251,10 +1304,14 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1251
1304
  const toString = (v, language) => {
1252
1305
  let value = "";
1253
1306
  if (typeof v !== "string") {
1254
- value = serialize(v, {
1255
- space: 2,
1256
- unsafe: true
1257
- }).replace(/"(\w+)":\s/g, "$1: ");
1307
+ if (props.language.toLocaleLowerCase() === "json") {
1308
+ value = JSON.stringify(v, null, 2);
1309
+ } else {
1310
+ value = serialize(v, {
1311
+ space: 2,
1312
+ unsafe: true
1313
+ }).replace(/"(\w+)":\s/g, "$1: ");
1314
+ }
1258
1315
  } else {
1259
1316
  value = v;
1260
1317
  }
@@ -1286,7 +1343,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1286
1343
  }
1287
1344
  return vsEditor?.setValue(values.value);
1288
1345
  };
1289
- const getEditorValue = () => props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue();
1346
+ const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
1290
1347
  const init = async () => {
1291
1348
  if (!codeEditor.value)
1292
1349
  return;
@@ -1308,12 +1365,18 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1308
1365
  if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
1309
1366
  e.preventDefault();
1310
1367
  e.stopPropagation();
1311
- emit("save", getEditorValue());
1368
+ const newValue = getEditorValue();
1369
+ values.value = newValue;
1370
+ emit("save", newValue);
1312
1371
  }
1313
1372
  });
1314
1373
  if (props.type !== "diff" && props.autoSave) {
1315
1374
  vsEditor?.onDidBlurEditorWidget(() => {
1316
- emit("save", getEditorValue());
1375
+ const newValue = getEditorValue();
1376
+ if (values.value !== newValue) {
1377
+ values.value = newValue;
1378
+ emit("save", newValue);
1379
+ }
1317
1380
  });
1318
1381
  }
1319
1382
  resizeObserver.observe(codeEditor.value);
@@ -1338,9 +1401,16 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1338
1401
  resizeObserver.disconnect();
1339
1402
  });
1340
1403
  __expose({
1404
+ values,
1341
1405
  getEditor() {
1342
1406
  return vsEditor || vsDiffEditor;
1343
1407
  },
1408
+ getVsEditor() {
1409
+ return vsEditor;
1410
+ },
1411
+ getVsDiffEditor() {
1412
+ return vsDiffEditor;
1413
+ },
1344
1414
  setEditorValue,
1345
1415
  focus() {
1346
1416
  vsEditor?.focus();
@@ -1357,7 +1427,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1357
1427
  }
1358
1428
  });
1359
1429
 
1360
- const _sfc_main$t = /* @__PURE__ */ defineComponent({
1430
+ const _sfc_main$u = /* @__PURE__ */ defineComponent({
1361
1431
  ...{
1362
1432
  name: "MEditorResizer"
1363
1433
  },
@@ -1399,7 +1469,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1399
1469
  }
1400
1470
  });
1401
1471
 
1402
- const _sfc_main$s = /* @__PURE__ */ defineComponent({
1472
+ const _sfc_main$t = /* @__PURE__ */ defineComponent({
1403
1473
  ...{
1404
1474
  name: "MEditorLayout"
1405
1475
  },
@@ -1511,7 +1581,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1511
1581
  }, [
1512
1582
  renderSlot(_ctx.$slots, "left")
1513
1583
  ], 6),
1514
- createVNode(_sfc_main$t, { onChange: changeLeft })
1584
+ createVNode(_sfc_main$u, { onChange: changeLeft })
1515
1585
  ], 64)) : createCommentVNode("", true),
1516
1586
  createElementVNode("div", {
1517
1587
  class: normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
@@ -1520,7 +1590,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
1520
1590
  renderSlot(_ctx.$slots, "center")
1521
1591
  ], 6),
1522
1592
  hasRight.value && _ctx.$slots.right ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1523
- createVNode(_sfc_main$t, { onChange: changeRight }),
1593
+ createVNode(_sfc_main$u, { onChange: changeRight }),
1524
1594
  createElementVNode("div", {
1525
1595
  class: normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
1526
1596
  style: normalizeStyle(`width: ${_ctx.right}px`)
@@ -3443,10 +3513,10 @@ const useStage = (stageOptions) => {
3443
3513
  return stage;
3444
3514
  };
3445
3515
 
3446
- const _hoisted_1$h = { class: "m-editor-empty-panel" };
3516
+ const _hoisted_1$i = { class: "m-editor-empty-panel" };
3447
3517
  const _hoisted_2$9 = { class: "m-editor-empty-content" };
3448
3518
  const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
3449
- const _sfc_main$r = /* @__PURE__ */ defineComponent({
3519
+ const _sfc_main$s = /* @__PURE__ */ defineComponent({
3450
3520
  ...{
3451
3521
  name: "MEditorAddPageBox"
3452
3522
  },
@@ -3466,14 +3536,14 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
3466
3536
  });
3467
3537
  };
3468
3538
  return (_ctx, _cache) => {
3469
- return openBlock(), createElementBlock("div", _hoisted_1$h, [
3539
+ return openBlock(), createElementBlock("div", _hoisted_1$i, [
3470
3540
  createElementVNode("div", _hoisted_2$9, [
3471
3541
  createElementVNode("div", {
3472
3542
  class: "m-editor-empty-button",
3473
3543
  onClick: clickHandler
3474
3544
  }, [
3475
3545
  createElementVNode("div", null, [
3476
- createVNode(_sfc_main$B, { icon: unref(Plus) }, null, 8, ["icon"])
3546
+ createVNode(_sfc_main$D, { icon: unref(Plus) }, null, 8, ["icon"])
3477
3547
  ]),
3478
3548
  _hoisted_3$4
3479
3549
  ])
@@ -3483,12 +3553,12 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
3483
3553
  }
3484
3554
  });
3485
3555
 
3486
- const _hoisted_1$g = { class: "m-editor" };
3556
+ const _hoisted_1$h = { class: "m-editor" };
3487
3557
  const DEFAULT_LEFT_COLUMN_WIDTH = 310;
3488
3558
  const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
3489
3559
  const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
3490
3560
  const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
3491
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
3561
+ const _sfc_main$r = /* @__PURE__ */ defineComponent({
3492
3562
  ...{
3493
3563
  name: "MEditorFramework"
3494
3564
  },
@@ -3554,18 +3624,18 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3554
3624
  }
3555
3625
  };
3556
3626
  return (_ctx, _cache) => {
3557
- return openBlock(), createElementBlock("div", _hoisted_1$g, [
3627
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
3558
3628
  renderSlot(_ctx.$slots, "header"),
3559
3629
  renderSlot(_ctx.$slots, "nav"),
3560
3630
  renderSlot(_ctx.$slots, "content-before"),
3561
3631
  showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
3562
- createVNode(_sfc_main$u, {
3632
+ createVNode(_sfc_main$v, {
3563
3633
  class: "m-editor-content",
3564
3634
  "init-values": root.value,
3565
3635
  options: unref(codeOptions),
3566
3636
  onSave: saveCode
3567
3637
  }, null, 8, ["init-values", "options"])
3568
- ]) : (openBlock(), createBlock(_sfc_main$s, {
3638
+ ]) : (openBlock(), createBlock(_sfc_main$t, {
3569
3639
  key: 1,
3570
3640
  class: "m-editor-content",
3571
3641
  "left-class": "m-editor-framework-left",
@@ -3584,7 +3654,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3584
3654
  ]),
3585
3655
  center: withCtx(() => [
3586
3656
  pageLength.value > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
3587
- createVNode(_sfc_main$r)
3657
+ createVNode(_sfc_main$s)
3588
3658
  ])
3589
3659
  ]),
3590
3660
  _: 2
@@ -3609,12 +3679,12 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3609
3679
  }
3610
3680
  });
3611
3681
 
3612
- const _hoisted_1$f = {
3682
+ const _hoisted_1$g = {
3613
3683
  key: 1,
3614
3684
  class: "menu-item-text"
3615
3685
  };
3616
3686
  const _hoisted_2$8 = { class: "el-dropdown-link menubar-menu-button" };
3617
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
3687
+ const _sfc_main$q = /* @__PURE__ */ defineComponent({
3618
3688
  ...{
3619
3689
  name: "MEditorToolButton"
3620
3690
  },
@@ -3693,7 +3763,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3693
3763
  _ctx.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
3694
3764
  key: 0,
3695
3765
  direction: _ctx.data.direction || "vertical"
3696
- }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$f, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3766
+ }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$g, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3697
3767
  _ctx.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
3698
3768
  key: 0,
3699
3769
  effect: "dark",
@@ -3707,7 +3777,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3707
3777
  disabled: disabled.value
3708
3778
  }, {
3709
3779
  default: withCtx(() => [
3710
- _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$B, {
3780
+ _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$D, {
3711
3781
  key: 0,
3712
3782
  icon: _ctx.data.icon
3713
3783
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -3724,7 +3794,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3724
3794
  disabled: disabled.value
3725
3795
  }, {
3726
3796
  default: withCtx(() => [
3727
- _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$B, {
3797
+ _ctx.data.icon ? (openBlock(), createBlock(_sfc_main$D, {
3728
3798
  key: 0,
3729
3799
  icon: _ctx.data.icon
3730
3800
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -3774,7 +3844,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3774
3844
  }
3775
3845
  });
3776
3846
 
3777
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
3847
+ const _sfc_main$p = /* @__PURE__ */ defineComponent({
3778
3848
  ...{
3779
3849
  name: "MEditorNavMenu"
3780
3850
  },
@@ -3936,7 +4006,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
3936
4006
  style: normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
3937
4007
  }, [
3938
4008
  (openBlock(true), createElementBlock(Fragment, null, renderList(buttons.value[key], (item, index) => {
3939
- return openBlock(), createBlock(_sfc_main$p, {
4009
+ return openBlock(), createBlock(_sfc_main$q, {
3940
4010
  data: item,
3941
4011
  key: index
3942
4012
  }, null, 8, ["data"]);
@@ -3948,11 +4018,11 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
3948
4018
  }
3949
4019
  });
3950
4020
 
3951
- const _hoisted_1$e = {
4021
+ const _hoisted_1$f = {
3952
4022
  key: 0,
3953
4023
  class: "m-editor-props-panel"
3954
4024
  };
3955
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
4025
+ const _sfc_main$o = /* @__PURE__ */ defineComponent({
3956
4026
  ...{
3957
4027
  name: "MEditorPropsPanel"
3958
4028
  },
@@ -4002,7 +4072,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
4002
4072
  };
4003
4073
  __expose({ submit });
4004
4074
  return (_ctx, _cache) => {
4005
- return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$e, [
4075
+ return nodes.value.length === 1 ? (openBlock(), createElementBlock("div", _hoisted_1$f, [
4006
4076
  renderSlot(_ctx.$slots, "props-panel-header"),
4007
4077
  createVNode(unref(MForm), {
4008
4078
  ref_key: "configForm",
@@ -4019,7 +4089,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
4019
4089
  }
4020
4090
  });
4021
4091
 
4022
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
4092
+ const _sfc_main$n = /* @__PURE__ */ defineComponent({
4023
4093
  ...{
4024
4094
  name: "MEditorSearchInput"
4025
4095
  },
@@ -4054,7 +4124,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
4054
4124
  }
4055
4125
  });
4056
4126
 
4057
- const _hoisted_1$d = { xmlns: "http://www.w3.org/2000/svg" };
4127
+ const _hoisted_1$e = { xmlns: "http://www.w3.org/2000/svg" };
4058
4128
  const _hoisted_2$7 = /* @__PURE__ */ createElementVNode("g", {
4059
4129
  fill: "#7C878E",
4060
4130
  "fill-rule": "evenodd"
@@ -4068,19 +4138,19 @@ const _hoisted_2$7 = /* @__PURE__ */ createElementVNode("g", {
4068
4138
  const _hoisted_3$3 = [
4069
4139
  _hoisted_2$7
4070
4140
  ];
4071
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
4141
+ const _sfc_main$m = /* @__PURE__ */ defineComponent({
4072
4142
  ...{
4073
4143
  name: "MEditorAppManageIcon"
4074
4144
  },
4075
4145
  __name: "AppManageIcon",
4076
4146
  setup(__props) {
4077
4147
  return (_ctx, _cache) => {
4078
- return openBlock(), createElementBlock("svg", _hoisted_1$d, _hoisted_3$3);
4148
+ return openBlock(), createElementBlock("svg", _hoisted_1$e, _hoisted_3$3);
4079
4149
  };
4080
4150
  }
4081
4151
  });
4082
4152
 
4083
- const _hoisted_1$c = {
4153
+ const _hoisted_1$d = {
4084
4154
  viewBox: "0 0 32 32",
4085
4155
  version: "1.1",
4086
4156
  xmlns: "http://www.w3.org/2000/svg",
@@ -4090,19 +4160,19 @@ const _hoisted_2$6 = /* @__PURE__ */ createStaticVNode('<defs><rect id="path-1"
4090
4160
  const _hoisted_4$3 = [
4091
4161
  _hoisted_2$6
4092
4162
  ];
4093
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
4163
+ const _sfc_main$l = /* @__PURE__ */ defineComponent({
4094
4164
  ...{
4095
4165
  name: "MEditorCodeIcon"
4096
4166
  },
4097
4167
  __name: "CodeIcon",
4098
4168
  setup(__props) {
4099
4169
  return (_ctx, _cache) => {
4100
- return openBlock(), createElementBlock("svg", _hoisted_1$c, _hoisted_4$3);
4170
+ return openBlock(), createElementBlock("svg", _hoisted_1$d, _hoisted_4$3);
4101
4171
  };
4102
4172
  }
4103
4173
  });
4104
4174
 
4105
- const _hoisted_1$b = {
4175
+ const _hoisted_1$c = {
4106
4176
  key: 0,
4107
4177
  class: "m-editor-content-bottom"
4108
4178
  };
@@ -4110,7 +4180,7 @@ const _hoisted_2$5 = {
4110
4180
  key: 1,
4111
4181
  class: "m-editor-content-bottom"
4112
4182
  };
4113
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
4183
+ const _sfc_main$k = /* @__PURE__ */ defineComponent({
4114
4184
  ...{
4115
4185
  name: "MEditorCodeDraftEditor"
4116
4186
  },
@@ -4197,7 +4267,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
4197
4267
  return openBlock(), createElementBlock("div", {
4198
4268
  class: normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
4199
4269
  }, [
4200
- createVNode(_sfc_main$u, {
4270
+ createVNode(_sfc_main$v, {
4201
4271
  ref_key: "codeEditor",
4202
4272
  ref: codeEditor,
4203
4273
  class: "m-editor-container",
@@ -4206,7 +4276,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
4206
4276
  language: _ctx.language,
4207
4277
  options: codeOptions.value
4208
4278
  }, null, 8, ["init-values", "language", "options"]),
4209
- _ctx.editable ? (openBlock(), createElementBlock("div", _hoisted_1$b, [
4279
+ _ctx.editable ? (openBlock(), createElementBlock("div", _hoisted_1$c, [
4210
4280
  createVNode(unref(TMagicButton), {
4211
4281
  type: "primary",
4212
4282
  class: "button",
@@ -4262,11 +4332,11 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
4262
4332
  }
4263
4333
  });
4264
4334
 
4265
- const _hoisted_1$a = { class: "code-name-wrapper" };
4335
+ const _hoisted_1$b = { class: "code-name-wrapper" };
4266
4336
  const _hoisted_2$4 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
4267
4337
  const _hoisted_3$2 = { class: "code-name-wrapper" };
4268
4338
  const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "参数", -1);
4269
- const _sfc_main$i = /* @__PURE__ */ defineComponent({
4339
+ const _sfc_main$j = /* @__PURE__ */ defineComponent({
4270
4340
  ...{
4271
4341
  name: "MEditorFunctionEditor"
4272
4342
  },
@@ -4282,7 +4352,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4282
4352
  },
4283
4353
  setup(__props, { expose: __expose }) {
4284
4354
  const props = __props;
4285
- provide("mForm", {});
4355
+ provide("mForm", null);
4286
4356
  const defaultParamColConfig = {
4287
4357
  type: "row",
4288
4358
  label: "参数类型",
@@ -4389,7 +4459,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4389
4459
  const _component_m_form_table = resolveComponent("m-form-table");
4390
4460
  return openBlock(), createBlock(unref(TMagicCard), { shadow: "never" }, {
4391
4461
  header: withCtx(() => [
4392
- createElementVNode("div", _hoisted_1$a, [
4462
+ createElementVNode("div", _hoisted_1$b, [
4393
4463
  _hoisted_2$4,
4394
4464
  createVNode(unref(TMagicInput), {
4395
4465
  class: "code-name-input",
@@ -4412,7 +4482,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4412
4482
  ])
4413
4483
  ]),
4414
4484
  default: withCtx(() => [
4415
- createVNode(_sfc_main$j, {
4485
+ createVNode(_sfc_main$k, {
4416
4486
  ref_key: "codeDraftEditor",
4417
4487
  ref: codeDraftEditor,
4418
4488
  id: _ctx.id,
@@ -4431,11 +4501,11 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4431
4501
  }
4432
4502
  });
4433
4503
 
4434
- const _hoisted_1$9 = {
4504
+ const _hoisted_1$a = {
4435
4505
  key: 0,
4436
4506
  class: "m-editor-code-block-editor-panel"
4437
4507
  };
4438
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
4508
+ const _sfc_main$i = /* @__PURE__ */ defineComponent({
4439
4509
  ...{
4440
4510
  name: "MEditorCodeBlockEditor"
4441
4511
  },
@@ -4492,16 +4562,16 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
4492
4562
  "before-close": handleClose
4493
4563
  }, {
4494
4564
  default: withCtx(() => [
4495
- createVNode(_sfc_main$s, {
4565
+ createVNode(_sfc_main$t, {
4496
4566
  left: left.value,
4497
4567
  "onUpdate:left": _cache[0] || (_cache[0] = ($event) => left.value = $event),
4498
4568
  "min-left": 45,
4499
4569
  class: "code-editor-layout"
4500
4570
  }, {
4501
4571
  center: withCtx(() => [
4502
- !unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$9, [
4572
+ !unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$a, [
4503
4573
  renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: id.value }),
4504
- codeConfig.value ? (openBlock(), createBlock(_sfc_main$i, {
4574
+ codeConfig.value ? (openBlock(), createBlock(_sfc_main$j, {
4505
4575
  key: 0,
4506
4576
  ref_key: "functionEditor",
4507
4577
  ref: functionEditor,
@@ -4524,14 +4594,14 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
4524
4594
  }
4525
4595
  });
4526
4596
 
4527
- const _hoisted_1$8 = { class: "search-wrapper" };
4597
+ const _hoisted_1$9 = { class: "search-wrapper" };
4528
4598
  const _hoisted_2$3 = ["id"];
4529
4599
  const _hoisted_3$1 = { class: "list-item" };
4530
4600
  const _hoisted_4$1 = {
4531
4601
  key: 2,
4532
4602
  class: "right-tool"
4533
4603
  };
4534
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
4604
+ const _sfc_main$h = /* @__PURE__ */ defineComponent({
4535
4605
  ...{
4536
4606
  name: "MEditorCodeBlockList"
4537
4607
  },
@@ -4627,8 +4697,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4627
4697
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
4628
4698
  default: withCtx(() => [
4629
4699
  renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
4630
- createElementVNode("div", _hoisted_1$8, [
4631
- createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4700
+ createElementVNode("div", _hoisted_1$9, [
4701
+ createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
4632
4702
  editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
4633
4703
  key: 0,
4634
4704
  class: "create-code-button",
@@ -4663,11 +4733,11 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4663
4733
  class: "list-container"
4664
4734
  }, [
4665
4735
  createElementVNode("div", _hoisted_3$1, [
4666
- data.type === "code" ? (openBlock(), createBlock(_sfc_main$k, {
4736
+ data.type === "code" ? (openBlock(), createBlock(_sfc_main$l, {
4667
4737
  key: 0,
4668
4738
  class: "codeIcon"
4669
4739
  })) : createCommentVNode("", true),
4670
- data.type === "node" ? (openBlock(), createBlock(_sfc_main$l, {
4740
+ data.type === "node" ? (openBlock(), createBlock(_sfc_main$m, {
4671
4741
  key: 1,
4672
4742
  class: "compIcon"
4673
4743
  })) : createCommentVNode("", true),
@@ -4681,7 +4751,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4681
4751
  placement: "bottom"
4682
4752
  }, {
4683
4753
  default: withCtx(() => [
4684
- createVNode(_sfc_main$B, {
4754
+ createVNode(_sfc_main$D, {
4685
4755
  icon: editable.value ? unref(Edit) : unref(View),
4686
4756
  class: "edit-icon",
4687
4757
  onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
@@ -4696,7 +4766,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4696
4766
  placement: "bottom"
4697
4767
  }, {
4698
4768
  default: withCtx(() => [
4699
- createVNode(_sfc_main$B, {
4769
+ createVNode(_sfc_main$D, {
4700
4770
  icon: unref(Close),
4701
4771
  class: "edit-icon",
4702
4772
  onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
@@ -4714,7 +4784,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4714
4784
  ]),
4715
4785
  _: 3
4716
4786
  }, 8, ["default-expanded-keys", "data"]),
4717
- isShowCodeBlockEditor.value ? (openBlock(), createBlock(_sfc_main$h, {
4787
+ isShowCodeBlockEditor.value ? (openBlock(), createBlock(_sfc_main$i, {
4718
4788
  key: 0,
4719
4789
  paramsColConfig: _ctx.paramsColConfig
4720
4790
  }, {
@@ -4730,7 +4800,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4730
4800
  }
4731
4801
  });
4732
4802
 
4733
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
4803
+ const _sfc_main$g = /* @__PURE__ */ defineComponent({
4734
4804
  ...{
4735
4805
  name: "MEditorDataSourceConfigPanel"
4736
4806
  },
@@ -4822,21 +4892,21 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
4822
4892
  }
4823
4893
  });
4824
4894
 
4825
- const _hoisted_1$7 = { class: "search-wrapper" };
4895
+ const _hoisted_1$8 = { class: "search-wrapper" };
4826
4896
  const _hoisted_2$2 = ["id"];
4827
4897
  const _hoisted_3 = { class: "list-item" };
4828
4898
  const _hoisted_4 = {
4829
4899
  key: 2,
4830
4900
  class: "right-tool"
4831
4901
  };
4832
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
4902
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
4833
4903
  ...{
4834
4904
  name: "MEditorDataSourceListPanel"
4835
4905
  },
4836
4906
  __name: "DataSourceListPanel",
4837
4907
  setup(__props) {
4838
4908
  const services = inject("services", {});
4839
- const { dataSourceService, depService } = inject("services") || {};
4909
+ const { dataSourceService, depService, editorService } = inject("services") || {};
4840
4910
  const list = computed(
4841
4911
  () => Object.values(depService?.targets["data-source"] || {}).map((target) => ({
4842
4912
  id: target.id,
@@ -4888,11 +4958,23 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4888
4958
  const filterTextChangeHandler = (val) => {
4889
4959
  tree.value?.filter(val);
4890
4960
  };
4961
+ const selectComp = (compId) => {
4962
+ const stage = editorService?.get("stage");
4963
+ editorService?.select(compId);
4964
+ stage?.select(compId);
4965
+ };
4966
+ const clickHandler = (data, node) => {
4967
+ if (data.type === "node") {
4968
+ selectComp(data.id);
4969
+ } else if (data.type === "key") {
4970
+ selectComp(node.parent.data.id);
4971
+ }
4972
+ };
4891
4973
  return (_ctx, _cache) => {
4892
4974
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
4893
4975
  default: withCtx(() => [
4894
- createElementVNode("div", _hoisted_1$7, [
4895
- createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
4976
+ createElementVNode("div", _hoisted_1$8, [
4977
+ createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
4896
4978
  createVNode(unref(TMagicButton), {
4897
4979
  type: "primary",
4898
4980
  size: "small",
@@ -4913,7 +4995,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4913
4995
  "default-expand-all": "",
4914
4996
  "expand-on-click-node": false,
4915
4997
  data: list.value,
4916
- "highlight-current": true
4998
+ "highlight-current": true,
4999
+ onNodeClick: clickHandler
4917
5000
  }, {
4918
5001
  default: withCtx(({ data }) => [
4919
5002
  createElementVNode("div", {
@@ -4921,12 +5004,12 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4921
5004
  class: "list-container"
4922
5005
  }, [
4923
5006
  createElementVNode("div", _hoisted_3, [
4924
- data.type === "code" ? (openBlock(), createBlock(_sfc_main$B, {
5007
+ data.type === "code" ? (openBlock(), createBlock(_sfc_main$D, {
4925
5008
  key: 0,
4926
5009
  class: "codeIcon",
4927
5010
  icon: unref(Coin)
4928
5011
  }, null, 8, ["icon"])) : createCommentVNode("", true),
4929
- data.type === "node" ? (openBlock(), createBlock(_sfc_main$B, {
5012
+ data.type === "node" ? (openBlock(), createBlock(_sfc_main$D, {
4930
5013
  key: 1,
4931
5014
  class: "compIcon",
4932
5015
  icon: unref(Aim)
@@ -4941,7 +5024,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4941
5024
  placement: "bottom"
4942
5025
  }, {
4943
5026
  default: withCtx(() => [
4944
- createVNode(_sfc_main$B, {
5027
+ createVNode(_sfc_main$D, {
4945
5028
  class: "edit-icon",
4946
5029
  icon: unref(Edit),
4947
5030
  onClick: withModifiers(($event) => editHandler(`${data.id}`), ["stop"])
@@ -4955,7 +5038,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4955
5038
  placement: "bottom"
4956
5039
  }, {
4957
5040
  default: withCtx(() => [
4958
- createVNode(_sfc_main$B, {
5041
+ createVNode(_sfc_main$D, {
4959
5042
  icon: unref(Close),
4960
5043
  class: "edit-icon",
4961
5044
  onClick: withModifiers(($event) => removeHandler(`${data.id}`), ["stop"])
@@ -4973,7 +5056,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4973
5056
  ]),
4974
5057
  _: 3
4975
5058
  }, 8, ["data"]),
4976
- createVNode(_sfc_main$f, {
5059
+ createVNode(_sfc_main$g, {
4977
5060
  ref_key: "editDialog",
4978
5061
  ref: editDialog,
4979
5062
  values: dataSourceValues.value,
@@ -4987,8 +5070,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4987
5070
  }
4988
5071
  });
4989
5072
 
4990
- const _hoisted_1$6 = ["onClick", "onDragstart"];
4991
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
5073
+ const _hoisted_1$7 = ["onClick", "onDragstart"];
5074
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4992
5075
  ...{
4993
5076
  name: "MEditorComponentListPanel"
4994
5077
  },
@@ -5022,14 +5105,13 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5022
5105
  };
5023
5106
  const dragstartHandler = ({ text, type, data = {} }, e) => {
5024
5107
  if (e.dataTransfer) {
5025
- e.dataTransfer.effectAllowed = "move";
5026
5108
  e.dataTransfer.setData(
5027
- "data",
5109
+ "text/html",
5028
5110
  serialize({
5029
5111
  name: text,
5030
5112
  type,
5031
5113
  ...data
5032
- }).replace(/"(\w+)":\s/g, "$1: ")
5114
+ })
5033
5115
  );
5034
5116
  }
5035
5117
  };
@@ -5057,7 +5139,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5057
5139
  }
5058
5140
  if (timeout || !stage.value)
5059
5141
  return;
5060
- timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
5142
+ timeout = stage.value.delayedMarkContainer(e);
5061
5143
  };
5062
5144
  return (_ctx, _cache) => {
5063
5145
  return openBlock(), createBlock(unref(TMagicScrollbar), null, {
@@ -5068,7 +5150,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5068
5150
  "model-value": collapseValue.value
5069
5151
  }, {
5070
5152
  default: withCtx(() => [
5071
- createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
5153
+ createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
5072
5154
  (openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
5073
5155
  return openBlock(), createElementBlock(Fragment, null, [
5074
5156
  group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
@@ -5076,7 +5158,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5076
5158
  name: `${index}`
5077
5159
  }, {
5078
5160
  title: withCtx(() => [
5079
- createVNode(_sfc_main$B, { icon: unref(Grid) }, null, 8, ["icon"]),
5161
+ createVNode(_sfc_main$D, { icon: unref(Grid) }, null, 8, ["icon"]),
5080
5162
  createTextVNode(toDisplayString(group.title), 1)
5081
5163
  ]),
5082
5164
  default: withCtx(() => [
@@ -5091,7 +5173,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5091
5173
  onDrag: dragHandler
5092
5174
  }, [
5093
5175
  renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
5094
- createVNode(_sfc_main$B, {
5176
+ createVNode(_sfc_main$D, {
5095
5177
  icon: item.icon
5096
5178
  }, null, 8, ["icon"]),
5097
5179
  createVNode(unref(TMagicTooltip), {
@@ -5105,7 +5187,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5105
5187
  _: 2
5106
5188
  }, 1032, ["content"])
5107
5189
  ])
5108
- ], 40, _hoisted_1$6);
5190
+ ], 40, _hoisted_1$7);
5109
5191
  }), 128))
5110
5192
  ]),
5111
5193
  _: 2
@@ -5122,7 +5204,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5122
5204
  }
5123
5205
  });
5124
5206
 
5125
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
5207
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5126
5208
  ...{
5127
5209
  name: "MEditorContentMenu"
5128
5210
  },
@@ -5219,7 +5301,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
5219
5301
  }, [
5220
5302
  createElementVNode("div", null, [
5221
5303
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
5222
- return openBlock(), createBlock(_sfc_main$p, {
5304
+ return openBlock(), createBlock(_sfc_main$q, {
5223
5305
  "event-type": "mouseup",
5224
5306
  data: item,
5225
5307
  key: index,
@@ -5246,7 +5328,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
5246
5328
  }
5247
5329
  });
5248
5330
 
5249
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
5331
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
5250
5332
  ...{
5251
5333
  name: "MEditorLayerMenu"
5252
5334
  },
@@ -5341,7 +5423,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5341
5423
  show
5342
5424
  });
5343
5425
  return (_ctx, _cache) => {
5344
- return openBlock(), createBlock(_sfc_main$c, {
5426
+ return openBlock(), createBlock(_sfc_main$d, {
5345
5427
  "menu-data": menuData.value,
5346
5428
  ref_key: "menu",
5347
5429
  ref: menu,
@@ -5351,6 +5433,57 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5351
5433
  }
5352
5434
  });
5353
5435
 
5436
+ const _hoisted_1$6 = { class: "layer-node-tool" };
5437
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
5438
+ __name: "LayerNode",
5439
+ props: {
5440
+ data: {}
5441
+ },
5442
+ setup(__props) {
5443
+ const props = __props;
5444
+ const services = inject("services");
5445
+ const editorService = services?.editorService;
5446
+ const setNodeVisible = (visible) => {
5447
+ if (!editorService)
5448
+ return;
5449
+ editorService.update({
5450
+ id: props.data.id,
5451
+ visible
5452
+ });
5453
+ };
5454
+ return (_ctx, _cache) => {
5455
+ const _component_el_icon = resolveComponent("el-icon");
5456
+ return openBlock(), createElementBlock(Fragment, null, [
5457
+ createElementVNode("div", null, toDisplayString(`${_ctx.data.name} (${_ctx.data.id})`), 1),
5458
+ createElementVNode("div", _hoisted_1$6, [
5459
+ _ctx.data.type !== "page" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
5460
+ _ctx.data.visible === false ? (openBlock(), createBlock(_component_el_icon, {
5461
+ key: 0,
5462
+ onClick: _cache[0] || (_cache[0] = withModifiers(($event) => setNodeVisible(true), ["stop"])),
5463
+ title: "点击显示"
5464
+ }, {
5465
+ default: withCtx(() => [
5466
+ createVNode(unref(Hide))
5467
+ ]),
5468
+ _: 1
5469
+ })) : (openBlock(), createBlock(_component_el_icon, {
5470
+ key: 1,
5471
+ onClick: _cache[1] || (_cache[1] = withModifiers(($event) => setNodeVisible(false), ["stop"])),
5472
+ class: "node-lock",
5473
+ title: "点击隐藏"
5474
+ }, {
5475
+ default: withCtx(() => [
5476
+ createVNode(unref(View))
5477
+ ]),
5478
+ _: 1
5479
+ }))
5480
+ ], 64)) : createCommentVNode("", true)
5481
+ ])
5482
+ ], 64);
5483
+ };
5484
+ }
5485
+ });
5486
+
5354
5487
  const _hoisted_1$5 = ["id", "onMouseenter"];
5355
5488
  const throttleTime = 150;
5356
5489
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
@@ -5591,7 +5724,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5591
5724
  return openBlock(), createBlock(unref(TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
5592
5725
  default: withCtx(() => [
5593
5726
  renderSlot(_ctx.$slots, "layer-panel-header"),
5594
- createVNode(_sfc_main$m, { onSearch: filterTextChangeHandler }),
5727
+ createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
5595
5728
  values.value.length ? (openBlock(), createBlock(unref(TMagicTree), {
5596
5729
  key: 0,
5597
5730
  class: "magic-editor-layer-tree",
@@ -5631,14 +5764,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
5631
5764
  node,
5632
5765
  data
5633
5766
  }, () => [
5634
- createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
5767
+ createVNode(_sfc_main$b, { data }, null, 8, ["data"])
5635
5768
  ])
5636
5769
  ], 40, _hoisted_1$5)
5637
5770
  ]),
5638
5771
  _: 3
5639
5772
  }, 8, ["default-expanded-keys", "default-checked-keys", "current-node-key", "data", "highlight-current", "show-checkbox"])) : createCommentVNode("", true),
5640
5773
  (openBlock(), createBlock(Teleport, { to: "body" }, [
5641
- createVNode(_sfc_main$b, {
5774
+ createVNode(_sfc_main$c, {
5642
5775
  ref_key: "menu",
5643
5776
  ref: menu,
5644
5777
  "layer-content-menu": _ctx.layerContentMenu
@@ -5676,7 +5809,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5676
5809
  type: "component",
5677
5810
  icon: Goods,
5678
5811
  text: "组件",
5679
- component: _sfc_main$d,
5812
+ component: _sfc_main$e,
5680
5813
  slots: {}
5681
5814
  },
5682
5815
  layer: {
@@ -5695,7 +5828,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5695
5828
  type: "component",
5696
5829
  icon: EditPen,
5697
5830
  text: "代码编辑",
5698
- component: _sfc_main$g,
5831
+ component: _sfc_main$h,
5699
5832
  slots: {}
5700
5833
  },
5701
5834
  "data-source": {
@@ -5703,7 +5836,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5703
5836
  type: "component",
5704
5837
  icon: Coin,
5705
5838
  text: "数据源",
5706
- component: _sfc_main$e,
5839
+ component: _sfc_main$f,
5707
5840
  slots: {}
5708
5841
  }
5709
5842
  };
@@ -5735,7 +5868,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5735
5868
  (openBlock(), createElementBlock("div", {
5736
5869
  key: config.text
5737
5870
  }, [
5738
- config.icon ? (openBlock(), createBlock(_sfc_main$B, {
5871
+ config.icon ? (openBlock(), createBlock(_sfc_main$D, {
5739
5872
  key: 0,
5740
5873
  icon: config.icon
5741
5874
  }, null, 8, ["icon"])) : createCommentVNode("", true),
@@ -5963,14 +6096,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5963
6096
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5964
6097
  onClick: addPage
5965
6098
  }, [
5966
- createVNode(_sfc_main$B, { icon: unref(Plus) }, null, 8, ["icon"])
6099
+ createVNode(_sfc_main$D, { icon: unref(Plus) }, null, 8, ["icon"])
5967
6100
  ])) : (openBlock(), createElementBlock("div", _hoisted_1$2)),
5968
6101
  canScroll.value ? (openBlock(), createElementBlock("div", {
5969
6102
  key: 2,
5970
6103
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5971
6104
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
5972
6105
  }, [
5973
- createVNode(_sfc_main$B, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
6106
+ createVNode(_sfc_main$D, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
5974
6107
  ])) : createCommentVNode("", true),
5975
6108
  pageLength.value ? (openBlock(), createElementBlock("div", {
5976
6109
  key: 3,
@@ -5986,7 +6119,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
5986
6119
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
5987
6120
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
5988
6121
  }, [
5989
- createVNode(_sfc_main$B, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
6122
+ createVNode(_sfc_main$D, { icon: unref(ArrowRightBold) }, null, 8, ["icon"])
5990
6123
  ])) : createCommentVNode("", true)
5991
6124
  ], 512);
5992
6125
  };
@@ -6058,7 +6191,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
6058
6191
  default: withCtx(() => [
6059
6192
  createElementVNode("div", null, [
6060
6193
  renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
6061
- createVNode(_sfc_main$p, {
6194
+ createVNode(_sfc_main$q, {
6062
6195
  data: {
6063
6196
  type: "button",
6064
6197
  text: "复制",
@@ -6066,7 +6199,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
6066
6199
  handler: () => copy(item)
6067
6200
  }
6068
6201
  }, null, 8, ["data"]),
6069
- createVNode(_sfc_main$p, {
6202
+ createVNode(_sfc_main$q, {
6070
6203
  data: {
6071
6204
  type: "button",
6072
6205
  text: "删除",
@@ -6557,7 +6690,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
6557
6690
  };
6558
6691
  __expose({ show });
6559
6692
  return (_ctx, _cache) => {
6560
- return openBlock(), createBlock(_sfc_main$c, {
6693
+ return openBlock(), createBlock(_sfc_main$d, {
6561
6694
  "menu-data": menuData.value,
6562
6695
  ref_key: "menu",
6563
6696
  ref: menu
@@ -6658,9 +6791,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6658
6791
  };
6659
6792
  const dragoverHandler = (e) => {
6660
6793
  e.preventDefault();
6661
- if (e.dataTransfer) {
6662
- e.dataTransfer.dropEffect = "move";
6663
- }
6794
+ if (!e.dataTransfer)
6795
+ return;
6796
+ e.dataTransfer.dropEffect = "move";
6664
6797
  };
6665
6798
  const dropHandler = async (e) => {
6666
6799
  e.preventDefault();
@@ -6672,7 +6805,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
6672
6805
  }
6673
6806
  if (e.dataTransfer && parent && stageContainer.value && stage) {
6674
6807
  const parseDSL = getConfig("parseDSL");
6675
- const config = parseDSL(`(${e.dataTransfer.getData("data")})`);
6808
+ const data = e.dataTransfer.getData("text/html");
6809
+ if (!data)
6810
+ return;
6811
+ const config = parseDSL(`(${data})`);
6812
+ if (!config)
6813
+ return;
6676
6814
  const layout = await services?.editorService.getLayout(parent);
6677
6815
  const containerRect = stageContainer.value.getBoundingClientRect();
6678
6816
  const { scrollTop, scrollLeft } = stage.mask;
@@ -7872,6 +8010,9 @@ const createCodeBlockTarget = (id, codeBlock) => new Target({
7872
8010
  id,
7873
8011
  name: codeBlock.name,
7874
8012
  isTarget: (key, value) => {
8013
+ if (id === value) {
8014
+ return true;
8015
+ }
7875
8016
  if (value?.hookType === HookType.CODE && !isEmpty(value.hookData)) {
7876
8017
  const index = value.hookData.findIndex((item) => item.codeId === id);
7877
8018
  return Boolean(index > -1);
@@ -7883,7 +8024,10 @@ const createDataSourceTarget = (id, ds) => new Target({
7883
8024
  type: "data-source",
7884
8025
  id,
7885
8026
  name: ds.title || `${id}`,
7886
- isTarget: (key, value) => typeof value === "string" && value.includes(`${id}`)
8027
+ isTarget: (key, value) => (
8028
+ // 关联数据源对象或者在模板在使用数据源
8029
+ value.isBindDataSource && value.dataSourceId || typeof value === "string" && value.includes(`${id}`)
8030
+ )
7887
8031
  });
7888
8032
 
7889
8033
  const initServiceState = (props, {
@@ -8136,11 +8280,11 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
8136
8280
  const _sfc_main = defineComponent({
8137
8281
  name: "MEditor",
8138
8282
  components: {
8139
- TMagicNavMenu: _sfc_main$o,
8283
+ TMagicNavMenu: _sfc_main$p,
8140
8284
  Sidebar: _sfc_main$9,
8141
8285
  Workspace: _sfc_main$1,
8142
- PropsPanel: _sfc_main$n,
8143
- Framework: _sfc_main$q
8286
+ PropsPanel: _sfc_main$o,
8287
+ Framework: _sfc_main$r
8144
8288
  },
8145
8289
  props: editorProps,
8146
8290
  emits: ["props-panel-mounted", "update:modelValue"],
@@ -8307,18 +8451,19 @@ const index = {
8307
8451
  app.config.globalProperties.$TMAGIC_EDITOR = option;
8308
8452
  setConfig(option);
8309
8453
  app.component(Editor.name, Editor);
8310
- app.component("m-fields-ui-select", _sfc_main$v);
8311
- app.component("m-fields-code-link", _sfc_main$D);
8312
- app.component("m-fields-vs-code", _sfc_main$E);
8313
- app.component("magic-code-editor", _sfc_main$u);
8314
- app.component("m-fields-code-select", _sfc_main$C);
8315
- app.component("m-fields-code-select-col", _sfc_main$A);
8316
- app.component("m-fields-event-select", _sfc_main$x);
8317
- app.component("m-fields-data-source-fields", _sfc_main$z);
8318
- app.component("m-fields-key-value", _sfc_main$w);
8319
- app.component("m-fields-data-source-input", _sfc_main$y);
8454
+ app.component("m-fields-ui-select", _sfc_main$w);
8455
+ app.component("m-fields-code-link", _sfc_main$F);
8456
+ app.component("m-fields-vs-code", _sfc_main$G);
8457
+ app.component("magic-code-editor", _sfc_main$v);
8458
+ app.component("m-fields-code-select", _sfc_main$E);
8459
+ app.component("m-fields-code-select-col", _sfc_main$C);
8460
+ app.component("m-fields-event-select", _sfc_main$y);
8461
+ app.component("m-fields-data-source-fields", _sfc_main$B);
8462
+ app.component("m-fields-key-value", _sfc_main$x);
8463
+ app.component("m-fields-data-source-input", _sfc_main$A);
8464
+ app.component("m-fields-data-source-select", _sfc_main$z);
8320
8465
  }
8321
8466
  };
8322
8467
 
8323
- export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$g as CodeBlockList, CodeDeleteErrorType, _sfc_main$C as CodeSelect, _sfc_main$A as CodeSelectCol, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, _sfc_main$z as DataSourceFields, _sfc_main$y as DataSourceInput, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$B as Icon, KeyBindingCommand, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$s as LayoutContainer, _sfc_main$n as PropsPanel, _sfc_main$t as Resizer, _sfc_main$s as SplitView, _sfc_main$u as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$p as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
8468
+ export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$h as CodeBlockList, CodeDeleteErrorType, _sfc_main$E as CodeSelect, _sfc_main$C as CodeSelectCol, ColumnLayout, _sfc_main$e as ComponentListPanel, _sfc_main$d as ContentMenu, _sfc_main$B as DataSourceFields, _sfc_main$A as DataSourceInput, _sfc_main$z as DataSourceSelect, _sfc_main$y as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$D as Icon, KeyBindingCommand, _sfc_main$x as KeyValue, Keys, LayerOffset, _sfc_main$a as LayerPanel, Layout, _sfc_main$t as LayoutContainer, _sfc_main$o as PropsPanel, _sfc_main$u as Resizer, _sfc_main$t as SplitView, _sfc_main$v as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$q as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
8324
8469
  //# sourceMappingURL=tmagic-editor.js.map