@tmagic/editor 1.0.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 +505 -0
- package/dist/tmagic-editor.es.js +4233 -0
- package/dist/tmagic-editor.es.js.map +1 -0
- package/dist/tmagic-editor.umd.js +4276 -0
- package/dist/tmagic-editor.umd.js.map +1 -0
- package/dist/types/src/Editor.vue.d.ts +136 -0
- package/dist/types/src/components/Icon.vue.d.ts +13 -0
- package/dist/types/src/components/ToolButton.vue.d.ts +35 -0
- package/dist/types/src/fields/Code.vue.d.ts +24 -0
- package/dist/types/src/fields/CodeLink.vue.d.ts +54 -0
- package/dist/types/src/fields/UISelect.vue.d.ts +32 -0
- package/dist/types/src/index.d.ts +19 -0
- package/dist/types/src/layouts/AddPageBox.vue.d.ts +5 -0
- package/dist/types/src/layouts/CodeEditor.vue.d.ts +46 -0
- package/dist/types/src/layouts/Framework.vue.d.ts +11 -0
- package/dist/types/src/layouts/NavMenu.vue.d.ts +24 -0
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +13 -0
- package/dist/types/src/layouts/Resizer.vue.d.ts +13 -0
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +12 -0
- package/dist/types/src/layouts/sidebar/LayerMenu.vue.d.ts +31 -0
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +973 -0
- package/dist/types/src/layouts/sidebar/Sidebar.vue.d.ts +27 -0
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +11 -0
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +153 -0
- package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +18 -0
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +37 -0
- package/dist/types/src/services/BaseService.d.ts +56 -0
- package/dist/types/src/services/editor.d.ts +122 -0
- package/dist/types/src/services/events.d.ts +16 -0
- package/dist/types/src/services/history.d.ts +51 -0
- package/dist/types/src/services/props.d.ts +36 -0
- package/dist/types/src/services/ui.d.ts +26 -0
- package/dist/types/src/shims-vue.d.ts +6 -0
- package/dist/types/src/type.d.ts +183 -0
- package/dist/types/src/utils/compose.d.ts +5 -0
- package/dist/types/src/utils/config.d.ts +4 -0
- package/dist/types/src/utils/editor.d.ts +45 -0
- package/dist/types/src/utils/index.d.ts +4 -0
- package/dist/types/src/utils/logger.d.ts +5 -0
- package/dist/types/src/utils/props.d.ts +49 -0
- package/dist/types/src/utils/undo-redo.d.ts +12 -0
- package/dist/types/src/vite-env.d.ts +1 -0
- package/package.json +57 -0
- package/src/Editor.vue +234 -0
- package/src/components/Icon.vue +29 -0
- package/src/components/ToolButton.vue +188 -0
- package/src/fields/Code.vue +35 -0
- package/src/fields/CodeLink.vue +81 -0
- package/src/fields/UISelect.vue +100 -0
- package/src/index.ts +63 -0
- package/src/layouts/AddPageBox.vue +41 -0
- package/src/layouts/CodeEditor.vue +188 -0
- package/src/layouts/Framework.vue +73 -0
- package/src/layouts/NavMenu.vue +37 -0
- package/src/layouts/PropsPanel.vue +81 -0
- package/src/layouts/Resizer.vue +61 -0
- package/src/layouts/sidebar/ComponentListPanel.vue +69 -0
- package/src/layouts/sidebar/LayerMenu.vue +117 -0
- package/src/layouts/sidebar/LayerPanel.vue +209 -0
- package/src/layouts/sidebar/Sidebar.vue +86 -0
- package/src/layouts/workspace/PageBar.vue +83 -0
- package/src/layouts/workspace/Stage.vue +221 -0
- package/src/layouts/workspace/ViewerMenu.vue +110 -0
- package/src/layouts/workspace/Workspace.vue +98 -0
- package/src/services/BaseService.ts +138 -0
- package/src/services/componentList.ts +48 -0
- package/src/services/editor.ts +521 -0
- package/src/services/events.ts +82 -0
- package/src/services/history.ts +124 -0
- package/src/services/props.ts +110 -0
- package/src/services/ui.ts +101 -0
- package/src/shims-vue.d.ts +6 -0
- package/src/theme/code-editor.scss +7 -0
- package/src/theme/common/var.scss +13 -0
- package/src/theme/component-list-panel.scss +102 -0
- package/src/theme/content-menu.scss +39 -0
- package/src/theme/framework.scss +72 -0
- package/src/theme/index.scss +13 -0
- package/src/theme/layer-panel.scss +68 -0
- package/src/theme/nav-menu.scss +69 -0
- package/src/theme/page-bar.scss +31 -0
- package/src/theme/props-panel.scss +17 -0
- package/src/theme/resizer.scss +51 -0
- package/src/theme/ruler.scss +38 -0
- package/src/theme/sidebar.scss +97 -0
- package/src/theme/stage.scss +22 -0
- package/src/theme/workspace.scss +5 -0
- package/src/type.ts +236 -0
- package/src/utils/compose.ts +33 -0
- package/src/utils/config.ts +29 -0
- package/src/utils/editor.ts +244 -0
- package/src/utils/index.ts +22 -0
- package/src/utils/logger.ts +47 -0
- package/src/utils/props.ts +218 -0
- package/src/utils/undo-redo.ts +76 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +9 -0
- package/vite.config.ts +30 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { reactive } from 'vue';
|
|
20
|
+
import { cloneDeep } from 'lodash-es';
|
|
21
|
+
|
|
22
|
+
import { DEFAULT_EVENTS, DEFAULT_METHODS, EventOption } from '@tmagic/core';
|
|
23
|
+
import { toLine } from '@tmagic/utils';
|
|
24
|
+
|
|
25
|
+
import type { ComponentGroup } from '@editor/type';
|
|
26
|
+
|
|
27
|
+
import BaseService from './BaseService';
|
|
28
|
+
|
|
29
|
+
const eventMap: Record<string, EventOption[]> = reactive({});
|
|
30
|
+
const methodMap: Record<string, EventOption[]> = reactive({});
|
|
31
|
+
|
|
32
|
+
class Events extends BaseService {
|
|
33
|
+
constructor() {
|
|
34
|
+
super([]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public init(componentGroupList: ComponentGroup[]) {
|
|
38
|
+
componentGroupList.forEach((group) => {
|
|
39
|
+
group.items.forEach((element) => {
|
|
40
|
+
const type = toLine(element.type);
|
|
41
|
+
if (!this.getEvent(type)) {
|
|
42
|
+
this.setEvent(type, DEFAULT_EVENTS);
|
|
43
|
+
}
|
|
44
|
+
if (!this.getMethod(type)) {
|
|
45
|
+
this.setMethod(type, DEFAULT_METHODS);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public setEvents(events: Record<string, EventOption[]>) {
|
|
52
|
+
Object.keys(events).forEach((type: string) => {
|
|
53
|
+
this.setEvent(toLine(type), events[type] || []);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public setEvent(type: string, events: EventOption[]) {
|
|
58
|
+
eventMap[type] = [...DEFAULT_EVENTS, ...events];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public getEvent(type: string): EventOption[] {
|
|
62
|
+
return cloneDeep(eventMap[type] || DEFAULT_EVENTS);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public setMethods(methods: Record<string, EventOption[]>) {
|
|
66
|
+
Object.keys(methods).forEach((type: string) => {
|
|
67
|
+
this.setMethod(toLine(type), methods[type] || []);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public setMethod(type: string, method: EventOption[]) {
|
|
72
|
+
methodMap[type] = [...DEFAULT_METHODS, ...method];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public getMethod(type: string) {
|
|
76
|
+
return cloneDeep(methodMap[type] || DEFAULT_METHODS);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type EventsService = Events;
|
|
81
|
+
|
|
82
|
+
export default new Events();
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { reactive } from 'vue';
|
|
20
|
+
|
|
21
|
+
import { Id, MPage } from '@tmagic/schema';
|
|
22
|
+
|
|
23
|
+
import { UndoRedo } from '@editor/utils/undo-redo';
|
|
24
|
+
|
|
25
|
+
import BaseService from './BaseService';
|
|
26
|
+
|
|
27
|
+
export interface StepValue {
|
|
28
|
+
data: MPage;
|
|
29
|
+
modifiedNodeIds: Map<Id, Id>;
|
|
30
|
+
nodeId: Id;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface HistoryState {
|
|
34
|
+
pageId?: Id;
|
|
35
|
+
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
|
36
|
+
canRedo: boolean;
|
|
37
|
+
canUndo: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class History extends BaseService {
|
|
41
|
+
public state = reactive<HistoryState>({
|
|
42
|
+
pageSteps: {},
|
|
43
|
+
pageId: undefined,
|
|
44
|
+
canRedo: false,
|
|
45
|
+
canUndo: false,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
super([]);
|
|
50
|
+
|
|
51
|
+
this.on('change', this.setCanUndoRedo);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public changePage(page: MPage): void {
|
|
55
|
+
if (!page) return;
|
|
56
|
+
|
|
57
|
+
this.state.pageId = page.id;
|
|
58
|
+
|
|
59
|
+
if (!this.state.pageSteps[this.state.pageId]) {
|
|
60
|
+
const undoRedo = new UndoRedo<StepValue>();
|
|
61
|
+
|
|
62
|
+
undoRedo.pushElement({
|
|
63
|
+
data: page,
|
|
64
|
+
modifiedNodeIds: new Map(),
|
|
65
|
+
nodeId: page.id,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
this.state.pageSteps[this.state.pageId] = undoRedo;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.setCanUndoRedo();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public empty(): void {
|
|
75
|
+
this.state.pageId = undefined;
|
|
76
|
+
this.state.pageSteps = {};
|
|
77
|
+
this.state.canRedo = false;
|
|
78
|
+
this.state.canUndo = false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public push(state: StepValue): StepValue | null {
|
|
82
|
+
const undoRedo = this.getUndoRedo();
|
|
83
|
+
if (!undoRedo) return null;
|
|
84
|
+
undoRedo.pushElement(state);
|
|
85
|
+
this.emit('change', state);
|
|
86
|
+
return state;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public undo(): StepValue | null {
|
|
90
|
+
const undoRedo = this.getUndoRedo();
|
|
91
|
+
if (!undoRedo) return null;
|
|
92
|
+
const state = undoRedo.undo();
|
|
93
|
+
this.emit('change', state);
|
|
94
|
+
return state;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public redo(): StepValue | null {
|
|
98
|
+
const undoRedo = this.getUndoRedo();
|
|
99
|
+
if (!undoRedo) return null;
|
|
100
|
+
const state = undoRedo.redo();
|
|
101
|
+
this.emit('change', state);
|
|
102
|
+
return state;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public destroy(): void {
|
|
106
|
+
this.empty();
|
|
107
|
+
this.removeAllListeners();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private getUndoRedo() {
|
|
111
|
+
if (!this.state.pageId) return null;
|
|
112
|
+
return this.state.pageSteps[this.state.pageId];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private setCanUndoRedo(): void {
|
|
116
|
+
const undoRedo = this.getUndoRedo();
|
|
117
|
+
this.state.canRedo = undoRedo?.canRedo() || false;
|
|
118
|
+
this.state.canUndo = undoRedo?.canUndo() || false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type HistoryService = History;
|
|
123
|
+
|
|
124
|
+
export default new History();
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { reactive } from 'vue';
|
|
20
|
+
import { cloneDeep } from 'lodash-es';
|
|
21
|
+
|
|
22
|
+
import type { FormConfig } from '@tmagic/form';
|
|
23
|
+
import type { MComponent, MNode } from '@tmagic/schema';
|
|
24
|
+
import { toLine } from '@tmagic/utils';
|
|
25
|
+
|
|
26
|
+
import type { PropsState } from '@editor/type';
|
|
27
|
+
import { DEFAULT_CONFIG, fillConfig, getDefaultPropsValue } from '@editor/utils/props';
|
|
28
|
+
|
|
29
|
+
import BaseService from './BaseService';
|
|
30
|
+
|
|
31
|
+
class Props extends BaseService {
|
|
32
|
+
private state = reactive<PropsState>({
|
|
33
|
+
propsConfigMap: {},
|
|
34
|
+
propsValueMap: {},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
super(['setPropsConfig', 'getPropsConfig', 'setPropsValue', 'getPropsValue']);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public setPropsConfigs(configs: Record<string, FormConfig>) {
|
|
42
|
+
Object.keys(configs).forEach((type: string) => {
|
|
43
|
+
this.setPropsConfig(toLine(type), configs[type]);
|
|
44
|
+
});
|
|
45
|
+
this.emit('props-configs-change');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 为指定类型组件设置组件属性表单配置
|
|
50
|
+
* @param type 组件类型
|
|
51
|
+
* @param config 组件属性表单配置
|
|
52
|
+
*/
|
|
53
|
+
public setPropsConfig(type: string, config: FormConfig) {
|
|
54
|
+
this.state.propsConfigMap[type] = fillConfig(Array.isArray(config) ? config : [config]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 获取指点类型的组件属性表单配置
|
|
59
|
+
* @param type 组件类型
|
|
60
|
+
* @returns 组件属性表单配置
|
|
61
|
+
*/
|
|
62
|
+
public async getPropsConfig(type: string): Promise<FormConfig> {
|
|
63
|
+
if (type === 'area') {
|
|
64
|
+
return await this.getPropsConfig('button');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return cloneDeep(this.state.propsConfigMap[type] || DEFAULT_CONFIG);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public setPropsValues(values: Record<string, MNode>) {
|
|
71
|
+
Object.keys(values).forEach((type: string) => {
|
|
72
|
+
this.setPropsValue(toLine(type), values[type]);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 为指点类型组件设置组件初始值
|
|
78
|
+
* @param type 组件类型
|
|
79
|
+
* @param value 组件初始值
|
|
80
|
+
*/
|
|
81
|
+
public setPropsValue(type: string, value: MNode) {
|
|
82
|
+
this.state.propsValueMap[type] = value;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 获取指定类型的组件初始值
|
|
87
|
+
* @param type 组件类型
|
|
88
|
+
* @returns 组件初始值
|
|
89
|
+
*/
|
|
90
|
+
public async getPropsValue(type: string) {
|
|
91
|
+
if (type === 'area') {
|
|
92
|
+
const value = (await this.getPropsValue('button')) as MComponent;
|
|
93
|
+
value.className = 'action-area';
|
|
94
|
+
value.text = '';
|
|
95
|
+
if (value.style) {
|
|
96
|
+
value.style.backgroundColor = 'rgba(255, 255, 255, 0)';
|
|
97
|
+
}
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return cloneDeep({
|
|
102
|
+
...getDefaultPropsValue(type),
|
|
103
|
+
...(this.state.propsValueMap[type] || {}),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type PropsService = Props;
|
|
109
|
+
|
|
110
|
+
export default new Props();
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { reactive, toRaw } from 'vue';
|
|
20
|
+
|
|
21
|
+
import type StageCore from '@tmagic/stage';
|
|
22
|
+
|
|
23
|
+
import editorService from '@editor/services/editor';
|
|
24
|
+
import { GetColumnWidth, SetColumnWidth, UiState } from '@editor/type';
|
|
25
|
+
|
|
26
|
+
import BaseService from './BaseService';
|
|
27
|
+
|
|
28
|
+
const state = reactive<UiState>({
|
|
29
|
+
uiSelectMode: false,
|
|
30
|
+
showSrc: false,
|
|
31
|
+
zoom: 1,
|
|
32
|
+
stageStyle: {},
|
|
33
|
+
columnWidth: {
|
|
34
|
+
left: 310,
|
|
35
|
+
center: globalThis.document.body.clientWidth - 310 - 400,
|
|
36
|
+
right: 400,
|
|
37
|
+
},
|
|
38
|
+
showGuides: true,
|
|
39
|
+
showRule: true,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
class Ui extends BaseService {
|
|
43
|
+
constructor() {
|
|
44
|
+
super([]);
|
|
45
|
+
globalThis.addEventListener('resize', () => {
|
|
46
|
+
this.setColumnWidth({
|
|
47
|
+
center: 'auto',
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public set<T = any>(name: keyof UiState, value: T) {
|
|
53
|
+
const mask = editorService.get<StageCore>('stage')?.mask;
|
|
54
|
+
|
|
55
|
+
if (name === 'columnWidth') {
|
|
56
|
+
this.setColumnWidth(value as unknown as SetColumnWidth);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (name === 'showGuides') {
|
|
61
|
+
mask?.showGuides(value as unknown as boolean);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (name === 'showRule') {
|
|
65
|
+
mask?.showRule(value as unknown as boolean);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
(state as any)[name] = value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public get<T>(name: keyof typeof state): T {
|
|
72
|
+
return (state as any)[name];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private setColumnWidth({ left, center, right }: SetColumnWidth) {
|
|
76
|
+
const columnWidth = {
|
|
77
|
+
...toRaw(this.get<GetColumnWidth>('columnWidth')),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (left) {
|
|
81
|
+
columnWidth.left = left;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (right) {
|
|
85
|
+
columnWidth.right = right;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!center || center === 'auto') {
|
|
89
|
+
const bodyWidth = globalThis.document.body.clientWidth;
|
|
90
|
+
columnWidth.center = bodyWidth - (columnWidth?.left || 0) - (columnWidth?.right || 0);
|
|
91
|
+
} else {
|
|
92
|
+
columnWidth.center = center;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
state.columnWidth = columnWidth;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type UiService = Ui;
|
|
100
|
+
|
|
101
|
+
export default new Ui();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
$--theme-color: #2882e0;
|
|
2
|
+
|
|
3
|
+
$--font-color: #070303;
|
|
4
|
+
$--border-color: #d9dbdd;
|
|
5
|
+
|
|
6
|
+
$--nav-height: 35px;
|
|
7
|
+
$--nav-color: #070303;
|
|
8
|
+
$--nav--background-color: #f8fbff;
|
|
9
|
+
|
|
10
|
+
$--sidebar-heder-background-color: $--theme-color;
|
|
11
|
+
$--sidebar-content-background-color: #f8fbff;
|
|
12
|
+
|
|
13
|
+
$--page-bar-height: 32px;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
.ui-component-panel {
|
|
2
|
+
height: 100%;
|
|
3
|
+
border-top: 0 !important;
|
|
4
|
+
margin-top: 50px;
|
|
5
|
+
background-color: $--sidebar-content-background-color;
|
|
6
|
+
|
|
7
|
+
.search-input {
|
|
8
|
+
background: #f8fbff;
|
|
9
|
+
color: #bbbbbb;
|
|
10
|
+
padding: 10px;
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
|
|
16
|
+
.el-input__prefix {
|
|
17
|
+
padding: 10px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.el-input__suffix {
|
|
21
|
+
padding: 10px 5px;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.el-collapse-item {
|
|
26
|
+
> div:first-of-type {
|
|
27
|
+
border-bottom: 1px solid $--border-color;
|
|
28
|
+
margin-bottom: 10px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.el-collapse-item__header {
|
|
33
|
+
background: $--sidebar-content-background-color;
|
|
34
|
+
color: $--font-color;
|
|
35
|
+
height: 25px;
|
|
36
|
+
line-height: 25px;
|
|
37
|
+
padding-left: 10px;
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
|
|
40
|
+
i {
|
|
41
|
+
margin-right: 5px;
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.el-collapse-item__wrap {
|
|
47
|
+
background: $--sidebar-content-background-color;
|
|
48
|
+
border-bottom: 0;
|
|
49
|
+
|
|
50
|
+
.el-collapse-item__content {
|
|
51
|
+
padding: 10px;
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-wrap: wrap;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.component-item {
|
|
57
|
+
display: flex;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
text-overflow: ellipsis;
|
|
60
|
+
margin: 5px 10px;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
color: $--font-color;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
width: 42px;
|
|
65
|
+
|
|
66
|
+
i {
|
|
67
|
+
font-size: 20px;
|
|
68
|
+
background: #fff;
|
|
69
|
+
height: 40px;
|
|
70
|
+
width: 40px;
|
|
71
|
+
line-height: 40px;
|
|
72
|
+
border-radius: 5px;
|
|
73
|
+
color: #909090;
|
|
74
|
+
border: 1px solid $--border-color;
|
|
75
|
+
display: flex;
|
|
76
|
+
justify-content: space-evenly;
|
|
77
|
+
align-items: center;
|
|
78
|
+
margin-bottom: 5px;
|
|
79
|
+
|
|
80
|
+
&:hover {
|
|
81
|
+
background: #2882e0;
|
|
82
|
+
color: #fff;
|
|
83
|
+
border-color: #4e8be1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
span {
|
|
88
|
+
font-size: 12px;
|
|
89
|
+
text-align: center;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.el-tooltip {
|
|
93
|
+
width: 50px;
|
|
94
|
+
height: 30px;
|
|
95
|
+
line-height: 15px;
|
|
96
|
+
display: block;
|
|
97
|
+
white-space: normal;
|
|
98
|
+
margin: 0;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.magic-editor-content-menu {
|
|
2
|
+
position: fixed;
|
|
3
|
+
font-size: 12px;
|
|
4
|
+
background: #fff;
|
|
5
|
+
color: #333;
|
|
6
|
+
box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);
|
|
7
|
+
z-index: 9999;
|
|
8
|
+
transform-origin: 0% 0%;
|
|
9
|
+
font-weight: 600;
|
|
10
|
+
padding: 4px 0px;
|
|
11
|
+
|
|
12
|
+
.separation {
|
|
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;
|
|
23
|
+
color: #333;
|
|
24
|
+
box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);
|
|
25
|
+
top: 0;
|
|
26
|
+
height: 223px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.magic-editor-content-menu-item {
|
|
31
|
+
display: flex;
|
|
32
|
+
-webkit-box-align: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
min-width: 140px;
|
|
36
|
+
transition: all 0.2s ease 0s;
|
|
37
|
+
padding: 10px 14px;
|
|
38
|
+
border-left: 2px solid transparent;
|
|
39
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
.m-editor {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
width: 100%;
|
|
5
|
+
|
|
6
|
+
&-content {
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: calc(100% - #{$--nav-height});
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-self: space-between;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&-framework-center {
|
|
14
|
+
position: relative;
|
|
15
|
+
transform: translateZ(0);
|
|
16
|
+
flex: 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-framework-left {
|
|
20
|
+
background-color: $--sidebar-content-background-color;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-framework-center .el-scrollbar__view {
|
|
24
|
+
height: 100%;
|
|
25
|
+
min-height: 100%;
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
align-items: center;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&-empty {
|
|
32
|
+
&-panel {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex: 1;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
align-items: center;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
height: calc(100% - $--page-bar-height);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&-content {
|
|
42
|
+
display: flex;
|
|
43
|
+
justify-content: space-evenly;
|
|
44
|
+
flex-direction: row;
|
|
45
|
+
width: 100%;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&-button {
|
|
49
|
+
border: 3px solid rgba(0, 0, 0, 0.2);
|
|
50
|
+
padding: 10px 40px;
|
|
51
|
+
color: rgba(0, 0, 0, 0.6);
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
|
|
54
|
+
i {
|
|
55
|
+
height: 180px;
|
|
56
|
+
line-height: 180px;
|
|
57
|
+
font-size: 100px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
p {
|
|
61
|
+
text-align: center;
|
|
62
|
+
font-size: 20px;
|
|
63
|
+
margin-top: 5px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:hover {
|
|
67
|
+
border-color: $--theme-color;
|
|
68
|
+
color: $--theme-color;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@import "./common/var.scss";
|
|
2
|
+
@import "./nav-menu.scss";
|
|
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";
|