@tmagic/editor 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/style.css +50 -0
  2. package/dist/tmagic-editor.js +578 -574
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +590 -585
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +15 -13
  7. package/src/components/CodeBlockEditor.vue +6 -4
  8. package/src/fields/DataSourceSelect.vue +15 -9
  9. package/src/hooks/index.ts +1 -0
  10. package/src/hooks/use-code-block-edit.ts +2 -0
  11. package/src/hooks/use-float-box.ts +153 -0
  12. package/src/index.ts +1 -0
  13. package/src/initService.ts +12 -11
  14. package/src/layouts/Framework.vue +10 -1
  15. package/src/layouts/sidebar/Sidebar.vue +90 -5
  16. package/src/layouts/sidebar/code-block/CodeBlockList.vue +2 -1
  17. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +11 -10
  18. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +6 -4
  19. package/src/layouts/sidebar/data-source/DataSourceList.vue +9 -8
  20. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +15 -15
  21. package/src/layouts/sidebar/layer/use-drag.ts +4 -0
  22. package/src/layouts/sidebar/layer/use-node-status.ts +20 -15
  23. package/src/services/dataSource.ts +4 -0
  24. package/src/services/dep.ts +22 -284
  25. package/src/services/ui.ts +15 -0
  26. package/src/theme/code-block.scss +5 -0
  27. package/src/theme/floatbox.scss +48 -0
  28. package/src/theme/sidebar.scss +1 -0
  29. package/src/theme/theme.scss +1 -0
  30. package/src/type.ts +30 -20
  31. package/types/components/CodeBlockEditor.vue.d.ts +3 -0
  32. package/types/fields/DataSourceSelect.vue.d.ts +6 -4
  33. package/types/hooks/index.d.ts +1 -0
  34. package/types/hooks/use-code-block-edit.d.ts +26 -46
  35. package/types/hooks/use-data-source-method.d.ts +26 -46
  36. package/types/hooks/use-float-box.d.ts +15 -0
  37. package/types/index.d.ts +1 -0
  38. package/types/layouts/PropsPanel.vue.d.ts +92 -59
  39. package/types/layouts/sidebar/Sidebar.vue.d.ts +1 -2
  40. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +1 -1
  41. package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +3 -1
  42. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -0
  43. package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +1 -1
  44. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +15 -2
  45. package/types/layouts/sidebar/layer/use-click.d.ts +7 -46
  46. package/types/services/dataSource.d.ts +10 -2
  47. package/types/services/dep.d.ts +12 -112
  48. package/types/services/ui.d.ts +8 -0
  49. package/types/type.d.ts +23 -18
  50. package/src/utils/dep.ts +0 -81
  51. package/types/utils/dep.d.ts +0 -6
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('serialize-javascript'), require('@tmagic/design'), require('@tmagic/schema'), require('@tmagic/form'), require('@tmagic/table'), require('@tmagic/utils'), require('gesto'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', 'serialize-javascript', '@tmagic/design', '@tmagic/schema', '@tmagic/form', '@tmagic/table', '@tmagic/utils', 'gesto', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.monaco, global.serialize, global.design, global.schema, global.form, global.table, global.utils, global.Gesto, global.StageCore, global.events, global.core, global.KeyController));
5
- })(this, (function (exports, vue, iconsVue, lodashEs, monaco, serialize, design, schema, form, table, utils, Gesto, StageCore, events, core, KeyController) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('monaco-editor'), require('serialize-javascript'), require('@tmagic/design'), require('@tmagic/schema'), require('@tmagic/form'), require('@tmagic/table'), require('@tmagic/utils'), require('gesto'), require('moveable'), require('@tmagic/dep'), require('@tmagic/stage'), require('events'), require('@tmagic/core'), require('keycon')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', 'monaco-editor', 'serialize-javascript', '@tmagic/design', '@tmagic/schema', '@tmagic/form', '@tmagic/table', '@tmagic/utils', 'gesto', 'moveable', '@tmagic/dep', '@tmagic/stage', 'events', '@tmagic/core', 'keycon'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.Vue, global.iconsVue, global.lodashEs, global.monaco, global.serialize, global.design, global.schema, global.form, global.table, global.utils, global.Gesto, global.Moveable, global.dep, global.StageCore, global.events, global.core, global.KeyController));
5
+ })(this, (function (exports, vue, iconsVue, lodashEs, monaco, serialize, design, schema, form, table, utils, Gesto, Moveable, dep, StageCore, events, core, KeyController) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -50,8 +50,9 @@
50
50
  parse: { type: Boolean, default: false }
51
51
  },
52
52
  emits: ["initd", "save"],
53
- setup(__props, { expose: __expose, emit }) {
53
+ setup(__props, { expose: __expose, emit: __emit }) {
54
54
  const props = __props;
55
+ const emit = __emit;
55
56
  const toString = (v, language) => {
56
57
  let value = "";
57
58
  if (typeof v !== "string") {
@@ -234,7 +235,8 @@
234
235
  lastValues: {}
235
236
  },
236
237
  emits: ["change"],
237
- setup(__props, { emit }) {
238
+ setup(__props, { emit: __emit }) {
239
+ const emit = __emit;
238
240
  const props = __props;
239
241
  const save = (v) => {
240
242
  props.model[props.name] = v;
@@ -273,8 +275,9 @@
273
275
  lastValues: {}
274
276
  },
275
277
  emits: ["change"],
276
- setup(__props, { emit }) {
278
+ setup(__props, { emit: __emit }) {
277
279
  const props = __props;
280
+ const emit = __emit;
278
281
  const formConfig = vue.computed(() => {
279
282
  const { codeOptions, ...config } = props.config;
280
283
  return {
@@ -352,9 +355,10 @@
352
355
  lastValues: {}
353
356
  },
354
357
  emits: ["change"],
355
- setup(__props, { emit }) {
356
- const props = __props;
358
+ setup(__props, { emit: __emit }) {
359
+ const emit = __emit;
357
360
  const services = vue.inject("services");
361
+ const props = __props;
358
362
  const codeConfig = vue.computed(() => ({
359
363
  type: "group-list",
360
364
  name: "hookData",
@@ -420,11 +424,13 @@
420
424
  content: {},
421
425
  disabled: { type: Boolean },
422
426
  isDataSource: { type: Boolean },
423
- dataSourceType: {}
427
+ dataSourceType: {},
428
+ slideType: {}
424
429
  },
425
430
  emits: ["submit"],
426
- setup(__props, { expose: __expose, emit }) {
431
+ setup(__props, { expose: __expose, emit: __emit }) {
427
432
  const props = __props;
433
+ const emit = __emit;
428
434
  const services = vue.inject("services");
429
435
  const difVisible = vue.ref(false);
430
436
  const height = vue.ref(globalThis.innerHeight);
@@ -591,7 +597,7 @@
591
597
  });
592
598
  return (_ctx, _cache) => {
593
599
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
594
- vue.createVNode(vue.unref(form.MFormDrawer), {
600
+ (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.slideType === "box" ? vue.unref(form.MFormBox) : vue.unref(form.MFormDrawer)), {
595
601
  class: "m-editor-code-block-editor",
596
602
  ref_key: "fomDrawer",
597
603
  ref: fomDrawer,
@@ -622,7 +628,7 @@
622
628
  })
623
629
  ]),
624
630
  _: 1
625
- }, 8, ["title", "width", "config", "values", "disabled"]),
631
+ }, 40, ["title", "width", "config", "values", "disabled"])),
626
632
  vue.createVNode(vue.unref(design.TMagicDialog), {
627
633
  modelValue: difVisible.value,
628
634
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => difVisible.value = $event),
@@ -1131,12 +1137,14 @@
1131
1137
  };
1132
1138
  this.get("dataSources").push(newConfig);
1133
1139
  this.emit("add", newConfig);
1140
+ return newConfig;
1134
1141
  }
1135
1142
  update(config) {
1136
1143
  const dataSources = this.get("dataSources");
1137
1144
  const index = dataSources.findIndex((ds) => ds.id === config.id);
1138
1145
  dataSources[index] = lodashEs.cloneDeep(config);
1139
1146
  this.emit("update", config);
1147
+ return config;
1140
1148
  }
1141
1149
  remove(id) {
1142
1150
  const dataSources = this.get("dataSources");
@@ -1559,14 +1567,6 @@
1559
1567
  KeyBindingCommand2["SWITCH_NODE"] = "tmagic-system-switch-node";
1560
1568
  return KeyBindingCommand2;
1561
1569
  })(KeyBindingCommand || {});
1562
- var DepTargetType = /* @__PURE__ */ ((DepTargetType2) => {
1563
- DepTargetType2["DEFAULT"] = "default";
1564
- DepTargetType2["CODE_BLOCK"] = "code-block";
1565
- DepTargetType2["DATA_SOURCE"] = "data-source";
1566
- DepTargetType2["DATA_SOURCE_METHOD"] = "data-source-method";
1567
- DepTargetType2["DATA_SOURCE_COND"] = "data-source-cond";
1568
- return DepTargetType2;
1569
- })(DepTargetType || {});
1570
1570
  var DragType = /* @__PURE__ */ ((DragType2) => {
1571
1571
  DragType2["COMPONENT_LIST"] = "component-list";
1572
1572
  DragType2["LAYER_TREE"] = "layer-tree";
@@ -2986,8 +2986,9 @@
2986
2986
  paramsConfig: {}
2987
2987
  },
2988
2988
  emits: ["change"],
2989
- setup(__props, { emit }) {
2989
+ setup(__props, { emit: __emit }) {
2990
2990
  const props = __props;
2991
+ const emit = __emit;
2991
2992
  const form$1 = vue.ref();
2992
2993
  const getFormConfig = (items = []) => [
2993
2994
  {
@@ -3111,6 +3112,7 @@
3111
3112
  if (!codeId.value)
3112
3113
  return;
3113
3114
  await codeBlockService?.setCodeDslById(codeId.value, values);
3115
+ design.tMagicMessage.success("代码块保存成功");
3114
3116
  codeBlockEditor.value?.hide();
3115
3117
  };
3116
3118
  return {
@@ -3143,9 +3145,10 @@
3143
3145
  lastValues: {}
3144
3146
  },
3145
3147
  emits: ["change"],
3146
- setup(__props, { emit }) {
3147
- const props = __props;
3148
+ setup(__props, { emit: __emit }) {
3148
3149
  const services = vue.inject("services");
3150
+ const emit = __emit;
3151
+ const props = __props;
3149
3152
  const getParamItemsConfig = (codeId) => {
3150
3153
  if (!codeDsl.value || !codeId)
3151
3154
  return [];
@@ -3254,8 +3257,9 @@
3254
3257
  lastValues: {}
3255
3258
  },
3256
3259
  emits: ["change"],
3257
- setup(__props, { emit }) {
3260
+ setup(__props, { emit: __emit }) {
3258
3261
  const props = __props;
3262
+ const emit = __emit;
3259
3263
  const services = vue.inject("services");
3260
3264
  const addDialog = vue.ref();
3261
3265
  const fieldValues = vue.ref({});
@@ -3539,9 +3543,10 @@
3539
3543
  lastValues: {}
3540
3544
  },
3541
3545
  emits: ["change"],
3542
- setup(__props, { emit }) {
3543
- const props = __props;
3546
+ setup(__props, { emit: __emit }) {
3544
3547
  const services = vue.inject("services");
3548
+ const emit = __emit;
3549
+ const props = __props;
3545
3550
  const dataSources = vue.computed(() => services?.dataSourceService.get("dataSources"));
3546
3551
  const getOptionChildren = (fields = []) => fields.map((field) => ({
3547
3552
  label: field.title || field.name,
@@ -3599,8 +3604,9 @@
3599
3604
  lastValues: {}
3600
3605
  },
3601
3606
  emits: ["change"],
3602
- setup(__props, { emit }) {
3607
+ setup(__props, { emit: __emit }) {
3603
3608
  const props = __props;
3609
+ const emit = __emit;
3604
3610
  const { dataSourceService } = vue.inject("services") || {};
3605
3611
  const autocomplete = vue.ref();
3606
3612
  const isFocused = vue.ref(false);
@@ -3908,8 +3914,9 @@
3908
3914
  lastValues: {}
3909
3915
  },
3910
3916
  emits: ["change"],
3911
- setup(__props, { emit }) {
3917
+ setup(__props, { emit: __emit }) {
3912
3918
  const props = __props;
3919
+ const emit = __emit;
3913
3920
  const { codeConfig, codeBlockEditor, createCode, editCode, deleteCode, submitCode } = useDataSourceMethod();
3914
3921
  const methodColumns = [
3915
3922
  {
@@ -4013,10 +4020,11 @@
4013
4020
  lastValues: {}
4014
4021
  },
4015
4022
  emits: ["change"],
4016
- setup(__props, { emit }) {
4017
- const props = __props;
4023
+ setup(__props, { emit: __emit }) {
4018
4024
  const services = vue.inject("services");
4025
+ const emit = __emit;
4019
4026
  const dataSourceService = services?.dataSourceService;
4027
+ const props = __props;
4020
4028
  const dataSources = vue.computed(() => dataSourceService?.get("dataSources"));
4021
4029
  const getParamItemsConfig = ([dataSourceId, medthodName] = ["", ""]) => {
4022
4030
  if (!dataSourceId)
@@ -4134,8 +4142,9 @@
4134
4142
  lastValues: {}
4135
4143
  },
4136
4144
  emits: ["change"],
4137
- setup(__props, { emit }) {
4145
+ setup(__props, { emit: __emit }) {
4138
4146
  const props = __props;
4147
+ const emit = __emit;
4139
4148
  const services = vue.inject("services");
4140
4149
  const width = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
4141
4150
  const addDialog = vue.ref();
@@ -4365,18 +4374,20 @@
4365
4374
  lastValues: {}
4366
4375
  },
4367
4376
  emits: ["change"],
4368
- setup(__props, { emit }) {
4377
+ setup(__props, { emit: __emit }) {
4378
+ const emit = __emit;
4369
4379
  const props = __props;
4370
4380
  const { dataSourceService } = vue.inject("services") || {};
4371
4381
  const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
4372
4382
  const selectConfig = vue.computed(() => {
4373
- const { type, dataSourceType, ...config } = props.config;
4383
+ const { type, dataSourceType, value, ...config } = props.config;
4384
+ const valueIsId = props.config.value === "id";
4374
4385
  return {
4375
4386
  ...config,
4376
4387
  type: "select",
4377
4388
  valueKey: "dataSourceId",
4378
- options: dataSources.value.filter((ds) => !dataSourceType || ds.type === dataSourceType).map((ds) => ({
4379
- value: {
4389
+ options: dataSources.value.filter((ds) => !props.config.dataSourceType || ds.type === props.config.dataSourceType).map((ds) => ({
4390
+ value: valueIsId ? ds.id : {
4380
4391
  isBindDataSource: true,
4381
4392
  dataSourceType: ds.type,
4382
4393
  dataSourceId: ds.id
@@ -4425,8 +4436,9 @@
4425
4436
  lastValues: {}
4426
4437
  },
4427
4438
  emits: ["change"],
4428
- setup(__props, { emit }) {
4439
+ setup(__props, { emit: __emit }) {
4429
4440
  const props = __props;
4441
+ const emit = __emit;
4430
4442
  const services = vue.inject("services");
4431
4443
  const editorService = services?.editorService;
4432
4444
  const dataSourceService = services?.dataSourceService;
@@ -4689,8 +4701,9 @@
4689
4701
  lastValues: {}
4690
4702
  },
4691
4703
  emits: ["change"],
4692
- setup(__props, { emit }) {
4704
+ setup(__props, { emit: __emit }) {
4693
4705
  const props = __props;
4706
+ const emit = __emit;
4694
4707
  const records = vue.ref([]);
4695
4708
  vue.watchEffect(() => {
4696
4709
  records.value = Object.entries(props.model[props.name] || {});
@@ -4793,8 +4806,9 @@
4793
4806
  lastValues: {}
4794
4807
  },
4795
4808
  emits: ["change"],
4796
- setup(__props, { emit }) {
4809
+ setup(__props, { emit: __emit }) {
4797
4810
  const props = __props;
4811
+ const emit = __emit;
4798
4812
  const services = vue.inject("services");
4799
4813
  const mForm = vue.inject("mForm");
4800
4814
  const val = vue.computed(() => props.model[props.name]);
@@ -4968,7 +4982,8 @@
4968
4982
  },
4969
4983
  __name: "Resizer",
4970
4984
  emits: ["change"],
4971
- setup(__props, { emit }) {
4985
+ setup(__props, { emit: __emit }) {
4986
+ const emit = __emit;
4972
4987
  const target = vue.ref();
4973
4988
  const { isDraging } = useGetSo(target, emit);
4974
4989
  return (_ctx, _cache) => {
@@ -4999,7 +5014,8 @@
4999
5014
  centerClass: {}
5000
5015
  },
5001
5016
  emits: ["update:left", "change", "update:right"],
5002
- setup(__props, { expose: __expose, emit }) {
5017
+ setup(__props, { expose: __expose, emit: __emit }) {
5018
+ const emit = __emit;
5003
5019
  const props = __props;
5004
5020
  const el = vue.ref();
5005
5021
  const hasLeft = vue.computed(() => typeof props.left !== "undefined");
@@ -5188,7 +5204,8 @@
5188
5204
  const root = vue.computed(() => editorService?.get("root"));
5189
5205
  const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
5190
5206
  const showSrc = vue.computed(() => uiService?.get("showSrc"));
5191
- const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
5207
+ const getLeftColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
5208
+ const leftColumnWidthCacheData = getLeftColumnWidthCacheData();
5192
5209
  const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
5193
5210
  const columnWidth = vue.ref({
5194
5211
  left: leftColumnWidthCacheData,
@@ -5218,6 +5235,12 @@
5218
5235
  globalThis.localStorage.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, `${left}`);
5219
5236
  }
5220
5237
  );
5238
+ vue.watch(
5239
+ () => uiService?.get("hideSlideBar"),
5240
+ (hideSlideBar) => {
5241
+ columnWidth.value.left = hideSlideBar ? 0 : getLeftColumnWidthCacheData();
5242
+ }
5243
+ );
5221
5244
  const columnWidthChange = (columnW) => {
5222
5245
  columnWidth.value.left = columnW.left;
5223
5246
  columnWidth.value.center = columnW.center;
@@ -5646,7 +5669,8 @@
5646
5669
  extendState: { type: Function }
5647
5670
  },
5648
5671
  emits: ["mounted"],
5649
- setup(__props, { expose: __expose, emit }) {
5672
+ setup(__props, { expose: __expose, emit: __emit }) {
5673
+ const emit = __emit;
5650
5674
  const internalInstance = vue.getCurrentInstance();
5651
5675
  const values = vue.ref({});
5652
5676
  const configForm = vue.ref();
@@ -5710,13 +5734,145 @@
5710
5734
  }
5711
5735
  });
5712
5736
 
5737
+ const useFloatBox = (slideKeys) => {
5738
+ const services = vue.inject("services");
5739
+ const moveable = vue.ref();
5740
+ const floatBox = vue.ref();
5741
+ const floatBoxStates = vue.computed(() => services?.uiService.get("floatBox"));
5742
+ const curKey = vue.ref("");
5743
+ const target = vue.computed(
5744
+ () => floatBox.value ? floatBox.value.find((item) => item.classList.contains(`m-editor-float-box-${curKey.value}`)) : void 0
5745
+ );
5746
+ const showingBoxKeys = vue.computed(
5747
+ () => [...floatBoxStates.value?.keys() ?? []].filter((key) => floatBoxStates.value?.get(key)?.status)
5748
+ );
5749
+ const isDraging = vue.ref(false);
5750
+ const showFloatBox = async (key) => {
5751
+ const curBoxStatus = floatBoxStates.value?.get(curKey.value)?.status;
5752
+ if (curKey.value === key && curBoxStatus)
5753
+ return;
5754
+ curKey.value = key;
5755
+ setSlideState(key, {
5756
+ zIndex: getMaxZIndex() + 1,
5757
+ status: true
5758
+ });
5759
+ await vue.nextTick();
5760
+ if (moveable.value) {
5761
+ moveable.value.target = target.value;
5762
+ moveable.value.dragTarget = getDragTarget();
5763
+ moveable.value.updateRect();
5764
+ } else {
5765
+ initFloatBoxMoveable();
5766
+ }
5767
+ };
5768
+ const setSlideState = (key, data) => {
5769
+ const slideState = floatBoxStates.value?.get(key);
5770
+ if (!slideState)
5771
+ return;
5772
+ floatBoxStates.value?.set(key, {
5773
+ ...slideState,
5774
+ ...data
5775
+ });
5776
+ };
5777
+ const getDragTarget = (key) => `.m-editor-float-box-header-${key ?? curKey.value}`;
5778
+ const closeFloatBox = (key) => {
5779
+ setSlideState(key, {
5780
+ status: false
5781
+ });
5782
+ if (!floatBoxStates.value?.values)
5783
+ return;
5784
+ const keys = [...floatBoxStates.value?.keys()];
5785
+ const values = [...floatBoxStates.value?.values()];
5786
+ const lastFloatBoxLen = values.filter((state) => state.status).length;
5787
+ if (lastFloatBoxLen === 0) {
5788
+ moveable.value?.destroy();
5789
+ moveable.value = void 0;
5790
+ return;
5791
+ }
5792
+ if (key === curKey.value) {
5793
+ const zIndexList = values.filter((item) => item.status).map((item) => item.zIndex);
5794
+ const maxZIndex = Math.max(...zIndexList);
5795
+ const key2 = keys.find((key3) => floatBoxStates.value?.get(key3)?.zIndex === maxZIndex);
5796
+ if (!key2)
5797
+ return;
5798
+ showFloatBox(key2);
5799
+ }
5800
+ };
5801
+ const getMaxZIndex = () => {
5802
+ if (!floatBoxStates.value?.values())
5803
+ return 0;
5804
+ const list = [...floatBoxStates.value?.values()].map((state) => state.zIndex);
5805
+ return Math.max(...list) ?? 0;
5806
+ };
5807
+ const initFloatBoxMoveable = () => {
5808
+ const dragTarget = getDragTarget();
5809
+ moveable.value = new Moveable(document.body, {
5810
+ target: target.value,
5811
+ draggable: true,
5812
+ resizable: true,
5813
+ edge: true,
5814
+ keepRatio: false,
5815
+ origin: false,
5816
+ snappable: true,
5817
+ dragTarget,
5818
+ dragTargetSelf: false,
5819
+ linePadding: 10,
5820
+ controlPadding: 10,
5821
+ elementGuidelines: [...floatBoxStates.value?.keys() ?? []].map((key) => getDragTarget(key)),
5822
+ bounds: { left: 0, top: 0, right: 0, bottom: 0, position: "css" }
5823
+ });
5824
+ moveable.value.on("drag", (e) => {
5825
+ e.target.style.transform = e.transform;
5826
+ });
5827
+ moveable.value.on("resize", (e) => {
5828
+ e.target.style.width = `${e.width}px`;
5829
+ e.target.style.height = `${e.height}px`;
5830
+ e.target.style.transform = e.drag.transform;
5831
+ });
5832
+ };
5833
+ const dragendHandler = (key, e) => {
5834
+ setSlideState(key, {
5835
+ left: e.clientX,
5836
+ top: e.clientY
5837
+ });
5838
+ showFloatBox(key);
5839
+ isDraging.value = false;
5840
+ };
5841
+ document.body.addEventListener("dragover", (e) => {
5842
+ if (!isDraging.value)
5843
+ return;
5844
+ e.preventDefault();
5845
+ });
5846
+ const dragstartHandler = () => isDraging.value = true;
5847
+ vue.watch(
5848
+ () => slideKeys.value,
5849
+ () => {
5850
+ services?.uiService.setFloatBox(slideKeys.value);
5851
+ },
5852
+ {
5853
+ deep: true,
5854
+ immediate: true
5855
+ }
5856
+ );
5857
+ return {
5858
+ showFloatBox,
5859
+ closeFloatBox,
5860
+ dragstartHandler,
5861
+ dragendHandler,
5862
+ floatBoxStates,
5863
+ floatBox,
5864
+ showingBoxKeys
5865
+ };
5866
+ };
5867
+
5713
5868
  const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
5714
5869
  ...{
5715
5870
  name: "MEditorSearchInput"
5716
5871
  },
5717
5872
  __name: "SearchInput",
5718
5873
  emits: ["search"],
5719
- setup(__props, { emit }) {
5874
+ setup(__props, { emit: __emit }) {
5875
+ const emit = __emit;
5720
5876
  const filterText = vue.ref("");
5721
5877
  let timer = null;
5722
5878
  const filterTextChangeHandler = () => {
@@ -5812,11 +5968,12 @@
5812
5968
  customError: { type: Function }
5813
5969
  },
5814
5970
  emits: ["edit", "remove"],
5815
- setup(__props, { expose: __expose, emit }) {
5971
+ setup(__props, { expose: __expose, emit: __emit }) {
5816
5972
  const props = __props;
5973
+ const emit = __emit;
5817
5974
  const { codeBlockService, depService, editorService } = vue.inject("services") || {};
5818
5975
  const codeList = vue.computed(
5819
- () => Object.values(depService?.getTargets(DepTargetType.CODE_BLOCK) || {}).map((target) => {
5976
+ () => Object.values(depService?.getTargets(dep.DepTargetType.CODE_BLOCK) || {}).map((target) => {
5820
5977
  const compNodes = Object.entries(target.deps).map(([id, dep]) => ({
5821
5978
  name: dep.name,
5822
5979
  type: "node",
@@ -5967,7 +6124,8 @@
5967
6124
  },
5968
6125
  __name: "CodeBlockListPanel",
5969
6126
  props: {
5970
- customError: { type: Function }
6127
+ customError: { type: Function },
6128
+ slideType: {}
5971
6129
  },
5972
6130
  setup(__props) {
5973
6131
  const { codeBlockService } = vue.inject("services") || {};
@@ -5978,52 +6136,55 @@
5978
6136
  codeBlockList.value?.filter(val);
5979
6137
  };
5980
6138
  return (_ctx, _cache) => {
5981
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
5982
- default: vue.withCtx(() => [
5983
- vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
5984
- vue.createElementVNode("div", _hoisted_1$f, [
5985
- vue.createVNode(_sfc_main$u, { onSearch: filterTextChangeHandler }),
5986
- editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
5987
- key: 0,
5988
- class: "create-code-button",
5989
- type: "primary",
5990
- size: "small",
5991
- onClick: vue.unref(createCodeBlock)
5992
- }, {
5993
- default: vue.withCtx(() => [
5994
- vue.createTextVNode("新增")
5995
- ]),
5996
- _: 1
5997
- }, 8, ["onClick"])) : vue.createCommentVNode("", true),
5998
- vue.renderSlot(_ctx.$slots, "code-block-panel-search")
5999
- ])
6000
- ]),
6001
- vue.createVNode(_sfc_main$r, {
6002
- ref_key: "codeBlockList",
6003
- ref: codeBlockList,
6004
- "custom-error": _ctx.customError,
6005
- onEdit: vue.unref(editCode),
6006
- onRemove: vue.unref(deleteCode)
6007
- }, {
6008
- "code-block-panel-tool": vue.withCtx(({ id, data }) => [
6009
- vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
6010
- id,
6011
- data
6012
- })
6139
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
6140
+ vue.createVNode(vue.unref(design.TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
6141
+ default: vue.withCtx(() => [
6142
+ vue.renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
6143
+ vue.createElementVNode("div", _hoisted_1$f, [
6144
+ vue.createVNode(_sfc_main$u, { onSearch: filterTextChangeHandler }),
6145
+ editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
6146
+ key: 0,
6147
+ class: "create-code-button",
6148
+ type: "primary",
6149
+ size: "small",
6150
+ onClick: vue.unref(createCodeBlock)
6151
+ }, {
6152
+ default: vue.withCtx(() => [
6153
+ vue.createTextVNode("新增")
6154
+ ]),
6155
+ _: 1
6156
+ }, 8, ["onClick"])) : vue.createCommentVNode("", true),
6157
+ vue.renderSlot(_ctx.$slots, "code-block-panel-search")
6158
+ ])
6013
6159
  ]),
6014
- _: 3
6015
- }, 8, ["custom-error", "onEdit", "onRemove"]),
6016
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
6017
- key: 0,
6018
- ref_key: "codeBlockEditor",
6019
- ref: codeBlockEditor,
6020
- disabled: !editable.value,
6021
- content: vue.unref(codeConfig),
6022
- onSubmit: vue.unref(submitCodeBlockHandler)
6023
- }, null, 8, ["disabled", "content", "onSubmit"])) : vue.createCommentVNode("", true)
6024
- ]),
6025
- _: 3
6026
- });
6160
+ vue.createVNode(_sfc_main$r, {
6161
+ ref_key: "codeBlockList",
6162
+ ref: codeBlockList,
6163
+ "custom-error": _ctx.customError,
6164
+ onEdit: vue.unref(editCode),
6165
+ onRemove: vue.unref(deleteCode)
6166
+ }, {
6167
+ "code-block-panel-tool": vue.withCtx(({ id, data }) => [
6168
+ vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
6169
+ id,
6170
+ data
6171
+ })
6172
+ ]),
6173
+ _: 3
6174
+ }, 8, ["custom-error", "onEdit", "onRemove"])
6175
+ ]),
6176
+ _: 3
6177
+ }),
6178
+ vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$P, {
6179
+ key: 0,
6180
+ ref_key: "codeBlockEditor",
6181
+ ref: codeBlockEditor,
6182
+ disabled: !editable.value,
6183
+ content: vue.unref(codeConfig),
6184
+ slideType: _ctx.slideType,
6185
+ onSubmit: vue.unref(submitCodeBlockHandler)
6186
+ }, null, 8, ["disabled", "content", "slideType", "onSubmit"])) : vue.createCommentVNode("", true)
6187
+ ], 64);
6027
6188
  };
6028
6189
  }
6029
6190
  });
@@ -6036,11 +6197,13 @@
6036
6197
  props: {
6037
6198
  title: {},
6038
6199
  values: {},
6039
- disabled: { type: Boolean }
6200
+ disabled: { type: Boolean },
6201
+ slideType: {}
6040
6202
  },
6041
6203
  emits: ["submit"],
6042
- setup(__props, { expose: __expose, emit }) {
6204
+ setup(__props, { expose: __expose, emit: __emit }) {
6043
6205
  const props = __props;
6206
+ const emit = __emit;
6044
6207
  const services = vue.inject("services");
6045
6208
  const size = vue.computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
6046
6209
  const fomDrawer = vue.ref();
@@ -6065,7 +6228,7 @@
6065
6228
  }
6066
6229
  });
6067
6230
  return (_ctx, _cache) => {
6068
- return vue.openBlock(), vue.createBlock(vue.unref(form.MFormDrawer), {
6231
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.slideType === "box" ? vue.unref(form.MFormBox) : vue.unref(form.MFormDrawer)), {
6069
6232
  ref_key: "fomDrawer",
6070
6233
  ref: fomDrawer,
6071
6234
  "label-width": "80px",
@@ -6077,7 +6240,7 @@
6077
6240
  disabled: _ctx.disabled,
6078
6241
  onSubmit: submitHandler,
6079
6242
  onError: errorHandler
6080
- }, null, 8, ["title", "width", "config", "values", "disabled"]);
6243
+ }, null, 40, ["title", "width", "config", "values", "disabled"]);
6081
6244
  };
6082
6245
  }
6083
6246
  });
@@ -6094,13 +6257,14 @@
6094
6257
  },
6095
6258
  __name: "DataSourceList",
6096
6259
  emits: ["edit", "remove"],
6097
- setup(__props, { expose: __expose, emit }) {
6260
+ setup(__props, { expose: __expose, emit: __emit }) {
6261
+ const emit = __emit;
6098
6262
  const { depService, editorService, dataSourceService } = vue.inject("services") || {};
6099
6263
  const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
6100
6264
  const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
6101
- const dsDep = vue.computed(() => depService?.getTargets(DepTargetType.DATA_SOURCE) || {});
6102
- const dsMethodDep = vue.computed(() => depService?.getTargets(DepTargetType.DATA_SOURCE_METHOD) || {});
6103
- const dsCondDep = vue.computed(() => depService?.getTargets(DepTargetType.DATA_SOURCE_COND) || {});
6265
+ const dsDep = vue.computed(() => depService?.getTargets(dep.DepTargetType.DATA_SOURCE) || {});
6266
+ const dsMethodDep = vue.computed(() => depService?.getTargets(dep.DepTargetType.DATA_SOURCE_METHOD) || {});
6267
+ const dsCondDep = vue.computed(() => depService?.getTargets(dep.DepTargetType.DATA_SOURCE_COND) || {});
6104
6268
  const getKeyTreeConfig = (dep, type) => dep.keys.map((key) => ({ name: key, id: key, type: "key", isMethod: type === "method", isCond: type === "cond" }));
6105
6269
  const getNodeTreeConfig = (id, dep, type) => ({
6106
6270
  name: dep.name,
@@ -6120,9 +6284,9 @@
6120
6284
  };
6121
6285
  const list = vue.computed(
6122
6286
  () => dataSources.value.map((ds) => {
6123
- const dsDeps = dsDep.value[ds.id].deps;
6124
- const dsMethodDeps = dsMethodDep.value[ds.id].deps;
6125
- const dsCondDeps = dsCondDep.value[ds.id].deps;
6287
+ const dsDeps = dsDep.value[ds.id]?.deps || {};
6288
+ const dsMethodDeps = dsMethodDep.value[ds.id]?.deps || {};
6289
+ const dsCondDeps = dsCondDep.value[ds.id]?.deps || {};
6126
6290
  const children = [];
6127
6291
  mergeChildren(children, dsDeps);
6128
6292
  mergeChildren(children, dsMethodDeps, "method");
@@ -6244,6 +6408,9 @@
6244
6408
  name: "MEditorDataSourceListPanel"
6245
6409
  },
6246
6410
  __name: "DataSourceListPanel",
6411
+ props: {
6412
+ slideType: {}
6413
+ },
6247
6414
  setup(__props) {
6248
6415
  const { dataSourceService } = vue.inject("services") || {};
6249
6416
  const editDialog = vue.ref();
@@ -6278,7 +6445,7 @@
6278
6445
  dataSourceValues.value = {
6279
6446
  ...dataSourceService?.getDataSourceById(id)
6280
6447
  };
6281
- dialogTitle.value = `新增${dataSourceValues.value.title || ""}`;
6448
+ dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
6282
6449
  editDialog.value.show();
6283
6450
  };
6284
6451
  const removeHandler = (id) => {
@@ -6297,64 +6464,62 @@
6297
6464
  dataSourceList.value?.filter(val);
6298
6465
  };
6299
6466
  return (_ctx, _cache) => {
6300
- return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
6301
- default: vue.withCtx(() => [
6302
- vue.createElementVNode("div", _hoisted_1$d, [
6303
- vue.createVNode(_sfc_main$u, { onSearch: filterTextChangeHandler }),
6304
- editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicPopover), {
6305
- key: 0,
6306
- placement: "right"
6307
- }, {
6308
- reference: vue.withCtx(() => [
6309
- vue.createVNode(vue.unref(design.TMagicButton), {
6310
- type: "primary",
6311
- size: "small"
6312
- }, {
6313
- default: vue.withCtx(() => [
6314
- vue.createTextVNode("新增")
6315
- ]),
6316
- _: 1
6317
- })
6318
- ]),
6319
- default: vue.withCtx(() => [
6320
- vue.createElementVNode("div", _hoisted_2$a, [
6321
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(datasourceTypeList.value, (item, index) => {
6322
- return vue.openBlock(), vue.createBlock(_sfc_main$x, {
6323
- data: {
6324
- type: "button",
6325
- text: item.text,
6326
- handler: () => {
6327
- addHandler(item.type);
6328
- }
6329
- },
6330
- key: index
6331
- }, null, 8, ["data"]);
6332
- }), 128))
6333
- ])
6334
- ]),
6335
- _: 1
6336
- })) : vue.createCommentVNode("", true)
6337
- ]),
6338
- vue.createVNode(_sfc_main$o, {
6339
- onEdit: editHandler,
6340
- onRemove: removeHandler
6341
- }, {
6342
- "data-source-panel-tool": vue.withCtx(({ data }) => [
6343
- vue.renderSlot(_ctx.$slots, "data-source-panel-tool", { data })
6467
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
6468
+ vue.createVNode(vue.unref(design.TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
6469
+ default: vue.withCtx(() => [
6470
+ vue.createElementVNode("div", _hoisted_1$d, [
6471
+ vue.createVNode(_sfc_main$u, { onSearch: filterTextChangeHandler }),
6472
+ editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicPopover), {
6473
+ key: 0,
6474
+ placement: "right"
6475
+ }, {
6476
+ reference: vue.withCtx(() => [
6477
+ vue.createVNode(vue.unref(design.TMagicButton), {
6478
+ type: "primary",
6479
+ size: "small"
6480
+ }, {
6481
+ default: vue.withCtx(() => [
6482
+ vue.createTextVNode("新增")
6483
+ ]),
6484
+ _: 1
6485
+ })
6486
+ ]),
6487
+ default: vue.withCtx(() => [
6488
+ vue.createElementVNode("div", _hoisted_2$a, [
6489
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(datasourceTypeList.value, (item, index) => {
6490
+ return vue.openBlock(), vue.createBlock(_sfc_main$x, {
6491
+ data: {
6492
+ type: "button",
6493
+ text: item.text,
6494
+ handler: () => {
6495
+ addHandler(item.type);
6496
+ }
6497
+ },
6498
+ key: index
6499
+ }, null, 8, ["data"]);
6500
+ }), 128))
6501
+ ])
6502
+ ]),
6503
+ _: 1
6504
+ })) : vue.createCommentVNode("", true)
6344
6505
  ]),
6345
- _: 3
6346
- }),
6347
- vue.createVNode(_sfc_main$p, {
6348
- ref_key: "editDialog",
6349
- ref: editDialog,
6350
- disabled: !editable.value,
6351
- values: dataSourceValues.value,
6352
- title: dialogTitle.value,
6353
- onSubmit: submitDataSourceHandler
6354
- }, null, 8, ["disabled", "values", "title"])
6355
- ]),
6356
- _: 3
6357
- });
6506
+ vue.createVNode(_sfc_main$o, {
6507
+ onEdit: editHandler,
6508
+ onRemove: removeHandler
6509
+ })
6510
+ ]),
6511
+ _: 1
6512
+ }),
6513
+ vue.createVNode(_sfc_main$p, {
6514
+ ref_key: "editDialog",
6515
+ ref: editDialog,
6516
+ disabled: !editable.value,
6517
+ values: dataSourceValues.value,
6518
+ title: dialogTitle.value,
6519
+ slideType: _ctx.slideType,
6520
+ onSubmit: submitDataSourceHandler
6521
+ }, null, 8, ["disabled", "values", "title", "slideType"])
6522
+ ], 64);
6358
6523
  };
6359
6524
  }
6360
6525
  });
@@ -6388,9 +6553,9 @@
6388
6553
  indent: { default: 0 }
6389
6554
  },
6390
6555
  emits: ["node-dragstart", "node-dragleave", "node-dragend", "node-contextmenu", "node-mouseenter", "node-click"],
6391
- setup(__props, { emit }) {
6392
- const props = __props;
6556
+ setup(__props, { emit: __emit }) {
6393
6557
  const treeEmit = vue.inject("treeEmit");
6558
+ const props = __props;
6394
6559
  const nodeStatus = vue.computed(
6395
6560
  () => props.nodeStatusMap?.get(props.data.id) || {
6396
6561
  selected: false,
@@ -6500,7 +6665,8 @@
6500
6665
  emptyText: { default: "暂无数据" }
6501
6666
  },
6502
6667
  emits: ["node-dragover", "node-dragstart", "node-dragleave", "node-dragend", "node-contextmenu", "node-mouseenter", "node-click"],
6503
- setup(__props, { emit }) {
6668
+ setup(__props, { emit: __emit }) {
6669
+ const emit = __emit;
6504
6670
  vue.provide("treeEmit", emit);
6505
6671
  const handleDragOver = (event) => {
6506
6672
  emit("node-dragover", event);
@@ -6545,8 +6711,9 @@
6545
6711
  autoHide: { type: Boolean, default: true }
6546
6712
  },
6547
6713
  emits: ["hide", "show", "mouseenter"],
6548
- setup(__props, { expose: __expose, emit }) {
6714
+ setup(__props, { expose: __expose, emit: __emit }) {
6549
6715
  const props = __props;
6716
+ const emit = __emit;
6550
6717
  const menu = vue.ref();
6551
6718
  const buttons = vue.ref();
6552
6719
  const subMenu = vue.ref();
@@ -6814,8 +6981,9 @@
6814
6981
  layerContentMenu: {}
6815
6982
  },
6816
6983
  emits: ["collapse-all"],
6817
- setup(__props, { expose: __expose, emit }) {
6984
+ setup(__props, { expose: __expose, emit: __emit }) {
6818
6985
  const props = __props;
6986
+ const emit = __emit;
6819
6987
  const services = vue.inject("services");
6820
6988
  const menu = vue.ref();
6821
6989
  const node = vue.computed(() => services?.editorService.get("node"));
@@ -7098,6 +7266,9 @@
7098
7266
  return;
7099
7267
  removeStatusClass(dragState.container);
7100
7268
  if (node && dragState.dragOverNodeId && dragState.dropType && services) {
7269
+ if (dragState.dragOverNodeId === node.id) {
7270
+ return;
7271
+ }
7101
7272
  const targetInfo = services.editorService.getNodeInfo(dragState.dragOverNodeId, false);
7102
7273
  const targetNode = targetInfo.node;
7103
7274
  let targetParent = targetInfo.parent;
@@ -7333,7 +7504,7 @@
7333
7504
  };
7334
7505
  };
7335
7506
 
7336
- const createPageNodeStatus = (services, pageId) => {
7507
+ const createPageNodeStatus = (services, pageId, initalLayerNodeStatus) => {
7337
7508
  const map = /* @__PURE__ */ new Map();
7338
7509
  map.set(pageId, {
7339
7510
  visible: true,
@@ -7343,12 +7514,15 @@
7343
7514
  });
7344
7515
  services?.editorService.getNodeById(pageId)?.items.forEach(
7345
7516
  (node) => traverseNode(node, (node2) => {
7346
- map.set(node2.id, {
7347
- visible: true,
7348
- expand: false,
7349
- selected: false,
7350
- draggable: true
7351
- });
7517
+ map.set(
7518
+ node2.id,
7519
+ initalLayerNodeStatus?.get(node2.id) || {
7520
+ visible: true,
7521
+ expand: false,
7522
+ selected: false,
7523
+ draggable: true
7524
+ }
7525
+ );
7352
7526
  })
7353
7527
  );
7354
7528
  return map;
@@ -7360,12 +7534,12 @@
7360
7534
  () => page.value ? nodeStatusMaps.value.get(page.value.id) : /* @__PURE__ */ new Map()
7361
7535
  );
7362
7536
  vue.watch(
7363
- () => page.value?.id,
7364
- (pageId) => {
7365
- if (!pageId || nodeStatusMaps.value.has(pageId)) {
7537
+ page,
7538
+ (page2) => {
7539
+ if (!page2) {
7366
7540
  return;
7367
7541
  }
7368
- nodeStatusMaps.value.set(pageId, createPageNodeStatus(services, pageId));
7542
+ nodeStatusMaps.value.set(page2.id, createPageNodeStatus(services, page2.id, nodeStatusMaps.value.get(page2.id)));
7369
7543
  },
7370
7544
  {
7371
7545
  immediate: true
@@ -7638,11 +7812,14 @@
7638
7812
  class: "m-editor-sidebar"
7639
7813
  };
7640
7814
  const _hoisted_2$6 = { class: "m-editor-sidebar-header" };
7641
- const _hoisted_3$3 = ["onClick"];
7815
+ const _hoisted_3$3 = ["onClick", "onDragend"];
7642
7816
  const _hoisted_4$3 = {
7643
7817
  key: 1,
7644
7818
  class: "magic-editor-tab-panel-title"
7645
7819
  };
7820
+ const _hoisted_5$3 = { class: "m-editor-float-box-list" };
7821
+ const _hoisted_6$2 = ["onClick"];
7822
+ const _hoisted_7 = { class: "m-editor-float-box-body" };
7646
7823
  const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
7647
7824
  ...{
7648
7825
  name: "MEditorSidebar"
@@ -7654,6 +7831,7 @@
7654
7831
  },
7655
7832
  setup(__props, { expose: __expose }) {
7656
7833
  const props = __props;
7834
+ const services = vue.inject("services");
7657
7835
  const activeTabName = vue.ref(props.data?.status);
7658
7836
  const getItemConfig = (data) => {
7659
7837
  const map = {
@@ -7682,7 +7860,12 @@
7682
7860
  icon: iconsVue.EditPen,
7683
7861
  text: "代码编辑",
7684
7862
  component: _sfc_main$q,
7685
- slots: {}
7863
+ slots: {},
7864
+ boxComponentConfig: {
7865
+ props: {
7866
+ slideType: "box"
7867
+ }
7868
+ }
7686
7869
  },
7687
7870
  "data-source": {
7688
7871
  $key: "data-source",
@@ -7690,7 +7873,12 @@
7690
7873
  icon: iconsVue.Coin,
7691
7874
  text: "数据源",
7692
7875
  component: _sfc_main$n,
7693
- slots: {}
7876
+ slots: {},
7877
+ boxComponentConfig: {
7878
+ props: {
7879
+ slideType: "box"
7880
+ }
7881
+ }
7694
7882
  }
7695
7883
  };
7696
7884
  return typeof data === "string" ? map[data] : data;
@@ -7702,119 +7890,182 @@
7702
7890
  activeTabName.value = status || "0";
7703
7891
  }
7704
7892
  );
7893
+ const slideKeys = vue.computed(() => sideBarItems.value.map((sideBarItem) => sideBarItem.$key));
7894
+ const { showFloatBox, closeFloatBox, dragstartHandler, dragendHandler, floatBoxStates, floatBox, showingBoxKeys } = useFloatBox(slideKeys);
7895
+ vue.watch(
7896
+ () => showingBoxKeys.value.length,
7897
+ () => {
7898
+ const isActiveTabShow = showingBoxKeys.value.some(
7899
+ (key) => activeTabName.value === sideBarItems.value.find((v) => v.$key === key)?.text
7900
+ );
7901
+ if (!isActiveTabShow && activeTabName.value)
7902
+ return;
7903
+ const nextSlideBarItem = sideBarItems.value.find((sideBarItem) => !showingBoxKeys.value.includes(sideBarItem.$key));
7904
+ if (!nextSlideBarItem) {
7905
+ activeTabName.value = "";
7906
+ services?.uiService.set("hideSlideBar", true);
7907
+ return;
7908
+ }
7909
+ services?.uiService.set("hideSlideBar", false);
7910
+ activeTabName.value = nextSlideBarItem?.text;
7911
+ }
7912
+ );
7705
7913
  __expose({
7706
7914
  activeTabName
7707
7915
  });
7708
7916
  return (_ctx, _cache) => {
7709
- return _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
7710
- vue.createElementVNode("div", _hoisted_2$6, [
7917
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
7918
+ _ctx.data.type === "tabs" && _ctx.data.items.length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
7919
+ vue.createElementVNode("div", _hoisted_2$6, [
7920
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
7921
+ return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
7922
+ class: vue.normalizeClass(["m-editor-sidebar-header-item", { "is-active": activeTabName.value === config.text }]),
7923
+ key: config.$key ?? index,
7924
+ onClick: ($event) => activeTabName.value = config.text || `${index}`,
7925
+ draggable: "true",
7926
+ onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
7927
+ (...args) => vue.unref(dragstartHandler) && vue.unref(dragstartHandler)(...args)),
7928
+ onDragend: ($event) => vue.unref(dragendHandler)(config.$key, $event)
7929
+ }, [
7930
+ config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
7931
+ key: 0,
7932
+ icon: config.icon
7933
+ }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
7934
+ config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$3, vue.toDisplayString(config.text), 1)) : vue.createCommentVNode("", true)
7935
+ ], 42, _hoisted_3$3)), [
7936
+ [vue.vShow, !vue.unref(floatBoxStates)?.get(config.$key)?.status]
7937
+ ]);
7938
+ }), 128))
7939
+ ]),
7711
7940
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
7712
- return vue.openBlock(), vue.createElementBlock("div", {
7713
- class: vue.normalizeClass(["m-editor-sidebar-header-item", { "is-active": activeTabName.value === config.text }]),
7714
- key: config.$key ?? index,
7715
- onClick: ($event) => activeTabName.value = config.text || `${index}`
7941
+ return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
7942
+ class: "m-editor-sidebar-content",
7943
+ key: config.$key ?? index
7716
7944
  }, [
7717
- config.icon ? (vue.openBlock(), vue.createBlock(_sfc_main$N, {
7718
- key: 0,
7719
- icon: config.icon
7720
- }, null, 8, ["icon"])) : vue.createCommentVNode("", true),
7721
- config.text ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$3, vue.toDisplayString(config.text), 1)) : vue.createCommentVNode("", true)
7722
- ], 10, _hoisted_3$3);
7945
+ config && !vue.unref(floatBoxStates)?.get(config.$key)?.status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({ key: 0 }, config.props || {}, vue.toHandlers(config?.listeners || {})), vue.createSlots({ _: 2 }, [
7946
+ config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
7947
+ name: "component-list-panel-header",
7948
+ fn: vue.withCtx(() => [
7949
+ config.$key === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : config.slots?.componentListPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.componentListPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
7950
+ ]),
7951
+ key: "0"
7952
+ } : void 0,
7953
+ config.$key === "component-list" || config.slots?.componentListItem ? {
7954
+ name: "component-list-item",
7955
+ fn: vue.withCtx(({ component }) => [
7956
+ config.$key === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-item", {
7957
+ key: 0,
7958
+ component
7959
+ }) : config.slots?.componentListItem ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.componentListItem), {
7960
+ key: 1,
7961
+ component
7962
+ }, null, 8, ["component"])) : vue.createCommentVNode("", true)
7963
+ ]),
7964
+ key: "1"
7965
+ } : void 0,
7966
+ config.$key === "layer" || config.slots?.layerPanelHeader ? {
7967
+ name: "layer-panel-header",
7968
+ fn: vue.withCtx(() => [
7969
+ config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : config.slots?.layerPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
7970
+ ]),
7971
+ key: "2"
7972
+ } : void 0,
7973
+ config.$key === "code-block" || config.slots?.codeBlockPanelHeader ? {
7974
+ name: "code-block-panel-header",
7975
+ fn: vue.withCtx(() => [
7976
+ config.$key === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : config.slots?.codeBlockPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.codeBlockPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
7977
+ ]),
7978
+ key: "3"
7979
+ } : void 0,
7980
+ config.$key === "code-block" || config.slots?.codeBlockPanelTool ? {
7981
+ name: "code-block-panel-tool",
7982
+ fn: vue.withCtx(({ id, data }) => [
7983
+ config.$key === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
7984
+ key: 0,
7985
+ id,
7986
+ data
7987
+ }) : config.slots?.codeBlockPanelTool ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.codeBlockPanelTool), { key: 1 })) : vue.createCommentVNode("", true)
7988
+ ]),
7989
+ key: "4"
7990
+ } : void 0,
7991
+ config.$key === "layer" || config.slots?.layerNodeContent ? {
7992
+ name: "layer-node-content",
7993
+ fn: vue.withCtx(({ data: nodeData }) => [
7994
+ config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-content", {
7995
+ key: 0,
7996
+ data: nodeData
7997
+ }) : config.slots?.layerNodeContent ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerNodeContent), {
7998
+ key: 1,
7999
+ data: nodeData
8000
+ }, null, 8, ["data"])) : vue.createCommentVNode("", true)
8001
+ ]),
8002
+ key: "5"
8003
+ } : void 0,
8004
+ config.$key === "layer" || config.slots?.layerNodeTool ? {
8005
+ name: "layer-node-tool",
8006
+ fn: vue.withCtx(({ data: nodeData }) => [
8007
+ config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-tool", {
8008
+ key: 0,
8009
+ data: nodeData
8010
+ }) : config.slots?.layerNodeTool ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerNodeTool), {
8011
+ key: 1,
8012
+ data: nodeData
8013
+ }, null, 8, ["data"])) : vue.createCommentVNode("", true)
8014
+ ]),
8015
+ key: "6"
8016
+ } : void 0,
8017
+ config.$key === "data-source" || config.slots?.codeBlockPanelTool ? {
8018
+ name: "data-source-panel-tool",
8019
+ fn: vue.withCtx(({ data }) => [
8020
+ config.$key === "data-source" ? vue.renderSlot(_ctx.$slots, "data-source-panel-tool", {
8021
+ key: 0,
8022
+ data
8023
+ }) : config.slots?.DataSourcePanelTool ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.DataSourcePanelTool), { key: 1 })) : vue.createCommentVNode("", true)
8024
+ ]),
8025
+ key: "7"
8026
+ } : void 0
8027
+ ]), 1040)) : vue.createCommentVNode("", true)
8028
+ ])), [
8029
+ [vue.vShow, activeTabName.value === config.text]
8030
+ ]);
7723
8031
  }), 128))
7724
- ]),
7725
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
7726
- return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
7727
- class: "m-editor-sidebar-content",
7728
- key: config.$key ?? index
7729
- }, [
7730
- config ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({ key: 0 }, config.props || {}, vue.toHandlers(config?.listeners || {})), vue.createSlots({ _: 2 }, [
7731
- config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
7732
- name: "component-list-panel-header",
7733
- fn: vue.withCtx(() => [
7734
- config.$key === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : config.slots?.componentListPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.componentListPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
7735
- ]),
7736
- key: "0"
7737
- } : void 0,
7738
- config.$key === "component-list" || config.slots?.componentListItem ? {
7739
- name: "component-list-item",
7740
- fn: vue.withCtx(({ component }) => [
7741
- config.$key === "component-list" ? vue.renderSlot(_ctx.$slots, "component-list-item", {
7742
- key: 0,
7743
- component
7744
- }) : config.slots?.componentListItem ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.componentListItem), {
7745
- key: 1,
7746
- component
7747
- }, null, 8, ["component"])) : vue.createCommentVNode("", true)
7748
- ]),
7749
- key: "1"
7750
- } : void 0,
7751
- config.$key === "layer" || config.slots?.layerPanelHeader ? {
7752
- name: "layer-panel-header",
7753
- fn: vue.withCtx(() => [
7754
- config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : config.slots?.layerPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
7755
- ]),
7756
- key: "2"
7757
- } : void 0,
7758
- config.$key === "code-block" || config.slots?.codeBlockPanelHeader ? {
7759
- name: "code-block-panel-header",
7760
- fn: vue.withCtx(() => [
7761
- config.$key === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : config.slots?.codeBlockPanelHeader ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.codeBlockPanelHeader), { key: 1 })) : vue.createCommentVNode("", true)
7762
- ]),
7763
- key: "3"
7764
- } : void 0,
7765
- config.$key === "code-block" || config.slots?.codeBlockPanelTool ? {
7766
- name: "code-block-panel-tool",
7767
- fn: vue.withCtx(({ id, data }) => [
7768
- config.$key === "code-block" ? vue.renderSlot(_ctx.$slots, "code-block-panel-tool", {
7769
- key: 0,
7770
- id,
7771
- data
7772
- }) : config.slots?.codeBlockPanelTool ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.codeBlockPanelTool), { key: 1 })) : vue.createCommentVNode("", true)
7773
- ]),
7774
- key: "4"
7775
- } : void 0,
7776
- config.$key === "layer" || config.slots?.layerNodeContent ? {
7777
- name: "layer-node-content",
7778
- fn: vue.withCtx(({ data: nodeData }) => [
7779
- config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-content", {
7780
- key: 0,
7781
- data: nodeData
7782
- }) : config.slots?.layerNodeContent ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerNodeContent), {
7783
- key: 1,
7784
- data: nodeData
7785
- }, null, 8, ["data"])) : vue.createCommentVNode("", true)
7786
- ]),
7787
- key: "5"
7788
- } : void 0,
7789
- config.$key === "layer" || config.slots?.layerNodeTool ? {
7790
- name: "layer-node-tool",
7791
- fn: vue.withCtx(({ data: nodeData }) => [
7792
- config.$key === "layer" ? vue.renderSlot(_ctx.$slots, "layer-node-tool", {
7793
- key: 0,
7794
- data: nodeData
7795
- }) : config.slots?.layerNodeTool ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.layerNodeTool), {
7796
- key: 1,
7797
- data: nodeData
7798
- }, null, 8, ["data"])) : vue.createCommentVNode("", true)
7799
- ]),
7800
- key: "6"
7801
- } : void 0,
7802
- config.$key === "data-source" || config.slots?.codeBlockPanelTool ? {
7803
- name: "data-source-panel-tool",
7804
- fn: vue.withCtx(({ data }) => [
7805
- config.$key === "data-source" ? vue.renderSlot(_ctx.$slots, "data-source-panel-tool", {
7806
- key: 0,
7807
- data
7808
- }) : config.slots?.DataSourcePanelTool ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.slots.DataSourcePanelTool), { key: 1 })) : vue.createCommentVNode("", true)
7809
- ]),
7810
- key: "7"
7811
- } : void 0
7812
- ]), 1040)) : vue.createCommentVNode("", true)
7813
- ])), [
7814
- [vue.vShow, activeTabName.value === config.text]
7815
- ]);
7816
- }), 128))
7817
- ])) : vue.createCommentVNode("", true);
8032
+ ])) : vue.createCommentVNode("", true),
8033
+ (vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
8034
+ vue.createElementVNode("div", _hoisted_5$3, [
8035
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
8036
+ return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
8037
+ key: config.$key ?? index,
8038
+ ref_for: true,
8039
+ ref_key: "floatBox",
8040
+ ref: floatBox,
8041
+ class: vue.normalizeClass(["m-editor-float-box", `m-editor-float-box-${config.$key}`]),
8042
+ style: vue.normalizeStyle({
8043
+ left: `${vue.unref(floatBoxStates)?.get(config.$key)?.left}px`,
8044
+ top: `${vue.unref(floatBoxStates)?.get(config.$key)?.top}px`,
8045
+ zIndex: vue.unref(floatBoxStates)?.get(config.$key)?.zIndex
8046
+ })
8047
+ }, [
8048
+ vue.createElementVNode("div", {
8049
+ class: vue.normalizeClass(["m-editor-float-box-header", `m-editor-float-box-header-${config.$key}`]),
8050
+ onClick: ($event) => vue.unref(showFloatBox)(config.$key)
8051
+ }, [
8052
+ vue.createElementVNode("div", null, vue.toDisplayString(config.text), 1),
8053
+ vue.createVNode(_sfc_main$N, {
8054
+ class: "m-editor-float-box-close",
8055
+ icon: vue.unref(iconsVue.Close),
8056
+ onClick: vue.withModifiers(($event) => vue.unref(closeFloatBox)(config.$key), ["stop"])
8057
+ }, null, 8, ["icon", "onClick"])
8058
+ ], 10, _hoisted_6$2),
8059
+ vue.createElementVNode("div", _hoisted_7, [
8060
+ config && vue.unref(floatBoxStates)?.get(config.$key)?.status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.boxComponentConfig?.component || config.component), vue.mergeProps({ key: 0 }, config.boxComponentConfig?.props || config.props || {}, vue.toHandlers(config?.listeners || {})), null, 16)) : vue.createCommentVNode("", true)
8061
+ ])
8062
+ ], 6)), [
8063
+ [vue.vShow, vue.unref(floatBoxStates)?.get(config.$key)?.status]
8064
+ ]);
8065
+ }), 128))
8066
+ ])
8067
+ ]))
8068
+ ], 64);
7818
8069
  };
7819
8070
  }
7820
8071
  });
@@ -7959,8 +8210,9 @@
7959
8210
  pos: {}
7960
8211
  },
7961
8212
  emits: ["scroll"],
7962
- setup(__props, { emit }) {
8213
+ setup(__props, { emit: __emit }) {
7963
8214
  const props = __props;
8215
+ const emit = __emit;
7964
8216
  const bar = vue.ref();
7965
8217
  const thumb = vue.ref();
7966
8218
  const thumbSize = vue.computed(() => props.size * (props.size / props.scrollSize));
@@ -8162,7 +8414,9 @@
8162
8414
  showGuides: true,
8163
8415
  showRule: true,
8164
8416
  propsPanelSize: "small",
8165
- showAddPageButton: true
8417
+ showAddPageButton: true,
8418
+ floatBox: /* @__PURE__ */ new Map(),
8419
+ hideSlideBar: false
8166
8420
  });
8167
8421
  class Ui extends BaseService {
8168
8422
  constructor() {
@@ -8202,6 +8456,19 @@
8202
8456
  }
8203
8457
  return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
8204
8458
  }
8459
+ async setFloatBox(keys) {
8460
+ const map = state.floatBox;
8461
+ for (const key of keys) {
8462
+ if (map.get(key))
8463
+ continue;
8464
+ map.set(key, {
8465
+ status: false,
8466
+ zIndex: 99,
8467
+ top: 0,
8468
+ left: 0
8469
+ });
8470
+ }
8471
+ }
8205
8472
  resetState() {
8206
8473
  this.set("showSrc", false);
8207
8474
  this.set("uiSelectMode", false);
@@ -8414,8 +8681,9 @@
8414
8681
  pinned: { type: Boolean }
8415
8682
  },
8416
8683
  emits: ["close", "update:pinned", "change"],
8417
- setup(__props, { emit }) {
8684
+ setup(__props, { emit: __emit }) {
8418
8685
  const props = __props;
8686
+ const emit = __emit;
8419
8687
  const pinHandler = () => {
8420
8688
  emit("update:pinned", !props.pinned);
8421
8689
  };
@@ -9478,254 +9746,41 @@
9478
9746
  }
9479
9747
  const componentListService = new ComponentList();
9480
9748
 
9481
- class Target extends events.EventEmitter {
9482
- /**
9483
- * 如何识别目标
9484
- */
9485
- isTarget;
9486
- /**
9487
- * 目标id,不可重复
9488
- * 例如目标是代码块,则为代码块id
9489
- */
9490
- id;
9491
- /**
9492
- * 目标名称,用于显示在依赖列表中
9493
- */
9494
- name;
9495
- /**
9496
- * 不同的目标可以进行分类,例如代码块,数据源可以为两个不同的type
9497
- */
9498
- type = DepTargetType.DEFAULT;
9499
- /**
9500
- * 依赖详情
9501
- * 实例:{ 'node_id': { name: 'node_name', keys: [ created, mounted ] } }
9502
- */
9503
- deps = vue.reactive({});
9504
- constructor(options) {
9505
- super();
9506
- this.isTarget = options.isTarget;
9507
- this.id = options.id;
9508
- this.name = options.name;
9509
- if (options.type) {
9510
- this.type = options.type;
9511
- }
9512
- }
9513
- /**
9514
- * 更新依赖
9515
- * @param node 节点配置
9516
- * @param key 哪个key配置了这个目标的id
9517
- */
9518
- updateDep(node, key) {
9519
- const dep = this.deps[node.id] || {
9520
- name: node.name,
9521
- keys: []
9522
- };
9523
- if (node.name) {
9524
- dep.name = node.name;
9525
- }
9526
- this.deps[node.id] = dep;
9527
- if (dep.keys.indexOf(key) === -1) {
9528
- dep.keys.push(key);
9529
- }
9530
- this.emit("change");
9531
- }
9532
- /**
9533
- * 删除依赖
9534
- * @param node 哪个节点的依赖需要移除,如果为空,则移除所有依赖
9535
- * @param key 节点下哪个key需要移除,如果为空,则移除改节点下的所有依赖key
9536
- * @returns void
9537
- */
9538
- removeDep(node, key) {
9539
- if (!node) {
9540
- Object.keys(this.deps).forEach((depKey) => {
9541
- delete this.deps[depKey];
9542
- });
9543
- this.emit("change");
9544
- return;
9545
- }
9546
- const dep = this.deps[node.id];
9547
- if (!dep)
9548
- return;
9549
- if (key) {
9550
- const index = dep.keys.indexOf(key);
9551
- dep.keys.splice(index, 1);
9552
- if (dep.keys.length === 0) {
9553
- delete this.deps[node.id];
9554
- }
9555
- } else {
9556
- delete this.deps[node.id];
9557
- }
9558
- this.emit("change");
9559
- }
9560
- /**
9561
- * 判断指定节点下的指定key是否存在在依赖列表中
9562
- * @param node 哪个节点
9563
- * @param key 哪个key
9564
- * @returns boolean
9565
- */
9566
- hasDep(node, key) {
9567
- const dep = this.deps[node.id];
9568
- return Boolean(dep?.keys.find((d) => d === key));
9749
+ class Dep extends BaseService {
9750
+ watcher = new dep.Watcher({ initialTargets: vue.reactive({}) });
9751
+ removeTargets(type = dep.DepTargetType.DEFAULT) {
9752
+ this.watcher.removeTargets(type);
9753
+ this.emit("remove-target");
9569
9754
  }
9570
- destroy() {
9571
- this.removeAllListeners();
9755
+ getTargets(type = dep.DepTargetType.DEFAULT) {
9756
+ return this.watcher.getTargets(type);
9572
9757
  }
9573
- }
9574
- class Watcher extends events.EventEmitter {
9575
- targets = vue.reactive({});
9576
- /**
9577
- * 获取指定类型中的所有target
9578
- * @param type 分类
9579
- * @returns Target[]
9580
- */
9581
- getTargets(type = DepTargetType.DEFAULT) {
9582
- return this.targets[type] || {};
9758
+ getTarget(id) {
9759
+ return this.watcher.getTarget(id);
9583
9760
  }
9584
- /**
9585
- * 添加新的目标
9586
- * @param target Target
9587
- */
9588
9761
  addTarget(target) {
9589
- const targets = this.getTargets(target.type) || {};
9590
- this.targets[target.type] = targets;
9591
- targets[target.id] = target;
9762
+ this.watcher.addTarget(target);
9592
9763
  this.emit("add-target", target);
9593
9764
  }
9594
- /**
9595
- * 获取指定id的target
9596
- * @param id target id
9597
- * @returns Target
9598
- */
9599
- getTarget(id) {
9600
- const allTargets = Object.values(this.targets);
9601
- for (const targets of allTargets) {
9602
- if (targets[id]) {
9603
- return targets[id];
9604
- }
9605
- }
9606
- }
9607
- /**
9608
- * 判断是否存在指定id的target
9609
- * @param id target id
9610
- * @returns boolean
9611
- */
9612
- hasTarget(id) {
9613
- const allTargets = Object.values(this.targets);
9614
- for (const targets of allTargets) {
9615
- if (targets[id]) {
9616
- return true;
9617
- }
9618
- }
9619
- return false;
9620
- }
9621
- /**
9622
- * 删除指定id的target
9623
- * @param id target id
9624
- */
9625
9765
  removeTarget(id) {
9626
- const allTargets = Object.values(this.targets);
9627
- for (const targets of allTargets) {
9628
- if (targets[id]) {
9629
- targets[id].destroy();
9630
- delete targets[id];
9631
- }
9632
- }
9633
- this.emit("remove-target");
9634
- }
9635
- /**
9636
- * 删除指定分类的所有target
9637
- * @param type 分类
9638
- * @returns void
9639
- */
9640
- removeTargets(type = DepTargetType.DEFAULT) {
9641
- const targets = this.targets[type];
9642
- if (!targets)
9643
- return;
9644
- for (const target of Object.values(targets)) {
9645
- target.destroy();
9646
- }
9647
- delete this.targets[type];
9766
+ this.watcher.removeTarget(id);
9648
9767
  this.emit("remove-target");
9649
9768
  }
9650
- /**
9651
- * 删除所有target
9652
- */
9653
9769
  clearTargets() {
9654
- Object.keys(this.targets).forEach((key) => {
9655
- delete this.targets[key];
9656
- });
9770
+ this.watcher.clearTargets();
9657
9771
  }
9658
- /**
9659
- * 收集依赖
9660
- * @param nodes 需要收集的节点
9661
- * @param deep 是否需要收集子节点
9662
- */
9663
9772
  collect(nodes, deep = false) {
9664
- Object.values(this.targets).forEach((targets) => {
9665
- Object.values(targets).forEach((target) => {
9666
- nodes.forEach((node) => {
9667
- target.removeDep(node);
9668
- this.collectItem(node, target, deep);
9669
- });
9670
- });
9671
- });
9773
+ this.watcher.collect(nodes, deep);
9672
9774
  this.emit("collected", nodes, deep);
9673
9775
  }
9674
- /**
9675
- * 清除依赖
9676
- * @param nodes 需要清除依赖的节点
9677
- */
9678
9776
  clear(nodes) {
9679
- const clearedItemsNodeIds = [];
9680
- Object.values(this.targets).forEach((targets) => {
9681
- Object.values(targets).forEach((target) => {
9682
- if (nodes) {
9683
- nodes.forEach((node) => {
9684
- target.removeDep(node);
9685
- if (Array.isArray(node.items) && node.items.length && !clearedItemsNodeIds.includes(node.id)) {
9686
- clearedItemsNodeIds.push(node.id);
9687
- this.clear(node.items);
9688
- }
9689
- });
9690
- } else {
9691
- target.removeDep();
9692
- }
9693
- });
9694
- });
9777
+ return this.watcher.clear(nodes);
9695
9778
  }
9696
- collectItem(node, target, deep = false) {
9697
- const collectTarget = (config, prop = "") => {
9698
- const doCollect = (key, value) => {
9699
- const keyIsItems = key === "items";
9700
- const fullKey = prop ? `${prop}.${key}` : key;
9701
- if (target.isTarget(fullKey, value)) {
9702
- target.updateDep(node, fullKey);
9703
- this.emit("update-dep", node, fullKey);
9704
- } else if (!keyIsItems && Array.isArray(value)) {
9705
- value.forEach((item, index) => {
9706
- if (utils.isObject(item)) {
9707
- collectTarget(item, `${fullKey}.${index}`);
9708
- }
9709
- });
9710
- } else if (utils.isObject(value)) {
9711
- collectTarget(value, fullKey);
9712
- }
9713
- if (keyIsItems && deep && Array.isArray(value)) {
9714
- value.forEach((child) => {
9715
- this.collectItem(child, target, deep);
9716
- });
9717
- }
9718
- };
9719
- Object.entries(config).forEach(([key, value]) => {
9720
- if (typeof value === "undefined" || value === "")
9721
- return;
9722
- doCollect(key, value);
9723
- });
9724
- };
9725
- collectTarget(node);
9779
+ hasTarget(id) {
9780
+ return this.watcher.hasTarget(id);
9726
9781
  }
9727
9782
  }
9728
- const depService = new Watcher();
9783
+ const depService = new Dep();
9729
9784
 
9730
9785
  let eventMap = vue.reactive({});
9731
9786
  let methodMap = vue.reactive({});
@@ -9949,61 +10004,6 @@
9949
10004
  codeOptions: () => ({})
9950
10005
  };
9951
10006
 
9952
- const createCodeBlockTarget = (id, codeBlock) => new Target({
9953
- type: DepTargetType.CODE_BLOCK,
9954
- id,
9955
- name: codeBlock.name,
9956
- isTarget: (key, value) => {
9957
- if (id === value) {
9958
- return true;
9959
- }
9960
- if (value?.hookType === schema.HookType.CODE && !lodashEs.isEmpty(value.hookData)) {
9961
- const index = value.hookData.findIndex((item) => item.codeId === id);
9962
- return Boolean(index > -1);
9963
- }
9964
- return false;
9965
- }
9966
- });
9967
- const createDataSourceTarget = (id) => new Target({
9968
- type: DepTargetType.DATA_SOURCE,
9969
- id,
9970
- isTarget: (key, value) => {
9971
- if (value?.isBindDataSource && value.dataSourceId || typeof value === "string" && value.includes(`${id}`)) {
9972
- return true;
9973
- }
9974
- if (!Array.isArray(value) || typeof value[0] !== "string") {
9975
- return false;
9976
- }
9977
- const [prefixId] = value;
9978
- const prefixIndex = prefixId.indexOf(utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);
9979
- if (prefixIndex === -1) {
9980
- return false;
9981
- }
9982
- const dsId = prefixId.substring(prefixIndex + utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length);
9983
- return dsId === id && Boolean(dataSourceService.getDataSourceById(id));
9984
- }
9985
- });
9986
- const createDataSourceCondTarget = (id) => new Target({
9987
- type: DepTargetType.DATA_SOURCE_COND,
9988
- id,
9989
- isTarget: (key, value) => {
9990
- if (!Array.isArray(value) || value[0] !== id || !`${key}`.startsWith("displayConds"))
9991
- return false;
9992
- const ds = dataSourceService.getDataSourceById(id);
9993
- return Boolean(ds?.fields?.find((field) => field.name === value[1]));
9994
- }
9995
- });
9996
- const createDataSourceMethodTarget = (id) => new Target({
9997
- type: DepTargetType.DATA_SOURCE_METHOD,
9998
- id,
9999
- isTarget: (key, value) => {
10000
- if (!Array.isArray(value) || value[0] !== id)
10001
- return false;
10002
- const ds = dataSourceService.getDataSourceById(id);
10003
- return Boolean(ds?.methods?.find((method) => method.name === value[1]));
10004
- }
10005
- });
10006
-
10007
10007
  const initServiceState = (props, {
10008
10008
  editorService,
10009
10009
  historyService,
@@ -10176,13 +10176,13 @@
10176
10176
  const root = editorService.get("root");
10177
10177
  if (!root)
10178
10178
  return;
10179
- if (target.type === DepTargetType.DATA_SOURCE) {
10179
+ if (target.type === dep.DepTargetType.DATA_SOURCE) {
10180
10180
  if (!root.dataSourceDeps) {
10181
10181
  root.dataSourceDeps = {};
10182
10182
  }
10183
10183
  root.dataSourceDeps[target.id] = target.deps;
10184
10184
  }
10185
- if (target.type === DepTargetType.DATA_SOURCE_COND) {
10185
+ if (target.type === dep.DepTargetType.DATA_SOURCE_COND) {
10186
10186
  if (!root.dataSourceCondDeps) {
10187
10187
  root.dataSourceCondDeps = {};
10188
10188
  }
@@ -10209,9 +10209,9 @@
10209
10209
  depService.on("dep-update", depUpdateHandler);
10210
10210
  depService.on("collected", collectedHandler);
10211
10211
  const initDataSourceDepTarget = (ds) => {
10212
- depService.addTarget(createDataSourceTarget(ds.id));
10213
- depService.addTarget(createDataSourceMethodTarget(ds.id));
10214
- depService.addTarget(createDataSourceCondTarget(ds.id));
10212
+ depService.addTarget(dep.createDataSourceTarget(ds, vue.reactive({})));
10213
+ depService.addTarget(dep.createDataSourceMethodTarget(ds, vue.reactive({})));
10214
+ depService.addTarget(dep.createDataSourceCondTarget(ds, vue.reactive({})));
10215
10215
  };
10216
10216
  const rootChangeHandler = async (value, preValue) => {
10217
10217
  if (!value)
@@ -10220,9 +10220,9 @@
10220
10220
  value.dataSources = value.dataSources || [];
10221
10221
  codeBlockService.setCodeDsl(value.codeBlocks);
10222
10222
  dataSourceService.set("dataSources", value.dataSources);
10223
- depService.removeTargets(DepTargetType.CODE_BLOCK);
10223
+ depService.removeTargets(dep.DepTargetType.CODE_BLOCK);
10224
10224
  Object.entries(value.codeBlocks).forEach(([id, code]) => {
10225
- depService.addTarget(createCodeBlockTarget(id, code));
10225
+ depService.addTarget(dep.createCodeBlockTarget(id, code));
10226
10226
  });
10227
10227
  value.dataSources.forEach((ds) => {
10228
10228
  initDataSourceDepTarget(ds);
@@ -10273,7 +10273,7 @@
10273
10273
  depService.getTarget(id).name = codeBlock.name;
10274
10274
  return;
10275
10275
  }
10276
- depService.addTarget(createCodeBlockTarget(id, codeBlock));
10276
+ depService.addTarget(dep.createCodeBlockTarget(id, codeBlock));
10277
10277
  };
10278
10278
  const codeBlockRemoveHandler = (id) => {
10279
10279
  depService.removeTarget(id);
@@ -10286,7 +10286,7 @@
10286
10286
  };
10287
10287
  const dataSourceUpdateHandler = (config) => {
10288
10288
  const root = editorService.get("root");
10289
- const targets = depService.getTargets(DepTargetType.DATA_SOURCE);
10289
+ const targets = depService.getTargets(dep.DepTargetType.DATA_SOURCE);
10290
10290
  const nodes = utils.getNodes(Object.keys(targets[config.id].deps), root?.items);
10291
10291
  upateNodeWhenDataSourceChange(nodes);
10292
10292
  };
@@ -10351,7 +10351,8 @@
10351
10351
  extendFormState: { type: Function }
10352
10352
  }, defaultEditorProps),
10353
10353
  emits: ["props-panel-mounted", "update:modelValue"],
10354
- setup(__props, { expose: __expose, emit }) {
10354
+ setup(__props, { expose: __expose, emit: __emit }) {
10355
+ const emit = __emit;
10355
10356
  const props = __props;
10356
10357
  const services = {
10357
10358
  componentListService,
@@ -10519,6 +10520,10 @@
10519
10520
  }
10520
10521
  };
10521
10522
 
10523
+ Object.defineProperty(exports, 'DepTargetType', {
10524
+ enumerable: true,
10525
+ get: () => dep.DepTargetType
10526
+ });
10522
10527
  exports.CODE_DRAFT_STORAGE_KEY = CODE_DRAFT_STORAGE_KEY;
10523
10528
  exports.COPY_STORAGE_KEY = COPY_STORAGE_KEY;
10524
10529
  exports.CodeBlockEditor = _sfc_main$P;
@@ -10537,7 +10542,6 @@
10537
10542
  exports.DataSourceMethods = _sfc_main$I;
10538
10543
  exports.DataSourceMocks = _sfc_main$G;
10539
10544
  exports.DataSourceSelect = _sfc_main$F;
10540
- exports.DepTargetType = DepTargetType;
10541
10545
  exports.DragType = DragType;
10542
10546
  exports.EventSelect = _sfc_main$E;
10543
10547
  exports.Fixed2Other = Fixed2Other;
@@ -10604,6 +10608,7 @@
10604
10608
  exports.uiService = uiService;
10605
10609
  exports.useCodeBlockEdit = useCodeBlockEdit;
10606
10610
  exports.useDataSourceMethod = useDataSourceMethod;
10611
+ exports.useFloatBox = useFloatBox;
10607
10612
  exports.useStage = useStage;
10608
10613
  exports.warn = warn;
10609
10614