@tmagic/editor 1.3.12 → 1.3.13

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.
@@ -2993,6 +2993,7 @@ class Editor extends BaseService {
2993
2993
  this.addModifiedNodeId(config.id);
2994
2994
  this.addModifiedNodeId(parent.id);
2995
2995
  this.pushHistoryState();
2996
+ this.emit("drag-to", { index, targetIndex, config, parent, targetParent });
2996
2997
  }
2997
2998
  /**
2998
2999
  * 撤销当前操作
@@ -5218,14 +5219,17 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
5218
5219
  const selectNode = async (id) => {
5219
5220
  await services?.editorService.select(id);
5220
5221
  services?.editorService.get("stage")?.select(id);
5222
+ services?.stageOverlayService.get("stage")?.select(id);
5221
5223
  };
5222
5224
  const highlight = throttle((id) => {
5223
5225
  services?.editorService.highlight(id);
5224
5226
  services?.editorService.get("stage")?.highlight(id);
5227
+ services?.stageOverlayService.get("stage")?.highlight(id);
5225
5228
  }, 150);
5226
5229
  const unhightlight = () => {
5227
5230
  services?.editorService.set("highlightNode", null);
5228
5231
  services?.editorService.get("stage")?.clearHighlight();
5232
+ services?.stageOverlayService.get("stage")?.clearHighlight();
5229
5233
  };
5230
5234
  return (_ctx, _cache) => {
5231
5235
  return uiSelectMode.value ? (openBlock(), createElementBlock("div", {
@@ -7893,6 +7897,7 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
7893
7897
  } else {
7894
7898
  await services?.editorService.select(data);
7895
7899
  services?.editorService.get("stage")?.select(data.id);
7900
+ services?.stageOverlayService.get("stage")?.select(data.id);
7896
7901
  }
7897
7902
  };
7898
7903
  const multiSelect = async (data) => {
@@ -7911,6 +7916,7 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
7911
7916
  }
7912
7917
  await services?.editorService.multiSelect(newNodes);
7913
7918
  services?.editorService.get("stage")?.multiSelect(newNodes);
7919
+ services?.stageOverlayService.get("stage")?.multiSelect(newNodes);
7914
7920
  };
7915
7921
  const throttleTime = 300;
7916
7922
  const highlightHandler = throttle((event, data) => {
@@ -7919,6 +7925,7 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
7919
7925
  const highlight = (data) => {
7920
7926
  services?.editorService?.highlight(data);
7921
7927
  services?.editorService?.get("stage")?.highlight(data.id);
7928
+ services?.stageOverlayService?.get("stage")?.highlight(data.id);
7922
7929
  };
7923
7930
  const nodeClickHandler = (event, data) => {
7924
7931
  if (!nodeStatusMap?.value)
@@ -10579,6 +10586,8 @@ class StageOverlay extends BaseService {
10579
10586
  editorService.on("update", this.updateHandler);
10580
10587
  editorService.on("add", this.addHandler);
10581
10588
  editorService.on("remove", this.removeHandler);
10589
+ editorService.on("drag-to", this.updateHandler);
10590
+ editorService.on("move-layer", this.updateHandler);
10582
10591
  }
10583
10592
  closeOverlay() {
10584
10593
  this.set("stageOverlayVisible", false);
@@ -10592,6 +10601,8 @@ class StageOverlay extends BaseService {
10592
10601
  editorService.off("update", this.updateHandler);
10593
10602
  editorService.off("add", this.addHandler);
10594
10603
  editorService.off("remove", this.removeHandler);
10604
+ editorService.off("drag-to", this.updateHandler);
10605
+ editorService.off("move-layer", this.updateHandler);
10595
10606
  }
10596
10607
  updateOverlay() {
10597
10608
  const sourceEl = this.get("sourceEl");
@@ -10618,12 +10629,6 @@ class StageOverlay extends BaseService {
10618
10629
  });
10619
10630
  }
10620
10631
  const wrapDiv = this.get("wrapDiv");
10621
- const sourceEl = this.get("sourceEl");
10622
- wrapDiv.style.cssText = `
10623
- width: ${sourceEl?.scrollWidth}px;
10624
- height: ${sourceEl?.scrollHeight}px;
10625
- background-color: #fff;
10626
- `;
10627
10632
  await this.render();
10628
10633
  return wrapDiv;
10629
10634
  }
@@ -10650,11 +10655,17 @@ class StageOverlay extends BaseService {
10650
10655
  async render() {
10651
10656
  this.createContentEl();
10652
10657
  const contentEl = this.get("contentEl");
10658
+ const sourceEl = this.get("sourceEl");
10653
10659
  const wrapDiv = this.get("wrapDiv");
10654
10660
  const subStage = this.get("stage");
10655
10661
  const stageOptions = this.get("stageOptions");
10656
10662
  if (!contentEl)
10657
10663
  return;
10664
+ wrapDiv.style.cssText = `
10665
+ width: ${sourceEl?.scrollWidth}px;
10666
+ height: ${sourceEl?.scrollHeight}px;
10667
+ background-color: #fff;
10668
+ `;
10658
10669
  Array.from(wrapDiv.children).forEach((element) => {
10659
10670
  element.remove();
10660
10671
  });
@@ -10667,17 +10678,31 @@ class StageOverlay extends BaseService {
10667
10678
  }
10668
10679
  }
10669
10680
  updateHandler = () => {
10670
- this.render();
10671
- this.updateOverlay();
10681
+ setTimeout(() => {
10682
+ this.render();
10683
+ this.updateOverlay();
10684
+ this.updateSelectStatus();
10685
+ });
10672
10686
  };
10673
10687
  addHandler = () => {
10674
10688
  this.render();
10675
10689
  this.updateOverlay();
10690
+ this.updateSelectStatus();
10676
10691
  };
10677
10692
  removeHandler = () => {
10678
10693
  this.render();
10679
10694
  this.updateOverlay();
10695
+ this.updateSelectStatus();
10680
10696
  };
10697
+ updateSelectStatus() {
10698
+ const subStage = this.get("stage");
10699
+ const nodes = editorService.get("nodes");
10700
+ if (nodes.length > 1) {
10701
+ subStage?.multiSelect(nodes.map((n) => n.id));
10702
+ } else {
10703
+ subStage?.select(nodes[0].id);
10704
+ }
10705
+ }
10681
10706
  }
10682
10707
  const stageOverlayService = new StageOverlay();
10683
10708
 
@@ -2998,6 +2998,7 @@
2998
2998
  this.addModifiedNodeId(config.id);
2999
2999
  this.addModifiedNodeId(parent.id);
3000
3000
  this.pushHistoryState();
3001
+ this.emit("drag-to", { index, targetIndex, config, parent, targetParent });
3001
3002
  }
3002
3003
  /**
3003
3004
  * 撤销当前操作
@@ -5223,14 +5224,17 @@
5223
5224
  const selectNode = async (id) => {
5224
5225
  await services?.editorService.select(id);
5225
5226
  services?.editorService.get("stage")?.select(id);
5227
+ services?.stageOverlayService.get("stage")?.select(id);
5226
5228
  };
5227
5229
  const highlight = lodashEs.throttle((id) => {
5228
5230
  services?.editorService.highlight(id);
5229
5231
  services?.editorService.get("stage")?.highlight(id);
5232
+ services?.stageOverlayService.get("stage")?.highlight(id);
5230
5233
  }, 150);
5231
5234
  const unhightlight = () => {
5232
5235
  services?.editorService.set("highlightNode", null);
5233
5236
  services?.editorService.get("stage")?.clearHighlight();
5237
+ services?.stageOverlayService.get("stage")?.clearHighlight();
5234
5238
  };
5235
5239
  return (_ctx, _cache) => {
5236
5240
  return uiSelectMode.value ? (vue.openBlock(), vue.createElementBlock("div", {
@@ -7898,6 +7902,7 @@
7898
7902
  } else {
7899
7903
  await services?.editorService.select(data);
7900
7904
  services?.editorService.get("stage")?.select(data.id);
7905
+ services?.stageOverlayService.get("stage")?.select(data.id);
7901
7906
  }
7902
7907
  };
7903
7908
  const multiSelect = async (data) => {
@@ -7916,6 +7921,7 @@
7916
7921
  }
7917
7922
  await services?.editorService.multiSelect(newNodes);
7918
7923
  services?.editorService.get("stage")?.multiSelect(newNodes);
7924
+ services?.stageOverlayService.get("stage")?.multiSelect(newNodes);
7919
7925
  };
7920
7926
  const throttleTime = 300;
7921
7927
  const highlightHandler = lodashEs.throttle((event, data) => {
@@ -7924,6 +7930,7 @@
7924
7930
  const highlight = (data) => {
7925
7931
  services?.editorService?.highlight(data);
7926
7932
  services?.editorService?.get("stage")?.highlight(data.id);
7933
+ services?.stageOverlayService?.get("stage")?.highlight(data.id);
7927
7934
  };
7928
7935
  const nodeClickHandler = (event, data) => {
7929
7936
  if (!nodeStatusMap?.value)
@@ -10584,6 +10591,8 @@
10584
10591
  editorService.on("update", this.updateHandler);
10585
10592
  editorService.on("add", this.addHandler);
10586
10593
  editorService.on("remove", this.removeHandler);
10594
+ editorService.on("drag-to", this.updateHandler);
10595
+ editorService.on("move-layer", this.updateHandler);
10587
10596
  }
10588
10597
  closeOverlay() {
10589
10598
  this.set("stageOverlayVisible", false);
@@ -10597,6 +10606,8 @@
10597
10606
  editorService.off("update", this.updateHandler);
10598
10607
  editorService.off("add", this.addHandler);
10599
10608
  editorService.off("remove", this.removeHandler);
10609
+ editorService.off("drag-to", this.updateHandler);
10610
+ editorService.off("move-layer", this.updateHandler);
10600
10611
  }
10601
10612
  updateOverlay() {
10602
10613
  const sourceEl = this.get("sourceEl");
@@ -10623,12 +10634,6 @@
10623
10634
  });
10624
10635
  }
10625
10636
  const wrapDiv = this.get("wrapDiv");
10626
- const sourceEl = this.get("sourceEl");
10627
- wrapDiv.style.cssText = `
10628
- width: ${sourceEl?.scrollWidth}px;
10629
- height: ${sourceEl?.scrollHeight}px;
10630
- background-color: #fff;
10631
- `;
10632
10637
  await this.render();
10633
10638
  return wrapDiv;
10634
10639
  }
@@ -10655,11 +10660,17 @@
10655
10660
  async render() {
10656
10661
  this.createContentEl();
10657
10662
  const contentEl = this.get("contentEl");
10663
+ const sourceEl = this.get("sourceEl");
10658
10664
  const wrapDiv = this.get("wrapDiv");
10659
10665
  const subStage = this.get("stage");
10660
10666
  const stageOptions = this.get("stageOptions");
10661
10667
  if (!contentEl)
10662
10668
  return;
10669
+ wrapDiv.style.cssText = `
10670
+ width: ${sourceEl?.scrollWidth}px;
10671
+ height: ${sourceEl?.scrollHeight}px;
10672
+ background-color: #fff;
10673
+ `;
10663
10674
  Array.from(wrapDiv.children).forEach((element) => {
10664
10675
  element.remove();
10665
10676
  });
@@ -10672,17 +10683,31 @@
10672
10683
  }
10673
10684
  }
10674
10685
  updateHandler = () => {
10675
- this.render();
10676
- this.updateOverlay();
10686
+ setTimeout(() => {
10687
+ this.render();
10688
+ this.updateOverlay();
10689
+ this.updateSelectStatus();
10690
+ });
10677
10691
  };
10678
10692
  addHandler = () => {
10679
10693
  this.render();
10680
10694
  this.updateOverlay();
10695
+ this.updateSelectStatus();
10681
10696
  };
10682
10697
  removeHandler = () => {
10683
10698
  this.render();
10684
10699
  this.updateOverlay();
10700
+ this.updateSelectStatus();
10685
10701
  };
10702
+ updateSelectStatus() {
10703
+ const subStage = this.get("stage");
10704
+ const nodes = editorService.get("nodes");
10705
+ if (nodes.length > 1) {
10706
+ subStage?.multiSelect(nodes.map((n) => n.id));
10707
+ } else {
10708
+ subStage?.select(nodes[0].id);
10709
+ }
10710
+ }
10686
10711
  }
10687
10712
  const stageOverlayService = new StageOverlay();
10688
10713
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.12",
2
+ "version": "1.3.13",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -42,14 +42,14 @@
42
42
  "dependencies": {
43
43
  "@babel/core": "^7.18.0",
44
44
  "@element-plus/icons-vue": "^2.3.1",
45
- "@tmagic/core": "1.3.12",
46
- "@tmagic/dep": "1.3.12",
47
- "@tmagic/design": "1.3.12",
48
- "@tmagic/form": "1.3.12",
49
- "@tmagic/schema": "1.3.12",
50
- "@tmagic/stage": "1.3.12",
51
- "@tmagic/table": "1.3.12",
52
- "@tmagic/utils": "1.3.12",
45
+ "@tmagic/core": "1.3.13",
46
+ "@tmagic/dep": "1.3.13",
47
+ "@tmagic/design": "1.3.13",
48
+ "@tmagic/form": "1.3.13",
49
+ "@tmagic/schema": "1.3.13",
50
+ "@tmagic/stage": "1.3.13",
51
+ "@tmagic/table": "1.3.13",
52
+ "@tmagic/utils": "1.3.13",
53
53
  "buffer": "^6.0.3",
54
54
  "color": "^3.1.3",
55
55
  "emmet-monaco-es": "^5.3.0",
@@ -63,8 +63,8 @@
63
63
  "vue": "^3.3.8"
64
64
  },
65
65
  "peerDependencies": {
66
- "@tmagic/design": "1.3.12",
67
- "@tmagic/form": "1.3.12",
66
+ "@tmagic/design": "1.3.13",
67
+ "@tmagic/form": "1.3.13",
68
68
  "monaco-editor": "^0.41.0",
69
69
  "vue": "^3.3.8"
70
70
  },
@@ -106,16 +106,19 @@ const deleteHandler = () => {
106
106
  const selectNode = async (id: Id) => {
107
107
  await services?.editorService.select(id);
108
108
  services?.editorService.get('stage')?.select(id);
109
+ services?.stageOverlayService.get('stage')?.select(id);
109
110
  };
110
111
 
111
112
  const highlight = throttle((id: Id) => {
112
113
  services?.editorService.highlight(id);
113
114
  services?.editorService.get('stage')?.highlight(id);
115
+ services?.stageOverlayService.get('stage')?.highlight(id);
114
116
  }, 150);
115
117
 
116
118
  const unhightlight = () => {
117
119
  services?.editorService.set('highlightNode', null);
118
120
  services?.editorService.get('stage')?.clearHighlight();
121
+ services?.stageOverlayService.get('stage')?.clearHighlight();
119
122
  };
120
123
  </script>
121
124
 
@@ -26,6 +26,7 @@ export const useClick = (
26
26
  } else {
27
27
  await services?.editorService.select(data);
28
28
  services?.editorService.get('stage')?.select(data.id);
29
+ services?.stageOverlayService.get('stage')?.select(data.id);
29
30
  }
30
31
  };
31
32
 
@@ -50,6 +51,7 @@ export const useClick = (
50
51
 
51
52
  await services?.editorService.multiSelect(newNodes);
52
53
  services?.editorService.get('stage')?.multiSelect(newNodes);
54
+ services?.stageOverlayService.get('stage')?.multiSelect(newNodes);
53
55
  };
54
56
 
55
57
  const throttleTime = 300;
@@ -62,6 +64,7 @@ export const useClick = (
62
64
  const highlight = (data: TreeNodeData) => {
63
65
  services?.editorService?.highlight(data);
64
66
  services?.editorService?.get('stage')?.highlight(data.id);
67
+ services?.stageOverlayService?.get('stage')?.highlight(data.id);
65
68
  };
66
69
 
67
70
  const nodeClickHandler = (event: MouseEvent, data: TreeNodeData) => {
@@ -892,6 +892,8 @@ class Editor extends BaseService {
892
892
  this.addModifiedNodeId(parent.id);
893
893
 
894
894
  this.pushHistoryState();
895
+
896
+ this.emit('drag-to', { index, targetIndex, config, parent, targetParent });
895
897
  }
896
898
 
897
899
  /**
@@ -51,6 +51,8 @@ class StageOverlay extends BaseService {
51
51
  editorService.on('update', this.updateHandler);
52
52
  editorService.on('add', this.addHandler);
53
53
  editorService.on('remove', this.removeHandler);
54
+ editorService.on('drag-to', this.updateHandler);
55
+ editorService.on('move-layer', this.updateHandler);
54
56
  }
55
57
 
56
58
  public closeOverlay() {
@@ -67,6 +69,8 @@ class StageOverlay extends BaseService {
67
69
  editorService.off('update', this.updateHandler);
68
70
  editorService.off('add', this.addHandler);
69
71
  editorService.off('remove', this.removeHandler);
72
+ editorService.off('drag-to', this.updateHandler);
73
+ editorService.off('move-layer', this.updateHandler);
70
74
  }
71
75
 
72
76
  public updateOverlay() {
@@ -99,13 +103,6 @@ class StageOverlay extends BaseService {
99
103
  }
100
104
 
101
105
  const wrapDiv = this.get('wrapDiv');
102
- const sourceEl = this.get('sourceEl');
103
-
104
- wrapDiv.style.cssText = `
105
- width: ${sourceEl?.scrollWidth}px;
106
- height: ${sourceEl?.scrollHeight}px;
107
- background-color: #fff;
108
- `;
109
106
 
110
107
  await this.render();
111
108
 
@@ -141,12 +138,19 @@ class StageOverlay extends BaseService {
141
138
  this.createContentEl();
142
139
 
143
140
  const contentEl = this.get('contentEl');
141
+ const sourceEl = this.get('sourceEl');
144
142
  const wrapDiv = this.get('wrapDiv');
145
143
  const subStage = this.get('stage');
146
144
  const stageOptions = this.get('stageOptions');
147
145
 
148
146
  if (!contentEl) return;
149
147
 
148
+ wrapDiv.style.cssText = `
149
+ width: ${sourceEl?.scrollWidth}px;
150
+ height: ${sourceEl?.scrollHeight}px;
151
+ background-color: #fff;
152
+ `;
153
+
150
154
  Array.from(wrapDiv.children).forEach((element) => {
151
155
  element.remove();
152
156
  });
@@ -162,19 +166,37 @@ class StageOverlay extends BaseService {
162
166
  }
163
167
 
164
168
  private updateHandler = () => {
165
- this.render();
166
- this.updateOverlay();
169
+ setTimeout(() => {
170
+ this.render();
171
+ this.updateOverlay();
172
+
173
+ this.updateSelectStatus();
174
+ });
167
175
  };
168
176
 
169
177
  private addHandler = () => {
170
178
  this.render();
171
179
  this.updateOverlay();
180
+
181
+ this.updateSelectStatus();
172
182
  };
173
183
 
174
184
  private removeHandler = () => {
175
185
  this.render();
176
186
  this.updateOverlay();
187
+
188
+ this.updateSelectStatus();
177
189
  };
190
+
191
+ private updateSelectStatus() {
192
+ const subStage = this.get('stage');
193
+ const nodes = editorService.get('nodes');
194
+ if (nodes.length > 1) {
195
+ subStage?.multiSelect(nodes.map((n) => n.id));
196
+ } else {
197
+ subStage?.select(nodes[0].id);
198
+ }
199
+ }
178
200
  }
179
201
 
180
202
  export type StageOverlayService = StageOverlay;
@@ -16,6 +16,7 @@ declare class StageOverlay extends BaseService {
16
16
  private updateHandler;
17
17
  private addHandler;
18
18
  private removeHandler;
19
+ private updateSelectStatus;
19
20
  }
20
21
  export type StageOverlayService = StageOverlay;
21
22
  declare const _default: StageOverlay;