@tmagic/editor 1.5.12 → 1.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/tmagic-editor.js +219 -166
  2. package/dist/tmagic-editor.umd.cjs +225 -266
  3. package/package.json +7 -7
  4. package/src/Editor.vue +4 -20
  5. package/src/components/CodeBlockEditor.vue +14 -2
  6. package/src/components/ContentMenu.vue +2 -2
  7. package/src/components/FloatingBox.vue +1 -1
  8. package/src/components/ScrollBar.vue +9 -3
  9. package/src/components/SearchInput.vue +1 -1
  10. package/src/components/Tree.vue +3 -3
  11. package/src/components/TreeNode.vue +3 -3
  12. package/src/fields/CodeSelect.vue +5 -7
  13. package/src/fields/CodeSelectCol.vue +9 -5
  14. package/src/fields/DataSourceFields.vue +4 -2
  15. package/src/fields/DataSourceInput.vue +7 -3
  16. package/src/fields/DataSourceMethodSelect.vue +17 -6
  17. package/src/fields/DataSourceMethods.vue +3 -3
  18. package/src/fields/EventSelect.vue +3 -2
  19. package/src/fields/UISelect.vue +2 -2
  20. package/src/hooks/use-code-block-edit.ts +1 -1
  21. package/src/index.ts +0 -1
  22. package/src/initService.ts +75 -65
  23. package/src/layouts/Framework.vue +1 -1
  24. package/src/layouts/NavMenu.vue +1 -1
  25. package/src/layouts/page-bar/PageBar.vue +1 -1
  26. package/src/layouts/props-panel/FormPanel.vue +2 -2
  27. package/src/layouts/props-panel/PropsPanel.vue +1 -1
  28. package/src/layouts/sidebar/ComponentListPanel.vue +1 -1
  29. package/src/layouts/sidebar/code-block/CodeBlockList.vue +2 -1
  30. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +20 -3
  31. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +13 -1
  32. package/src/layouts/sidebar/data-source/DataSourceList.vue +1 -0
  33. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +20 -3
  34. package/src/layouts/workspace/viewer/Stage.vue +1 -1
  35. package/src/services/BaseService.ts +1 -0
  36. package/src/services/editor.ts +4 -3
  37. package/src/type.ts +9 -0
  38. package/src/utils/props.ts +9 -7
  39. package/types/index.d.ts +945 -9788
@@ -7,18 +7,18 @@ export { default as formPlugin } from '@tmagic/form';
7
7
  import tablePlugin__default, { MagicTable } from '@tmagic/table';
8
8
  export * from '@tmagic/table';
9
9
  export { default as tablePlugin } from '@tmagic/table';
10
- import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, ref, useTemplateRef, watch, onMounted, onBeforeUnmount, Teleport, normalizeStyle, computed, reactive, resolveComponent, inject, createCommentVNode, Fragment, renderList, mergeProps, mergeModels, useModel, nextTick, provide, renderSlot, toDisplayString, shallowReactive, createTextVNode, isRef, createStaticVNode, watchEffect, markRaw, withDirectives, vModelText, vShow, shallowRef, withModifiers, toHandlers, createSlots, getCurrentInstance, Transition, resolveDirective, mergeDefaults } from 'vue';
11
- import { Edit, FullScreen, View, Close, Coin, Delete, Plus, Grid, ArrowDown, ArrowLeftBold, ArrowRightBold, Files, Search, CaretBottom, DocumentCopy, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Document, Sugar, ArrowRight, CopyDocument, Hide, Goods, List, EditPen, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
10
+ import { defineComponent, createBlock, createElementBlock, openBlock, unref, withCtx, createVNode, createElementVNode, normalizeClass, resolveDynamicComponent, toRaw, ref, useTemplateRef, watch, onMounted, onBeforeUnmount, Teleport, normalizeStyle, computed, reactive, resolveComponent, inject, createCommentVNode, Fragment, renderList, mergeProps, mergeModels, useModel, nextTick, provide, renderSlot, toDisplayString, shallowReactive, createTextVNode, isRef, createStaticVNode, watchEffect, markRaw, withDirectives, vModelText, vShow, shallowRef, withModifiers, toHandlers, createSlots, getCurrentInstance, Transition, resolveDirective, mergeDefaults } from 'vue';
11
+ import { Edit, FullScreen, View, Close, Coin, Delete, Plus, Grid, ArrowDown, ArrowLeftBold, ArrowRightBold, Files, Search, DocumentCopy, CaretBottom, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Document, Sugar, ArrowRight, CopyDocument, Hide, EditPen, List, Goods, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
12
12
  import { throttle, isEmpty, isObject, cloneDeep, mergeWith, uniq, get, map, has, pick, keys } from 'lodash-es';
13
13
  import serialize from 'serialize-javascript';
14
14
  import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
15
15
  import * as monaco from 'monaco-editor';
16
16
  import { HookCodeType, HookType, NODE_CONDS_KEY, Target, Watcher, NodeType, ActionType, DepTargetType, createCodeBlockTarget, createDataSourceTarget, createDataSourceCondTarget, createDataSourceMethodTarget } from '@tmagic/core';
17
17
  export { DepTargetType } from '@tmagic/core';
18
- import { isPage, isPageFragment, isPop, getNodePath, isNumber, getElById, calcValueByFontsize, isValueIncludeDataSource, toLine, guid, getValueByKeyPath, setValueByKeyPath, getNodeInfo, dataSourceTemplateRegExp, getKeysArray, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, convertToNumber, getIdFromEl, traverseNode, getDefaultValueFromFields, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, removeClassName, addClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
18
+ import { isPage, isPageFragment, isPop, getNodePath, isNumber, getElById, calcValueByFontsize, isValueIncludeDataSource, toLine, guid, getValueByKeyPath, setValueByKeyPath, getNodeInfo, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, dataSourceTemplateRegExp, getKeysArray, getKeys, convertToNumber, getIdFromEl, traverseNode, getDefaultValueFromFields, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, removeClassName, addClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
19
19
  export * from '@tmagic/utils';
20
20
  import VanillaMoveable from 'moveable';
21
- import StageCore__default, { isFixed, GuidesType, getOffset, RenderType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
21
+ import StageCore__default, { isFixed, GuidesType, getOffset, ContainerHighlightType, CONTAINER_HIGHLIGHT_CLASS_NAME, RenderType } from '@tmagic/stage';
22
22
  export * from '@tmagic/stage';
23
23
  export { default as StageCore } from '@tmagic/stage';
24
24
  import { EventEmitter } from 'events';
@@ -471,13 +471,11 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
471
471
  { value: HookCodeType.DATA_SOURCE_METHOD, text: "数据源方法" }
472
472
  ],
473
473
  defaultValue: "code",
474
- onChange: (mForm, v, { model, prop, changeRecords }) => {
474
+ onChange: (_mForm, v, { setModel }) => {
475
475
  if (v === HookCodeType.DATA_SOURCE_METHOD) {
476
- model.codeId = [];
477
- changeRecords.push({ propPath: prop.replace("codeType", "codeId"), value: [] });
476
+ setModel("codeId", []);
478
477
  } else {
479
- model.codeId = "";
480
- changeRecords.push({ propPath: prop.replace("codeType", "codeId"), value: "" });
478
+ setModel("codeId", "");
481
479
  }
482
480
  return v;
483
481
  }
@@ -487,7 +485,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
487
485
  name: "codeId",
488
486
  span: 18,
489
487
  labelWidth: 0,
490
- display: (mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
488
+ display: (_mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
491
489
  notEditable: () => !codeBlockService.getEditStatus()
492
490
  },
493
491
  {
@@ -495,7 +493,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
495
493
  name: "codeId",
496
494
  span: 18,
497
495
  labelWidth: 0,
498
- display: (mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
496
+ display: (_mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
499
497
  notEditable: () => !dataSourceService.get("editable")
500
498
  }
501
499
  ]
@@ -693,13 +691,12 @@ const fillConfig$1 = (config = [], labelWidth = "80px") => [
693
691
  append: {
694
692
  type: "button",
695
693
  text: "复制",
696
- handler: async (vm, { model }) => {
697
- try {
698
- await navigator.clipboard.writeText(`${model.id}`);
694
+ handler: (vm, { model }) => {
695
+ navigator.clipboard.writeText(`${model.id}`).then(() => {
699
696
  tMagicMessage.success("已复制");
700
- } catch (err) {
697
+ }).catch(() => {
701
698
  tMagicMessage.error("复制失败");
702
- }
699
+ });
703
700
  }
704
701
  }
705
702
  },
@@ -1454,7 +1451,7 @@ class UndoRedo {
1454
1451
  class History extends BaseService {
1455
1452
  state = reactive({
1456
1453
  pageSteps: {},
1457
- pageId: undefined,
1454
+ pageId: void 0,
1458
1455
  canRedo: false,
1459
1456
  canUndo: false
1460
1457
  });
@@ -1467,7 +1464,7 @@ class History extends BaseService {
1467
1464
  this.resetPage();
1468
1465
  }
1469
1466
  resetPage() {
1470
- this.state.pageId = undefined;
1467
+ this.state.pageId = void 0;
1471
1468
  this.state.canRedo = false;
1472
1469
  this.state.canUndo = false;
1473
1470
  }
@@ -1487,7 +1484,7 @@ class History extends BaseService {
1487
1484
  this.emit("page-change", this.state.pageSteps[this.state.pageId]);
1488
1485
  }
1489
1486
  resetState() {
1490
- this.state.pageId = undefined;
1487
+ this.state.pageId = void 0;
1491
1488
  this.state.pageSteps = {};
1492
1489
  this.state.canRedo = false;
1493
1490
  this.state.canUndo = false;
@@ -1539,7 +1536,6 @@ var Protocol = /* @__PURE__ */ ((Protocol2) => {
1539
1536
  return Protocol2;
1540
1537
  })(Protocol || {});
1541
1538
  const canUsePluginMethods$5 = {
1542
- async: [],
1543
1539
  sync: ["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"]
1544
1540
  };
1545
1541
  class WebStorage extends BaseService {
@@ -1676,9 +1672,7 @@ const canUsePluginMethods$4 = {
1676
1672
  "undo",
1677
1673
  "redo",
1678
1674
  "move"
1679
- ],
1680
- sync: []
1681
- };
1675
+ ]};
1682
1676
  class Editor extends BaseService {
1683
1677
  state = reactive({
1684
1678
  root: null,
@@ -2440,10 +2434,11 @@ class Editor extends BaseService {
2440
2434
  this.isHistoryStateChange = true;
2441
2435
  await this.update(value.data);
2442
2436
  this.set("modifiedNodeIds", value.modifiedNodeIds);
2443
- setTimeout(async () => {
2437
+ setTimeout(() => {
2444
2438
  if (!value.nodeId) return;
2445
- await this.select(value.nodeId);
2446
- this.get("stage")?.select(value.nodeId);
2439
+ this.select(value.nodeId).then(() => {
2440
+ this.get("stage")?.select(value.nodeId);
2441
+ });
2447
2442
  }, 0);
2448
2443
  this.emit("history-change", value.data);
2449
2444
  }
@@ -3075,7 +3070,7 @@ const updateStatus = (nodeStatusMap, id, status) => {
3075
3070
  const nodeStatus = nodeStatusMap.get(id);
3076
3071
  if (!nodeStatus) return;
3077
3072
  getKeys(status).forEach((key) => {
3078
- if (nodeStatus[key] !== undefined && status[key] !== undefined) {
3073
+ if (nodeStatus[key] !== void 0 && status[key] !== void 0) {
3079
3074
  nodeStatus[key] = Boolean(status[key]);
3080
3075
  }
3081
3076
  });
@@ -3215,20 +3210,23 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
3215
3210
  }
3216
3211
  return [];
3217
3212
  },
3218
- onChange: (formState, codeId, { model }) => {
3213
+ onChange: (formState, codeId, { setModel, model }) => {
3219
3214
  paramsConfig.value = getParamItemsConfig(codeId);
3220
3215
  if (paramsConfig.value.length) {
3221
- model.params = createValues(formState, paramsConfig.value, {}, model.params);
3216
+ setModel("params", createValues(formState, paramsConfig.value, {}, model.params));
3222
3217
  } else {
3223
- model.params = {};
3218
+ setModel("params", {});
3224
3219
  }
3225
3220
  return codeId;
3226
3221
  }
3227
3222
  };
3228
- const onCodeIdChangeHandler = (value) => {
3223
+ const onCodeIdChangeHandler = (value, eventData) => {
3229
3224
  props.model.params = value.params;
3230
3225
  emit("change", props.model, {
3231
- changeRecords: [
3226
+ changeRecords: eventData.changeRecords?.map((item) => ({
3227
+ prop: `${props.prop.replace(props.name, "")}${item.propPath}`,
3228
+ value: item.value
3229
+ })) || [
3232
3230
  {
3233
3231
  propPath: props.prop,
3234
3232
  value: value[props.name]
@@ -3593,9 +3591,7 @@ const useCodeBlockEdit = (codeBlockService) => {
3593
3591
  const createCodeBlock = async () => {
3594
3592
  codeConfig.value = {
3595
3593
  name: "",
3596
- content: `({app, params, flowState}) => {
3597
- // place your code here
3598
- }`,
3594
+ content: "({app, params, flowState}) => {\n // place your code here\n}",
3599
3595
  params: []
3600
3596
  };
3601
3597
  codeId.value = await codeBlockService.getUniqueId();
@@ -3678,9 +3674,7 @@ const state = shallowReactive({
3678
3674
  }
3679
3675
  });
3680
3676
  const canUsePluginMethods$3 = {
3681
- async: ["zoom", "calcZoom"],
3682
- sync: []
3683
- };
3677
+ async: ["zoom", "calcZoom"]};
3684
3678
  class Ui extends BaseService {
3685
3679
  constructor() {
3686
3680
  super(canUsePluginMethods$3.async.map((methodName) => ({ name: methodName, isAsync: true })));
@@ -4169,6 +4163,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
4169
4163
  try {
4170
4164
  return JSON.stringify(row.defaultValue);
4171
4165
  } catch (e) {
4166
+ error(e);
4172
4167
  return row.defaultValue;
4173
4168
  }
4174
4169
  }
@@ -4217,9 +4212,9 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
4217
4212
  { text: "null", value: "null" },
4218
4213
  { text: "any", value: "any" }
4219
4214
  ],
4220
- onChange: (formState, v, { model }) => {
4215
+ onChange: (_formState, v, { setModel }) => {
4221
4216
  if (!["any", "array", "object"].includes(v)) {
4222
- model.fields = [];
4217
+ setModel("fields", []);
4223
4218
  }
4224
4219
  return v;
4225
4220
  }
@@ -5088,7 +5083,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
5088
5083
  "visible": { type: Boolean, ...{ default: false } },
5089
5084
  "visibleModifiers": {}
5090
5085
  }),
5091
- emits: /* @__PURE__ */ mergeModels(["submit"], ["update:width", "update:visible"]),
5086
+ emits: /* @__PURE__ */ mergeModels(["submit", "close", "open"], ["update:width", "update:visible"]),
5092
5087
  setup(__props, { expose: __expose, emit: __emit }) {
5093
5088
  const width = useModel(__props, "width");
5094
5089
  const boxVisible = useModel(__props, "visible");
@@ -5201,7 +5196,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
5201
5196
  }
5202
5197
  ]);
5203
5198
  const submitForm = (values, data) => {
5204
- changedValue.value = undefined;
5199
+ changedValue.value = void 0;
5205
5200
  emit("submit", values, data);
5206
5201
  };
5207
5202
  const errorHandler = (error) => {
@@ -5230,10 +5225,19 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
5230
5225
  });
5231
5226
  };
5232
5227
  const closedHandler = () => {
5233
- changedValue.value = undefined;
5228
+ changedValue.value = void 0;
5234
5229
  };
5235
5230
  const parentFloating = inject("parentFloating", ref(null));
5236
5231
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
5232
+ watch(boxVisible, (visible) => {
5233
+ nextTick(() => {
5234
+ if (!visible) {
5235
+ emit("close");
5236
+ } else {
5237
+ emit("open");
5238
+ }
5239
+ });
5240
+ });
5237
5241
  __expose({
5238
5242
  async show() {
5239
5243
  calcBoxPosition();
@@ -5429,9 +5433,7 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
5429
5433
  {
5430
5434
  text: "编辑",
5431
5435
  handler: (method, index) => {
5432
- let codeContent = method.content || `({ params, dataSource, app }) => {
5433
- // place your code here
5434
- }`;
5436
+ let codeContent = method.content || "({ params, dataSource, app }) => {\n // place your code here\n}";
5435
5437
  if (typeof codeContent !== "string") {
5436
5438
  codeContent = codeContent.toString();
5437
5439
  }
@@ -5460,9 +5462,7 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
5460
5462
  const createCodeHandler = () => {
5461
5463
  codeConfig.value = {
5462
5464
  name: "",
5463
- content: `({ params, dataSource, app, flowState }) => {
5464
- // place your code here
5465
- }`,
5465
+ content: "({ params, dataSource, app, flowState }) => {\n // place your code here\n}",
5466
5466
  params: []
5467
5467
  };
5468
5468
  editIndex = -1;
@@ -5498,7 +5498,7 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
5498
5498
  });
5499
5499
  }
5500
5500
  editIndex = -1;
5501
- codeConfig.value = undefined;
5501
+ codeConfig.value = void 0;
5502
5502
  codeBlockEditorRef.value?.hide();
5503
5503
  };
5504
5504
  return (_ctx, _cache) => {
@@ -5581,12 +5581,12 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
5581
5581
  }));
5582
5582
  };
5583
5583
  const paramsConfig = ref(getParamItemsConfig(props.model[props.name || "dataSourceMethod"]));
5584
- const setParamsConfig = (dataSourceMethod, formState = {}) => {
5584
+ const setParamsConfig = (dataSourceMethod, formState = {}, setModel) => {
5585
5585
  paramsConfig.value = dataSourceMethod ? getParamItemsConfig(dataSourceMethod) : [];
5586
5586
  if (paramsConfig.value.length) {
5587
- props.model.params = createValues(formState, paramsConfig.value, {}, props.model.params);
5587
+ setModel("params", createValues(formState, paramsConfig.value, {}, props.model.params));
5588
5588
  } else {
5589
- props.model.params = {};
5589
+ setModel("params", {});
5590
5590
  }
5591
5591
  };
5592
5592
  const methodsOptions = computed(
@@ -5607,8 +5607,8 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
5607
5607
  name: props.name,
5608
5608
  options: methodsOptions.value,
5609
5609
  disable: props.disabled,
5610
- onChange: (formState, dataSourceMethod) => {
5611
- setParamsConfig(dataSourceMethod, formState);
5610
+ onChange: (formState, dataSourceMethod, { setModel }) => {
5611
+ setParamsConfig(dataSourceMethod, formState, setModel);
5612
5612
  return dataSourceMethod;
5613
5613
  }
5614
5614
  }));
@@ -6276,8 +6276,8 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
6276
6276
  text: "联动组件",
6277
6277
  type: "ui-select",
6278
6278
  display: (mForm, { model }) => model.actionType === ActionType.COMP,
6279
- onChange: (MForm, v, { model }) => {
6280
- model.method = "";
6279
+ onChange: (MForm, v, { setModel }) => {
6280
+ setModel("method", "");
6281
6281
  return v;
6282
6282
  }
6283
6283
  };
@@ -6850,7 +6850,7 @@ const _export_sfc = (sfc, props) => {
6850
6850
  return target;
6851
6851
  };
6852
6852
 
6853
- const _sfc_main$13 = {};
6853
+ const _sfc_main$13 = { };
6854
6854
 
6855
6855
  const _hoisted_1$J = {
6856
6856
  xmlns: "http://www.w3.org/2000/svg",
@@ -6864,7 +6864,7 @@ function _sfc_render$k(_ctx, _cache) {
6864
6864
  }
6865
6865
  const BackgroundRepeat = /*#__PURE__*/_export_sfc(_sfc_main$13, [['render',_sfc_render$k]]);
6866
6866
 
6867
- const _sfc_main$12 = {};
6867
+ const _sfc_main$12 = { };
6868
6868
 
6869
6869
  const _hoisted_1$I = {
6870
6870
  xmlns: "http://www.w3.org/2000/svg",
@@ -6881,7 +6881,7 @@ function _sfc_render$j(_ctx, _cache) {
6881
6881
  }
6882
6882
  const BackgroundRepeatX = /*#__PURE__*/_export_sfc(_sfc_main$12, [['render',_sfc_render$j]]);
6883
6883
 
6884
- const _sfc_main$11 = {};
6884
+ const _sfc_main$11 = { };
6885
6885
 
6886
6886
  const _hoisted_1$H = {
6887
6887
  xmlns: "http://www.w3.org/2000/svg",
@@ -6898,7 +6898,7 @@ function _sfc_render$i(_ctx, _cache) {
6898
6898
  }
6899
6899
  const BackgroundRepeatY = /*#__PURE__*/_export_sfc(_sfc_main$11, [['render',_sfc_render$i]]);
6900
6900
 
6901
- const _sfc_main$10 = {};
6901
+ const _sfc_main$10 = { };
6902
6902
 
6903
6903
  const _hoisted_1$G = {
6904
6904
  xmlns: "http://www.w3.org/2000/svg",
@@ -6990,7 +6990,7 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent({
6990
6990
  }
6991
6991
  });
6992
6992
 
6993
- const _sfc_main$_ = {};
6993
+ const _sfc_main$_ = { };
6994
6994
 
6995
6995
  const _hoisted_1$F = {
6996
6996
  xmlns: "http://www.w3.org/2000/svg",
@@ -7004,7 +7004,7 @@ function _sfc_render$g(_ctx, _cache) {
7004
7004
  }
7005
7005
  const AlignLeft = /*#__PURE__*/_export_sfc(_sfc_main$_, [['render',_sfc_render$g]]);
7006
7006
 
7007
- const _sfc_main$Z = {};
7007
+ const _sfc_main$Z = { };
7008
7008
 
7009
7009
  const _hoisted_1$E = {
7010
7010
  xmlns: "http://www.w3.org/2000/svg",
@@ -7018,7 +7018,7 @@ function _sfc_render$f(_ctx, _cache) {
7018
7018
  }
7019
7019
  const AlignCenter = /*#__PURE__*/_export_sfc(_sfc_main$Z, [['render',_sfc_render$f]]);
7020
7020
 
7021
- const _sfc_main$Y = {};
7021
+ const _sfc_main$Y = { };
7022
7022
 
7023
7023
  const _hoisted_1$D = {
7024
7024
  xmlns: "http://www.w3.org/2000/svg",
@@ -7215,7 +7215,7 @@ const _sfc_main$W = /* @__PURE__ */ defineComponent({
7215
7215
  }
7216
7216
  });
7217
7217
 
7218
- const _sfc_main$V = {};
7218
+ const _sfc_main$V = { };
7219
7219
 
7220
7220
  const _hoisted_1$B = {
7221
7221
  xmlns: "http://www.w3.org/2000/svg",
@@ -7229,7 +7229,7 @@ function _sfc_render$d(_ctx, _cache) {
7229
7229
  }
7230
7230
  const DisplayBlock = /*#__PURE__*/_export_sfc(_sfc_main$V, [['render',_sfc_render$d]]);
7231
7231
 
7232
- const _sfc_main$U = {};
7232
+ const _sfc_main$U = { };
7233
7233
 
7234
7234
  const _hoisted_1$A = {
7235
7235
  xmlns: "http://www.w3.org/2000/svg",
@@ -7243,7 +7243,7 @@ function _sfc_render$c(_ctx, _cache) {
7243
7243
  }
7244
7244
  const DisplayFlex = /*#__PURE__*/_export_sfc(_sfc_main$U, [['render',_sfc_render$c]]);
7245
7245
 
7246
- const _sfc_main$T = {};
7246
+ const _sfc_main$T = { };
7247
7247
 
7248
7248
  const _hoisted_1$z = {
7249
7249
  xmlns: "http://www.w3.org/2000/svg",
@@ -7257,7 +7257,7 @@ function _sfc_render$b(_ctx, _cache) {
7257
7257
  }
7258
7258
  const DisplayInline = /*#__PURE__*/_export_sfc(_sfc_main$T, [['render',_sfc_render$b]]);
7259
7259
 
7260
- const _sfc_main$S = {};
7260
+ const _sfc_main$S = { };
7261
7261
 
7262
7262
  const _hoisted_1$y = {
7263
7263
  xmlns: "http://www.w3.org/2000/svg",
@@ -7271,7 +7271,7 @@ function _sfc_render$a(_ctx, _cache) {
7271
7271
  }
7272
7272
  const DisplayInlineBlock = /*#__PURE__*/_export_sfc(_sfc_main$S, [['render',_sfc_render$a]]);
7273
7273
 
7274
- const _sfc_main$R = {};
7274
+ const _sfc_main$R = { };
7275
7275
 
7276
7276
  const _hoisted_1$x = {
7277
7277
  xmlns: "http://www.w3.org/2000/svg",
@@ -7285,7 +7285,7 @@ function _sfc_render$9(_ctx, _cache) {
7285
7285
  }
7286
7286
  const DisplayNone = /*#__PURE__*/_export_sfc(_sfc_main$R, [['render',_sfc_render$9]]);
7287
7287
 
7288
- const _sfc_main$Q = {};
7288
+ const _sfc_main$Q = { };
7289
7289
 
7290
7290
  const _hoisted_1$w = {
7291
7291
  xmlns: "http://www.w3.org/2000/svg",
@@ -7299,7 +7299,7 @@ function _sfc_render$8(_ctx, _cache) {
7299
7299
  }
7300
7300
  const FlexDirectionColumn = /*#__PURE__*/_export_sfc(_sfc_main$Q, [['render',_sfc_render$8]]);
7301
7301
 
7302
- const _sfc_main$P = {};
7302
+ const _sfc_main$P = { };
7303
7303
 
7304
7304
  const _hoisted_1$v = {
7305
7305
  xmlns: "http://www.w3.org/2000/svg",
@@ -7313,7 +7313,7 @@ function _sfc_render$7(_ctx, _cache) {
7313
7313
  }
7314
7314
  const FlexDirectionColumnReverse = /*#__PURE__*/_export_sfc(_sfc_main$P, [['render',_sfc_render$7]]);
7315
7315
 
7316
- const _sfc_main$O = {};
7316
+ const _sfc_main$O = { };
7317
7317
 
7318
7318
  const _hoisted_1$u = {
7319
7319
  xmlns: "http://www.w3.org/2000/svg",
@@ -7327,7 +7327,7 @@ function _sfc_render$6(_ctx, _cache) {
7327
7327
  }
7328
7328
  const FlexDirectionRow = /*#__PURE__*/_export_sfc(_sfc_main$O, [['render',_sfc_render$6]]);
7329
7329
 
7330
- const _sfc_main$N = {};
7330
+ const _sfc_main$N = { };
7331
7331
 
7332
7332
  const _hoisted_1$t = {
7333
7333
  xmlns: "http://www.w3.org/2000/svg",
@@ -7341,7 +7341,7 @@ function _sfc_render$5(_ctx, _cache) {
7341
7341
  }
7342
7342
  const FlexDirectionRowReverse = /*#__PURE__*/_export_sfc(_sfc_main$N, [['render',_sfc_render$5]]);
7343
7343
 
7344
- const _sfc_main$M = {};
7344
+ const _sfc_main$M = { };
7345
7345
 
7346
7346
  const _hoisted_1$s = {
7347
7347
  xmlns: "http://www.w3.org/2000/svg",
@@ -7355,7 +7355,7 @@ function _sfc_render$4(_ctx, _cache) {
7355
7355
  }
7356
7356
  const JustifyContentCenter = /*#__PURE__*/_export_sfc(_sfc_main$M, [['render',_sfc_render$4]]);
7357
7357
 
7358
- const _sfc_main$L = {};
7358
+ const _sfc_main$L = { };
7359
7359
 
7360
7360
  const _hoisted_1$r = {
7361
7361
  xmlns: "http://www.w3.org/2000/svg",
@@ -7369,7 +7369,7 @@ function _sfc_render$3(_ctx, _cache) {
7369
7369
  }
7370
7370
  const JustifyContentFlexEnd = /*#__PURE__*/_export_sfc(_sfc_main$L, [['render',_sfc_render$3]]);
7371
7371
 
7372
- const _sfc_main$K = {};
7372
+ const _sfc_main$K = { };
7373
7373
 
7374
7374
  const _hoisted_1$q = {
7375
7375
  xmlns: "http://www.w3.org/2000/svg",
@@ -7383,7 +7383,7 @@ function _sfc_render$2(_ctx, _cache) {
7383
7383
  }
7384
7384
  const JustifyContentFlexStart = /*#__PURE__*/_export_sfc(_sfc_main$K, [['render',_sfc_render$2]]);
7385
7385
 
7386
- const _sfc_main$J = {};
7386
+ const _sfc_main$J = { };
7387
7387
 
7388
7388
  const _hoisted_1$p = {
7389
7389
  xmlns: "http://www.w3.org/2000/svg",
@@ -7397,7 +7397,7 @@ function _sfc_render$1(_ctx, _cache) {
7397
7397
  }
7398
7398
  const JustifyContentSpaceAround = /*#__PURE__*/_export_sfc(_sfc_main$J, [['render',_sfc_render$1]]);
7399
7399
 
7400
- const _sfc_main$I = {};
7400
+ const _sfc_main$I = { };
7401
7401
 
7402
7402
  const _hoisted_1$o = {
7403
7403
  xmlns: "http://www.w3.org/2000/svg",
@@ -7995,7 +7995,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
7995
7995
  emit("change", id);
7996
7996
  mForm?.$emit("field-change", props.prop, id);
7997
7997
  }
7998
- {
7998
+ if (cancelHandler) {
7999
7999
  cancelHandler();
8000
8000
  }
8001
8001
  };
@@ -9311,7 +9311,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
9311
9311
  renderSlot(_ctx.$slots, "props-panel")
9312
9312
  ]),
9313
9313
  key: "0"
9314
- } : undefined
9314
+ } : void 0
9315
9315
  ]), 1032, ["left", "right", "min-left", "min-right", "min-center", "width"])),
9316
9316
  renderSlot(_ctx.$slots, "content-after"),
9317
9317
  renderSlot(_ctx.$slots, "footer")
@@ -9368,7 +9368,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
9368
9368
  type: "button",
9369
9369
  className: "delete",
9370
9370
  icon: markRaw(Delete),
9371
- tooltip: `刪除(Delete)`,
9371
+ tooltip: "刪除(Delete)",
9372
9372
  disabled: () => editorService.get("node")?.type === NodeType.PAGE,
9373
9373
  handler: () => {
9374
9374
  const node = editorService.get("node");
@@ -10433,6 +10433,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
10433
10433
  emit("node-contextmenu", event, data);
10434
10434
  };
10435
10435
  __expose({
10436
+ nodeStatusMap,
10436
10437
  filter: filterTextChangeHandler,
10437
10438
  deleteCode
10438
10439
  });
@@ -10594,7 +10595,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
10594
10595
  const eventBus = inject("eventBus");
10595
10596
  const { codeBlockService } = useServices();
10596
10597
  const editable = computed(() => codeBlockService.getEditStatus());
10597
- const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
10598
+ const { codeId, codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
10598
10599
  const codeBlockListRef = useTemplateRef("codeBlockList");
10599
10600
  const filterTextChangeHandler = (val) => {
10600
10601
  codeBlockListRef.value?.filter(val);
@@ -10602,6 +10603,20 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
10602
10603
  eventBus?.on("edit-code", (id) => {
10603
10604
  editCode(id);
10604
10605
  });
10606
+ watch(codeId, () => {
10607
+ if (codeBlockListRef.value) {
10608
+ for (const [statusId, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
10609
+ status.selected = statusId === codeId.value;
10610
+ }
10611
+ }
10612
+ });
10613
+ const editDialogCloseHandler = () => {
10614
+ if (codeBlockListRef.value) {
10615
+ for (const [, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
10616
+ status.selected = false;
10617
+ }
10618
+ }
10619
+ };
10605
10620
  const {
10606
10621
  nodeContentMenuHandler,
10607
10622
  menuData: contentMenuData,
@@ -10665,7 +10680,8 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
10665
10680
  ref: codeBlockEditor,
10666
10681
  disabled: !editable.value,
10667
10682
  content: unref(codeConfig),
10668
- onSubmit: unref(submitCodeBlockHandler)
10683
+ onSubmit: unref(submitCodeBlockHandler),
10684
+ onClose: editDialogCloseHandler
10669
10685
  }, null, 8, ["disabled", "content", "onSubmit"])) : createCommentVNode("v-if", true),
10670
10686
  (openBlock(), createBlock(Teleport, { to: "body" }, [
10671
10687
  menuData.value.length ? (openBlock(), createBlock(_sfc_main$o, {
@@ -10730,7 +10746,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
10730
10746
  "width": { default: 670 },
10731
10747
  "widthModifiers": {}
10732
10748
  }),
10733
- emits: /* @__PURE__ */ mergeModels(["submit"], ["update:visible", "update:width"]),
10749
+ emits: /* @__PURE__ */ mergeModels(["submit", "close", "open"], ["update:visible", "update:width"]),
10734
10750
  setup(__props, { expose: __expose, emit: __emit }) {
10735
10751
  const props = __props;
10736
10752
  const boxVisible = useModel(__props, "visible");
@@ -10752,6 +10768,15 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
10752
10768
  const errorHandler = (error) => {
10753
10769
  tMagicMessage.error(error.message);
10754
10770
  };
10771
+ watch(boxVisible, (visible) => {
10772
+ nextTick(() => {
10773
+ if (!visible) {
10774
+ emit("close");
10775
+ } else if (initValues.value?.id) {
10776
+ emit("open", initValues.value.id);
10777
+ }
10778
+ });
10779
+ });
10755
10780
  __expose({
10756
10781
  show() {
10757
10782
  calcBoxPosition();
@@ -10887,6 +10912,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
10887
10912
  emit("node-contextmenu", event, data);
10888
10913
  };
10889
10914
  __expose({
10915
+ nodeStatusMap,
10890
10916
  filter: filterTextChangeHandler
10891
10917
  });
10892
10918
  return (_ctx, _cache) => {
@@ -11042,6 +11068,20 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
11042
11068
  const eventBus = inject("eventBus");
11043
11069
  const { dataSourceService } = useServices();
11044
11070
  const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
11071
+ const editDialogCloseHandler = () => {
11072
+ if (dataSourceListRef.value) {
11073
+ for (const [, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
11074
+ status.selected = false;
11075
+ }
11076
+ }
11077
+ };
11078
+ watch(dataSourceValues, (dataSourceValues2) => {
11079
+ if (dataSourceListRef.value && dataSourceValues2.id) {
11080
+ for (const [statusId, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
11081
+ status.selected = statusId === dataSourceValues2.id;
11082
+ }
11083
+ }
11084
+ });
11045
11085
  const datasourceTypeList = computed(
11046
11086
  () => [
11047
11087
  { text: "基础", type: "base" },
@@ -11071,9 +11111,9 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
11071
11111
  });
11072
11112
  dataSourceService.remove(id);
11073
11113
  };
11074
- const dataSourceList = ref();
11114
+ const dataSourceListRef = useTemplateRef("dataSourceList");
11075
11115
  const filterTextChangeHandler = (val) => {
11076
- dataSourceList.value?.filter(val);
11116
+ dataSourceListRef.value?.filter(val);
11077
11117
  };
11078
11118
  eventBus?.on("edit-data-source", (id) => {
11079
11119
  editHandler(id);
@@ -11140,8 +11180,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
11140
11180
  ]),
11141
11181
  createCommentVNode(" 数据源列表 "),
11142
11182
  createVNode(_sfc_main$h, {
11143
- ref_key: "dataSourceList",
11144
- ref: dataSourceList,
11183
+ ref: "dataSourceList",
11145
11184
  indent: _ctx.indent,
11146
11185
  "next-level-indent-increment": _ctx.nextLevelIndentIncrement,
11147
11186
  onEdit: unref(editHandler),
@@ -11158,7 +11197,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
11158
11197
  disabled: !unref(editable),
11159
11198
  values: unref(dataSourceValues),
11160
11199
  title: unref(dialogTitle),
11161
- onSubmit: unref(submitDataSourceHandler)
11200
+ onSubmit: unref(submitDataSourceHandler),
11201
+ onClose: editDialogCloseHandler
11162
11202
  }, null, 8, ["disabled", "values", "title", "onSubmit"]),
11163
11203
  (openBlock(), createBlock(Teleport, { to: "body" }, [
11164
11204
  menuData.value.length ? (openBlock(), createBlock(_sfc_main$o, {
@@ -12045,7 +12085,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
12045
12085
  const dragendHandler = () => {
12046
12086
  if (timeout) {
12047
12087
  globalThis.clearTimeout(timeout);
12048
- timeout = undefined;
12088
+ timeout = void 0;
12049
12089
  }
12050
12090
  const doc = stage.value?.renderer?.getDocument();
12051
12091
  if (doc && stageOptions?.containerHighlightClassName) {
@@ -12060,7 +12100,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
12060
12100
  clientY = e.clientY;
12061
12101
  if (timeout) {
12062
12102
  globalThis.clearTimeout(timeout);
12063
- timeout = undefined;
12103
+ timeout = void 0;
12064
12104
  }
12065
12105
  return;
12066
12106
  }
@@ -12384,14 +12424,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12384
12424
  }) : config.slots?.componentList ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentList), { key: 1 })) : createCommentVNode("v-if", true)
12385
12425
  ]),
12386
12426
  key: "0"
12387
- } : undefined,
12427
+ } : void 0,
12388
12428
  config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
12389
12429
  name: "component-list-panel-header",
12390
12430
  fn: withCtx(() => [
12391
12431
  config.$key === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : config.slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("v-if", true)
12392
12432
  ]),
12393
12433
  key: "1"
12394
- } : undefined,
12434
+ } : void 0,
12395
12435
  config.$key === "component-list" || config.slots?.componentListItem ? {
12396
12436
  name: "component-list-item",
12397
12437
  fn: withCtx(({ component }) => [
@@ -12404,21 +12444,21 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12404
12444
  }, null, 8, ["component"])) : createCommentVNode("v-if", true)
12405
12445
  ]),
12406
12446
  key: "2"
12407
- } : undefined,
12447
+ } : void 0,
12408
12448
  config.$key === "layer" || config.slots?.layerPanelHeader ? {
12409
12449
  name: "layer-panel-header",
12410
12450
  fn: withCtx(() => [
12411
12451
  config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : config.slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerPanelHeader), { key: 1 })) : createCommentVNode("v-if", true)
12412
12452
  ]),
12413
12453
  key: "3"
12414
- } : undefined,
12454
+ } : void 0,
12415
12455
  config.$key === "code-block" || config.slots?.codeBlockPanelHeader ? {
12416
12456
  name: "code-block-panel-header",
12417
12457
  fn: withCtx(() => [
12418
12458
  config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : config.slots?.codeBlockPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelHeader), { key: 1 })) : createCommentVNode("v-if", true)
12419
12459
  ]),
12420
12460
  key: "4"
12421
- } : undefined,
12461
+ } : void 0,
12422
12462
  config.$key === "code-block" || config.slots?.codeBlockPanelTool ? {
12423
12463
  name: "code-block-panel-tool",
12424
12464
  fn: withCtx(({ id, data }) => [
@@ -12429,14 +12469,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12429
12469
  }) : config.slots?.codeBlockPanelTool ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelTool), { key: 1 })) : createCommentVNode("v-if", true)
12430
12470
  ]),
12431
12471
  key: "5"
12432
- } : undefined,
12472
+ } : void 0,
12433
12473
  config.$key === "code-block" || config.slots?.codeBlockPanelSearch ? {
12434
12474
  name: "code-block-panel-search",
12435
12475
  fn: withCtx(() => [
12436
12476
  config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-search", { key: 0 }) : config.slots?.codeBlockPanelSearch ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelSearch), { key: 1 })) : createCommentVNode("v-if", true)
12437
12477
  ]),
12438
12478
  key: "6"
12439
- } : undefined,
12479
+ } : void 0,
12440
12480
  config.$key === "layer" || config.slots?.layerNodeContent ? {
12441
12481
  name: "layer-node-content",
12442
12482
  fn: withCtx(({ data: nodeData }) => [
@@ -12449,7 +12489,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12449
12489
  }, null, 8, ["data"])) : createCommentVNode("v-if", true)
12450
12490
  ]),
12451
12491
  key: "7"
12452
- } : undefined,
12492
+ } : void 0,
12453
12493
  config.$key === "layer" || config.slots?.layerNodeLabel ? {
12454
12494
  name: "layer-node-label",
12455
12495
  fn: withCtx(({ data: nodeData }) => [
@@ -12462,7 +12502,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12462
12502
  }, null, 8, ["data"])) : createCommentVNode("v-if", true)
12463
12503
  ]),
12464
12504
  key: "8"
12465
- } : undefined,
12505
+ } : void 0,
12466
12506
  config.$key === "layer" || config.slots?.layerNodeTool ? {
12467
12507
  name: "layer-node-tool",
12468
12508
  fn: withCtx(({ data: nodeData }) => [
@@ -12475,7 +12515,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12475
12515
  }, null, 8, ["data"])) : createCommentVNode("v-if", true)
12476
12516
  ]),
12477
12517
  key: "9"
12478
- } : undefined,
12518
+ } : void 0,
12479
12519
  config.$key === "data-source" || config.slots?.dataSourcePanelTool ? {
12480
12520
  name: "data-source-panel-tool",
12481
12521
  fn: withCtx(({ data }) => [
@@ -12485,14 +12525,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
12485
12525
  }) : config.slots?.DataSourcePanelTool ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.DataSourcePanelTool), { key: 1 })) : createCommentVNode("v-if", true)
12486
12526
  ]),
12487
12527
  key: "10"
12488
- } : undefined,
12528
+ } : void 0,
12489
12529
  config.$key === "data-source" || config.slots?.dataSourcePanelSearch ? {
12490
12530
  name: "data-source-panel-search",
12491
12531
  fn: withCtx(() => [
12492
12532
  config.$key === "data-source" ? renderSlot(_ctx.$slots, "data-source-panel-search", { key: 0 }) : config.slots?.dataSourcePanelSearch ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.dataSourcePanelSearch), { key: 1 })) : createCommentVNode("v-if", true)
12493
12533
  ]),
12494
12534
  key: "11"
12495
- } : undefined
12535
+ } : void 0
12496
12536
  ]),
12497
12537
  1040
12498
12538
  /* FULL_PROPS, DYNAMIC_SLOTS */
@@ -13487,7 +13527,7 @@ class CodeBlock extends BaseService {
13487
13527
  editable: true,
13488
13528
  combineIds: [],
13489
13529
  undeletableList: [],
13490
- paramsColConfig: undefined
13530
+ paramsColConfig: void 0
13491
13531
  });
13492
13532
  constructor() {
13493
13533
  super([
@@ -13751,7 +13791,6 @@ class ComponentList extends BaseService {
13751
13791
  const componentListService = new ComponentList();
13752
13792
 
13753
13793
  const canUsePluginMethods$1 = {
13754
- async: [],
13755
13794
  sync: [
13756
13795
  "getFormConfig",
13757
13796
  "setFormConfig",
@@ -14273,7 +14312,6 @@ class Keybinding extends BaseService {
14273
14312
  const keybindingService = new Keybinding();
14274
14313
 
14275
14314
  const canUsePluginMethods = {
14276
- async: [],
14277
14315
  sync: ["openOverlay", "closeOverlay", "updateOverlay", "createStage"]
14278
14316
  };
14279
14317
  class StageOverlay extends BaseService {
@@ -14613,14 +14651,14 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
14613
14651
  const getTMagicApp = () => {
14614
14652
  const renderer = editorService.get("stage")?.renderer;
14615
14653
  if (!renderer) {
14616
- return undefined;
14654
+ return void 0;
14617
14655
  }
14618
14656
  if (renderer.runtime) {
14619
14657
  return renderer.runtime.getApp?.();
14620
14658
  }
14621
14659
  return new Promise((resolve) => {
14622
14660
  const timeout = globalThis.setTimeout(() => {
14623
- resolve(undefined);
14661
+ resolve(void 0);
14624
14662
  }, 1e4);
14625
14663
  renderer.on("runtime-ready", () => {
14626
14664
  if (timeout) {
@@ -14654,12 +14692,13 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
14654
14692
  app.dsl.dataSources = root.dataSources;
14655
14693
  }
14656
14694
  };
14657
- const dsDepCollectedHandler = async () => {
14695
+ const dsDepCollectedHandler = () => {
14658
14696
  const root = editorService.get("root");
14659
- const app = await getTMagicApp();
14660
- if (root && app?.dsl) {
14661
- app.dsl.dataSourceDeps = root.dataSourceDeps;
14662
- }
14697
+ getTMagicApp()?.then((app) => {
14698
+ if (root && app?.dsl) {
14699
+ app.dsl.dataSourceDeps = root.dataSourceDeps;
14700
+ }
14701
+ });
14663
14702
  };
14664
14703
  const collectIdle = (nodes, deep, type) => Promise.all(
14665
14704
  nodes.map((node) => {
@@ -14692,7 +14731,7 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
14692
14731
  depService.addTarget(createDataSourceMethodTarget(ds, reactive({})));
14693
14732
  depService.addTarget(createDataSourceCondTarget(ds, reactive({})));
14694
14733
  };
14695
- const rootChangeHandler = async (value, preValue) => {
14734
+ const rootChangeHandler = (value, preValue) => {
14696
14735
  if (!value) return;
14697
14736
  value.codeBlocks = value.codeBlocks || {};
14698
14737
  value.dataSources = value.dataSources || [];
@@ -14715,29 +14754,33 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
14715
14754
  delete value.dataSourceDeps;
14716
14755
  delete value.dataSourceCondDeps;
14717
14756
  }
14718
- const nodeId = editorService.get("node")?.id || props.defaultSelected;
14719
- let node;
14720
- if (nodeId) {
14721
- node = editorService.getNodeById(nodeId);
14722
- }
14723
- if (node && node !== value) {
14724
- await editorService.select(node.id);
14725
- } else if (value.items?.length) {
14726
- await editorService.select(value.items[0]);
14727
- } else if (value.id) {
14728
- editorService.set("nodes", [value]);
14729
- editorService.set("parent", null);
14730
- editorService.set("page", null);
14731
- }
14732
- if (toRaw(value) !== toRaw(preValue)) {
14733
- emit("update:modelValue", value);
14734
- }
14757
+ const handler = async () => {
14758
+ const nodeId = editorService.get("node")?.id || props.defaultSelected;
14759
+ let node;
14760
+ if (nodeId) {
14761
+ node = editorService.getNodeById(nodeId);
14762
+ }
14763
+ if (node && node !== value) {
14764
+ await editorService.select(node.id);
14765
+ } else if (value.items?.length) {
14766
+ await editorService.select(value.items[0]);
14767
+ } else if (value.id) {
14768
+ editorService.set("nodes", [value]);
14769
+ editorService.set("parent", null);
14770
+ editorService.set("page", null);
14771
+ }
14772
+ if (toRaw(value) !== toRaw(preValue)) {
14773
+ emit("update:modelValue", value);
14774
+ }
14775
+ };
14776
+ handler();
14735
14777
  };
14736
- const nodeAddHandler = async (nodes) => {
14737
- await collectIdle(nodes, true);
14738
- updateStageNodes(nodes);
14778
+ const nodeAddHandler = (nodes) => {
14779
+ collectIdle(nodes, true).then(() => {
14780
+ updateStageNodes(nodes);
14781
+ });
14739
14782
  };
14740
- const nodeUpdateHandler = async (data) => {
14783
+ const nodeUpdateHandler = (data) => {
14741
14784
  const needRecollectNodes = [];
14742
14785
  const normalNodes = [];
14743
14786
  for (const { newNode, oldNode, changeRecords } of data) {
@@ -14769,9 +14812,12 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
14769
14812
  }
14770
14813
  }
14771
14814
  if (needRecollectNodes.length) {
14772
- await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE);
14773
- await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE_COND);
14774
- updateStageNodes(needRecollectNodes);
14815
+ const handler = async () => {
14816
+ await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE);
14817
+ await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE_COND);
14818
+ updateStageNodes(needRecollectNodes);
14819
+ };
14820
+ handler();
14775
14821
  } else {
14776
14822
  updateStageNodes(normalNodes);
14777
14823
  Promise.all([
@@ -14783,28 +14829,32 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
14783
14829
  const nodeRemoveHandler = (nodes) => {
14784
14830
  depService.clear(nodes);
14785
14831
  };
14786
- const historyChangeHandler = async (page) => {
14787
- await collectIdle([page], true);
14788
- updateStageNode(page);
14832
+ const historyChangeHandler = (page) => {
14833
+ collectIdle([page], true).then(() => {
14834
+ updateStageNode(page);
14835
+ });
14789
14836
  };
14790
14837
  editorService.on("history-change", historyChangeHandler);
14791
14838
  editorService.on("root-change", rootChangeHandler);
14792
14839
  editorService.on("add", nodeAddHandler);
14793
14840
  editorService.on("remove", nodeRemoveHandler);
14794
14841
  editorService.on("update", nodeUpdateHandler);
14795
- const dataSourceAddHandler = async (config) => {
14796
- initDataSourceDepTarget(config);
14797
- const app = await getTMagicApp();
14798
- if (!app?.dataSourceManager) {
14799
- return;
14800
- }
14801
- app.dataSourceManager.addDataSource(config);
14802
- const newDs = app.dataSourceManager.get(config.id);
14803
- if (newDs) {
14804
- app.dataSourceManager.init(newDs);
14805
- }
14842
+ const dataSourceAddHandler = (config) => {
14843
+ const handler = async () => {
14844
+ initDataSourceDepTarget(config);
14845
+ const app = await getTMagicApp();
14846
+ if (!app?.dataSourceManager) {
14847
+ return;
14848
+ }
14849
+ app.dataSourceManager.addDataSource(config);
14850
+ const newDs = app.dataSourceManager.get(config.id);
14851
+ if (newDs) {
14852
+ app.dataSourceManager.init(newDs);
14853
+ }
14854
+ };
14855
+ handler();
14806
14856
  };
14807
- const dataSourceUpdateHandler = async (config, { changeRecords }) => {
14857
+ const dataSourceUpdateHandler = (config, { changeRecords }) => {
14808
14858
  const updateDsData = async () => {
14809
14859
  const app = await getTMagicApp();
14810
14860
  if (!app?.dataSourceManager) {
@@ -14865,23 +14915,26 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
14865
14915
  depService.removeTarget(id, DepTargetType.DATA_SOURCE_COND);
14866
14916
  depService.removeTarget(id, DepTargetType.DATA_SOURCE_METHOD);
14867
14917
  };
14868
- const dataSourceRemoveHandler = async (id) => {
14918
+ const dataSourceRemoveHandler = (id) => {
14869
14919
  const root = editorService.get("root");
14870
14920
  if (!root) {
14871
14921
  return;
14872
14922
  }
14873
- const nodeIds = Object.keys(root.dataSourceDeps?.[id] || {});
14874
- const nodes = getNodes(nodeIds, root.items);
14875
- await Promise.all([
14876
- collectIdle(nodes, false, DepTargetType.DATA_SOURCE),
14877
- collectIdle(nodes, false, DepTargetType.DATA_SOURCE_COND),
14878
- collectIdle(nodes, false, DepTargetType.DATA_SOURCE_METHOD)
14879
- ]);
14880
- updateDataSourceSchema();
14881
- const app = await getTMagicApp();
14882
- app?.dataSourceManager?.removeDataSource(id);
14883
- updateStageNodes(nodes);
14884
- removeDataSourceTarget(id);
14923
+ const handler = async () => {
14924
+ const nodeIds = Object.keys(root.dataSourceDeps?.[id] || {});
14925
+ const nodes = getNodes(nodeIds, root.items);
14926
+ await Promise.all([
14927
+ collectIdle(nodes, false, DepTargetType.DATA_SOURCE),
14928
+ collectIdle(nodes, false, DepTargetType.DATA_SOURCE_COND),
14929
+ collectIdle(nodes, false, DepTargetType.DATA_SOURCE_METHOD)
14930
+ ]);
14931
+ updateDataSourceSchema();
14932
+ const app = await getTMagicApp();
14933
+ app?.dataSourceManager?.removeDataSource(id);
14934
+ updateStageNodes(nodes);
14935
+ removeDataSourceTarget(id);
14936
+ };
14937
+ handler();
14885
14938
  };
14886
14939
  dataSourceService.on("add", dataSourceAddHandler);
14887
14940
  dataSourceService.on("update", dataSourceUpdateHandler);