@tmagic/editor 1.3.0-alpha.9 → 1.3.0-beta.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/style.css +77 -218
- package/dist/tmagic-editor.js +4143 -3302
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +5289 -4434
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +15 -15
- package/src/Editor.vue +4 -5
- package/src/components/CodeBlockEditor.vue +257 -0
- package/src/components/CodeParams.vue +60 -0
- package/src/components/ContentMenu.vue +11 -3
- package/src/editorProps.ts +30 -5
- package/src/fields/Code.vue +23 -19
- package/src/fields/CodeLink.vue +6 -7
- package/src/fields/CodeSelect.vue +12 -9
- package/src/fields/CodeSelectCol.vue +70 -81
- package/src/fields/DataSourceFieldSelect.vue +47 -0
- package/src/fields/DataSourceFields.vue +28 -22
- package/src/fields/DataSourceInput.vue +21 -58
- package/src/fields/DataSourceMethodSelect.vue +136 -0
- package/src/fields/DataSourceMethods.vue +103 -0
- package/src/fields/DataSourceSelect.vue +5 -12
- package/src/fields/EventSelect.vue +53 -19
- package/src/fields/KeyValue.vue +9 -11
- package/src/fields/UISelect.vue +54 -14
- package/src/hooks/index.ts +21 -0
- package/src/hooks/use-code-block-edit.ts +84 -0
- package/src/hooks/use-data-source-method.ts +100 -0
- package/src/{utils/stage.ts → hooks/use-stage.ts} +4 -7
- package/src/icons/CenterIcon.vue +13 -0
- package/src/icons/CodeIcon.vue +0 -2
- package/src/icons/FolderMinusIcon.vue +22 -0
- package/src/index.ts +12 -0
- package/src/initService.ts +69 -16
- package/src/layouts/CodeEditor.vue +35 -3
- package/src/layouts/Framework.vue +7 -3
- package/src/layouts/PropsPanel.vue +8 -3
- package/src/layouts/sidebar/ComponentListPanel.vue +4 -6
- package/src/layouts/sidebar/LayerMenu.vue +20 -21
- package/src/layouts/sidebar/LayerPanel.vue +12 -2
- package/src/layouts/sidebar/Sidebar.vue +22 -36
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +81 -119
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +64 -0
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +27 -47
- package/src/layouts/sidebar/data-source/DataSourceList.vue +145 -0
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +58 -85
- package/src/layouts/workspace/Stage.vue +3 -2
- package/src/layouts/workspace/ViewerMenu.vue +10 -35
- package/src/services/codeBlock.ts +18 -71
- package/src/services/dataSource.ts +16 -1
- package/src/services/dep.ts +22 -20
- package/src/services/editor.ts +46 -18
- package/src/services/props.ts +2 -2
- package/src/theme/code-block.scss +5 -117
- package/src/theme/code-editor.scss +27 -2
- package/src/theme/content-menu.scss +1 -1
- package/src/theme/data-source-methods.scss +13 -0
- package/src/theme/data-source.scss +11 -0
- package/src/theme/event.scss +15 -12
- package/src/theme/framework.scss +0 -3
- package/src/theme/layout.scss +4 -0
- package/src/theme/sidebar.scss +18 -60
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +47 -7
- package/src/utils/content-menu.ts +92 -0
- package/src/utils/data-source/formConfigs/base.ts +28 -30
- package/src/utils/data-source/index.ts +65 -2
- package/src/utils/dep.ts +33 -7
- package/src/utils/index.ts +1 -1
- package/src/utils/props.ts +298 -189
- package/src/utils/undo-redo.ts +1 -1
- package/types/Editor.vue.d.ts +30 -6
- package/types/components/CodeBlockEditor.vue.d.ts +23 -0
- package/types/components/CodeParams.vue.d.ts +26 -0
- package/types/components/ContentMenu.vue.d.ts +2 -2
- package/types/components/ToolButton.vue.d.ts +3 -3
- package/types/editorProps.d.ts +19 -5
- package/types/fields/Code.vue.d.ts +24 -19
- package/types/fields/CodeLink.vue.d.ts +12 -21
- package/types/fields/CodeSelect.vue.d.ts +6 -17
- package/types/fields/CodeSelectCol.vue.d.ts +10 -14
- package/types/fields/DataSourceFieldSelect.vue.d.ts +29 -0
- package/types/fields/DataSourceFields.vue.d.ts +7 -18
- package/types/fields/DataSourceInput.vue.d.ts +10 -30
- package/types/fields/DataSourceMethodSelect.vue.d.ts +29 -0
- package/types/fields/DataSourceMethods.vue.d.ts +32 -0
- package/types/fields/DataSourceSelect.vue.d.ts +13 -29
- package/types/fields/EventSelect.vue.d.ts +2 -13
- package/types/fields/KeyValue.vue.d.ts +9 -24
- package/types/fields/UISelect.vue.d.ts +2 -11
- package/types/hooks/index.d.ts +3 -0
- package/types/{components/FunctionEditor.vue.d.ts → hooks/use-code-block-edit.d.ts} +31 -121
- package/types/hooks/use-data-source-method.d.ts +123 -0
- package/types/icons/CenterIcon.vue.d.ts +2 -0
- package/types/icons/FolderMinusIcon.vue.d.ts +2 -0
- package/types/index.d.ts +6 -0
- package/types/initService.d.ts +2 -2
- package/types/layouts/CodeEditor.vue.d.ts +7 -4
- package/types/layouts/PropsPanel.vue.d.ts +274 -2
- package/types/layouts/sidebar/Sidebar.vue.d.ts +0 -3
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +4 -9
- package/types/layouts/sidebar/code-block/{CodeBlockEditor.vue.d.ts → CodeBlockListPanel.vue.d.ts} +9 -5
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -1
- package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +14 -0
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +1 -11
- package/types/services/codeBlock.d.ts +6 -37
- package/types/services/dataSource.d.ts +7 -1
- package/types/services/dep.d.ts +12 -21
- package/types/services/editor.d.ts +1 -1
- package/types/services/props.d.ts +10 -115
- package/types/type.d.ts +42 -7
- package/types/utils/content-menu.d.ts +7 -0
- package/types/utils/data-source/formConfigs/base.d.ts +1 -2
- package/types/utils/data-source/index.d.ts +5 -0
- package/types/utils/dep.d.ts +4 -2
- package/types/utils/index.d.ts +1 -1
- package/types/utils/props.d.ts +13 -102
- package/src/components/CodeDraftEditor.vue +0 -148
- package/src/components/FunctionEditor.vue +0 -197
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +0 -100
- package/types/components/CodeDraftEditor.vue.d.ts +0 -61
- /package/types/{utils/stage.d.ts → hooks/use-stage.d.ts} +0 -0
package/src/services/editor.ts
CHANGED
|
@@ -193,7 +193,7 @@ class Editor extends BaseService {
|
|
|
193
193
|
/**
|
|
194
194
|
* 只有容器拥有布局
|
|
195
195
|
*/
|
|
196
|
-
public async getLayout(parent: MNode, node?: MNode): Promise<Layout> {
|
|
196
|
+
public async getLayout(parent: MNode, node?: MNode | null): Promise<Layout> {
|
|
197
197
|
if (node && typeof node !== 'function' && isFixed(node)) return Layout.FIXED;
|
|
198
198
|
|
|
199
199
|
if (parent.layout) {
|
|
@@ -648,12 +648,14 @@ class Editor extends BaseService {
|
|
|
648
648
|
|
|
649
649
|
if (doc) {
|
|
650
650
|
const el = doc.getElementById(`${node.id}`);
|
|
651
|
-
const parentEl = el?.offsetParent;
|
|
651
|
+
const parentEl = layout === Layout.FIXED ? doc.body : el?.offsetParent;
|
|
652
652
|
if (parentEl && el) {
|
|
653
653
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
654
|
+
node.style.right = '';
|
|
654
655
|
}
|
|
655
656
|
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
656
657
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
658
|
+
node.style.right = '';
|
|
657
659
|
}
|
|
658
660
|
|
|
659
661
|
return node;
|
|
@@ -705,9 +707,9 @@ class Editor extends BaseService {
|
|
|
705
707
|
brothers.splice(index, 1);
|
|
706
708
|
|
|
707
709
|
if (offset === LayerOffset.TOP) {
|
|
708
|
-
brothers.splice(isRelative ? 0 : brothers.length
|
|
710
|
+
brothers.splice(isRelative ? 0 : brothers.length, 0, node);
|
|
709
711
|
} else if (offset === LayerOffset.BOTTOM) {
|
|
710
|
-
brothers.splice(isRelative ? brothers.length
|
|
712
|
+
brothers.splice(isRelative ? brothers.length : 0, 0, node);
|
|
711
713
|
} else {
|
|
712
714
|
brothers.splice(index + (isRelative ? -offset : offset), 0, node);
|
|
713
715
|
}
|
|
@@ -792,20 +794,46 @@ class Editor extends BaseService {
|
|
|
792
794
|
if (!node || isPage(node)) return;
|
|
793
795
|
|
|
794
796
|
const { style, id, type } = node;
|
|
795
|
-
if (!style || style.position
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
797
|
+
if (!style || !['absolute', 'fixed'].includes(style.position)) return;
|
|
798
|
+
|
|
799
|
+
const update = (style: { [key: string]: any }) =>
|
|
800
|
+
this.update({
|
|
801
|
+
id,
|
|
802
|
+
type,
|
|
803
|
+
style,
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
if (top) {
|
|
807
|
+
if (isNumber(style.top)) {
|
|
808
|
+
update({
|
|
809
|
+
...style,
|
|
810
|
+
top: Number(style.top) + Number(top),
|
|
811
|
+
bottom: '',
|
|
812
|
+
});
|
|
813
|
+
} else if (isNumber(style.bottom)) {
|
|
814
|
+
update({
|
|
815
|
+
...style,
|
|
816
|
+
bottom: Number(style.bottom) - Number(top),
|
|
817
|
+
top: '',
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (left) {
|
|
823
|
+
if (isNumber(style.left)) {
|
|
824
|
+
update({
|
|
825
|
+
...style,
|
|
826
|
+
left: Number(style.left) + Number(left),
|
|
827
|
+
right: '',
|
|
828
|
+
});
|
|
829
|
+
} else if (isNumber(style.right)) {
|
|
830
|
+
update({
|
|
831
|
+
...style,
|
|
832
|
+
right: Number(style.right) - Number(left),
|
|
833
|
+
left: '',
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
}
|
|
809
837
|
}
|
|
810
838
|
|
|
811
839
|
public resetState() {
|
package/src/services/props.ts
CHANGED
|
@@ -80,7 +80,7 @@ class Props extends BaseService {
|
|
|
80
80
|
return cloneDeep(this.state.propsConfigMap[type] || (await this.fillConfig([])));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
public setPropsValues(values: Record<string, MNode
|
|
83
|
+
public setPropsValues(values: Record<string, Partial<MNode>>) {
|
|
84
84
|
Object.keys(values).forEach((type: string) => {
|
|
85
85
|
this.setPropsValue(toLine(type), values[type]);
|
|
86
86
|
});
|
|
@@ -91,7 +91,7 @@ class Props extends BaseService {
|
|
|
91
91
|
* @param type 组件类型
|
|
92
92
|
* @param value 组件初始值
|
|
93
93
|
*/
|
|
94
|
-
public async setPropsValue(type: string, value: MNode) {
|
|
94
|
+
public async setPropsValue(type: string, value: Partial<MNode>) {
|
|
95
95
|
this.state.propsValueMap[type] = value;
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -25,124 +25,12 @@
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.code-editor-dialog {
|
|
33
|
-
.tmagic-design-card {
|
|
34
|
-
.t-card__header {
|
|
35
|
-
display: block;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.el-dialog__body,
|
|
40
|
-
.t-dialog__body {
|
|
41
|
-
height: 90%;
|
|
42
|
-
padding-top: 10px;
|
|
43
|
-
}
|
|
44
|
-
.tmagic-design-card {
|
|
45
|
-
height: 100%;
|
|
46
|
-
background: #fff;
|
|
47
|
-
.el-card__body,
|
|
48
|
-
.t-card__body {
|
|
49
|
-
height: 100%;
|
|
50
|
-
background: #fff;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.code-editor-layout {
|
|
55
|
-
height: 100%;
|
|
56
|
-
border: 1px solid #e4e7ed;
|
|
57
|
-
|
|
58
|
-
.side-tree {
|
|
59
|
-
height: 100%;
|
|
60
|
-
overflow: auto;
|
|
61
|
-
.el-tree-node__label {
|
|
62
|
-
width: 100%;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.list-container {
|
|
66
|
-
width: 100%;
|
|
67
|
-
overflow: hidden;
|
|
68
|
-
margin-left: -10px;
|
|
69
|
-
.list-item {
|
|
70
|
-
width: 100%;
|
|
71
|
-
margin: 10px 0;
|
|
72
|
-
line-height: 30px;
|
|
73
|
-
.code-name {
|
|
74
|
-
width: 100%;
|
|
75
|
-
font-size: 14px;
|
|
76
|
-
overflow: hidden;
|
|
77
|
-
white-space: nowrap;
|
|
78
|
-
text-overflow: ellipsis;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
28
|
+
.m-editor-code-block-editor {
|
|
29
|
+
.tmagic-design-table {
|
|
30
|
+
height: 180px;
|
|
83
31
|
}
|
|
84
32
|
|
|
85
|
-
.
|
|
86
|
-
|
|
87
|
-
align-items: center;
|
|
88
|
-
font-size: 16px;
|
|
89
|
-
margin-bottom: 10px;
|
|
90
|
-
.code-name-label {
|
|
91
|
-
margin-right: 10px;
|
|
92
|
-
}
|
|
93
|
-
.code-name-input {
|
|
94
|
-
width: 300px;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.m-editor-code-block-editor-panel-list-mode {
|
|
99
|
-
height: 100%;
|
|
100
|
-
z-index: 10;
|
|
101
|
-
background: #fff;
|
|
102
|
-
.el-card {
|
|
103
|
-
border: 0;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.m-editor-code-block-editor-panel {
|
|
108
|
-
position: absolute;
|
|
109
|
-
top: 0;
|
|
110
|
-
left: 4px;
|
|
111
|
-
width: calc(100% - 9px);
|
|
112
|
-
height: 100%;
|
|
113
|
-
z-index: 10;
|
|
114
|
-
background: #fff;
|
|
115
|
-
.el-card {
|
|
116
|
-
border: 0;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.m-editor-wrapper {
|
|
121
|
-
height: 100%;
|
|
122
|
-
&.fullScreen {
|
|
123
|
-
height: 100%;
|
|
124
|
-
width: 100%;
|
|
125
|
-
position: fixed;
|
|
126
|
-
top: 0;
|
|
127
|
-
left: 0;
|
|
128
|
-
z-index: 100;
|
|
129
|
-
}
|
|
130
|
-
.m-editor-container {
|
|
131
|
-
height: calc(100% - 45px);
|
|
132
|
-
}
|
|
133
|
-
.m-editor-content-bottom {
|
|
134
|
-
height: 45px;
|
|
135
|
-
width: 100%;
|
|
136
|
-
display: flex;
|
|
137
|
-
justify-content: end;
|
|
138
|
-
background: #fff;
|
|
139
|
-
position: absolute;
|
|
140
|
-
right: 20px;
|
|
141
|
-
bottom: 0;
|
|
142
|
-
> button {
|
|
143
|
-
height: 30px;
|
|
144
|
-
margin-top: 5px;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
33
|
+
.el-drawer__body {
|
|
34
|
+
padding: 10px 20px;
|
|
147
35
|
}
|
|
148
36
|
}
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
.magic-code-editor {
|
|
2
2
|
width: 100%;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.magic-code-editor-wrapper {
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 100%;
|
|
8
|
+
position: relative;
|
|
9
|
+
|
|
10
|
+
&.full-screen {
|
|
11
|
+
position: fixed;
|
|
12
|
+
z-index: 10000;
|
|
13
|
+
top: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.magic-code-editor-content {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
|
|
21
|
+
.margin {
|
|
22
|
+
margin: 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
3
25
|
|
|
4
|
-
.
|
|
5
|
-
|
|
26
|
+
.magic-code-editor-full-screen-icon {
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 5px;
|
|
29
|
+
right: 0;
|
|
30
|
+
z-index: 11;
|
|
6
31
|
}
|
|
7
32
|
}
|
package/src/theme/event.scss
CHANGED
|
@@ -19,18 +19,21 @@
|
|
|
19
19
|
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.12);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
.m-fields-code-select-col
|
|
22
|
+
.m-fields-code-select-col,
|
|
23
|
+
.m-fields-data-source-method-select {
|
|
23
24
|
width: 100%;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.code-select-container,
|
|
28
|
+
.data-source-method-select-container {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
.select {
|
|
32
|
+
flex: 10 0 100px;
|
|
33
|
+
}
|
|
34
|
+
.icon {
|
|
35
|
+
flex: 1 0 20px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
margin-right: 5px;
|
|
35
38
|
}
|
|
36
39
|
}
|
package/src/theme/framework.scss
CHANGED
package/src/theme/layout.scss
CHANGED
package/src/theme/sidebar.scss
CHANGED
|
@@ -1,76 +1,33 @@
|
|
|
1
|
-
.m-editor-sidebar
|
|
1
|
+
.m-editor-sidebar {
|
|
2
|
+
display: flex;
|
|
2
3
|
height: 100%;
|
|
3
4
|
|
|
4
|
-
.
|
|
5
|
-
.t-tabs__header {
|
|
5
|
+
.m-editor-sidebar-header {
|
|
6
6
|
background: $--sidebar-heder-background-color;
|
|
7
|
-
border: 0;
|
|
8
7
|
height: 100%;
|
|
8
|
+
width: 40px;
|
|
9
9
|
|
|
10
|
-
.
|
|
11
|
-
background-color: transparent;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.t-tabs__nav--card.t-tabs__nav-item:not(.t-is-disabled):not(
|
|
15
|
-
.t-is-active
|
|
16
|
-
):hover {
|
|
17
|
-
background-color: transparent;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&.is-left,
|
|
21
|
-
&.t-is-left {
|
|
22
|
-
width: 40px;
|
|
23
|
-
margin-right: 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.el-tabs__nav-wrap {
|
|
27
|
-
margin: 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.el-tabs__nav {
|
|
31
|
-
border: 0;
|
|
32
|
-
border-radius: 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.tab-label {
|
|
36
|
-
margin-left: 2px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.el-tabs__item.is-left,
|
|
40
|
-
.t-tabs__nav-item {
|
|
10
|
+
.m-editor-sidebar-header-item {
|
|
41
11
|
line-height: 15px;
|
|
42
|
-
border: 0;
|
|
43
12
|
height: auto;
|
|
44
13
|
padding: 8px;
|
|
45
14
|
color: rgb(255, 255, 255);
|
|
46
15
|
box-sizing: border-box;
|
|
16
|
+
cursor: pointer;
|
|
47
17
|
|
|
48
|
-
&.is-
|
|
49
|
-
|
|
50
|
-
&.is-active,
|
|
51
|
-
&.t-is-active {
|
|
52
|
-
background: $--sidebar-content-background-color;
|
|
53
|
-
border: 0;
|
|
54
|
-
|
|
55
|
-
i {
|
|
56
|
-
color: #353140;
|
|
57
|
-
}
|
|
18
|
+
&.is-active {
|
|
19
|
+
background: $--sidebar-content-background-color;
|
|
58
20
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
21
|
+
i {
|
|
22
|
+
color: #353140;
|
|
62
23
|
}
|
|
63
24
|
|
|
64
|
-
|
|
65
|
-
|
|
25
|
+
.magic-editor-tab-panel-title {
|
|
26
|
+
color: #353140;
|
|
66
27
|
}
|
|
67
28
|
}
|
|
68
29
|
}
|
|
69
30
|
|
|
70
|
-
.t-tabs__nav-item {
|
|
71
|
-
padding: 7px;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
31
|
i {
|
|
75
32
|
font-size: 25px;
|
|
76
33
|
color: rgba(255, 255, 255, 0.6);
|
|
@@ -86,6 +43,12 @@
|
|
|
86
43
|
}
|
|
87
44
|
}
|
|
88
45
|
|
|
46
|
+
.m-editor-sidebar-content {
|
|
47
|
+
height: 100%;
|
|
48
|
+
width: calc(100% - 40px);
|
|
49
|
+
overflow: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
89
52
|
.el-scrollbar {
|
|
90
53
|
height: 100%;
|
|
91
54
|
}
|
|
@@ -109,9 +72,4 @@
|
|
|
109
72
|
background: rgba(0, 0, 0, 0.2);
|
|
110
73
|
}
|
|
111
74
|
}
|
|
112
|
-
|
|
113
|
-
.el-tabs__content,
|
|
114
|
-
.el-tab-pane {
|
|
115
|
-
height: 100%;
|
|
116
|
-
}
|
|
117
75
|
}
|
package/src/theme/theme.scss
CHANGED
package/src/type.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import type { Component } from 'vue';
|
|
20
20
|
|
|
21
|
-
import type { FormConfig, FormItem } from '@tmagic/form';
|
|
21
|
+
import type { ColumnConfig, FilterFunction, FormConfig, FormItem } from '@tmagic/form';
|
|
22
22
|
import type { CodeBlockContent, CodeBlockDSL, Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
23
23
|
import type StageCore from '@tmagic/stage';
|
|
24
24
|
import type {
|
|
@@ -45,7 +45,7 @@ export type BeforeAdd = (config: MNode, parent: MContainer) => Promise<MNode> |
|
|
|
45
45
|
export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig;
|
|
46
46
|
|
|
47
47
|
export interface InstallOptions {
|
|
48
|
-
parseDSL: (dsl: string) =>
|
|
48
|
+
parseDSL: <T = any>(dsl: string) => T;
|
|
49
49
|
[key: string]: any;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -93,7 +93,7 @@ export type StoreStateKey = keyof StoreState;
|
|
|
93
93
|
|
|
94
94
|
export interface PropsState {
|
|
95
95
|
propsConfigMap: Record<string, FormConfig>;
|
|
96
|
-
propsValueMap: Record<string, MNode
|
|
96
|
+
propsValueMap: Record<string, Partial<MNode>>;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export interface ComponentGroupState {
|
|
@@ -334,18 +334,15 @@ export interface ScrollViewerEvent {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
export type CodeState = {
|
|
337
|
-
/** 是否展示代码块编辑区 */
|
|
338
|
-
isShowCodeEditor: boolean;
|
|
339
337
|
/** 代码块DSL数据源 */
|
|
340
338
|
codeDsl: CodeBlockDSL | null;
|
|
341
|
-
/** 当前选中的代码块id */
|
|
342
|
-
id: Id;
|
|
343
339
|
/** 代码块是否可编辑 */
|
|
344
340
|
editable: boolean;
|
|
345
341
|
/** list模式下左侧展示的代码列表 */
|
|
346
342
|
combineIds: string[];
|
|
347
343
|
/** 为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除) */
|
|
348
344
|
undeletableList: Id[];
|
|
345
|
+
paramsColConfig?: ColumnConfig;
|
|
349
346
|
};
|
|
350
347
|
|
|
351
348
|
export type HookData = {
|
|
@@ -429,6 +426,8 @@ export interface EventSelectConfig {
|
|
|
429
426
|
compActionConfig?: FormItem;
|
|
430
427
|
/** 联动代码配置 */
|
|
431
428
|
codeActionConfig?: FormItem;
|
|
429
|
+
/** 联动数据源配置 */
|
|
430
|
+
dataSourceActionConfig?: FormItem;
|
|
432
431
|
}
|
|
433
432
|
|
|
434
433
|
export enum KeyBindingCommand {
|
|
@@ -485,3 +484,44 @@ export interface KeyBindingCacheItem {
|
|
|
485
484
|
eventType: 'keyup' | 'keydown';
|
|
486
485
|
binded: boolean;
|
|
487
486
|
}
|
|
487
|
+
|
|
488
|
+
export interface CodeSelectColConfig {
|
|
489
|
+
type: 'code-select-col';
|
|
490
|
+
name: string;
|
|
491
|
+
labelWidth?: number | string;
|
|
492
|
+
disabled?: boolean | FilterFunction;
|
|
493
|
+
display?: boolean | FilterFunction;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export interface DataSourceMethodSelectConfig {
|
|
497
|
+
type: 'data-source-method-select';
|
|
498
|
+
name: string;
|
|
499
|
+
labelWidth?: number | string;
|
|
500
|
+
disabled?: boolean | FilterFunction;
|
|
501
|
+
display?: boolean | FilterFunction;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface DataSourceFieldSelectConfig {
|
|
505
|
+
type: 'data-source-field-select';
|
|
506
|
+
name: string;
|
|
507
|
+
labelWidth?: number | string;
|
|
508
|
+
disabled?: boolean | FilterFunction;
|
|
509
|
+
display?: boolean | FilterFunction;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export enum DepTargetType {
|
|
513
|
+
DEFAULT = 'default',
|
|
514
|
+
/** 代码块 */
|
|
515
|
+
CODE_BLOCK = 'code-block',
|
|
516
|
+
/** 数据源 */
|
|
517
|
+
DATA_SOURCE = 'data-source',
|
|
518
|
+
/** 数据源方法 */
|
|
519
|
+
DATA_SOURCE_METHOD = 'data-source-method',
|
|
520
|
+
/** 数据源条件 */
|
|
521
|
+
DATA_SOURCE_COND = 'data-source-cond',
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export interface DatasourceTypeOption {
|
|
525
|
+
type: string;
|
|
526
|
+
text: string;
|
|
527
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { computed, markRaw, Ref, ref } from 'vue';
|
|
2
|
+
import { CopyDocument, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
3
|
+
|
|
4
|
+
import { Id, MContainer, NodeType } from '@tmagic/schema';
|
|
5
|
+
import { isPage } from '@tmagic/utils';
|
|
6
|
+
|
|
7
|
+
import ContentMenu from '@editor/components/ContentMenu.vue';
|
|
8
|
+
import type { MenuButton, Services } from '@editor/type';
|
|
9
|
+
|
|
10
|
+
export const useDeleteMenu = (): MenuButton => ({
|
|
11
|
+
type: 'button',
|
|
12
|
+
text: '删除',
|
|
13
|
+
icon: Delete,
|
|
14
|
+
display: (services) => {
|
|
15
|
+
const node = services?.editorService?.get('node');
|
|
16
|
+
return node?.type !== NodeType.ROOT && !isPage(node);
|
|
17
|
+
},
|
|
18
|
+
handler: (services) => {
|
|
19
|
+
const nodes = services?.editorService?.get('nodes');
|
|
20
|
+
nodes && services?.editorService?.remove(nodes);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const canPaste = ref(false);
|
|
25
|
+
|
|
26
|
+
export const useCopyMenu = (): MenuButton => ({
|
|
27
|
+
type: 'button',
|
|
28
|
+
text: '复制',
|
|
29
|
+
icon: markRaw(CopyDocument),
|
|
30
|
+
handler: (services) => {
|
|
31
|
+
const nodes = services?.editorService?.get('nodes');
|
|
32
|
+
nodes && services?.editorService?.copy(nodes);
|
|
33
|
+
canPaste.value = true;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const usePasteMenu = (menu?: Ref<InstanceType<typeof ContentMenu> | undefined>): MenuButton => ({
|
|
38
|
+
type: 'button',
|
|
39
|
+
text: '粘贴',
|
|
40
|
+
icon: markRaw(DocumentCopy),
|
|
41
|
+
display: () => canPaste.value,
|
|
42
|
+
handler: (services) => {
|
|
43
|
+
const nodes = services?.editorService?.get('nodes');
|
|
44
|
+
if (!nodes || nodes.length === 0) return;
|
|
45
|
+
|
|
46
|
+
if (menu?.value?.$el) {
|
|
47
|
+
const stage = services?.editorService?.get('stage');
|
|
48
|
+
const rect = menu.value.$el.getBoundingClientRect();
|
|
49
|
+
const parentRect = stage?.container?.getBoundingClientRect();
|
|
50
|
+
const initialLeft = (rect.left || 0) - (parentRect?.left || 0);
|
|
51
|
+
const initialTop = (rect.top || 0) - (parentRect?.top || 0);
|
|
52
|
+
services?.editorService?.paste({ left: initialLeft, top: initialTop });
|
|
53
|
+
} else {
|
|
54
|
+
services?.editorService?.paste();
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const moveTo = (id: Id, services?: Services) => {
|
|
60
|
+
if (!services?.editorService) return;
|
|
61
|
+
|
|
62
|
+
const nodes = services.editorService.get('nodes') || [];
|
|
63
|
+
const parent = services.editorService.getNodeById(id) as MContainer;
|
|
64
|
+
|
|
65
|
+
if (!parent) return;
|
|
66
|
+
|
|
67
|
+
services?.editorService.add(nodes, parent);
|
|
68
|
+
services?.editorService.remove(nodes);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const useMoveToMenu = (services?: Services): MenuButton => {
|
|
72
|
+
const root = computed(() => services?.editorService?.get('root'));
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
type: 'button',
|
|
76
|
+
text: '移动至',
|
|
77
|
+
display: (services) => {
|
|
78
|
+
const node = services?.editorService?.get('node');
|
|
79
|
+
const pageLength = services?.editorService?.get('pageLength') || 0;
|
|
80
|
+
return !isPage(node) && pageLength > 1;
|
|
81
|
+
},
|
|
82
|
+
items: (root.value?.items || [])
|
|
83
|
+
.filter((page) => page.id !== services?.editorService?.get('page')?.id)
|
|
84
|
+
.map((page) => ({
|
|
85
|
+
text: `${page.name}(${page.id})`,
|
|
86
|
+
type: 'button',
|
|
87
|
+
handler: (services?: Services) => {
|
|
88
|
+
moveTo(page.id, services);
|
|
89
|
+
},
|
|
90
|
+
})),
|
|
91
|
+
};
|
|
92
|
+
};
|