@tmagic/editor 1.1.0 → 1.1.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.
@@ -12,13 +12,6 @@ import Gesto from 'gesto';
12
12
  import { ElMessage } from 'element-plus';
13
13
  import KeyController from 'keycon';
14
14
 
15
- if (typeof global === "undefined") {
16
- window.global = window;
17
- }
18
- if (typeof globalThis === "undefined") {
19
- window.globalThis = window;
20
- }
21
-
22
15
  const _sfc_main$o = defineComponent({
23
16
  name: "m-fields-vs-code",
24
17
  props: ["model", "name", "config", "prop"],
@@ -45,7 +38,7 @@ const _export_sfc = (sfc, props) => {
45
38
  return target;
46
39
  };
47
40
 
48
- function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
41
+ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
49
42
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
50
43
  return openBlock(), createBlock(_component_magic_code_editor, {
51
44
  style: normalizeStyle(`height: ${_ctx.height}`),
@@ -54,7 +47,7 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
54
47
  onSave: _ctx.save
55
48
  }, null, 8, ["style", "init-values", "language", "onSave"]);
56
49
  }
57
- const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$b]]);
50
+ const Code = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["render", _sfc_render$a]]);
58
51
 
59
52
  const _sfc_main$n = defineComponent({
60
53
  name: "m-fields-code-link",
@@ -112,7 +105,7 @@ const _sfc_main$n = defineComponent({
112
105
  }
113
106
  });
114
107
 
115
- function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
108
+ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
116
109
  const _component_m_fields_link = resolveComponent("m-fields-link");
117
110
  return openBlock(), createBlock(_component_m_fields_link, {
118
111
  config: _ctx.formConfig,
@@ -121,9 +114,9 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
121
114
  onChange: _ctx.changeHandler
122
115
  }, null, 8, ["config", "model", "onChange"]);
123
116
  }
124
- const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$a]]);
117
+ const CodeLink = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$9]]);
125
118
 
126
- const _hoisted_1$b = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
119
+ const _hoisted_1$c = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
127
120
  const _sfc_main$m = /* @__PURE__ */ defineComponent({
128
121
  __name: "UISelect",
129
122
  props: {
@@ -189,7 +182,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
189
182
  style: { "padding": "0" }
190
183
  }, {
191
184
  default: withCtx(() => [
192
- _hoisted_1$b
185
+ _hoisted_1$c
193
186
  ]),
194
187
  _: 1
195
188
  }, 8, ["icon"])
@@ -360,14 +353,14 @@ const _sfc_main$l = defineComponent({
360
353
  }
361
354
  });
362
355
 
363
- const _hoisted_1$a = {
356
+ const _hoisted_1$b = {
364
357
  ref: "codeEditor",
365
358
  class: "magic-code-editor"
366
359
  };
367
- function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
368
- return openBlock(), createElementBlock("div", _hoisted_1$a, null, 512);
360
+ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
361
+ return openBlock(), createElementBlock("div", _hoisted_1$b, null, 512);
369
362
  }
370
- const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$9]]);
363
+ const CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["render", _sfc_render$8]]);
371
364
 
372
365
  let $TMAGIC_EDITOR = {};
373
366
  const setConfig = (option) => {
@@ -1278,7 +1271,7 @@ class Editor$1 extends BaseService {
1278
1271
  await this.select(root.items[0]);
1279
1272
  stage?.select(root.items[0].id);
1280
1273
  } else {
1281
- this.set("node", null);
1274
+ this.set("nodes", [root]);
1282
1275
  this.set("parent", null);
1283
1276
  this.set("page", null);
1284
1277
  this.set("stage", null);
@@ -1424,12 +1417,15 @@ class Editor$1 extends BaseService {
1424
1417
  const node = this.get("node");
1425
1418
  const brothers = parent?.items || [];
1426
1419
  const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
1420
+ const layout = await this.getLayout(parent, node);
1421
+ const isRelative = layout === Layout.RELATIVE;
1422
+ brothers.splice(index, 1);
1427
1423
  if (offset === LayerOffset.TOP) {
1428
- brothers.splice(brothers.length - 1, 0, brothers.splice(index, 1)[0]);
1424
+ brothers.splice(isRelative ? 0 : brothers.length - 1, 0, node);
1429
1425
  } else if (offset === LayerOffset.BOTTOM) {
1430
- brothers.splice(0, 0, brothers.splice(index, 1)[0]);
1426
+ brothers.splice(isRelative ? brothers.length - 1 : 0, 0, node);
1431
1427
  } else {
1432
- brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
1428
+ brothers.splice(index + (isRelative ? -offset : offset), 0, node);
1433
1429
  }
1434
1430
  const grandparent = this.getParentById(parent.id);
1435
1431
  this.get("stage")?.update({
@@ -1883,7 +1879,8 @@ const state = reactive({
1883
1879
  columnWidth: defaultColumnWidth,
1884
1880
  showGuides: true,
1885
1881
  showRule: true,
1886
- propsPanelSize: "small"
1882
+ propsPanelSize: "small",
1883
+ showAddPageButton: true
1887
1884
  });
1888
1885
  class Ui extends BaseService {
1889
1886
  constructor() {
@@ -2063,13 +2060,13 @@ const _sfc_main$k = defineComponent({
2063
2060
  }
2064
2061
  });
2065
2062
 
2066
- const _hoisted_1$9 = { class: "m-editor-empty-panel" };
2063
+ const _hoisted_1$a = { class: "m-editor-empty-panel" };
2067
2064
  const _hoisted_2$4 = { class: "m-editor-empty-content" };
2068
2065
  const _hoisted_3 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
2069
- function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2066
+ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2070
2067
  const _component_plus = resolveComponent("plus");
2071
2068
  const _component_el_icon = resolveComponent("el-icon");
2072
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
2069
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
2073
2070
  createElementVNode("div", _hoisted_2$4, [
2074
2071
  createElementVNode("div", {
2075
2072
  class: "m-editor-empty-button",
@@ -2088,7 +2085,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
2088
2085
  ])
2089
2086
  ]);
2090
2087
  }
2091
- const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$8]]);
2088
+ const AddPageBox = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["render", _sfc_render$7]]);
2092
2089
 
2093
2090
  const _sfc_main$j = defineComponent({
2094
2091
  name: "m-editor-resize",
@@ -2133,16 +2130,16 @@ const _sfc_main$j = defineComponent({
2133
2130
  }
2134
2131
  });
2135
2132
 
2136
- const _hoisted_1$8 = {
2133
+ const _hoisted_1$9 = {
2137
2134
  ref: "target",
2138
2135
  class: "m-editor-resizer"
2139
2136
  };
2140
- function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
2141
- return openBlock(), createElementBlock("span", _hoisted_1$8, [
2137
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2138
+ return openBlock(), createElementBlock("span", _hoisted_1$9, [
2142
2139
  renderSlot(_ctx.$slots, "default")
2143
2140
  ], 512);
2144
2141
  }
2145
- const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$7]]);
2142
+ const Resizer = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["render", _sfc_render$6]]);
2146
2143
 
2147
2144
  const _sfc_main$i = defineComponent({
2148
2145
  components: {
@@ -2174,17 +2171,17 @@ const _sfc_main$i = defineComponent({
2174
2171
  }
2175
2172
  });
2176
2173
 
2177
- const _hoisted_1$7 = { class: "m-editor" };
2174
+ const _hoisted_1$8 = { class: "m-editor" };
2178
2175
  const _hoisted_2$3 = {
2179
2176
  key: 1,
2180
2177
  class: "m-editor-content"
2181
2178
  };
2182
- function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2179
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2183
2180
  const _component_magic_code_editor = resolveComponent("magic-code-editor");
2184
2181
  const _component_resizer = resolveComponent("resizer");
2185
2182
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
2186
2183
  const _component_add_page_box = resolveComponent("add-page-box");
2187
- return openBlock(), createElementBlock("div", _hoisted_1$7, [
2184
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
2188
2185
  renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2189
2186
  _ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
2190
2187
  key: 0,
@@ -2225,9 +2222,9 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2225
2222
  ]))
2226
2223
  ]);
2227
2224
  }
2228
- const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$6]]);
2225
+ const Framework = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["render", _sfc_render$5]]);
2229
2226
 
2230
- const _hoisted_1$6 = ["src"];
2227
+ const _hoisted_1$7 = ["src"];
2231
2228
  const _sfc_main$h = /* @__PURE__ */ defineComponent({
2232
2229
  __name: "Icon",
2233
2230
  props: {
@@ -2236,20 +2233,29 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
2236
2233
  setup(__props) {
2237
2234
  return (_ctx, _cache) => {
2238
2235
  const _component_el_icon = resolveComponent("el-icon");
2239
- return !__props.icon ? (openBlock(), createBlock(_component_el_icon, { key: 0 }, {
2236
+ return !__props.icon ? (openBlock(), createBlock(_component_el_icon, {
2237
+ key: 0,
2238
+ class: "magic-editor-icon"
2239
+ }, {
2240
2240
  default: withCtx(() => [
2241
2241
  createVNode(unref(Edit))
2242
2242
  ]),
2243
2243
  _: 1
2244
- })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, { key: 1 }, {
2244
+ })) : typeof __props.icon === "string" && __props.icon.startsWith("http") ? (openBlock(), createBlock(_component_el_icon, {
2245
+ key: 1,
2246
+ class: "magic-editor-icon"
2247
+ }, {
2245
2248
  default: withCtx(() => [
2246
- createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$6)
2249
+ createElementVNode("img", { src: __props.icon }, null, 8, _hoisted_1$7)
2247
2250
  ]),
2248
2251
  _: 1
2249
2252
  })) : typeof __props.icon === "string" ? (openBlock(), createElementBlock("i", {
2250
2253
  key: 2,
2251
- class: normalizeClass(__props.icon)
2252
- }, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
2254
+ class: normalizeClass(["magic-editor-icon", __props.icon])
2255
+ }, null, 2)) : (openBlock(), createBlock(_component_el_icon, {
2256
+ key: 3,
2257
+ class: "magic-editor-icon"
2258
+ }, {
2253
2259
  default: withCtx(() => [
2254
2260
  (openBlock(), createBlock(resolveDynamicComponent(toRaw(__props.icon))))
2255
2261
  ]),
@@ -2259,7 +2265,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
2259
2265
  }
2260
2266
  });
2261
2267
 
2262
- const _hoisted_1$5 = {
2268
+ const _hoisted_1$6 = {
2263
2269
  key: 1,
2264
2270
  class: "menu-item-text"
2265
2271
  };
@@ -2347,7 +2353,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
2347
2353
  __props.data.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2348
2354
  key: 0,
2349
2355
  direction: __props.data.direction || "vertical"
2350
- }, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$5, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2356
+ }, null, 8, ["direction"])) : __props.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$6, toDisplayString(__props.data.text), 1)) : __props.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2351
2357
  __props.data.tooltip ? (openBlock(), createBlock(_component_el_tooltip, {
2352
2358
  key: 0,
2353
2359
  effect: "dark",
@@ -2590,7 +2596,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
2590
2596
  }
2591
2597
  });
2592
2598
 
2593
- const _hoisted_1$4 = { class: "`m-editor-props-panel" };
2599
+ const _hoisted_1$5 = { class: "`m-editor-props-panel" };
2594
2600
  const _sfc_main$e = /* @__PURE__ */ defineComponent({
2595
2601
  __name: "PropsPanel",
2596
2602
  emits: ["mounted"],
@@ -2640,7 +2646,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
2640
2646
  expose({ submit });
2641
2647
  return (_ctx, _cache) => {
2642
2648
  const _component_m_form = resolveComponent("m-form");
2643
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
2649
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [
2644
2650
  renderSlot(_ctx.$slots, "props-panel-header"),
2645
2651
  createVNode(_component_m_form, {
2646
2652
  ref_key: "configForm",
@@ -2657,10 +2663,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
2657
2663
  }
2658
2664
  });
2659
2665
 
2660
- const _sfc_main$d = defineComponent({
2661
- name: "ui-component-panel",
2662
- components: { MIcon: _sfc_main$h },
2663
- setup() {
2666
+ const _hoisted_1$4 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2667
+ const _hoisted_2$1 = ["onClick", "onDragstart"];
2668
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
2669
+ __name: "ComponentListPanel",
2670
+ setup(__props) {
2664
2671
  const searchText = ref("");
2665
2672
  const services = inject("services");
2666
2673
  const stageOptions = inject("stageOptions");
@@ -2673,132 +2680,124 @@ const _sfc_main$d = defineComponent({
2673
2680
  let timeout;
2674
2681
  let clientX;
2675
2682
  let clientY;
2676
- return {
2677
- searchText,
2678
- collapseValue,
2679
- list,
2680
- appendComponent({ text, type, data = {} }) {
2681
- services?.editorService.add({
2683
+ const appendComponent = ({ text, type, data = {} }) => {
2684
+ services?.editorService.add({
2685
+ name: text,
2686
+ type,
2687
+ ...data
2688
+ });
2689
+ };
2690
+ const dragstartHandler = ({ text, type, data = {} }, e) => {
2691
+ if (e.dataTransfer) {
2692
+ e.dataTransfer.effectAllowed = "move";
2693
+ e.dataTransfer.setData("data", serialize({
2682
2694
  name: text,
2683
2695
  type,
2684
2696
  ...data
2685
- });
2686
- },
2687
- dragstartHandler({ text, type, data = {} }, e) {
2688
- if (e.dataTransfer) {
2689
- e.dataTransfer.effectAllowed = "move";
2690
- e.dataTransfer.setData("data", serialize({
2691
- name: text,
2692
- type,
2693
- ...data
2694
- }).replace(/"(\w+)":\s/g, "$1: "));
2695
- }
2696
- },
2697
- dragendHandler() {
2697
+ }).replace(/"(\w+)":\s/g, "$1: "));
2698
+ }
2699
+ };
2700
+ const dragendHandler = () => {
2701
+ if (timeout) {
2702
+ globalThis.clearTimeout(timeout);
2703
+ timeout = void 0;
2704
+ }
2705
+ const doc = stage.value?.renderer.contentWindow?.document;
2706
+ if (doc && stageOptions) {
2707
+ removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
2708
+ }
2709
+ clientX = 0;
2710
+ clientY = 0;
2711
+ };
2712
+ const dragHandler = (e) => {
2713
+ if (e.clientX !== clientX || e.clientY !== clientY) {
2714
+ clientX = e.clientX;
2715
+ clientY = e.clientY;
2698
2716
  if (timeout) {
2699
2717
  globalThis.clearTimeout(timeout);
2700
2718
  timeout = void 0;
2701
2719
  }
2702
- const doc = stage.value?.renderer.contentWindow?.document;
2703
- if (doc && stageOptions) {
2704
- removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
2705
- }
2706
- clientX = 0;
2707
- clientY = 0;
2708
- },
2709
- dragHandler(e) {
2710
- if (e.clientX !== clientX || e.clientY !== clientY) {
2711
- clientX = e.clientX;
2712
- clientY = e.clientY;
2713
- if (timeout) {
2714
- globalThis.clearTimeout(timeout);
2715
- timeout = void 0;
2716
- }
2717
- return;
2718
- }
2719
- if (timeout || !stage.value)
2720
- return;
2721
- timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
2720
+ return;
2722
2721
  }
2722
+ if (timeout || !stage.value)
2723
+ return;
2724
+ timeout = stage.value.getAddContainerHighlightClassNameTimeout(e);
2723
2725
  };
2724
- }
2725
- });
2726
-
2727
- const _hoisted_1$3 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
2728
- const _hoisted_2$1 = ["onClick", "onDragstart"];
2729
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
2730
- const _component_el_input = resolveComponent("el-input");
2731
- const _component_m_icon = resolveComponent("m-icon");
2732
- const _component_el_tooltip = resolveComponent("el-tooltip");
2733
- const _component_el_collapse_item = resolveComponent("el-collapse-item");
2734
- const _component_el_collapse = resolveComponent("el-collapse");
2735
- const _component_el_scrollbar = resolveComponent("el-scrollbar");
2736
- return openBlock(), createBlock(_component_el_scrollbar, null, {
2737
- default: withCtx(() => [
2738
- renderSlot(_ctx.$slots, "component-list-panel-header"),
2739
- createVNode(_component_el_collapse, {
2740
- class: "ui-component-panel",
2741
- "model-value": _ctx.collapseValue
2742
- }, {
2726
+ return (_ctx, _cache) => {
2727
+ const _component_el_input = resolveComponent("el-input");
2728
+ const _component_el_tooltip = resolveComponent("el-tooltip");
2729
+ const _component_el_collapse_item = resolveComponent("el-collapse-item");
2730
+ const _component_el_collapse = resolveComponent("el-collapse");
2731
+ const _component_el_scrollbar = resolveComponent("el-scrollbar");
2732
+ return openBlock(), createBlock(_component_el_scrollbar, null, {
2743
2733
  default: withCtx(() => [
2744
- createVNode(_component_el_input, {
2745
- "prefix-icon": "el-icon-search",
2746
- placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
2747
- class: "search-input",
2748
- size: "small",
2749
- clearable: "",
2750
- modelValue: _ctx.searchText,
2751
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.searchText = $event)
2752
- }, null, 8, ["modelValue"]),
2753
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (group, index) => {
2754
- return openBlock(), createElementBlock(Fragment, null, [
2755
- group.items && group.items.length ? (openBlock(), createBlock(_component_el_collapse_item, {
2756
- key: index,
2757
- name: index
2758
- }, {
2759
- title: withCtx(() => [
2760
- _hoisted_1$3,
2761
- createTextVNode(toDisplayString(group.title), 1)
2762
- ]),
2763
- default: withCtx(() => [
2764
- (openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
2765
- return openBlock(), createElementBlock("div", {
2766
- class: "component-item",
2767
- draggable: "true",
2768
- key: item.type,
2769
- onClick: ($event) => _ctx.appendComponent(item),
2770
- onDragstart: ($event) => _ctx.dragstartHandler(item, $event),
2771
- onDragend: _cache[1] || (_cache[1] = (...args) => _ctx.dragendHandler && _ctx.dragendHandler(...args)),
2772
- onDrag: _cache[2] || (_cache[2] = (...args) => _ctx.dragHandler && _ctx.dragHandler(...args))
2773
- }, [
2774
- createVNode(_component_m_icon, {
2775
- icon: item.icon
2776
- }, null, 8, ["icon"]),
2777
- createVNode(_component_el_tooltip, {
2778
- effect: "dark",
2779
- placement: "bottom",
2780
- content: item.text
2781
- }, {
2782
- default: withCtx(() => [
2783
- createElementVNode("span", null, toDisplayString(item.text), 1)
2784
- ]),
2785
- _: 2
2786
- }, 1032, ["content"])
2787
- ], 40, _hoisted_2$1);
2788
- }), 128))
2789
- ]),
2790
- _: 2
2791
- }, 1032, ["name"])) : createCommentVNode("", true)
2792
- ], 64);
2793
- }), 256))
2734
+ renderSlot(_ctx.$slots, "component-list-panel-header"),
2735
+ createVNode(_component_el_collapse, {
2736
+ class: "ui-component-panel",
2737
+ "model-value": unref(collapseValue)
2738
+ }, {
2739
+ default: withCtx(() => [
2740
+ createVNode(_component_el_input, {
2741
+ "prefix-icon": "el-icon-search",
2742
+ placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
2743
+ class: "search-input",
2744
+ size: "small",
2745
+ clearable: "",
2746
+ modelValue: searchText.value,
2747
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event)
2748
+ }, null, 8, ["modelValue"]),
2749
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(list), (group, index) => {
2750
+ return openBlock(), createElementBlock(Fragment, null, [
2751
+ group.items && group.items.length ? (openBlock(), createBlock(_component_el_collapse_item, {
2752
+ key: index,
2753
+ name: index
2754
+ }, {
2755
+ title: withCtx(() => [
2756
+ _hoisted_1$4,
2757
+ createTextVNode(toDisplayString(group.title), 1)
2758
+ ]),
2759
+ default: withCtx(() => [
2760
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group.items, (item) => {
2761
+ return openBlock(), createElementBlock("div", {
2762
+ class: "component-item",
2763
+ draggable: "true",
2764
+ key: item.type,
2765
+ onClick: ($event) => appendComponent(item),
2766
+ onDragstart: ($event) => dragstartHandler(item, $event),
2767
+ onDragend: dragendHandler,
2768
+ onDrag: dragHandler
2769
+ }, [
2770
+ renderSlot(_ctx.$slots, "component-list-item", { component: item }, () => [
2771
+ createVNode(_sfc_main$h, {
2772
+ icon: item.icon
2773
+ }, null, 8, ["icon"]),
2774
+ createVNode(_component_el_tooltip, {
2775
+ effect: "dark",
2776
+ placement: "bottom",
2777
+ content: item.text
2778
+ }, {
2779
+ default: withCtx(() => [
2780
+ createElementVNode("span", null, toDisplayString(item.text), 1)
2781
+ ]),
2782
+ _: 2
2783
+ }, 1032, ["content"])
2784
+ ])
2785
+ ], 40, _hoisted_2$1);
2786
+ }), 128))
2787
+ ]),
2788
+ _: 2
2789
+ }, 1032, ["name"])) : createCommentVNode("", true)
2790
+ ], 64);
2791
+ }), 256))
2792
+ ]),
2793
+ _: 3
2794
+ }, 8, ["model-value"])
2794
2795
  ]),
2795
- _: 1
2796
- }, 8, ["model-value"])
2797
- ]),
2798
- _: 3
2799
- });
2800
- }
2801
- const ComponentListPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$5]]);
2796
+ _: 3
2797
+ });
2798
+ };
2799
+ }
2800
+ });
2802
2801
 
2803
2802
  const _sfc_main$c = /* @__PURE__ */ defineComponent({
2804
2803
  __name: "ContentMenu",
@@ -3180,7 +3179,7 @@ const _sfc_main$a = defineComponent({
3180
3179
  }
3181
3180
  });
3182
3181
 
3183
- const _hoisted_1$2 = ["id", "onMouseenter"];
3182
+ const _hoisted_1$3 = ["id", "onMouseenter"];
3184
3183
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3185
3184
  const _component_el_input = resolveComponent("el-input");
3186
3185
  const _component_el_tree = resolveComponent("el-tree");
@@ -3234,7 +3233,7 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
3234
3233
  }, () => [
3235
3234
  createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
3236
3235
  ])
3237
- ], 42, _hoisted_1$2)
3236
+ ], 42, _hoisted_1$3)
3238
3237
  ]),
3239
3238
  _: 3
3240
3239
  }, 8, ["default-expanded-keys", "load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd", "onNodeCollapse", "onNodeExpand"])) : createCommentVNode("", true),
@@ -3266,7 +3265,7 @@ const _sfc_main$9 = defineComponent({
3266
3265
  type: "component",
3267
3266
  icon: Coin,
3268
3267
  text: "\u7EC4\u4EF6",
3269
- component: ComponentListPanel,
3268
+ component: _sfc_main$d,
3270
3269
  slots: {}
3271
3270
  };
3272
3271
  case "layer":
@@ -3285,7 +3284,7 @@ const _sfc_main$9 = defineComponent({
3285
3284
  }
3286
3285
  });
3287
3286
 
3288
- const _hoisted_1$1 = {
3287
+ const _hoisted_1$2 = {
3289
3288
  key: 1,
3290
3289
  class: "magic-editor-tab-panel-title"
3291
3290
  };
@@ -3304,7 +3303,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3304
3303
  key: 0,
3305
3304
  icon: _ctx.config.icon
3306
3305
  }, null, 8, ["icon"])) : createCommentVNode("", true),
3307
- _ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$1, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
3306
+ _ctx.config.text ? (openBlock(), createElementBlock("div", _hoisted_1$2, toDisplayString(_ctx.config.text), 1)) : createCommentVNode("", true)
3308
3307
  ]))
3309
3308
  ]),
3310
3309
  default: withCtx(() => [
@@ -3315,6 +3314,18 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
3315
3314
  _ctx.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-panel-header", { key: 0 }) : _ctx.config.slots?.componentListPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.componentListPanelHeader), { key: 1 })) : createCommentVNode("", true)
3316
3315
  ])
3317
3316
  } : void 0,
3317
+ _ctx.data === "component-list" || _ctx.config.slots?.componentListItem ? {
3318
+ name: "component-list-item",
3319
+ fn: withCtx(({ component }) => [
3320
+ _ctx.data === "component-list" ? renderSlot(_ctx.$slots, "component-list-item", {
3321
+ key: 0,
3322
+ component
3323
+ }) : _ctx.config.slots?.componentListItem ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.config.slots.componentListItem), {
3324
+ key: 1,
3325
+ component
3326
+ }, null, 8, ["component"])) : createCommentVNode("", true)
3327
+ ])
3328
+ } : void 0,
3318
3329
  _ctx.data === "layer" || _ctx.config.slots?.layerPanelHeader ? {
3319
3330
  name: "layer-panel-header",
3320
3331
  fn: withCtx(() => [
@@ -3385,6 +3396,12 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3385
3396
  fn: withCtx(() => [
3386
3397
  renderSlot(_ctx.$slots, "component-list-panel-header")
3387
3398
  ])
3399
+ } : void 0,
3400
+ item === "component-list" ? {
3401
+ name: "component-list-item",
3402
+ fn: withCtx(({ component }) => [
3403
+ renderSlot(_ctx.$slots, "component-list-item", { component })
3404
+ ])
3388
3405
  } : void 0
3389
3406
  ]), 1032, ["data"]);
3390
3407
  }), 128))
@@ -3394,16 +3411,22 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
3394
3411
  }
3395
3412
  const Sidebar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$1]]);
3396
3413
 
3414
+ const _hoisted_1$1 = {
3415
+ key: 1,
3416
+ style: { "width": "21px" }
3417
+ };
3397
3418
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3398
3419
  __name: "PageBarScrollContainer",
3399
3420
  setup(__props) {
3400
3421
  const services = inject("services");
3401
3422
  const editorService = services?.editorService;
3423
+ const uiService = services?.uiService;
3402
3424
  const pageBar = ref();
3403
3425
  const itemsContainer = ref();
3404
3426
  const pageBarWidth = ref(0);
3405
3427
  const canScroll = ref(false);
3406
- const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
3428
+ const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
3429
+ const itemsContainerWidth = computed(() => pageBarWidth.value - 35 * 2 - (showAddPageButton.value ? 35 : 21));
3407
3430
  let translateLeft = 0;
3408
3431
  const resizeObserver = new ResizeObserver((entries) => {
3409
3432
  for (const { contentRect } of entries) {
@@ -3414,7 +3437,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3414
3437
  });
3415
3438
  const setCanScroll = () => {
3416
3439
  if (itemsContainer.value) {
3417
- canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
3440
+ canScroll.value = itemsContainer.value.scrollWidth > itemsContainerWidth.value;
3418
3441
  }
3419
3442
  };
3420
3443
  const scroll = (type) => {
@@ -3471,7 +3494,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3471
3494
  ref_key: "pageBar",
3472
3495
  ref: pageBar
3473
3496
  }, [
3474
- createElementVNode("div", {
3497
+ unref(showAddPageButton) ? (openBlock(), createElementBlock("div", {
3498
+ key: 0,
3475
3499
  id: "m-editor-page-bar-add-icon",
3476
3500
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3477
3501
  onClick: addPage
@@ -3482,9 +3506,9 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3482
3506
  ]),
3483
3507
  _: 1
3484
3508
  })
3485
- ]),
3509
+ ])) : (openBlock(), createElementBlock("div", _hoisted_1$1)),
3486
3510
  canScroll.value ? (openBlock(), createElementBlock("div", {
3487
- key: 0,
3511
+ key: 2,
3488
3512
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3489
3513
  onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
3490
3514
  }, [
@@ -3496,7 +3520,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3496
3520
  })
3497
3521
  ])) : createCommentVNode("", true),
3498
3522
  unref(root) ? (openBlock(), createElementBlock("div", {
3499
- key: 1,
3523
+ key: 3,
3500
3524
  class: "m-editor-page-bar-items",
3501
3525
  ref_key: "itemsContainer",
3502
3526
  ref: itemsContainer,
@@ -3505,7 +3529,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
3505
3529
  renderSlot(_ctx.$slots, "default")
3506
3530
  ], 4)) : createCommentVNode("", true),
3507
3531
  canScroll.value ? (openBlock(), createElementBlock("div", {
3508
- key: 2,
3532
+ key: 4,
3509
3533
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
3510
3534
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
3511
3535
  }, [
@@ -4161,8 +4185,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
4161
4185
  config.style = {
4162
4186
  ...style,
4163
4187
  position,
4164
- top,
4165
- left
4188
+ top: top / zoom.value,
4189
+ left: left / zoom.value
4166
4190
  };
4167
4191
  config.inputEvent = e;
4168
4192
  services?.editorService.add(config, parent);
@@ -4443,9 +4467,14 @@ const _sfc_main = defineComponent({
4443
4467
  },
4444
4468
  emits: ["props-panel-mounted", "update:modelValue"],
4445
4469
  setup(props, { emit }) {
4446
- editorService.on("root-change", () => {
4447
- const node = editorService.get("node") || props.defaultSelected;
4448
- node && editorService.select(node);
4470
+ editorService.on("root-change", (value) => {
4471
+ const node = editorService.get("node");
4472
+ const nodeId = node?.id || props.defaultSelected;
4473
+ if (nodeId && node !== value) {
4474
+ editorService.select(nodeId);
4475
+ } else {
4476
+ editorService.set("nodes", [value]);
4477
+ }
4449
4478
  emit("update:modelValue", toRaw(editorService.get("root")));
4450
4479
  });
4451
4480
  watch(() => props.modelValue, (modelValue) => editorService.set("root", modelValue), {
@@ -4536,6 +4565,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4536
4565
  "component-list-panel-header": withCtx(() => [
4537
4566
  renderSlot(_ctx.$slots, "component-list-panel-header")
4538
4567
  ]),
4568
+ "component-list-item": withCtx(({ component }) => [
4569
+ renderSlot(_ctx.$slots, "component-list-item", { component })
4570
+ ]),
4539
4571
  _: 3
4540
4572
  }, 8, ["data"])
4541
4573
  ])
@@ -4595,5 +4627,5 @@ const index = {
4595
4627
  }
4596
4628
  };
4597
4629
 
4598
- export { COPY_STORAGE_KEY, ColumnLayout, ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$h as Icon, Keys, LayerOffset, LayerPanel, Layout, _sfc_main$e as PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$g as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, useStage, warn };
4630
+ export { COPY_STORAGE_KEY, ColumnLayout, _sfc_main$d as ComponentListPanel, _sfc_main$c as ContentMenu, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$h as Icon, Keys, LayerOffset, LayerPanel, Layout, _sfc_main$e as PropsPanel, CodeEditor as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$g as ToolButton, V_GUIDE_LINE_STORAGE_KEY, change2Fixed, debug, index as default, editorService, error, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getRelativeStyle, historyService, info, isFixed, log, propsService, setConfig, setLayout, storageService, uiService, useStage, warn };
4599
4631
  //# sourceMappingURL=tmagic-editor.mjs.map