@tmagic/editor 1.3.0-beta.4 → 1.3.0-beta.6

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 (34) hide show
  1. package/dist/style.css +4 -4
  2. package/dist/tmagic-editor.js +301 -195
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +301 -193
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +11 -10
  7. package/src/components/Icon.vue +5 -1
  8. package/src/fields/CodeSelectCol.vue +1 -2
  9. package/src/fields/DataSourceMethodSelect.vue +0 -3
  10. package/src/fields/EventSelect.vue +4 -5
  11. package/src/fields/KeyValue.vue +1 -0
  12. package/src/fields/UISelect.vue +3 -3
  13. package/src/hooks/use-stage.ts +7 -2
  14. package/src/layouts/CodeEditor.vue +1 -0
  15. package/src/layouts/sidebar/ComponentListPanel.vue +4 -3
  16. package/src/layouts/sidebar/layer/LayerNode.vue +7 -5
  17. package/src/layouts/sidebar/layer/LayerPanel.vue +4 -2
  18. package/src/layouts/sidebar/layer/use-keybinding.ts +11 -8
  19. package/src/layouts/sidebar/layer/use-node-status.ts +9 -5
  20. package/src/layouts/workspace/viewer/Stage.vue +2 -1
  21. package/src/services/dataSource.ts +2 -2
  22. package/src/theme/event.scss +1 -3
  23. package/src/theme/framework.scss +0 -2
  24. package/src/theme/layer-panel.scss +4 -0
  25. package/src/type.ts +19 -0
  26. package/src/utils/data-source/index.ts +117 -34
  27. package/src/utils/keybinding-config.ts +31 -26
  28. package/src/utils/props.ts +1 -0
  29. package/types/layouts/CodeEditor.vue.d.ts +4 -1
  30. package/types/layouts/sidebar/layer/LayerNode.vue.d.ts +1 -1
  31. package/types/layouts/sidebar/layer/use-keybinding.d.ts +3 -2
  32. package/types/type.d.ts +18 -0
  33. package/types/utils/data-source/index.d.ts +1 -0
  34. package/types/utils/keybinding-config.d.ts +4 -0
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watch, onMounted, onUnmounted, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, Fragment, createTextVNode, createCommentVNode, toRaw, resolveDynamicComponent, nextTick, mergeProps, toDisplayString, renderList, watchEffect, withModifiers, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, withDirectives, vShow, createStaticVNode, Transition, onBeforeUnmount, provide, toHandlers, mergeDefaults } from 'vue';
1
+ import { defineComponent, ref, watch, onMounted, onUnmounted, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, Fragment, createTextVNode, createCommentVNode, toRaw, resolveDynamicComponent, nextTick, mergeProps, toDisplayString, renderList, watchEffect, withModifiers, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, withDirectives, vShow, createStaticVNode, Transition, provide, toHandlers, mergeDefaults } from 'vue';
2
2
  import { FullScreen, Edit, View, Coin, Delete, Plus, Close, ArrowDown, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Aim, CopyDocument, DocumentCopy, Files, Hide, ArrowRight, Goods, List, EditPen, Top, Bottom, ArrowLeftBold, ArrowRightBold, CaretBottom } from '@element-plus/icons-vue';
3
3
  import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, map, has, pick, keys } from 'lodash-es';
4
4
  import * as monaco from 'monaco-editor';
@@ -29,7 +29,7 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
29
29
  },
30
30
  __name: "CodeEditor",
31
31
  props: {
32
- initValues: {},
32
+ initValues: { default: "" },
33
33
  modifiedValues: {},
34
34
  type: {},
35
35
  language: { default: "javascript" },
@@ -777,47 +777,72 @@ const fillConfig$1 = (config) => [
777
777
  ...BaseFormConfig(),
778
778
  ...config,
779
779
  {
780
- type: "panel",
781
- title: "数据定义",
780
+ type: "tab",
782
781
  items: [
783
782
  {
784
- name: "fields",
785
- type: "data-source-fields",
786
- defaultValue: () => []
787
- }
788
- ]
789
- },
790
- {
791
- type: "panel",
792
- title: "方法定义",
793
- items: [
783
+ title: "数据定义",
784
+ items: [
785
+ {
786
+ name: "fields",
787
+ type: "data-source-fields",
788
+ defaultValue: () => []
789
+ }
790
+ ]
791
+ },
794
792
  {
795
- name: "methods",
796
- type: "data-source-methods",
797
- defaultValue: () => []
798
- }
799
- ]
800
- },
801
- {
802
- type: "panel",
803
- title: "事件配置",
804
- display: false,
805
- items: [
793
+ title: "方法定义",
794
+ items: [
795
+ {
796
+ name: "methods",
797
+ type: "data-source-methods",
798
+ defaultValue: () => []
799
+ }
800
+ ]
801
+ },
806
802
  {
807
- name: "events",
808
- src: "datasource",
809
- type: "event-select"
810
- }
811
- ]
812
- },
813
- {
814
- type: "panel",
815
- title: "mock数据",
816
- items: [
803
+ title: "事件配置",
804
+ display: false,
805
+ items: [
806
+ {
807
+ name: "events",
808
+ src: "datasource",
809
+ type: "event-select"
810
+ }
811
+ ]
812
+ },
817
813
  {
818
- name: "mocks",
819
- type: "data-source-mocks",
820
- defaultValue: () => []
814
+ title: "mock数据",
815
+ items: [
816
+ {
817
+ name: "mocks",
818
+ type: "data-source-mocks",
819
+ defaultValue: () => []
820
+ }
821
+ ]
822
+ },
823
+ {
824
+ title: "请求参数裁剪",
825
+ display: (formState, { model }) => model.type === "http",
826
+ items: [
827
+ {
828
+ name: "beforeRequest",
829
+ type: "vs-code",
830
+ parse: true,
831
+ height: "600px"
832
+ }
833
+ ]
834
+ },
835
+ {
836
+ title: "响应数据裁剪",
837
+ display: (formState, { model }) => model.type === "http",
838
+ items: [
839
+ {
840
+ name: "afterResponse",
841
+ type: "vs-code",
842
+ parse: true,
843
+ height: "600px"
844
+ }
845
+ ]
821
846
  }
822
847
  ]
823
848
  }
@@ -832,6 +857,62 @@ const getFormConfig = (type, configs) => {
832
857
  return fillConfig$1(configs[type] || []);
833
858
  }
834
859
  };
860
+ const getFormValue = (type, values) => {
861
+ if (type !== "http") {
862
+ return values;
863
+ }
864
+ return {
865
+ beforeRequest: `(options, context) => {
866
+ /**
867
+ * 用户可以直接编写函数,在原始接口调用之前,会运行该函数,将这个函数的返回值作为该数据源接口的入参
868
+ *
869
+ * options: HttpOptions
870
+ *
871
+ * interface HttpOptions {
872
+ * // 请求链接
873
+ * url: string;
874
+ * // query参数
875
+ * params?: Record<string, string>;
876
+ * // body数据
877
+ * data?: Record<string, any>;
878
+ * // 请求头
879
+ * headers?: Record<string, string>;
880
+ * // 请求方法 GET/POST
881
+ * method?: Method;
882
+ * }
883
+ *
884
+ * context:上下文对象
885
+ *
886
+ * interface Content {
887
+ * app: AppCore;
888
+ * dataSource: HttpDataSource;
889
+ * }
890
+ *
891
+ * return: HttpOptions
892
+ */
893
+
894
+ // 此处的返回值会作为这个接口的入参
895
+ return options;
896
+ }`,
897
+ afterResponse: `(response, context) => {
898
+ /**
899
+ * 用户可以直接编写函数,在原始接口返回之后,会运行该函数,将这个函数的返回值作为该数据源接口的返回
900
+
901
+ * context:上下文对象
902
+ *
903
+ * interface Content {
904
+ * app: AppCore;
905
+ * dataSource: HttpDataSource;
906
+ * }
907
+ *
908
+ */
909
+
910
+ // 此处的返回值会作为这个接口的返回值
911
+ return response;
912
+ }`,
913
+ ...values
914
+ };
915
+ };
835
916
  const getDisplayField = (dataSources, key) => {
836
917
  const displayState = [];
837
918
  const matches = key.matchAll(/\$\{([\s\S]+?)\}/g);
@@ -1017,7 +1098,7 @@ class DataSource extends BaseService {
1017
1098
  this.get("configs")[type] = config;
1018
1099
  }
1019
1100
  getFormValue(type = "base") {
1020
- return this.get("values")[type];
1101
+ return getFormValue(type, this.get("values")[type]);
1021
1102
  }
1022
1103
  setFormValue(type, value) {
1023
1104
  this.get("values")[type] = value;
@@ -1251,6 +1332,7 @@ const eventTabConfig = {
1251
1332
  {
1252
1333
  name: "events",
1253
1334
  src: "component",
1335
+ labelWidth: "100px",
1254
1336
  type: "event-select"
1255
1337
  }
1256
1338
  ]
@@ -1481,6 +1563,7 @@ var DragType = /* @__PURE__ */ ((DragType2) => {
1481
1563
  DragType2["LAYER_TREE"] = "layer-tree";
1482
1564
  return DragType2;
1483
1565
  })(DragType || {});
1566
+ const UI_SELECT_MODE_EVENT_NAME = "ui-select";
1484
1567
 
1485
1568
  const COPY_STORAGE_KEY = "$MagicEditorCopyData";
1486
1569
  const getPageList = (app) => {
@@ -2931,6 +3014,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
2931
3014
  icon: {}
2932
3015
  },
2933
3016
  setup(__props) {
3017
+ const isRelativePath = (str) => /^(\.|(\.\.)?\/)/.test(str);
2934
3018
  return (_ctx, _cache) => {
2935
3019
  return !_ctx.icon ? (openBlock(), createBlock(unref(TMagicIcon), {
2936
3020
  key: 0,
@@ -2940,7 +3024,7 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
2940
3024
  createVNode(unref(Edit))
2941
3025
  ]),
2942
3026
  _: 1
2943
- })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createBlock(unref(TMagicIcon), {
3027
+ })) : typeof _ctx.icon === "string" && (_ctx.icon.startsWith("http") || isRelativePath(_ctx.icon)) ? (openBlock(), createBlock(unref(TMagicIcon), {
2944
3028
  key: 1,
2945
3029
  class: "magic-editor-icon"
2946
3030
  }, {
@@ -3068,9 +3152,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
3068
3152
  );
3069
3153
  const selectConfig = {
3070
3154
  type: "select",
3071
- text: "代码块",
3072
3155
  name: props.name,
3073
- labelWidth: "80px",
3074
3156
  options: () => {
3075
3157
  if (codeDsl.value) {
3076
3158
  return map(codeDsl.value, (value, key) => ({
@@ -3104,8 +3186,9 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
3104
3186
  class: "select",
3105
3187
  config: selectConfig,
3106
3188
  model: _ctx.model,
3189
+ size: _ctx.size,
3107
3190
  onChange: onParamsChangeHandler
3108
- }, null, 8, ["model"]),
3191
+ }, null, 8, ["model", "size"]),
3109
3192
  _ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$M, {
3110
3193
  key: 0,
3111
3194
  class: "icon",
@@ -3924,7 +4007,6 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
3924
4007
  if (!paramStatements)
3925
4008
  return [];
3926
4009
  return paramStatements.map((paramState) => ({
3927
- labelWidth: "100px",
3928
4010
  text: paramState.name,
3929
4011
  ...paramState
3930
4012
  }));
@@ -3953,9 +4035,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
3953
4035
  );
3954
4036
  const cascaderConfig = computed(() => ({
3955
4037
  type: "cascader",
3956
- text: "数据源方法",
3957
4038
  name: props.name,
3958
- labelWidth: "80px",
3959
4039
  options: methodsOptions.value,
3960
4040
  onChange: (formState, dataSourceMethod) => {
3961
4041
  setParamsConfig(dataSourceMethod, formState);
@@ -4361,7 +4441,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4361
4441
  const defaultActionTypeConfig = {
4362
4442
  name: "actionType",
4363
4443
  text: "联动类型",
4364
- labelWidth: "80px",
4365
4444
  type: "select",
4366
4445
  defaultValue: ActionType.COMP,
4367
4446
  options: () => [
@@ -4390,7 +4469,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4390
4469
  const defaultTargetCompConfig = {
4391
4470
  name: "to",
4392
4471
  text: "联动组件",
4393
- labelWidth: "80px",
4394
4472
  type: "ui-select",
4395
4473
  display: (mForm, { model }) => model.actionType === ActionType.COMP
4396
4474
  };
@@ -4400,7 +4478,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4400
4478
  const defaultCompActionConfig = {
4401
4479
  name: "method",
4402
4480
  text: "动作",
4403
- labelWidth: "80px",
4404
4481
  type: "select",
4405
4482
  display: (mForm, { model }) => model.actionType === ActionType.COMP,
4406
4483
  options: (mForm, { model }) => {
@@ -4418,7 +4495,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4418
4495
  const codeActionConfig = computed(() => {
4419
4496
  const defaultCodeActionConfig = {
4420
4497
  type: "code-select-col",
4421
- labelWidth: 0,
4498
+ text: "代码块",
4422
4499
  name: "codeId",
4423
4500
  disabled: () => !codeBlockService?.getEditStatus(),
4424
4501
  display: (mForm, { model }) => model.actionType === ActionType.CODE
@@ -4428,8 +4505,8 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4428
4505
  const dataSourceActionConfig = computed(() => {
4429
4506
  const defaultDataSourceActionConfig = {
4430
4507
  type: "data-source-method-select",
4508
+ text: "数据源方法",
4431
4509
  name: "dataSourceMethod",
4432
- labelWidth: 0,
4433
4510
  display: (mForm, { model }) => model.actionType === ActionType.DATA_SOURCE
4434
4511
  };
4435
4512
  return { ...defaultDataSourceActionConfig, ...props.config.dataSourceActionConfig };
@@ -4475,6 +4552,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4475
4552
  name: "actions",
4476
4553
  expandAll: true,
4477
4554
  enableToggleMode: false,
4555
+ titlePrefix: "动作",
4478
4556
  items: [
4479
4557
  actionTypeConfig.value,
4480
4558
  targetCompConfig.value,
@@ -4544,6 +4622,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4544
4622
  size: _ctx.size,
4545
4623
  config: actionsConfig.value,
4546
4624
  model: cardItem,
4625
+ "label-width": _ctx.config.labelWidth || "100px",
4547
4626
  onChange: onChangeHandler
4548
4627
  }, {
4549
4628
  header: withCtx(() => [
@@ -4565,7 +4644,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4565
4644
  }, null, 8, ["icon", "disabled", "size", "onClick"])
4566
4645
  ]),
4567
4646
  _: 2
4568
- }, 1032, ["disabled", "size", "config", "model"]);
4647
+ }, 1032, ["disabled", "size", "config", "model", "label-width"]);
4569
4648
  }), 128))
4570
4649
  ]))
4571
4650
  ]);
@@ -4618,6 +4697,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
4618
4697
  };
4619
4698
  const deleteHandler = (index) => {
4620
4699
  records.value.splice(index, 1);
4700
+ emit("change", getValue());
4621
4701
  };
4622
4702
  return (_ctx, _cache) => {
4623
4703
  return openBlock(), createElementBlock("div", _hoisted_1$m, [
@@ -4706,7 +4786,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
4706
4786
  return;
4707
4787
  services.uiService.set("uiSelectMode", false);
4708
4788
  uiSelectMode.value = false;
4709
- globalThis.document.removeEventListener("ui-select", clickHandler);
4789
+ globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
4710
4790
  };
4711
4791
  const clickHandler = ({ detail }) => {
4712
4792
  if (detail.id) {
@@ -4727,7 +4807,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
4727
4807
  return;
4728
4808
  services.uiService.set("uiSelectMode", true);
4729
4809
  uiSelectMode.value = true;
4730
- globalThis.document.addEventListener("ui-select", clickHandler);
4810
+ globalThis.document.addEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
4731
4811
  };
4732
4812
  const deleteHandler = () => {
4733
4813
  if (props.model) {
@@ -6885,7 +6965,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
6885
6965
  if (!nodeStatusMap?.value)
6886
6966
  return;
6887
6967
  if (uiService?.get("uiSelectMode")) {
6888
- document.dispatchEvent(new CustomEvent("ui-select", { detail: props.data }));
6968
+ document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: props.data }));
6889
6969
  return;
6890
6970
  }
6891
6971
  if (hasChilren.value && !props.isCtrlKeyDown) {
@@ -6899,7 +6979,10 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
6899
6979
  };
6900
6980
  const contextmenuHandler = (event) => {
6901
6981
  event.preventDefault();
6902
- nodeClickHandler();
6982
+ const nodes = editorService?.get("nodes") || [];
6983
+ if (nodes.length < 2 || !nodes.includes(props.data)) {
6984
+ nodeClickHandler();
6985
+ }
6903
6986
  emit("node-contextmenu", event, props.data);
6904
6987
  };
6905
6988
  const nodeContentmenuHandler = (event, node) => {
@@ -7004,7 +7087,131 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
7004
7087
  }
7005
7088
  });
7006
7089
 
7007
- const useKeybinding = (services) => {
7090
+ var KeyBindingContainerKey = /* @__PURE__ */ ((KeyBindingContainerKey2) => {
7091
+ KeyBindingContainerKey2["STAGE"] = "stage";
7092
+ KeyBindingContainerKey2["LAYER_PANEL"] = "layer-panel";
7093
+ return KeyBindingContainerKey2;
7094
+ })(KeyBindingContainerKey || {});
7095
+ const keybindingConfig = [
7096
+ {
7097
+ command: KeyBindingCommand.DELETE_NODE,
7098
+ keybinding: ["delete", "backspace"],
7099
+ when: [
7100
+ ["stage" /* STAGE */, "keyup"],
7101
+ ["layer-panel" /* LAYER_PANEL */, "keydown"]
7102
+ ]
7103
+ },
7104
+ {
7105
+ command: KeyBindingCommand.COPY_NODE,
7106
+ keybinding: "ctrl+c",
7107
+ when: [
7108
+ ["stage" /* STAGE */, "keydown"],
7109
+ ["layer-panel" /* LAYER_PANEL */, "keydown"]
7110
+ ]
7111
+ },
7112
+ {
7113
+ command: KeyBindingCommand.PASTE_NODE,
7114
+ keybinding: "ctrl+v",
7115
+ when: [
7116
+ ["stage" /* STAGE */, "keydown"],
7117
+ ["layer-panel" /* LAYER_PANEL */, "keydown"]
7118
+ ]
7119
+ },
7120
+ {
7121
+ command: KeyBindingCommand.CUT_NODE,
7122
+ keybinding: "ctrl+x",
7123
+ when: [
7124
+ ["stage" /* STAGE */, "keydown"],
7125
+ ["layer-panel" /* LAYER_PANEL */, "keydown"]
7126
+ ]
7127
+ },
7128
+ {
7129
+ command: KeyBindingCommand.UNDO,
7130
+ keybinding: "ctrl+z",
7131
+ when: [
7132
+ ["stage" /* STAGE */, "keydown"],
7133
+ ["layer-panel" /* LAYER_PANEL */, "keydown"]
7134
+ ]
7135
+ },
7136
+ {
7137
+ command: KeyBindingCommand.REDO,
7138
+ keybinding: "ctrl+shift+z",
7139
+ when: [
7140
+ ["stage" /* STAGE */, "keydown"],
7141
+ ["layer-panel" /* LAYER_PANEL */, "keydown"]
7142
+ ]
7143
+ },
7144
+ {
7145
+ command: KeyBindingCommand.MOVE_UP_1,
7146
+ keybinding: "up",
7147
+ when: [["stage" /* STAGE */, "keydown"]]
7148
+ },
7149
+ {
7150
+ command: KeyBindingCommand.MOVE_DOWN_1,
7151
+ keybinding: "down",
7152
+ when: [["stage" /* STAGE */, "keydown"]]
7153
+ },
7154
+ {
7155
+ command: KeyBindingCommand.MOVE_LEFT_1,
7156
+ keybinding: "left",
7157
+ when: [["stage" /* STAGE */, "keydown"]]
7158
+ },
7159
+ {
7160
+ command: KeyBindingCommand.MOVE_RIGHT_1,
7161
+ keybinding: "right",
7162
+ when: [["stage" /* STAGE */, "keydown"]]
7163
+ },
7164
+ {
7165
+ command: KeyBindingCommand.MOVE_UP_10,
7166
+ keybinding: "ctrl+up",
7167
+ when: [["stage" /* STAGE */, "keydown"]]
7168
+ },
7169
+ {
7170
+ command: KeyBindingCommand.MOVE_DOWN_10,
7171
+ keybinding: "ctrl+down",
7172
+ when: [["stage" /* STAGE */, "keydown"]]
7173
+ },
7174
+ {
7175
+ command: KeyBindingCommand.MOVE_LEFT_10,
7176
+ keybinding: "ctrl+left",
7177
+ when: [["stage" /* STAGE */, "keydown"]]
7178
+ },
7179
+ {
7180
+ command: KeyBindingCommand.MOVE_RIGHT_10,
7181
+ keybinding: "ctrl+right",
7182
+ when: [["stage" /* STAGE */, "keydown"]]
7183
+ },
7184
+ {
7185
+ command: KeyBindingCommand.SWITCH_NODE,
7186
+ keybinding: "tab",
7187
+ when: [
7188
+ ["stage" /* STAGE */, "keydown"],
7189
+ ["layer-panel" /* LAYER_PANEL */, "keydown"]
7190
+ ]
7191
+ },
7192
+ {
7193
+ command: KeyBindingCommand.ZOOM_IN,
7194
+ keybinding: ["ctrl+=", "ctrl+numpadplus"],
7195
+ when: [["stage" /* STAGE */, "keydown"]]
7196
+ },
7197
+ {
7198
+ command: KeyBindingCommand.ZOOM_OUT,
7199
+ keybinding: ["ctrl+-", "ctrl+numpad-"],
7200
+ when: [["stage" /* STAGE */, "keydown"]]
7201
+ },
7202
+ {
7203
+ command: KeyBindingCommand.ZOOM_FIT,
7204
+ keybinding: "ctrl+0",
7205
+ when: [["stage" /* STAGE */, "keydown"]]
7206
+ },
7207
+ {
7208
+ command: KeyBindingCommand.ZOOM_RESET,
7209
+ keybinding: "ctrl+1",
7210
+ when: [["stage" /* STAGE */, "keydown"]]
7211
+ }
7212
+ ];
7213
+
7214
+ const useKeybinding = (services, contianer) => {
7008
7215
  const keybindingService = services?.keybindingService;
7009
7216
  const isCtrlKeyDown = ref(false);
7010
7217
  const windowBlurHandler = () => {
@@ -7028,11 +7235,14 @@ const useKeybinding = (services) => {
7028
7235
  when: [["global", "keyup"]]
7029
7236
  }
7030
7237
  ]);
7031
- onMounted(() => {
7032
- globalThis.addEventListener("blur", windowBlurHandler);
7033
- });
7034
- onBeforeUnmount(() => {
7035
- globalThis.removeEventListener("blur", windowBlurHandler);
7238
+ watchEffect(() => {
7239
+ if (contianer.value) {
7240
+ globalThis.addEventListener("blur", windowBlurHandler);
7241
+ keybindingService?.registeEl(KeyBindingContainerKey.LAYER_PANEL, contianer.value);
7242
+ } else {
7243
+ globalThis.removeEventListener("blur", windowBlurHandler);
7244
+ keybindingService?.unregisteEl(KeyBindingContainerKey.LAYER_PANEL);
7245
+ }
7036
7246
  });
7037
7247
  return {
7038
7248
  isCtrlKeyDown
@@ -7097,16 +7307,20 @@ const useNodeStatus = (services, page) => {
7097
7307
  );
7098
7308
  services?.editorService.on("add", (newNodes) => {
7099
7309
  newNodes.forEach((node) => {
7100
- nodeStatusMap.value?.set(node.id, {
7101
- visible: true,
7102
- expand: Array.isArray(node.items),
7103
- selected: true
7310
+ traverseNode(node, (node2) => {
7311
+ nodeStatusMap.value?.set(node2.id, {
7312
+ visible: true,
7313
+ expand: Array.isArray(node2.items),
7314
+ selected: true
7315
+ });
7104
7316
  });
7105
7317
  });
7106
7318
  });
7107
7319
  services?.editorService.on("remove", (nodes2) => {
7108
7320
  nodes2.forEach((node) => {
7109
- nodeStatusMap.value?.delete(node.id);
7321
+ traverseNode(node, (node2) => {
7322
+ nodeStatusMap.value?.delete(node2.id);
7323
+ });
7110
7324
  });
7111
7325
  });
7112
7326
  return {
@@ -7126,10 +7340,11 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7126
7340
  setup(__props) {
7127
7341
  const services = inject("services");
7128
7342
  const editorService = services?.editorService;
7343
+ const layerTreeContainer = ref();
7129
7344
  const page = computed(() => editorService?.get("page"));
7130
7345
  const root = computed(() => editorService?.get("root"));
7131
7346
  const { nodeStatusMap } = useNodeStatus(services, page);
7132
- const { isCtrlKeyDown } = useKeybinding(services);
7347
+ const { isCtrlKeyDown } = useKeybinding(services, layerTreeContainer);
7133
7348
  provide("nodeStatusMap", nodeStatusMap);
7134
7349
  const { filterText, filterTextChangeHandler } = useFilter(nodeStatusMap, page);
7135
7350
  const collapseAllHandler = () => {
@@ -7156,6 +7371,8 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7156
7371
  createVNode(_sfc_main$t, { onSearch: unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
7157
7372
  createElementVNode("div", {
7158
7373
  class: "magic-editor-layer-tree",
7374
+ ref_key: "layerTreeContainer",
7375
+ ref: layerTreeContainer,
7159
7376
  tabindex: "-1",
7160
7377
  onDragover: _cache[0] || (_cache[0] = //@ts-ignore
7161
7378
  (...args) => unref(handleDragOver) && unref(handleDragOver)(...args))
@@ -7172,7 +7389,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
7172
7389
  ]),
7173
7390
  _: 3
7174
7391
  }, 8, ["data", "filter-text", "is-ctrl-key-down"])) : createCommentVNode("", true)
7175
- ], 32),
7392
+ ], 544),
7176
7393
  (openBlock(), createBlock(Teleport, { to: "body" }, [
7177
7394
  createVNode(_sfc_main$j, {
7178
7395
  ref_key: "menu",
@@ -7293,10 +7510,18 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
7293
7510
  onDrag: dragHandler
7294
7511
  }, [
7295
7512
  renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
7296
- createVNode(_sfc_main$M, {
7297
- title: item.text,
7298
- icon: item.icon
7299
- }, null, 8, ["title", "icon"]),
7513
+ createVNode(unref(TMagicTooltip), {
7514
+ placement: "right",
7515
+ disabled: !Boolean(item.desc),
7516
+ content: item.desc
7517
+ }, {
7518
+ default: withCtx(() => [
7519
+ createVNode(_sfc_main$M, {
7520
+ icon: item.icon
7521
+ }, null, 8, ["icon"])
7522
+ ]),
7523
+ _: 2
7524
+ }, 1032, ["disabled", "content"]),
7300
7525
  createElementVNode("span", {
7301
7526
  title: item.text
7302
7527
  }, toDisplayString(item.text), 9, _hoisted_2$7)
@@ -7907,7 +8132,7 @@ const useStage = (stageOptions) => {
7907
8132
  canSelect: (el, event, stop) => {
7908
8133
  const elCanSelect = stageOptions.canSelect(el);
7909
8134
  if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
7910
- document.dispatchEvent(new CustomEvent("ui-select", { detail: el }));
8135
+ document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
7911
8136
  return stop();
7912
8137
  }
7913
8138
  return elCanSelect;
@@ -8512,7 +8737,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
8512
8737
  onMounted(() => {
8513
8738
  if (stageWrap.value?.container) {
8514
8739
  resizeObserver.observe(stageWrap.value.container);
8515
- services?.keybindingService.registeEl("stage", stageWrap.value.container);
8740
+ services?.keybindingService.registeEl(KeyBindingContainerKey.STAGE, stageWrap.value.container);
8516
8741
  }
8517
8742
  });
8518
8743
  onUnmounted(() => {
@@ -9584,125 +9809,6 @@ class Keybinding extends BaseService {
9584
9809
  }
9585
9810
  const keybindingService = new Keybinding();
9586
9811
 
9587
- const keybindingConfig = [
9588
- {
9589
- command: KeyBindingCommand.DELETE_NODE,
9590
- keybinding: ["delete", "backspace"],
9591
- when: [
9592
- ["stage", "keyup"],
9593
- ["layer-panel", "keydown"]
9594
- ]
9595
- },
9596
- {
9597
- command: KeyBindingCommand.COPY_NODE,
9598
- keybinding: "ctrl+c",
9599
- when: [
9600
- ["stage", "keydown"],
9601
- ["layer-panel", "keydown"]
9602
- ]
9603
- },
9604
- {
9605
- command: KeyBindingCommand.PASTE_NODE,
9606
- keybinding: "ctrl+v",
9607
- when: [
9608
- ["stage", "keydown"],
9609
- ["layer-panel", "keydown"]
9610
- ]
9611
- },
9612
- {
9613
- command: KeyBindingCommand.CUT_NODE,
9614
- keybinding: "ctrl+x",
9615
- when: [
9616
- ["stage", "keydown"],
9617
- ["layer-panel", "keydown"]
9618
- ]
9619
- },
9620
- {
9621
- command: KeyBindingCommand.UNDO,
9622
- keybinding: "ctrl+z",
9623
- when: [
9624
- ["stage", "keydown"],
9625
- ["layer-panel", "keydown"]
9626
- ]
9627
- },
9628
- {
9629
- command: KeyBindingCommand.REDO,
9630
- keybinding: "ctrl+shift+z",
9631
- when: [
9632
- ["stage", "keydown"],
9633
- ["layer-panel", "keydown"]
9634
- ]
9635
- },
9636
- {
9637
- command: KeyBindingCommand.MOVE_UP_1,
9638
- keybinding: "up",
9639
- when: [["stage", "keydown"]]
9640
- },
9641
- {
9642
- command: KeyBindingCommand.MOVE_DOWN_1,
9643
- keybinding: "down",
9644
- when: [["stage", "keydown"]]
9645
- },
9646
- {
9647
- command: KeyBindingCommand.MOVE_LEFT_1,
9648
- keybinding: "left",
9649
- when: [["stage", "keydown"]]
9650
- },
9651
- {
9652
- command: KeyBindingCommand.MOVE_RIGHT_1,
9653
- keybinding: "right",
9654
- when: [["stage", "keydown"]]
9655
- },
9656
- {
9657
- command: KeyBindingCommand.MOVE_UP_10,
9658
- keybinding: "ctrl+up",
9659
- when: [["stage", "keydown"]]
9660
- },
9661
- {
9662
- command: KeyBindingCommand.MOVE_DOWN_10,
9663
- keybinding: "ctrl+down",
9664
- when: [["stage", "keydown"]]
9665
- },
9666
- {
9667
- command: KeyBindingCommand.MOVE_LEFT_10,
9668
- keybinding: "ctrl+left",
9669
- when: [["stage", "keydown"]]
9670
- },
9671
- {
9672
- command: KeyBindingCommand.MOVE_RIGHT_10,
9673
- keybinding: "ctrl+right",
9674
- when: [["stage", "keydown"]]
9675
- },
9676
- {
9677
- command: KeyBindingCommand.SWITCH_NODE,
9678
- keybinding: "tab",
9679
- when: [
9680
- ["stage", "keydown"],
9681
- ["layer-panel", "keydown"]
9682
- ]
9683
- },
9684
- {
9685
- command: KeyBindingCommand.ZOOM_IN,
9686
- keybinding: ["ctrl+=", "ctrl+numpadplus"],
9687
- when: [["stage", "keydown"]]
9688
- },
9689
- {
9690
- command: KeyBindingCommand.ZOOM_OUT,
9691
- keybinding: ["ctrl+-", "ctrl+numpad-"],
9692
- when: [["stage", "keydown"]]
9693
- },
9694
- {
9695
- command: KeyBindingCommand.ZOOM_FIT,
9696
- keybinding: "ctrl+0",
9697
- when: [["stage", "keydown"]]
9698
- },
9699
- {
9700
- command: KeyBindingCommand.ZOOM_RESET,
9701
- keybinding: "ctrl+1",
9702
- when: [["stage", "keydown"]]
9703
- }
9704
- ];
9705
-
9706
9812
  const defaultEditorProps = {
9707
9813
  componentGroupList: () => [],
9708
9814
  datasourceList: () => [],
@@ -10281,5 +10387,5 @@ const index = {
10281
10387
  }
10282
10388
  };
10283
10389
 
10284
- export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$O as CodeBlockEditor, _sfc_main$q as CodeBlockList, _sfc_main$p as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$P as CodeSelect, _sfc_main$L as CodeSelectCol, ColumnLayout, _sfc_main$f as ComponentListPanel, _sfc_main$l as ContentMenu, _sfc_main$J as DataSourceFieldSelect, _sfc_main$K as DataSourceFields, _sfc_main$I as DataSourceInput, _sfc_main$G as DataSourceMethodSelect, _sfc_main$H as DataSourceMethods, _sfc_main$F as DataSourceMocks, _sfc_main$E as DataSourceSelect, DepTargetType, DragType, _sfc_main$D as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$M as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$g as LayerPanel, Layout, _sfc_main$z as LayoutContainer, _sfc_main$u as PropsPanel, _sfc_main$A as Resizer, _sfc_main$z as SplitView, _sfc_main$S as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$w as ToolButton, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useStage, warn };
10390
+ export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$O as CodeBlockEditor, _sfc_main$q as CodeBlockList, _sfc_main$p as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$P as CodeSelect, _sfc_main$L as CodeSelectCol, ColumnLayout, _sfc_main$f as ComponentListPanel, _sfc_main$l as ContentMenu, _sfc_main$J as DataSourceFieldSelect, _sfc_main$K as DataSourceFields, _sfc_main$I as DataSourceInput, _sfc_main$G as DataSourceMethodSelect, _sfc_main$H as DataSourceMethods, _sfc_main$F as DataSourceMocks, _sfc_main$E as DataSourceSelect, DepTargetType, DragType, _sfc_main$D as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$M as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$g as LayerPanel, Layout, _sfc_main$z as LayoutContainer, _sfc_main$u as PropsPanel, _sfc_main$A as Resizer, _sfc_main$z as SplitView, _sfc_main$S as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$w as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useStage, warn };
10285
10391
  //# sourceMappingURL=tmagic-editor.js.map