@tmagic/editor 1.0.0-beta.8 → 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.
@@ -2,7 +2,8 @@ import { defineComponent, computed, resolveComponent, openBlock, createBlock, no
2
2
  import serialize from 'serialize-javascript';
3
3
  import * as monaco from 'monaco-editor';
4
4
  import { Plus, Edit, ArrowDown, Grid, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Delete, Files, Coin, CaretBottom } from '@element-plus/icons';
5
- import { cloneDeep, random, mergeWith } from 'lodash-es';
5
+ import { NodeType } from '@tmagic/schema';
6
+ import { cloneDeep, random, mergeWith, throttle } from 'lodash-es';
6
7
  import { toLine, isPop, getNodePath } from '@tmagic/utils';
7
8
  import { EventEmitter as EventEmitter$2 } from 'events';
8
9
  import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
@@ -175,12 +176,12 @@ const _sfc_main$i = defineComponent({
175
176
  };
176
177
  }
177
178
  });
178
- const _hoisted_1$d = /* @__PURE__ */ createElementVNode("i", {
179
+ const _hoisted_1$e = /* @__PURE__ */ createElementVNode("i", {
179
180
  class: "el-icon-delete",
180
181
  style: { "color": "rgb(221, 75, 57)" }
181
182
  }, "\u53D6\u6D88", -1);
182
183
  const _hoisted_2$7 = [
183
- _hoisted_1$d
184
+ _hoisted_1$e
184
185
  ];
185
186
  const _hoisted_3$5 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-thumb" }, null, -1);
186
187
  function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) {
@@ -324,12 +325,12 @@ const _sfc_main$h = defineComponent({
324
325
  };
325
326
  }
326
327
  });
327
- const _hoisted_1$c = {
328
+ const _hoisted_1$d = {
328
329
  ref: "codeEditor",
329
330
  class: "magic-code-editor"
330
331
  };
331
332
  function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
332
- return openBlock(), createElementBlock("div", _hoisted_1$c, null, 512);
333
+ return openBlock(), createElementBlock("div", _hoisted_1$d, null, 512);
333
334
  }
334
335
  var CodeEditor = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h]]);
335
336
 
@@ -613,7 +614,7 @@ const COPY_STORAGE_KEY = "$MagicEditorCopyData";
613
614
  const generateId = (type) => `${type}_${random(1e4, false)}`;
614
615
  const getPageList = (app) => {
615
616
  if (app.items && Array.isArray(app.items)) {
616
- return app.items.filter((item) => item.type === "page");
617
+ return app.items.filter((item) => item.type === NodeType.PAGE);
617
618
  }
618
619
  return [];
619
620
  };
@@ -649,7 +650,7 @@ const setNewItemId = (config, parent) => {
649
650
  const oldId = config.id;
650
651
  config.id = generateId(config.type);
651
652
  config.name = `${config.name?.replace(/_(\d+)$/, "")}_${config.id}`;
652
- if (isPop(config) && parent?.type === "page") {
653
+ if (isPop(config) && parent?.type === NodeType.PAGE) {
653
654
  updatePopId(oldId, config.id, parent);
654
655
  }
655
656
  if (config.items && Array.isArray(config.items)) {
@@ -762,6 +763,7 @@ class Editor$1 extends BaseService {
762
763
  parent: null,
763
764
  node: null,
764
765
  stage: null,
766
+ highlightNode: null,
765
767
  modifiedNodeIds: /* @__PURE__ */ new Map()
766
768
  });
767
769
  constructor() {
@@ -777,7 +779,8 @@ class Editor$1 extends BaseService {
777
779
  "alignCenter",
778
780
  "moveLayer",
779
781
  "undo",
780
- "redo"
782
+ "redo",
783
+ "highlight"
781
784
  ]);
782
785
  }
783
786
  set(name, value) {
@@ -804,7 +807,7 @@ class Editor$1 extends BaseService {
804
807
  info.node = path[path.length - 1];
805
808
  info.parent = path[path.length - 2];
806
809
  path.forEach((item) => {
807
- if (item.type === "page") {
810
+ if (item.type === NodeType.PAGE) {
808
811
  info.page = item;
809
812
  return;
810
813
  }
@@ -831,21 +834,7 @@ class Editor$1 extends BaseService {
831
834
  return Layout.ABSOLUTE;
832
835
  }
833
836
  async select(config2) {
834
- let id;
835
- if (typeof config2 === "string" || typeof config2 === "number") {
836
- id = config2;
837
- } else {
838
- id = config2.id;
839
- }
840
- if (!id) {
841
- throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
842
- }
843
- const { node, parent, page } = this.getNodeInfo(id);
844
- if (!node)
845
- throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
846
- if (node.id === this.state.root?.id) {
847
- throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
848
- }
837
+ const { node, page, parent } = this.selectedConfigExceptionHandler(config2);
849
838
  this.set("node", node);
850
839
  this.set("page", page || null);
851
840
  this.set("parent", parent || null);
@@ -856,10 +845,17 @@ class Editor$1 extends BaseService {
856
845
  }
857
846
  return node;
858
847
  }
848
+ highlight(config2) {
849
+ const { node } = this.selectedConfigExceptionHandler(config2);
850
+ const currentHighligtNode = this.get("highlightNode");
851
+ if (currentHighligtNode === node)
852
+ return;
853
+ this.set("highlightNode", node);
854
+ }
859
855
  async add({ type, ...config2 }, parent) {
860
856
  const curNode = this.get("node");
861
857
  let parentNode;
862
- if (type === "page") {
858
+ if (type === NodeType.PAGE) {
863
859
  parentNode = this.get("root");
864
860
  } else if (parent && typeof parent !== "function") {
865
861
  parentNode = parent;
@@ -872,14 +868,16 @@ class Editor$1 extends BaseService {
872
868
  throw new Error("\u672A\u627E\u5230\u7236\u5143\u7D20");
873
869
  const layout = await this.getLayout(parentNode);
874
870
  const newNode = initPosition({ ...toRaw(await propsService.getPropsValue(type)), ...config2 }, layout);
875
- if ((parentNode?.type === "app" || curNode.type === "app") && newNode.type !== "page") {
871
+ if ((parentNode?.type === NodeType.ROOT || curNode.type === NodeType.ROOT) && newNode.type !== NodeType.PAGE) {
876
872
  throw new Error("app\u4E0B\u4E0D\u80FD\u6DFB\u52A0\u7EC4\u4EF6");
877
873
  }
878
874
  parentNode?.items?.push(newNode);
879
875
  await this.get("stage")?.add({ config: cloneDeep(newNode), root: cloneDeep(this.get("root")) });
880
876
  await this.select(newNode);
881
877
  this.addModifiedNodeId(newNode.id);
882
- this.pushHistoryState();
878
+ if (type !== NodeType.PAGE) {
879
+ this.pushHistoryState();
880
+ }
883
881
  return newNode;
884
882
  }
885
883
  async remove(node) {
@@ -896,7 +894,7 @@ class Editor$1 extends BaseService {
896
894
  throw new Error("\u627E\u4E0D\u8981\u5220\u9664\u7684\u8282\u70B9");
897
895
  parent.items?.splice(index, 1);
898
896
  this.get("stage")?.remove({ id: node.id, root: this.get("root") });
899
- if (node.type === "page") {
897
+ if (node.type === NodeType.PAGE) {
900
898
  await this.select(root.items[0] || root);
901
899
  } else {
902
900
  await this.select(parent);
@@ -920,7 +918,7 @@ class Editor$1 extends BaseService {
920
918
  });
921
919
  if (!newConfig.type)
922
920
  throw new Error("\u914D\u7F6E\u7F3A\u5C11type\u503C");
923
- if (newConfig.type === "app") {
921
+ if (newConfig.type === NodeType.ROOT) {
924
922
  this.set("root", newConfig);
925
923
  return newConfig;
926
924
  }
@@ -941,7 +939,7 @@ class Editor$1 extends BaseService {
941
939
  this.set("node", newConfig);
942
940
  }
943
941
  this.get("stage")?.update({ config: cloneDeep(newConfig), root: this.get("root") });
944
- if (newConfig.type === "page") {
942
+ if (newConfig.type === NodeType.PAGE) {
945
943
  this.set("page", newConfig);
946
944
  }
947
945
  this.addModifiedNodeId(newConfig.id);
@@ -1071,6 +1069,28 @@ class Editor$1 extends BaseService {
1071
1069
  }
1072
1070
  return newConfig;
1073
1071
  }
1072
+ selectedConfigExceptionHandler(config2) {
1073
+ let id;
1074
+ if (typeof config2 === "string" || typeof config2 === "number") {
1075
+ id = config2;
1076
+ } else {
1077
+ id = config2.id;
1078
+ }
1079
+ if (!id) {
1080
+ throw new Error("\u6CA1\u6709ID\uFF0C\u65E0\u6CD5\u9009\u4E2D");
1081
+ }
1082
+ const { node, parent, page } = this.getNodeInfo(id);
1083
+ if (!node)
1084
+ throw new Error("\u83B7\u53D6\u4E0D\u5230\u7EC4\u4EF6\u4FE1\u606F");
1085
+ if (node.id === this.state.root?.id) {
1086
+ throw new Error("\u4E0D\u80FD\u9009\u6839\u8282\u70B9");
1087
+ }
1088
+ return {
1089
+ node,
1090
+ parent,
1091
+ page
1092
+ };
1093
+ }
1074
1094
  }
1075
1095
  var editorService = new Editor$1();
1076
1096
 
@@ -1305,20 +1325,20 @@ const _sfc_main$g = defineComponent({
1305
1325
  if (!editorService)
1306
1326
  return;
1307
1327
  editorService.add({
1308
- type: "page",
1328
+ type: NodeType.PAGE,
1309
1329
  name: generatePageNameByApp(toRaw(editorService.get("root")))
1310
1330
  });
1311
1331
  }
1312
1332
  };
1313
1333
  }
1314
1334
  });
1315
- const _hoisted_1$b = { class: "m-editor-empty-panel" };
1335
+ const _hoisted_1$c = { class: "m-editor-empty-panel" };
1316
1336
  const _hoisted_2$6 = { class: "m-editor-empty-content" };
1317
1337
  const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "\u65B0\u589E\u9875\u9762", -1);
1318
1338
  function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
1319
1339
  const _component_plus = resolveComponent("plus");
1320
1340
  const _component_el_icon = resolveComponent("el-icon");
1321
- return openBlock(), createElementBlock("div", _hoisted_1$b, [
1341
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
1322
1342
  createElementVNode("div", _hoisted_2$6, [
1323
1343
  createElementVNode("div", {
1324
1344
  class: "m-editor-empty-button",
@@ -2548,12 +2568,12 @@ const _sfc_main$f = defineComponent({
2548
2568
  };
2549
2569
  }
2550
2570
  });
2551
- const _hoisted_1$a = {
2571
+ const _hoisted_1$b = {
2552
2572
  ref: "target",
2553
2573
  class: "m-editor-resizer"
2554
2574
  };
2555
2575
  function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) {
2556
- return openBlock(), createElementBlock("span", _hoisted_1$a, [
2576
+ return openBlock(), createElementBlock("span", _hoisted_1$b, [
2557
2577
  renderSlot(_ctx.$slots, "default")
2558
2578
  ], 512);
2559
2579
  }
@@ -2582,7 +2602,7 @@ const _sfc_main$e = defineComponent({
2582
2602
  };
2583
2603
  }
2584
2604
  });
2585
- const _hoisted_1$9 = { class: "m-editor" };
2605
+ const _hoisted_1$a = { class: "m-editor" };
2586
2606
  const _hoisted_2$5 = {
2587
2607
  key: 1,
2588
2608
  class: "m-editor-content"
@@ -2592,7 +2612,7 @@ function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) {
2592
2612
  const _component_resizer = resolveComponent("resizer");
2593
2613
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
2594
2614
  const _component_add_page_box = resolveComponent("add-page-box");
2595
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
2615
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
2596
2616
  renderSlot(_ctx.$slots, "nav", { class: "m-editor-nav-menu" }),
2597
2617
  _ctx.showSrc ? (openBlock(), createBlock(_component_magic_code_editor, {
2598
2618
  key: 0,
@@ -2648,7 +2668,7 @@ const _sfc_main$d = defineComponent({
2648
2668
  };
2649
2669
  }
2650
2670
  });
2651
- const _hoisted_1$8 = ["src"];
2671
+ const _hoisted_1$9 = ["src"];
2652
2672
  function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2653
2673
  const _component_edit = resolveComponent("edit");
2654
2674
  const _component_el_icon = resolveComponent("el-icon");
@@ -2660,7 +2680,7 @@ function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) {
2660
2680
  })) : typeof _ctx.icon === "string" && _ctx.icon.startsWith("http") ? (openBlock(), createElementBlock("img", {
2661
2681
  key: 1,
2662
2682
  src: _ctx.icon
2663
- }, null, 8, _hoisted_1$8)) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
2683
+ }, null, 8, _hoisted_1$9)) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
2664
2684
  key: 2,
2665
2685
  class: normalizeClass(_ctx.icon)
2666
2686
  }, null, 2)) : (openBlock(), createBlock(_component_el_icon, { key: 3 }, {
@@ -2710,7 +2730,7 @@ const _sfc_main$c = defineComponent({
2710
2730
  type: "button",
2711
2731
  icon: Delete,
2712
2732
  tooltip: "\u522A\u9664",
2713
- disabled: () => services?.editorService.get("node")?.type === "page",
2733
+ disabled: () => services?.editorService.get("node")?.type === NodeType.PAGE,
2714
2734
  handler: () => services?.editorService.remove(services?.editorService.get("node"))
2715
2735
  };
2716
2736
  case "undo":
@@ -2807,7 +2827,7 @@ const _sfc_main$c = defineComponent({
2807
2827
  };
2808
2828
  }
2809
2829
  });
2810
- const _hoisted_1$7 = {
2830
+ const _hoisted_1$8 = {
2811
2831
  key: 0,
2812
2832
  class: "menu-item"
2813
2833
  };
@@ -2830,7 +2850,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
2830
2850
  const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
2831
2851
  const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
2832
2852
  const _component_el_dropdown = resolveComponent("el-dropdown");
2833
- return _ctx.display ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
2853
+ return _ctx.display ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
2834
2854
  _ctx.item.type === "divider" ? (openBlock(), createBlock(_component_el_divider, {
2835
2855
  key: 0,
2836
2856
  direction: "vertical"
@@ -3037,7 +3057,7 @@ const _sfc_main$9 = defineComponent({
3037
3057
  };
3038
3058
  }
3039
3059
  });
3040
- const _hoisted_1$6 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3060
+ const _hoisted_1$7 = /* @__PURE__ */ createElementVNode("i", { class: "el-icon-s-grid" }, null, -1);
3041
3061
  const _hoisted_2$3 = ["onClick"];
3042
3062
  function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
3043
3063
  const _component_el_input = resolveComponent("el-input");
@@ -3069,7 +3089,7 @@ function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
3069
3089
  name: index
3070
3090
  }, {
3071
3091
  title: withCtx(() => [
3072
- _hoisted_1$6,
3092
+ _hoisted_1$7,
3073
3093
  createTextVNode(toDisplayString(group.title), 1)
3074
3094
  ]),
3075
3095
  default: withCtx(() => [
@@ -3150,7 +3170,7 @@ const _sfc_main$8 = defineComponent({
3150
3170
  };
3151
3171
  }
3152
3172
  });
3153
- const _hoisted_1$5 = {
3173
+ const _hoisted_1$6 = {
3154
3174
  key: 0,
3155
3175
  class: "magic-editor-content-menu"
3156
3176
  };
@@ -3159,7 +3179,7 @@ const _hoisted_3$2 = ["onClick"];
3159
3179
  const _hoisted_4$2 = /* @__PURE__ */ createElementVNode("div", { class: "separation" }, null, -1);
3160
3180
  function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
3161
3181
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
3162
- return _ctx.node ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
3182
+ return _ctx.node ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
3163
3183
  _ctx.node.items ? (openBlock(), createElementBlock("div", {
3164
3184
  key: 0,
3165
3185
  class: "magic-editor-content-menu-item",
@@ -3221,20 +3241,27 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
3221
3241
  }
3222
3242
  var LayerMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
3223
3243
 
3244
+ const throttleTime = 150;
3224
3245
  const select = (data, editorService) => {
3225
3246
  if (!data.id) {
3226
3247
  throw new Error("\u6CA1\u6709id");
3227
3248
  }
3228
3249
  editorService?.select(data);
3229
3250
  };
3251
+ const highlight = (data, editorService) => {
3252
+ if (!data?.id) {
3253
+ throw new Error("\u6CA1\u6709id");
3254
+ }
3255
+ editorService?.highlight(data);
3256
+ };
3230
3257
  const useDrop = (tree, editorService) => ({
3231
3258
  allowDrop: (draggingNode, dropNode, type) => {
3232
3259
  const { data } = dropNode || {};
3233
3260
  const { data: ingData } = draggingNode;
3234
3261
  const { type: ingType } = ingData;
3235
- if (ingType !== "page" && data.type === "page")
3262
+ if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE)
3236
3263
  return false;
3237
- if (ingType === "page" && data.type !== "page")
3264
+ if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE)
3238
3265
  return false;
3239
3266
  if (!data || !data.type)
3240
3267
  return false;
@@ -3253,29 +3280,34 @@ const useDrop = (tree, editorService) => ({
3253
3280
  }
3254
3281
  });
3255
3282
  const useStatus = (tree, editorService) => {
3283
+ const highlightNode = ref();
3284
+ const node = ref();
3256
3285
  const page = computed(() => editorService?.get("page"));
3257
3286
  watchEffect(() => {
3258
3287
  if (!tree.value)
3259
3288
  return;
3260
- const node = editorService?.get("node");
3261
- node && tree.value.setCurrentKey(node.id, true);
3289
+ node.value = editorService?.get("node");
3290
+ node.value && tree.value.setCurrentKey(node.value.id, true);
3262
3291
  const parent = editorService?.get("parent");
3263
3292
  if (!parent?.id)
3264
3293
  return;
3265
3294
  const treeNode = tree.value.getNode(parent.id);
3266
3295
  treeNode?.updateChildren();
3296
+ highlightNode.value = editorService?.get("highlightNode");
3267
3297
  });
3268
3298
  return {
3269
3299
  values: computed(() => page.value ? [page.value] : []),
3270
- loadItems: (node, resolve) => {
3271
- if (Array.isArray(node.data)) {
3272
- return resolve(node.data);
3300
+ loadItems: (node2, resolve) => {
3301
+ if (Array.isArray(node2.data)) {
3302
+ return resolve(node2.data);
3273
3303
  }
3274
- if (Array.isArray(node.data?.items)) {
3275
- return resolve(node.data?.items);
3304
+ if (Array.isArray(node2.data?.items)) {
3305
+ return resolve(node2.data?.items);
3276
3306
  }
3277
3307
  resolve([]);
3278
- }
3308
+ },
3309
+ highlightNode,
3310
+ clickNode: node
3279
3311
  };
3280
3312
  };
3281
3313
  const useFilter = (tree) => ({
@@ -3332,11 +3364,20 @@ const _sfc_main$7 = defineComponent({
3332
3364
  setup() {
3333
3365
  const services = inject("services");
3334
3366
  const tree = ref();
3367
+ const clicked = ref(false);
3335
3368
  const editorService = services?.editorService;
3369
+ const highlightHandler = throttle((data) => {
3370
+ highlight(data, editorService);
3371
+ }, throttleTime);
3372
+ const toogleClickFlag = () => {
3373
+ clicked.value = !clicked.value;
3374
+ };
3375
+ const statusData = useStatus(tree, editorService);
3376
+ const canHighlight = computed(() => statusData.highlightNode.value?.id !== statusData.clickNode.value?.id && !clicked.value);
3336
3377
  return {
3337
3378
  tree,
3379
+ ...statusData,
3338
3380
  ...useDrop(tree, editorService),
3339
- ...useStatus(tree, editorService),
3340
3381
  ...useFilter(tree),
3341
3382
  ...useContentMenu(editorService),
3342
3383
  clickHandler(data) {
@@ -3344,11 +3385,16 @@ const _sfc_main$7 = defineComponent({
3344
3385
  document.dispatchEvent(new CustomEvent("ui-select", { detail: data }));
3345
3386
  return;
3346
3387
  }
3388
+ tree.value?.setCurrentKey(data.id);
3347
3389
  select(data, editorService);
3348
- }
3390
+ },
3391
+ highlightHandler,
3392
+ toogleClickFlag,
3393
+ canHighlight
3349
3394
  };
3350
3395
  }
3351
3396
  });
3397
+ const _hoisted_1$5 = ["id", "onMouseenter"];
3352
3398
  function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3353
3399
  const _component_el_input = resolveComponent("el-input");
3354
3400
  const _component_el_tree = resolveComponent("el-tree");
@@ -3385,12 +3431,20 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
3385
3431
  "empty-text": "\u9875\u9762\u7A7A\u8361\u8361\u7684"
3386
3432
  }, {
3387
3433
  default: withCtx(({ node, data }) => [
3388
- renderSlot(_ctx.$slots, "layer-node-content", {
3389
- node,
3390
- data
3391
- }, () => [
3392
- createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
3393
- ])
3434
+ createElementVNode("div", {
3435
+ id: data.id,
3436
+ class: normalizeClass(["cus-tree-node", { "cus-tree-node-hover": _ctx.canHighlight && data.id === _ctx.highlightNode?.id }]),
3437
+ onMousedown: _cache[1] || (_cache[1] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
3438
+ onMouseup: _cache[2] || (_cache[2] = (...args) => _ctx.toogleClickFlag && _ctx.toogleClickFlag(...args)),
3439
+ onMouseenter: ($event) => _ctx.highlightHandler(data)
3440
+ }, [
3441
+ renderSlot(_ctx.$slots, "layer-node-content", {
3442
+ node,
3443
+ data
3444
+ }, () => [
3445
+ createElementVNode("span", null, toDisplayString(`${data.name} (${data.id})`), 1)
3446
+ ])
3447
+ ], 42, _hoisted_1$5)
3394
3448
  ]),
3395
3449
  _: 3
3396
3450
  }, 8, ["load", "data", "filter-node-method", "allow-drop", "onNodeClick", "onNodeContextmenu", "onNodeDragEnd"])) : createCommentVNode("", true),
@@ -3517,7 +3571,7 @@ const _sfc_main$5 = defineComponent({
3517
3571
  if (!editorService)
3518
3572
  return;
3519
3573
  const pageConfig = {
3520
- type: "page",
3574
+ type: NodeType.PAGE,
3521
3575
  name: generatePageNameByApp(toRaw(editorService.get("root")))
3522
3576
  };
3523
3577
  editorService.add(pageConfig);
@@ -3537,11 +3591,13 @@ const _sfc_main$5 = defineComponent({
3537
3591
  });
3538
3592
  const _hoisted_1$3 = { class: "m-editor-page-bar" };
3539
3593
  const _hoisted_2$1 = ["onClick"];
3540
- const _hoisted_3$1 = ["onClick"];
3594
+ const _hoisted_3$1 = { class: "m-editor-page-bar-title" };
3541
3595
  const _hoisted_4$1 = ["onClick"];
3596
+ const _hoisted_5 = ["onClick"];
3542
3597
  function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3543
3598
  const _component_plus = resolveComponent("plus");
3544
3599
  const _component_el_icon = resolveComponent("el-icon");
3600
+ const _component_el_tooltip = resolveComponent("el-tooltip");
3545
3601
  const _component_caret_bottom = resolveComponent("caret-bottom");
3546
3602
  const _component_el_popover = resolveComponent("el-popover");
3547
3603
  return openBlock(), createElementBlock("div", _hoisted_1$3, [
@@ -3562,8 +3618,19 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3562
3618
  class: normalizeClass(["m-editor-page-bar-item", { active: _ctx.page?.id === item.id }]),
3563
3619
  onClick: ($event) => _ctx.switchPage(item)
3564
3620
  }, [
3565
- renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3566
- createElementVNode("span", null, toDisplayString(item.name), 1)
3621
+ createElementVNode("div", _hoisted_3$1, [
3622
+ renderSlot(_ctx.$slots, "page-bar-title", { page: item }, () => [
3623
+ createVNode(_component_el_tooltip, {
3624
+ effect: "dark",
3625
+ placement: "top-start",
3626
+ content: item.name
3627
+ }, {
3628
+ default: withCtx(() => [
3629
+ createElementVNode("span", null, toDisplayString(item.name), 1)
3630
+ ]),
3631
+ _: 2
3632
+ }, 1032, ["content"])
3633
+ ])
3567
3634
  ]),
3568
3635
  createVNode(_component_el_popover, {
3569
3636
  placement: "top",
@@ -3584,11 +3651,11 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
3584
3651
  createElementVNode("div", {
3585
3652
  class: "magic-editor-content-menu-item",
3586
3653
  onClick: () => _ctx.copy(item)
3587
- }, "\u590D\u5236", 8, _hoisted_3$1),
3654
+ }, "\u590D\u5236", 8, _hoisted_4$1),
3588
3655
  createElementVNode("div", {
3589
3656
  class: "magic-editor-content-menu-item",
3590
3657
  onClick: () => _ctx.remove(item)
3591
- }, "\u5220\u9664", 8, _hoisted_4$1)
3658
+ }, "\u5220\u9664", 8, _hoisted_5)
3592
3659
  ])
3593
3660
  ])
3594
3661
  ]),
@@ -3837,13 +3904,13 @@ const _sfc_main$3 = defineComponent({
3837
3904
  if (!parent.value || !editorService)
3838
3905
  return canCenter.value = false;
3839
3906
  const layout = await editorService.getLayout(parent.value);
3840
- canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && !["app", "page", "pop"].includes(`${node.value?.type}`);
3907
+ canCenter.value = [Layout.ABSOLUTE, Layout.FIXED].includes(layout) && ![NodeType.ROOT, NodeType.PAGE, "pop"].includes(`${node.value?.type}`);
3841
3908
  }, { immediate: true });
3842
3909
  return {
3843
3910
  menu,
3844
3911
  canPaste,
3845
- canDelete: computed(() => node.value?.type !== "page"),
3846
- canMoveZPos: computed(() => node.value?.type !== "page"),
3912
+ canDelete: computed(() => node.value?.type !== NodeType.PAGE),
3913
+ canMoveZPos: computed(() => node.value?.type !== NodeType.PAGE),
3847
3914
  canCenter,
3848
3915
  center() {
3849
3916
  node.value && editorService?.alignCenter(node.value);
@@ -3990,7 +4057,7 @@ const _sfc_main$2 = defineComponent({
3990
4057
  })
3991
4058
  }
3992
4059
  },
3993
- emits: ["select", "update", "sort"],
4060
+ emits: ["select", "update", "sort", "highlight"],
3994
4061
  setup(props, { emit }) {
3995
4062
  const services = inject("services");
3996
4063
  const stageWrap = ref();
@@ -4001,6 +4068,7 @@ const _sfc_main$2 = defineComponent({
4001
4068
  const page = computed(() => services?.editorService.get("page"));
4002
4069
  const zoom = computed(() => services?.uiService.get("zoom"));
4003
4070
  const node = computed(() => services?.editorService.get("node"));
4071
+ const highlightNode = computed(() => services?.editorService.get("highlightNode"));
4004
4072
  let stage = null;
4005
4073
  let runtime = null;
4006
4074
  watchEffect(() => {
@@ -4026,7 +4094,12 @@ const _sfc_main$2 = defineComponent({
4026
4094
  });
4027
4095
  services?.editorService.set("stage", stage);
4028
4096
  stage?.mount(stageContainer.value);
4029
- stage?.on("select", (el) => emit("select", el));
4097
+ stage?.on("select", (el) => {
4098
+ emit("select", el);
4099
+ });
4100
+ stage?.on("highlight", (el) => {
4101
+ emit("highlight", el);
4102
+ });
4030
4103
  stage?.on("update", (ev) => {
4031
4104
  emit("update", { id: ev.el.id, style: ev.style });
4032
4105
  });
@@ -4062,6 +4135,11 @@ const _sfc_main$2 = defineComponent({
4062
4135
  id && stage?.select(id);
4063
4136
  });
4064
4137
  });
4138
+ watch(() => highlightNode.value?.id, (id) => {
4139
+ nextTick(() => {
4140
+ id && stage?.highlight(id);
4141
+ });
4142
+ });
4065
4143
  const resizeObserver = new ResizeObserver((entries) => {
4066
4144
  for (const { contentRect } of entries) {
4067
4145
  services?.uiService.set("stageContainerRect", {
@@ -4146,6 +4224,9 @@ const _sfc_main$1 = defineComponent({
4146
4224
  },
4147
4225
  sortNodeHandler(ev) {
4148
4226
  services?.editorService.sort(ev.src, ev.dist);
4227
+ },
4228
+ highlightHandler(el) {
4229
+ services?.editorService.highlight(el.id);
4149
4230
  }
4150
4231
  };
4151
4232
  }
@@ -4162,9 +4243,10 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
4162
4243
  "moveable-options": _ctx.moveableOptions,
4163
4244
  "can-select": _ctx.canSelect,
4164
4245
  onSelect: _ctx.selectHandler,
4246
+ onHighlight: _ctx.highlightHandler,
4165
4247
  onUpdate: _ctx.updateNodeHandler,
4166
4248
  onSort: _ctx.sortNodeHandler
4167
- }, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onUpdate", "onSort"])),
4249
+ }, null, 8, ["runtime-url", "render", "moveable-options", "can-select", "onSelect", "onHighlight", "onUpdate", "onSort"])),
4168
4250
  renderSlot(_ctx.$slots, "workspace-content"),
4169
4251
  createVNode(_component_page_bar, null, {
4170
4252
  "page-bar-title": withCtx(({ page }) => [