@tmagic/editor 1.2.0-beta.26 → 1.2.0-beta.27

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.0-beta.26",
2
+ "version": "1.2.0-beta.27",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -46,12 +46,12 @@
46
46
  "dependencies": {
47
47
  "@babel/core": "^7.18.0",
48
48
  "@element-plus/icons-vue": "^2.0.9",
49
- "@tmagic/core": "1.2.0-beta.26",
50
- "@tmagic/design": "1.2.0-beta.26",
51
- "@tmagic/form": "1.2.0-beta.26",
52
- "@tmagic/schema": "1.2.0-beta.26",
53
- "@tmagic/stage": "1.2.0-beta.26",
54
- "@tmagic/utils": "1.2.0-beta.26",
49
+ "@tmagic/core": "1.2.0-beta.27",
50
+ "@tmagic/design": "1.2.0-beta.27",
51
+ "@tmagic/form": "1.2.0-beta.27",
52
+ "@tmagic/schema": "1.2.0-beta.27",
53
+ "@tmagic/stage": "1.2.0-beta.27",
54
+ "@tmagic/utils": "1.2.0-beta.27",
55
55
  "buffer": "^6.0.3",
56
56
  "color": "^3.1.3",
57
57
  "events": "^3.3.0",
@@ -63,8 +63,8 @@
63
63
  "vue": "^3.2.37"
64
64
  },
65
65
  "peerDependencies": {
66
- "@tmagic/design": "1.2.0-beta.26",
67
- "@tmagic/form": "1.2.0-beta.26",
66
+ "@tmagic/design": "1.2.0-beta.27",
67
+ "@tmagic/form": "1.2.0-beta.27",
68
68
  "monaco-editor": "^0.34.0",
69
69
  "vue": "^3.2.37"
70
70
  },
package/src/Editor.vue CHANGED
@@ -227,7 +227,7 @@ export default defineComponent({
227
227
  emits: ['props-panel-mounted', 'update:modelValue'],
228
228
 
229
229
  setup(props, { emit }) {
230
- editorService.on('root-change', (value, preValue) => {
230
+ const rootChangeHandler = (value: MApp, preValue?: MApp | null) => {
231
231
  const nodeId = editorService.get<MNode | null>('node')?.id || props.defaultSelected;
232
232
  let node;
233
233
  if (nodeId) {
@@ -247,7 +247,9 @@ export default defineComponent({
247
247
  if (toRaw(value) !== toRaw(preValue)) {
248
248
  emit('update:modelValue', value);
249
249
  }
250
- });
250
+ };
251
+
252
+ editorService.on('root-change', rootChangeHandler);
251
253
 
252
254
  // 初始值变化,重新设置节点信息
253
255
  watch(
@@ -326,6 +328,8 @@ export default defineComponent({
326
328
  uiService.resetState();
327
329
  componentListService.resetState();
328
330
  codeBlockService.resetState();
331
+
332
+ editorService.off('root-change', rootChangeHandler);
329
333
  });
330
334
 
331
335
  const services: Services = {
@@ -14,7 +14,7 @@
14
14
  </template>
15
15
 
16
16
  <script lang="ts" setup name="MEditorPropsPanel">
17
- import { computed, getCurrentInstance, inject, onMounted, ref, watchEffect } from 'vue';
17
+ import { computed, getCurrentInstance, inject, onMounted, onUnmounted, ref, watchEffect } from 'vue';
18
18
 
19
19
  import { tMagicMessage } from '@tmagic/design';
20
20
  import type { FormValue } from '@tmagic/form';
@@ -56,6 +56,10 @@ onMounted(() => {
56
56
  emit('mounted', internalInstance);
57
57
  });
58
58
 
59
+ onUnmounted(() => {
60
+ services?.propsService.off('props-configs-change', init);
61
+ });
62
+
59
63
  watchEffect(() => {
60
64
  if (configForm.value && stage.value) {
61
65
  configForm.value.formState.stage = stage.value;
@@ -104,12 +104,6 @@ const filterText = ref('');
104
104
  // 默认展开节点
105
105
  const defaultExpandedKeys = computed(() => (selectedIds.value.length > 0 ? selectedIds.value : []));
106
106
 
107
- editorService?.on('remove', () => {
108
- setTimeout(() => {
109
- tree.value?.getNode(editorService.get('node').id)?.updateChildren();
110
- }, 0);
111
- });
112
-
113
107
  // 触发画布单选
114
108
  const select = async (data: MNode) => {
115
109
  if (!data.id) {
@@ -273,9 +267,17 @@ const mouseleaveHandler = () => {
273
267
  isMultiSelectStatus.value = false;
274
268
  };
275
269
 
270
+ const editorServiceRemoveHandler = () => {
271
+ setTimeout(() => {
272
+ tree.value?.getNode(editorService?.get('node').id)?.updateChildren();
273
+ }, 0);
274
+ };
275
+
276
276
  let keycon: KeyController;
277
277
 
278
278
  onMounted(() => {
279
+ editorService?.on('remove', editorServiceRemoveHandler);
280
+
279
281
  keycon = new KeyController(tree.value?.$el);
280
282
  const isMac = /mac os x/.test(navigator.userAgent.toLowerCase());
281
283
  const ctrl = isMac ? 'meta' : 'ctrl';
@@ -293,6 +295,8 @@ onMounted(() => {
293
295
 
294
296
  onUnmounted(() => {
295
297
  keycon.destroy();
298
+
299
+ editorService?.off('remove', editorServiceRemoveHandler);
296
300
  });
297
301
 
298
302
  // 鼠标是否按下标志,用于高亮状态互斥
@@ -170,8 +170,12 @@ export default class extends EventEmitter {
170
170
  }
171
171
 
172
172
  public removeAllPlugins() {
173
- this.pluginOptionsList = {};
174
- this.middleware = {};
173
+ Object.keys(this.pluginOptionsList).forEach((key) => {
174
+ this.pluginOptionsList[key] = [];
175
+ });
176
+ Object.keys(this.middleware).forEach((key) => {
177
+ this.middleware[key] = [];
178
+ });
175
179
  }
176
180
 
177
181
  private async doTask() {