@tmagic/editor 1.3.0-alpha.9 → 1.3.0-beta.1
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 +106 -219
- package/dist/tmagic-editor.js +6253 -5042
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +6280 -5055
- 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 +266 -0
- package/src/components/CodeParams.vue +60 -0
- package/src/components/ContentMenu.vue +97 -43
- package/src/components/Resizer.vue +8 -30
- package/src/components/SplitView.vue +3 -2
- 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 +38 -22
- package/src/fields/DataSourceInput.vue +21 -58
- package/src/fields/DataSourceMethodSelect.vue +136 -0
- package/src/fields/DataSourceMethods.vue +104 -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/hooks/use-getso.ts +35 -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/icons/PinIcon.vue +25 -0
- package/src/icons/PinnedIcon.vue +25 -0
- package/src/index.ts +14 -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/Workspace.vue +1 -1
- package/src/layouts/workspace/viewer/NodeListMenu.vue +159 -0
- package/src/layouts/workspace/viewer/NodeListMenuTitle.vue +68 -0
- package/src/layouts/workspace/{Stage.vue → viewer/Stage.vue} +5 -2
- package/src/layouts/workspace/{ViewerMenu.vue → viewer/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 +26 -2
- 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/index.scss +8 -0
- 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 +49 -7
- package/src/utils/content-menu.ts +92 -0
- package/src/utils/data-source/formConfigs/base.ts +28 -30
- package/src/utils/data-source/formConfigs/http.ts +9 -0
- 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 +308 -189
- package/src/utils/undo-redo.ts +1 -1
- package/types/Editor.vue.d.ts +30 -6
- package/types/components/CodeBlockEditor.vue.d.ts +25 -0
- package/types/components/CodeParams.vue.d.ts +26 -0
- package/types/components/ContentMenu.vue.d.ts +27 -8
- package/types/components/Resizer.vue.d.ts +1 -3
- 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} +36 -119
- package/types/hooks/use-data-source-method.d.ts +130 -0
- package/types/hooks/use-getso.d.ts +5 -0
- package/types/icons/CenterIcon.vue.d.ts +2 -0
- package/types/icons/FolderMinusIcon.vue.d.ts +2 -0
- package/types/icons/PinIcon.vue.d.ts +2 -0
- package/types/icons/PinnedIcon.vue.d.ts +2 -0
- package/types/index.d.ts +7 -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/layouts/workspace/viewer/NodeListMenu.vue.d.ts +15 -0
- package/types/layouts/workspace/viewer/NodeListMenuTitle.vue.d.ts +15 -0
- package/types/layouts/workspace/{Stage.vue.d.ts → viewer/Stage.vue.d.ts} +1 -1
- package/types/layouts/workspace/{ViewerMenu.vue.d.ts → viewer/ViewerMenu.vue.d.ts} +1 -1
- 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 +44 -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
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
import { reactive } from 'vue';
|
|
20
20
|
import { keys, pick } from 'lodash-es';
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import type { ColumnConfig } from '@tmagic/form';
|
|
23
|
+
import type { CodeBlockContent, CodeBlockDSL, Id } from '@tmagic/schema';
|
|
23
24
|
|
|
24
25
|
import type { CodeState } from '@editor/type';
|
|
25
26
|
import { CODE_DRAFT_STORAGE_KEY } from '@editor/type';
|
|
@@ -29,23 +30,15 @@ import BaseService from './BaseService';
|
|
|
29
30
|
|
|
30
31
|
class CodeBlock extends BaseService {
|
|
31
32
|
private state = reactive<CodeState>({
|
|
32
|
-
isShowCodeEditor: false,
|
|
33
33
|
codeDsl: null,
|
|
34
|
-
id: '',
|
|
35
34
|
editable: true,
|
|
36
35
|
combineIds: [],
|
|
37
36
|
undeletableList: [],
|
|
37
|
+
paramsColConfig: undefined,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
constructor() {
|
|
41
|
-
super([
|
|
42
|
-
'setCodeDslById',
|
|
43
|
-
'setCodeEditorShowStatus',
|
|
44
|
-
'setEditStatus',
|
|
45
|
-
'setCombineIds',
|
|
46
|
-
'setUndeleteableList',
|
|
47
|
-
'deleteCodeDslByIds',
|
|
48
|
-
]);
|
|
41
|
+
super(['setCodeDslById', 'setEditStatus', 'setCombineIds', 'setUndeleteableList', 'deleteCodeDslByIds']);
|
|
49
42
|
}
|
|
50
43
|
|
|
51
44
|
/**
|
|
@@ -86,7 +79,7 @@ class CodeBlock extends BaseService {
|
|
|
86
79
|
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
87
80
|
* @returns {void}
|
|
88
81
|
*/
|
|
89
|
-
public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
|
|
82
|
+
public async setCodeDslById(id: Id, codeConfig: Partial<CodeBlockContent>): Promise<void> {
|
|
90
83
|
const codeDsl = this.getCodeDsl();
|
|
91
84
|
|
|
92
85
|
if (!codeDsl) {
|
|
@@ -97,7 +90,10 @@ class CodeBlock extends BaseService {
|
|
|
97
90
|
if (codeConfig.content) {
|
|
98
91
|
// 在保存的时候转换代码内容
|
|
99
92
|
const parseDSL = getConfig('parseDSL');
|
|
100
|
-
|
|
93
|
+
if (typeof codeConfig.content === 'string') {
|
|
94
|
+
codeConfig.content = parseDSL<(...args: any[]) => any>(codeConfig.content);
|
|
95
|
+
}
|
|
96
|
+
codeConfigProcessed.content = codeConfig.content;
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
const existContent = codeDsl[id] || {};
|
|
@@ -120,43 +116,6 @@ class CodeBlock extends BaseService {
|
|
|
120
116
|
return pick(codeDsl, ids) as CodeBlockDSL;
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
/**
|
|
124
|
-
* 设置代码编辑面板展示状态
|
|
125
|
-
* @param {boolean} status 是否展示代码编辑面板
|
|
126
|
-
* @returns {void}
|
|
127
|
-
*/
|
|
128
|
-
public async setCodeEditorShowStatus(status: boolean): Promise<void> {
|
|
129
|
-
this.state.isShowCodeEditor = status;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 获取代码编辑面板展示状态
|
|
134
|
-
* @returns {boolean} 是否展示代码编辑面板
|
|
135
|
-
*/
|
|
136
|
-
public getCodeEditorShowStatus(): boolean {
|
|
137
|
-
return this.state.isShowCodeEditor;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* 设置代码编辑面板展示状态及展示内容
|
|
142
|
-
* @param {boolean} status 是否展示代码编辑面板
|
|
143
|
-
* @param {Id} id 代码块id
|
|
144
|
-
* @returns {void}
|
|
145
|
-
*/
|
|
146
|
-
public setCodeEditorContent(status: boolean, id: Id): void {
|
|
147
|
-
if (!id) return;
|
|
148
|
-
this.setId(id);
|
|
149
|
-
this.state.isShowCodeEditor = status;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* 获取当前选中的代码块内容
|
|
154
|
-
* @returns {CodeBlockContent | null}
|
|
155
|
-
*/
|
|
156
|
-
public getCurrentDsl(): CodeBlockContent | null {
|
|
157
|
-
return this.getCodeContentById(this.state.id);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
119
|
/**
|
|
161
120
|
* 获取编辑状态
|
|
162
121
|
* @returns {boolean} 是否可编辑
|
|
@@ -174,24 +133,6 @@ class CodeBlock extends BaseService {
|
|
|
174
133
|
this.state.editable = status;
|
|
175
134
|
}
|
|
176
135
|
|
|
177
|
-
/**
|
|
178
|
-
* 设置当前选中的代码块ID
|
|
179
|
-
* @param {Id} id 代码块id
|
|
180
|
-
* @returns {void}
|
|
181
|
-
*/
|
|
182
|
-
public setId(id: Id): void {
|
|
183
|
-
if (!id) return;
|
|
184
|
-
this.state.id = id;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* 获取当前选中的代码块ID
|
|
189
|
-
* @returns {Id} id 代码块id
|
|
190
|
-
*/
|
|
191
|
-
public getId(): Id {
|
|
192
|
-
return this.state.id;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
136
|
/**
|
|
196
137
|
* 设置当前选中组件已关联绑定的代码块id数组
|
|
197
138
|
* @param {string[]} ids 代码块id数组
|
|
@@ -263,11 +204,19 @@ class CodeBlock extends BaseService {
|
|
|
263
204
|
});
|
|
264
205
|
}
|
|
265
206
|
|
|
207
|
+
public setParamsColConfig(config: ColumnConfig): void {
|
|
208
|
+
this.state.paramsColConfig = config;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public getParamsColConfig(): ColumnConfig | undefined {
|
|
212
|
+
return this.state.paramsColConfig;
|
|
213
|
+
}
|
|
214
|
+
|
|
266
215
|
/**
|
|
267
216
|
* 生成代码块唯一id
|
|
268
217
|
* @returns {Id} 代码块唯一id
|
|
269
218
|
*/
|
|
270
|
-
public async getUniqueId(): Promise<
|
|
219
|
+
public async getUniqueId(): Promise<string> {
|
|
271
220
|
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
272
221
|
// 判断是否重复
|
|
273
222
|
const dsl = await this.getCodeDsl();
|
|
@@ -277,9 +226,7 @@ class CodeBlock extends BaseService {
|
|
|
277
226
|
}
|
|
278
227
|
|
|
279
228
|
public resetState() {
|
|
280
|
-
this.state.isShowCodeEditor = false;
|
|
281
229
|
this.state.codeDsl = null;
|
|
282
|
-
this.state.id = '';
|
|
283
230
|
this.state.editable = true;
|
|
284
231
|
this.state.combineIds = [];
|
|
285
232
|
this.state.undeletableList = [];
|
|
@@ -2,23 +2,30 @@ import { reactive } from 'vue';
|
|
|
2
2
|
import { cloneDeep } from 'lodash-es';
|
|
3
3
|
|
|
4
4
|
import type { FormConfig } from '@tmagic/form';
|
|
5
|
-
import { DataSourceSchema } from '@tmagic/schema';
|
|
5
|
+
import type { DataSourceSchema } from '@tmagic/schema';
|
|
6
6
|
import { guid } from '@tmagic/utils';
|
|
7
7
|
|
|
8
|
+
import type { DatasourceTypeOption } from '@editor/type';
|
|
8
9
|
import { getFormConfig } from '@editor/utils/data-source';
|
|
9
10
|
|
|
10
11
|
import BaseService from './BaseService';
|
|
11
12
|
|
|
12
13
|
interface State {
|
|
14
|
+
datasourceTypeList: DatasourceTypeOption[];
|
|
13
15
|
dataSources: DataSourceSchema[];
|
|
16
|
+
editable: boolean;
|
|
14
17
|
configs: Record<string, FormConfig>;
|
|
18
|
+
values: Record<string, Partial<DataSourceSchema>>;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
type StateKey = keyof State;
|
|
18
22
|
class DataSource extends BaseService {
|
|
19
23
|
private state = reactive<State>({
|
|
24
|
+
datasourceTypeList: [],
|
|
20
25
|
dataSources: [],
|
|
26
|
+
editable: true,
|
|
21
27
|
configs: {},
|
|
28
|
+
values: {},
|
|
22
29
|
});
|
|
23
30
|
|
|
24
31
|
public set<K extends StateKey, T extends State[K]>(name: K, value: T) {
|
|
@@ -37,6 +44,14 @@ class DataSource extends BaseService {
|
|
|
37
44
|
this.get('configs')[type] = config;
|
|
38
45
|
}
|
|
39
46
|
|
|
47
|
+
public getFormValue(type = 'base') {
|
|
48
|
+
return this.get('values')[type];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public setFormValue(type: string, value: Partial<DataSourceSchema>) {
|
|
52
|
+
this.get('values')[type] = value;
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
public add(config: DataSourceSchema) {
|
|
41
56
|
const newConfig = {
|
|
42
57
|
...config,
|
package/src/services/dep.ts
CHANGED
|
@@ -19,27 +19,24 @@ import { EventEmitter } from 'events';
|
|
|
19
19
|
|
|
20
20
|
import { reactive } from 'vue';
|
|
21
21
|
|
|
22
|
-
import { MNode } from '@tmagic/schema';
|
|
22
|
+
import type { Dep, Id, MNode } from '@tmagic/schema';
|
|
23
|
+
import { isObject } from '@tmagic/utils';
|
|
24
|
+
|
|
25
|
+
import { DepTargetType } from '@editor/type';
|
|
23
26
|
|
|
24
27
|
type IsTarget = (key: string | number, value: any) => boolean;
|
|
25
28
|
|
|
26
29
|
interface TargetOptions {
|
|
27
30
|
isTarget: IsTarget;
|
|
28
31
|
id: string | number;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
interface Dep {
|
|
34
|
-
[key: string | number]: {
|
|
35
|
-
name: string;
|
|
36
|
-
keys: (string | number)[];
|
|
37
|
-
};
|
|
32
|
+
/** 类型,数据源、代码块或其他 */
|
|
33
|
+
type?: DepTargetType | string;
|
|
34
|
+
name?: string;
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
interface TargetList {
|
|
41
|
-
[
|
|
42
|
-
[
|
|
38
|
+
[type: DepTargetType | string]: {
|
|
39
|
+
[targetId: string | number]: Target;
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
42
|
|
|
@@ -60,11 +57,11 @@ export class Target extends EventEmitter {
|
|
|
60
57
|
/**
|
|
61
58
|
* 目标名称,用于显示在依赖列表中
|
|
62
59
|
*/
|
|
63
|
-
public name
|
|
60
|
+
public name?: string;
|
|
64
61
|
/**
|
|
65
62
|
* 不同的目标可以进行分类,例如代码块,数据源可以为两个不同的type
|
|
66
63
|
*/
|
|
67
|
-
public type =
|
|
64
|
+
public type: DepTargetType | string = DepTargetType.DEFAULT;
|
|
68
65
|
/**
|
|
69
66
|
* 依赖详情
|
|
70
67
|
* 实例:{ 'node_id': { name: 'node_name', keys: [ created, mounted ] } }
|
|
@@ -156,14 +153,14 @@ export class Target extends EventEmitter {
|
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
export class Watcher extends EventEmitter {
|
|
159
|
-
|
|
156
|
+
private targets = reactive<TargetList>({});
|
|
160
157
|
|
|
161
158
|
/**
|
|
162
159
|
* 获取指定类型中的所有target
|
|
163
160
|
* @param type 分类
|
|
164
161
|
* @returns Target[]
|
|
165
162
|
*/
|
|
166
|
-
public getTargets(type =
|
|
163
|
+
public getTargets(type: DepTargetType | string = DepTargetType.DEFAULT) {
|
|
167
164
|
return this.targets[type] || {};
|
|
168
165
|
}
|
|
169
166
|
|
|
@@ -230,7 +227,7 @@ export class Watcher extends EventEmitter {
|
|
|
230
227
|
* @param type 分类
|
|
231
228
|
* @returns void
|
|
232
229
|
*/
|
|
233
|
-
public removeTargets(type =
|
|
230
|
+
public removeTargets(type: DepTargetType | string = DepTargetType.DEFAULT) {
|
|
234
231
|
const targets = this.targets[type];
|
|
235
232
|
|
|
236
233
|
if (!targets) return;
|
|
@@ -277,13 +274,15 @@ export class Watcher extends EventEmitter {
|
|
|
277
274
|
* @param nodes 需要清除依赖的节点
|
|
278
275
|
*/
|
|
279
276
|
public clear(nodes?: MNode[]) {
|
|
277
|
+
const clearedItemsNodeIds: Id[] = [];
|
|
280
278
|
Object.values(this.targets).forEach((targets) => {
|
|
281
279
|
Object.values(targets).forEach((target) => {
|
|
282
280
|
if (nodes) {
|
|
283
281
|
nodes.forEach((node) => {
|
|
284
282
|
target.removeDep(node);
|
|
285
283
|
|
|
286
|
-
if (Array.isArray(node.items)) {
|
|
284
|
+
if (Array.isArray(node.items) && node.items.length && !clearedItemsNodeIds.includes(node.id)) {
|
|
285
|
+
clearedItemsNodeIds.push(node.id);
|
|
287
286
|
this.clear(node.items);
|
|
288
287
|
}
|
|
289
288
|
});
|
|
@@ -305,9 +304,11 @@ export class Watcher extends EventEmitter {
|
|
|
305
304
|
this.emit('update-dep', node, fullKey);
|
|
306
305
|
} else if (!keyIsItems && Array.isArray(value)) {
|
|
307
306
|
value.forEach((item, index) => {
|
|
308
|
-
|
|
307
|
+
if (isObject(item)) {
|
|
308
|
+
collectTarget(item, `${fullKey}.${index}`);
|
|
309
|
+
}
|
|
309
310
|
});
|
|
310
|
-
} else if (
|
|
311
|
+
} else if (isObject(value)) {
|
|
311
312
|
collectTarget(value, fullKey);
|
|
312
313
|
}
|
|
313
314
|
|
|
@@ -319,6 +320,7 @@ export class Watcher extends EventEmitter {
|
|
|
319
320
|
};
|
|
320
321
|
|
|
321
322
|
Object.entries(config).forEach(([key, value]) => {
|
|
323
|
+
if (typeof value === 'undefined' || value === '') return;
|
|
322
324
|
doCollect(key, value);
|
|
323
325
|
});
|
|
324
326
|
};
|
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
|
}
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
font-size: 12px;
|
|
4
4
|
background: #fff;
|
|
5
5
|
box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);
|
|
6
|
-
z-index:
|
|
6
|
+
z-index: 1000;
|
|
7
7
|
transform-origin: 0% 0%;
|
|
8
8
|
font-weight: 600;
|
|
9
9
|
padding: 4px 0px;
|
|
10
10
|
overflow: auto;
|
|
11
|
-
max-height:
|
|
11
|
+
max-height: 80%;
|
|
12
|
+
min-width: 180px;
|
|
12
13
|
|
|
13
14
|
.menu-item {
|
|
14
15
|
color: #333;
|
|
@@ -43,8 +44,31 @@
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
&.active {
|
|
48
|
+
background-color: $--theme-color;
|
|
49
|
+
.tmagic-design-button,
|
|
50
|
+
.tmagic-design-button:active,
|
|
51
|
+
.tmagic-design-button:focus {
|
|
52
|
+
color: #fff;
|
|
53
|
+
background-color: $--theme-color;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&.menu-item i {
|
|
57
|
+
color: #fff;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
46
61
|
&:hover {
|
|
47
62
|
background-color: $--hover-color;
|
|
63
|
+
.tmagic-design-button,
|
|
64
|
+
.tmagic-design-button:active,
|
|
65
|
+
.tmagic-design-button:focus {
|
|
66
|
+
color: $--font-color;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&.menu-item i {
|
|
70
|
+
color: $--font-color;
|
|
71
|
+
}
|
|
48
72
|
}
|
|
49
73
|
}
|
|
50
74
|
}
|