@tmagic/editor 1.2.0-beta.20 → 1.2.0-beta.21

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.
@@ -552,7 +552,7 @@
552
552
  const props = __props;
553
553
  const el = vue.ref();
554
554
  const hasLeft = vue.computed(() => typeof props.left !== "undefined");
555
- const hasRight = vue.computed(() => typeof props.left !== "undefined");
555
+ const hasRight = vue.computed(() => typeof props.right !== "undefined");
556
556
  const getCenterWidth = (clientWidth2, left, right) => {
557
557
  let center2 = clientWidth2 - left - right;
558
558
  if (center2 < props.minCenter) {
@@ -874,6 +874,10 @@
874
874
  this.pluginOptionsList[methodName2].push(method);
875
875
  });
876
876
  }
877
+ removeAllPlugins() {
878
+ this.pluginOptionsList = {};
879
+ this.middleware = {};
880
+ }
877
881
  async doTask() {
878
882
  this.doingTask = true;
879
883
  let task = this.taskList.shift();
@@ -1052,7 +1056,7 @@
1052
1056
  this.refreshRelationDeep(node, codeDsl2);
1053
1057
  this.setCodeDsl(codeDsl2);
1054
1058
  }
1055
- destroy() {
1059
+ resetState() {
1056
1060
  this.state.isShowCodeEditor = false;
1057
1061
  this.state.codeDsl = null;
1058
1062
  this.state.id = "";
@@ -1061,6 +1065,11 @@
1061
1065
  this.state.combineIds = [];
1062
1066
  this.state.undeletableList = [];
1063
1067
  }
1068
+ destroy() {
1069
+ this.resetState();
1070
+ this.removeAllListeners();
1071
+ this.removeAllPlugins();
1072
+ }
1064
1073
  refreshRelationDeep(node, codeDsl2) {
1065
1074
  if (!node.id)
1066
1075
  return;
@@ -1179,7 +1188,7 @@
1179
1188
  this.setCanUndoRedo();
1180
1189
  this.emit("page-change", this.state.pageSteps[this.state.pageId]);
1181
1190
  }
1182
- empty() {
1191
+ resetState() {
1183
1192
  this.state.pageId = void 0;
1184
1193
  this.state.pageSteps = {};
1185
1194
  this.state.canRedo = false;
@@ -1210,8 +1219,9 @@
1210
1219
  return state;
1211
1220
  }
1212
1221
  destroy() {
1213
- this.empty();
1222
+ this.resetState();
1214
1223
  this.removeAllListeners();
1224
+ this.removeAllPlugins();
1215
1225
  }
1216
1226
  getUndoRedo() {
1217
1227
  if (!this.state.pageId)
@@ -1291,6 +1301,7 @@
1291
1301
  }
1292
1302
  destroy() {
1293
1303
  this.removeAllListeners();
1304
+ this.removeAllPlugins();
1294
1305
  }
1295
1306
  getValueAndProtocol(value) {
1296
1307
  let protocol2 = "";
@@ -1562,10 +1573,14 @@
1562
1573
  name: type
1563
1574
  };
1564
1575
  }
1565
- destroy() {
1576
+ resetState() {
1566
1577
  this.state.propsConfigMap = {};
1567
1578
  this.state.propsValueMap = {};
1579
+ }
1580
+ destroy() {
1581
+ this.resetState();
1568
1582
  this.removeAllListeners();
1583
+ this.removeAllPlugins();
1569
1584
  }
1570
1585
  guid(digit = 8) {
1571
1586
  return "x".repeat(digit).replace(/[xy]/g, (c) => {
@@ -1757,7 +1772,7 @@
1757
1772
  if (page) {
1758
1773
  historyService.changePage(vue.toRaw(page));
1759
1774
  } else {
1760
- historyService.empty();
1775
+ historyService.resetState();
1761
1776
  }
1762
1777
  if (node?.id) {
1763
1778
  this.get("stage")?.renderer.runtime?.getApp?.()?.emit(
@@ -2136,8 +2151,7 @@
2136
2151
  }
2137
2152
  });
2138
2153
  }
2139
- destroy() {
2140
- this.removeAllListeners();
2154
+ resetState() {
2141
2155
  this.set("root", null);
2142
2156
  this.set("node", null);
2143
2157
  this.set("nodes", []);
@@ -2148,6 +2162,11 @@
2148
2162
  this.set("modifiedNodeIds", /* @__PURE__ */ new Map());
2149
2163
  this.set("pageLength", /* @__PURE__ */ new Map());
2150
2164
  }
2165
+ destroy() {
2166
+ this.removeAllListeners();
2167
+ this.resetState();
2168
+ this.removeAllPlugins();
2169
+ }
2151
2170
  resetModifiedNodeId() {
2152
2171
  this.get("modifiedNodeIds").clear();
2153
2172
  }
@@ -2274,10 +2293,14 @@
2274
2293
  getMethod(type) {
2275
2294
  return lodashEs.cloneDeep(methodMap[type] || core.DEFAULT_METHODS);
2276
2295
  }
2277
- destroy() {
2296
+ resetState() {
2278
2297
  eventMap = vue.reactive({});
2279
2298
  methodMap = vue.reactive({});
2299
+ }
2300
+ destroy() {
2301
+ this.resetState();
2280
2302
  this.removeAllListeners();
2303
+ this.removeAllPlugins();
2281
2304
  }
2282
2305
  }
2283
2306
  const eventsService = new Events();
@@ -2552,8 +2575,19 @@
2552
2575
  }
2553
2576
  return Math.min((width - 60) / stageWidth || 1, (height - 80) / stageHeight || 1);
2554
2577
  }
2578
+ resetState() {
2579
+ this.set("showSrc", false);
2580
+ this.set("uiSelectMode", false);
2581
+ this.set("zoom", 1);
2582
+ this.set("stageContainerRect", {
2583
+ width: 0,
2584
+ height: 0
2585
+ });
2586
+ }
2555
2587
  destroy() {
2588
+ this.resetState();
2556
2589
  this.removeAllListeners();
2590
+ this.removeAllPlugins();
2557
2591
  }
2558
2592
  async setStageRect(value) {
2559
2593
  state.stageRect = {
@@ -5762,9 +5796,13 @@
5762
5796
  getList() {
5763
5797
  return this.state.list;
5764
5798
  }
5765
- destroy() {
5799
+ resetState() {
5766
5800
  this.state.list = [];
5801
+ }
5802
+ destroy() {
5803
+ this.resetState();
5767
5804
  this.removeAllListeners();
5805
+ this.removeAllPlugins();
5768
5806
  }
5769
5807
  }
5770
5808
  const componentListService = new ComponentList();
@@ -5939,13 +5977,12 @@
5939
5977
  }
5940
5978
  );
5941
5979
  vue.onUnmounted(() => {
5942
- editorService.destroy();
5943
- historyService.destroy();
5944
- propsService.destroy();
5945
- uiService.destroy();
5946
- componentListService.destroy();
5947
- storageService.destroy();
5948
- codeBlockService.destroy();
5980
+ editorService.resetState();
5981
+ historyService.resetState();
5982
+ propsService.resetState();
5983
+ uiService.resetState();
5984
+ componentListService.resetState();
5985
+ codeBlockService.resetState();
5949
5986
  });
5950
5987
  const services = {
5951
5988
  componentListService,
@@ -6152,4 +6189,4 @@
6152
6189
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
6153
6190
 
6154
6191
  }));
6155
- //# sourceMappingURL=tmagic-editor.umd.js.map
6192
+ //# sourceMappingURL=tmagic-editor.umd.cjs.map