@tmagic/editor 1.3.0-beta.8 → 1.3.0
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/dist/tmagic-editor.js +25 -23
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +25 -23
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/initService.ts +21 -21
- package/src/layouts/workspace/viewer/Stage.vue +10 -7
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0
|
|
2
|
+
"version": "1.3.0",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/core": "^7.18.0",
|
|
49
49
|
"@element-plus/icons-vue": "^2.0.9",
|
|
50
|
-
"@tmagic/core": "1.3.0
|
|
51
|
-
"@tmagic/design": "1.3.0
|
|
52
|
-
"@tmagic/form": "1.3.0
|
|
53
|
-
"@tmagic/schema": "1.3.0
|
|
54
|
-
"@tmagic/stage": "1.3.0
|
|
55
|
-
"@tmagic/table": "1.3.0
|
|
56
|
-
"@tmagic/utils": "1.3.0
|
|
50
|
+
"@tmagic/core": "1.3.0",
|
|
51
|
+
"@tmagic/design": "1.3.0",
|
|
52
|
+
"@tmagic/form": "1.3.0",
|
|
53
|
+
"@tmagic/schema": "1.3.0",
|
|
54
|
+
"@tmagic/stage": "1.3.0",
|
|
55
|
+
"@tmagic/table": "1.3.0",
|
|
56
|
+
"@tmagic/utils": "1.3.0",
|
|
57
57
|
"buffer": "^6.0.3",
|
|
58
58
|
"color": "^3.1.3",
|
|
59
59
|
"events": "^3.3.0",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"vue": "^3.3.4"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@tmagic/design": "1.3.0
|
|
69
|
-
"@tmagic/form": "1.3.0
|
|
68
|
+
"@tmagic/design": "1.3.0",
|
|
69
|
+
"@tmagic/form": "1.3.0",
|
|
70
70
|
"monaco-editor": "^0.41.0",
|
|
71
71
|
"vue": "^3.3.4"
|
|
72
72
|
},
|
package/src/initService.ts
CHANGED
|
@@ -276,26 +276,6 @@ export const initServiceEvents = (
|
|
|
276
276
|
};
|
|
277
277
|
|
|
278
278
|
const rootChangeHandler = async (value: MApp | null, preValue?: MApp | null) => {
|
|
279
|
-
const nodeId = editorService.get('node')?.id || props.defaultSelected;
|
|
280
|
-
let node;
|
|
281
|
-
if (nodeId) {
|
|
282
|
-
node = editorService.getNodeById(nodeId);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (node && node !== value) {
|
|
286
|
-
await editorService.select(node.id);
|
|
287
|
-
} else if (value?.items?.length) {
|
|
288
|
-
await editorService.select(value.items[0]);
|
|
289
|
-
} else if (value?.id) {
|
|
290
|
-
editorService.set('nodes', [value]);
|
|
291
|
-
editorService.set('parent', null);
|
|
292
|
-
editorService.set('page', null);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (toRaw(value) !== toRaw(preValue)) {
|
|
296
|
-
emit('update:modelValue', value);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
279
|
if (!value) return;
|
|
300
280
|
|
|
301
281
|
value.codeBlocks = value.codeBlocks || {};
|
|
@@ -314,12 +294,32 @@ export const initServiceEvents = (
|
|
|
314
294
|
initDataSourceDepTarget(ds);
|
|
315
295
|
});
|
|
316
296
|
|
|
317
|
-
if (
|
|
297
|
+
if (Array.isArray(value.items)) {
|
|
318
298
|
depService.collect(value.items, true);
|
|
319
299
|
} else {
|
|
320
300
|
depService.clear();
|
|
321
301
|
delete value.dataSourceDeps;
|
|
322
302
|
}
|
|
303
|
+
|
|
304
|
+
const nodeId = editorService.get('node')?.id || props.defaultSelected;
|
|
305
|
+
let node;
|
|
306
|
+
if (nodeId) {
|
|
307
|
+
node = editorService.getNodeById(nodeId);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (node && node !== value) {
|
|
311
|
+
await editorService.select(node.id);
|
|
312
|
+
} else if (value.items?.length) {
|
|
313
|
+
await editorService.select(value.items[0]);
|
|
314
|
+
} else if (value.id) {
|
|
315
|
+
editorService.set('nodes', [value]);
|
|
316
|
+
editorService.set('parent', null);
|
|
317
|
+
editorService.set('page', null);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (toRaw(value) !== toRaw(preValue)) {
|
|
321
|
+
emit('update:modelValue', value);
|
|
322
|
+
}
|
|
323
323
|
};
|
|
324
324
|
|
|
325
325
|
// 新增节点,收集依赖
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
import { computed, inject, markRaw, nextTick, onMounted, onUnmounted, ref, toRaw, watch, watchEffect } from 'vue';
|
|
34
34
|
import { cloneDeep } from 'lodash-es';
|
|
35
35
|
|
|
36
|
-
import type { MContainer } from '@tmagic/schema';
|
|
36
|
+
import type { MApp, MContainer } from '@tmagic/schema';
|
|
37
37
|
import StageCore, { calcValueByFontsize, getOffset, Runtime } from '@tmagic/stage';
|
|
38
38
|
|
|
39
39
|
import ScrollViewer from '@editor/components/ScrollViewer.vue';
|
|
@@ -105,12 +105,6 @@ watch(zoom, (zoom) => {
|
|
|
105
105
|
stage.setZoom(zoom);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
watch(root, (root) => {
|
|
109
|
-
if (runtime && root) {
|
|
110
|
-
runtime.updateRootConfig?.(cloneDeep(toRaw(root)));
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
108
|
watch(page, (page) => {
|
|
115
109
|
if (runtime && page) {
|
|
116
110
|
runtime.updatePageId?.(page.id);
|
|
@@ -120,6 +114,14 @@ watch(page, (page) => {
|
|
|
120
114
|
}
|
|
121
115
|
});
|
|
122
116
|
|
|
117
|
+
const rootChangeHandler = (root: MApp) => {
|
|
118
|
+
if (runtime && root) {
|
|
119
|
+
runtime.updateRootConfig?.(cloneDeep(toRaw(root)));
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
services?.editorService.on('root-change', rootChangeHandler);
|
|
124
|
+
|
|
123
125
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
124
126
|
for (const { contentRect } of entries) {
|
|
125
127
|
services?.uiService.set('stageContainerRect', {
|
|
@@ -141,6 +143,7 @@ onUnmounted(() => {
|
|
|
141
143
|
resizeObserver.disconnect();
|
|
142
144
|
services?.editorService.set('stage', null);
|
|
143
145
|
services?.keybindingService.unregisteEl('stage');
|
|
146
|
+
services?.editorService.off('root-change', rootChangeHandler);
|
|
144
147
|
});
|
|
145
148
|
|
|
146
149
|
const parseDSL = getConfig('parseDSL');
|