@tmagic/editor 1.2.0-beta.19 → 1.2.0-beta.20
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.mjs +28 -9
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +31 -8
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/Editor.vue +16 -6
- package/src/layouts/workspace/Stage.vue +1 -1
- package/src/services/editor.ts +4 -1
- package/src/utils/index.ts +1 -0
- package/types/utils/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.0-beta.
|
|
2
|
+
"version": "1.2.0-beta.20",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/core": "^7.18.0",
|
|
47
47
|
"@element-plus/icons-vue": "^2.0.9",
|
|
48
|
-
"@tmagic/core": "1.2.0-beta.
|
|
49
|
-
"@tmagic/design": "1.2.0-beta.
|
|
50
|
-
"@tmagic/form": "1.2.0-beta.
|
|
51
|
-
"@tmagic/schema": "1.2.0-beta.
|
|
52
|
-
"@tmagic/stage": "1.2.0-beta.
|
|
53
|
-
"@tmagic/utils": "1.2.0-beta.
|
|
48
|
+
"@tmagic/core": "1.2.0-beta.20",
|
|
49
|
+
"@tmagic/design": "1.2.0-beta.20",
|
|
50
|
+
"@tmagic/form": "1.2.0-beta.20",
|
|
51
|
+
"@tmagic/schema": "1.2.0-beta.20",
|
|
52
|
+
"@tmagic/stage": "1.2.0-beta.20",
|
|
53
|
+
"@tmagic/utils": "1.2.0-beta.20",
|
|
54
54
|
"buffer": "^6.0.3",
|
|
55
55
|
"color": "^3.1.3",
|
|
56
56
|
"events": "^3.3.0",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"vue": "^3.2.37"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@tmagic/design": "1.2.0-beta.
|
|
66
|
-
"@tmagic/form": "1.2.0-beta.
|
|
65
|
+
"@tmagic/design": "1.2.0-beta.20",
|
|
66
|
+
"@tmagic/form": "1.2.0-beta.20",
|
|
67
67
|
"monaco-editor": "^0.34.0",
|
|
68
68
|
"vue": "^3.2.37"
|
|
69
69
|
},
|
package/src/Editor.vue
CHANGED
|
@@ -224,15 +224,25 @@ export default defineComponent({
|
|
|
224
224
|
|
|
225
225
|
setup(props, { emit }) {
|
|
226
226
|
editorService.on('root-change', (value) => {
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
if (nodeId
|
|
230
|
-
editorService.
|
|
231
|
-
}
|
|
227
|
+
const nodeId = editorService.get<MNode | null>('node')?.id || props.defaultSelected;
|
|
228
|
+
let node;
|
|
229
|
+
if (nodeId) {
|
|
230
|
+
node = editorService.getNodeById(nodeId);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (node && node !== value) {
|
|
234
|
+
editorService.select(node.id);
|
|
235
|
+
} else if (value?.items?.length) {
|
|
236
|
+
editorService.select(value.items[0]);
|
|
237
|
+
} else if (value?.id) {
|
|
232
238
|
editorService.set('nodes', [value]);
|
|
239
|
+
editorService.set('parent', null);
|
|
240
|
+
editorService.set('page', null);
|
|
233
241
|
}
|
|
234
242
|
|
|
235
|
-
|
|
243
|
+
if (toRaw(value) !== toRaw(editorService.get('root'))) {
|
|
244
|
+
emit('update:modelValue', value);
|
|
245
|
+
}
|
|
236
246
|
});
|
|
237
247
|
|
|
238
248
|
// 初始值变化,重新设置节点信息
|
|
@@ -62,7 +62,7 @@ const zoom = computed(() => services?.uiService.get<number>('zoom') || 1);
|
|
|
62
62
|
const node = computed(() => services?.editorService.get<MNode>('node'));
|
|
63
63
|
|
|
64
64
|
watchEffect(() => {
|
|
65
|
-
if (stage) return;
|
|
65
|
+
if (stage || !page.value) return;
|
|
66
66
|
|
|
67
67
|
if (!stageContainer.value) return;
|
|
68
68
|
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value) return;
|
package/src/services/editor.ts
CHANGED
|
@@ -352,6 +352,9 @@ class Editor extends BaseService {
|
|
|
352
352
|
|
|
353
353
|
const newNodes = await Promise.all(
|
|
354
354
|
addNodes.map((node) => {
|
|
355
|
+
if (isPage(node)) {
|
|
356
|
+
return this.doAdd(node, this.get('root'));
|
|
357
|
+
}
|
|
355
358
|
const parentNode = parent && typeof parent !== 'function' ? parent : getAddParent(node);
|
|
356
359
|
if (!parentNode) throw new Error('未找到父元素');
|
|
357
360
|
return this.doAdd(node, parentNode);
|
|
@@ -579,7 +582,7 @@ class Editor extends BaseService {
|
|
|
579
582
|
|
|
580
583
|
const pasteConfigs = await this.doPaste(config, position);
|
|
581
584
|
|
|
582
|
-
return this.add(pasteConfigs);
|
|
585
|
+
return this.add(pasteConfigs, this.get('parent'));
|
|
583
586
|
}
|
|
584
587
|
|
|
585
588
|
public async doPaste(config: MNode[], position: PastePosition = {}): Promise<MNode[]> {
|
package/src/utils/index.ts
CHANGED
package/types/utils/index.d.ts
CHANGED