@tmagic/editor 1.5.7 → 1.5.8

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 (72) hide show
  1. package/dist/style.css +17 -0
  2. package/dist/tmagic-editor.js +463 -470
  3. package/dist/tmagic-editor.umd.cjs +471 -469
  4. package/package.json +7 -7
  5. package/src/components/CodeBlockEditor.vue +4 -4
  6. package/src/components/FloatingBox.vue +4 -4
  7. package/src/components/ToolButton.vue +6 -4
  8. package/src/components/TreeNode.vue +2 -2
  9. package/src/fields/CodeSelect.vue +6 -6
  10. package/src/fields/CodeSelectCol.vue +5 -4
  11. package/src/fields/CondOpSelect.vue +5 -4
  12. package/src/fields/DataSourceFieldSelect/FieldSelect.vue +6 -5
  13. package/src/fields/DataSourceFieldSelect/Index.vue +4 -3
  14. package/src/fields/DataSourceFields.vue +3 -3
  15. package/src/fields/DataSourceInput.vue +4 -4
  16. package/src/fields/DataSourceMethodSelect.vue +8 -9
  17. package/src/fields/DataSourceMocks.vue +3 -3
  18. package/src/fields/DataSourceSelect.vue +6 -5
  19. package/src/fields/DisplayConds.vue +4 -4
  20. package/src/fields/EventSelect.vue +17 -23
  21. package/src/fields/PageFragmentSelect.vue +6 -5
  22. package/src/fields/UISelect.vue +16 -19
  23. package/src/hooks/index.ts +1 -0
  24. package/src/hooks/use-code-block-edit.ts +5 -10
  25. package/src/hooks/use-data-source-edit.ts +6 -6
  26. package/src/hooks/use-editor-content-height.ts +5 -5
  27. package/src/hooks/use-float-box.ts +5 -5
  28. package/src/hooks/use-next-float-box-position.ts +9 -9
  29. package/src/hooks/use-services.ts +13 -0
  30. package/src/hooks/use-stage.ts +2 -6
  31. package/src/layouts/AddPageBox.vue +3 -7
  32. package/src/layouts/Framework.vue +27 -27
  33. package/src/layouts/NavMenu.vue +16 -16
  34. package/src/layouts/page-bar/AddButton.vue +4 -7
  35. package/src/layouts/page-bar/PageBar.vue +10 -10
  36. package/src/layouts/page-bar/PageBarScrollContainer.vue +7 -8
  37. package/src/layouts/page-bar/PageList.vue +6 -8
  38. package/src/layouts/props-panel/FormPanel.vue +6 -4
  39. package/src/layouts/props-panel/PropsPanel.vue +39 -49
  40. package/src/layouts/props-panel/use-style-panel.ts +35 -19
  41. package/src/layouts/sidebar/ComponentListPanel.vue +5 -5
  42. package/src/layouts/sidebar/Sidebar.vue +15 -9
  43. package/src/layouts/sidebar/code-block/CodeBlockList.vue +13 -18
  44. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +4 -3
  45. package/src/layouts/sidebar/code-block/useContentMenu.ts +3 -3
  46. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +5 -5
  47. package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -17
  48. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +6 -12
  49. package/src/layouts/sidebar/data-source/useContentMenu.ts +3 -3
  50. package/src/layouts/sidebar/layer/LayerMenu.vue +11 -8
  51. package/src/layouts/sidebar/layer/LayerNodeTool.vue +2 -6
  52. package/src/layouts/sidebar/layer/LayerPanel.vue +6 -12
  53. package/src/layouts/sidebar/layer/use-click.ts +16 -15
  54. package/src/layouts/sidebar/layer/use-drag.ts +6 -6
  55. package/src/layouts/sidebar/layer/use-keybinding.ts +6 -8
  56. package/src/layouts/sidebar/layer/use-node-status.ts +16 -7
  57. package/src/layouts/workspace/Breadcrumb.vue +8 -9
  58. package/src/layouts/workspace/Workspace.vue +4 -10
  59. package/src/layouts/workspace/viewer/NodeListMenu.vue +9 -8
  60. package/src/layouts/workspace/viewer/Stage.vue +24 -24
  61. package/src/layouts/workspace/viewer/StageOverlay.vue +15 -16
  62. package/src/layouts/workspace/viewer/ViewerMenu.vue +15 -14
  63. package/src/services/dep.ts +23 -8
  64. package/src/services/ui.ts +6 -2
  65. package/src/theme/common/var.scss +1 -0
  66. package/src/theme/sidebar.scss +20 -1
  67. package/src/type.ts +3 -9
  68. package/src/utils/const.ts +11 -0
  69. package/src/utils/content-menu.ts +28 -30
  70. package/src/utils/idle-task.ts +11 -0
  71. package/src/utils/index.ts +1 -0
  72. package/types/index.d.ts +28 -10
@@ -5298,6 +5298,14 @@
5298
5298
  }
5299
5299
  });
5300
5300
 
5301
+ const useServices = () => {
5302
+ const services = vue.inject("services");
5303
+ if (!services) {
5304
+ throw new Error("services is required");
5305
+ }
5306
+ return services;
5307
+ };
5308
+
5301
5309
  const _sfc_main$1n = /* @__PURE__ */ vue.defineComponent({
5302
5310
  ...{
5303
5311
  name: "MFieldsCodeSelect"
@@ -5317,7 +5325,7 @@
5317
5325
  emits: ["change"],
5318
5326
  setup(__props, { emit: __emit }) {
5319
5327
  const emit = __emit;
5320
- const services = vue.inject("services");
5328
+ const { dataSourceService, codeBlockService } = useServices();
5321
5329
  const props = __props;
5322
5330
  const codeConfig = vue.computed(() => ({
5323
5331
  type: "group-list",
@@ -5330,7 +5338,7 @@
5330
5338
  if (model.codeId.length < 2) {
5331
5339
  return index;
5332
5340
  }
5333
- const ds = services?.dataSourceService.getDataSourceById(model.codeId[0]);
5341
+ const ds = dataSourceService.getDataSourceById(model.codeId[0]);
5334
5342
  return `${ds?.title} / ${model.codeId[1]}`;
5335
5343
  }
5336
5344
  return Array.isArray(model.codeId) ? model.codeId.join("/") : index;
@@ -5367,7 +5375,7 @@
5367
5375
  span: 18,
5368
5376
  labelWidth: 0,
5369
5377
  display: (mForm, { model }) => model.codeType !== core.HookCodeType.DATA_SOURCE_METHOD,
5370
- notEditable: () => !services?.codeBlockService.getEditStatus()
5378
+ notEditable: () => !codeBlockService.getEditStatus()
5371
5379
  },
5372
5380
  {
5373
5381
  type: "data-source-method-select",
@@ -5375,7 +5383,7 @@
5375
5383
  span: 18,
5376
5384
  labelWidth: 0,
5377
5385
  display: (mForm, { model }) => model.codeType === core.HookCodeType.DATA_SOURCE_METHOD,
5378
- notEditable: () => !services?.dataSourceService.get("editable")
5386
+ notEditable: () => !dataSourceService.get("editable")
5379
5387
  }
5380
5388
  ]
5381
5389
  }
@@ -5652,8 +5660,6 @@
5652
5660
  Keys2["ESCAPE"] = "Space";
5653
5661
  return Keys2;
5654
5662
  })(Keys || {});
5655
- const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
5656
- const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
5657
5663
  var CodeDeleteErrorType = /* @__PURE__ */ ((CodeDeleteErrorType2) => {
5658
5664
  CodeDeleteErrorType2["UNDELETEABLE"] = "undeleteable";
5659
5665
  CodeDeleteErrorType2["BIND"] = "bind";
@@ -5687,7 +5693,6 @@
5687
5693
  DragType2["LAYER_TREE"] = "layer-tree";
5688
5694
  return DragType2;
5689
5695
  })(DragType || {});
5690
- const UI_SELECT_MODE_EVENT_NAME = "ui-select";
5691
5696
 
5692
5697
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
5693
5698
  const COPY_CODE_STORAGE_KEY = "$MagicEditorCopyCode";
@@ -7772,6 +7777,10 @@
7772
7777
  this.hightLevelTaskList = [];
7773
7778
  this.taskList = [];
7774
7779
  this.taskHandle = null;
7780
+ this.emit("update-task-length", {
7781
+ length: this.taskList.length + this.hightLevelTaskList.length,
7782
+ hightLevelLength: this.hightLevelTaskList.length
7783
+ });
7775
7784
  }
7776
7785
  on(eventName, listener) {
7777
7786
  return super.on(eventName, listener);
@@ -7815,6 +7824,10 @@
7815
7824
  this.taskHandle = 0;
7816
7825
  this.emit("finish");
7817
7826
  }
7827
+ this.emit("update-task-length", {
7828
+ length: taskList.length + hightLevelTaskList.length,
7829
+ hightLevelLength: hightLevelTaskList.length
7830
+ });
7818
7831
  }
7819
7832
  }
7820
7833
 
@@ -7955,6 +7968,18 @@
7955
7968
  });
7956
7969
  };
7957
7970
 
7971
+ const UI_SELECT_MODE_EVENT_NAME = "ui-select";
7972
+ const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
7973
+ const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
7974
+ const PROPS_PANEL_WIDTH_STORAGE_KEY = "$MagicEditorPropsPanelWidthData";
7975
+ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
7976
+ const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
7977
+ const MIN_LEFT_COLUMN_WIDTH = 200;
7978
+ const MIN_CENTER_COLUMN_WIDTH = 400;
7979
+ const MIN_RIGHT_COLUMN_WIDTH = 300;
7980
+ const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
7981
+ const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
7982
+
7958
7983
  const _sfc_main$1m = /* @__PURE__ */ vue.defineComponent({
7959
7984
  ...{
7960
7985
  name: "MEditorCodeParams"
@@ -8035,13 +8060,13 @@
8035
8060
  emits: ["change"],
8036
8061
  setup(__props, { emit: __emit }) {
8037
8062
  const mForm = vue.inject("mForm");
8038
- const services = vue.inject("services");
8063
+ const { codeBlockService, uiService } = useServices();
8039
8064
  const eventBus = vue.inject("eventBus");
8040
8065
  const emit = __emit;
8041
8066
  const props = __props;
8042
8067
  const notEditable = vue.computed(() => formPlugin.filterFunction(mForm, props.config.notEditable, props));
8043
8068
  const hasCodeBlockSidePanel = vue.computed(
8044
- () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
8069
+ () => (uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
8045
8070
  );
8046
8071
  const getParamItemsConfig = (codeId) => {
8047
8072
  if (!codeDsl.value || !codeId) return [];
@@ -8053,7 +8078,7 @@
8053
8078
  ...paramState
8054
8079
  }));
8055
8080
  };
8056
- const codeDsl = vue.computed(() => services?.codeBlockService.getCodeDsl());
8081
+ const codeDsl = vue.computed(() => codeBlockService.getCodeDsl());
8057
8082
  const paramsConfig = vue.ref(getParamItemsConfig(props.model[props.name]));
8058
8083
  vue.watch(
8059
8084
  () => props.model[props.name],
@@ -8171,12 +8196,12 @@
8171
8196
  emits: ["change"],
8172
8197
  setup(__props, { emit: __emit }) {
8173
8198
  const emit = __emit;
8174
- const { dataSourceService } = vue.inject("services") || {};
8199
+ const { dataSourceService } = useServices();
8175
8200
  const props = __props;
8176
8201
  const optionComponent = designPlugin.getDesignConfig("components")?.option;
8177
8202
  const options = vue.computed(() => {
8178
8203
  const [id, ...fieldNames] = [...props.config.parentFields || [], ...props.model.field];
8179
- const ds = dataSourceService?.getDataSourceById(id);
8204
+ const ds = dataSourceService.getDataSourceById(id);
8180
8205
  let fields = ds?.fields || [];
8181
8206
  let type = "";
8182
8207
  (fieldNames || []).forEach((fieldName) => {
@@ -8289,8 +8314,8 @@
8289
8314
  }
8290
8315
  return "auto";
8291
8316
  });
8292
- const services = vue.inject("services");
8293
- const frameworkWidth = vue.computed(() => services?.uiService.get("frameworkRect").width || 0);
8317
+ const { uiService } = useServices();
8318
+ const frameworkWidth = vue.computed(() => uiService.get("frameworkRect").width || 0);
8294
8319
  const style = vue.computed(() => {
8295
8320
  let { left } = props.position;
8296
8321
  if (width.value) {
@@ -8453,10 +8478,6 @@
8453
8478
  const codeId = vue.ref();
8454
8479
  const codeBlockEditorRef = vue.useTemplateRef("codeBlockEditor");
8455
8480
  const createCodeBlock = async () => {
8456
- if (!codeBlockService) {
8457
- designPlugin.tMagicMessage.error("新增代码块失败");
8458
- return;
8459
- }
8460
8481
  codeConfig.value = {
8461
8482
  name: "",
8462
8483
  content: `({app, params, flowState}) => {
@@ -8469,7 +8490,7 @@
8469
8490
  codeBlockEditorRef.value?.show();
8470
8491
  };
8471
8492
  const editCode = async (id) => {
8472
- const codeBlock = await codeBlockService?.getCodeContentById(id);
8493
+ const codeBlock = await codeBlockService.getCodeContentById(id);
8473
8494
  if (!codeBlock) {
8474
8495
  designPlugin.tMagicMessage.error("获取代码块内容失败");
8475
8496
  return;
@@ -8487,11 +8508,11 @@
8487
8508
  codeBlockEditorRef.value?.show();
8488
8509
  };
8489
8510
  const deleteCode = async (key) => {
8490
- codeBlockService?.deleteCodeDslByIds([key]);
8511
+ codeBlockService.deleteCodeDslByIds([key]);
8491
8512
  };
8492
8513
  const submitCodeBlockHandler = async (values) => {
8493
8514
  if (!codeId.value) return;
8494
- await codeBlockService?.setCodeDslById(codeId.value, values);
8515
+ await codeBlockService.setCodeDslById(codeId.value, values);
8495
8516
  codeBlockEditorRef.value?.hide();
8496
8517
  };
8497
8518
  return {
@@ -8505,11 +8526,6 @@
8505
8526
  };
8506
8527
  };
8507
8528
 
8508
- const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
8509
- const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
8510
- const DEFAULT_LEFT_COLUMN_WIDTH = 310;
8511
- const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
8512
-
8513
8529
  const state = vue.shallowReactive({
8514
8530
  uiSelectMode: false,
8515
8531
  showSrc: false,
@@ -8524,9 +8540,9 @@
8524
8540
  height: 817
8525
8541
  },
8526
8542
  columnWidth: {
8527
- left: Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH,
8543
+ left: storageService.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_LEFT_COLUMN_WIDTH,
8528
8544
  center: 0,
8529
- right: Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH
8545
+ right: storageService.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_RIGHT_COLUMN_WIDTH
8530
8546
  },
8531
8547
  showGuides: true,
8532
8548
  showRule: true,
@@ -8718,7 +8734,7 @@
8718
8734
  };
8719
8735
 
8720
8736
  const useFloatBox = (slideKeys) => {
8721
- const services = vue.inject("services");
8737
+ const { uiService } = useServices();
8722
8738
  const floatBoxStates = vue.ref(
8723
8739
  slideKeys.value.reduce(
8724
8740
  (total, cur) => ({
@@ -8752,10 +8768,10 @@
8752
8768
  if (!dragState.isDragging) return;
8753
8769
  const { startOffset } = dragState;
8754
8770
  if (Math.abs(startOffset.x - e.clientX) > effectiveDistance || Math.abs(startOffset.y - e.clientY) > effectiveDistance) {
8755
- const navMenuRect = services?.uiService?.get("navMenuRect");
8771
+ const navMenuRect = uiService.get("navMenuRect");
8756
8772
  floatBoxStates.value[key] = {
8757
8773
  left: e.clientX,
8758
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0),
8774
+ top: navMenuRect.top + navMenuRect.height,
8759
8775
  status: true
8760
8776
  };
8761
8777
  }
@@ -8818,9 +8834,9 @@
8818
8834
  };
8819
8835
 
8820
8836
  const useEditorContentHeight = () => {
8821
- const services = vue.inject("services");
8822
- const frameworkHeight = vue.computed(() => services?.uiService.get("frameworkRect").height || 0);
8823
- const navMenuHeight = vue.computed(() => services?.uiService.get("navMenuRect").height || 0);
8837
+ const { uiService } = useServices();
8838
+ const frameworkHeight = vue.computed(() => uiService.get("frameworkRect").height);
8839
+ const navMenuHeight = vue.computed(() => uiService.get("navMenuRect").height);
8824
8840
  const editorContentHeight = vue.computed(() => frameworkHeight.value - navMenuHeight.value);
8825
8841
  const height = vue.ref(0);
8826
8842
  vue.watch(
@@ -8906,16 +8922,16 @@
8906
8922
  top: 0
8907
8923
  });
8908
8924
  const calcBoxPosition = () => {
8909
- const columnWidth = uiService?.get("columnWidth");
8910
- const navMenuRect = uiService?.get("navMenuRect");
8911
- let left = columnWidth?.left ?? 0;
8925
+ const columnWidth = uiService.get("columnWidth");
8926
+ const navMenuRect = uiService.get("navMenuRect");
8927
+ let left = columnWidth.left ?? 0;
8912
8928
  if (parent?.value) {
8913
- const rect = parent?.value?.getBoundingClientRect();
8914
- left = (rect?.left ?? 0) + (rect?.width ?? 0);
8929
+ const rect = parent.value.getBoundingClientRect();
8930
+ left = rect.left + rect.width;
8915
8931
  }
8916
8932
  boxPosition.value = {
8917
8933
  left,
8918
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
8934
+ top: navMenuRect.top + navMenuRect.height
8919
8935
  };
8920
8936
  };
8921
8937
  return {
@@ -8987,7 +9003,7 @@
8987
9003
  setup(__props, { emit: __emit }) {
8988
9004
  const props = __props;
8989
9005
  const emit = __emit;
8990
- const services = vue.inject("services");
9006
+ const { uiService } = useServices();
8991
9007
  const fieldValues = vue.ref({});
8992
9008
  const fieldTitle = vue.ref("");
8993
9009
  const width = vue.useModel(__props, "width");
@@ -9222,7 +9238,7 @@
9222
9238
  const addFromJsonDialogVisible = vue.useModel(__props, "visible1");
9223
9239
  const { height: editorHeight } = useEditorContentHeight();
9224
9240
  const parentFloating = vue.inject("parentFloating", vue.ref(null));
9225
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
9241
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
9226
9242
  return (_ctx, _cache) => {
9227
9243
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$X, [
9228
9244
  vue.createVNode(vue.unref(tablePlugin.MagicTable), {
@@ -9326,10 +9342,10 @@
9326
9342
  const emit = __emit;
9327
9343
  const modelValue = vue.useModel(__props, "modelValue");
9328
9344
  const optionComponent = designPlugin.getDesignConfig("components")?.option;
9329
- const services = vue.inject("services");
9345
+ const { dataSourceService, uiService } = useServices();
9330
9346
  const mForm = vue.inject("mForm");
9331
9347
  const eventBus = vue.inject("eventBus");
9332
- const dataSources = vue.computed(() => services?.dataSourceService.get("dataSources") || []);
9348
+ const dataSources = vue.computed(() => dataSourceService.get("dataSources") || []);
9333
9349
  const valueIsKey = vue.computed(() => props.value === "key");
9334
9350
  const notEditable = vue.computed(() => formPlugin.filterFunction(mForm, props.notEditable, props));
9335
9351
  const dataSourcesOptions = vue.computed(
@@ -9382,7 +9398,7 @@
9382
9398
  emit("change", v);
9383
9399
  };
9384
9400
  const hasDataSourceSidePanel = vue.computed(
9385
- () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
9401
+ () => uiService.get("sideBarItems").find((item) => item.$key === SideItemKey.DATA_SOURCE)
9386
9402
  );
9387
9403
  const editHandler = (id) => {
9388
9404
  eventBus?.emit("edit-data-source", removeDataSourceFieldPrefix(id));
@@ -9526,9 +9542,9 @@
9526
9542
  immediate: true
9527
9543
  }
9528
9544
  );
9529
- const services = vue.inject("services");
9545
+ const { dataSourceService } = useServices();
9530
9546
  const mForm = vue.inject("mForm");
9531
- const dataSources = vue.computed(() => services?.dataSourceService.get("dataSources") || []);
9547
+ const dataSources = vue.computed(() => dataSourceService.get("dataSources") || []);
9532
9548
  const type = vue.computed(() => {
9533
9549
  let type2 = props.config.fieldConfig?.type;
9534
9550
  if (typeof type2 === "function") {
@@ -9666,13 +9682,13 @@
9666
9682
  setup(__props, { emit: __emit }) {
9667
9683
  const props = __props;
9668
9684
  const emit = __emit;
9669
- const { dataSourceService } = vue.inject("services") || {};
9685
+ const { dataSourceService } = useServices();
9670
9686
  const autocompleteRef = vue.useTemplateRef("autocomplete");
9671
9687
  const isFocused = vue.ref(false);
9672
9688
  const state = vue.ref("");
9673
9689
  const displayState = vue.ref([]);
9674
9690
  const input = vue.computed(() => autocompleteRef.value?.inputRef?.input);
9675
- const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
9691
+ const dataSources = vue.computed(() => dataSourceService.get("dataSources"));
9676
9692
  const setDisplayState = () => {
9677
9693
  displayState.value = getDisplayField(dataSources.value, state.value);
9678
9694
  };
@@ -9965,7 +9981,7 @@
9965
9981
  const boxVisible = vue.useModel(__props, "visible");
9966
9982
  const props = __props;
9967
9983
  const emit = __emit;
9968
- const services = vue.inject("services");
9984
+ const { codeBlockService, uiService } = useServices();
9969
9985
  const { height: codeBlockEditorHeight } = useEditorContentHeight();
9970
9986
  const difVisible = vue.ref(false);
9971
9987
  const { rect: windowRect } = useWindowRect();
@@ -10052,7 +10068,7 @@
10052
10068
  label: "描述",
10053
10069
  name: "extra"
10054
10070
  },
10055
- services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
10071
+ codeBlockService.getParamsColConfig() || defaultParamColConfig
10056
10072
  ]
10057
10073
  },
10058
10074
  {
@@ -10104,7 +10120,7 @@
10104
10120
  changedValue.value = undefined;
10105
10121
  };
10106
10122
  const parentFloating = vue.inject("parentFloating", vue.ref(null));
10107
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
10123
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
10108
10124
  __expose({
10109
10125
  async show() {
10110
10126
  calcBoxPosition();
@@ -10427,20 +10443,19 @@
10427
10443
  },
10428
10444
  emits: ["change"],
10429
10445
  setup(__props, { emit: __emit }) {
10446
+ const { dataSourceService, uiService } = useServices();
10430
10447
  const mForm = vue.inject("mForm");
10431
- const services = vue.inject("services");
10432
10448
  const eventBus = vue.inject("eventBus");
10433
10449
  const emit = __emit;
10434
- const dataSourceService = services?.dataSourceService;
10435
10450
  const props = __props;
10436
10451
  const hasDataSourceSidePanel = vue.computed(
10437
- () => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
10452
+ () => (uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
10438
10453
  );
10439
10454
  const notEditable = vue.computed(() => formPlugin.filterFunction(mForm, props.config.notEditable, props));
10440
- const dataSources = vue.computed(() => dataSourceService?.get("dataSources"));
10455
+ const dataSources = vue.computed(() => dataSourceService.get("dataSources"));
10441
10456
  const isCustomMethod = vue.computed(() => {
10442
10457
  const [id, name] = props.model[props.name];
10443
- const dataSource = dataSourceService?.getDataSourceById(id);
10458
+ const dataSource = dataSourceService.getDataSourceById(id);
10444
10459
  return Boolean(dataSource?.methods.find((method) => method.name === name));
10445
10460
  });
10446
10461
  const getParamItemsConfig = ([dataSourceId, methodName] = ["", ""]) => {
@@ -10462,7 +10477,7 @@
10462
10477
  }
10463
10478
  };
10464
10479
  const methodsOptions = vue.computed(
10465
- () => dataSources.value?.filter((ds) => ds.methods?.length || dataSourceService?.getFormMethod(ds.type).length)?.map((ds) => ({
10480
+ () => dataSources.value?.filter((ds) => ds.methods?.length || dataSourceService.getFormMethod(ds.type).length)?.map((ds) => ({
10466
10481
  label: ds.title || ds.id,
10467
10482
  value: ds.id,
10468
10483
  children: [
@@ -10490,7 +10505,7 @@
10490
10505
  };
10491
10506
  const editCodeHandler = () => {
10492
10507
  const [id] = props.model[props.name];
10493
- const dataSource = dataSourceService?.getDataSourceById(id);
10508
+ const dataSource = dataSourceService.getDataSourceById(id);
10494
10509
  if (!dataSource) return;
10495
10510
  eventBus?.emit("edit-data-source", id);
10496
10511
  };
@@ -10568,7 +10583,7 @@
10568
10583
  setup(__props, { emit: __emit }) {
10569
10584
  const props = __props;
10570
10585
  const emit = __emit;
10571
- const services = vue.inject("services");
10586
+ const { uiService } = useServices();
10572
10587
  const width = vue.useModel(__props, "width");
10573
10588
  const drawerTitle = vue.ref("");
10574
10589
  const formValues = vue.ref({});
@@ -10745,7 +10760,7 @@
10745
10760
  const addDialogVisible = vue.useModel(__props, "visible");
10746
10761
  const { height: editorHeight } = useEditorContentHeight();
10747
10762
  const parentFloating = vue.inject("parentFloating", vue.ref(null));
10748
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
10763
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
10749
10764
  return (_ctx, _cache) => {
10750
10765
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$Q, [
10751
10766
  vue.createVNode(vue.unref(tablePlugin.MagicTable), {
@@ -10817,12 +10832,12 @@
10817
10832
  const emit = __emit;
10818
10833
  const props = __props;
10819
10834
  const mForm = vue.inject("mForm");
10820
- const { dataSourceService, uiService } = vue.inject("services") || {};
10835
+ const { dataSourceService, uiService } = useServices();
10821
10836
  const eventBus = vue.inject("eventBus");
10822
- const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
10837
+ const dataSources = vue.computed(() => dataSourceService.get("dataSources"));
10823
10838
  const notEditable = vue.computed(() => formPlugin.filterFunction(mForm, props.config.notEditable, props));
10824
10839
  const hasDataSourceSidePanel = vue.computed(
10825
- () => (uiService?.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
10840
+ () => uiService.get("sideBarItems").find((item) => item.$key === SideItemKey.DATA_SOURCE)
10826
10841
  );
10827
10842
  const selectConfig = vue.computed(() => {
10828
10843
  const { type, dataSourceType, value, ...config } = props.config;
@@ -10848,7 +10863,7 @@
10848
10863
  const value = props.model[props.name];
10849
10864
  if (!value) return;
10850
10865
  const id = typeof value === "string" ? value : value.dataSourceId;
10851
- const dataSource = dataSourceService?.getDataSourceById(id);
10866
+ const dataSource = dataSourceService.getDataSourceById(id);
10852
10867
  if (!dataSource) return;
10853
10868
  eventBus?.emit("edit-data-source", id);
10854
10869
  };
@@ -10911,7 +10926,7 @@
10911
10926
  setup(__props, { emit: __emit }) {
10912
10927
  const emit = __emit;
10913
10928
  const props = __props;
10914
- const { dataSourceService } = vue.inject("services") || {};
10929
+ const { dataSourceService } = useServices();
10915
10930
  const mForm = vue.inject("mForm");
10916
10931
  const parentFields = vue.computed(() => formPlugin.filterFunction(mForm, props.config.parentFields, props) || []);
10917
10932
  const config = vue.computed(() => ({
@@ -10930,7 +10945,7 @@
10930
10945
  type: "cascader",
10931
10946
  options: () => {
10932
10947
  const [dsId, ...keys] = parentFields.value;
10933
- const ds = dataSourceService?.getDataSourceById(dsId);
10948
+ const ds = dataSourceService.getDataSourceById(dsId);
10934
10949
  if (!ds) {
10935
10950
  return [];
10936
10951
  }
@@ -10968,7 +10983,7 @@
10968
10983
  name: "value",
10969
10984
  type: (mForm2, { model }) => {
10970
10985
  const [id, ...fieldNames] = [...parentFields.value, ...model.field];
10971
- const ds = dataSourceService?.getDataSourceById(id);
10986
+ const ds = dataSourceService.getDataSourceById(id);
10972
10987
  let fields = ds?.fields || [];
10973
10988
  let type = "";
10974
10989
  (fieldNames || []).forEach((fieldName) => {
@@ -11048,11 +11063,7 @@
11048
11063
  setup(__props, { emit: __emit }) {
11049
11064
  const props = __props;
11050
11065
  const emit = __emit;
11051
- const services = vue.inject("services");
11052
- const editorService = services?.editorService;
11053
- const dataSourceService = services?.dataSourceService;
11054
- const eventsService = services?.eventsService;
11055
- const codeBlockService = services?.codeBlockService;
11066
+ const { editorService, dataSourceService, eventsService, codeBlockService } = useServices();
11056
11067
  const eventNameConfig = vue.computed(() => {
11057
11068
  const defaultEventNameConfig = {
11058
11069
  name: "name",
@@ -11068,11 +11079,10 @@
11068
11079
  valueSeparator: ".",
11069
11080
  options: (mForm, { formValue }) => {
11070
11081
  let events = [];
11071
- if (!eventsService || !dataSourceService) return events;
11072
11082
  if (props.config.src === "component") {
11073
11083
  events = eventsService.getEvent(formValue.type);
11074
11084
  if (formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
11075
- const pageFragment = editorService?.get("root")?.items?.find((page) => page.id === formValue.pageFragmentId);
11085
+ const pageFragment = editorService.get("root")?.items?.find((page) => page.id === formValue.pageFragmentId);
11076
11086
  if (pageFragment) {
11077
11087
  events = [
11078
11088
  {
@@ -11134,13 +11144,13 @@
11134
11144
  {
11135
11145
  text: "代码",
11136
11146
  label: "代码",
11137
- disabled: !Object.keys(codeBlockService?.getCodeDsl() || {}).length,
11147
+ disabled: !Object.keys(codeBlockService.getCodeDsl() || {}).length,
11138
11148
  value: core.ActionType.CODE
11139
11149
  },
11140
11150
  {
11141
11151
  text: "数据源",
11142
11152
  label: "数据源",
11143
- disabled: !dataSourceService?.get("dataSources")?.filter((ds) => ds.methods?.length || dataSourceService?.getFormMethod(ds.type).length).length,
11153
+ disabled: !dataSourceService?.get("dataSources")?.filter((ds) => ds.methods?.length || dataSourceService.getFormMethod(ds.type).length).length,
11144
11154
  value: core.ActionType.DATA_SOURCE
11145
11155
  }
11146
11156
  ]
@@ -11165,7 +11175,7 @@
11165
11175
  name: "method",
11166
11176
  text: "动作",
11167
11177
  type: (mForm, { model }) => {
11168
- const to = editorService?.getNodeById(model.to);
11178
+ const to = editorService.getNodeById(model.to);
11169
11179
  if (to && to.type === "page-fragment-container" && to.pageFragmentId) {
11170
11180
  return "cascader";
11171
11181
  }
@@ -11174,17 +11184,17 @@
11174
11184
  checkStrictly: () => props.config.src !== "component",
11175
11185
  display: (mForm, { model }) => model.actionType === core.ActionType.COMP,
11176
11186
  options: (mForm, { model }) => {
11177
- const node = editorService?.getNodeById(model.to);
11187
+ const node = editorService.getNodeById(model.to);
11178
11188
  if (!node?.type) return [];
11179
11189
  let methods = [];
11180
- methods = eventsService?.getMethod(node.type) || [];
11190
+ methods = eventsService.getMethod(node.type);
11181
11191
  if (node.type === "page-fragment-container" && node.pageFragmentId) {
11182
- const pageFragment = editorService?.get("root")?.items?.find((page) => page.id === node.pageFragmentId);
11192
+ const pageFragment = editorService.get("root")?.items?.find((page) => page.id === node.pageFragmentId);
11183
11193
  if (pageFragment) {
11184
11194
  methods = [];
11185
11195
  pageFragment.items.forEach((node2) => {
11186
11196
  utils.traverseNode(node2, (node3) => {
11187
- const nodeMethods = node3.type && eventsService?.getMethod(node3.type) || [];
11197
+ const nodeMethods = node3.type && eventsService.getMethod(node3.type) || [];
11188
11198
  if (nodeMethods.length) {
11189
11199
  methods.push({
11190
11200
  label: `${node3.name}_${node3.id}`,
@@ -11210,7 +11220,7 @@
11210
11220
  type: "code-select-col",
11211
11221
  text: "代码块",
11212
11222
  name: "codeId",
11213
- notEditable: () => !codeBlockService?.getEditStatus(),
11223
+ notEditable: () => !codeBlockService.getEditStatus(),
11214
11224
  display: (mForm, { model }) => model.actionType === core.ActionType.CODE
11215
11225
  };
11216
11226
  return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
@@ -11220,7 +11230,7 @@
11220
11230
  type: "data-source-method-select",
11221
11231
  text: "数据源方法",
11222
11232
  name: "dataSourceMethod",
11223
- notEditable: () => !services?.dataSourceService.get("editable"),
11233
+ notEditable: () => !dataSourceService.get("editable"),
11224
11234
  display: (mForm, { model }) => model.actionType === core.ActionType.DATA_SOURCE
11225
11235
  };
11226
11236
  return { ...defaultDataSourceActionConfig, ...props.config.dataSourceActionConfig };
@@ -11233,7 +11243,7 @@
11233
11243
  name: "name",
11234
11244
  label: "事件名",
11235
11245
  type: eventNameConfig.value.type,
11236
- options: (mForm, { formValue }) => eventsService?.getEvent(formValue.type).map((option) => ({
11246
+ options: (mForm, { formValue }) => eventsService.getEvent(formValue.type).map((option) => ({
11237
11247
  text: option.label,
11238
11248
  value: option.value
11239
11249
  }))
@@ -11248,9 +11258,9 @@
11248
11258
  label: "动作",
11249
11259
  type: compActionConfig.value.type,
11250
11260
  options: (mForm, { model }) => {
11251
- const node = editorService?.getNodeById(model.to);
11261
+ const node = editorService.getNodeById(model.to);
11252
11262
  if (!node?.type) return [];
11253
- return eventsService?.getMethod(node.type).map((option) => ({
11263
+ return eventsService.getMethod(node.type).map((option) => ({
11254
11264
  text: option.label,
11255
11265
  value: option.value
11256
11266
  }));
@@ -11564,11 +11574,11 @@
11564
11574
  },
11565
11575
  emits: ["change"],
11566
11576
  setup(__props, { emit: __emit }) {
11567
- const services = vue.inject("services");
11577
+ const { editorService } = useServices();
11568
11578
  const emit = __emit;
11569
11579
  const props = __props;
11570
11580
  const pageList = vue.computed(
11571
- () => services?.editorService.get("root")?.items.filter((item) => item.type === core.NodeType.PAGE_FRAGMENT)
11581
+ () => editorService.get("root")?.items.filter((item) => item.type === core.NodeType.PAGE_FRAGMENT)
11572
11582
  );
11573
11583
  const selectConfig = {
11574
11584
  type: "select",
@@ -11588,7 +11598,7 @@
11588
11598
  emit("change", props.model[props.name]);
11589
11599
  };
11590
11600
  const editPageFragment = (id) => {
11591
- services?.editorService.select(id);
11601
+ editorService.select(id);
11592
11602
  };
11593
11603
  return (_ctx, _cache) => {
11594
11604
  const _component_m_form_container = vue.resolveComponent("m-form-container");
@@ -12561,7 +12571,7 @@
12561
12571
  const _hoisted_3$3 = { class: "border-icon-container-row" };
12562
12572
  const _hoisted_4$3 = { class: "border-icon-container-row" };
12563
12573
  const _hoisted_5$1 = { class: "border-icon-container-row" };
12564
- const _hoisted_6 = { class: "border-value-container" };
12574
+ const _hoisted_6$1 = { class: "border-value-container" };
12565
12575
  const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
12566
12576
  __name: "Border",
12567
12577
  props: {
@@ -12674,7 +12684,7 @@
12674
12684
  )
12675
12685
  ])
12676
12686
  ]),
12677
- vue.createElementVNode("div", _hoisted_6, [
12687
+ vue.createElementVNode("div", _hoisted_6$1, [
12678
12688
  vue.createVNode(vue.unref(formPlugin.MContainer), {
12679
12689
  config: config.value,
12680
12690
  model: _ctx.model,
@@ -12853,13 +12863,12 @@
12853
12863
  setup(__props, { emit: __emit }) {
12854
12864
  const props = __props;
12855
12865
  const emit = __emit;
12856
- const services = vue.inject("services");
12866
+ const { editorService, uiService, stageOverlayService } = useServices();
12857
12867
  const mForm = vue.inject("mForm");
12858
12868
  const val = vue.computed(() => props.model[props.name]);
12859
12869
  const uiSelectMode = vue.ref(false);
12860
12870
  const cancelHandler = () => {
12861
- if (!services?.uiService) return;
12862
- services.uiService.set("uiSelectMode", false);
12871
+ uiService.set("uiSelectMode", false);
12863
12872
  uiSelectMode.value = false;
12864
12873
  globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
12865
12874
  };
@@ -12878,12 +12887,11 @@
12878
12887
  }
12879
12888
  };
12880
12889
  const toName = vue.computed(() => {
12881
- const config = services?.editorService.getNodeById(val.value);
12890
+ const config = editorService.getNodeById(val.value);
12882
12891
  return config?.name || "";
12883
12892
  });
12884
12893
  const startSelect = () => {
12885
- if (!services?.uiService) return;
12886
- services.uiService.set("uiSelectMode", true);
12894
+ uiService.set("uiSelectMode", true);
12887
12895
  uiSelectMode.value = true;
12888
12896
  globalThis.document.addEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
12889
12897
  };
@@ -12895,22 +12903,19 @@
12895
12903
  }
12896
12904
  };
12897
12905
  const selectNode = async (id) => {
12898
- if (!services) return;
12899
- await services.editorService.select(id);
12900
- services.editorService.get("stage")?.select(id);
12901
- services.stageOverlayService.get("stage")?.select(id);
12906
+ await editorService.select(id);
12907
+ editorService.get("stage")?.select(id);
12908
+ stageOverlayService.get("stage")?.select(id);
12902
12909
  };
12903
12910
  const highlight = throttle((id) => {
12904
- if (!services) return;
12905
- services.editorService.highlight(id);
12906
- services.editorService.get("stage")?.highlight(id);
12907
- services.stageOverlayService.get("stage")?.highlight(id);
12911
+ editorService.highlight(id);
12912
+ editorService.get("stage")?.highlight(id);
12913
+ stageOverlayService.get("stage")?.highlight(id);
12908
12914
  }, 150);
12909
12915
  const unhighlight = () => {
12910
- if (!services) return;
12911
- services.editorService.set("highlightNode", null);
12912
- services.editorService.get("stage")?.clearHighlight();
12913
- services.stageOverlayService.get("stage")?.clearHighlight();
12916
+ editorService.set("highlightNode", null);
12917
+ editorService.get("stage")?.clearHighlight();
12918
+ stageOverlayService.get("stage")?.clearHighlight();
12914
12919
  };
12915
12920
  return (_ctx, _cache) => {
12916
12921
  return uiSelectMode.value ? (vue.openBlock(), vue.createElementBlock("div", {
@@ -13260,7 +13265,7 @@
13260
13265
  },
13261
13266
  setup(__props) {
13262
13267
  const props = __props;
13263
- const services = vue.inject("services");
13268
+ const services = useServices();
13264
13269
  const disabled = vue.computed(() => {
13265
13270
  if (typeof props.data === "string") return false;
13266
13271
  if (props.data.type === "component") return false;
@@ -13279,7 +13284,7 @@
13279
13284
  });
13280
13285
  const buttonHandler = (item, event) => {
13281
13286
  if (disabled.value) return;
13282
- if (typeof item.handler === "function" && services) {
13287
+ if (typeof item.handler === "function") {
13283
13288
  item.handler?.(services, event);
13284
13289
  }
13285
13290
  };
@@ -13471,12 +13476,9 @@
13471
13476
  },
13472
13477
  __name: "AddButton",
13473
13478
  setup(__props) {
13474
- const services = vue.inject("services");
13475
- const uiService = services?.uiService;
13476
- const editorService = services?.editorService;
13477
- const showAddPageButton = vue.computed(() => uiService?.get("showAddPageButton"));
13479
+ const { editorService, uiService } = useServices();
13480
+ const showAddPageButton = vue.computed(() => uiService.get("showAddPageButton"));
13478
13481
  const addPage = (type) => {
13479
- if (!editorService) return;
13480
13482
  const root = vue.toRaw(editorService.get("root"));
13481
13483
  if (!root) throw new Error("root 不能为空");
13482
13484
  const pageConfig = {
@@ -13540,13 +13542,11 @@
13540
13542
  },
13541
13543
  setup(__props, { expose: __expose }) {
13542
13544
  const props = __props;
13543
- const services = vue.inject("services");
13544
- const editorService = services?.editorService;
13545
- const uiService = services?.uiService;
13545
+ const { editorService, uiService } = useServices();
13546
13546
  const itemsContainerEl = vue.useTemplateRef("itemsContainer");
13547
13547
  const canScroll = vue.ref(false);
13548
- const showAddPageButton = vue.computed(() => uiService?.get("showAddPageButton"));
13549
- const showPageListButton = vue.computed(() => uiService?.get("showPageListButton"));
13548
+ const showAddPageButton = vue.computed(() => uiService.get("showAddPageButton"));
13549
+ const showPageListButton = vue.computed(() => uiService.get("showPageListButton"));
13550
13550
  const itemsContainerWidth = vue.ref(0);
13551
13551
  const pageBarEl = vue.useTemplateRef("pageBar");
13552
13552
  const setCanScroll = () => {
@@ -13618,7 +13618,7 @@
13618
13618
  beforeDragList = sortable.toArray();
13619
13619
  },
13620
13620
  onUpdate: async (event) => {
13621
- await editorService?.sort(
13621
+ await editorService.sort(
13622
13622
  beforeDragList[event.oldIndex],
13623
13623
  beforeDragList[event.newIndex]
13624
13624
  );
@@ -13699,13 +13699,11 @@
13699
13699
  list: {}
13700
13700
  },
13701
13701
  setup(__props) {
13702
- const services = vue.inject("services");
13703
- const uiService = services?.uiService;
13704
- const editorService = services?.editorService;
13705
- const showPageListButton = vue.computed(() => uiService?.get("showPageListButton"));
13706
- const page = vue.computed(() => editorService?.get("page"));
13702
+ const { editorService, uiService } = useServices();
13703
+ const showPageListButton = vue.computed(() => uiService.get("showPageListButton"));
13704
+ const page = vue.computed(() => editorService.get("page"));
13707
13705
  const switchPage = async (id) => {
13708
- await editorService?.select(id);
13706
+ await editorService.select(id);
13709
13707
  };
13710
13708
  return (_ctx, _cache) => {
13711
13709
  return showPageListButton.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, [
@@ -13836,10 +13834,9 @@
13836
13834
  },
13837
13835
  setup(__props) {
13838
13836
  const props = __props;
13839
- const services = vue.inject("services");
13840
- const editorService = services?.editorService;
13841
- const root = vue.computed(() => editorService?.get("root"));
13842
- const page = vue.computed(() => editorService?.get("page"));
13837
+ const { editorService } = useServices();
13838
+ const root = vue.computed(() => editorService.get("root"));
13839
+ const page = vue.computed(() => editorService.get("page"));
13843
13840
  const query = vue.ref({
13844
13841
  pageType: [core.NodeType.PAGE, core.NodeType.PAGE_FRAGMENT],
13845
13842
  keyword: ""
@@ -13860,17 +13857,17 @@
13860
13857
  });
13861
13858
  });
13862
13859
  const switchPage = (id) => {
13863
- editorService?.select(id);
13860
+ editorService.select(id);
13864
13861
  };
13865
13862
  const copy = (node) => {
13866
- node && editorService?.copy(node);
13867
- editorService?.paste({
13863
+ node && editorService.copy(node);
13864
+ editorService.paste({
13868
13865
  left: 0,
13869
13866
  top: 0
13870
13867
  });
13871
13868
  };
13872
13869
  const remove = (node) => {
13873
- editorService?.remove(node);
13870
+ editorService.remove(node);
13874
13871
  };
13875
13872
  const pageBarScrollContainerRef = vue.useTemplateRef("pageBarScrollContainer");
13876
13873
  const pageBarItemEls = vue.useTemplateRef("pageBarItems");
@@ -14014,10 +14011,8 @@
14014
14011
  disabledPageFragment: { type: Boolean }
14015
14012
  },
14016
14013
  setup(__props) {
14017
- const services = vue.inject("services");
14014
+ const { editorService } = useServices();
14018
14015
  const clickHandler = (type) => {
14019
- const { editorService } = services || {};
14020
- if (!editorService) return;
14021
14016
  const root = vue.toRaw(editorService.get("root"));
14022
14017
  if (!root) throw new Error("root 不能为空");
14023
14018
  editorService.add({
@@ -14083,41 +14078,35 @@
14083
14078
  },
14084
14079
  setup(__props) {
14085
14080
  const codeOptions = vue.inject("codeOptions", {});
14086
- const { editorService, uiService } = vue.inject("services") || {};
14081
+ const { editorService, uiService, storageService } = useServices();
14087
14082
  const contentEl = vue.useTemplateRef("content");
14088
14083
  const splitViewRef = vue.useTemplateRef("splitView");
14089
- const root = vue.computed(() => editorService?.get("root"));
14090
- const page = vue.computed(() => editorService?.get("page"));
14091
- const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
14092
- const showSrc = vue.computed(() => uiService?.get("showSrc"));
14093
- const columnWidth = vue.computed(
14094
- () => uiService?.get("columnWidth") || {
14095
- left: 0,
14096
- center: 0,
14097
- right: 0
14098
- }
14099
- );
14084
+ const root = vue.computed(() => editorService.get("root"));
14085
+ const page = vue.computed(() => editorService.get("page"));
14086
+ const pageLength = vue.computed(() => editorService.get("pageLength") || 0);
14087
+ const showSrc = vue.computed(() => uiService.get("showSrc"));
14088
+ const columnWidth = vue.computed(() => uiService.get("columnWidth"));
14100
14089
  vue.watch(pageLength, () => {
14101
14090
  splitViewRef.value?.updateWidth();
14102
14091
  });
14103
14092
  vue.watch(
14104
- () => uiService?.get("hideSlideBar"),
14093
+ () => uiService.get("hideSlideBar"),
14105
14094
  (hideSlideBar) => {
14106
- uiService?.set("columnWidth", {
14095
+ uiService.set("columnWidth", {
14107
14096
  ...columnWidth.value,
14108
- left: hideSlideBar ? 0 : Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH
14097
+ left: hideSlideBar ? 0 : storageService.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || DEFAULT_LEFT_COLUMN_WIDTH
14109
14098
  });
14110
14099
  }
14111
14100
  );
14112
14101
  const columnWidthChange = (columnW) => {
14113
- globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.left}`);
14114
- globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${columnW.right}`);
14115
- uiService?.set("columnWidth", columnW);
14102
+ storageService.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, columnW.left, { protocol: Protocol.NUMBER });
14103
+ storageService.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, columnW.right, { protocol: Protocol.NUMBER });
14104
+ uiService.set("columnWidth", columnW);
14116
14105
  };
14117
- const frameworkRect = vue.computed(() => uiService?.get("frameworkRect"));
14106
+ const frameworkRect = vue.computed(() => uiService.get("frameworkRect"));
14118
14107
  const resizerObserver = new ResizeObserver((entries) => {
14119
14108
  const { contentRect } = entries[0];
14120
- uiService?.set("frameworkRect", {
14109
+ uiService.set("frameworkRect", {
14121
14110
  width: contentRect.width,
14122
14111
  height: contentRect.height,
14123
14112
  left: contentRect.left,
@@ -14135,7 +14124,7 @@
14135
14124
  const saveCode = (value) => {
14136
14125
  try {
14137
14126
  const parseDSL = getEditorConfig("parseDSL");
14138
- editorService?.set("root", parseDSL(value));
14127
+ editorService.set("root", parseDSL(value));
14139
14128
  } catch (e) {
14140
14129
  console.error(e);
14141
14130
  }
@@ -14164,10 +14153,10 @@
14164
14153
  "right-class": "m-editor-framework-right",
14165
14154
  left: columnWidth.value.left,
14166
14155
  right: columnWidth.value.right,
14167
- "min-left": 200,
14168
- "min-right": 300,
14169
- "min-center": 400,
14170
- width: frameworkRect.value?.width || 0,
14156
+ "min-left": vue.unref(MIN_LEFT_COLUMN_WIDTH),
14157
+ "min-right": vue.unref(MIN_RIGHT_COLUMN_WIDTH),
14158
+ "min-center": vue.unref(MIN_CENTER_COLUMN_WIDTH),
14159
+ width: frameworkRect.value.width,
14171
14160
  onChange: columnWidthChange
14172
14161
  }, vue.createSlots({
14173
14162
  left: vue.withCtx(() => [
@@ -14210,7 +14199,7 @@
14210
14199
  ]),
14211
14200
  key: "0"
14212
14201
  } : undefined
14213
- ]), 1032, ["left", "right", "width"])),
14202
+ ]), 1032, ["left", "right", "min-left", "min-right", "min-center", "width"])),
14214
14203
  vue.renderSlot(_ctx.$slots, "content-after"),
14215
14204
  vue.renderSlot(_ctx.$slots, "footer")
14216
14205
  ],
@@ -14232,13 +14221,12 @@
14232
14221
  },
14233
14222
  setup(__props) {
14234
14223
  const props = __props;
14235
- const services = vue.inject("services");
14236
- const uiService = services?.uiService;
14237
- const columnWidth = vue.computed(() => services?.uiService.get("columnWidth"));
14224
+ const { uiService, editorService, historyService } = useServices();
14225
+ const columnWidth = vue.computed(() => uiService.get("columnWidth"));
14238
14226
  const keys = Object.values(ColumnLayout);
14239
- const showGuides = vue.computed(() => uiService?.get("showGuides") ?? true);
14240
- const showRule = vue.computed(() => uiService?.get("showRule") ?? true);
14241
- const zoom = vue.computed(() => uiService?.get("zoom") ?? 1);
14227
+ const showGuides = vue.computed(() => uiService.get("showGuides"));
14228
+ const showRule = vue.computed(() => uiService.get("showRule"));
14229
+ const zoom = vue.computed(() => uiService.get("zoom"));
14242
14230
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
14243
14231
  const ctrl = isMac ? "Command" : "Ctrl";
14244
14232
  const getConfig = (item) => {
@@ -14268,10 +14256,10 @@
14268
14256
  className: "delete",
14269
14257
  icon: vue.markRaw(iconsVue.Delete),
14270
14258
  tooltip: `刪除(Delete)`,
14271
- disabled: () => services?.editorService.get("node")?.type === core.NodeType.PAGE,
14259
+ disabled: () => editorService.get("node")?.type === core.NodeType.PAGE,
14272
14260
  handler: () => {
14273
- const node = services?.editorService.get("node");
14274
- node && services?.editorService.remove(node);
14261
+ const node = editorService.get("node");
14262
+ node && editorService.remove(node);
14275
14263
  }
14276
14264
  });
14277
14265
  break;
@@ -14281,8 +14269,8 @@
14281
14269
  className: "undo",
14282
14270
  icon: vue.markRaw(iconsVue.Back),
14283
14271
  tooltip: `后退(${ctrl}+z)`,
14284
- disabled: () => !services?.historyService.state.canUndo,
14285
- handler: () => services?.editorService.undo()
14272
+ disabled: () => !historyService.state.canUndo,
14273
+ handler: () => editorService.undo()
14286
14274
  });
14287
14275
  break;
14288
14276
  case "redo":
@@ -14291,8 +14279,8 @@
14291
14279
  className: "redo",
14292
14280
  icon: vue.markRaw(iconsVue.Right),
14293
14281
  tooltip: `前进(${ctrl}+Shift+z)`,
14294
- disabled: () => !services?.historyService.state.canRedo,
14295
- handler: () => services?.editorService.redo()
14282
+ disabled: () => !historyService.state.canRedo,
14283
+ handler: () => editorService.redo()
14296
14284
  });
14297
14285
  break;
14298
14286
  case "zoom-in":
@@ -14375,7 +14363,7 @@
14375
14363
  const resizeObserver = new ResizeObserver(() => {
14376
14364
  const rect = navMenuEl.value?.getBoundingClientRect();
14377
14365
  if (rect) {
14378
- uiService?.set("navMenuRect", {
14366
+ uiService.set("navMenuRect", {
14379
14367
  left: rect.left,
14380
14368
  top: rect.top,
14381
14369
  width: rect.width,
@@ -14457,12 +14445,13 @@
14457
14445
  setup(__props, { expose: __expose, emit: __emit }) {
14458
14446
  const props = __props;
14459
14447
  const emit = __emit;
14460
- const services = vue.inject("services");
14448
+ const services = useServices();
14449
+ const { editorService, uiService } = services;
14461
14450
  const codeOptions = vue.inject("codeOptions", {});
14462
14451
  const showSrc = vue.ref(false);
14463
- const propsPanelSize = vue.computed(() => services?.uiService.get("propsPanelSize") || "small");
14452
+ const propsPanelSize = vue.computed(() => uiService.get("propsPanelSize") || "small");
14464
14453
  const { height: editorContentHeight } = useEditorContentHeight();
14465
- const stage = vue.computed(() => services?.editorService.get("stage"));
14454
+ const stage = vue.computed(() => editorService.get("stage"));
14466
14455
  const configFormRef = vue.useTemplateRef("configForm");
14467
14456
  vue.watchEffect(() => {
14468
14457
  if (configFormRef.value) {
@@ -14539,33 +14528,41 @@
14539
14528
  }
14540
14529
  });
14541
14530
 
14542
- const useStylePanel = (services) => {
14531
+ const useStylePanel = ({ uiService, storageService }, propsPanelWidth) => {
14543
14532
  const showStylePanelStorageKey = "props-panel-show-style-panel";
14544
- const showStylePanelStorageValue = services?.storageService.getItem(showStylePanelStorageKey, {
14533
+ const showStylePanelStorageValue = storageService.getItem(showStylePanelStorageKey, {
14545
14534
  protocol: Protocol.BOOLEAN
14546
14535
  });
14547
14536
  if (typeof showStylePanelStorageValue === "boolean") {
14548
- services?.uiService.set("showStylePanel", showStylePanelStorageValue);
14549
- }
14550
- const showStylePanel = vue.computed(
14551
- () => showStylePanelToggleButton.value && (services?.uiService.get("showStylePanel") ?? true)
14552
- );
14553
- const showStylePanelToggleButton = vue.computed(
14554
- () => !(services && services.uiService.get("frameworkRect").width < 1280)
14555
- );
14556
- const showStylePanelHandler = () => {
14557
- services?.uiService.set("showStylePanel", true);
14558
- services?.storageService.setItem(showStylePanelStorageKey, true, { protocol: Protocol.BOOLEAN });
14559
- };
14560
- const closeStylePanelHandler = () => {
14561
- services?.uiService.set("showStylePanel", false);
14562
- services?.storageService.setItem(showStylePanelStorageKey, false, { protocol: Protocol.BOOLEAN });
14537
+ uiService.set("showStylePanel", showStylePanelStorageValue);
14538
+ }
14539
+ const showStylePanel = vue.computed(() => showStylePanelToggleButton.value && (uiService.get("showStylePanel") ?? true));
14540
+ const showStylePanelToggleButton = vue.computed(() => uiService.get("frameworkRect").width >= 1280);
14541
+ const toggleStylePanel = (showStylePanel2) => {
14542
+ uiService.set("showStylePanel", showStylePanel2);
14543
+ storageService.setItem(showStylePanelStorageKey, showStylePanel2, { protocol: Protocol.BOOLEAN });
14544
+ const columnWidth = {
14545
+ ...uiService.get("columnWidth")
14546
+ };
14547
+ if (showStylePanel2) {
14548
+ columnWidth.right += propsPanelWidth.value;
14549
+ columnWidth.center -= propsPanelWidth.value;
14550
+ } else {
14551
+ columnWidth.right -= propsPanelWidth.value;
14552
+ columnWidth.center += propsPanelWidth.value;
14553
+ }
14554
+ if (columnWidth.center < 0) {
14555
+ columnWidth.right = columnWidth.right + columnWidth.center - MIN_CENTER_COLUMN_WIDTH;
14556
+ columnWidth.center = MIN_CENTER_COLUMN_WIDTH;
14557
+ propsPanelWidth.value = columnWidth.right / 2;
14558
+ }
14559
+ storageService.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, columnWidth.right, { protocol: Protocol.NUMBER });
14560
+ uiService.set("columnWidth", columnWidth);
14563
14561
  };
14564
14562
  return {
14565
14563
  showStylePanel,
14566
14564
  showStylePanelToggleButton,
14567
- showStylePanelHandler,
14568
- closeStylePanelHandler
14565
+ toggleStylePanel
14569
14566
  };
14570
14567
  };
14571
14568
 
@@ -14586,11 +14583,11 @@
14586
14583
  emits: ["submit-error", "form-error", "mounted"],
14587
14584
  setup(__props, { expose: __expose, emit: __emit }) {
14588
14585
  const emit = __emit;
14589
- const services = vue.inject("services");
14586
+ const { editorService, uiService, propsService, storageService } = useServices();
14590
14587
  const values = vue.ref({});
14591
14588
  const curFormConfig = vue.ref([]);
14592
- const node = vue.computed(() => services?.editorService.get("node"));
14593
- const nodes = vue.computed(() => services?.editorService.get("nodes") || []);
14589
+ const node = vue.computed(() => editorService.get("node"));
14590
+ const nodes = vue.computed(() => editorService.get("nodes"));
14594
14591
  const styleFormConfig = [
14595
14592
  {
14596
14593
  tabPosition: "right",
@@ -14603,13 +14600,13 @@
14603
14600
  return;
14604
14601
  }
14605
14602
  const type = node.value.type || (node.value.items ? "container" : "text");
14606
- curFormConfig.value = await services?.propsService.getPropsConfig(type) || [];
14603
+ curFormConfig.value = await propsService.getPropsConfig(type);
14607
14604
  values.value = node.value;
14608
14605
  };
14609
14606
  vue.watchEffect(init);
14610
- services?.propsService.on("props-configs-change", init);
14607
+ propsService.on("props-configs-change", init);
14611
14608
  vue.onBeforeUnmount(() => {
14612
- services?.propsService.off("props-configs-change", init);
14609
+ propsService.off("props-configs-change", init);
14613
14610
  });
14614
14611
  const submit = async (v, eventData) => {
14615
14612
  try {
@@ -14632,7 +14629,7 @@
14632
14629
  }
14633
14630
  });
14634
14631
  }
14635
- services?.editorService.update(newValue, { changeRecords: eventData?.changeRecords });
14632
+ editorService.update(newValue, { changeRecords: eventData?.changeRecords });
14636
14633
  } catch (e) {
14637
14634
  emit("submit-error", e);
14638
14635
  }
@@ -14646,45 +14643,36 @@
14646
14643
  }
14647
14644
  };
14648
14645
  const propsPanelEl = vue.useTemplateRef("propsPanel");
14646
+ const propsPanelWidth = vue.ref(
14647
+ storageService.getItem(PROPS_PANEL_WIDTH_STORAGE_KEY, { protocol: Protocol.NUMBER }) || 300
14648
+ );
14649
+ vue.onMounted(() => {
14650
+ propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${propsPanelWidth.value}px`);
14651
+ });
14649
14652
  const widthChange = ({ deltaX }) => {
14650
- if (!propsPanelEl.value || !services) {
14653
+ if (!propsPanelEl.value) {
14651
14654
  return;
14652
14655
  }
14653
14656
  const width = globalThis.parseFloat(
14654
14657
  getComputedStyle(propsPanelEl.value).getPropertyValue("--props-style-panel-width")
14655
14658
  );
14656
14659
  let value = width - deltaX;
14657
- if (value > services.uiService.get("columnWidth").right) {
14658
- value = services.uiService.get("columnWidth").right - 40;
14660
+ if (value > uiService.get("columnWidth").right) {
14661
+ value = uiService.get("columnWidth").right - 40;
14659
14662
  }
14660
- propsPanelEl.value.style.setProperty("--props-style-panel-width", `${value}px`);
14663
+ propsPanelWidth.value = value;
14661
14664
  };
14662
- const { showStylePanel, showStylePanelToggleButton, showStylePanelHandler, closeStylePanelHandler } = useStylePanel(services);
14663
- vue.watch(showStylePanel, (showStylePanel2) => {
14664
- if (!propsPanelEl.value || !services) {
14665
- return;
14666
- }
14667
- const columnWidth = {
14668
- ...services.uiService.get("columnWidth")
14669
- };
14670
- const width = globalThis.parseFloat(
14671
- getComputedStyle(propsPanelEl.value).getPropertyValue("--props-style-panel-width")
14672
- );
14673
- if (showStylePanel2) {
14674
- columnWidth.right += width;
14675
- columnWidth.center -= width;
14676
- } else {
14677
- columnWidth.right -= width;
14678
- columnWidth.center += width;
14679
- }
14680
- if (columnWidth.center < 0) {
14681
- columnWidth.right = columnWidth.right + columnWidth.center - 400;
14682
- columnWidth.center = 400;
14683
- propsPanelEl.value.style.setProperty("--props-style-panel-width", `${columnWidth.right / 2}px`);
14684
- }
14685
- globalThis.localStorage.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, `${columnWidth.right}`);
14686
- services.uiService.set("columnWidth", columnWidth);
14665
+ vue.watch(propsPanelWidth, (value) => {
14666
+ propsPanelEl.value?.style.setProperty("--props-style-panel-width", `${value}px`);
14667
+ storageService.setItem(PROPS_PANEL_WIDTH_STORAGE_KEY, value, { protocol: Protocol.NUMBER });
14687
14668
  });
14669
+ const { showStylePanel, showStylePanelToggleButton, toggleStylePanel } = useStylePanel(
14670
+ {
14671
+ storageService,
14672
+ uiService
14673
+ },
14674
+ propsPanelWidth
14675
+ );
14688
14676
  const propertyFormPanelRef = vue.useTemplateRef("propertyFormPanel");
14689
14677
  __expose({
14690
14678
  getFormState() {
@@ -14729,7 +14717,7 @@
14729
14717
  }, {
14730
14718
  "props-form-panel-header": vue.withCtx(() => [
14731
14719
  vue.createElementVNode("div", _hoisted_2$4, [
14732
- _cache[0] || (_cache[0] = vue.createElementVNode(
14720
+ _cache[2] || (_cache[2] = vue.createElementVNode(
14733
14721
  "span",
14734
14722
  null,
14735
14723
  "样式",
@@ -14740,14 +14728,14 @@
14740
14728
  vue.createVNode(vue.unref(designPlugin.TMagicButton), {
14741
14729
  link: "",
14742
14730
  size: "small",
14743
- onClick: vue.unref(closeStylePanelHandler)
14731
+ onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(toggleStylePanel)(false))
14744
14732
  }, {
14745
14733
  default: vue.withCtx(() => [
14746
14734
  vue.createVNode(_sfc_main$1r, { icon: vue.unref(iconsVue.Close) }, null, 8, ["icon"])
14747
14735
  ]),
14748
14736
  _: 1
14749
14737
  /* STABLE */
14750
- }, 8, ["onClick"])
14738
+ })
14751
14739
  ])
14752
14740
  ])
14753
14741
  ]),
@@ -14758,14 +14746,14 @@
14758
14746
  key: 2,
14759
14747
  class: "m-editor-props-panel-style-icon",
14760
14748
  circle: "",
14761
- onClick: vue.unref(showStylePanelHandler)
14749
+ onClick: _cache[1] || (_cache[1] = ($event) => vue.unref(toggleStylePanel)(true))
14762
14750
  }, {
14763
14751
  default: vue.withCtx(() => [
14764
14752
  vue.createVNode(_sfc_main$1r, { icon: vue.unref(iconsVue.Sugar) }, null, 8, ["icon"])
14765
14753
  ]),
14766
14754
  _: 1
14767
14755
  /* STABLE */
14768
- }, 8, ["onClick"])) : vue.createCommentVNode("v-if", true)
14756
+ })) : vue.createCommentVNode("v-if", true)
14769
14757
  ],
14770
14758
  512
14771
14759
  /* NEED_PATCH */
@@ -15047,7 +15035,7 @@
15047
15035
  const handleDragEnd = (event) => {
15048
15036
  treeEmit?.("node-dragend", event, props.data);
15049
15037
  };
15050
- const nodeContentmenuHandler = (event) => {
15038
+ const nodeContextmenuHandler = (event) => {
15051
15039
  treeEmit?.("node-contextmenu", event, props.data);
15052
15040
  };
15053
15041
  const mouseenterHandler = (event) => {
@@ -15079,7 +15067,7 @@
15079
15067
  {
15080
15068
  class: vue.normalizeClass(["tree-node", { selected: selected.value, expanded: expanded.value }]),
15081
15069
  style: vue.normalizeStyle(`padding-left: ${_ctx.indent}px`),
15082
- onContextmenu: nodeContentmenuHandler,
15070
+ onContextmenu: nodeContextmenuHandler,
15083
15071
  onMouseenter: mouseenterHandler
15084
15072
  },
15085
15073
  [
@@ -15237,13 +15225,11 @@
15237
15225
  setup(__props, { expose: __expose, emit: __emit }) {
15238
15226
  const props = __props;
15239
15227
  const emit = __emit;
15240
- const services = vue.inject("services");
15241
- const { codeBlockService, depService, editorService } = services || {};
15242
- const collecting = vue.computed(() => depService?.get("collecting"));
15228
+ const { codeBlockService, depService, editorService } = useServices();
15243
15229
  const codeList = vue.computed(
15244
- () => Object.entries(codeBlockService?.getCodeDsl() || {}).map(([codeId, code]) => {
15245
- const target = depService?.getTarget(codeId, core.DepTargetType.CODE_BLOCK);
15246
- const pageList = editorService?.get("root")?.items.map((page) => ({
15230
+ () => Object.entries(codeBlockService.getCodeDsl() || {}).map(([codeId, code]) => {
15231
+ const target = depService.getTarget(codeId, core.DepTargetType.CODE_BLOCK);
15232
+ const pageList = editorService.get("root")?.items.map((page) => ({
15247
15233
  name: page.devconfig?.tabName || page.name,
15248
15234
  type: "node",
15249
15235
  id: `${codeId}_${page.id}`,
@@ -15270,7 +15256,7 @@
15270
15256
  key: codeId,
15271
15257
  name: code.name,
15272
15258
  type: "code",
15273
- codeBlockContent: codeBlockService?.getCodeContentById(codeId),
15259
+ codeBlockContent: codeBlockService.getCodeContentById(codeId),
15274
15260
  // 只有一个页面不显示页面分类
15275
15261
  items: pageList.length > 1 ? pageList.filter((page) => page.items?.length) : pageList[0]?.items || []
15276
15262
  };
@@ -15285,10 +15271,10 @@
15285
15271
  };
15286
15272
  const { nodeStatusMap } = useNodeStatus$1(codeList);
15287
15273
  const { filterTextChangeHandler } = useFilter(codeList, nodeStatusMap, filterNode);
15288
- const editable = vue.computed(() => codeBlockService?.getEditStatus());
15274
+ const editable = vue.computed(() => codeBlockService.getEditStatus());
15289
15275
  const selectComp = (compId) => {
15290
- const stage = editorService?.get("stage");
15291
- editorService?.select(compId);
15276
+ const stage = editorService.get("stage");
15277
+ editorService.select(compId);
15292
15278
  stage?.select(compId);
15293
15279
  };
15294
15280
  const clickHandler = (event, data) => {
@@ -15302,7 +15288,7 @@
15302
15288
  const deleteCode = async (id) => {
15303
15289
  const currentCode = codeList.value.find((codeItem) => codeItem.id === id);
15304
15290
  const existBinds = Boolean(currentCode?.items?.length);
15305
- const undeleteableList = codeBlockService?.getUndeletableList() || [];
15291
+ const undeleteableList = codeBlockService.getUndeletableList() || [];
15306
15292
  if (!existBinds && !undeleteableList.includes(id)) {
15307
15293
  await designPlugin.tMagicMessageBox.confirm("确定删除该代码块吗?", "提示", {
15308
15294
  confirmButtonText: "确定",
@@ -15354,20 +15340,8 @@
15354
15340
  )
15355
15341
  ]),
15356
15342
  "tree-node-tool": vue.withCtx(({ data }) => [
15357
- collecting.value && data.type === "code" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTag), {
15358
- key: 0,
15359
- type: "info",
15360
- size: "small",
15361
- style: { "margin-right": "5px" }
15362
- }, {
15363
- default: vue.withCtx(() => _cache[0] || (_cache[0] = [
15364
- vue.createTextVNode("依赖收集中")
15365
- ])),
15366
- _: 1
15367
- /* STABLE */
15368
- })) : vue.createCommentVNode("v-if", true),
15369
15343
  data.type === "code" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
15370
- key: 1,
15344
+ key: 0,
15371
15345
  effect: "dark",
15372
15346
  content: editable.value ? "编辑" : "查看",
15373
15347
  placement: "bottom"
@@ -15385,7 +15359,7 @@
15385
15359
  data.type === "code" && editable.value ? (vue.openBlock(), vue.createBlock(
15386
15360
  vue.unref(designPlugin.TMagicTooltip),
15387
15361
  {
15388
- key: 2,
15362
+ key: 1,
15389
15363
  effect: "dark",
15390
15364
  content: "删除",
15391
15365
  placement: "bottom"
@@ -15425,7 +15399,7 @@
15425
15399
  type: "button",
15426
15400
  text: "编辑",
15427
15401
  icon: iconsVue.Edit,
15428
- display: (services) => services?.codeBlockService?.getEditStatus() ?? true,
15402
+ display: ({ codeBlockService }) => codeBlockService.getEditStatus(),
15429
15403
  handler: () => {
15430
15404
  if (!selectId) {
15431
15405
  return;
@@ -15497,8 +15471,8 @@
15497
15471
  setup(__props) {
15498
15472
  const props = __props;
15499
15473
  const eventBus = vue.inject("eventBus");
15500
- const { codeBlockService } = vue.inject("services") || {};
15501
- const editable = vue.computed(() => codeBlockService?.getEditStatus());
15474
+ const { codeBlockService } = useServices();
15475
+ const editable = vue.computed(() => codeBlockService.getEditStatus());
15502
15476
  const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
15503
15477
  const codeBlockListRef = vue.useTemplateRef("codeBlockList");
15504
15478
  const filterTextChangeHandler = (val) => {
@@ -15593,20 +15567,20 @@
15593
15567
  const dialogTitle = vue.ref("");
15594
15568
  const editDialog = vue.ref();
15595
15569
  const dataSourceValues = vue.ref({});
15596
- const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
15570
+ const editable = vue.computed(() => dataSourceService.get("editable"));
15597
15571
  const editHandler = (id) => {
15598
15572
  if (!editDialog.value) return;
15599
15573
  dataSourceValues.value = {
15600
- ...dataSourceService?.getDataSourceById(id)
15574
+ ...dataSourceService.getDataSourceById(id) || {}
15601
15575
  };
15602
15576
  dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
15603
15577
  editDialog.value.show();
15604
15578
  };
15605
15579
  const submitDataSourceHandler = (value, eventData) => {
15606
15580
  if (value.id) {
15607
- dataSourceService?.update(value, { changeRecords: eventData.changeRecords });
15581
+ dataSourceService.update(value, { changeRecords: eventData.changeRecords });
15608
15582
  } else {
15609
- dataSourceService?.add(value);
15583
+ dataSourceService.add(value);
15610
15584
  }
15611
15585
  editDialog.value?.hide();
15612
15586
  };
@@ -15641,15 +15615,15 @@
15641
15615
  const boxVisible = vue.useModel(__props, "visible");
15642
15616
  const width = vue.useModel(__props, "width");
15643
15617
  const emit = __emit;
15644
- const services = vue.inject("services");
15618
+ const { uiService, dataSourceService } = useServices();
15645
15619
  const initValues = vue.ref({});
15646
15620
  const dataSourceConfig = vue.ref([]);
15647
15621
  const { height: editorHeight } = useEditorContentHeight();
15648
15622
  const parentFloating = vue.inject("parentFloating", vue.ref(null));
15649
- const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
15623
+ const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, parentFloating);
15650
15624
  vue.watchEffect(() => {
15651
15625
  initValues.value = props.values;
15652
- dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
15626
+ dataSourceConfig.value = dataSourceService.getFormConfig(initValues.value.type);
15653
15627
  });
15654
15628
  const submitHandler = (values, data) => {
15655
15629
  emit("submit", values, data);
@@ -15708,13 +15682,12 @@
15708
15682
  emits: ["edit", "remove", "node-contextmenu"],
15709
15683
  setup(__props, { expose: __expose, emit: __emit }) {
15710
15684
  const emit = __emit;
15711
- const { depService, editorService, dataSourceService } = vue.inject("services") || {};
15712
- const collecting = vue.computed(() => depService?.get("collecting"));
15713
- const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
15714
- const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
15715
- const dsDep = vue.computed(() => depService?.getTargets(core.DepTargetType.DATA_SOURCE) || {});
15716
- const dsMethodDep = vue.computed(() => depService?.getTargets(core.DepTargetType.DATA_SOURCE_METHOD) || {});
15717
- const dsCondDep = vue.computed(() => depService?.getTargets(core.DepTargetType.DATA_SOURCE_COND) || {});
15685
+ const { depService, editorService, dataSourceService } = useServices();
15686
+ const editable = vue.computed(() => dataSourceService.get("editable"));
15687
+ const dataSources = vue.computed(() => dataSourceService.get("dataSources"));
15688
+ const dsDep = vue.computed(() => depService.getTargets(core.DepTargetType.DATA_SOURCE));
15689
+ const dsMethodDep = vue.computed(() => depService.getTargets(core.DepTargetType.DATA_SOURCE_METHOD));
15690
+ const dsCondDep = vue.computed(() => depService.getTargets(core.DepTargetType.DATA_SOURCE_COND));
15718
15691
  const getKeyTreeConfig = (dep, type, parentKey) => dep.keys.map((key) => ({
15719
15692
  name: key,
15720
15693
  id: `${parentKey}_${key}`,
@@ -15745,7 +15718,7 @@
15745
15718
  const dsDeps = dsDep.value[ds.id]?.deps || {};
15746
15719
  const dsMethodDeps = dsMethodDep.value[ds.id]?.deps || {};
15747
15720
  const dsCondDeps = dsCondDep.value[ds.id]?.deps || {};
15748
- const items = editorService?.get("root")?.items.map((page) => ({
15721
+ const items = editorService.get("root")?.items.map((page) => ({
15749
15722
  name: page.devconfig?.tabName || page.name,
15750
15723
  type: "node",
15751
15724
  id: `${ds.id}_${page.id}`,
@@ -15780,8 +15753,8 @@
15780
15753
  emit("remove", id);
15781
15754
  };
15782
15755
  const selectComp = (compId) => {
15783
- const stage = editorService?.get("stage");
15784
- editorService?.select(compId);
15756
+ const stage = editorService.get("stage");
15757
+ editorService.select(compId);
15785
15758
  stage?.select(compId);
15786
15759
  };
15787
15760
  const clickHandler = (event, data) => {
@@ -15820,20 +15793,8 @@
15820
15793
  )
15821
15794
  ]),
15822
15795
  "tree-node-tool": vue.withCtx(({ data }) => [
15823
- collecting.value && data.type === "ds" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTag), {
15824
- key: 0,
15825
- type: "info",
15826
- size: "small",
15827
- style: { "margin-right": "5px" }
15828
- }, {
15829
- default: vue.withCtx(() => _cache[0] || (_cache[0] = [
15830
- vue.createTextVNode("依赖收集中")
15831
- ])),
15832
- _: 1
15833
- /* STABLE */
15834
- })) : vue.createCommentVNode("v-if", true),
15835
15796
  data.type === "ds" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
15836
- key: 1,
15797
+ key: 0,
15837
15798
  effect: "dark",
15838
15799
  content: editable.value ? "编辑" : "查看",
15839
15800
  placement: "bottom"
@@ -15851,7 +15812,7 @@
15851
15812
  data.type === "ds" && editable.value ? (vue.openBlock(), vue.createBlock(
15852
15813
  vue.unref(designPlugin.TMagicTooltip),
15853
15814
  {
15854
- key: 2,
15815
+ key: 1,
15855
15816
  effect: "dark",
15856
15817
  content: "删除",
15857
15818
  placement: "bottom"
@@ -15888,7 +15849,7 @@
15888
15849
  type: "button",
15889
15850
  text: "编辑",
15890
15851
  icon: iconsVue.Edit,
15891
- display: (services) => services?.dataSourceService?.get("editable") ?? true,
15852
+ display: ({ dataSourceService }) => dataSourceService.get("editable"),
15892
15853
  handler: () => {
15893
15854
  if (!selectId) {
15894
15855
  return;
@@ -15958,20 +15919,20 @@
15958
15919
  setup(__props) {
15959
15920
  const props = __props;
15960
15921
  const eventBus = vue.inject("eventBus");
15961
- const { dataSourceService } = vue.inject("services") || {};
15922
+ const { dataSourceService } = useServices();
15962
15923
  const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
15963
15924
  const datasourceTypeList = vue.computed(
15964
15925
  () => [
15965
15926
  { text: "基础", type: "base" },
15966
15927
  { text: "HTTP", type: "http" }
15967
- ].concat(dataSourceService?.get("datasourceTypeList") ?? [])
15928
+ ].concat(dataSourceService.get("datasourceTypeList"))
15968
15929
  );
15969
15930
  const addHandler = (type) => {
15970
15931
  if (!editDialog.value) return;
15971
15932
  const datasourceType = datasourceTypeList.value.find((item) => item.type === type);
15972
15933
  dataSourceValues.value = mergeWith(
15973
15934
  { type, title: datasourceType?.text },
15974
- dataSourceService?.getFormValue(type) || {},
15935
+ dataSourceService.getFormValue(type),
15975
15936
  (objValue, srcValue) => {
15976
15937
  if (Array.isArray(srcValue)) {
15977
15938
  return srcValue;
@@ -15987,7 +15948,7 @@
15987
15948
  cancelButtonText: "取消",
15988
15949
  type: "warning"
15989
15950
  });
15990
- dataSourceService?.remove(id);
15951
+ dataSourceService.remove(id);
15991
15952
  };
15992
15953
  const dataSourceList = vue.ref();
15993
15954
  const filterTextChangeHandler = (val) => {
@@ -16140,67 +16101,66 @@
16140
16101
  type: "button",
16141
16102
  text: "删除",
16142
16103
  icon: iconsVue.Delete,
16143
- display: (services) => {
16144
- const node = services?.editorService?.get("node");
16104
+ display: ({ editorService }) => {
16105
+ const node = editorService.get("node");
16145
16106
  return node?.type !== core.NodeType.ROOT && !utils.isPage(node) && !utils.isPageFragment(node);
16146
16107
  },
16147
- handler: (services) => {
16148
- const nodes = services?.editorService?.get("nodes");
16149
- nodes && services?.editorService?.remove(nodes);
16108
+ handler: ({ editorService }) => {
16109
+ const nodes = editorService.get("nodes");
16110
+ nodes && editorService.remove(nodes);
16150
16111
  }
16151
16112
  });
16152
16113
  const useCopyMenu = () => ({
16153
16114
  type: "button",
16154
16115
  text: "复制",
16155
16116
  icon: vue.markRaw(iconsVue.CopyDocument),
16156
- handler: (services) => {
16157
- const nodes = services?.editorService?.get("nodes");
16158
- nodes && services?.editorService?.copy(nodes);
16117
+ handler: ({ editorService }) => {
16118
+ const nodes = editorService?.get("nodes");
16119
+ nodes && editorService?.copy(nodes);
16159
16120
  }
16160
16121
  });
16161
16122
  const usePasteMenu = (menu) => ({
16162
16123
  type: "button",
16163
16124
  text: "粘贴",
16164
16125
  icon: vue.markRaw(iconsVue.DocumentCopy),
16165
- display: (services) => !!services?.storageService?.getItem(COPY_STORAGE_KEY),
16166
- handler: (services) => {
16167
- const nodes = services?.editorService?.get("nodes");
16126
+ display: ({ storageService }) => !!storageService.getItem(COPY_STORAGE_KEY),
16127
+ handler: ({ editorService, uiService }) => {
16128
+ const nodes = editorService?.get("nodes");
16168
16129
  if (!nodes || nodes.length === 0) return;
16169
16130
  if (menu?.value?.$el) {
16170
- const stage = services?.editorService?.get("stage");
16131
+ const stage = editorService.get("stage");
16171
16132
  const rect = menu.value.$el.getBoundingClientRect();
16172
16133
  const parentRect = stage?.container?.getBoundingClientRect();
16173
- const initialLeft = utils.calcValueByFontsize(stage?.renderer?.getDocument(), (rect.left || 0) - (parentRect?.left || 0)) / services.uiService.get("zoom");
16174
- const initialTop = utils.calcValueByFontsize(stage?.renderer?.getDocument(), (rect.top || 0) - (parentRect?.top || 0)) / services.uiService.get("zoom");
16175
- services?.editorService?.paste({ left: initialLeft, top: initialTop });
16134
+ const initialLeft = utils.calcValueByFontsize(stage?.renderer?.getDocument(), (rect.left || 0) - (parentRect?.left || 0)) / uiService.get("zoom");
16135
+ const initialTop = utils.calcValueByFontsize(stage?.renderer?.getDocument(), (rect.top || 0) - (parentRect?.top || 0)) / uiService.get("zoom");
16136
+ editorService.paste({ left: initialLeft, top: initialTop });
16176
16137
  } else {
16177
- services?.editorService?.paste();
16138
+ editorService.paste();
16178
16139
  }
16179
16140
  }
16180
16141
  });
16181
- const moveTo = (id, services) => {
16182
- if (!services?.editorService) return;
16183
- const nodes = services.editorService.get("nodes") || [];
16184
- const parent = services.editorService.getNodeById(id);
16142
+ const moveTo = (id, { editorService }) => {
16143
+ const nodes = editorService.get("nodes") || [];
16144
+ const parent = editorService.getNodeById(id);
16185
16145
  if (!parent) return;
16186
- services?.editorService.add(nodes, parent);
16187
- services?.editorService.remove(nodes);
16146
+ editorService.add(nodes, parent);
16147
+ editorService.remove(nodes);
16188
16148
  };
16189
- const useMoveToMenu = (services) => {
16190
- const root = vue.computed(() => services?.editorService?.get("root"));
16149
+ const useMoveToMenu = ({ editorService }) => {
16150
+ const root = vue.computed(() => editorService.get("root"));
16191
16151
  return {
16192
16152
  type: "button",
16193
16153
  text: "移动至",
16194
- display: (services2) => {
16195
- const node = services2?.editorService?.get("node");
16196
- const pageLength = services2?.editorService?.get("pageLength") || 0;
16154
+ display: ({ editorService: editorService2 }) => {
16155
+ const node = editorService2.get("node");
16156
+ const pageLength = editorService2.get("pageLength");
16197
16157
  return !utils.isPage(node) && pageLength > 1;
16198
16158
  },
16199
- items: (root.value?.items || []).filter((page) => page.id !== services?.editorService?.get("page")?.id).map((page) => ({
16159
+ items: (root.value?.items || []).filter((page) => page.id !== editorService.get("page")?.id).map((page) => ({
16200
16160
  text: `${page.name}(${page.id})`,
16201
16161
  type: "button",
16202
- handler: (services2) => {
16203
- moveTo(page.id, services2);
16162
+ handler: (services) => {
16163
+ moveTo(page.id, services);
16204
16164
  }
16205
16165
  }))
16206
16166
  };
@@ -16219,17 +16179,18 @@
16219
16179
  setup(__props, { expose: __expose, emit: __emit }) {
16220
16180
  const props = __props;
16221
16181
  const emit = __emit;
16222
- const services = vue.inject("services");
16182
+ const services = useServices();
16183
+ const { editorService, componentListService } = services;
16223
16184
  const menuRef = vue.useTemplateRef("menu");
16224
- const node = vue.computed(() => services?.editorService.get("node"));
16225
- const nodes = vue.computed(() => services?.editorService.get("nodes"));
16226
- const componentList = vue.computed(() => services?.componentListService.getList() || []);
16185
+ const node = vue.computed(() => editorService.get("node"));
16186
+ const nodes = vue.computed(() => editorService.get("nodes"));
16187
+ const componentList = vue.computed(() => componentListService.getList());
16227
16188
  const createMenuItems = (group) => group.items.map((component) => ({
16228
16189
  text: component.text,
16229
16190
  type: "button",
16230
16191
  icon: component.icon,
16231
16192
  handler: () => {
16232
- services?.editorService.add({
16193
+ editorService.add({
16233
16194
  name: component.text,
16234
16195
  type: component.type,
16235
16196
  ...component.data || {}
@@ -16244,7 +16205,7 @@
16244
16205
  type: "button",
16245
16206
  icon: iconsVue.Files,
16246
16207
  handler: () => {
16247
- services?.editorService.add({
16208
+ editorService.add({
16248
16209
  type: "tab-pane"
16249
16210
  });
16250
16211
  }
@@ -16318,10 +16279,8 @@
16318
16279
  },
16319
16280
  setup(__props) {
16320
16281
  const props = __props;
16321
- const services = vue.inject("services");
16322
- const editorService = services?.editorService;
16282
+ const { editorService } = useServices();
16323
16283
  const setNodeVisible = (visible) => {
16324
- if (!editorService) return;
16325
16284
  editorService.update({
16326
16285
  id: props.data.id,
16327
16286
  visible
@@ -16352,8 +16311,8 @@
16352
16311
  }
16353
16312
  });
16354
16313
 
16355
- const useClick = (services, isCtrlKeyDown, nodeStatusMap, menuRef) => {
16356
- const isMultiSelect = vue.computed(() => isCtrlKeyDown.value && !services?.editorService.get("disabledMultiSelect"));
16314
+ const useClick = ({ editorService, stageOverlayService, uiService }, isCtrlKeyDown, nodeStatusMap, menuRef) => {
16315
+ const isMultiSelect = vue.computed(() => isCtrlKeyDown.value && !editorService.get("disabledMultiSelect"));
16357
16316
  const select = async (data) => {
16358
16317
  if (!data.id) {
16359
16318
  throw new Error("没有id");
@@ -16361,16 +16320,16 @@
16361
16320
  if (isMultiSelect.value) {
16362
16321
  multiSelect(data);
16363
16322
  } else {
16364
- await services?.editorService.select(data);
16365
- services?.editorService.get("stage")?.select(data.id);
16366
- services?.stageOverlayService.get("stage")?.select(data.id);
16323
+ await editorService.select(data);
16324
+ editorService.get("stage")?.select(data.id);
16325
+ stageOverlayService.get("stage")?.select(data.id);
16367
16326
  }
16368
16327
  };
16369
16328
  const multiSelect = async (data) => {
16370
16329
  if (utils.isPage(data) || utils.isPageFragment(data)) {
16371
16330
  return;
16372
16331
  }
16373
- const nodes = services?.editorService.get("nodes") || [];
16332
+ const nodes = editorService.get("nodes") || [];
16374
16333
  const newNodes = [];
16375
16334
  let isCancel = false;
16376
16335
  nodes.forEach((node) => {
@@ -16386,9 +16345,9 @@
16386
16345
  if (!isCancel || newNodes.length === 0) {
16387
16346
  newNodes.push(data.id);
16388
16347
  }
16389
- await services?.editorService.multiSelect(newNodes);
16390
- services?.editorService.get("stage")?.multiSelect(newNodes);
16391
- services?.stageOverlayService.get("stage")?.multiSelect(newNodes);
16348
+ await editorService.multiSelect(newNodes);
16349
+ editorService.get("stage")?.multiSelect(newNodes);
16350
+ stageOverlayService.get("stage")?.multiSelect(newNodes);
16392
16351
  };
16393
16352
  const throttleTime = 300;
16394
16353
  const highlightHandler = throttle(
@@ -16398,13 +16357,13 @@
16398
16357
  throttleTime
16399
16358
  );
16400
16359
  const highlight = (data) => {
16401
- services?.editorService?.highlight(data);
16402
- services?.editorService?.get("stage")?.highlight(data.id);
16403
- services?.stageOverlayService?.get("stage")?.highlight(data.id);
16360
+ editorService.highlight(data);
16361
+ editorService.get("stage")?.highlight(data.id);
16362
+ stageOverlayService.get("stage")?.highlight(data.id);
16404
16363
  };
16405
16364
  const nodeClickHandler = (event, data) => {
16406
16365
  if (!nodeStatusMap?.value) return;
16407
- if (services?.uiService.get("uiSelectMode")) {
16366
+ if (uiService.get("uiSelectMode")) {
16408
16367
  document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: data }));
16409
16368
  return;
16410
16369
  }
@@ -16422,7 +16381,7 @@
16422
16381
  nodeClickHandler,
16423
16382
  nodeContentMenuHandler(event, data) {
16424
16383
  event.preventDefault();
16425
- const nodes = services?.editorService.get("nodes") || [];
16384
+ const nodes = editorService.get("nodes") || [];
16426
16385
  if (nodes.length < 2 || !nodes.includes(data)) {
16427
16386
  nodeClickHandler(event, data);
16428
16387
  }
@@ -16453,7 +16412,7 @@
16453
16412
  });
16454
16413
  });
16455
16414
  };
16456
- const useDrag = (services) => {
16415
+ const useDrag = ({ editorService }) => {
16457
16416
  const handleDragStart = (event) => {
16458
16417
  if (!event.dataTransfer || !event.target || !event.currentTarget) return;
16459
16418
  const targetEl = getNodeEl(event.target);
@@ -16527,11 +16486,11 @@
16527
16486
  const targetEl = getNodeEl(event.target);
16528
16487
  if (!targetEl || targetEl !== event.currentTarget) return;
16529
16488
  removeStatusClass(dragState.container);
16530
- if (node && dragState.dragOverNodeId && dragState.dropType && services) {
16489
+ if (node && dragState.dragOverNodeId && dragState.dropType) {
16531
16490
  if (dragState.dragOverNodeId === node.id) {
16532
16491
  return;
16533
16492
  }
16534
- const targetInfo = services.editorService.getNodeInfo(dragState.dragOverNodeId, false);
16493
+ const targetInfo = editorService.getNodeInfo(dragState.dragOverNodeId, false);
16535
16494
  const targetNode = targetInfo.node;
16536
16495
  let targetParent = targetInfo.parent;
16537
16496
  if (!targetParent || !targetNode) return;
@@ -16545,11 +16504,11 @@
16545
16504
  if (dragState.dropType === "after") {
16546
16505
  targetIndex += 1;
16547
16506
  }
16548
- const selectedNodes = services.editorService.get("nodes");
16507
+ const selectedNodes = editorService.get("nodes");
16549
16508
  if (selectedNodes.find((n) => `${n.id}` === `${node.id}`)) {
16550
- services.editorService.dragTo(selectedNodes, targetParent, targetIndex);
16509
+ editorService.dragTo(selectedNodes, targetParent, targetIndex);
16551
16510
  } else {
16552
- services.editorService.dragTo([node], targetParent, targetIndex);
16511
+ editorService.dragTo([node], targetParent, targetIndex);
16553
16512
  }
16554
16513
  }
16555
16514
  dragState.dragOverNodeId = "";
@@ -16688,19 +16647,18 @@
16688
16647
  }
16689
16648
  ];
16690
16649
 
16691
- const useKeybinding = (services, container) => {
16692
- const keybindingService = services?.keybindingService;
16650
+ const useKeybinding = ({ keybindingService }, container) => {
16693
16651
  const isCtrlKeyDown = vue.ref(false);
16694
16652
  const windowBlurHandler = () => {
16695
16653
  isCtrlKeyDown.value = false;
16696
16654
  };
16697
- keybindingService?.registerCommand("layer-panel-global-keyup", () => {
16655
+ keybindingService.registerCommand("layer-panel-global-keyup", () => {
16698
16656
  isCtrlKeyDown.value = false;
16699
16657
  });
16700
- keybindingService?.registerCommand("layer-panel-global-keydown", () => {
16658
+ keybindingService.registerCommand("layer-panel-global-keydown", () => {
16701
16659
  isCtrlKeyDown.value = true;
16702
16660
  });
16703
- keybindingService?.register([
16661
+ keybindingService.register([
16704
16662
  {
16705
16663
  command: "layer-panel-global-keydown",
16706
16664
  keybinding: "ctrl",
@@ -16715,10 +16673,10 @@
16715
16673
  vue.watchEffect(() => {
16716
16674
  if (container.value) {
16717
16675
  globalThis.addEventListener("blur", windowBlurHandler);
16718
- keybindingService?.registerEl(KeyBindingContainerKey.LAYER_PANEL, container.value.$el);
16676
+ keybindingService.registerEl(KeyBindingContainerKey.LAYER_PANEL, container.value.$el);
16719
16677
  } else {
16720
16678
  globalThis.removeEventListener("blur", windowBlurHandler);
16721
- keybindingService?.unregisterEl(KeyBindingContainerKey.LAYER_PANEL);
16679
+ keybindingService.unregisterEl(KeyBindingContainerKey.LAYER_PANEL);
16722
16680
  }
16723
16681
  });
16724
16682
  return {
@@ -16749,9 +16707,9 @@
16749
16707
  );
16750
16708
  return map;
16751
16709
  };
16752
- const useNodeStatus = (services) => {
16753
- const page = vue.computed(() => services?.editorService.get("page"));
16754
- const nodes = vue.computed(() => services?.editorService.get("nodes") || []);
16710
+ const useNodeStatus = ({ editorService }) => {
16711
+ const page = vue.computed(() => editorService.get("page"));
16712
+ const nodes = vue.computed(() => editorService.get("nodes"));
16755
16713
  const nodeStatusMaps = vue.ref(/* @__PURE__ */ new Map());
16756
16714
  const nodeStatusMap = vue.computed(
16757
16715
  () => page.value ? nodeStatusMaps.value.get(page.value.id) : /* @__PURE__ */ new Map()
@@ -16787,7 +16745,7 @@
16787
16745
  immediate: true
16788
16746
  }
16789
16747
  );
16790
- services?.editorService.on("add", (newNodes) => {
16748
+ const addHandler = (newNodes) => {
16791
16749
  newNodes.forEach((node) => {
16792
16750
  if (utils.isPage(node) || utils.isPageFragment(node)) return;
16793
16751
  utils.traverseNode(node, (node2) => {
@@ -16799,13 +16757,19 @@
16799
16757
  });
16800
16758
  });
16801
16759
  });
16802
- });
16803
- services?.editorService.on("remove", (nodes2) => {
16760
+ };
16761
+ editorService.on("add", addHandler);
16762
+ const removeHandler = (nodes2) => {
16804
16763
  nodes2.forEach((node) => {
16805
16764
  utils.traverseNode(node, (node2) => {
16806
16765
  nodeStatusMap.value?.delete(node2.id);
16807
16766
  });
16808
16767
  });
16768
+ };
16769
+ editorService.on("remove", removeHandler);
16770
+ vue.onBeforeUnmount(() => {
16771
+ editorService.off("remove", removeHandler);
16772
+ editorService.off("add", addHandler);
16809
16773
  });
16810
16774
  return {
16811
16775
  nodeStatusMaps,
@@ -16825,10 +16789,10 @@
16825
16789
  customContentMenu: { type: Function }
16826
16790
  },
16827
16791
  setup(__props) {
16828
- const services = vue.inject("services");
16829
- const editorService = services?.editorService;
16792
+ const services = useServices();
16793
+ const { editorService } = services;
16830
16794
  const treeRef = vue.useTemplateRef("tree");
16831
- const page = vue.computed(() => editorService?.get("page"));
16795
+ const page = vue.computed(() => editorService.get("page"));
16832
16796
  const nodeData = vue.computed(() => !page.value ? [] : [page.value]);
16833
16797
  const { nodeStatusMap } = useNodeStatus(services);
16834
16798
  const { isCtrlKeyDown } = useKeybinding(services, treeRef);
@@ -16922,11 +16886,11 @@
16922
16886
  const filterTextChangeHandler = (v) => {
16923
16887
  searchText.value = v;
16924
16888
  };
16925
- const services = vue.inject("services");
16889
+ const { editorService, componentListService } = useServices();
16926
16890
  const stageOptions = vue.inject("stageOptions");
16927
- const stage = vue.computed(() => services?.editorService.get("stage"));
16891
+ const stage = vue.computed(() => editorService.get("stage"));
16928
16892
  const list = vue.computed(
16929
- () => (services?.componentListService.getList() || []).map((group) => ({
16893
+ () => componentListService.getList().map((group) => ({
16930
16894
  ...group,
16931
16895
  items: group.items.filter((item) => item.text.includes(searchText.value))
16932
16896
  }))
@@ -16938,7 +16902,7 @@
16938
16902
  let clientX;
16939
16903
  let clientY;
16940
16904
  const appendComponent = ({ text, type, data = {} }) => {
16941
- services?.editorService.add({
16905
+ editorService.add({
16942
16906
  name: text,
16943
16907
  type,
16944
16908
  ...data
@@ -17085,7 +17049,11 @@
17085
17049
  key: 1,
17086
17050
  class: "magic-editor-tab-panel-title"
17087
17051
  };
17088
- const _hoisted_5 = { class: "m-editor-slide-list-box" };
17052
+ const _hoisted_5 = {
17053
+ key: 0,
17054
+ class: "m-editor-sidebar-tips"
17055
+ };
17056
+ const _hoisted_6 = { class: "m-editor-slide-list-box" };
17089
17057
  const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
17090
17058
  ...{
17091
17059
  name: "MEditorSidebar"
@@ -17104,9 +17072,11 @@
17104
17072
  },
17105
17073
  setup(__props, { expose: __expose }) {
17106
17074
  const props = __props;
17107
- const services = vue.inject("services");
17108
- const collecting = vue.computed(() => services?.depService.get("collecting"));
17109
- const columnLeftWidth = vue.computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
17075
+ const { depService, uiService } = useServices();
17076
+ const collecting = vue.computed(() => depService.get("collecting"));
17077
+ const taskLength = vue.computed(() => depService.get("taskLength"));
17078
+ const tipsBarVisible = vue.ref(true);
17079
+ const columnLeftWidth = vue.computed(() => uiService.get("columnWidth")[ColumnLayout.LEFT]);
17110
17080
  const { height: editorContentHeight } = useEditorContentHeight();
17111
17081
  const columnLeftHeight = vue.ref(0);
17112
17082
  const unWatchEditorContentHeight = vue.watch(
@@ -17181,7 +17151,7 @@
17181
17151
  vue.watch(
17182
17152
  sideBarItems,
17183
17153
  (items) => {
17184
- services?.uiService.set("sideBarItems", items);
17154
+ uiService.set("sideBarItems", items);
17185
17155
  },
17186
17156
  {
17187
17157
  immediate: true
@@ -17205,10 +17175,10 @@
17205
17175
  const nextSlideBarItem = sideBarItems.value.find((sideBarItem) => !showingBoxKeys.value.includes(sideBarItem.$key));
17206
17176
  if (!nextSlideBarItem) {
17207
17177
  activeTabName.value = "";
17208
- services?.uiService.set("hideSlideBar", true);
17178
+ uiService.set("hideSlideBar", true);
17209
17179
  return;
17210
17180
  }
17211
- services?.uiService.set("hideSlideBar", false);
17181
+ uiService.set("hideSlideBar", false);
17212
17182
  activeTabName.value = nextSlideBarItem?.text;
17213
17183
  }
17214
17184
  );
@@ -17415,7 +17385,21 @@
17415
17385
  }),
17416
17386
  128
17417
17387
  /* KEYED_FRAGMENT */
17418
- ))
17388
+ )),
17389
+ tipsBarVisible.value && collecting.value && taskLength.value > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
17390
+ vue.createElementVNode(
17391
+ "span",
17392
+ null,
17393
+ "依赖收集中(剩余任务:" + vue.toDisplayString(taskLength.value) + ")",
17394
+ 1
17395
+ /* TEXT */
17396
+ ),
17397
+ vue.createVNode(_sfc_main$1r, {
17398
+ icon: vue.unref(iconsVue.Close),
17399
+ class: "close-icon",
17400
+ onClick: _cache[1] || (_cache[1] = vue.withModifiers(($event) => tipsBarVisible.value = false, ["stop"]))
17401
+ }, null, 8, ["icon"])
17402
+ ])) : vue.createCommentVNode("v-if", true)
17419
17403
  ])) : vue.createCommentVNode("v-if", true),
17420
17404
  (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
17421
17405
  (vue.openBlock(true), vue.createElementBlock(
@@ -17431,7 +17415,7 @@
17431
17415
  visible: vue.unref(floatBoxStates)[config.$key].status,
17432
17416
  "onUpdate:visible": ($event) => vue.unref(floatBoxStates)[config.$key].status = $event,
17433
17417
  height: columnLeftHeight.value,
17434
- "onUpdate:height": _cache[1] || (_cache[1] = ($event) => columnLeftHeight.value = $event),
17418
+ "onUpdate:height": _cache[2] || (_cache[2] = ($event) => columnLeftHeight.value = $event),
17435
17419
  width: columnLeftWidth.value,
17436
17420
  title: config.text,
17437
17421
  position: {
@@ -17440,7 +17424,7 @@
17440
17424
  }
17441
17425
  }, {
17442
17426
  body: vue.withCtx(() => [
17443
- vue.createElementVNode("div", _hoisted_5, [
17427
+ vue.createElementVNode("div", _hoisted_6, [
17444
17428
  config && vue.unref(floatBoxStates)[config.$key].status ? (vue.openBlock(), vue.createBlock(
17445
17429
  vue.resolveDynamicComponent(config.component),
17446
17430
  vue.mergeProps({
@@ -17688,15 +17672,15 @@
17688
17672
  const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
17689
17673
  __name: "NodeListMenu",
17690
17674
  setup(__props) {
17691
- const services = vue.inject("services");
17692
- const editorService = services?.editorService;
17675
+ const services = useServices();
17676
+ const { editorService } = services;
17693
17677
  const visible = vue.ref(false);
17694
17678
  const buttonVisible = vue.ref(false);
17695
17679
  const buttonEl = vue.useTemplateRef("button");
17696
17680
  const boxRef = vue.useTemplateRef("box");
17697
- const stage = vue.computed(() => editorService?.get("stage"));
17698
- const page = vue.computed(() => editorService?.get("page"));
17699
- const nodes = vue.computed(() => editorService?.get("nodes") || []);
17681
+ const stage = vue.computed(() => editorService.get("stage"));
17682
+ const page = vue.computed(() => editorService.get("page"));
17683
+ const nodes = vue.computed(() => editorService.get("nodes"));
17700
17684
  const nodeData = vue.computed(() => !page.value ? [] : [page.value]);
17701
17685
  const { nodeStatusMap } = useNodeStatus(services);
17702
17686
  const filterNodeMethod = (value, data) => data.id === value;
@@ -17730,7 +17714,7 @@
17730
17714
  }
17731
17715
  );
17732
17716
  const clickHandler = async (event, data) => {
17733
- await editorService?.select(data.id);
17717
+ await editorService.select(data.id);
17734
17718
  stage.value?.select(data.id);
17735
17719
  };
17736
17720
  const menuPosition = vue.ref({
@@ -17804,13 +17788,13 @@
17804
17788
  const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
17805
17789
  __name: "StageOverlay",
17806
17790
  setup(__props) {
17807
- const services = vue.inject("services");
17791
+ const { stageOverlayService, editorService } = useServices();
17808
17792
  const stageOptions = vue.inject("stageOptions");
17809
17793
  const stageOverlayEl = vue.useTemplateRef("stageOverlay");
17810
- const stageOverlayVisible = vue.computed(() => services?.stageOverlayService.get("stageOverlayVisible"));
17811
- const wrapWidth = vue.computed(() => services?.stageOverlayService.get("wrapWidth") || 0);
17812
- const wrapHeight = vue.computed(() => services?.stageOverlayService.get("wrapHeight") || 0);
17813
- const stage = vue.computed(() => services?.editorService.get("stage"));
17794
+ const stageOverlayVisible = vue.computed(() => stageOverlayService.get("stageOverlayVisible"));
17795
+ const wrapWidth = vue.computed(() => stageOverlayService.get("wrapWidth"));
17796
+ const wrapHeight = vue.computed(() => stageOverlayService.get("wrapHeight"));
17797
+ const stage = vue.computed(() => editorService.get("stage"));
17814
17798
  const style = vue.computed(() => ({
17815
17799
  width: `${wrapWidth.value}px`,
17816
17800
  height: `${wrapHeight.value}px`
@@ -17819,31 +17803,30 @@
17819
17803
  if (stage2) {
17820
17804
  stage2.on("dblclick", async (event) => {
17821
17805
  const el = await stage2.actionManager?.getElementFromPoint(event) || null;
17822
- services?.stageOverlayService.openOverlay(el);
17806
+ stageOverlayService.openOverlay(el);
17823
17807
  });
17824
17808
  } else {
17825
- services?.stageOverlayService.closeOverlay();
17809
+ stageOverlayService.closeOverlay();
17826
17810
  }
17827
17811
  });
17828
17812
  vue.watch(stageOverlayEl, (stageOverlay) => {
17829
- if (!services) return;
17830
- const subStage = services.stageOverlayService.createStage(stageOptions);
17831
- services?.stageOverlayService.set("stage", subStage);
17813
+ const subStage = stageOverlayService.createStage(stageOptions);
17814
+ stageOverlayService.set("stage", subStage);
17832
17815
  if (stageOverlay && subStage) {
17833
17816
  subStage.mount(stageOverlay);
17834
17817
  const { mask, renderer } = subStage;
17835
17818
  const { contentWindow } = renderer;
17836
17819
  mask?.showRule(false);
17837
- services?.stageOverlayService.updateOverlay();
17820
+ stageOverlayService.updateOverlay();
17838
17821
  contentWindow?.magic.onRuntimeReady({});
17839
17822
  }
17840
17823
  });
17841
17824
  vue.onBeforeUnmount(() => {
17842
- services?.stageOverlayService.get("stage")?.destroy();
17843
- services?.stageOverlayService.set("stage", null);
17825
+ stageOverlayService.get("stage")?.destroy();
17826
+ stageOverlayService.set("stage", null);
17844
17827
  });
17845
17828
  const closeOverlayHandler = () => {
17846
- services?.stageOverlayService.closeOverlay();
17829
+ stageOverlayService.closeOverlay();
17847
17830
  };
17848
17831
  return (_ctx, _cache) => {
17849
17832
  return stageOverlayVisible.value ? (vue.openBlock(), vue.createElementBlock("div", {
@@ -17949,13 +17932,13 @@
17949
17932
  },
17950
17933
  setup(__props, { expose: __expose }) {
17951
17934
  const props = __props;
17952
- const services = vue.inject("services");
17953
- const editorService = services?.editorService;
17935
+ const services = useServices();
17936
+ const { editorService } = services;
17954
17937
  const menuRef = vue.useTemplateRef("menu");
17955
17938
  const canCenter = vue.ref(false);
17956
- const node = vue.computed(() => editorService?.get("node"));
17957
- const nodes = vue.computed(() => editorService?.get("nodes"));
17958
- const parent = vue.computed(() => editorService?.get("parent"));
17939
+ const node = vue.computed(() => editorService.get("node"));
17940
+ const nodes = vue.computed(() => editorService.get("nodes"));
17941
+ const parent = vue.computed(() => editorService.get("parent"));
17959
17942
  const menuData = vue.computed(
17960
17943
  () => props.customContentMenu(
17961
17944
  [
@@ -17966,7 +17949,7 @@
17966
17949
  display: () => canCenter.value,
17967
17950
  handler: () => {
17968
17951
  if (!nodes.value) return;
17969
- editorService?.alignCenter(nodes.value);
17952
+ editorService.alignCenter(nodes.value);
17970
17953
  }
17971
17954
  },
17972
17955
  useCopyMenu(),
@@ -17985,7 +17968,7 @@
17985
17968
  icon: vue.markRaw(iconsVue.Top),
17986
17969
  display: () => !utils.isPage(node.value) && !utils.isPageFragment(node.value) && !props.isMultiSelect,
17987
17970
  handler: () => {
17988
- editorService?.moveLayer(1);
17971
+ editorService.moveLayer(1);
17989
17972
  }
17990
17973
  },
17991
17974
  {
@@ -17994,7 +17977,7 @@
17994
17977
  icon: vue.markRaw(iconsVue.Bottom),
17995
17978
  display: () => !utils.isPage(node.value) && !utils.isPageFragment(node.value) && !props.isMultiSelect,
17996
17979
  handler: () => {
17997
- editorService?.moveLayer(-1);
17980
+ editorService.moveLayer(-1);
17998
17981
  }
17999
17982
  },
18000
17983
  {
@@ -18003,7 +17986,7 @@
18003
17986
  icon: vue.markRaw(iconsVue.Top),
18004
17987
  display: () => !utils.isPage(node.value) && !utils.isPageFragment(node.value) && !props.isMultiSelect,
18005
17988
  handler: () => {
18006
- editorService?.moveLayer(LayerOffset.TOP);
17989
+ editorService.moveLayer(LayerOffset.TOP);
18007
17990
  }
18008
17991
  },
18009
17992
  {
@@ -18012,7 +17995,7 @@
18012
17995
  icon: vue.markRaw(iconsVue.Bottom),
18013
17996
  display: () => !utils.isPage(node.value) && !utils.isPageFragment(node.value) && !props.isMultiSelect,
18014
17997
  handler: () => {
18015
- editorService?.moveLayer(LayerOffset.BOTTOM);
17998
+ editorService.moveLayer(LayerOffset.BOTTOM);
18016
17999
  }
18017
18000
  },
18018
18001
  useMoveToMenu(services),
@@ -18030,7 +18013,7 @@
18030
18013
  type: "button",
18031
18014
  text: "清空参考线",
18032
18015
  handler: () => {
18033
- editorService?.get("stage")?.clearGuides();
18016
+ editorService.get("stage")?.clearGuides();
18034
18017
  }
18035
18018
  },
18036
18019
  ...props.stageContentMenu
@@ -18041,7 +18024,7 @@
18041
18024
  vue.watch(
18042
18025
  parent,
18043
18026
  async () => {
18044
- if (!parent.value || !editorService) return canCenter.value = false;
18027
+ if (!parent.value) return canCenter.value = false;
18045
18028
  const layout = await editorService.getLayout(parent.value);
18046
18029
  const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
18047
18030
  const isTypeConform = nodes.value?.every(
@@ -18079,19 +18062,19 @@
18079
18062
  const props = __props;
18080
18063
  let stage = null;
18081
18064
  let runtime = null;
18082
- const services = vue.inject("services");
18083
- const stageLoading = vue.computed(() => services?.editorService.get("stageLoading") || false);
18065
+ const { editorService, uiService, keybindingService } = useServices();
18066
+ const stageLoading = vue.computed(() => editorService.get("stageLoading"));
18084
18067
  const stageWrapRef = vue.useTemplateRef("stageWrap");
18085
18068
  const stageContainerEl = vue.useTemplateRef("stageContainer");
18086
18069
  const menuRef = vue.useTemplateRef("menu");
18087
- const nodes = vue.computed(() => services?.editorService.get("nodes") || []);
18070
+ const nodes = vue.computed(() => editorService.get("nodes"));
18088
18071
  const isMultiSelect = vue.computed(() => nodes.value.length > 1);
18089
- const stageRect = vue.computed(() => services?.uiService.get("stageRect"));
18090
- const stageContainerRect = vue.computed(() => services?.uiService.get("stageContainerRect"));
18091
- const root = vue.computed(() => services?.editorService.get("root"));
18092
- const page = vue.computed(() => services?.editorService.get("page"));
18093
- const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
18094
- const node = vue.computed(() => services?.editorService.get("node"));
18072
+ const stageRect = vue.computed(() => uiService.get("stageRect"));
18073
+ const stageContainerRect = vue.computed(() => uiService.get("stageContainerRect"));
18074
+ const root = vue.computed(() => editorService.get("root"));
18075
+ const page = vue.computed(() => editorService.get("page"));
18076
+ const zoom = vue.computed(() => uiService.get("zoom"));
18077
+ const node = vue.computed(() => editorService.get("node"));
18095
18078
  vue.watchEffect(() => {
18096
18079
  if (stage || !page.value) return;
18097
18080
  if (!stageContainerEl.value) return;
@@ -18100,7 +18083,7 @@
18100
18083
  stage.on("select", () => {
18101
18084
  stageWrapRef.value?.container?.focus();
18102
18085
  });
18103
- services?.editorService.set("stage", vue.markRaw(stage));
18086
+ editorService.set("stage", vue.markRaw(stage));
18104
18087
  stage.mount(stageContainerEl.value);
18105
18088
  if (!node.value?.id) {
18106
18089
  return;
@@ -18116,7 +18099,7 @@
18116
18099
  });
18117
18100
  vue.onBeforeUnmount(() => {
18118
18101
  stage?.destroy();
18119
- services?.editorService.set("stage", null);
18102
+ editorService.set("stage", null);
18120
18103
  });
18121
18104
  vue.watch(zoom, (zoom2) => {
18122
18105
  if (!stage || !zoom2) return;
@@ -18125,12 +18108,12 @@
18125
18108
  let timeoutId = null;
18126
18109
  vue.watch(page, (page2) => {
18127
18110
  if (runtime && page2) {
18128
- services?.editorService.set("stageLoading", true);
18111
+ editorService.set("stageLoading", true);
18129
18112
  if (timeoutId) {
18130
18113
  globalThis.clearTimeout(timeoutId);
18131
18114
  }
18132
18115
  timeoutId = globalThis.setTimeout(() => {
18133
- services?.editorService.set("stageLoading", false);
18116
+ editorService.set("stageLoading", false);
18134
18117
  timeoutId = null;
18135
18118
  }, 3e3);
18136
18119
  runtime.updatePageId?.(page2.id);
@@ -18144,10 +18127,10 @@
18144
18127
  runtime.updateRootConfig?.(cloneDeep(vue.toRaw(root2)));
18145
18128
  }
18146
18129
  };
18147
- services?.editorService.on("root-change", rootChangeHandler);
18130
+ editorService.on("root-change", rootChangeHandler);
18148
18131
  const resizeObserver = new ResizeObserver((entries) => {
18149
18132
  for (const { contentRect } of entries) {
18150
- services?.uiService.set("stageContainerRect", {
18133
+ uiService.set("stageContainerRect", {
18151
18134
  width: contentRect.width,
18152
18135
  height: contentRect.height
18153
18136
  });
@@ -18156,15 +18139,15 @@
18156
18139
  vue.onMounted(() => {
18157
18140
  if (stageWrapRef.value?.container) {
18158
18141
  resizeObserver.observe(stageWrapRef.value.container);
18159
- services?.keybindingService.registerEl(KeyBindingContainerKey.STAGE, stageWrapRef.value.container);
18142
+ keybindingService.registerEl(KeyBindingContainerKey.STAGE, stageWrapRef.value.container);
18160
18143
  }
18161
18144
  });
18162
18145
  vue.onBeforeUnmount(() => {
18163
18146
  stage?.destroy();
18164
18147
  resizeObserver.disconnect();
18165
- services?.editorService.set("stage", null);
18166
- services?.keybindingService.unregisterEl("stage");
18167
- services?.editorService.off("root-change", rootChangeHandler);
18148
+ editorService.set("stage", null);
18149
+ keybindingService.unregisterEl("stage");
18150
+ editorService.off("root-change", rootChangeHandler);
18168
18151
  });
18169
18152
  const parseDSL = getEditorConfig("parseDSL");
18170
18153
  const contextmenuHandler = (e) => {
@@ -18190,10 +18173,10 @@
18190
18173
  let parent = page.value;
18191
18174
  const parentId = utils.getIdFromEl()(parentEl);
18192
18175
  if (parentId) {
18193
- parent = services?.editorService.getNodeById(parentId, false);
18176
+ parent = editorService.getNodeById(parentId, false);
18194
18177
  }
18195
18178
  if (parent && stageContainerEl.value && stage) {
18196
- const layout = await services?.editorService.getLayout(parent);
18179
+ const layout = await editorService.getLayout(parent);
18197
18180
  const containerRect = stageContainerEl.value.getBoundingClientRect();
18198
18181
  const { scrollTop, scrollLeft } = stage.mask;
18199
18182
  const { style = {} } = config.data;
@@ -18221,7 +18204,7 @@
18221
18204
  left: utils.calcValueByFontsize(doc, left / zoom.value)
18222
18205
  };
18223
18206
  config.data.inputEvent = e;
18224
- services?.editorService.add(config.data, parent);
18207
+ editorService.add(config.data, parent);
18225
18208
  }
18226
18209
  };
18227
18210
  return (_ctx, _cache) => {
@@ -18290,15 +18273,14 @@
18290
18273
  },
18291
18274
  __name: "Breadcrumb",
18292
18275
  setup(__props) {
18293
- const services = vue.inject("services");
18294
- const editorService = services?.editorService;
18295
- const node = vue.computed(() => editorService?.get("node"));
18296
- const nodes = vue.computed(() => editorService?.get("nodes") || []);
18297
- const root = vue.computed(() => editorService?.get("root"));
18276
+ const { editorService } = useServices();
18277
+ const node = vue.computed(() => editorService.get("node"));
18278
+ const nodes = vue.computed(() => editorService.get("nodes"));
18279
+ const root = vue.computed(() => editorService.get("root"));
18298
18280
  const path = vue.computed(() => utils.getNodePath(node.value?.id || "", root.value?.items || []));
18299
18281
  const select = async (node2) => {
18300
- await editorService?.select(node2);
18301
- editorService?.get("stage")?.select(node2.id);
18282
+ await editorService.select(node2);
18283
+ editorService.get("stage")?.select(node2.id);
18302
18284
  };
18303
18285
  return (_ctx, _cache) => {
18304
18286
  return nodes.value.length === 1 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
@@ -18354,8 +18336,8 @@
18354
18336
  },
18355
18337
  setup(__props) {
18356
18338
  const stageOptions = vue.inject("stageOptions");
18357
- const services = vue.inject("services");
18358
- const page = vue.computed(() => services?.editorService.get("page"));
18339
+ const { editorService } = useServices();
18340
+ const page = vue.computed(() => editorService.get("page"));
18359
18341
  return (_ctx, _cache) => {
18360
18342
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
18361
18343
  vue.createVNode(_sfc_main$2),
@@ -18800,12 +18782,22 @@
18800
18782
  }
18801
18783
  const dataSourceService = new DataSource();
18802
18784
 
18803
- const idleTask = new IdleTask();
18804
18785
  class Dep extends BaseService {
18805
18786
  state = vue.shallowReactive({
18806
- collecting: false
18787
+ collecting: false,
18788
+ taskLength: 0
18807
18789
  });
18790
+ idleTask = new IdleTask();
18808
18791
  watcher = new core.Watcher({ initialTargets: vue.reactive({}) });
18792
+ constructor() {
18793
+ super();
18794
+ this.idleTask.on(
18795
+ "update-task-length",
18796
+ throttle(({ length }) => {
18797
+ this.set("taskLength", length);
18798
+ }, 1e3)
18799
+ );
18800
+ }
18809
18801
  set(name, value) {
18810
18802
  this.state[name] = value;
18811
18803
  }
@@ -18860,11 +18852,11 @@
18860
18852
  resolve();
18861
18853
  return;
18862
18854
  }
18863
- idleTask.once("finish", () => {
18855
+ this.idleTask.once("finish", () => {
18864
18856
  this.emit("collected", nodes, deep);
18865
18857
  this.set("collecting", false);
18866
18858
  });
18867
- idleTask.once("hight-level-finish", () => {
18859
+ this.idleTask.once("hight-level-finish", () => {
18868
18860
  this.emit("ds-collected", nodes, deep);
18869
18861
  resolve();
18870
18862
  });
@@ -18895,7 +18887,7 @@
18895
18887
  return this.watcher.hasSpecifiedTypeTarget(type);
18896
18888
  }
18897
18889
  clearIdleTasks() {
18898
- idleTask.clearTasks();
18890
+ this.idleTask.clearTasks();
18899
18891
  }
18900
18892
  on(eventName, listener) {
18901
18893
  return super.on(eventName, listener);
@@ -18904,8 +18896,8 @@
18904
18896
  return super.once(eventName, listener);
18905
18897
  }
18906
18898
  reset() {
18907
- idleTask.removeAllListeners();
18908
- idleTask.clearTasks();
18899
+ this.idleTask.removeAllListeners();
18900
+ this.idleTask.clearTasks();
18909
18901
  for (const type of Object.keys(this.watcher.getTargetsList())) {
18910
18902
  this.removeTargets(type);
18911
18903
  }
@@ -18915,12 +18907,13 @@
18915
18907
  this.removeAllListeners();
18916
18908
  this.reset();
18917
18909
  this.removeAllPlugins();
18910
+ this.idleTask.removeAllListeners();
18918
18911
  }
18919
18912
  emit(eventName, ...args) {
18920
18913
  return super.emit(eventName, ...args);
18921
18914
  }
18922
18915
  enqueueTask(node, target, depExtendedData, deep) {
18923
- idleTask.enqueueTask(
18916
+ this.idleTask.enqueueTask(
18924
18917
  ({ node: node2, deep: deep2, target: target2 }) => {
18925
18918
  this.collectNode(node2, target2, depExtendedData, deep2);
18926
18919
  },
@@ -20136,6 +20129,8 @@
20136
20129
  exports.ComponentListPanel = _sfc_main$b;
20137
20130
  exports.CondOpSelect = _sfc_main$1k;
20138
20131
  exports.ContentMenu = _sfc_main$o;
20132
+ exports.DEFAULT_LEFT_COLUMN_WIDTH = DEFAULT_LEFT_COLUMN_WIDTH;
20133
+ exports.DEFAULT_RIGHT_COLUMN_WIDTH = DEFAULT_RIGHT_COLUMN_WIDTH;
20139
20134
  exports.DataSourceConfigPanel = _sfc_main$i;
20140
20135
  exports.DataSourceFieldSelect = _sfc_main$1g;
20141
20136
  exports.DataSourceFields = _sfc_main$1i;
@@ -20155,13 +20150,19 @@
20155
20150
  exports.KeyBindingCommand = KeyBindingCommand;
20156
20151
  exports.KeyValue = _sfc_main$16;
20157
20152
  exports.Keys = Keys;
20153
+ exports.LEFT_COLUMN_WIDTH_STORAGE_KEY = LEFT_COLUMN_WIDTH_STORAGE_KEY;
20158
20154
  exports.LayerOffset = LayerOffset;
20159
20155
  exports.LayerPanel = _sfc_main$c;
20160
20156
  exports.Layout = Layout;
20161
20157
  exports.LayoutContainer = _sfc_main$A;
20158
+ exports.MIN_CENTER_COLUMN_WIDTH = MIN_CENTER_COLUMN_WIDTH;
20159
+ exports.MIN_LEFT_COLUMN_WIDTH = MIN_LEFT_COLUMN_WIDTH;
20160
+ exports.MIN_RIGHT_COLUMN_WIDTH = MIN_RIGHT_COLUMN_WIDTH;
20161
+ exports.PROPS_PANEL_WIDTH_STORAGE_KEY = PROPS_PANEL_WIDTH_STORAGE_KEY;
20162
20162
  exports.PageFragmentSelect = _sfc_main$15;
20163
20163
  exports.PropsFormPanel = _sfc_main$q;
20164
20164
  exports.PropsPanel = _sfc_main$p;
20165
+ exports.RIGHT_COLUMN_WIDTH_STORAGE_KEY = RIGHT_COLUMN_WIDTH_STORAGE_KEY;
20165
20166
  exports.Resizer = _sfc_main$B;
20166
20167
  exports.ScrollViewer = ScrollViewer;
20167
20168
  exports.SideItemKey = SideItemKey;
@@ -20234,6 +20235,7 @@
20234
20235
  exports.useGetSo = useGetSo;
20235
20236
  exports.useNextFloatBoxPosition = useNextFloatBoxPosition;
20236
20237
  exports.useNodeStatus = useNodeStatus$1;
20238
+ exports.useServices = useServices;
20237
20239
  exports.useStage = useStage;
20238
20240
  exports.useWindowRect = useWindowRect;
20239
20241
  exports.warn = warn;