@tmagic/editor 1.4.14 → 1.4.16

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 (73) hide show
  1. package/dist/tmagic-editor.js +246 -127
  2. package/dist/tmagic-editor.umd.cjs +244 -125
  3. package/package.json +12 -12
  4. package/src/Editor.vue +4 -0
  5. package/src/components/ContentMenu.vue +8 -1
  6. package/src/components/TreeNode.vue +7 -0
  7. package/src/fields/CodeSelect.vue +3 -3
  8. package/src/fields/DataSourceFieldSelect/FieldSelect.vue +12 -8
  9. package/src/fields/DataSourceFieldSelect/Index.vue +10 -9
  10. package/src/fields/DataSourceMethodSelect.vue +8 -8
  11. package/src/fields/DataSourceSelect.vue +6 -8
  12. package/src/hooks/use-float-box.ts +52 -12
  13. package/src/layouts/sidebar/ComponentListPanel.vue +30 -27
  14. package/src/layouts/sidebar/Sidebar.vue +24 -3
  15. package/src/layouts/sidebar/layer/LayerPanel.vue +1 -1
  16. package/src/layouts/sidebar/layer/use-click.ts +9 -0
  17. package/src/layouts/sidebar/layer/use-drag.ts +28 -4
  18. package/src/services/editor.ts +13 -2
  19. package/src/type.ts +5 -0
  20. package/types/Editor.vue.d.ts +2313 -0
  21. package/types/components/CodeParams.vue.d.ts +4 -4
  22. package/types/components/ContentMenu.vue.d.ts +23 -15
  23. package/types/components/FloatingBox.vue.d.ts +9 -7
  24. package/types/components/Resizer.vue.d.ts +6 -4
  25. package/types/components/ScrollBar.vue.d.ts +2 -2
  26. package/types/components/ScrollViewer.vue.d.ts +22 -20
  27. package/types/components/SplitView.vue.d.ts +26 -24
  28. package/types/components/ToolButton.vue.d.ts +5 -5
  29. package/types/components/Tree.vue.d.ts +28 -26
  30. package/types/components/TreeNode.vue.d.ts +33 -24
  31. package/types/fields/Code.vue.d.ts +8 -8
  32. package/types/fields/CodeLink.vue.d.ts +4 -4
  33. package/types/fields/CodeSelect.vue.d.ts +2 -2
  34. package/types/fields/DisplayConds.vue.d.ts +4 -4
  35. package/types/fields/KeyValue.vue.d.ts +2 -2
  36. package/types/hooks/use-code-block-edit.d.ts +91 -2
  37. package/types/hooks/use-data-source-edit.d.ts +85 -2
  38. package/types/hooks/use-data-source-method.d.ts +90 -1
  39. package/types/hooks/use-editor-content-height.d.ts +1 -1
  40. package/types/hooks/use-filter.d.ts +1 -1
  41. package/types/hooks/use-float-box.d.ts +3 -1
  42. package/types/hooks/use-getso.d.ts +2 -2
  43. package/types/hooks/use-next-float-box-position.d.ts +6 -0
  44. package/types/hooks/use-node-status.d.ts +6 -1
  45. package/types/initService.d.ts +1 -1
  46. package/types/layouts/CodeEditor.vue.d.ts +14 -14
  47. package/types/layouts/Framework.vue.d.ts +6 -4
  48. package/types/layouts/NavMenu.vue.d.ts +4 -4
  49. package/types/layouts/PropsPanel.vue.d.ts +265 -14
  50. package/types/layouts/page-bar/PageBar.vue.d.ts +10 -8
  51. package/types/layouts/page-bar/PageBarScrollContainer.vue.d.ts +9 -7
  52. package/types/layouts/page-bar/PageList.vue.d.ts +8 -6
  53. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +3 -1
  54. package/types/layouts/sidebar/Sidebar.vue.d.ts +9 -7
  55. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +6 -4
  56. package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +6 -4
  57. package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +4 -2
  58. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +3 -1
  59. package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +8 -8
  60. package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +9 -7
  61. package/types/layouts/sidebar/layer/use-click.d.ts +65 -10
  62. package/types/layouts/sidebar/layer/use-keybinding.d.ts +1 -1
  63. package/types/layouts/sidebar/layer/use-node-status.d.ts +6 -1
  64. package/types/layouts/workspace/Workspace.vue.d.ts +10 -8
  65. package/types/layouts/workspace/viewer/Stage.vue.d.ts +6 -6
  66. package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +10 -10
  67. package/types/services/BaseService.d.ts +0 -1
  68. package/types/services/dataSource.d.ts +4 -4
  69. package/types/services/ui.d.ts +7 -5
  70. package/types/type.d.ts +7 -1
  71. package/types/utils/data-source/index.d.ts +1 -1
  72. package/types/utils/idle-task.d.ts +0 -1
  73. package/types/utils/scroll-viewer.d.ts +0 -1
@@ -2,13 +2,13 @@ import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, c
2
2
  import { Edit, FullScreen, View, Close, Coin, Delete, Plus, ArrowDown, ArrowLeftBold, ArrowRightBold, Files, CaretBottom, DocumentCopy, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Document, Search, ArrowRight, CopyDocument, Hide, Goods, List, EditPen, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
3
3
  import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, get, map, has, pick, keys } from 'lodash-es';
4
4
  import serialize from 'serialize-javascript';
5
- import { TMagicIcon, TMagicButton, TMagicCard, getConfig as getConfig$1, TMagicSelect, useZIndex, tMagicMessage, tMagicMessageBox, TMagicCascader, TMagicTag, TMagicDialog, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
5
+ import { TMagicIcon, TMagicButton, TMagicCard, getConfig as getConfig$1, TMagicSelect, useZIndex, tMagicMessage, tMagicMessageBox, TMagicCascader, TMagicTooltip, TMagicTag, TMagicDialog, TMagicSwitch, TMagicInput, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
6
6
  import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
7
7
  import * as monaco from 'monaco-editor';
8
8
  import { MContainer, MForm, filterFunction, createValues, MFormBox, MSelect, MGroupList, MPanel } from '@tmagic/form';
9
9
  import { HookCodeType, HookType, NodeType, ActionType } from '@tmagic/schema';
10
10
  import { MagicTable } from '@tmagic/table';
11
- import { isPage, isPageFragment, isPop, getNodePath, isNumber, calcValueByFontsize, toLine, guid, getValueByKeyPath, setValueByKeyPath, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName } from '@tmagic/utils';
11
+ import { isPage, isPageFragment, isPop, getNodePath, isNumber, calcValueByFontsize, toLine, guid, getValueByKeyPath, setValueByKeyPath, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, getKeys, removeClassName, addClassName, removeClassNameByClassName } from '@tmagic/utils';
12
12
  import VanillaMoveable from 'moveable';
13
13
  import { Target, Watcher, DepTargetType, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
14
14
  export { DepTargetType } from '@tmagic/dep';
@@ -429,7 +429,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
429
429
  {
430
430
  type: "select",
431
431
  name: "codeType",
432
- span: 8,
432
+ span: 6,
433
433
  options: [
434
434
  { value: HookCodeType.CODE, text: "代码块" },
435
435
  { value: HookCodeType.DATA_SOURCE_METHOD, text: "数据源方法" }
@@ -447,7 +447,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
447
447
  {
448
448
  type: "code-select-col",
449
449
  name: "codeId",
450
- span: 16,
450
+ span: 18,
451
451
  labelWidth: 0,
452
452
  display: (mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
453
453
  notEditable: () => !services?.codeBlockService.getEditStatus()
@@ -455,7 +455,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
455
455
  {
456
456
  type: "data-source-method-select",
457
457
  name: "codeId",
458
- span: 16,
458
+ span: 18,
459
459
  labelWidth: 0,
460
460
  display: (mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
461
461
  notEditable: () => !services?.dataSourceService.get("editable")
@@ -2416,9 +2416,17 @@ class Editor extends BaseService {
2416
2416
  const sourceIndicesInTargetParent = [];
2417
2417
  const sourceOutTargetParent = [];
2418
2418
  const newLayout = await this.getLayout(targetParent);
2419
- for (const config2 of configs) {
2419
+ forConfigs: for (const config2 of configs) {
2420
2420
  const { parent, node: curNode } = this.getNodeInfo(config2.id, false);
2421
- if (!parent || !curNode) throw new Error("找不要删除的节点");
2421
+ if (!parent || !curNode) {
2422
+ continue;
2423
+ }
2424
+ const path = getNodePath(curNode.id, parent.items);
2425
+ for (const node of path) {
2426
+ if (targetParent.id === node.id) {
2427
+ continue forConfigs;
2428
+ }
2429
+ }
2422
2430
  const index = getNodeIndex(curNode.id, parent);
2423
2431
  if (parent.id === targetParent.id) {
2424
2432
  if (typeof index !== "number" || index === -1) {
@@ -3761,20 +3769,46 @@ const useFloatBox = (slideKeys) => {
3761
3769
  const showingBoxKeys = computed(
3762
3770
  () => Object.keys(floatBoxStates.value).filter((key) => floatBoxStates.value[key].status)
3763
3771
  );
3764
- const isDragging = ref(false);
3765
- const dragstartHandler = () => isDragging.value = true;
3772
+ const dragState = {
3773
+ startOffset: {
3774
+ x: 0,
3775
+ y: 0
3776
+ },
3777
+ isDragging: false
3778
+ };
3779
+ const dragstartHandler = (e) => {
3780
+ dragState.isDragging = true;
3781
+ dragState.startOffset.x = e.clientX;
3782
+ dragState.startOffset.y = e.clientY;
3783
+ };
3784
+ const effectiveDistance = 20;
3766
3785
  const dragendHandler = (key, e) => {
3767
- const navMenuRect = services?.uiService?.get("navMenuRect");
3768
- floatBoxStates.value[key] = {
3769
- left: e.clientX,
3770
- top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0),
3771
- status: true
3772
- };
3773
- isDragging.value = false;
3786
+ if (!dragState.isDragging) return;
3787
+ const { startOffset } = dragState;
3788
+ if (Math.abs(startOffset.x - e.clientX) > effectiveDistance || Math.abs(startOffset.y - e.clientY) > effectiveDistance) {
3789
+ const navMenuRect = services?.uiService?.get("navMenuRect");
3790
+ floatBoxStates.value[key] = {
3791
+ left: e.clientX,
3792
+ top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0),
3793
+ status: true
3794
+ };
3795
+ }
3796
+ dragState.isDragging = false;
3774
3797
  };
3775
- document.body.addEventListener("dragover", (e) => {
3776
- if (!isDragging.value) return;
3798
+ const dragoverHandler = (e) => {
3799
+ if (!dragState.isDragging) return;
3777
3800
  e.preventDefault();
3801
+ };
3802
+ const blurHandler = () => {
3803
+ dragState.startOffset.x = 0;
3804
+ dragState.startOffset.y = 0;
3805
+ dragState.isDragging = false;
3806
+ };
3807
+ globalThis.document.body.addEventListener("dragover", dragoverHandler);
3808
+ globalThis.addEventListener("blur", blurHandler);
3809
+ onBeforeUnmount(() => {
3810
+ globalThis.document.body.removeEventListener("dragover", dragoverHandler);
3811
+ globalThis.removeEventListener("blur", blurHandler);
3778
3812
  });
3779
3813
  watch(
3780
3814
  () => slideKeys.value,
@@ -4332,19 +4366,26 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
4332
4366
  },
4333
4367
  onChange: onChangeHandler
4334
4368
  }, null, 8, ["model-value", "disabled", "size", "options", "props"])),
4335
- selectDataSourceId.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
4369
+ selectDataSourceId.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
4336
4370
  key: 2,
4337
- class: "m-fields-select-action-button",
4338
- size: _ctx.size,
4339
- onClick: _cache[0] || (_cache[0] = ($event) => editHandler(selectDataSourceId.value))
4371
+ content: notEditable.value ? "查看" : "编辑"
4340
4372
  }, {
4341
4373
  default: withCtx(() => [
4342
- createVNode(_sfc_main$Y, {
4343
- icon: !notEditable.value ? unref(Edit) : unref(View)
4344
- }, null, 8, ["icon"])
4374
+ createVNode(unref(TMagicButton), {
4375
+ class: "m-fields-select-action-button",
4376
+ size: _ctx.size,
4377
+ onClick: _cache[0] || (_cache[0] = ($event) => editHandler(selectDataSourceId.value))
4378
+ }, {
4379
+ default: withCtx(() => [
4380
+ createVNode(_sfc_main$Y, {
4381
+ icon: !notEditable.value ? unref(Edit) : unref(View)
4382
+ }, null, 8, ["icon"])
4383
+ ]),
4384
+ _: 1
4385
+ }, 8, ["size"])
4345
4386
  ]),
4346
4387
  _: 1
4347
- }, 8, ["size"])) : createCommentVNode("", true)
4388
+ }, 8, ["content"])) : createCommentVNode("", true)
4348
4389
  ]);
4349
4390
  };
4350
4391
  }
@@ -4475,18 +4516,26 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
4475
4516
  prop: `${_ctx.prop}${_ctx.prop ? "." : ""}${_ctx.name}`,
4476
4517
  onChange: onChangeHandler
4477
4518
  }, null, 40, ["config", "model", "name", "disabled", "size", "last-values", "init-values", "values", "prop"])),
4478
- _ctx.config.fieldConfig ? (openBlock(), createBlock(unref(TMagicButton), {
4519
+ _ctx.config.fieldConfig ? (openBlock(), createBlock(unref(TMagicTooltip), {
4479
4520
  key: 2,
4480
- style: { "margin-left": "5px" },
4481
- type: showDataSourceFieldSelect.value ? "primary" : "default",
4482
- size: _ctx.size,
4483
- onClick: _cache[0] || (_cache[0] = ($event) => showDataSourceFieldSelect.value = !showDataSourceFieldSelect.value)
4521
+ disabled: showDataSourceFieldSelect.value,
4522
+ content: "选择数据源"
4484
4523
  }, {
4485
4524
  default: withCtx(() => [
4486
- createVNode(_sfc_main$Y, { icon: unref(Coin) }, null, 8, ["icon"])
4525
+ createVNode(unref(TMagicButton), {
4526
+ style: { "margin-left": "5px" },
4527
+ type: showDataSourceFieldSelect.value ? "primary" : "default",
4528
+ size: _ctx.size,
4529
+ onClick: _cache[0] || (_cache[0] = ($event) => showDataSourceFieldSelect.value = !showDataSourceFieldSelect.value)
4530
+ }, {
4531
+ default: withCtx(() => [
4532
+ createVNode(_sfc_main$Y, { icon: unref(Coin) }, null, 8, ["icon"])
4533
+ ]),
4534
+ _: 1
4535
+ }, 8, ["type", "size"])
4487
4536
  ]),
4488
4537
  _: 1
4489
- }, 8, ["type", "size"])) : createCommentVNode("", true)
4538
+ }, 8, ["disabled"])) : createCommentVNode("", true)
4490
4539
  ]);
4491
4540
  };
4492
4541
  }
@@ -5189,7 +5238,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
5189
5238
  ...paramState
5190
5239
  }));
5191
5240
  };
5192
- const paramsConfig = ref(getParamItemsConfig(props.model.dataSourceMethod));
5241
+ const paramsConfig = ref(getParamItemsConfig(props.model[props.name || "dataSourceMethod"]));
5193
5242
  const setParamsConfig = (dataSourceMethod, formState = {}) => {
5194
5243
  paramsConfig.value = dataSourceMethod ? getParamItemsConfig(dataSourceMethod) : [];
5195
5244
  if (paramsConfig.value.length) {
@@ -5241,19 +5290,26 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
5241
5290
  size: _ctx.size,
5242
5291
  onChange: onChangeHandler
5243
5292
  }, null, 8, ["config", "model", "size"]),
5244
- _ctx.model[_ctx.name] && isCustomMethod.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
5293
+ _ctx.model[_ctx.name] && isCustomMethod.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
5245
5294
  key: 0,
5246
- class: "m-fields-select-action-button",
5247
- size: _ctx.size,
5248
- onClick: editCodeHandler
5295
+ content: notEditable.value ? "查看" : "编辑"
5249
5296
  }, {
5250
5297
  default: withCtx(() => [
5251
- createVNode(_sfc_main$Y, {
5252
- icon: !notEditable.value ? unref(Edit) : unref(View)
5253
- }, null, 8, ["icon"])
5298
+ createVNode(unref(TMagicButton), {
5299
+ class: "m-fields-select-action-button",
5300
+ size: _ctx.size,
5301
+ onClick: editCodeHandler
5302
+ }, {
5303
+ default: withCtx(() => [
5304
+ createVNode(_sfc_main$Y, {
5305
+ icon: !notEditable.value ? unref(Edit) : unref(View)
5306
+ }, null, 8, ["icon"])
5307
+ ]),
5308
+ _: 1
5309
+ }, 8, ["size"])
5254
5310
  ]),
5255
5311
  _: 1
5256
- }, 8, ["size"])) : createCommentVNode("", true)
5312
+ }, 8, ["content"])) : createCommentVNode("", true)
5257
5313
  ]),
5258
5314
  paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$T, {
5259
5315
  key: 0,
@@ -5591,19 +5647,26 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
5591
5647
  "last-values": _ctx.lastValues,
5592
5648
  onChange: changeHandler
5593
5649
  }, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]),
5594
- _ctx.model[_ctx.name] && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
5650
+ _ctx.model[_ctx.name] && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
5595
5651
  key: 0,
5596
- class: "m-fields-select-action-button",
5597
- size: _ctx.size,
5598
- onClick: editHandler
5652
+ content: notEditable.value ? "查看" : "编辑"
5599
5653
  }, {
5600
5654
  default: withCtx(() => [
5601
- createVNode(_sfc_main$Y, {
5602
- icon: !notEditable.value ? unref(Edit) : unref(View)
5603
- }, null, 8, ["icon"])
5655
+ createVNode(unref(TMagicButton), {
5656
+ class: "m-fields-select-action-button",
5657
+ size: _ctx.size,
5658
+ onClick: editHandler
5659
+ }, {
5660
+ default: withCtx(() => [
5661
+ createVNode(_sfc_main$Y, {
5662
+ icon: !notEditable.value ? unref(Edit) : unref(View)
5663
+ }, null, 8, ["icon"])
5664
+ ]),
5665
+ _: 1
5666
+ }, 8, ["size"])
5604
5667
  ]),
5605
5668
  _: 1
5606
- }, 8, ["size"])) : createCommentVNode("", true)
5669
+ }, 8, ["content"])) : createCommentVNode("", true)
5607
5670
  ]);
5608
5671
  };
5609
5672
  }
@@ -7863,7 +7926,7 @@ const updateStatus = (nodeStatusMap, id, status) => {
7863
7926
  });
7864
7927
  };
7865
7928
 
7866
- const _hoisted_1$9 = ["draggable", "data-node-id", "data-is-container"];
7929
+ const _hoisted_1$9 = ["draggable", "data-node-id", "data-parent-id", "data-parents-id", "data-is-container"];
7867
7930
  const _hoisted_2$6 = { class: "tree-node-label" };
7868
7931
  const _hoisted_3$3 = { class: "tree-node-tool" };
7869
7932
  const _hoisted_4$3 = {
@@ -7877,6 +7940,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
7877
7940
  __name: "TreeNode",
7878
7941
  props: {
7879
7942
  data: {},
7943
+ parent: {},
7944
+ parentsId: { default: () => [] },
7880
7945
  nodeStatusMap: {},
7881
7946
  indent: { default: 0 }
7882
7947
  },
@@ -7928,6 +7993,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
7928
7993
  class: "m-editor-tree-node",
7929
7994
  draggable: draggable.value,
7930
7995
  "data-node-id": _ctx.data.id,
7996
+ "data-parent-id": _ctx.parent?.id,
7997
+ "data-parents-id": _ctx.parentsId,
7931
7998
  "data-is-container": Array.isArray(_ctx.data.items),
7932
7999
  onDragstart: handleDragStart,
7933
8000
  onDragleave: handleDragLeave,
@@ -7966,6 +8033,8 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
7966
8033
  return openBlock(), createBlock(_component_TreeNode, {
7967
8034
  key: item.id,
7968
8035
  data: item,
8036
+ parent: _ctx.data,
8037
+ parentsId: [..._ctx.parentsId, _ctx.data.id],
7969
8038
  "node-status-map": _ctx.nodeStatusMap,
7970
8039
  indent: _ctx.indent + 11
7971
8040
  }, {
@@ -7979,7 +8048,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
7979
8048
  renderSlot(_ctx.$slots, "tree-node-tool", { data: nodeData })
7980
8049
  ]),
7981
8050
  _: 2
7982
- }, 1032, ["data", "node-status-map", "indent"]);
8051
+ }, 1032, ["data", "parent", "parentsId", "node-status-map", "indent"]);
7983
8052
  }), 128))
7984
8053
  ])) : createCommentVNode("", true)
7985
8054
  ], 40, _hoisted_1$9)), [
@@ -8719,13 +8788,16 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8719
8788
  const subMenu = ref();
8720
8789
  const visible = ref(false);
8721
8790
  const subMenuData = ref([]);
8791
+ const zIndex = useZIndex();
8792
+ const curZIndex = ref(0);
8722
8793
  const menuPosition = ref({
8723
8794
  left: 0,
8724
8795
  top: 0
8725
8796
  });
8726
8797
  const menuStyle = computed(() => ({
8727
8798
  top: `${menuPosition.value.top}px`,
8728
- left: `${menuPosition.value.left}px`
8799
+ left: `${menuPosition.value.left}px`,
8800
+ zIndex: curZIndex.value
8729
8801
  }));
8730
8802
  const contains = (el) => menu.value?.contains(el) || subMenu.value?.contains(el);
8731
8803
  const hide = () => {
@@ -8765,6 +8837,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
8765
8837
  visible.value = true;
8766
8838
  nextTick(() => {
8767
8839
  e && setPosition(e);
8840
+ curZIndex.value = zIndex.nextZIndex();
8768
8841
  emit("show");
8769
8842
  });
8770
8843
  }, 300);
@@ -9118,6 +9191,9 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
9118
9191
  }
9119
9192
  };
9120
9193
  const multiSelect = async (data) => {
9194
+ if (isPage(data) || isPageFragment(data)) {
9195
+ return;
9196
+ }
9121
9197
  const nodes = services?.editorService.get("nodes") || [];
9122
9198
  const newNodes = [];
9123
9199
  let isCancel = false;
@@ -9126,6 +9202,9 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
9126
9202
  isCancel = true;
9127
9203
  return;
9128
9204
  }
9205
+ if (isPage(node) || isPageFragment(node)) {
9206
+ return;
9207
+ }
9129
9208
  newNodes.push(node.id);
9130
9209
  });
9131
9210
  if (!isCancel || newNodes.length === 0) {
@@ -9205,6 +9284,7 @@ const useDrag = (services) => {
9205
9284
  const targetEl = getNodeEl(event.target);
9206
9285
  if (!targetEl || targetEl !== event.currentTarget) return;
9207
9286
  event.dataTransfer.effectAllowed = "move";
9287
+ dragState.nodeId = targetEl.dataset.nodeId;
9208
9288
  try {
9209
9289
  event.dataTransfer.setData(
9210
9290
  "text/json",
@@ -9221,26 +9301,42 @@ const useDrag = (services) => {
9221
9301
  if (!targetEl?.draggable) return;
9222
9302
  const labelEl = targetEl.children[0];
9223
9303
  if (!labelEl) return;
9304
+ removeClassName(labelEl, "drag-before", "drag-after", "drag-inner");
9224
9305
  const { top: targetTop, height: targetHeight } = labelEl.getBoundingClientRect();
9225
9306
  const distance = event.clientY - targetTop;
9226
9307
  const isContainer = targetEl.dataset.isContainer === "true";
9308
+ const targetNodeId = targetEl.dataset.nodeId;
9309
+ const { nodeId } = dragState;
9310
+ const parentsId = targetEl.dataset.parentsId?.split(",");
9311
+ if (!targetNodeId) {
9312
+ return;
9313
+ }
9314
+ if (parentsId) {
9315
+ let targetIdIndex = -1;
9316
+ for (let i = 0, l = parentsId.length; i < l; i++) {
9317
+ const id = parentsId[i];
9318
+ if (nodeId === id) {
9319
+ targetIdIndex = i;
9320
+ }
9321
+ if (parentsId.includes(`${nodeId}`) && i >= targetIdIndex) {
9322
+ return;
9323
+ }
9324
+ }
9325
+ }
9227
9326
  if (distance < targetHeight / 3) {
9228
9327
  dragState.dropType = "before";
9229
9328
  addClassName(labelEl, globalThis.document, "drag-before");
9230
- removeClassName(labelEl, "drag-after", "drag-inner");
9231
9329
  } else if (distance > targetHeight * 2 / 3) {
9232
9330
  dragState.dropType = "after";
9233
9331
  addClassName(labelEl, globalThis.document, "drag-after");
9234
- removeClassName(labelEl, "drag-before", "drag-inner");
9235
9332
  } else if (isContainer) {
9236
9333
  dragState.dropType = "inner";
9237
9334
  addClassName(labelEl, globalThis.document, "drag-inner");
9238
- removeClassName(labelEl, "drag-before", "drag-after");
9239
9335
  }
9240
9336
  if (!dragState.dropType) {
9241
9337
  return;
9242
9338
  }
9243
- dragState.dragOverNodeId = targetEl.dataset.nodeId || "";
9339
+ dragState.dragOverNodeId = targetNodeId;
9244
9340
  dragState.container = event.currentTarget;
9245
9341
  event.preventDefault();
9246
9342
  };
@@ -9651,7 +9747,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
9651
9747
  const stageOptions = inject("stageOptions");
9652
9748
  const stage = computed(() => services?.editorService.get("stage"));
9653
9749
  const list = computed(
9654
- () => services?.componentListService.getList().map((group) => ({
9750
+ () => (services?.componentListService.getList() || []).map((group) => ({
9655
9751
  ...group,
9656
9752
  items: group.items.filter((item) => item.text.includes(searchText.value))
9657
9753
  }))
@@ -9711,60 +9807,62 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
9711
9807
  return openBlock(), createBlock(unref(TMagicScrollbar), null, {
9712
9808
  default: withCtx(() => [
9713
9809
  renderSlot(_ctx.$slots, "component-list-panel-header"),
9714
- createVNode(unref(TMagicCollapse), {
9715
- class: "ui-component-panel",
9716
- "model-value": collapseValue.value
9717
- }, {
9718
- default: withCtx(() => [
9719
- createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
9720
- (openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
9721
- return openBlock(), createElementBlock(Fragment, null, [
9722
- group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
9723
- key: index,
9724
- name: `${index}`
9725
- }, {
9726
- title: withCtx(() => [
9727
- createVNode(_sfc_main$Y, { icon: unref(Grid) }, null, 8, ["icon"]),
9728
- createTextVNode(toDisplayString(group.title), 1)
9729
- ]),
9730
- default: withCtx(() => [
9731
- (openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
9732
- return openBlock(), createElementBlock("div", {
9733
- class: "component-item",
9734
- draggable: "true",
9735
- key: item.type,
9736
- onClick: ($event) => appendComponent(item),
9737
- onDragstart: ($event) => dragstartHandler(item, $event),
9738
- onDragend: dragendHandler,
9739
- onDrag: dragHandler
9740
- }, [
9741
- renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
9742
- createVNode(unref(TMagicTooltip), {
9743
- placement: "right",
9744
- disabled: !Boolean(item.desc),
9745
- content: item.desc
9746
- }, {
9747
- default: withCtx(() => [
9748
- createVNode(_sfc_main$Y, {
9749
- icon: item.icon
9750
- }, null, 8, ["icon"])
9751
- ]),
9752
- _: 2
9753
- }, 1032, ["disabled", "content"]),
9754
- createElementVNode("span", {
9755
- title: item.text
9756
- }, toDisplayString(item.text), 9, _hoisted_2$3)
9757
- ])
9758
- ], 40, _hoisted_1$4);
9759
- }), 128))
9760
- ]),
9761
- _: 2
9762
- }, 1032, ["name"])) : createCommentVNode("", true)
9763
- ], 64);
9764
- }), 256))
9765
- ]),
9766
- _: 3
9767
- }, 8, ["model-value"])
9810
+ createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
9811
+ renderSlot(_ctx.$slots, "component-list", { componentGroupList: list.value }, () => [
9812
+ createVNode(unref(TMagicCollapse), {
9813
+ class: "ui-component-panel",
9814
+ "model-value": collapseValue.value
9815
+ }, {
9816
+ default: withCtx(() => [
9817
+ (openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
9818
+ return openBlock(), createElementBlock(Fragment, null, [
9819
+ group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
9820
+ key: index,
9821
+ name: `${index}`
9822
+ }, {
9823
+ title: withCtx(() => [
9824
+ createVNode(_sfc_main$Y, { icon: unref(Grid) }, null, 8, ["icon"]),
9825
+ createTextVNode(toDisplayString(group.title), 1)
9826
+ ]),
9827
+ default: withCtx(() => [
9828
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
9829
+ return openBlock(), createElementBlock("div", {
9830
+ class: "component-item",
9831
+ draggable: "true",
9832
+ key: item.type,
9833
+ onClick: ($event) => appendComponent(item),
9834
+ onDragstart: ($event) => dragstartHandler(item, $event),
9835
+ onDragend: dragendHandler,
9836
+ onDrag: dragHandler
9837
+ }, [
9838
+ renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
9839
+ createVNode(unref(TMagicTooltip), {
9840
+ placement: "right",
9841
+ disabled: !Boolean(item.desc),
9842
+ content: item.desc
9843
+ }, {
9844
+ default: withCtx(() => [
9845
+ createVNode(_sfc_main$Y, {
9846
+ icon: item.icon
9847
+ }, null, 8, ["icon"])
9848
+ ]),
9849
+ _: 2
9850
+ }, 1032, ["disabled", "content"]),
9851
+ createElementVNode("span", {
9852
+ title: item.text
9853
+ }, toDisplayString(item.text), 9, _hoisted_2$3)
9854
+ ])
9855
+ ], 40, _hoisted_1$4);
9856
+ }), 128))
9857
+ ]),
9858
+ _: 2
9859
+ }, 1032, ["name"])) : createCommentVNode("", true)
9860
+ ], 64);
9861
+ }), 256))
9862
+ ]),
9863
+ _: 3
9864
+ }, 8, ["model-value"])
9865
+ ])
9768
9866
  ]),
9769
9867
  _: 3
9770
9868
  });
@@ -9777,7 +9875,7 @@ const _hoisted_1$3 = {
9777
9875
  class: "m-editor-sidebar"
9778
9876
  };
9779
9877
  const _hoisted_2$2 = { class: "m-editor-sidebar-header" };
9780
- const _hoisted_3$1 = ["onClick", "onDragend"];
9878
+ const _hoisted_3$1 = ["draggable", "onClick", "onDragend"];
9781
9879
  const _hoisted_4$1 = {
9782
9880
  key: 1,
9783
9881
  class: "magic-editor-tab-panel-title"
@@ -9879,6 +9977,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9879
9977
  activeTabName.value = nextSlideBarItem?.text;
9880
9978
  }
9881
9979
  );
9980
+ const headerItemClickHandler = async (config, index) => {
9981
+ if (typeof config.beforeClick === "function") {
9982
+ if (await config.beforeClick(config) === false) {
9983
+ return;
9984
+ }
9985
+ }
9986
+ activeTabName.value = config.text || config.$key || `${index}`;
9987
+ };
9882
9988
  __expose({
9883
9989
  activeTabName
9884
9990
  });
@@ -9889,10 +9995,10 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9889
9995
  (openBlock(true), createElementBlock(Fragment, null, renderList(sideBarItems.value, (config, index) => {
9890
9996
  return withDirectives((openBlock(), createElementBlock("div", {
9891
9997
  class: normalizeClass(["m-editor-sidebar-header-item", { "is-active": activeTabName.value === config.text }]),
9892
- draggable: "true",
9998
+ draggable: config.draggable ?? true,
9893
9999
  key: config.$key ?? index,
9894
10000
  style: normalizeStyle(config.tabStyle || {}),
9895
- onClick: ($event) => activeTabName.value = config.text || config.$key || `${index}`,
10001
+ onClick: ($event) => headerItemClickHandler(config, index),
9896
10002
  onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
9897
10003
  (...args) => unref(dragstartHandler) && unref(dragstartHandler)(...args)),
9898
10004
  onDragend: ($event) => unref(dragendHandler)(config.$key, $event)
@@ -9912,16 +10018,26 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9912
10018
  class: "m-editor-sidebar-content",
9913
10019
  key: config.$key ?? index
9914
10020
  }, [
9915
- config && !unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({
10021
+ config?.component && !unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(resolveDynamicComponent(config.component), mergeProps({
9916
10022
  key: 0,
9917
10023
  ref_for: true
9918
10024
  }, config.props || {}, toHandlers(config?.listeners || {})), createSlots({ _: 2 }, [
10025
+ config.$key === "component-list" || config.slots?.componentList ? {
10026
+ name: "component-list",
10027
+ fn: withCtx(({ componentGroupList }) => [
10028
+ config.$key === "component-list" ? renderSlot(_ctx.$slots, "component-list", {
10029
+ key: 0,
10030
+ componentGroupList
10031
+ }) : config.slots?.componentList ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentList), { key: 1 })) : createCommentVNode("", true)
10032
+ ]),
10033
+ key: "0"
10034
+ } : void 0,
9919
10035
  config.$key === "component-list" || config.slots?.componentListPanelHeader ? {
9920
10036
  name: "component-list-panel-header",
9921
10037
  fn: withCtx(() => [
9922
10038
  config.$key === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : config.slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
9923
10039
  ]),
9924
- key: "0"
10040
+ key: "1"
9925
10041
  } : void 0,
9926
10042
  config.$key === "component-list" || config.slots?.componentListItem ? {
9927
10043
  name: "component-list-item",
@@ -9934,21 +10050,21 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9934
10050
  component
9935
10051
  }, null, 8, ["component"])) : createCommentVNode("", true)
9936
10052
  ]),
9937
- key: "1"
10053
+ key: "2"
9938
10054
  } : void 0,
9939
10055
  config.$key === "layer" || config.slots?.layerPanelHeader ? {
9940
10056
  name: "layer-panel-header",
9941
10057
  fn: withCtx(() => [
9942
10058
  config.$key === "layer" ? renderSlot(_ctx.$slots, "layer-panel-header", { key: 0 }) : config.slots?.layerPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.layerPanelHeader), { key: 1 })) : createCommentVNode("", true)
9943
10059
  ]),
9944
- key: "2"
10060
+ key: "3"
9945
10061
  } : void 0,
9946
10062
  config.$key === "code-block" || config.slots?.codeBlockPanelHeader ? {
9947
10063
  name: "code-block-panel-header",
9948
10064
  fn: withCtx(() => [
9949
10065
  config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-header", { key: 0 }) : config.slots?.codeBlockPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelHeader), { key: 1 })) : createCommentVNode("", true)
9950
10066
  ]),
9951
- key: "3"
10067
+ key: "4"
9952
10068
  } : void 0,
9953
10069
  config.$key === "code-block" || config.slots?.codeBlockPanelTool ? {
9954
10070
  name: "code-block-panel-tool",
@@ -9959,14 +10075,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9959
10075
  data
9960
10076
  }) : config.slots?.codeBlockPanelTool ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelTool), { key: 1 })) : createCommentVNode("", true)
9961
10077
  ]),
9962
- key: "4"
10078
+ key: "5"
9963
10079
  } : void 0,
9964
10080
  config.$key === "code-block" || config.slots?.codeBlockPanelSearch ? {
9965
10081
  name: "code-block-panel-search",
9966
10082
  fn: withCtx(() => [
9967
10083
  config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-panel-search", { key: 0 }) : config.slots?.codeBlockPanelSearch ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockPanelSearch), { key: 1 })) : createCommentVNode("", true)
9968
10084
  ]),
9969
- key: "5"
10085
+ key: "6"
9970
10086
  } : void 0,
9971
10087
  config.$key === "layer" || config.slots?.layerNodeContent ? {
9972
10088
  name: "layer-node-content",
@@ -9979,7 +10095,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9979
10095
  data: nodeData
9980
10096
  }, null, 8, ["data"])) : createCommentVNode("", true)
9981
10097
  ]),
9982
- key: "6"
10098
+ key: "7"
9983
10099
  } : void 0,
9984
10100
  config.$key === "layer" || config.slots?.layerNodeLabel ? {
9985
10101
  name: "layer-node-label",
@@ -9992,7 +10108,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
9992
10108
  data: nodeData
9993
10109
  }, null, 8, ["data"])) : createCommentVNode("", true)
9994
10110
  ]),
9995
- key: "7"
10111
+ key: "8"
9996
10112
  } : void 0,
9997
10113
  config.$key === "layer" || config.slots?.layerNodeTool ? {
9998
10114
  name: "layer-node-tool",
@@ -10005,7 +10121,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
10005
10121
  data: nodeData
10006
10122
  }, null, 8, ["data"])) : createCommentVNode("", true)
10007
10123
  ]),
10008
- key: "8"
10124
+ key: "9"
10009
10125
  } : void 0,
10010
10126
  config.$key === "data-source" || config.slots?.dataSourcePanelTool ? {
10011
10127
  name: "data-source-panel-tool",
@@ -10015,14 +10131,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
10015
10131
  data
10016
10132
  }) : config.slots?.DataSourcePanelTool ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.DataSourcePanelTool), { key: 1 })) : createCommentVNode("", true)
10017
10133
  ]),
10018
- key: "9"
10134
+ key: "10"
10019
10135
  } : void 0,
10020
10136
  config.$key === "data-source" || config.slots?.dataSourcePanelSearch ? {
10021
10137
  name: "data-source-panel-search",
10022
10138
  fn: withCtx(() => [
10023
10139
  config.$key === "data-source" ? renderSlot(_ctx.$slots, "data-source-panel-search", { key: 0 }) : config.slots?.dataSourcePanelSearch ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.dataSourcePanelSearch), { key: 1 })) : createCommentVNode("", true)
10024
10140
  ]),
10025
- key: "10"
10141
+ key: "11"
10026
10142
  } : void 0
10027
10143
  ]), 1040)) : createCommentVNode("", true)
10028
10144
  ])), [
@@ -12422,6 +12538,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
12422
12538
  "layer-node-tool": withCtx(({ data }) => [
12423
12539
  renderSlot(_ctx.$slots, "layer-node-tool", { data })
12424
12540
  ]),
12541
+ "component-list": withCtx(({ componentGroupList }) => [
12542
+ renderSlot(_ctx.$slots, "component-list", { componentGroupList })
12543
+ ]),
12425
12544
  "component-list-panel-header": withCtx(() => [
12426
12545
  renderSlot(_ctx.$slots, "component-list-panel-header")
12427
12546
  ]),