@tmagic/editor 1.1.6 → 1.2.0-beta.10
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 +191 -8
- package/dist/tmagic-editor.mjs +2104 -1027
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +2136 -1053
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +11 -10
- package/src/Editor.vue +27 -12
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +7 -5
- package/src/{layouts → components}/Layout.vue +15 -5
- package/src/components/ScrollBar.vue +1 -1
- package/src/components/ScrollViewer.vue +10 -1
- package/src/components/ToolButton.vue +30 -15
- package/src/fields/Code.vue +5 -2
- package/src/fields/CodeLink.vue +20 -12
- package/src/fields/CodeSelect.vue +131 -0
- package/src/fields/UISelect.vue +9 -8
- package/src/index.ts +7 -2
- package/src/layouts/AddPageBox.vue +13 -20
- package/src/layouts/CodeEditor.vue +106 -120
- package/src/layouts/Framework.vue +62 -40
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/PropsPanel.vue +5 -10
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +15 -13
- package/src/layouts/sidebar/LayerMenu.vue +89 -92
- package/src/layouts/sidebar/LayerPanel.vue +273 -178
- package/src/layouts/sidebar/Sidebar.vue +129 -37
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +169 -0
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +267 -0
- package/src/layouts/workspace/Breadcrumb.vue +32 -0
- package/src/layouts/workspace/PageBar.vue +12 -11
- package/src/layouts/workspace/PageBarScrollContainer.vue +1 -1
- package/src/layouts/workspace/Stage.vue +15 -7
- package/src/layouts/workspace/ViewerMenu.vue +8 -7
- package/src/layouts/workspace/Workspace.vue +10 -3
- package/src/services/codeBlock.ts +415 -0
- package/src/services/editor.ts +35 -5
- package/src/theme/breadcrumb.scss +6 -0
- package/src/theme/code-block.scss +184 -0
- package/src/theme/component-list-panel.scss +3 -7
- package/src/theme/index.scss +1 -13
- package/src/theme/layer-panel.scss +7 -2
- package/src/theme/layout.scss +5 -0
- package/src/theme/theme.scss +16 -0
- package/src/type.ts +88 -1
- package/src/utils/props.ts +9 -3
- package/src/utils/scroll-viewer.ts +18 -2
- package/src/utils/stage.ts +7 -0
- package/types/Editor.vue.d.ts +2 -2
- package/types/components/ContentMenu.vue.d.ts +1 -3
- package/types/components/Icon.vue.d.ts +1 -3
- package/types/{layouts → components}/Layout.vue.d.ts +0 -0
- package/types/components/ScrollBar.vue.d.ts +1 -3
- package/types/components/ScrollViewer.vue.d.ts +45 -1
- package/types/components/ToolButton.vue.d.ts +1 -3
- package/types/fields/Code.vue.d.ts +9 -3
- package/types/fields/CodeLink.vue.d.ts +5 -3
- package/types/fields/CodeSelect.vue.d.ts +94 -0
- package/types/fields/UISelect.vue.d.ts +1 -3
- package/types/index.d.ts +4 -0
- package/types/layouts/AddPageBox.vue.d.ts +43 -3
- package/types/layouts/CodeEditor.vue.d.ts +158 -45
- package/types/layouts/NavMenu.vue.d.ts +1 -3
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +31 -63
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +38 -1074
- package/types/layouts/sidebar/Sidebar.vue.d.ts +119 -17
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +50 -0
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +73 -0
- package/types/layouts/workspace/Breadcrumb.vue.d.ts +44 -0
- package/types/layouts/workspace/Stage.vue.d.ts +23 -7
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +6 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
- package/types/services/codeBlock.d.ts +155 -0
- package/types/services/editor.d.ts +12 -1
- package/types/services/props.d.ts +12 -0
- package/types/services/ui.d.ts +1 -1
- package/types/type.d.ts +78 -1
- package/types/utils/props.d.ts +12 -0
- package/types/utils/scroll-viewer.d.ts +5 -0
- package/src/layouts/sidebar/TabPane.vue +0 -99
- package/types/layouts/sidebar/TabPane.vue.d.ts +0 -14
package/src/services/editor.ts
CHANGED
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
import { reactive, toRaw } from 'vue';
|
|
20
20
|
import { cloneDeep, mergeWith, uniq } from 'lodash-es';
|
|
21
21
|
|
|
22
|
-
import type { Id, MApp, MComponent, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
22
|
+
import type { CodeBlockDSL, Id, MApp, MComponent, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
23
23
|
import { NodeType } from '@tmagic/schema';
|
|
24
24
|
import StageCore from '@tmagic/stage';
|
|
25
25
|
import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
|
|
26
26
|
|
|
27
|
+
import codeBlockService from '../services/codeBlock';
|
|
27
28
|
import historyService, { StepValue } from '../services/history';
|
|
28
29
|
import storageService, { Protocol } from '../services/storage';
|
|
29
30
|
import type { AddMNode, EditorNodeInfo, PastePosition, StoreState } from '../type';
|
|
@@ -72,7 +73,7 @@ class Editor extends BaseService {
|
|
|
72
73
|
'copy',
|
|
73
74
|
'paste',
|
|
74
75
|
'doPaste',
|
|
75
|
-
'
|
|
76
|
+
'doAlignCenter',
|
|
76
77
|
'alignCenter',
|
|
77
78
|
'moveLayer',
|
|
78
79
|
'moveToContainer',
|
|
@@ -80,6 +81,8 @@ class Editor extends BaseService {
|
|
|
80
81
|
'undo',
|
|
81
82
|
'redo',
|
|
82
83
|
'highlight',
|
|
84
|
+
'getCodeDsl',
|
|
85
|
+
'setCodeDsl',
|
|
83
86
|
],
|
|
84
87
|
// 需要注意循环依赖问题,如果函数间有相互调用的话,不能设置为串行调用
|
|
85
88
|
['select', 'update', 'moveLayer'],
|
|
@@ -419,6 +422,9 @@ class Editor extends BaseService {
|
|
|
419
422
|
}
|
|
420
423
|
|
|
421
424
|
this.addModifiedNodeId(parent.id);
|
|
425
|
+
|
|
426
|
+
// 通知codeBlockService解除绑定关系
|
|
427
|
+
codeBlockService.deleteCompsInRelation(node);
|
|
422
428
|
}
|
|
423
429
|
|
|
424
430
|
/**
|
|
@@ -478,10 +484,10 @@ class Editor extends BaseService {
|
|
|
478
484
|
parentNodeItems[index] = newConfig;
|
|
479
485
|
|
|
480
486
|
// 将update后的配置更新到nodes中
|
|
481
|
-
const nodes = this.get('nodes');
|
|
487
|
+
const nodes = this.get<MNode[]>('nodes') || [];
|
|
482
488
|
const targetIndex = nodes.findIndex((nodeItem: MNode) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
483
489
|
nodes.splice(targetIndex, 1, newConfig);
|
|
484
|
-
this.set('nodes', nodes);
|
|
490
|
+
this.set('nodes', [...nodes]);
|
|
485
491
|
|
|
486
492
|
this.get<StageCore | null>('stage')?.update({
|
|
487
493
|
config: cloneDeep(newConfig),
|
|
@@ -617,7 +623,11 @@ class Editor extends BaseService {
|
|
|
617
623
|
|
|
618
624
|
const newNode = await this.update(newNodes);
|
|
619
625
|
|
|
620
|
-
|
|
626
|
+
if (newNodes.length > 1) {
|
|
627
|
+
await stage?.multiSelect(newNodes.map((node) => node.id));
|
|
628
|
+
} else {
|
|
629
|
+
await stage?.select(newNodes[0].id);
|
|
630
|
+
}
|
|
621
631
|
|
|
622
632
|
return newNode;
|
|
623
633
|
}
|
|
@@ -760,6 +770,26 @@ class Editor extends BaseService {
|
|
|
760
770
|
this.get<Map<Id, Id>>('modifiedNodeIds').clear();
|
|
761
771
|
}
|
|
762
772
|
|
|
773
|
+
/**
|
|
774
|
+
* 从dsl中的codeBlocks字段读取活动的代码块
|
|
775
|
+
* @returns {CodeBlockDSL | null}
|
|
776
|
+
*/
|
|
777
|
+
public async getCodeDsl(): Promise<CodeBlockDSL | null> {
|
|
778
|
+
const root = this.get<MApp | null>('root');
|
|
779
|
+
if (!root) return null;
|
|
780
|
+
return root.codeBlocks || null;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* 设置代码块到dsl的codeBlocks字段
|
|
785
|
+
* @param {CodeBlockDSL} codeDsl 代码DSL
|
|
786
|
+
* @returns {void}
|
|
787
|
+
*/
|
|
788
|
+
public async setCodeDsl(codeDsl: CodeBlockDSL): Promise<void> {
|
|
789
|
+
if (!this.state.root) return;
|
|
790
|
+
this.state.root.codeBlocks = codeDsl;
|
|
791
|
+
}
|
|
792
|
+
|
|
763
793
|
private addModifiedNodeId(id: Id) {
|
|
764
794
|
if (!this.isHistoryStateChange) {
|
|
765
795
|
this.get<Map<Id, Id>>('modifiedNodeIds').set(id, id);
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
.m-editor-code-block-list {
|
|
2
|
+
margin-top: 5px;
|
|
3
|
+
.el-tree-node__content {
|
|
4
|
+
height: auto;
|
|
5
|
+
}
|
|
6
|
+
.code-header-wrapper {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
.code-filter-input {
|
|
11
|
+
margin: 0 5px;
|
|
12
|
+
}
|
|
13
|
+
.code-filter-input-no-btn {
|
|
14
|
+
margin-left: 5px;
|
|
15
|
+
margin-right: 10px;
|
|
16
|
+
}
|
|
17
|
+
.create-code-button {
|
|
18
|
+
margin-left: 2px;
|
|
19
|
+
margin-right: 10px;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.divider {
|
|
24
|
+
margin: 10px 0 0 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.list-container {
|
|
28
|
+
width: 100%;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
margin-left: -25px;
|
|
31
|
+
.list-item {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
.right-tool {
|
|
35
|
+
position: absolute;
|
|
36
|
+
right: 15px;
|
|
37
|
+
padding-left: 5px;
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
.edit-icon {
|
|
41
|
+
margin: 0 5px;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
.code-name {
|
|
45
|
+
font-size: 14px;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
text-overflow: ellipsis;
|
|
49
|
+
padding: 10px 15px;
|
|
50
|
+
margin-right: 60px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
.code-comp-map-wrapper {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
flex-wrap: wrap;
|
|
57
|
+
margin-left: 20px;
|
|
58
|
+
margin-bottom: 5px;
|
|
59
|
+
.arrow-left {
|
|
60
|
+
transform: rotate(-45deg);
|
|
61
|
+
width: 20px;
|
|
62
|
+
height: 20px;
|
|
63
|
+
}
|
|
64
|
+
.code-comp {
|
|
65
|
+
margin-left: 5px;
|
|
66
|
+
padding: 5px;
|
|
67
|
+
.comp-delete-icon {
|
|
68
|
+
margin-left: 3px;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.m-fields-code-select {
|
|
76
|
+
width: 100%;
|
|
77
|
+
.el-card__body {
|
|
78
|
+
padding: 5px;
|
|
79
|
+
}
|
|
80
|
+
.tool-bar {
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: end;
|
|
84
|
+
height: 20px;
|
|
85
|
+
.tool-item {
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
.code-editor-dialog {
|
|
92
|
+
.el-dialog__body {
|
|
93
|
+
height: 90%;
|
|
94
|
+
padding-top: 10px;
|
|
95
|
+
}
|
|
96
|
+
.el-card {
|
|
97
|
+
height: 100%;
|
|
98
|
+
background: #fff;
|
|
99
|
+
.el-card__body {
|
|
100
|
+
height: calc(100% - 80px);
|
|
101
|
+
background: #fff;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.code-editor-layout {
|
|
106
|
+
height: 100%;
|
|
107
|
+
border: 1px solid #e4e7ed;
|
|
108
|
+
|
|
109
|
+
.side-tree {
|
|
110
|
+
height: 100%;
|
|
111
|
+
overflow: auto;
|
|
112
|
+
|
|
113
|
+
.list-container {
|
|
114
|
+
width: 100%;
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
margin-left: -10px;
|
|
117
|
+
.list-item {
|
|
118
|
+
width: 100%;
|
|
119
|
+
margin: 10px 0;
|
|
120
|
+
line-height: 30px;
|
|
121
|
+
.code-name {
|
|
122
|
+
width: 100%;
|
|
123
|
+
font-size: 14px;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
white-space: nowrap;
|
|
126
|
+
text-overflow: ellipsis;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.code-name-wrapper {
|
|
134
|
+
display: flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
font-size: 16px;
|
|
137
|
+
.code-name-label {
|
|
138
|
+
margin-right: 10px;
|
|
139
|
+
}
|
|
140
|
+
.code-name-input {
|
|
141
|
+
width: 300px;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.m-editor-code-block-editor-panel-list-mode {
|
|
146
|
+
height: 100%;
|
|
147
|
+
z-index: 10;
|
|
148
|
+
background: #fff;
|
|
149
|
+
.el-card {
|
|
150
|
+
border: 0;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.m-editor-code-block-editor-panel {
|
|
155
|
+
position: absolute;
|
|
156
|
+
top: 0;
|
|
157
|
+
left: 4px;
|
|
158
|
+
width: calc(100% - 9px);
|
|
159
|
+
height: 100%;
|
|
160
|
+
z-index: 10;
|
|
161
|
+
background: #fff;
|
|
162
|
+
.el-card {
|
|
163
|
+
border: 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.m-editor-wrapper {
|
|
168
|
+
height: 100%;
|
|
169
|
+
.m-editor-container {
|
|
170
|
+
height: calc(100% - 70px);
|
|
171
|
+
}
|
|
172
|
+
.m-editor-content-bottom {
|
|
173
|
+
height: 40px;
|
|
174
|
+
width: 100%;
|
|
175
|
+
display: flex;
|
|
176
|
+
justify-content: end;
|
|
177
|
+
background: #fff;
|
|
178
|
+
> button {
|
|
179
|
+
height: 30px;
|
|
180
|
+
margin-top: 15px;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
.ui-component-panel {
|
|
2
2
|
height: 100%;
|
|
3
3
|
border-top: 0 !important;
|
|
4
|
-
margin-top:
|
|
4
|
+
margin-top: 48px;
|
|
5
5
|
background-color: $--sidebar-content-background-color;
|
|
6
6
|
|
|
7
7
|
.search-input {
|
|
8
|
-
background: #
|
|
8
|
+
background: #fff;
|
|
9
9
|
color: #bbbbbb;
|
|
10
10
|
padding: 10px;
|
|
11
11
|
position: absolute;
|
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
z-index: 1;
|
|
16
16
|
|
|
17
17
|
.el-input__prefix {
|
|
18
|
-
padding:
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.el-input__suffix {
|
|
22
|
-
padding: 10px 5px;
|
|
18
|
+
padding: 7px;
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
21
|
|
package/src/theme/index.scss
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
1
|
@import "./common/var.scss";
|
|
2
|
-
@import "./
|
|
3
|
-
@import "./framework.scss";
|
|
4
|
-
@import "./sidebar.scss";
|
|
5
|
-
@import "./layer-panel.scss";
|
|
6
|
-
@import "./component-list-panel.scss";
|
|
7
|
-
@import "./resizer.scss";
|
|
8
|
-
@import "./workspace.scss";
|
|
9
|
-
@import "./page-bar.scss";
|
|
10
|
-
@import "./props-panel.scss";
|
|
11
|
-
@import "./content-menu.scss";
|
|
12
|
-
@import "./stage.scss";
|
|
13
|
-
@import "./code-editor.scss";
|
|
14
|
-
@import "./icon.scss";
|
|
2
|
+
@import "./theme.scss";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@import "./nav-menu.scss";
|
|
2
|
+
@import "./framework.scss";
|
|
3
|
+
@import "./sidebar.scss";
|
|
4
|
+
@import "./layer-panel.scss";
|
|
5
|
+
@import "./component-list-panel.scss";
|
|
6
|
+
@import "./resizer.scss";
|
|
7
|
+
@import "./workspace.scss";
|
|
8
|
+
@import "./page-bar.scss";
|
|
9
|
+
@import "./props-panel.scss";
|
|
10
|
+
@import "./content-menu.scss";
|
|
11
|
+
@import "./stage.scss";
|
|
12
|
+
@import "./code-editor.scss";
|
|
13
|
+
@import "./icon.scss";
|
|
14
|
+
@import "./code-block.scss";
|
|
15
|
+
@import "./layout.scss";
|
|
16
|
+
@import "./breadcrumb.scss";
|
package/src/type.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
|
23
23
|
import type StageCore from '@tmagic/stage';
|
|
24
24
|
import type { ContainerHighlightType, MoveableOptions } from '@tmagic/stage';
|
|
25
25
|
|
|
26
|
+
import type { CodeBlockService } from './services/codeBlock';
|
|
26
27
|
import type { ComponentListService } from './services/componentList';
|
|
27
28
|
import type { EditorService } from './services/editor';
|
|
28
29
|
import type { EventsService } from './services/events';
|
|
@@ -46,6 +47,7 @@ export interface Services {
|
|
|
46
47
|
propsService: PropsService;
|
|
47
48
|
componentListService: ComponentListService;
|
|
48
49
|
uiService: UiService;
|
|
50
|
+
codeBlockService: CodeBlockService;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export interface StageOptions {
|
|
@@ -198,6 +200,7 @@ export interface MenuComponent {
|
|
|
198
200
|
/** 是否显示,默认为true */
|
|
199
201
|
className?: string;
|
|
200
202
|
display?: boolean | ((data?: Services) => Promise<boolean> | boolean);
|
|
203
|
+
[key: string]: any;
|
|
201
204
|
}
|
|
202
205
|
|
|
203
206
|
/**
|
|
@@ -243,7 +246,7 @@ export interface SideComponent extends MenuComponent {
|
|
|
243
246
|
* component-list: 组件列表
|
|
244
247
|
* layer: 已选组件树
|
|
245
248
|
*/
|
|
246
|
-
export type SideItem = 'component-list' | 'layer' | SideComponent;
|
|
249
|
+
export type SideItem = 'component-list' | 'layer' | 'code-block' | SideComponent;
|
|
247
250
|
|
|
248
251
|
/** 工具栏 */
|
|
249
252
|
export interface SideBarData {
|
|
@@ -305,3 +308,87 @@ export interface ScrollViewerEvent {
|
|
|
305
308
|
scrollHeight: number;
|
|
306
309
|
scrollWidth: number;
|
|
307
310
|
}
|
|
311
|
+
|
|
312
|
+
export interface CodeBlockDSL {
|
|
313
|
+
[id: string]: CodeBlockContent;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface CodeBlockContent {
|
|
317
|
+
/** 代码块名称 */
|
|
318
|
+
name: string;
|
|
319
|
+
/** 代码块内容 */
|
|
320
|
+
content: string;
|
|
321
|
+
/** 代码块与组件的绑定关系 */
|
|
322
|
+
comps?: CodeRelation;
|
|
323
|
+
/** 扩展字段 */
|
|
324
|
+
[propName: string]: any;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export type CodeState = {
|
|
328
|
+
/** 是否展示代码块编辑区 */
|
|
329
|
+
isShowCodeEditor: boolean;
|
|
330
|
+
/** 代码块DSL数据源 */
|
|
331
|
+
codeDsl: CodeBlockDSL | null;
|
|
332
|
+
/** 当前选中的代码块id */
|
|
333
|
+
id: string;
|
|
334
|
+
/** 代码块是否可编辑 */
|
|
335
|
+
editable: boolean;
|
|
336
|
+
/** 代码编辑面板的展示模式 */
|
|
337
|
+
mode: CodeEditorMode;
|
|
338
|
+
/** list模式下左侧展示的代码列表 */
|
|
339
|
+
combineIds: string[];
|
|
340
|
+
/** 为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除) */
|
|
341
|
+
undeletableList: string[];
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export type CodeRelation = {
|
|
345
|
+
/** 组件id:['created'] */
|
|
346
|
+
[compId: string | number]: string[];
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export enum CodeEditorMode {
|
|
350
|
+
/** 左侧菜单,右侧代码 */
|
|
351
|
+
LIST = 'list',
|
|
352
|
+
/** 全屏代码 */
|
|
353
|
+
EDITOR = 'editor',
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface CodeDslList {
|
|
357
|
+
/** 代码块id */
|
|
358
|
+
id: string;
|
|
359
|
+
/** 代码块名称 */
|
|
360
|
+
name: string;
|
|
361
|
+
/** 代码块函数内容 */
|
|
362
|
+
codeBlockContent?: CodeBlockContent;
|
|
363
|
+
/** 是否展示代码绑定关系 */
|
|
364
|
+
showRelation?: boolean;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface ListState {
|
|
368
|
+
/** 代码块列表 */
|
|
369
|
+
codeList: CodeDslList[];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export interface ListRelationState extends ListState {
|
|
373
|
+
/** 与代码块绑定的组件id信息 */
|
|
374
|
+
bindComps: {
|
|
375
|
+
/** 代码块id : 组件信息 */
|
|
376
|
+
[id: string]: MNode[];
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export enum CodeDeleteErrorType {
|
|
381
|
+
/** 代码块存在于不可删除列表中 */
|
|
382
|
+
UNDELETEABLE = 'undeleteable',
|
|
383
|
+
/** 代码块存在绑定关系 */
|
|
384
|
+
BIND = 'bind',
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export enum CodeSelectOp {
|
|
388
|
+
/** 增加 */
|
|
389
|
+
ADD = 'add',
|
|
390
|
+
/** 删除 */
|
|
391
|
+
DELETE = 'delete',
|
|
392
|
+
/** 单选修改 */
|
|
393
|
+
CHANGE = 'change',
|
|
394
|
+
}
|
package/src/utils/props.ts
CHANGED
|
@@ -221,13 +221,19 @@ export const fillConfig = (config: FormConfig = []) => [
|
|
|
221
221
|
},
|
|
222
222
|
{
|
|
223
223
|
title: '高级',
|
|
224
|
-
|
|
224
|
+
lazy: true,
|
|
225
225
|
items: [
|
|
226
226
|
{
|
|
227
|
-
type: 'code-link',
|
|
228
227
|
name: 'created',
|
|
229
228
|
text: 'created',
|
|
230
|
-
|
|
229
|
+
type: 'code-select',
|
|
230
|
+
labelWidth: '100px',
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: 'mounted',
|
|
234
|
+
text: 'mounted',
|
|
235
|
+
type: 'code-select',
|
|
236
|
+
labelWidth: '100px',
|
|
231
237
|
},
|
|
232
238
|
],
|
|
233
239
|
},
|
|
@@ -4,6 +4,10 @@ interface ScrollViewerOptions {
|
|
|
4
4
|
container: HTMLDivElement;
|
|
5
5
|
target: HTMLDivElement;
|
|
6
6
|
zoom: number;
|
|
7
|
+
correctionScrollSize?: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export class ScrollViewer extends EventEmitter {
|
|
@@ -23,6 +27,11 @@ export class ScrollViewer extends EventEmitter {
|
|
|
23
27
|
private translateXCorrectionValue = 0;
|
|
24
28
|
private translateYCorrectionValue = 0;
|
|
25
29
|
|
|
30
|
+
private correctionScrollSize = {
|
|
31
|
+
width: 0,
|
|
32
|
+
height: 0,
|
|
33
|
+
};
|
|
34
|
+
|
|
26
35
|
private resizeObserver = new ResizeObserver(() => {
|
|
27
36
|
this.setSize();
|
|
28
37
|
this.setScrollSize();
|
|
@@ -35,6 +44,13 @@ export class ScrollViewer extends EventEmitter {
|
|
|
35
44
|
this.target = options.target;
|
|
36
45
|
this.zoom = options.zoom;
|
|
37
46
|
|
|
47
|
+
if (this.correctionScrollSize) {
|
|
48
|
+
this.correctionScrollSize = {
|
|
49
|
+
...this.correctionScrollSize,
|
|
50
|
+
...options.correctionScrollSize,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
38
54
|
this.container.addEventListener('wheel', this.wheelHandler, false);
|
|
39
55
|
|
|
40
56
|
this.setSize();
|
|
@@ -109,9 +125,9 @@ export class ScrollViewer extends EventEmitter {
|
|
|
109
125
|
|
|
110
126
|
private setScrollSize = () => {
|
|
111
127
|
const targetRect = this.target.getBoundingClientRect();
|
|
112
|
-
this.scrollWidth = targetRect.width * this.zoom +
|
|
128
|
+
this.scrollWidth = targetRect.width * this.zoom + this.correctionScrollSize.width;
|
|
113
129
|
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
114
|
-
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom +
|
|
130
|
+
this.scrollHeight = (targetRect.height + targetMarginTop) * this.zoom + this.correctionScrollSize.height;
|
|
115
131
|
|
|
116
132
|
let left: number | undefined;
|
|
117
133
|
let top: number | undefined;
|
package/src/utils/stage.ts
CHANGED
|
@@ -46,6 +46,7 @@ export const useStage = (stageOptions: StageOptions) => {
|
|
|
46
46
|
]);
|
|
47
47
|
|
|
48
48
|
stage.on('select', (el: HTMLElement) => {
|
|
49
|
+
if (`${editorService.get('node')?.id}` === el.id && editorService.get('nodes').length === 1) return;
|
|
49
50
|
editorService.select(el.id);
|
|
50
51
|
});
|
|
51
52
|
|
|
@@ -72,6 +73,12 @@ export const useStage = (stageOptions: StageOptions) => {
|
|
|
72
73
|
editorService.sort(ev.src, ev.dist);
|
|
73
74
|
});
|
|
74
75
|
|
|
76
|
+
stage.on('select-parent', () => {
|
|
77
|
+
const parent = editorService.get('parent');
|
|
78
|
+
editorService.select(parent);
|
|
79
|
+
editorService.get<StageCore>('stage').select(parent.id);
|
|
80
|
+
});
|
|
81
|
+
|
|
75
82
|
stage.on('changeGuides', (e) => {
|
|
76
83
|
uiService.set('showGuides', true);
|
|
77
84
|
|
package/types/Editor.vue.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
97
97
|
updateDragEl: {
|
|
98
98
|
type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
|
|
99
99
|
};
|
|
100
|
-
}, Services, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("props-panel-mounted"
|
|
100
|
+
}, Services, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "props-panel-mounted")[], "update:modelValue" | "props-panel-mounted", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
101
101
|
/** 页面初始值 */
|
|
102
102
|
modelValue: {
|
|
103
103
|
type: PropType<MApp>;
|
|
@@ -191,8 +191,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
191
191
|
type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
|
|
192
192
|
};
|
|
193
193
|
}>> & {
|
|
194
|
-
"onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
|
|
195
194
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
195
|
+
"onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
|
|
196
196
|
}, {
|
|
197
197
|
menu: MenuBarData;
|
|
198
198
|
codeOptions: Record<string, any>;
|
|
@@ -96,9 +96,7 @@ declare const _default: {
|
|
|
96
96
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("hide" | "show")[], "hide" | "show", {
|
|
97
97
|
menuData: (MenuButton | MenuComponent)[];
|
|
98
98
|
isSubMenu: boolean;
|
|
99
|
-
}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps
|
|
100
|
-
$slots: {};
|
|
101
|
-
});
|
|
99
|
+
}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
|
|
102
100
|
export default _default;
|
|
103
101
|
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
104
102
|
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
@@ -48,9 +48,7 @@ declare const _default: {
|
|
|
48
48
|
__isSuspense?: undefined;
|
|
49
49
|
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
50
50
|
icon?: any;
|
|
51
|
-
}>>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps
|
|
52
|
-
$slots: {};
|
|
53
|
-
});
|
|
51
|
+
}>>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
|
|
54
52
|
export default _default;
|
|
55
53
|
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
56
54
|
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
File without changes
|
|
@@ -68,9 +68,7 @@ declare const _default: {
|
|
|
68
68
|
pos: number;
|
|
69
69
|
}>>> & {
|
|
70
70
|
onScroll?: ((...args: any[]) => any) | undefined;
|
|
71
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "scroll"[], "scroll", {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps
|
|
72
|
-
$slots: {};
|
|
73
|
-
});
|
|
71
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "scroll"[], "scroll", {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
|
|
74
72
|
export default _default;
|
|
75
73
|
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
76
74
|
declare type __VLS_TypePropsToRuntimeProps<T> = {
|