@tmagic/editor 1.0.0-rc.2 → 1.0.0-rc.5
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/coverage/clover.xml +485 -448
- package/coverage/coverage-final.json +9 -9
- package/coverage/lcov-report/index.html +39 -39
- package/coverage/lcov-report/src/Editor.vue.html +14 -2
- package/coverage/lcov-report/src/components/ContentMenu.vue.html +12 -12
- package/coverage/lcov-report/src/components/Icon.vue.html +2 -2
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
- package/coverage/lcov-report/src/components/ToolButton.vue.html +25 -25
- package/coverage/lcov-report/src/components/index.html +5 -5
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Framework.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/index.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +17 -17
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +2 -2
- package/coverage/lcov-report/src/layouts/sidebar/index.html +19 -19
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +8 -2
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +69 -33
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +85 -34
- package/coverage/lcov-report/src/layouts/workspace/index.html +28 -28
- package/coverage/lcov-report/src/services/BaseService.ts.html +2 -2
- package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
- package/coverage/lcov-report/src/services/editor.ts.html +100 -10
- package/coverage/lcov-report/src/services/events.ts.html +1 -1
- package/coverage/lcov-report/src/services/history.ts.html +1 -1
- package/coverage/lcov-report/src/services/index.html +15 -15
- package/coverage/lcov-report/src/services/props.ts.html +1 -1
- package/coverage/lcov-report/src/services/ui.ts.html +1 -1
- package/coverage/lcov-report/src/type.ts.html +1 -1
- package/coverage/lcov-report/src/utils/compose.ts.html +1 -1
- package/coverage/lcov-report/src/utils/config.ts.html +1 -1
- package/coverage/lcov-report/src/utils/editor.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
- package/coverage/lcov-report/src/utils/props.ts.html +1 -1
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
- package/coverage/lcov.info +1156 -1057
- package/dist/tmagic-editor.es.js +90 -38
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +89 -37
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +5 -0
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +5 -1
- package/dist/types/src/services/BaseService.d.ts +1 -1
- package/package.json +7 -7
- package/src/Editor.vue +4 -0
- package/src/components/ContentMenu.vue +3 -3
- package/src/layouts/sidebar/TabPane.vue +1 -1
- package/src/layouts/workspace/Stage.vue +2 -0
- package/src/layouts/workspace/ViewerMenu.vue +14 -2
- package/src/layouts/workspace/Workspace.vue +40 -23
- package/src/services/BaseService.ts +1 -1
- package/src/services/editor.ts +31 -1
- package/src/utils/editor.ts +6 -2
|
@@ -34,6 +34,8 @@ declare const _default: DefineComponent<{
|
|
|
34
34
|
};
|
|
35
35
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
36
36
|
runtimeUrl: StringConstructor;
|
|
37
|
+
/** 选中时是否自动滚动到可视区域 */
|
|
38
|
+
autoScrollIntoView: BooleanConstructor;
|
|
37
39
|
/** 组件的属性配置表单的dsl */
|
|
38
40
|
propsConfigs: {
|
|
39
41
|
type: PropType<Record<string, FormConfig>>;
|
|
@@ -97,6 +99,8 @@ declare const _default: DefineComponent<{
|
|
|
97
99
|
};
|
|
98
100
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
99
101
|
runtimeUrl: StringConstructor;
|
|
102
|
+
/** 选中时是否自动滚动到可视区域 */
|
|
103
|
+
autoScrollIntoView: BooleanConstructor;
|
|
100
104
|
/** 组件的属性配置表单的dsl */
|
|
101
105
|
propsConfigs: {
|
|
102
106
|
type: PropType<Record<string, FormConfig>>;
|
|
@@ -135,6 +139,7 @@ declare const _default: DefineComponent<{
|
|
|
135
139
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
136
140
|
}, {
|
|
137
141
|
menu: MenuBarData;
|
|
142
|
+
autoScrollIntoView: boolean;
|
|
138
143
|
codeOptions: Record<string, any>;
|
|
139
144
|
modelValue: MApp;
|
|
140
145
|
componentGroupList: ComponentGroup[];
|
|
@@ -4,6 +4,7 @@ import type { MoveableOptions } from '@tmagic/stage';
|
|
|
4
4
|
import StageCore from '@tmagic/stage';
|
|
5
5
|
declare const _default: DefineComponent<{
|
|
6
6
|
runtimeUrl: StringConstructor;
|
|
7
|
+
autoScrollIntoView: BooleanConstructor;
|
|
7
8
|
render: {
|
|
8
9
|
type: PropType<() => HTMLDivElement>;
|
|
9
10
|
};
|
|
@@ -18,6 +19,7 @@ declare const _default: DefineComponent<{
|
|
|
18
19
|
page: ComputedRef<MPage | undefined>;
|
|
19
20
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
20
21
|
runtimeUrl: StringConstructor;
|
|
22
|
+
autoScrollIntoView: BooleanConstructor;
|
|
21
23
|
render: {
|
|
22
24
|
type: PropType<() => HTMLDivElement>;
|
|
23
25
|
};
|
|
@@ -27,5 +29,7 @@ declare const _default: DefineComponent<{
|
|
|
27
29
|
canSelect: {
|
|
28
30
|
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
29
31
|
};
|
|
30
|
-
}>>, {
|
|
32
|
+
}>>, {
|
|
33
|
+
autoScrollIntoView: boolean;
|
|
34
|
+
}>;
|
|
31
35
|
export default _default;
|
|
@@ -27,7 +27,7 @@ import { EventEmitter } from 'events';
|
|
|
27
27
|
* editorService.afterAdd();
|
|
28
28
|
* }
|
|
29
29
|
*
|
|
30
|
-
* 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after
|
|
30
|
+
* 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after第一个参数则是原方法的return值;
|
|
31
31
|
* 如需终止后续方法调用可以return new Error();
|
|
32
32
|
*
|
|
33
33
|
* 方法2:
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-rc.
|
|
2
|
+
"version": "1.0.0-rc.5",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/core": "^7.18.0",
|
|
47
47
|
"@element-plus/icons": "0.0.11",
|
|
48
|
-
"@tmagic/core": "^1.0.0-rc.
|
|
49
|
-
"@tmagic/form": "^1.0.0-rc.
|
|
50
|
-
"@tmagic/schema": "^1.0.0-rc.
|
|
51
|
-
"@tmagic/stage": "^1.0.0-rc.
|
|
52
|
-
"@tmagic/utils": "^1.0.0-rc.
|
|
48
|
+
"@tmagic/core": "^1.0.0-rc.5",
|
|
49
|
+
"@tmagic/form": "^1.0.0-rc.5",
|
|
50
|
+
"@tmagic/schema": "^1.0.0-rc.5",
|
|
51
|
+
"@tmagic/stage": "^1.0.0-rc.5",
|
|
52
|
+
"@tmagic/utils": "^1.0.0-rc.5",
|
|
53
53
|
"buffer": "^6.0.3",
|
|
54
54
|
"color": "^3.1.3",
|
|
55
55
|
"element-plus": "^2.2.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"vite-plugin-dts": "^0.9.6",
|
|
89
89
|
"vue-tsc": "^0.0.24"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "d147b361d7e6123cda99c6ba68a2ac7e074be37f"
|
|
92
92
|
}
|
package/src/Editor.vue
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<slot name="workspace">
|
|
15
15
|
<workspace
|
|
16
16
|
:runtime-url="runtimeUrl"
|
|
17
|
+
:auto-scroll-into-view="autoScrollIntoView"
|
|
17
18
|
:render="render"
|
|
18
19
|
:moveable-options="moveableOptions"
|
|
19
20
|
:can-select="canSelect"
|
|
@@ -101,6 +102,9 @@ export default defineComponent({
|
|
|
101
102
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
102
103
|
runtimeUrl: String,
|
|
103
104
|
|
|
105
|
+
/** 选中时是否自动滚动到可视区域 */
|
|
106
|
+
autoScrollIntoView: Boolean,
|
|
107
|
+
|
|
104
108
|
/** 组件的属性配置表单的dsl */
|
|
105
109
|
propsConfigs: {
|
|
106
110
|
type: Object as PropType<Record<string, FormConfig>>,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div v-if="menuData.length
|
|
2
|
+
<div v-if="menuData.length && visible" class="magic-editor-content-menu" ref="menu" :style="menuStyle">
|
|
3
3
|
<div>
|
|
4
4
|
<tool-button
|
|
5
5
|
v-for="(item, index) in menuData"
|
|
@@ -49,7 +49,7 @@ export default defineComponent({
|
|
|
49
49
|
|
|
50
50
|
onMounted(() => {
|
|
51
51
|
globalThis.addEventListener(
|
|
52
|
-
'
|
|
52
|
+
'mouseup',
|
|
53
53
|
(e: MouseEvent) => {
|
|
54
54
|
if (!visible.value || (e.target && menu.value?.contains(e.target as HTMLElement))) {
|
|
55
55
|
return;
|
|
@@ -82,7 +82,7 @@ export default defineComponent({
|
|
|
82
82
|
|
|
83
83
|
menuStyle.value = {
|
|
84
84
|
top: `${top}px`,
|
|
85
|
-
left: `${e.clientX}px`,
|
|
85
|
+
left: `${e.clientX + 2}px`,
|
|
86
86
|
};
|
|
87
87
|
});
|
|
88
88
|
},
|
|
@@ -59,6 +59,7 @@ export default defineComponent({
|
|
|
59
59
|
},
|
|
60
60
|
|
|
61
61
|
runtimeUrl: String,
|
|
62
|
+
autoScrollIntoView: Boolean,
|
|
62
63
|
|
|
63
64
|
canSelect: {
|
|
64
65
|
type: Function as PropType<(el: HTMLElement) => boolean | Promise<boolean>>,
|
|
@@ -100,6 +101,7 @@ export default defineComponent({
|
|
|
100
101
|
render: props.render,
|
|
101
102
|
runtimeUrl: props.runtimeUrl,
|
|
102
103
|
zoom: zoom.value,
|
|
104
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
103
105
|
canSelect: (el, event, stop) => {
|
|
104
106
|
const elCanSelect = props.canSelect(el);
|
|
105
107
|
// 在组件联动过程中不能再往下选择,返回并触发 ui-select
|
|
@@ -69,8 +69,20 @@ export default defineComponent({
|
|
|
69
69
|
text: '粘贴',
|
|
70
70
|
display: () => canPaste.value,
|
|
71
71
|
handler: () => {
|
|
72
|
-
const
|
|
73
|
-
|
|
72
|
+
const stage = editorService?.get<StageCore>('stage');
|
|
73
|
+
|
|
74
|
+
const rect = menu.value?.$el.getBoundingClientRect();
|
|
75
|
+
const parentRect = stage?.container?.getBoundingClientRect();
|
|
76
|
+
let left = (rect?.left || 0) - (parentRect?.left || 0);
|
|
77
|
+
let top = (rect?.top || 0) - (parentRect?.top || 0);
|
|
78
|
+
|
|
79
|
+
if (node.value?.items && stage) {
|
|
80
|
+
const parentEl = stage.renderer.contentWindow?.document.getElementById(`${node.value.id}`);
|
|
81
|
+
const parentElRect = parentEl?.getBoundingClientRect();
|
|
82
|
+
left = left - (parentElRect?.left || 0);
|
|
83
|
+
top = top - (parentElRect?.top || 0);
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
editorService?.paste({ left, top });
|
|
75
87
|
},
|
|
76
88
|
},
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
<magic-stage
|
|
4
4
|
:key="page?.id"
|
|
5
5
|
:runtime-url="runtimeUrl"
|
|
6
|
+
:auto-scroll-into-view="autoScrollIntoView"
|
|
6
7
|
:render="render"
|
|
7
8
|
:moveable-options="moveableOptions"
|
|
8
9
|
:can-select="canSelect"
|
|
@@ -41,6 +42,7 @@ export default defineComponent({
|
|
|
41
42
|
|
|
42
43
|
props: {
|
|
43
44
|
runtimeUrl: String,
|
|
45
|
+
autoScrollIntoView: Boolean,
|
|
44
46
|
|
|
45
47
|
render: {
|
|
46
48
|
type: Function as PropType<() => HTMLDivElement>,
|
|
@@ -80,10 +82,6 @@ export default defineComponent({
|
|
|
80
82
|
const ctrl = isMac ? 'meta' : 'ctrl';
|
|
81
83
|
|
|
82
84
|
keycon
|
|
83
|
-
.keydown((e) => {
|
|
84
|
-
console.log(e);
|
|
85
|
-
e.inputEvent.preventDefault();
|
|
86
|
-
})
|
|
87
85
|
.keyup('delete', (e) => {
|
|
88
86
|
e.inputEvent.preventDefault();
|
|
89
87
|
if (!node.value || isPage(node.value)) return;
|
|
@@ -94,63 +92,82 @@ export default defineComponent({
|
|
|
94
92
|
if (!node.value || isPage(node.value)) return;
|
|
95
93
|
services?.editorService.remove(node.value);
|
|
96
94
|
})
|
|
97
|
-
.keydown([ctrl, 'c'], () => {
|
|
95
|
+
.keydown([ctrl, 'c'], (e) => {
|
|
96
|
+
e.inputEvent.preventDefault();
|
|
98
97
|
node.value && services?.editorService.copy(node.value);
|
|
99
98
|
})
|
|
100
|
-
.keydown([ctrl, 'v'], () => {
|
|
99
|
+
.keydown([ctrl, 'v'], (e) => {
|
|
100
|
+
e.inputEvent.preventDefault();
|
|
101
101
|
node.value && services?.editorService.paste();
|
|
102
102
|
})
|
|
103
|
-
.keydown([ctrl, 'x'], () => {
|
|
103
|
+
.keydown([ctrl, 'x'], (e) => {
|
|
104
|
+
e.inputEvent.preventDefault();
|
|
104
105
|
if (!node.value || isPage(node.value)) return;
|
|
105
106
|
services?.editorService.copy(node.value);
|
|
106
107
|
services?.editorService.remove(node.value);
|
|
107
108
|
})
|
|
108
|
-
.keydown([ctrl, 'z'], () => {
|
|
109
|
+
.keydown([ctrl, 'z'], (e) => {
|
|
110
|
+
e.inputEvent.preventDefault();
|
|
109
111
|
services?.editorService.undo();
|
|
110
112
|
})
|
|
111
|
-
.keydown([ctrl, 'shift', 'z'], () => {
|
|
113
|
+
.keydown([ctrl, 'shift', 'z'], (e) => {
|
|
114
|
+
e.inputEvent.preventDefault();
|
|
112
115
|
services?.editorService.redo();
|
|
113
116
|
})
|
|
114
|
-
.keydown('up', () => {
|
|
117
|
+
.keydown('up', (e) => {
|
|
118
|
+
e.inputEvent.preventDefault();
|
|
115
119
|
services?.editorService.move(0, -1);
|
|
116
120
|
})
|
|
117
|
-
.keydown('down', () => {
|
|
121
|
+
.keydown('down', (e) => {
|
|
122
|
+
e.inputEvent.preventDefault();
|
|
118
123
|
services?.editorService.move(0, 1);
|
|
119
124
|
})
|
|
120
|
-
.keydown('left', () => {
|
|
125
|
+
.keydown('left', (e) => {
|
|
126
|
+
e.inputEvent.preventDefault();
|
|
121
127
|
services?.editorService.move(-1, 0);
|
|
122
128
|
})
|
|
123
|
-
.keydown('right', () => {
|
|
129
|
+
.keydown('right', (e) => {
|
|
130
|
+
e.inputEvent.preventDefault();
|
|
124
131
|
services?.editorService.move(1, 0);
|
|
125
132
|
})
|
|
126
|
-
.keydown([ctrl, 'up'], () => {
|
|
133
|
+
.keydown([ctrl, 'up'], (e) => {
|
|
134
|
+
e.inputEvent.preventDefault();
|
|
127
135
|
services?.editorService.move(0, -10);
|
|
128
136
|
})
|
|
129
|
-
.keydown([ctrl, 'down'], () => {
|
|
137
|
+
.keydown([ctrl, 'down'], (e) => {
|
|
138
|
+
e.inputEvent.preventDefault();
|
|
130
139
|
services?.editorService.move(0, 10);
|
|
131
140
|
})
|
|
132
|
-
.keydown([ctrl, 'left'], () => {
|
|
141
|
+
.keydown([ctrl, 'left'], (e) => {
|
|
142
|
+
e.inputEvent.preventDefault();
|
|
133
143
|
services?.editorService.move(-10, 0);
|
|
134
144
|
})
|
|
135
|
-
.keydown([ctrl, 'right'], () => {
|
|
145
|
+
.keydown([ctrl, 'right'], (e) => {
|
|
146
|
+
e.inputEvent.preventDefault();
|
|
136
147
|
services?.editorService.move(10, 0);
|
|
137
148
|
})
|
|
138
|
-
.keydown('tab', () => {
|
|
149
|
+
.keydown('tab', (e) => {
|
|
150
|
+
e.inputEvent.preventDefault();
|
|
139
151
|
services?.editorService.selectNextNode();
|
|
140
152
|
})
|
|
141
|
-
.keydown([ctrl, 'tab'], () => {
|
|
153
|
+
.keydown([ctrl, 'tab'], (e) => {
|
|
154
|
+
e.inputEvent.preventDefault();
|
|
142
155
|
services?.editorService.selectNextPage();
|
|
143
156
|
})
|
|
144
|
-
.keydown([ctrl, '='], () => {
|
|
157
|
+
.keydown([ctrl, '='], (e) => {
|
|
158
|
+
e.inputEvent.preventDefault();
|
|
145
159
|
services?.uiService.zoom(0.1);
|
|
146
160
|
})
|
|
147
|
-
.keydown([ctrl, 'numpadplus'], () => {
|
|
161
|
+
.keydown([ctrl, 'numpadplus'], (e) => {
|
|
162
|
+
e.inputEvent.preventDefault();
|
|
148
163
|
services?.uiService.zoom(0.1);
|
|
149
164
|
})
|
|
150
|
-
.keydown([ctrl, '-'], () => {
|
|
165
|
+
.keydown([ctrl, '-'], (e) => {
|
|
166
|
+
e.inputEvent.preventDefault();
|
|
151
167
|
services?.uiService.zoom(-0.1);
|
|
152
168
|
})
|
|
153
|
-
.keydown([ctrl, 'numpad-'], () => {
|
|
169
|
+
.keydown([ctrl, 'numpad-'], (e) => {
|
|
170
|
+
e.inputEvent.preventDefault();
|
|
154
171
|
services?.uiService.zoom(-0.1);
|
|
155
172
|
});
|
|
156
173
|
});
|
|
@@ -91,7 +91,7 @@ const doAction = async (
|
|
|
91
91
|
* editorService.afterAdd();
|
|
92
92
|
* }
|
|
93
93
|
*
|
|
94
|
-
* 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after
|
|
94
|
+
* 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after第一个参数则是原方法的return值;
|
|
95
95
|
* 如需终止后续方法调用可以return new Error();
|
|
96
96
|
*
|
|
97
97
|
* 方法2:
|
package/src/services/editor.ts
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
change2Fixed,
|
|
34
34
|
COPY_STORAGE_KEY,
|
|
35
35
|
Fixed2Other,
|
|
36
|
+
generatePageNameByApp,
|
|
36
37
|
getNodeIndex,
|
|
37
38
|
initPosition,
|
|
38
39
|
isFixed,
|
|
@@ -194,6 +195,20 @@ class Editor extends BaseService {
|
|
|
194
195
|
historyService.empty();
|
|
195
196
|
}
|
|
196
197
|
|
|
198
|
+
if (node?.id) {
|
|
199
|
+
this.get<StageCore>('stage')
|
|
200
|
+
?.renderer.runtime?.getApp?.()
|
|
201
|
+
?.emit(
|
|
202
|
+
'editor:select',
|
|
203
|
+
{
|
|
204
|
+
node,
|
|
205
|
+
page,
|
|
206
|
+
parent,
|
|
207
|
+
},
|
|
208
|
+
getNodePath(node.id, this.get<MApp>('root').items),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
197
212
|
this.emit('select', node);
|
|
198
213
|
|
|
199
214
|
return node!;
|
|
@@ -488,6 +503,10 @@ class Editor extends BaseService {
|
|
|
488
503
|
};
|
|
489
504
|
}
|
|
490
505
|
|
|
506
|
+
if (isPage(config)) {
|
|
507
|
+
config.name = generatePageNameByApp(this.get('root'));
|
|
508
|
+
}
|
|
509
|
+
|
|
491
510
|
return await this.add(config);
|
|
492
511
|
}
|
|
493
512
|
|
|
@@ -504,7 +523,18 @@ class Editor extends BaseService {
|
|
|
504
523
|
return;
|
|
505
524
|
}
|
|
506
525
|
|
|
507
|
-
if (
|
|
526
|
+
if (!node.style) return;
|
|
527
|
+
|
|
528
|
+
const stage = this.get<StageCore>('stage');
|
|
529
|
+
const doc = stage?.renderer.contentWindow?.document;
|
|
530
|
+
|
|
531
|
+
if (doc) {
|
|
532
|
+
const parentEl = doc.getElementById(`${parent.id}`);
|
|
533
|
+
const el = doc.getElementById(`${node.id}`);
|
|
534
|
+
if (parentEl && el) {
|
|
535
|
+
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
536
|
+
}
|
|
537
|
+
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
508
538
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
509
539
|
}
|
|
510
540
|
|
package/src/utils/editor.ts
CHANGED
|
@@ -142,9 +142,13 @@ export const toRelative = (node: MNode) => {
|
|
|
142
142
|
|
|
143
143
|
const setTop2Middle = (node: MNode, parentNode: MNode, stage: StageCore) => {
|
|
144
144
|
const style = node.style || {};
|
|
145
|
-
|
|
145
|
+
let height = style.height || 0;
|
|
146
146
|
|
|
147
|
-
if (!stage || typeof style.top !== 'undefined' || !parentNode.style
|
|
147
|
+
if (!stage || typeof style.top !== 'undefined' || !parentNode.style) return style;
|
|
148
|
+
|
|
149
|
+
if (!isNumber(height)) {
|
|
150
|
+
height = 0;
|
|
151
|
+
}
|
|
148
152
|
|
|
149
153
|
const { height: parentHeight } = parentNode.style;
|
|
150
154
|
|