@tmagic/editor 1.0.0-beta.9 → 1.0.0-rc.3
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/README.md +1 -0
- package/coverage/clover.xml +1556 -0
- package/coverage/coverage-final.json +36 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +206 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Editor.vue.html +814 -0
- package/coverage/lcov-report/src/components/ContentMenu.vue.html +406 -0
- package/coverage/lcov-report/src/components/Icon.vue.html +172 -0
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +283 -0
- package/coverage/lcov-report/src/components/ToolButton.vue.html +772 -0
- package/coverage/lcov-report/src/components/index.html +161 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +214 -0
- package/coverage/lcov-report/src/layouts/Framework.vue.html +343 -0
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +208 -0
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +319 -0
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +268 -0
- package/coverage/lcov-report/src/layouts/index.html +176 -0
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +358 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +421 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +775 -0
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +226 -0
- package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +289 -0
- package/coverage/lcov-report/src/layouts/sidebar/index.html +176 -0
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +718 -0
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +766 -0
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +532 -0
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +604 -0
- package/coverage/lcov-report/src/layouts/workspace/index.html +161 -0
- package/coverage/lcov-report/src/services/BaseService.ts.html +643 -0
- package/coverage/lcov-report/src/services/componentList.ts.html +229 -0
- package/coverage/lcov-report/src/services/editor.ts.html +2077 -0
- package/coverage/lcov-report/src/services/events.ts.html +331 -0
- package/coverage/lcov-report/src/services/history.ts.html +478 -0
- package/coverage/lcov-report/src/services/index.html +206 -0
- package/coverage/lcov-report/src/services/props.ts.html +415 -0
- package/coverage/lcov-report/src/services/ui.ts.html +580 -0
- package/coverage/lcov-report/src/type.ts.html +850 -0
- package/coverage/lcov-report/src/utils/compose.ts.html +184 -0
- package/coverage/lcov-report/src/utils/config.ts.html +172 -0
- package/coverage/lcov-report/src/utils/editor.ts.html +838 -0
- package/coverage/lcov-report/src/utils/index.html +221 -0
- package/coverage/lcov-report/src/utils/index.ts.html +151 -0
- package/coverage/lcov-report/src/utils/logger.ts.html +226 -0
- package/coverage/lcov-report/src/utils/props.ts.html +796 -0
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +733 -0
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +313 -0
- package/coverage/lcov.info +3747 -0
- package/dist/style.css +68 -36
- package/dist/tmagic-editor.es.js +1431 -2048
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +1431 -2048
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +15 -1
- package/dist/types/src/components/ToolButton.vue.d.ts +12 -1
- package/dist/types/src/fields/UISelect.vue.d.ts +4 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/layouts/CodeEditor.vue.d.ts +13 -4
- package/dist/types/src/layouts/Framework.vue.d.ts +15 -3
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +2 -1
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +2 -1
- package/dist/types/src/layouts/sidebar/Sidebar.vue.d.ts +2 -3
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +10 -3
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +9 -8
- package/dist/types/src/services/BaseService.d.ts +4 -1
- package/dist/types/src/services/editor.d.ts +5 -2
- package/dist/types/src/services/history.d.ts +1 -0
- package/dist/types/src/services/props.d.ts +2 -2
- package/dist/types/src/services/ui.d.ts +2 -0
- package/dist/types/src/type.d.ts +15 -9
- package/dist/types/src/utils/editor.d.ts +4 -3
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +44 -12
- package/src/Editor.vue +10 -1
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +69 -30
- package/src/fields/UISelect.vue +14 -6
- package/src/index.ts +2 -0
- package/src/layouts/CodeEditor.vue +20 -13
- package/src/layouts/Framework.vue +20 -7
- package/src/layouts/PropsPanel.vue +5 -4
- package/src/layouts/sidebar/ComponentListPanel.vue +25 -3
- package/src/layouts/sidebar/LayerMenu.vue +91 -96
- package/src/layouts/sidebar/LayerPanel.vue +31 -54
- package/src/layouts/sidebar/Sidebar.vue +13 -52
- package/src/layouts/sidebar/TabPane.vue +68 -0
- package/src/layouts/workspace/PageBar.vue +136 -13
- package/src/layouts/workspace/Stage.vue +53 -75
- package/src/layouts/workspace/ViewerMenu.vue +104 -67
- package/src/layouts/workspace/Workspace.vue +111 -22
- package/src/services/BaseService.ts +70 -22
- package/src/services/editor.ts +148 -39
- package/src/services/history.ts +7 -0
- package/src/services/props.ts +3 -3
- package/src/services/ui.ts +35 -5
- package/src/theme/common/var.scss +1 -0
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +2 -1
- package/src/theme/nav-menu.scss +6 -2
- package/src/theme/page-bar.scss +35 -3
- package/src/theme/props-panel.scss +19 -17
- package/src/type.ts +16 -9
- package/src/utils/editor.ts +31 -6
- package/src/utils/polyfills.ts +8 -0
- package/src/utils/props.ts +20 -1
- package/dist/types/src/layouts/sidebar/LayerMenu.vue.d.ts +0 -31
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -979
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -193
- package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
- package/tsconfig.json +0 -9
- package/vite.config.ts +0 -30
package/src/services/ui.ts
CHANGED
|
@@ -25,6 +25,17 @@ import type { GetColumnWidth, SetColumnWidth, StageRect, UiState } from '@editor
|
|
|
25
25
|
|
|
26
26
|
import BaseService from './BaseService';
|
|
27
27
|
|
|
28
|
+
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
29
|
+
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
30
|
+
|
|
31
|
+
const COLUMN_WIDTH_STORAGE_KEY = '$MagicEditorColumnWidthData';
|
|
32
|
+
|
|
33
|
+
const defaultColumnWidth = {
|
|
34
|
+
left: DEFAULT_LEFT_COLUMN_WIDTH,
|
|
35
|
+
center: globalThis.document.body.clientWidth - DEFAULT_LEFT_COLUMN_WIDTH - DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
36
|
+
right: DEFAULT_RIGHT_COLUMN_WIDTH,
|
|
37
|
+
};
|
|
38
|
+
|
|
28
39
|
const state = reactive<UiState>({
|
|
29
40
|
uiSelectMode: false,
|
|
30
41
|
showSrc: false,
|
|
@@ -37,13 +48,10 @@ const state = reactive<UiState>({
|
|
|
37
48
|
width: 375,
|
|
38
49
|
height: 817,
|
|
39
50
|
},
|
|
40
|
-
columnWidth:
|
|
41
|
-
left: 310,
|
|
42
|
-
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
43
|
-
right: 400,
|
|
44
|
-
},
|
|
51
|
+
columnWidth: defaultColumnWidth,
|
|
45
52
|
showGuides: true,
|
|
46
53
|
showRule: true,
|
|
54
|
+
propsPanelSize: 'small',
|
|
47
55
|
});
|
|
48
56
|
|
|
49
57
|
class Ui extends BaseService {
|
|
@@ -54,6 +62,16 @@ class Ui extends BaseService {
|
|
|
54
62
|
center: 'auto',
|
|
55
63
|
});
|
|
56
64
|
});
|
|
65
|
+
|
|
66
|
+
const columnWidthCacheData = globalThis.localStorage.getItem(COLUMN_WIDTH_STORAGE_KEY);
|
|
67
|
+
if (columnWidthCacheData) {
|
|
68
|
+
try {
|
|
69
|
+
const columnWidthCache = JSON.parse(columnWidthCacheData);
|
|
70
|
+
this.setColumnWidth(columnWidthCache);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.error(e);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
57
75
|
}
|
|
58
76
|
|
|
59
77
|
public set<T = any>(name: keyof UiState, value: T) {
|
|
@@ -88,6 +106,11 @@ class Ui extends BaseService {
|
|
|
88
106
|
return (state as any)[name];
|
|
89
107
|
}
|
|
90
108
|
|
|
109
|
+
public zoom(zoom: number) {
|
|
110
|
+
this.set('zoom', (this.get<number>('zoom') * 100 + zoom * 100) / 100);
|
|
111
|
+
if (this.get<number>('zoom') < 0.1) this.set('zoom', 0.1);
|
|
112
|
+
}
|
|
113
|
+
|
|
91
114
|
private setColumnWidth({ left, center, right }: SetColumnWidth) {
|
|
92
115
|
const columnWidth = {
|
|
93
116
|
...toRaw(this.get<GetColumnWidth>('columnWidth')),
|
|
@@ -104,10 +127,17 @@ class Ui extends BaseService {
|
|
|
104
127
|
if (!center || center === 'auto') {
|
|
105
128
|
const bodyWidth = globalThis.document.body.clientWidth;
|
|
106
129
|
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
130
|
+
if (columnWidth.center <= 0) {
|
|
131
|
+
columnWidth.left = defaultColumnWidth.left;
|
|
132
|
+
columnWidth.center = defaultColumnWidth.center;
|
|
133
|
+
columnWidth.right = defaultColumnWidth.right;
|
|
134
|
+
}
|
|
107
135
|
} else {
|
|
108
136
|
columnWidth.center = center;
|
|
109
137
|
}
|
|
110
138
|
|
|
139
|
+
globalThis.localStorage.setItem(COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(columnWidth));
|
|
140
|
+
|
|
111
141
|
state.columnWidth = columnWidth;
|
|
112
142
|
}
|
|
113
143
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
top: 0;
|
|
13
13
|
left: 0;
|
|
14
14
|
box-sizing: border-box;
|
|
15
|
+
z-index: 1;
|
|
15
16
|
|
|
16
17
|
.el-input__prefix {
|
|
17
18
|
padding: 10px;
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
color: $--font-color;
|
|
63
64
|
flex-direction: column;
|
|
64
65
|
width: 42px;
|
|
66
|
+
cursor: pointer;
|
|
65
67
|
|
|
66
68
|
i {
|
|
67
69
|
font-size: 20px;
|
|
@@ -2,38 +2,45 @@
|
|
|
2
2
|
position: fixed;
|
|
3
3
|
font-size: 12px;
|
|
4
4
|
background: #fff;
|
|
5
|
-
color: #333;
|
|
6
5
|
box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);
|
|
7
6
|
z-index: 9999;
|
|
8
7
|
transform-origin: 0% 0%;
|
|
9
8
|
font-weight: 600;
|
|
10
9
|
padding: 4px 0px;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
max-height: 100%;
|
|
11
12
|
|
|
12
|
-
.
|
|
13
|
-
width: 100%;
|
|
14
|
-
height: 0;
|
|
15
|
-
border-color: rgba(155, 155, 155, 0.1);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.subMenu {
|
|
19
|
-
position: absolute;
|
|
20
|
-
right: 0;
|
|
21
|
-
transform: translate(100%, 0);
|
|
22
|
-
background-color: #fff;
|
|
13
|
+
.menu-item {
|
|
23
14
|
color: #333;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
display: flex;
|
|
16
|
+
-webkit-box-align: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
min-width: 140px;
|
|
20
|
+
transition: all 0.2s ease 0s;
|
|
21
|
+
padding: 5px 14px;
|
|
22
|
+
border-left: 2px solid transparent;
|
|
23
|
+
|
|
24
|
+
.el-button {
|
|
25
|
+
width: 100%;
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
}
|
|
29
28
|
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
.el-button--text,
|
|
30
|
+
i {
|
|
31
|
+
color: $--font-color;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.divider {
|
|
35
|
+
padding: 0 14px;
|
|
36
|
+
|
|
37
|
+
.el-divider {
|
|
38
|
+
margin: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:hover {
|
|
43
|
+
background-color: $--hover-color;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
39
46
|
}
|
package/src/theme/nav-menu.scss
CHANGED
|
@@ -43,13 +43,17 @@
|
|
|
43
43
|
display: flex !important;
|
|
44
44
|
transition: all 0.3s ease 0s;
|
|
45
45
|
border-bottom: 2px solid transparent;
|
|
46
|
-
margin: 0
|
|
46
|
+
margin: 0;
|
|
47
47
|
|
|
48
48
|
.is-disabled {
|
|
49
49
|
opacity: 0.5;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.
|
|
52
|
+
.is-text {
|
|
53
|
+
padding: 5px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.is-text,
|
|
53
57
|
i {
|
|
54
58
|
color: $--font-color;
|
|
55
59
|
}
|
package/src/theme/page-bar.scss
CHANGED
|
@@ -6,19 +6,25 @@
|
|
|
6
6
|
width: 100%;
|
|
7
7
|
height: $--page-bar-height;
|
|
8
8
|
line-height: $--page-bar-height;
|
|
9
|
-
background-color: #f3f3f3;
|
|
10
9
|
color: $--font-color;
|
|
10
|
+
background-color: #f3f3f3;
|
|
11
11
|
border-top: 1px solid $--border-color;
|
|
12
12
|
z-index: 2;
|
|
13
13
|
overflow: hidden;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
&-items {
|
|
16
|
+
display: flex;
|
|
17
|
+
transition: transform 0.3s;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&-item {
|
|
16
21
|
padding: 0 10px;
|
|
17
22
|
cursor: pointer;
|
|
18
23
|
border-right: 1px solid $--border-color;
|
|
19
24
|
display: flex;
|
|
20
25
|
justify-items: center;
|
|
21
26
|
align-items: center;
|
|
27
|
+
background-color: #f3f3f3;
|
|
22
28
|
|
|
23
29
|
&.active {
|
|
24
30
|
background-color: #fff;
|
|
@@ -29,7 +35,12 @@
|
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
&-icon {
|
|
39
|
+
position: relative;
|
|
40
|
+
z-index: 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-title {
|
|
33
44
|
max-width: 150px;
|
|
34
45
|
text-overflow: ellipsis;
|
|
35
46
|
white-space: nowrap;
|
|
@@ -37,3 +48,24 @@
|
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
50
|
}
|
|
51
|
+
|
|
52
|
+
.page-bar-popover {
|
|
53
|
+
&.el-popper.el-popover {
|
|
54
|
+
padding: 10px 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.menu-item {
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
transition: all 0.2s ease 0s;
|
|
60
|
+
padding: 5px 14px;
|
|
61
|
+
|
|
62
|
+
.el-button--text,
|
|
63
|
+
i {
|
|
64
|
+
color: $--font-color;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
background-color: $--hover-color;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
.m-editor-props-panel {
|
|
2
2
|
padding: 0 10px;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.m-fieldset {
|
|
9
|
-
legend {
|
|
4
|
+
&.small {
|
|
5
|
+
.el-form-item__label {
|
|
10
6
|
font-size: 12px;
|
|
11
7
|
}
|
|
12
|
-
}
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
.m-fieldset {
|
|
10
|
+
legend {
|
|
11
|
+
font-size: 12px;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.el-tabs__item {
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
p {
|
|
21
|
-
font-size: 12px;
|
|
20
|
+
.el-input__wrapper {
|
|
21
|
+
border-radius: 0;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.m-editor-props-panel-popper {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
&.small {
|
|
27
|
+
span,
|
|
28
|
+
a,
|
|
29
|
+
p {
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
}
|
|
30
32
|
}
|
|
31
33
|
}
|
package/src/type.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface StoreState {
|
|
|
53
53
|
highlightNode: MNode | null;
|
|
54
54
|
stage: StageCore | null;
|
|
55
55
|
modifiedNodeIds: Map<Id, Id>;
|
|
56
|
+
pageLength: number;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
export interface PropsState {
|
|
@@ -98,6 +99,8 @@ export interface UiState {
|
|
|
98
99
|
showGuides: boolean;
|
|
99
100
|
/** 是否显示标尺,true: 显示,false: 不显示,默认为true */
|
|
100
101
|
showRule: boolean;
|
|
102
|
+
/** 用于控制该属性配置表单内组件的尺寸 */
|
|
103
|
+
propsPanelSize: 'large' | 'default' | 'small';
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
export interface EditorNodeInfo {
|
|
@@ -125,6 +128,8 @@ export interface MenuButton {
|
|
|
125
128
|
* zoom: 放大缩小
|
|
126
129
|
*/
|
|
127
130
|
type: 'button' | 'dropdown' | 'text' | 'divider' | 'zoom';
|
|
131
|
+
/** 当type为divider时有效,分割线方向, 默认vertical */
|
|
132
|
+
direction?: 'horizontal' | 'vertical';
|
|
128
133
|
/** 展示的文案 */
|
|
129
134
|
text?: string;
|
|
130
135
|
/** 鼠标悬浮是显示的气泡中的文案 */
|
|
@@ -136,14 +141,9 @@ export interface MenuButton {
|
|
|
136
141
|
/** 是否显示,默认为true */
|
|
137
142
|
display?: boolean | ((data?: Services) => boolean);
|
|
138
143
|
/** type为button/dropdown时点击运行的方法 */
|
|
139
|
-
handler?: (data
|
|
140
|
-
/** type为dropdown
|
|
141
|
-
items?:
|
|
142
|
-
/** 展示的文案 */
|
|
143
|
-
text: string;
|
|
144
|
-
/** 点击运行的方法 */
|
|
145
|
-
handler(data: Services): any;
|
|
146
|
-
}[];
|
|
144
|
+
handler?: (data: Services, event: MouseEvent) => Promise<any> | any;
|
|
145
|
+
/** type为dropdown时,下拉的菜单列表, 或者有子菜单时 */
|
|
146
|
+
items?: MenuButton[];
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
export interface MenuComponent {
|
|
@@ -220,7 +220,9 @@ export interface ComponentItem {
|
|
|
220
220
|
type: string;
|
|
221
221
|
/** element-plus icon class */
|
|
222
222
|
icon?: string | Component;
|
|
223
|
-
|
|
223
|
+
data?: {
|
|
224
|
+
[key: string]: any;
|
|
225
|
+
};
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
export interface ComponentGroup {
|
|
@@ -230,6 +232,11 @@ export interface ComponentGroup {
|
|
|
230
232
|
items: ComponentItem[];
|
|
231
233
|
}
|
|
232
234
|
|
|
235
|
+
export interface UpdateData {
|
|
236
|
+
id: Id;
|
|
237
|
+
[key: string]: any;
|
|
238
|
+
}
|
|
239
|
+
|
|
233
240
|
export enum LayerOffset {
|
|
234
241
|
TOP = 'top',
|
|
235
242
|
BOTTOM = 'bottom',
|
package/src/utils/editor.ts
CHANGED
|
@@ -20,7 +20,8 @@ import { random } from 'lodash-es';
|
|
|
20
20
|
|
|
21
21
|
import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
22
22
|
import { NodeType } from '@tmagic/schema';
|
|
23
|
-
import
|
|
23
|
+
import type StageCore from '@tmagic/stage';
|
|
24
|
+
import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
|
|
24
25
|
|
|
25
26
|
import { Layout } from '@editor/type';
|
|
26
27
|
|
|
@@ -105,7 +106,7 @@ const updatePopId = (oldId: Id, popId: Id, pageConfig: MPage) => {
|
|
|
105
106
|
export const setNewItemId = (config: MNode, parent?: MPage) => {
|
|
106
107
|
const oldId = config.id;
|
|
107
108
|
|
|
108
|
-
config.id = generateId(config.type);
|
|
109
|
+
config.id = generateId(config.type || 'component');
|
|
109
110
|
config.name = `${config.name?.replace(/_(\d+)$/, '')}_${config.id}`;
|
|
110
111
|
|
|
111
112
|
// 只有弹窗在页面下的一级子元素才有效
|
|
@@ -124,7 +125,7 @@ export const setNewItemId = (config: MNode, parent?: MPage) => {
|
|
|
124
125
|
*/
|
|
125
126
|
export const isFixed = (node: MNode): boolean => node.style?.position === 'fixed';
|
|
126
127
|
|
|
127
|
-
export const getNodeIndex = (node: MNode, parent: MContainer): number => {
|
|
128
|
+
export const getNodeIndex = (node: MNode, parent: MContainer | MApp): number => {
|
|
128
129
|
const items = parent?.items || [];
|
|
129
130
|
return items.findIndex((item: MNode) => `${item.id}` === `${node.id}`);
|
|
130
131
|
};
|
|
@@ -139,11 +140,29 @@ export const toRelative = (node: MNode) => {
|
|
|
139
140
|
return node;
|
|
140
141
|
};
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
const setTop2Middle = (node: MNode, parentNode: MNode, stage: StageCore) => {
|
|
144
|
+
const style = node.style || {};
|
|
145
|
+
const height = style.height || 0;
|
|
146
|
+
|
|
147
|
+
if (!stage || typeof style.top !== 'undefined' || !parentNode.style || !isNumber(height)) return style;
|
|
148
|
+
|
|
149
|
+
const { height: parentHeight } = parentNode.style;
|
|
150
|
+
|
|
151
|
+
if (isPage(parentNode)) {
|
|
152
|
+
const { scrollTop = 0, wrapperHeight } = stage.mask;
|
|
153
|
+
style.top = (wrapperHeight - height) / 2 + scrollTop;
|
|
154
|
+
} else {
|
|
155
|
+
style.top = (parentHeight - height) / 2;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return style;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const initPosition = (node: MNode, layout: Layout, parentNode: MNode, stage: StageCore) => {
|
|
143
162
|
if (layout === Layout.ABSOLUTE) {
|
|
144
163
|
node.style = {
|
|
145
164
|
position: 'absolute',
|
|
146
|
-
...(node
|
|
165
|
+
...setTop2Middle(node, parentNode, stage),
|
|
147
166
|
};
|
|
148
167
|
return node;
|
|
149
168
|
}
|
|
@@ -194,12 +213,18 @@ export const change2Fixed = (node: MNode, root: MApp) => {
|
|
|
194
213
|
return node;
|
|
195
214
|
};
|
|
196
215
|
|
|
197
|
-
export const Fixed2Other = async (
|
|
216
|
+
export const Fixed2Other = async (
|
|
217
|
+
node: MNode,
|
|
218
|
+
root: MApp,
|
|
219
|
+
getLayout: (parent: MNode, node?: MNode) => Promise<Layout>,
|
|
220
|
+
) => {
|
|
198
221
|
const path = getNodePath(node.id, root.items);
|
|
199
222
|
const cur = path.pop();
|
|
200
223
|
const offset = {
|
|
201
224
|
left: cur?.style?.left || 0,
|
|
202
225
|
top: cur?.style?.top || 0,
|
|
226
|
+
right: '',
|
|
227
|
+
bottom: '',
|
|
203
228
|
};
|
|
204
229
|
|
|
205
230
|
path.forEach((value) => {
|
package/src/utils/props.ts
CHANGED
|
@@ -142,6 +142,25 @@ export const fillConfig = (config: FormConfig = []) => [
|
|
|
142
142
|
},
|
|
143
143
|
],
|
|
144
144
|
},
|
|
145
|
+
{
|
|
146
|
+
type: 'fieldset',
|
|
147
|
+
legend: '字体',
|
|
148
|
+
items: [
|
|
149
|
+
{
|
|
150
|
+
name: 'color',
|
|
151
|
+
text: '颜色',
|
|
152
|
+
type: 'colorPicker',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: 'fontSize',
|
|
156
|
+
text: '大小',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'fontWeight',
|
|
160
|
+
text: '粗细',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
},
|
|
145
164
|
],
|
|
146
165
|
},
|
|
147
166
|
],
|
|
@@ -174,7 +193,7 @@ export const fillConfig = (config: FormConfig = []) => [
|
|
|
174
193
|
type: 'select',
|
|
175
194
|
options: (mForm: FormState, { model }: any) => {
|
|
176
195
|
const node = editorService.getNodeById(model.to);
|
|
177
|
-
if (!node) return [];
|
|
196
|
+
if (!node?.type) return [];
|
|
178
197
|
|
|
179
198
|
return eventsService.getMethod(node.type).map((option) => ({
|
|
180
199
|
text: option.label,
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { MNode } from '@tmagic/schema';
|
|
2
|
-
import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
|
|
3
|
-
import type { ComponentGroup } from '../../type';
|
|
4
|
-
declare const _default: DefineComponent<{
|
|
5
|
-
componentGroupList: {
|
|
6
|
-
type: PropType<ComponentGroup[]>;
|
|
7
|
-
default: () => never[];
|
|
8
|
-
};
|
|
9
|
-
}, {
|
|
10
|
-
subVisible: Ref<boolean>;
|
|
11
|
-
node: ComputedRef<MNode | undefined>;
|
|
12
|
-
menu: ComputedRef<{
|
|
13
|
-
app: {
|
|
14
|
-
type: string;
|
|
15
|
-
text: string;
|
|
16
|
-
}[];
|
|
17
|
-
component: ComponentGroup[];
|
|
18
|
-
}>;
|
|
19
|
-
append(config: any): void;
|
|
20
|
-
remove(): void;
|
|
21
|
-
copy(node: any): void;
|
|
22
|
-
setSubVisiable(v: any): void;
|
|
23
|
-
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
24
|
-
componentGroupList: {
|
|
25
|
-
type: PropType<ComponentGroup[]>;
|
|
26
|
-
default: () => never[];
|
|
27
|
-
};
|
|
28
|
-
}>>, {
|
|
29
|
-
componentGroupList: ComponentGroup[];
|
|
30
|
-
}>;
|
|
31
|
-
export default _default;
|