@tmagic/editor 1.0.0-beta.6 → 1.0.0-beta.9

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,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('monaco-editor'), require('@element-plus/icons'), require('lodash-es'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('element-plus'), require('@tmagic/stage')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'monaco-editor', '@element-plus/icons', 'lodash-es', '@tmagic/utils', 'events', '@tmagic/core', 'element-plus', '@tmagic/stage'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.monaco, global.icons, global.lodashEs, global.utils, global.events, global.core, global.elementPlus, global.StageCore));
5
- })(this, (function (exports, vue, serialize, monaco, icons, lodashEs, utils, events, core, elementPlus, StageCore) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('serialize-javascript'), require('monaco-editor'), require('@element-plus/icons'), require('@tmagic/schema'), require('lodash-es'), require('@tmagic/utils'), require('events'), require('@tmagic/core'), require('element-plus'), require('@tmagic/stage')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', 'serialize-javascript', 'monaco-editor', '@element-plus/icons', '@tmagic/schema', 'lodash-es', '@tmagic/utils', 'events', '@tmagic/core', 'element-plus', '@tmagic/stage'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.vue, global.serialize, global.monaco, global.icons, global.schema, global.lodashEs, global.utils, global.events, global.core, global.elementPlus, global.StageCore));
5
+ })(this, (function (exports, vue, serialize, monaco, icons, schema, lodashEs, utils, events, core, elementPlus, StageCore) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -194,12 +194,12 @@
194
194
  };
195
195
  }
196
196
  });
197
- const _hoisted_1$d = /* @__PURE__ */ vue.createElementVNode("i", {
197
+ const _hoisted_1$e = /* @__PURE__ */ vue.createElementVNode("i", {
198
198
  class: "el-icon-delete",
199
199
  style: { "color": "rgb(221, 75, 57)" }
200
200
  }, "\u53D6\u6D88", -1);
201
201
  const _hoisted_2$7 = [
202
- _hoisted_1$d
202
+ _hoisted_1$e
203
203
  ];
204
204
  const _hoisted_3$5 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
205
205
  function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
@@ -343,12 +343,12 @@
343
343
  };
344
344
  }
345
345
  });
346
- const _hoisted_1$c = {
346
+ const _hoisted_1$d = {
347
347
  ref: "codeEditor",
348
348
  class: "magic-code-editor"
349
349
  };
350
350
  function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
351
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, null, 512);
351
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, null, 512);
352
352
  }
353
353
  var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
354
354
 
@@ -632,7 +632,7 @@
632
632
  const generateId = (type) => `${type}_${lodashEs.random(1e4, false)}`;
633
633
  const getPageList = (app) => {
634
634
  if (app.items && Array.isArray(app.items)) {
635
- return app.items.filter((item) => item.type === "page");
635
+ return app.items.filter((item) => item.type === schema.NodeType.PAGE);
636
636
  }
637
637
  return [];
638
638
  };
@@ -668,7 +668,7 @@
668
668
  const oldId = config.id;
669
669
  config.id = generateId(config.type);
670
670
  config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
671
- if (utils.isPop(config) && parent?.type === "page") {
671
+ if (utils.isPop(config) && parent?.type === schema.NodeType.PAGE) {
672
672
  updatePopId(oldId, config.id, parent);
673
673
  }
674
674
  if (config.items && Array.isArray(config.items)) {
@@ -781,6 +781,7 @@
781
781
  parent: null,
782
782
  node: null,
783
783
  stage: null,
784
+ highlightNode: null,
784
785
  modifiedNodeIds: /* @__PURE__ */ new Map()
785
786
  });
786
787
  constructor() {
@@ -796,7 +797,8 @@
796
797
  "alignCenter",
797
798
  "moveLayer",
798
799
  "undo",
799
- "redo"
800
+ "redo",
801
+ "highlight"
800
802
  ]);
801
803
  }
802
804
  set(name, value) {
@@ -823,7 +825,7 @@
823
825
  info.node = path[path.length - 1];
824
826
  info.parent = path[path.length - 2];
825
827
  path.forEach((item) => {
826
- if (item.type === "page") {
828
+ if (item.type === schema.NodeType.PAGE) {
827
829
  info.page = item;
828
830
  return;
829
831
  }
@@ -850,21 +852,7 @@
850
852
  return Layout.ABSOLUTE;
851
853
  }
852
854
  async select(config2) {
853
- let id;
854
- if (typeof config2 === "string" || typeof config2 === "number") {
855
- id = config2;
856
- } else {
857
- id = config2.id;
858
- }
859
- if (!id) {
860
- throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
861
- }
862
- const { node, parent, page } = this.getNodeInfo(id);
863
- if (!node)
864
- throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
865
- if (node.id === this.state.root?.id) {
866
- throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
867
- }
855
+ const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
868
856
  this.set("node", node);
869
857
  this.set("page", page || null);
870
858
  this.set("parent", parent || null);
@@ -875,10 +863,17 @@
875
863
  }
876
864
  return node;
877
865
  }
866
+ highlight(config2) {
867
+ const { node } = this.selectedConfigExceptionHandler(config2);
868
+ const currentHighligtNode = this.get("highlightNode");
869
+ if (currentHighligtNode === node)
870
+ return;
871
+ this.set("highlightNode", node);
872
+ }
878
873
  async add({ type, ...config2 }, parent) {
879
874
  const curNode = this.get("node");
880
875
  let parentNode;
881
- if (type === "page") {
876
+ if (type === schema.NodeType.PAGE) {
882
877
  parentNode = this.get("root");
883
878
  } else if (parent && typeof parent !== "function") {
884
879
  parentNode = parent;
@@ -891,14 +886,16 @@
891
886
  throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
892
887
  const layout = await this.getLayout(parentNode);
893
888
  const newNode = initPosition({ ...vue.toRaw(await propsService.getPropsValue(type)), ...config2 }, layout);
894
- if ((parentNode?.type === "app" || curNode.type === "app") && newNode.type !== "page") {
889
+ if ((parentNode?.type === schema.NodeType.ROOT || curNode.type === schema.NodeType.ROOT) && newNode.type !== schema.NodeType.PAGE) {
895
890
  throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
896
891
  }
897
892
  parentNode?.items?.push(newNode);
898
893
  await this.get("stage")?.add({ config: lodashEs.cloneDeep(newNode), root: lodashEs.cloneDeep(this.get("root")) });
899
894
  await this.select(newNode);
900
895
  this.addModifiedNodeId(newNode.id);
901
- this.pushHistoryState();
896
+ if (type !== schema.NodeType.PAGE) {
897
+ this.pushHistoryState();
898
+ }
902
899
  return newNode;
903
900
  }
904
901
  async remove(node) {
@@ -915,7 +912,7 @@
915
912
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
916
913
  parent.items?.splice(index, 1);
917
914
  this.get("stage")?.remove({ id: node.id, root: this.get("root") });
918
- if (node.type === "page") {
915
+ if (node.type === schema.NodeType.PAGE) {
919
916
  await this.select(root.items[0] || root);
920
917
  } else {
921
918
  await this.select(parent);
@@ -932,14 +929,14 @@
932
929
  throw new Error(`\u83B7\u53D6\u4E0D\u5230id\u4E3A${config2.id}\u7684\u8282\u70B9`);
933
930
  const node = lodashEs.cloneDeep(vue.toRaw(info.node));
934
931
  let newConfig = await this.toggleFixedPosition(vue.toRaw(config2), node, this.get("root"));
935
- newConfig = lodashEs.mergeWith(node, newConfig, (objValue, srcValue) => {
932
+ newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue) => {
936
933
  if (Array.isArray(srcValue)) {
937
934
  return srcValue;
938
935
  }
939
936
  });
940
937
  if (!newConfig.type)
941
938
  throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
942
- if (newConfig.type === "app") {
939
+ if (newConfig.type === schema.NodeType.ROOT) {
943
940
  this.set("root", newConfig);
944
941
  return newConfig;
945
942
  }
@@ -960,7 +957,7 @@
960
957
  this.set("node", newConfig);
961
958
  }
962
959
  this.get("stage")?.update({ config: lodashEs.cloneDeep(newConfig), root: this.get("root") });
963
- if (newConfig.type === "page") {
960
+ if (newConfig.type === schema.NodeType.PAGE) {
964
961
  this.set("page", newConfig);
965
962
  }
966
963
  this.addModifiedNodeId(newConfig.id);
@@ -977,6 +974,7 @@
977
974
  parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
978
975
  await this.update(parent);
979
976
  await this.select(node);
977
+ this.get("stage")?.update({ config: lodashEs.cloneDeep(node), root: this.get("root") });
980
978
  this.addModifiedNodeId(parent.id);
981
979
  this.pushHistoryState();
982
980
  }
@@ -1089,6 +1087,28 @@
1089
1087
  }
1090
1088
  return newConfig;
1091
1089
  }
1090
+ selectedConfigExceptionHandler(config2) {
1091
+ let id;
1092
+ if (typeof config2 === "string" || typeof config2 === "number") {
1093
+ id = config2;
1094
+ } else {
1095
+ id = config2.id;
1096
+ }
1097
+ if (!id) {
1098
+ throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
1099
+ }
1100
+ const { node, parent, page } = this.getNodeInfo(id);
1101
+ if (!node)
1102
+ throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
1103
+ if (node.id === this.state.root?.id) {
1104
+ throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
1105
+ }
1106
+ return {
1107
+ node,
1108
+ parent,
1109
+ page
1110
+ };
1111
+ }
1092
1112
  }
1093
1113
  var editorService = new Editor$1();
1094
1114
 
@@ -1323,20 +1343,20 @@
1323
1343
  if (!editorService)
1324
1344
  return;
1325
1345
  editorService.add({
1326
- type: "page",
1346
+ type: schema.NodeType.PAGE,
1327
1347
  name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
1328
1348
  });
1329
1349
  }
1330
1350
  };
1331
1351
  }
1332
1352
  });
1333
- const _hoisted_1$b = { class: "m-editor-empty-panel" };
1353
+ const _hoisted_1$c = { class: "m-editor-empty-panel" };
1334
1354
  const _hoisted_2$6 = { class: "m-editor-empty-content" };
1335
1355
  const _hoisted_3$4 = /* @__PURE__ */ vue.createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1336
1356
  function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1337
1357
  const _component_plus = vue.resolveComponent("plus");
1338
1358
  const _component_el_icon = vue.resolveComponent("el-icon");
1339
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
1359
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
1340
1360
  vue.createElementVNode("div", _hoisted_2$6, [
1341
1361
  vue.createElementVNode("div", {
1342
1362
  class: "m-editor-empty-button",
@@ -2566,12 +2586,12 @@
2566
2586
  };
2567
2587
  }
2568
2588
  });
2569
- const _hoisted_1$a = {
2589
+ const _hoisted_1$b = {
2570
2590
  ref: "target",
2571
2591
  class: "m-editor-resizer"
2572
2592
  };
2573
2593
  function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2574
- return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$a, [
2594
+ return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$b, [
2575
2595
  vue.renderSlot(_ctx.$slots, "default")
2576
2596
  ], 512);
2577
2597
  }
@@ -2600,7 +2620,7 @@
2600
2620
  };
2601
2621
  }
2602
2622
  });
2603
- const _hoisted_1$9 = { class: "m-editor" };
2623
+ const _hoisted_1$a = { class: "m-editor" };
2604
2624
  const _hoisted_2$5 = {
2605
2625
  key: 1,
2606
2626
  class: "m-editor-content"
@@ -2610,7 +2630,7 @@
2610
2630
  const _component_resizer = vue.resolveComponent("resizer");
2611
2631
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
2612
2632
  const _component_add_page_box = vue.resolveComponent("add-page-box");
2613
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
2633
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$a, [
2614
2634
  vue.renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2615
2635
  _ctx.showSrc ? (vue.openBlock(), vue.createBlock(_component_magic_code_editor, {
2616
2636
  key: 0,
@@ -2666,7 +2686,7 @@
2666
2686
  };
2667
2687
  }
2668
2688
  });
2669
- const _hoisted_1$8 = ["src"];
2689
+ const _hoisted_1$9 = ["src"];
2670
2690
  function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2671
2691
  const _component_edit = vue.resolveComponent("edit");
2672
2692
  const _component_el_icon = vue.resolveComponent("el-icon");
@@ -2678,7 +2698,7 @@
2678
2698
  })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (vue.openBlock(), vue.createElementBlock("img", {
2679
2699
  key: 1,
2680
2700
  src: _ctx.icon
2681
- }, null, 8, _hoisted_1$8)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2701
+ }, null, 8, _hoisted_1$9)) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
2682
2702
  key: 2,
2683
2703
  class: vue.normalizeClass(_ctx.icon)
2684
2704
  }, null, 2)) : (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 3 }, {
@@ -2728,7 +2748,7 @@
2728
2748
  type: "button",
2729
2749
  icon: icons.Delete,
2730
2750
  tooltip: "\u522A\u9664",
2731
- disabled: () => services?.editorService.get("node")?.type === "page",
2751
+ disabled: () => services?.editorService.get("node")?.type === schema.NodeType.PAGE,
2732
2752
  handler: () => services?.editorService.remove(services?.editorService.get("node"))
2733
2753
  };
2734
2754
  case "undo":
@@ -2825,7 +2845,7 @@
2825
2845
  };
2826
2846
  }
2827
2847
  });
2828
- const _hoisted_1$7 = {
2848
+ const _hoisted_1$8 = {
2829
2849
  key: 0,
2830
2850
  class: "menu-item"
2831
2851
  };
@@ -2848,7 +2868,7 @@
2848
2868
  const _component_el_dropdown_item = vue.resolveComponent("el-dropdown-item");
2849
2869
  const _component_el_dropdown_menu = vue.resolveComponent("el-dropdown-menu");
2850
2870
  const _component_el_dropdown = vue.resolveComponent("el-dropdown");
2851
- return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$7, [
2871
+ return _ctx.display ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
2852
2872
  _ctx.item.type === "divider" ? (vue.openBlock(), vue.createBlock(_component_el_divider, {
2853
2873
  key: 0,
2854
2874
  direction: "vertical"
@@ -3020,6 +3040,7 @@
3020
3040
  const _component_m_form = vue.resolveComponent("m-form");
3021
3041
  return vue.openBlock(), vue.createBlock(_component_m_form, {
3022
3042
  class: "m-editor-props-panel",
3043
+ "popper-class": "m-editor-props-panel-popper",
3023
3044
  ref: "configForm",
3024
3045
  size: "small",
3025
3046
  "init-values": _ctx.values,
@@ -3054,7 +3075,7 @@
3054
3075
  };
3055
3076
  }
3056
3077
  });
3057
- const _hoisted_1$6 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3078
+ const _hoisted_1$7 = /* @__PURE__ */ vue.createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3058
3079
  const _hoisted_2$3 = ["onClick"];
3059
3080
  function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
3060
3081
  const _component_el_input = vue.resolveComponent("el-input");
@@ -3086,7 +3107,7 @@
3086
3107
  name: index
3087
3108
  }, {
3088
3109
  title: vue.withCtx(() => [
3089
- _hoisted_1$6,
3110
+ _hoisted_1$7,
3090
3111
  vue.createTextVNode(vue.toDisplayString(group.title), 1)
3091
3112
  ]),
3092
3113
  default: vue.withCtx(() => [
@@ -3167,7 +3188,7 @@
3167
3188
  };
3168
3189
  }
3169
3190
  });
3170
- const _hoisted_1$5 = {
3191
+ const _hoisted_1$6 = {
3171
3192
  key: 0,
3172
3193
  class: "magic-editor-content-menu"
3173
3194
  };
@@ -3176,7 +3197,7 @@
3176
3197
  const _hoisted_4$2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "separation" }, null, -1);
3177
3198
  function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
3178
3199
  const _component_el_scrollbar = vue.resolveComponent("el-scrollbar");
3179
- return _ctx.node ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$5, [
3200
+ return _ctx.node ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$6, [
3180
3201
  _ctx.node.items ? (vue.openBlock(), vue.createElementBlock("div", {
3181
3202
  key: 0,
3182
3203
  class: "magic-editor-content-menu-item",
@@ -3238,20 +3259,27 @@
3238
3259
  }
3239
3260
  var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
3240
3261
 
3262
+ const throttleTime = 150;
3241
3263
  const select = (data, editorService) => {
3242
3264
  if (!data.id) {
3243
3265
  throw new Error("\u6CA1\u6709id");
3244
3266
  }
3245
3267
  editorService?.select(data);
3246
3268
  };
3269
+ const highlight = (data, editorService) => {
3270
+ if (!data?.id) {
3271
+ throw new Error("\u6CA1\u6709id");
3272
+ }
3273
+ editorService?.highlight(data);
3274
+ };
3247
3275
  const useDrop = (tree, editorService) => ({
3248
3276
  allowDrop: (draggingNode, dropNode, type) => {
3249
3277
  const { data } = dropNode || {};
3250
3278
  const { data: ingData } = draggingNode;
3251
3279
  const { type: ingType } = ingData;
3252
- if (ingType !== "page" && data.type === "page")
3280
+ if (ingType !== schema.NodeType.PAGE && data.type === schema.NodeType.PAGE)
3253
3281
  return false;
3254
- if (ingType === "page" && data.type !== "page")
3282
+ if (ingType === schema.NodeType.PAGE && data.type !== schema.NodeType.PAGE)
3255
3283
  return false;
3256
3284
  if (!data || !data.type)
3257
3285
  return false;
@@ -3270,29 +3298,34 @@
3270
3298
  }
3271
3299
  });
3272
3300
  const useStatus = (tree, editorService) => {
3301
+ const highlightNode = vue.ref();
3302
+ const node = vue.ref();
3273
3303
  const page = vue.computed(() => editorService?.get("page"));
3274
3304
  vue.watchEffect(() => {
3275
3305
  if (!tree.value)
3276
3306
  return;
3277
- const node = editorService?.get("node");
3278
- node && tree.value.setCurrentKey(node.id, true);
3307
+ node.value = editorService?.get("node");
3308
+ node.value && tree.value.setCurrentKey(node.value.id, true);
3279
3309
  const parent = editorService?.get("parent");
3280
3310
  if (!parent?.id)
3281
3311
  return;
3282
3312
  const treeNode = tree.value.getNode(parent.id);
3283
3313
  treeNode?.updateChildren();
3314
+ highlightNode.value = editorService?.get("highlightNode");
3284
3315
  });
3285
3316
  return {
3286
3317
  values: vue.computed(() => page.value ? [page.value] : []),
3287
- loadItems: (node, resolve) => {
3288
- if (Array.isArray(node.data)) {
3289
- return resolve(node.data);
3318
+ loadItems: (node2, resolve) => {
3319
+ if (Array.isArray(node2.data)) {
3320
+ return resolve(node2.data);
3290
3321
  }
3291
- if (Array.isArray(node.data?.items)) {
3292
- return resolve(node.data?.items);
3322
+ if (Array.isArray(node2.data?.items)) {
3323
+ return resolve(node2.data?.items);
3293
3324
  }
3294
3325
  resolve([]);
3295
- }
3326
+ },
3327
+ highlightNode,
3328
+ clickNode: node
3296
3329
  };
3297
3330
  };
3298
3331
  const useFilter = (tree) => ({
@@ -3349,11 +3382,20 @@
3349
3382
  setup() {
3350
3383
  const services = vue.inject("services");
3351
3384
  const tree = vue.ref();
3385
+ const clicked = vue.ref(false);
3352
3386
  const editorService = services?.editorService;
3387
+ const highlightHandler = lodashEs.throttle((data) => {
3388
+ highlight(data, editorService);
3389
+ }, throttleTime);
3390
+ const toogleClickFlag = () => {
3391
+ clicked.value = !clicked.value;
3392
+ };
3393
+ const statusData = useStatus(tree, editorService);
3394
+ const canHighlight = vue.computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
3353
3395
  return {
3354
3396
  tree,
3397
+ ...statusData,
3355
3398
  ...useDrop(tree, editorService),
3356
- ...useStatus(tree, editorService),
3357
3399
  ...useFilter(tree),
3358
3400
  ...useContentMenu(editorService),
3359
3401
  clickHandler(data) {
@@ -3361,11 +3403,16 @@
3361
3403
  document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
3362
3404
  return;
3363
3405
  }
3406
+ tree.value?.setCurrentKey(data.id);
3364
3407
  select(data, editorService);
3365
- }
3408
+ },
3409
+ highlightHandler,
3410
+ toogleClickFlag,
3411
+ canHighlight
3366
3412
  };
3367
3413
  }
3368
3414
  });
3415
+ const _hoisted_1$5 = ["id", "onMouseenter"];
3369
3416
  function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3370
3417
  const _component_el_input = vue.resolveComponent("el-input");
3371
3418
  const _component_el_tree = vue.resolveComponent("el-tree");
@@ -3402,12 +3449,20 @@
3402
3449
  "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
3403
3450
  }, {
3404
3451
  default: vue.withCtx(({ node, data }) => [
3405
- vue.renderSlot(_ctx.$slots, "layer-node-content", {
3406
- node,
3407
- data
3408
- }, () => [
3409
- vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
3410
- ])
3452
+ vue.createElementVNode("div", {
3453
+ id: data.id,
3454
+ class: vue.normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
3455
+ onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
3456
+ onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
3457
+ onMouseenter: ($event) => _ctx.highlightHandler(data)
3458
+ }, [
3459
+ vue.renderSlot(_ctx.$slots, "layer-node-content", {
3460
+ node,
3461
+ data
3462
+ }, () => [
3463
+ vue.createElementVNode("span", null, vue.toDisplayString(`${data.name} (${data.id})`), 1)
3464
+ ])
3465
+ ], 42, _hoisted_1$5)
3411
3466
  ]),
3412
3467
  _: 3
3413
3468
  }, 8, ["load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : vue.createCommentVNode("", true),
@@ -3534,7 +3589,7 @@
3534
3589
  if (!editorService)
3535
3590
  return;
3536
3591
  const pageConfig = {
3537
- type: "page",
3592
+ type: schema.NodeType.PAGE,
3538
3593
  name: generatePageNameByApp(vue.toRaw(editorService.get("root")))
3539
3594
  };
3540
3595
  editorService.add(pageConfig);
@@ -3554,11 +3609,13 @@
3554
3609
  });
3555
3610
  const _hoisted_1$3 = { class: "m-editor-page-bar" };
3556
3611
  const _hoisted_2$1 = ["onClick"];
3557
- const _hoisted_3$1 = ["onClick"];
3612
+ const _hoisted_3$1 = { class: "m-editor-page-bar-title" };
3558
3613
  const _hoisted_4$1 = ["onClick"];
3614
+ const _hoisted_5 = ["onClick"];
3559
3615
  function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3560
3616
  const _component_plus = vue.resolveComponent("plus");
3561
3617
  const _component_el_icon = vue.resolveComponent("el-icon");
3618
+ const _component_el_tooltip = vue.resolveComponent("el-tooltip");
3562
3619
  const _component_caret_bottom = vue.resolveComponent("caret-bottom");
3563
3620
  const _component_el_popover = vue.resolveComponent("el-popover");
3564
3621
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
@@ -3579,8 +3636,19 @@
3579
3636
  class: vue.normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
3580
3637
  onClick: ($event) => _ctx.switchPage(item)
3581
3638
  }, [
3582
- vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3583
- vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
3639
+ vue.createElementVNode("div", _hoisted_3$1, [
3640
+ vue.renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3641
+ vue.createVNode(_component_el_tooltip, {
3642
+ effect: "dark",
3643
+ placement: "top-start",
3644
+ content: item.name
3645
+ }, {
3646
+ default: vue.withCtx(() => [
3647
+ vue.createElementVNode("span", null, vue.toDisplayString(item.name), 1)
3648
+ ]),
3649
+ _: 2
3650
+ }, 1032, ["content"])
3651
+ ])
3584
3652
  ]),
3585
3653
  vue.createVNode(_component_el_popover, {
3586
3654
  placement: "top",
@@ -3601,11 +3669,11 @@
3601
3669
  vue.createElementVNode("div", {
3602
3670
  class: "magic-editor-content-menu-item",
3603
3671
  onClick: () => _ctx.copy(item)
3604
- }, "\u590D\u5236", 8, _hoisted_3$1),
3672
+ }, "\u590D\u5236", 8, _hoisted_4$1),
3605
3673
  vue.createElementVNode("div", {
3606
3674
  class: "magic-editor-content-menu-item",
3607
3675
  onClick: () => _ctx.remove(item)
3608
- }, "\u5220\u9664", 8, _hoisted_4$1)
3676
+ }, "\u5220\u9664", 8, _hoisted_5)
3609
3677
  ])
3610
3678
  ])
3611
3679
  ]),
@@ -3854,13 +3922,13 @@
3854
3922
  if (!parent.value || !editorService)
3855
3923
  return canCenter.value = false;
3856
3924
  const layout = await editorService.getLayout(parent.value);
3857
- canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && !["app", "page", "pop"].includes(`${node.value?.type}`);
3925
+ canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![schema.NodeType.ROOT, schema.NodeType.PAGE, "pop"].includes(`${node.value?.type}`);
3858
3926
  }, { immediate: true });
3859
3927
  return {
3860
3928
  menu,
3861
3929
  canPaste,
3862
- canDelete: vue.computed(() => node.value?.type !== "page"),
3863
- canMoveZPos: vue.computed(() => node.value?.type !== "page"),
3930
+ canDelete: vue.computed(() => node.value?.type !== schema.NodeType.PAGE),
3931
+ canMoveZPos: vue.computed(() => node.value?.type !== schema.NodeType.PAGE),
3864
3932
  canCenter,
3865
3933
  center() {
3866
3934
  node.value && editorService?.alignCenter(node.value);
@@ -4007,7 +4075,7 @@
4007
4075
  })
4008
4076
  }
4009
4077
  },
4010
- emits: ["select", "update", "sort"],
4078
+ emits: ["select", "update", "sort", "highlight"],
4011
4079
  setup(props, { emit }) {
4012
4080
  const services = vue.inject("services");
4013
4081
  const stageWrap = vue.ref();
@@ -4018,6 +4086,7 @@
4018
4086
  const page = vue.computed(() => services?.editorService.get("page"));
4019
4087
  const zoom = vue.computed(() => services?.uiService.get("zoom"));
4020
4088
  const node = vue.computed(() => services?.editorService.get("node"));
4089
+ const highlightNode = vue.computed(() => services?.editorService.get("highlightNode"));
4021
4090
  let stage = null;
4022
4091
  let runtime = null;
4023
4092
  vue.watchEffect(() => {
@@ -4043,7 +4112,12 @@
4043
4112
  });
4044
4113
  services?.editorService.set("stage", stage);
4045
4114
  stage?.mount(stageContainer.value);
4046
- stage?.on("select", (el) => emit("select", el));
4115
+ stage?.on("select", (el) => {
4116
+ emit("select", el);
4117
+ });
4118
+ stage?.on("highlight", (el) => {
4119
+ emit("highlight", el);
4120
+ });
4047
4121
  stage?.on("update", (ev) => {
4048
4122
  emit("update", { id: ev.el.id, style: ev.style });
4049
4123
  });
@@ -4079,6 +4153,11 @@
4079
4153
  id && stage?.select(id);
4080
4154
  });
4081
4155
  });
4156
+ vue.watch(() => highlightNode.value?.id, (id) => {
4157
+ vue.nextTick(() => {
4158
+ id && stage?.highlight(id);
4159
+ });
4160
+ });
4082
4161
  const resizeObserver = new ResizeObserver((entries) => {
4083
4162
  for (const { contentRect } of entries) {
4084
4163
  services?.uiService.set("stageContainerRect", {
@@ -4163,6 +4242,9 @@
4163
4242
  },
4164
4243
  sortNodeHandler(ev) {
4165
4244
  services?.editorService.sort(ev.src, ev.dist);
4245
+ },
4246
+ highlightHandler(el) {
4247
+ services?.editorService.highlight(el.id);
4166
4248
  }
4167
4249
  };
4168
4250
  }
@@ -4179,9 +4261,10 @@
4179
4261
  "moveable-options": _ctx.moveableOptions,
4180
4262
  "can-select": _ctx.canSelect,
4181
4263
  onSelect: _ctx.selectHandler,
4264
+ onHighlight: _ctx.highlightHandler,
4182
4265
  onUpdate: _ctx.updateNodeHandler,
4183
4266
  onSort: _ctx.sortNodeHandler
4184
- }, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
4267
+ }, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onHighlight", "onUpdate", "onSort"])),
4185
4268
  vue.renderSlot(_ctx.$slots, "workspace-content"),
4186
4269
  vue.createVNode(_component_page_bar, null, {
4187
4270
  "page-bar-title": vue.withCtx(({ page }) => [