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

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.21",
2
+ "version": "1.2.0-beta.23",
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.21",
50
- "@tmagic/design": "1.2.0-beta.21",
51
- "@tmagic/form": "1.2.0-beta.21",
52
- "@tmagic/schema": "1.2.0-beta.21",
53
- "@tmagic/stage": "1.2.0-beta.21",
54
- "@tmagic/utils": "1.2.0-beta.21",
49
+ "@tmagic/core": "1.2.0-beta.23",
50
+ "@tmagic/design": "1.2.0-beta.23",
51
+ "@tmagic/form": "1.2.0-beta.23",
52
+ "@tmagic/schema": "1.2.0-beta.23",
53
+ "@tmagic/stage": "1.2.0-beta.23",
54
+ "@tmagic/utils": "1.2.0-beta.23",
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.21",
67
- "@tmagic/form": "1.2.0-beta.21",
66
+ "@tmagic/design": "1.2.0-beta.23",
67
+ "@tmagic/form": "1.2.0-beta.23",
68
68
  "monaco-editor": "^0.34.0",
69
69
  "vue": "^3.2.37"
70
70
  },
package/src/Editor.vue CHANGED
@@ -223,7 +223,7 @@ export default defineComponent({
223
223
  emits: ['props-panel-mounted', 'update:modelValue'],
224
224
 
225
225
  setup(props, { emit }) {
226
- editorService.on('root-change', (value) => {
226
+ editorService.on('root-change', (value, preValue) => {
227
227
  const nodeId = editorService.get<MNode | null>('node')?.id || props.defaultSelected;
228
228
  let node;
229
229
  if (nodeId) {
@@ -240,7 +240,7 @@ export default defineComponent({
240
240
  editorService.set('page', null);
241
241
  }
242
242
 
243
- if (toRaw(value) !== toRaw(editorService.get('root'))) {
243
+ if (toRaw(value) !== toRaw(preValue)) {
244
244
  emit('update:modelValue', value);
245
245
  }
246
246
  });
@@ -95,6 +95,7 @@ class Editor extends BaseService {
95
95
  * @param value MNode
96
96
  */
97
97
  public set<T = MNode>(name: keyof StoreState, value: T) {
98
+ const preValue = this.state[name];
98
99
  this.state[name] = value as any;
99
100
  // set nodes时将node设置为nodes第一个元素
100
101
  if (name === 'nodes') {
@@ -102,7 +103,7 @@ class Editor extends BaseService {
102
103
  }
103
104
  if (name === 'root') {
104
105
  this.state.pageLength = (value as unknown as MApp)?.items?.length || 0;
105
- this.emit('root-change', value);
106
+ this.emit('root-change', value, preValue);
106
107
  }
107
108
  }
108
109