@tmagic/editor 1.5.0-beta.10 → 1.5.0-beta.12

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.
@@ -1,21 +1,21 @@
1
1
  import designPlugin__default, { TMagicIcon, TMagicButton, TMagicCard, getDesignConfig, TMagicSelect, useZIndex, tMagicMessage, tMagicMessageBox, TMagicCascader, TMagicTooltip, TMagicTag, TMagicDialog, TMagicSwitch, TMagicInput, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
2
2
  export * from '@tmagic/design';
3
3
  export { default as designPlugin } from '@tmagic/design';
4
- import formPlugin__default, { MContainer, MForm, filterFunction, createValues, MFormBox, MSelect, MGroupList, MPanel } from '@tmagic/form';
4
+ import formPlugin__default, { MContainer, MForm, filterFunction, createValues, MFormBox, MSelect, MGroupList, MPanel, createForm } from '@tmagic/form';
5
5
  export * from '@tmagic/form';
6
6
  export { default as formPlugin } from '@tmagic/form';
7
7
  import tablePlugin__default, { MagicTable } from '@tmagic/table';
8
8
  export * from '@tmagic/table';
9
9
  export { default as tablePlugin } from '@tmagic/table';
10
10
  import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, ref, watch, onMounted, onBeforeUnmount, Teleport, normalizeStyle, computed, reactive, resolveComponent, inject, createCommentVNode, Fragment, renderList, mergeProps, mergeModels, useModel, nextTick, provide, renderSlot, toDisplayString, createTextVNode, isRef, createStaticVNode, watchEffect, withModifiers, toHandlers, resolveDirective, withDirectives, createSlots, markRaw, getCurrentInstance, vShow, Transition, mergeDefaults } from 'vue';
11
- 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';
12
- import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, get, map, has, pick, keys, debounce } from 'lodash-es';
11
+ import { Edit, FullScreen, View, Close, Coin, Delete, Plus, ArrowDown, ArrowLeftBold, ArrowRightBold, Files, Search, CaretBottom, DocumentCopy, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Document, ArrowRight, CopyDocument, Hide, Goods, List, EditPen, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
12
+ import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, get, map, has, pick, keys } from 'lodash-es';
13
13
  import serialize from 'serialize-javascript';
14
14
  import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
15
15
  import * as monaco from 'monaco-editor';
16
16
  import { HookCodeType, HookType, NODE_CONDS_KEY, Target, Watcher, NodeType, ActionType, DepTargetType, DEFAULT_EVENTS, DEFAULT_METHODS, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/core';
17
17
  export { DepTargetType } from '@tmagic/core';
18
- import { isPage, isPageFragment, isPop, getNodePath, isNumber, getElById, calcValueByFontsize, toLine, guid, getValueByKeyPath, setValueByKeyPath, dataSourceTemplateRegExp, getKeysArray, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, convertToNumber, getIdFromEl, traverseNode, getDefaultValueFromFields, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, removeClassName, addClassName, removeClassNameByClassName } from '@tmagic/utils';
18
+ import { isPage, isPageFragment, isPop, getNodePath, isNumber, getElById, calcValueByFontsize, toLine, guid, getValueByKeyPath, setValueByKeyPath, getNodeInfo, dataSourceTemplateRegExp, getKeysArray, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, convertToNumber, getIdFromEl, traverseNode, getDefaultValueFromFields, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, removeClassName, addClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
19
19
  export * from '@tmagic/utils';
20
20
  import VanillaMoveable from 'moveable';
21
21
  import StageCore__default, { isFixed, GuidesType, getOffset, RenderType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
@@ -26,7 +26,7 @@ import Gesto from 'gesto';
26
26
  import Sortable from 'sortablejs';
27
27
  import KeyController from 'keycon';
28
28
 
29
- const _hoisted_1$w = ["src"];
29
+ const _hoisted_1$x = ["src"];
30
30
  const _sfc_main$Y = /* @__PURE__ */ defineComponent({
31
31
  ...{
32
32
  name: "MEditorIcon"
@@ -51,7 +51,7 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
51
51
  class: "magic-editor-icon"
52
52
  }, {
53
53
  default: withCtx(() => [
54
- createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$w)
54
+ createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$x)
55
55
  ]),
56
56
  _: 1
57
57
  })) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
@@ -79,7 +79,7 @@ const getEditorConfig = (key) => $TMAGIC_EDITOR[key];
79
79
  emmetHTML(monaco);
80
80
  emmetCSS(monaco, ["css", "scss"]);
81
81
 
82
- const _hoisted_1$v = {
82
+ const _hoisted_1$w = {
83
83
  class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
84
84
  };
85
85
  const _sfc_main$X = /* @__PURE__ */ defineComponent({
@@ -239,7 +239,7 @@ const _sfc_main$X = /* @__PURE__ */ defineComponent({
239
239
  }
240
240
  });
241
241
  return (_ctx, _cache) => {
242
- return openBlock(), createElementBlock("div", _hoisted_1$v, [
242
+ return openBlock(), createElementBlock("div", _hoisted_1$w, [
243
243
  (openBlock(), createBlock(Teleport, {
244
244
  to: "body",
245
245
  disabled: !fullScreen.value
@@ -1868,28 +1868,7 @@ class Editor extends BaseService {
1868
1868
  if (raw) {
1869
1869
  root = toRaw(root);
1870
1870
  }
1871
- const info = {
1872
- node: null,
1873
- parent: null,
1874
- page: null
1875
- };
1876
- if (!root) return info;
1877
- if (id === root.id) {
1878
- info.node = root;
1879
- return info;
1880
- }
1881
- const path = getNodePath(id, root.items);
1882
- if (!path.length) return info;
1883
- path.unshift(root);
1884
- info.node = path[path.length - 1];
1885
- info.parent = path[path.length - 2];
1886
- path.forEach((item) => {
1887
- if (isPage(item) || isPageFragment(item)) {
1888
- info.page = item;
1889
- return;
1890
- }
1891
- });
1892
- return info;
1871
+ return getNodeInfo(id, root);
1893
1872
  }
1894
1873
  /**
1895
1874
  * 根据ID获取指点节点配置
@@ -2110,10 +2089,10 @@ class Editor extends BaseService {
2110
2089
  const rootItems = root.items || [];
2111
2090
  if (isPage(node)) {
2112
2091
  this.state.pageLength -= 1;
2113
- await selectDefault(getPageList(root));
2092
+ await selectDefault(rootItems);
2114
2093
  } else if (isPageFragment(node)) {
2115
2094
  this.state.pageFragmentLength -= 1;
2116
- await selectDefault(getPageFragmentList(root));
2095
+ await selectDefault(rootItems);
2117
2096
  } else {
2118
2097
  await this.select(parent);
2119
2098
  stage?.select(parent.id);
@@ -2175,11 +2154,6 @@ class Editor extends BaseService {
2175
2154
  const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
2176
2155
  nodes.splice(targetIndex, 1, newConfig);
2177
2156
  this.set("nodes", [...nodes]);
2178
- this.get("stage")?.update({
2179
- config: cloneDeep(newConfig),
2180
- parentId: parent.id,
2181
- root: cloneDeep(root)
2182
- });
2183
2157
  if (isPage(newConfig) || isPageFragment(newConfig)) {
2184
2158
  this.set("page", newConfig);
2185
2159
  }
@@ -2401,7 +2375,11 @@ class Editor extends BaseService {
2401
2375
  target.items.push(newConfig);
2402
2376
  await stage.select(targetId);
2403
2377
  const targetParent = this.getParentById(target.id);
2404
- await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root: cloneDeep(root) });
2378
+ await stage.update({
2379
+ config: cloneDeep(target),
2380
+ parentId: targetParent?.id,
2381
+ root: cloneDeep(root)
2382
+ });
2405
2383
  await this.select(newConfig);
2406
2384
  stage.select(newConfig.id);
2407
2385
  this.addModifiedNodeId(target.id);
@@ -3019,12 +2997,12 @@ class IdleTask extends EventEmitter {
3019
2997
  return super.emit(eventName, ...args);
3020
2998
  }
3021
2999
  runTaskQueue(deadline) {
3022
- while ((deadline.timeRemaining() > 15 || deadline.didTimeout) && this.taskList.length) {
3000
+ while ((deadline.timeRemaining() > 10 || deadline.didTimeout) && this.taskList.length) {
3023
3001
  const task = this.taskList.shift();
3024
3002
  task.handler(task.data);
3025
3003
  }
3026
3004
  if (this.taskList.length) {
3027
- this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 1e4 });
3005
+ this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 300 });
3028
3006
  } else {
3029
3007
  this.taskHandle = 0;
3030
3008
  this.emit("finish");
@@ -3229,8 +3207,8 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
3229
3207
  }
3230
3208
  });
3231
3209
 
3232
- const _hoisted_1$u = { class: "m-fields-code-select-col" };
3233
- const _hoisted_2$g = { class: "code-select-container" };
3210
+ const _hoisted_1$v = { class: "m-fields-code-select-col" };
3211
+ const _hoisted_2$h = { class: "code-select-container" };
3234
3212
  const _sfc_main$S = /* @__PURE__ */ defineComponent({
3235
3213
  ...{
3236
3214
  name: "MFieldsCodeSelectCol"
@@ -3310,8 +3288,8 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
3310
3288
  eventBus?.emit("edit-code", id);
3311
3289
  };
3312
3290
  return (_ctx, _cache) => {
3313
- return openBlock(), createElementBlock("div", _hoisted_1$u, [
3314
- createElementVNode("div", _hoisted_2$g, [
3291
+ return openBlock(), createElementBlock("div", _hoisted_1$v, [
3292
+ createElementVNode("div", _hoisted_2$h, [
3315
3293
  createVNode(unref(MContainer), {
3316
3294
  class: "select",
3317
3295
  config: selectConfig,
@@ -4181,8 +4159,8 @@ const useNodeStatus$1 = (nodeData) => {
4181
4159
  };
4182
4160
  };
4183
4161
 
4184
- const _hoisted_1$t = { class: "m-editor-data-source-fields" };
4185
- const _hoisted_2$f = { class: "m-editor-data-source-fields-footer" };
4162
+ const _hoisted_1$u = { class: "m-editor-data-source-fields" };
4163
+ const _hoisted_2$g = { class: "m-editor-data-source-fields-footer" };
4186
4164
  const _sfc_main$P = /* @__PURE__ */ defineComponent({
4187
4165
  ...{
4188
4166
  name: "MFieldsDataSourceFields"
@@ -4434,12 +4412,12 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
4434
4412
  const parentFloating = inject("parentFloating", ref(null));
4435
4413
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4436
4414
  return (_ctx, _cache) => {
4437
- return openBlock(), createElementBlock("div", _hoisted_1$t, [
4415
+ return openBlock(), createElementBlock("div", _hoisted_1$u, [
4438
4416
  createVNode(unref(MagicTable), {
4439
4417
  data: _ctx.model[_ctx.name],
4440
4418
  columns: fieldColumns
4441
4419
  }, null, 8, ["data"]),
4442
- createElementVNode("div", _hoisted_2$f, [
4420
+ createElementVNode("div", _hoisted_2$g, [
4443
4421
  createVNode(unref(TMagicButton), {
4444
4422
  size: "small",
4445
4423
  disabled: _ctx.disabled,
@@ -4512,7 +4490,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
4512
4490
  }
4513
4491
  });
4514
4492
 
4515
- const _hoisted_1$s = { class: "m-editor-data-source-field-select" };
4493
+ const _hoisted_1$t = { class: "m-editor-data-source-field-select" };
4516
4494
  const _sfc_main$O = /* @__PURE__ */ defineComponent({
4517
4495
  __name: "FieldSelect",
4518
4496
  props: /* @__PURE__ */ mergeModels({
@@ -4594,7 +4572,7 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
4594
4572
  eventBus?.emit("edit-data-source", removeDataSourceFieldPrefix(id));
4595
4573
  };
4596
4574
  return (_ctx, _cache) => {
4597
- return openBlock(), createElementBlock("div", _hoisted_1$s, [
4575
+ return openBlock(), createElementBlock("div", _hoisted_1$t, [
4598
4576
  _ctx.checkStrictly ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
4599
4577
  createVNode(unref(TMagicSelect), {
4600
4578
  "model-value": selectDataSourceId.value,
@@ -4676,7 +4654,7 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
4676
4654
  }
4677
4655
  });
4678
4656
 
4679
- const _hoisted_1$r = { class: "m-fields-data-source-field-select" };
4657
+ const _hoisted_1$s = { class: "m-fields-data-source-field-select" };
4680
4658
  const _sfc_main$N = /* @__PURE__ */ defineComponent({
4681
4659
  ...{
4682
4660
  name: "MFieldsDataSourceFieldSelect"
@@ -4778,7 +4756,7 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
4778
4756
  }
4779
4757
  };
4780
4758
  return (_ctx, _cache) => {
4781
- return openBlock(), createElementBlock("div", _hoisted_1$r, [
4759
+ return openBlock(), createElementBlock("div", _hoisted_1$s, [
4782
4760
  showDataSourceFieldSelect.value || !_ctx.config.fieldConfig ? (openBlock(), createBlock(_sfc_main$O, {
4783
4761
  key: 0,
4784
4762
  "model-value": _ctx.model[_ctx.name],
@@ -4826,8 +4804,8 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
4826
4804
  }
4827
4805
  });
4828
4806
 
4829
- const _hoisted_1$q = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4830
- const _hoisted_2$e = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4807
+ const _hoisted_1$r = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4808
+ const _hoisted_2$f = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4831
4809
  const _hoisted_3$4 = { class: "el-input__inner t-input__inner" };
4832
4810
  const _sfc_main$M = /* @__PURE__ */ defineComponent({
4833
4811
  ...{
@@ -5032,9 +5010,9 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
5032
5010
  createVNode(_sfc_main$Y, { icon: unref(Coin) }, null, 8, ["icon"])
5033
5011
  ]),
5034
5012
  default: withCtx(({ item }) => [
5035
- createElementVNode("div", _hoisted_1$q, [
5013
+ createElementVNode("div", _hoisted_1$r, [
5036
5014
  createElementVNode("div", null, toDisplayString(item.text), 1),
5037
- createElementVNode("span", _hoisted_2$e, toDisplayString(item.value), 1)
5015
+ createElementVNode("span", _hoisted_2$f, toDisplayString(item.value), 1)
5038
5016
  ])
5039
5017
  ]),
5040
5018
  _: 1
@@ -5075,8 +5053,8 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
5075
5053
  }
5076
5054
  });
5077
5055
 
5078
- const _hoisted_1$p = { style: { "display": "flex", "margin-bottom": "10px" } };
5079
- const _hoisted_2$d = { style: { "flex": "1" } };
5056
+ const _hoisted_1$q = { style: { "display": "flex", "margin-bottom": "10px" } };
5057
+ const _hoisted_2$e = { style: { "flex": "1" } };
5080
5058
  const _hoisted_3$3 = { style: { "flex": "1" } };
5081
5059
  const _hoisted_4$3 = { class: "dialog-footer" };
5082
5060
  const _sfc_main$L = /* @__PURE__ */ defineComponent({
@@ -5329,8 +5307,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
5329
5307
  ])
5330
5308
  ]),
5331
5309
  default: withCtx(() => [
5332
- createElementVNode("div", _hoisted_1$p, [
5333
- createElementVNode("div", _hoisted_2$d, [
5310
+ createElementVNode("div", _hoisted_1$q, [
5311
+ createElementVNode("div", _hoisted_2$e, [
5334
5312
  createVNode(unref(TMagicTag), {
5335
5313
  size: "small",
5336
5314
  type: "info"
@@ -5372,8 +5350,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
5372
5350
  }
5373
5351
  });
5374
5352
 
5375
- const _hoisted_1$o = { class: "m-editor-data-source-methods" };
5376
- const _hoisted_2$c = { class: "m-editor-data-source-methods-footer" };
5353
+ const _hoisted_1$p = { class: "m-editor-data-source-methods" };
5354
+ const _hoisted_2$d = { class: "m-editor-data-source-methods-footer" };
5377
5355
  const _sfc_main$K = /* @__PURE__ */ defineComponent({
5378
5356
  ...{
5379
5357
  name: "MFieldsDataSourceMethods"
@@ -5444,12 +5422,12 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
5444
5422
  emit("change", props.model[props.name]);
5445
5423
  };
5446
5424
  return (_ctx, _cache) => {
5447
- return openBlock(), createElementBlock("div", _hoisted_1$o, [
5425
+ return openBlock(), createElementBlock("div", _hoisted_1$p, [
5448
5426
  createVNode(unref(MagicTable), {
5449
5427
  data: _ctx.model[_ctx.name],
5450
5428
  columns: methodColumns
5451
5429
  }, null, 8, ["data"]),
5452
- createElementVNode("div", _hoisted_2$c, [
5430
+ createElementVNode("div", _hoisted_2$d, [
5453
5431
  createVNode(unref(TMagicButton), {
5454
5432
  size: "small",
5455
5433
  type: "primary",
@@ -5478,8 +5456,8 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
5478
5456
  }
5479
5457
  });
5480
5458
 
5481
- const _hoisted_1$n = { class: "m-fields-data-source-method-select" };
5482
- const _hoisted_2$b = { class: "data-source-method-select-container" };
5459
+ const _hoisted_1$o = { class: "m-fields-data-source-method-select" };
5460
+ const _hoisted_2$c = { class: "data-source-method-select-container" };
5483
5461
  const _sfc_main$J = /* @__PURE__ */ defineComponent({
5484
5462
  ...{
5485
5463
  name: "MFieldsDataSourceMethodSelect"
@@ -5566,8 +5544,8 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
5566
5544
  eventBus?.emit("edit-data-source", id);
5567
5545
  };
5568
5546
  return (_ctx, _cache) => {
5569
- return openBlock(), createElementBlock("div", _hoisted_1$n, [
5570
- createElementVNode("div", _hoisted_2$b, [
5547
+ return openBlock(), createElementBlock("div", _hoisted_1$o, [
5548
+ createElementVNode("div", _hoisted_2$c, [
5571
5549
  createVNode(unref(MContainer), {
5572
5550
  class: "select",
5573
5551
  config: cascaderConfig.value,
@@ -5610,8 +5588,8 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
5610
5588
  }
5611
5589
  });
5612
5590
 
5613
- const _hoisted_1$m = { class: "m-editor-data-source-fields" };
5614
- const _hoisted_2$a = { class: "m-editor-data-source-fields-footer" };
5591
+ const _hoisted_1$n = { class: "m-editor-data-source-fields" };
5592
+ const _hoisted_2$b = { class: "m-editor-data-source-fields-footer" };
5615
5593
  const _sfc_main$I = /* @__PURE__ */ defineComponent({
5616
5594
  ...{
5617
5595
  name: "MFieldsDataSourceMocks"
@@ -5816,12 +5794,12 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
5816
5794
  const parentFloating = inject("parentFloating", ref(null));
5817
5795
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
5818
5796
  return (_ctx, _cache) => {
5819
- return openBlock(), createElementBlock("div", _hoisted_1$m, [
5797
+ return openBlock(), createElementBlock("div", _hoisted_1$n, [
5820
5798
  createVNode(unref(MagicTable), {
5821
5799
  data: _ctx.model[_ctx.name],
5822
5800
  columns
5823
5801
  }, null, 8, ["data"]),
5824
- createElementVNode("div", _hoisted_2$a, [
5802
+ createElementVNode("div", _hoisted_2$b, [
5825
5803
  createVNode(unref(TMagicButton), {
5826
5804
  size: "small",
5827
5805
  type: "primary",
@@ -5863,7 +5841,7 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
5863
5841
  }
5864
5842
  });
5865
5843
 
5866
- const _hoisted_1$l = { class: "m-fields-data-source-select" };
5844
+ const _hoisted_1$m = { class: "m-fields-data-source-select" };
5867
5845
  const _sfc_main$H = /* @__PURE__ */ defineComponent({
5868
5846
  ...{
5869
5847
  name: "MFieldsDataSourceSelect"
@@ -5921,7 +5899,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
5921
5899
  eventBus?.emit("edit-data-source", id);
5922
5900
  };
5923
5901
  return (_ctx, _cache) => {
5924
- return openBlock(), createElementBlock("div", _hoisted_1$l, [
5902
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
5925
5903
  createVNode(unref(MSelect), {
5926
5904
  model: _ctx.model,
5927
5905
  name: _ctx.name,
@@ -6085,8 +6063,8 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
6085
6063
  }
6086
6064
  });
6087
6065
 
6088
- const _hoisted_1$k = { class: "m-fields-event-select" };
6089
- const _hoisted_2$9 = {
6066
+ const _hoisted_1$l = { class: "m-fields-event-select" };
6067
+ const _hoisted_2$a = {
6090
6068
  key: 1,
6091
6069
  class: "fullWidth"
6092
6070
  };
@@ -6364,7 +6342,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
6364
6342
  };
6365
6343
  return (_ctx, _cache) => {
6366
6344
  const _component_m_form_table = resolveComponent("m-form-table");
6367
- return openBlock(), createElementBlock("div", _hoisted_1$k, [
6345
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
6368
6346
  isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
6369
6347
  key: 0,
6370
6348
  ref: "eventForm",
@@ -6374,7 +6352,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
6374
6352
  model: _ctx.model,
6375
6353
  config: tableConfig.value,
6376
6354
  onChange: onChangeHandler
6377
- }, null, 8, ["size", "disabled", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$9, [
6355
+ }, null, 8, ["size", "disabled", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$a, [
6378
6356
  createVNode(unref(TMagicButton), {
6379
6357
  class: "create-button",
6380
6358
  type: "primary",
@@ -6424,7 +6402,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
6424
6402
  }
6425
6403
  });
6426
6404
 
6427
- const _hoisted_1$j = {
6405
+ const _hoisted_1$k = {
6428
6406
  viewBox: "0 0 32 32",
6429
6407
  version: "1.1",
6430
6408
  xmlns: "http://www.w3.org/2000/svg",
@@ -6437,15 +6415,15 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
6437
6415
  __name: "CodeIcon",
6438
6416
  setup(__props) {
6439
6417
  return (_ctx, _cache) => {
6440
- return openBlock(), createElementBlock("svg", _hoisted_1$j, _cache[0] || (_cache[0] = [
6418
+ return openBlock(), createElementBlock("svg", _hoisted_1$k, _cache[0] || (_cache[0] = [
6441
6419
  createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2)
6442
6420
  ]));
6443
6421
  };
6444
6422
  }
6445
6423
  });
6446
6424
 
6447
- const _hoisted_1$i = { class: "m-fields-key-value" };
6448
- const _hoisted_2$8 = { key: 0 };
6425
+ const _hoisted_1$j = { class: "m-fields-key-value" };
6426
+ const _hoisted_2$9 = { key: 0 };
6449
6427
  const _sfc_main$D = /* @__PURE__ */ defineComponent({
6450
6428
  ...{
6451
6429
  name: "MFieldsKeyValue"
@@ -6504,8 +6482,8 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
6504
6482
  emit("change", v);
6505
6483
  };
6506
6484
  return (_ctx, _cache) => {
6507
- return openBlock(), createElementBlock("div", _hoisted_1$i, [
6508
- !showCode.value ? (openBlock(), createElementBlock("div", _hoisted_2$8, [
6485
+ return openBlock(), createElementBlock("div", _hoisted_1$j, [
6486
+ !showCode.value ? (openBlock(), createElementBlock("div", _hoisted_2$9, [
6509
6487
  (openBlock(true), createElementBlock(Fragment, null, renderList(records.value, (item, index) => {
6510
6488
  return openBlock(), createElementBlock("div", {
6511
6489
  class: "m-fields-key-value-item",
@@ -6578,8 +6556,8 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
6578
6556
  }
6579
6557
  });
6580
6558
 
6581
- const _hoisted_1$h = { class: "m-fields-page-fragment-select" };
6582
- const _hoisted_2$7 = { class: "page-fragment-select-container" };
6559
+ const _hoisted_1$i = { class: "m-fields-page-fragment-select" };
6560
+ const _hoisted_2$8 = { class: "page-fragment-select-container" };
6583
6561
  const _sfc_main$C = /* @__PURE__ */ defineComponent({
6584
6562
  ...{
6585
6563
  name: "MFieldsPageFragmentSelect"
@@ -6626,8 +6604,8 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
6626
6604
  };
6627
6605
  return (_ctx, _cache) => {
6628
6606
  const _component_m_form_container = resolveComponent("m-form-container");
6629
- return openBlock(), createElementBlock("div", _hoisted_1$h, [
6630
- createElementVNode("div", _hoisted_2$7, [
6607
+ return openBlock(), createElementBlock("div", _hoisted_1$i, [
6608
+ createElementVNode("div", _hoisted_2$8, [
6631
6609
  createVNode(_component_m_form_container, {
6632
6610
  class: "select",
6633
6611
  config: selectConfig,
@@ -6647,7 +6625,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
6647
6625
  }
6648
6626
  });
6649
6627
 
6650
- const _hoisted_1$g = {
6628
+ const _hoisted_1$h = {
6651
6629
  key: 1,
6652
6630
  class: "m-fields-ui-select",
6653
6631
  style: { "display": "flex" }
@@ -6747,7 +6725,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
6747
6725
  ])),
6748
6726
  _: 1
6749
6727
  }, 8, ["icon", "disabled", "size"])
6750
- ])) : (openBlock(), createElementBlock("div", _hoisted_1$g, [
6728
+ ])) : (openBlock(), createElementBlock("div", _hoisted_1$h, [
6751
6729
  val.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
6752
6730
  createVNode(unref(TMagicTooltip), {
6753
6731
  content: "清除",
@@ -6996,11 +6974,11 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
6996
6974
  }
6997
6975
  });
6998
6976
 
6999
- const _hoisted_1$f = {
6977
+ const _hoisted_1$g = {
7000
6978
  key: 1,
7001
6979
  class: "menu-item-text"
7002
6980
  };
7003
- const _hoisted_2$6 = { class: "el-dropdown-link menubar-menu-button" };
6981
+ const _hoisted_2$7 = { class: "el-dropdown-link menubar-menu-button" };
7004
6982
  const _sfc_main$y = /* @__PURE__ */ defineComponent({
7005
6983
  ...{
7006
6984
  name: "MEditorToolButton"
@@ -7072,7 +7050,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
7072
7050
  _ctx.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
7073
7051
  key: 0,
7074
7052
  direction: _ctx.data.direction || "vertical"
7075
- }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$f, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
7053
+ }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$g, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
7076
7054
  _ctx.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
7077
7055
  key: 0,
7078
7056
  effect: "dark",
@@ -7137,7 +7115,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
7137
7115
  })) : createCommentVNode("", true)
7138
7116
  ]),
7139
7117
  default: withCtx(() => [
7140
- createElementVNode("span", _hoisted_2$6, [
7118
+ createElementVNode("span", _hoisted_2$7, [
7141
7119
  createTextVNode(toDisplayString(_ctx.data.text), 1),
7142
7120
  createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
7143
7121
  default: withCtx(() => [
@@ -7154,7 +7132,12 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
7154
7132
  }
7155
7133
  });
7156
7134
 
7157
- const _hoisted_1$e = {
7135
+ const _hoisted_1$f = {
7136
+ key: 0,
7137
+ id: "m-editor-page-bar-add-icon",
7138
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon"
7139
+ };
7140
+ const _hoisted_2$6 = {
7158
7141
  key: 1,
7159
7142
  style: { "width": "21px" }
7160
7143
  };
@@ -7163,35 +7146,51 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
7163
7146
  name: "MEditorPageBarAddButton"
7164
7147
  },
7165
7148
  __name: "AddButton",
7166
- props: {
7167
- type: {}
7168
- },
7169
7149
  setup(__props) {
7170
- const props = __props;
7171
7150
  const services = inject("services");
7172
7151
  const uiService = services?.uiService;
7173
7152
  const editorService = services?.editorService;
7174
7153
  const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
7175
- const addPage = () => {
7154
+ const addPage = (type) => {
7176
7155
  if (!editorService) return;
7177
7156
  const root = toRaw(editorService.get("root"));
7178
7157
  if (!root) throw new Error("root 不能为空");
7179
7158
  const pageConfig = {
7180
- type: props.type,
7181
- name: generatePageNameByApp(root, props.type),
7159
+ type,
7160
+ name: generatePageNameByApp(root, type),
7182
7161
  items: []
7183
7162
  };
7184
7163
  editorService.add(pageConfig);
7185
7164
  };
7186
7165
  return (_ctx, _cache) => {
7187
- return showAddPageButton.value ? (openBlock(), createElementBlock("div", {
7188
- key: 0,
7189
- id: "m-editor-page-bar-add-icon",
7190
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
7191
- onClick: addPage
7192
- }, [
7193
- createVNode(_sfc_main$Y, { icon: unref(Plus) }, null, 8, ["icon"])
7194
- ])) : (openBlock(), createElementBlock("div", _hoisted_1$e));
7166
+ return showAddPageButton.value ? (openBlock(), createElementBlock("div", _hoisted_1$f, [
7167
+ createVNode(unref(TMagicPopover), { "popper-class": "data-source-list-panel-add-menu" }, {
7168
+ reference: withCtx(() => [
7169
+ createVNode(_sfc_main$Y, { icon: unref(Plus) }, null, 8, ["icon"])
7170
+ ]),
7171
+ default: withCtx(() => [
7172
+ createVNode(_sfc_main$y, {
7173
+ data: {
7174
+ type: "button",
7175
+ text: "页面",
7176
+ handler: () => {
7177
+ addPage(unref(NodeType).PAGE);
7178
+ }
7179
+ }
7180
+ }, null, 8, ["data"]),
7181
+ createVNode(_sfc_main$y, {
7182
+ data: {
7183
+ type: "button",
7184
+ text: "页面片",
7185
+ handler: () => {
7186
+ addPage(unref(NodeType).PAGE_FRAGMENT);
7187
+ }
7188
+ }
7189
+ }, null, 8, ["data"])
7190
+ ]),
7191
+ _: 1
7192
+ })
7193
+ ])) : (openBlock(), createElementBlock("div", _hoisted_2$6));
7195
7194
  };
7196
7195
  }
7197
7196
  });
@@ -7202,8 +7201,8 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
7202
7201
  },
7203
7202
  __name: "PageBarScrollContainer",
7204
7203
  props: {
7205
- type: {},
7206
- pageBarSortOptions: {}
7204
+ pageBarSortOptions: {},
7205
+ length: {}
7207
7206
  },
7208
7207
  setup(__props) {
7209
7208
  const props = __props;
@@ -7216,7 +7215,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
7216
7215
  const showPageListButton = computed(() => uiService?.get("showPageListButton"));
7217
7216
  const itemsContainerWidth = ref(0);
7218
7217
  const setCanScroll = () => {
7219
- itemsContainerWidth.value = (pageBar.value?.clientWidth || 0) - 37 * 2 - (showAddPageButton.value ? 37 : 21) - (showPageListButton.value ? 37 : 0);
7218
+ itemsContainerWidth.value = (pageBar.value?.clientWidth || 0) - 37 * 2 - 37 - (showAddPageButton.value ? 37 : 21) - (showPageListButton.value ? 37 : 0);
7220
7219
  nextTick(() => {
7221
7220
  if (itemsContainer.value) {
7222
7221
  canScroll.value = itemsContainer.value.scrollWidth - itemsContainerWidth.value > 1;
@@ -7254,19 +7253,17 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
7254
7253
  }
7255
7254
  itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
7256
7255
  };
7257
- const pageLength = computed(() => editorService?.get("pageLength") || 0);
7258
- const pageFragmentLength = computed(() => editorService?.get("pageFragmentLength") || 0);
7259
- const crateWatchLength = (length) => watch(
7260
- length,
7261
- (length2 = 0, preLength = 0) => {
7256
+ watch(
7257
+ () => props.length,
7258
+ (length = 0, preLength = 0) => {
7262
7259
  setTimeout(() => {
7263
7260
  setCanScroll();
7264
- if (length2 < preLength) {
7261
+ if (length < preLength) {
7265
7262
  scroll("start");
7266
7263
  } else {
7267
7264
  scroll("end");
7268
7265
  }
7269
- if (length2 > 1) {
7266
+ if (length > 1) {
7270
7267
  const el = document.querySelector(".m-editor-page-bar-items");
7271
7268
  let beforeDragList = [];
7272
7269
  const options = {
@@ -7302,25 +7299,6 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
7302
7299
  immediate: true
7303
7300
  }
7304
7301
  );
7305
- let unWatchPageLength;
7306
- let unWatchPageFragmentLength;
7307
- watch(
7308
- () => props.type,
7309
- (type) => {
7310
- if (type === NodeType.PAGE) {
7311
- unWatchPageFragmentLength?.();
7312
- unWatchPageFragmentLength = null;
7313
- unWatchPageLength = crateWatchLength(pageLength);
7314
- } else {
7315
- unWatchPageLength?.();
7316
- unWatchPageLength = null;
7317
- unWatchPageFragmentLength = crateWatchLength(pageFragmentLength);
7318
- }
7319
- },
7320
- {
7321
- immediate: true
7322
- }
7323
- );
7324
7302
  return (_ctx, _cache) => {
7325
7303
  return openBlock(), createElementBlock("div", {
7326
7304
  class: "m-editor-page-bar",
@@ -7335,7 +7313,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
7335
7313
  }, [
7336
7314
  createVNode(_sfc_main$Y, { icon: unref(ArrowLeftBold) }, null, 8, ["icon"])
7337
7315
  ])) : createCommentVNode("", true),
7338
- _ctx.type === unref(NodeType).PAGE && pageLength.value || _ctx.type === unref(NodeType).PAGE_FRAGMENT && pageFragmentLength.value ? (openBlock(), createElementBlock("div", {
7316
+ _ctx.length ? (openBlock(), createElementBlock("div", {
7339
7317
  key: 1,
7340
7318
  class: "m-editor-page-bar-items",
7341
7319
  ref_key: "itemsContainer",
@@ -7356,7 +7334,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
7356
7334
  }
7357
7335
  });
7358
7336
 
7359
- const _hoisted_1$d = {
7337
+ const _hoisted_1$e = {
7360
7338
  key: 0,
7361
7339
  id: "m-editor-page-bar-list-icon",
7362
7340
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon"
@@ -7378,7 +7356,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
7378
7356
  editorService?.select(id);
7379
7357
  };
7380
7358
  return (_ctx, _cache) => {
7381
- return showPageListButton.value ? (openBlock(), createElementBlock("div", _hoisted_1$d, [
7359
+ return showPageListButton.value ? (openBlock(), createElementBlock("div", _hoisted_1$e, [
7382
7360
  createVNode(unref(TMagicPopover), {
7383
7361
  "popper-class": "page-bar-popover",
7384
7362
  placement: "top",
@@ -7417,46 +7395,63 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
7417
7395
  }
7418
7396
  });
7419
7397
 
7398
+ const _hoisted_1$d = { class: "m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-search" };
7420
7399
  const _sfc_main$u = /* @__PURE__ */ defineComponent({
7421
- ...{
7422
- name: "MEditorPageBarSwitchTypeButton"
7423
- },
7424
- __name: "SwitchTypeButton",
7400
+ __name: "Search",
7425
7401
  props: {
7426
- modelValue: {}
7402
+ "query": {},
7403
+ "queryModifiers": {}
7427
7404
  },
7428
- emits: ["update:modelValue"],
7405
+ emits: /* @__PURE__ */ mergeModels(["search"], ["update:query"]),
7429
7406
  setup(__props, { emit: __emit }) {
7430
- const data = [
7407
+ const emit = __emit;
7408
+ const query = useModel(__props, "query");
7409
+ const formConfig = createForm([
7431
7410
  {
7432
- type: NodeType.PAGE,
7433
- text: "页面"
7411
+ type: "checkbox-group",
7412
+ name: "pageType",
7413
+ options: [
7414
+ {
7415
+ value: NodeType.PAGE,
7416
+ text: "页面"
7417
+ },
7418
+ {
7419
+ value: NodeType.PAGE_FRAGMENT,
7420
+ text: "页面片段"
7421
+ }
7422
+ ]
7434
7423
  },
7435
7424
  {
7436
- type: NodeType.PAGE_FRAGMENT,
7437
- text: "页面片"
7425
+ name: "keyword",
7426
+ placeholder: "请输入关键字"
7438
7427
  }
7439
- ];
7440
- const emit = __emit;
7441
- const clickHandler = (value) => {
7442
- emit("update:modelValue", value);
7428
+ ]);
7429
+ const visible = ref(false);
7430
+ const onFormChange = (values) => {
7431
+ query.value = values;
7432
+ emit("search", values);
7443
7433
  };
7444
7434
  return (_ctx, _cache) => {
7445
- return openBlock(), createElementBlock(Fragment, null, renderList(data, (item) => {
7446
- return createVNode(unref(TMagicButton), {
7447
- class: normalizeClass(["m-editor-page-bar-switch-type-button", { active: _ctx.modelValue === item.type }]),
7448
- size: "small",
7449
- key: item.type,
7450
- link: "",
7451
- type: _ctx.modelValue === item.type ? "primary" : "",
7452
- onClick: ($event) => clickHandler(item.type)
7453
- }, {
7454
- default: withCtx(() => [
7455
- createTextVNode(toDisplayString(item.text), 1)
7456
- ]),
7457
- _: 2
7458
- }, 1032, ["class", "type", "onClick"]);
7459
- }), 64);
7435
+ return openBlock(), createElementBlock("div", _hoisted_1$d, [
7436
+ createVNode(_sfc_main$Y, {
7437
+ icon: unref(Search),
7438
+ onClick: _cache[0] || (_cache[0] = ($event) => visible.value = !visible.value),
7439
+ class: normalizeClass({ "icon-active": visible.value })
7440
+ }, null, 8, ["icon", "class"]),
7441
+ visible.value ? (openBlock(), createBlock(Teleport, {
7442
+ key: 0,
7443
+ to: ".m-editor-page-bar-tabs"
7444
+ }, [
7445
+ query.value ? (openBlock(), createBlock(unref(MForm), {
7446
+ key: 0,
7447
+ class: "m-editor-page-bar-search-panel",
7448
+ inline: true,
7449
+ config: unref(formConfig),
7450
+ "init-values": query.value,
7451
+ onChange: onFormChange
7452
+ }, null, 8, ["config", "init-values"])) : createCommentVNode("", true)
7453
+ ])) : createCommentVNode("", true)
7454
+ ]);
7460
7455
  };
7461
7456
  }
7462
7457
  });
@@ -7475,60 +7470,28 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
7475
7470
  pageBarSortOptions: {}
7476
7471
  },
7477
7472
  setup(__props) {
7478
- const active = ref(NodeType.PAGE);
7479
7473
  const services = inject("services");
7480
7474
  const editorService = services?.editorService;
7481
7475
  const root = computed(() => editorService?.get("root"));
7482
7476
  const page = computed(() => editorService?.get("page"));
7483
- const pageList = computed(() => getPageList(root.value));
7484
- const pageFragmentList = computed(() => getPageFragmentList(root.value));
7485
- const list = computed(() => active.value === NodeType.PAGE ? pageList.value : pageFragmentList.value);
7486
- const activePage = ref("");
7487
- const activePageFragment = ref("");
7488
- watch(
7489
- page,
7490
- (page2) => {
7491
- if (!page2) {
7492
- if (active.value === NodeType.PAGE) {
7493
- activePage.value = "";
7494
- }
7495
- if (active.value === NodeType.PAGE_FRAGMENT) {
7496
- activePageFragment.value = "";
7497
- }
7498
- return;
7499
- }
7500
- if (isPage(page2)) {
7501
- activePage.value = page2?.id;
7502
- if (active.value !== NodeType.PAGE) {
7503
- active.value = NodeType.PAGE;
7504
- }
7505
- } else if (isPageFragment(page2)) {
7506
- activePageFragment.value = page2?.id;
7507
- if (active.value !== NodeType.PAGE_FRAGMENT) {
7508
- active.value = NodeType.PAGE_FRAGMENT;
7509
- }
7510
- }
7511
- },
7512
- {
7513
- immediate: true
7514
- }
7515
- );
7516
- watch(active, (active2) => {
7517
- if (active2 === NodeType.PAGE) {
7518
- if (!activePage.value && !pageList.value.length) {
7519
- editorService?.selectRoot();
7520
- return;
7521
- }
7522
- switchPage(activePage.value);
7523
- return;
7477
+ const query = ref({
7478
+ pageType: [NodeType.PAGE, NodeType.PAGE_FRAGMENT],
7479
+ keyword: ""
7480
+ });
7481
+ const list = computed(() => {
7482
+ const { pageType, keyword } = query.value;
7483
+ if (pageType.length === 0) {
7484
+ return [];
7524
7485
  }
7525
- if (active2 === NodeType.PAGE_FRAGMENT) {
7526
- if (!activePageFragment.value && !pageFragmentList.value.length) {
7527
- editorService?.selectRoot();
7528
- return;
7486
+ return (root.value?.items || []).filter((item) => {
7487
+ if (pageType.includes(item.type)) {
7488
+ if (keyword) {
7489
+ return item.name?.includes(keyword);
7490
+ }
7491
+ return true;
7529
7492
  }
7530
- switchPage(activePageFragment.value || pageFragmentList.value[0].id);
7531
- }
7493
+ return false;
7494
+ });
7532
7495
  });
7533
7496
  const switchPage = (id) => {
7534
7497
  editorService?.select(id);
@@ -7545,17 +7508,18 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
7545
7508
  };
7546
7509
  return (_ctx, _cache) => {
7547
7510
  return openBlock(), createElementBlock("div", _hoisted_1$c, [
7548
- !_ctx.disabledPageFragment ? (openBlock(), createBlock(_sfc_main$u, {
7549
- key: 0,
7550
- modelValue: active.value,
7551
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => active.value = $event)
7552
- }, null, 8, ["modelValue"])) : createCommentVNode("", true),
7553
7511
  createVNode(_sfc_main$w, {
7554
- type: active.value,
7555
- "page-bar-sort-options": _ctx.pageBarSortOptions
7512
+ "page-bar-sort-options": _ctx.pageBarSortOptions,
7513
+ length: list.value.length
7556
7514
  }, {
7557
7515
  prepend: withCtx(() => [
7558
- createVNode(_sfc_main$x, { type: active.value }, null, 8, ["type"]),
7516
+ renderSlot(_ctx.$slots, "page-bar-add-button", {}, () => [
7517
+ createVNode(_sfc_main$x)
7518
+ ]),
7519
+ createVNode(_sfc_main$u, {
7520
+ query: query.value,
7521
+ "onUpdate:query": _cache[0] || (_cache[0] = ($event) => query.value = $event)
7522
+ }, null, 8, ["query"]),
7559
7523
  createVNode(_sfc_main$v, { list: list.value }, {
7560
7524
  "page-list-popover": withCtx(({ list: list2 }) => [
7561
7525
  renderSlot(_ctx.$slots, "page-list-popover", { list: list2 })
@@ -7621,7 +7585,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
7621
7585
  }), 128))
7622
7586
  ]),
7623
7587
  _: 3
7624
- }, 8, ["type", "page-bar-sort-options"])
7588
+ }, 8, ["page-bar-sort-options", "length"])
7625
7589
  ]);
7626
7590
  };
7627
7591
  }
@@ -7798,6 +7762,9 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
7798
7762
  "disabled-page-fragment": _ctx.disabledPageFragment,
7799
7763
  "page-bar-sort-options": _ctx.pageBarSortOptions
7800
7764
  }, {
7765
+ "page-bar-add-button": withCtx(() => [
7766
+ renderSlot(_ctx.$slots, "page-bar-add-button")
7767
+ ]),
7801
7768
  "page-bar-title": withCtx(({ page: page2 }) => [
7802
7769
  renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
7803
7770
  ]),
@@ -11003,9 +10970,17 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
11003
10970
  if (!stage || !zoom2) return;
11004
10971
  stage.setZoom(zoom2);
11005
10972
  });
10973
+ let timeoutId = null;
11006
10974
  watch(page, (page2) => {
11007
10975
  if (runtime && page2) {
11008
10976
  services?.editorService.set("stageLoading", true);
10977
+ if (timeoutId) {
10978
+ globalThis.clearTimeout(timeoutId);
10979
+ }
10980
+ timeoutId = globalThis.setTimeout(() => {
10981
+ services?.editorService.set("stageLoading", false);
10982
+ timeoutId = null;
10983
+ }, 3e3);
11009
10984
  runtime.updatePageId?.(page2.id);
11010
10985
  nextTick(() => {
11011
10986
  stage?.select(page2.id);
@@ -11686,8 +11661,11 @@ class Dep extends BaseService {
11686
11661
  }
11687
11662
  );
11688
11663
  });
11689
- idleTask.once("finish", () => {
11690
- this.emit("collected", nodes, deep);
11664
+ return new Promise((resolve) => {
11665
+ idleTask.once("finish", () => {
11666
+ this.emit("collected", nodes, deep);
11667
+ resolve();
11668
+ });
11691
11669
  });
11692
11670
  }
11693
11671
  collectNode(node, target, depExtendedData = {}, deep = false) {
@@ -12324,49 +12302,19 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
12324
12302
  const stage = editorService.get("stage");
12325
12303
  return stage?.renderer?.runtime?.getApp?.();
12326
12304
  };
12327
- const updateDataSourceSchema = () => {
12328
- const root = editorService.get("root");
12329
- if (root?.dataSources) {
12330
- getApp()?.dataSourceManager?.updateSchema(root.dataSources);
12331
- }
12332
- };
12333
- const targetAddHandler = (target) => {
12305
+ const updateDataSourceSchema = (nodes, deep) => {
12334
12306
  const root = editorService.get("root");
12335
- if (!root) return;
12336
- if (target.type === DepTargetType.DATA_SOURCE) {
12337
- if (!root.dataSourceDeps) {
12338
- root.dataSourceDeps = {};
12339
- }
12340
- root.dataSourceDeps[target.id] = target.deps;
12341
- }
12342
- if (target.type === DepTargetType.DATA_SOURCE_COND) {
12343
- if (!root.dataSourceCondDeps) {
12344
- root.dataSourceCondDeps = {};
12345
- }
12346
- root.dataSourceCondDeps[target.id] = target.deps;
12347
- }
12348
- };
12349
- const targetRemoveHandler = (id) => {
12350
- const root = editorService.get("root");
12351
- if (root?.dataSourceDeps) {
12352
- delete root.dataSourceDeps[id];
12353
- }
12354
- if (root?.dataSourceCondDeps) {
12355
- delete root.dataSourceCondDeps[id];
12356
- }
12357
- };
12358
- const collectedHandler = debounce((nodes, deep) => {
12359
- const root = editorService.get("root");
12360
- const stage = editorService.get("stage");
12361
- if (!root || !stage) return;
12362
12307
  const app = getApp();
12363
- if (!app) return;
12364
- if (app.dsl) {
12308
+ if (root && app?.dsl) {
12365
12309
  app.dsl.dataSourceDeps = root.dataSourceDeps;
12366
12310
  app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
12367
12311
  app.dsl.dataSources = root.dataSources;
12368
12312
  }
12369
- updateDataSourceSchema();
12313
+ if (root?.dataSources) {
12314
+ getApp()?.dataSourceManager?.updateSchema(root.dataSources);
12315
+ }
12316
+ const stage = editorService.get("stage");
12317
+ if (!root || !stage) return;
12370
12318
  const allNodes = [];
12371
12319
  if (deep) {
12372
12320
  nodes.forEach((node) => {
@@ -12390,17 +12338,58 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
12390
12338
  });
12391
12339
  });
12392
12340
  });
12393
- }, 300);
12341
+ };
12342
+ const afterUpdateNodes = (nodes) => {
12343
+ const root = editorService.get("root");
12344
+ if (!root) return;
12345
+ const stage = editorService.get("stage");
12346
+ const app = getApp();
12347
+ if (app?.dsl) {
12348
+ app.dsl.dataSourceDeps = root.dataSourceDeps;
12349
+ }
12350
+ for (const node of nodes) {
12351
+ stage?.update({
12352
+ config: cloneDeep(node),
12353
+ parentId: editorService.getParentById(node.id)?.id,
12354
+ root: cloneDeep(root)
12355
+ });
12356
+ }
12357
+ };
12358
+ const targetAddHandler = (target) => {
12359
+ const root = editorService.get("root");
12360
+ if (!root) return;
12361
+ if (target.type === DepTargetType.DATA_SOURCE) {
12362
+ if (!root.dataSourceDeps) {
12363
+ root.dataSourceDeps = {};
12364
+ }
12365
+ root.dataSourceDeps[target.id] = target.deps;
12366
+ }
12367
+ if (target.type === DepTargetType.DATA_SOURCE_COND) {
12368
+ if (!root.dataSourceCondDeps) {
12369
+ root.dataSourceCondDeps = {};
12370
+ }
12371
+ root.dataSourceCondDeps[target.id] = target.deps;
12372
+ }
12373
+ };
12374
+ const targetRemoveHandler = (id) => {
12375
+ const root = editorService.get("root");
12376
+ if (!root) return;
12377
+ if (root.dataSourceDeps) {
12378
+ delete root.dataSourceDeps[id];
12379
+ }
12380
+ if (root.dataSourceCondDeps) {
12381
+ delete root.dataSourceCondDeps[id];
12382
+ }
12383
+ };
12394
12384
  depService.on("add-target", targetAddHandler);
12395
12385
  depService.on("remove-target", targetRemoveHandler);
12396
- depService.on("collected", collectedHandler);
12397
12386
  const initDataSourceDepTarget = (ds) => {
12398
12387
  depService.addTarget(createDataSourceTarget(ds, reactive({})));
12399
12388
  depService.addTarget(createDataSourceMethodTarget(ds, reactive({})));
12400
12389
  depService.addTarget(createDataSourceCondTarget(ds, reactive({})));
12401
12390
  };
12402
- const collectIdle = (nodes, deep) => {
12403
- nodes.forEach((node) => {
12391
+ const collectIdle = (nodes, deep) => Promise.all(
12392
+ nodes.map((node) => {
12404
12393
  let pageId;
12405
12394
  if (isPage(node)) {
12406
12395
  pageId = node.id;
@@ -12408,20 +12397,26 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
12408
12397
  const info = editorService.getNodeInfo(node.id);
12409
12398
  pageId = info.page?.id;
12410
12399
  }
12411
- depService.collectIdle([node], { pageId }, deep);
12412
- });
12413
- };
12400
+ return depService.collectIdle([node], { pageId }, deep);
12401
+ })
12402
+ );
12414
12403
  const nodeAddHandler = (nodes) => {
12415
- collectIdle(nodes, true);
12404
+ collectIdle(nodes, true).then(() => {
12405
+ afterUpdateNodes(nodes);
12406
+ });
12416
12407
  };
12417
12408
  const nodeUpdateHandler = (nodes) => {
12418
- collectIdle(nodes, true);
12409
+ collectIdle(nodes, true).then(() => {
12410
+ afterUpdateNodes(nodes);
12411
+ });
12419
12412
  };
12420
12413
  const nodeRemoveHandler = (nodes) => {
12421
12414
  depService.clear(nodes);
12422
12415
  };
12423
12416
  const historyChangeHandler = (page) => {
12424
- collectIdle([page], true);
12417
+ collectIdle([page], true).then(() => {
12418
+ updateDataSourceSchema([page], true);
12419
+ });
12425
12420
  };
12426
12421
  editorService.on("history-change", historyChangeHandler);
12427
12422
  editorService.on("root-change", rootChangeHandler);
@@ -12448,7 +12443,9 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
12448
12443
  const root = editorService.get("root");
12449
12444
  removeDataSourceTarget(config.id);
12450
12445
  initDataSourceDepTarget(config);
12451
- collectIdle(root?.items || [], true);
12446
+ collectIdle(root?.items || [], true).then(() => {
12447
+ updateDataSourceSchema(root?.items || [], true);
12448
+ });
12452
12449
  };
12453
12450
  const removeDataSourceTarget = (id) => {
12454
12451
  depService.removeTarget(id, DepTargetType.DATA_SOURCE);
@@ -12456,8 +12453,13 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
12456
12453
  depService.removeTarget(id, DepTargetType.DATA_SOURCE_METHOD);
12457
12454
  };
12458
12455
  const dataSourceRemoveHandler = (id) => {
12456
+ const root = editorService.get("root");
12457
+ const nodeIds = Object.keys(root?.dataSourceDeps?.[id] || {});
12458
+ const nodes = getNodes(nodeIds, root?.items);
12459
+ collectIdle(nodes, false).then(() => {
12460
+ updateDataSourceSchema(nodes, false);
12461
+ });
12459
12462
  removeDataSourceTarget(id);
12460
- getApp()?.dataSourceManager?.removeDataSource(id);
12461
12463
  };
12462
12464
  dataSourceService.on("add", dataSourceAddHandler);
12463
12465
  dataSourceService.on("update", dataSourceUpdateHandler);
@@ -12465,7 +12467,6 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
12465
12467
  onBeforeUnmount(() => {
12466
12468
  depService.off("add-target", targetAddHandler);
12467
12469
  depService.off("remove-target", targetRemoveHandler);
12468
- depService.off("collected", collectedHandler);
12469
12470
  editorService.off("history-change", historyChangeHandler);
12470
12471
  editorService.off("root-change", rootChangeHandler);
12471
12472
  editorService.off("add", nodeAddHandler);
@@ -12684,6 +12685,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
12684
12685
  "page-bar": withCtx(() => [
12685
12686
  renderSlot(_ctx.$slots, "page-bar")
12686
12687
  ]),
12688
+ "page-bar-add-button": withCtx(() => [
12689
+ renderSlot(_ctx.$slots, "page-bar-add-button")
12690
+ ]),
12687
12691
  "page-bar-title": withCtx(({ page }) => [
12688
12692
  renderSlot(_ctx.$slots, "page-bar-title", { page })
12689
12693
  ]),