@tmagic/editor 1.0.0-rc.1 → 1.0.0-rc.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 +6 -3
- package/dist/tmagic-editor.es.js +292 -1394
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +292 -1396
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +49 -1
- package/dist/types/src/fields/Code.vue.d.ts +4 -4
- package/dist/types/src/fields/CodeLink.vue.d.ts +1 -3
- package/dist/types/src/layouts/Framework.vue.d.ts +15 -3
- package/dist/types/src/layouts/PropsPanel.vue.d.ts +2 -4
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +3 -27
- package/dist/types/src/services/BaseService.d.ts +1 -1
- package/dist/types/src/services/history.d.ts +1 -18
- package/dist/types/src/services/props.d.ts +8 -2
- package/dist/types/src/type.d.ts +9 -0
- package/dist/types/src/utils/editor.d.ts +0 -6
- package/dist/types/src/utils/props.d.ts +8 -1
- package/package.json +17 -18
- package/src/Editor.vue +44 -9
- package/src/components/ContentMenu.vue +59 -26
- package/src/layouts/CodeEditor.vue +1 -4
- package/src/layouts/Framework.vue +14 -1
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/LayerMenu.vue +3 -0
- package/src/layouts/sidebar/TabPane.vue +1 -1
- package/src/layouts/workspace/Stage.vue +12 -29
- package/src/layouts/workspace/ViewerMenu.vue +17 -2
- package/src/layouts/workspace/Workspace.vue +21 -26
- package/src/services/BaseService.ts +1 -1
- package/src/services/editor.ts +34 -5
- package/src/services/props.ts +64 -9
- package/src/theme/props-panel.scss +6 -4
- package/src/theme/workspace.scss +4 -0
- package/src/type.ts +10 -0
- package/src/utils/editor.ts +7 -52
- package/src/utils/polyfills.ts +5 -19
- package/src/utils/props.ts +30 -7
- package/LICENSE +0 -5432
- package/coverage/clover.xml +0 -1560
- package/coverage/coverage-final.json +0 -36
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -206
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/Editor.vue.html +0 -787
- package/coverage/lcov-report/src/components/ContentMenu.vue.html +0 -406
- package/coverage/lcov-report/src/components/Icon.vue.html +0 -172
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +0 -283
- package/coverage/lcov-report/src/components/ToolButton.vue.html +0 -772
- package/coverage/lcov-report/src/components/index.html +0 -161
- package/coverage/lcov-report/src/index.html +0 -131
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +0 -214
- package/coverage/lcov-report/src/layouts/Framework.vue.html +0 -304
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +0 -208
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +0 -319
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +0 -268
- package/coverage/lcov-report/src/layouts/index.html +0 -176
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +0 -358
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +0 -421
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +0 -775
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +0 -226
- package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +0 -289
- package/coverage/lcov-report/src/layouts/sidebar/index.html +0 -176
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +0 -718
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +0 -757
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +0 -532
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +0 -586
- package/coverage/lcov-report/src/layouts/workspace/index.html +0 -161
- package/coverage/lcov-report/src/services/BaseService.ts.html +0 -643
- package/coverage/lcov-report/src/services/componentList.ts.html +0 -229
- package/coverage/lcov-report/src/services/editor.ts.html +0 -2077
- package/coverage/lcov-report/src/services/events.ts.html +0 -331
- package/coverage/lcov-report/src/services/history.ts.html +0 -478
- package/coverage/lcov-report/src/services/index.html +0 -206
- package/coverage/lcov-report/src/services/props.ts.html +0 -415
- package/coverage/lcov-report/src/services/ui.ts.html +0 -580
- package/coverage/lcov-report/src/type.ts.html +0 -850
- package/coverage/lcov-report/src/utils/compose.ts.html +0 -184
- package/coverage/lcov-report/src/utils/config.ts.html +0 -172
- package/coverage/lcov-report/src/utils/editor.ts.html +0 -838
- package/coverage/lcov-report/src/utils/index.html +0 -221
- package/coverage/lcov-report/src/utils/index.ts.html +0 -151
- package/coverage/lcov-report/src/utils/logger.ts.html +0 -226
- package/coverage/lcov-report/src/utils/props.ts.html +0 -796
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +0 -733
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +0 -313
- package/coverage/lcov.info +0 -3708
- package/dist/types/src/components/ToolButton.vue.d.ts +0 -46
- package/dist/types/src/fields/UISelect.vue.d.ts +0 -35
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +0 -18
|
@@ -3,7 +3,7 @@ import type { FormConfig } from '@tmagic/form';
|
|
|
3
3
|
import type { MApp, MNode } from '@tmagic/schema';
|
|
4
4
|
import type StageCore from '@tmagic/stage';
|
|
5
5
|
import type { MoveableOptions } from '@tmagic/stage';
|
|
6
|
-
import type { ComponentGroup, MenuBarData, Services, SideBarData, StageRect } from './type';
|
|
6
|
+
import type { ComponentGroup, MenuBarData, MenuItem, Services, SideBarData, StageRect } from './type';
|
|
7
7
|
declare const _default: DefineComponent<{
|
|
8
8
|
/** 页面初始值 */
|
|
9
9
|
modelValue: {
|
|
@@ -20,6 +20,14 @@ declare const _default: DefineComponent<{
|
|
|
20
20
|
sidebar: {
|
|
21
21
|
type: PropType<SideBarData>;
|
|
22
22
|
};
|
|
23
|
+
layerContentMenu: {
|
|
24
|
+
type: PropType<MenuItem[]>;
|
|
25
|
+
default: () => never[];
|
|
26
|
+
};
|
|
27
|
+
stageContentMenu: {
|
|
28
|
+
type: PropType<MenuItem[]>;
|
|
29
|
+
default: () => never[];
|
|
30
|
+
};
|
|
23
31
|
/** 顶部工具栏配置 */
|
|
24
32
|
menu: {
|
|
25
33
|
type: PropType<MenuBarData>;
|
|
@@ -34,6 +42,8 @@ declare const _default: DefineComponent<{
|
|
|
34
42
|
};
|
|
35
43
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
36
44
|
runtimeUrl: StringConstructor;
|
|
45
|
+
/** 选中时是否自动滚动到可视区域 */
|
|
46
|
+
autoScrollIntoView: BooleanConstructor;
|
|
37
47
|
/** 组件的属性配置表单的dsl */
|
|
38
48
|
propsConfigs: {
|
|
39
49
|
type: PropType<Record<string, FormConfig>>;
|
|
@@ -52,6 +62,9 @@ declare const _default: DefineComponent<{
|
|
|
52
62
|
/** 画布中组件选中框的移动范围 */
|
|
53
63
|
moveableOptions: {
|
|
54
64
|
type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
|
|
65
|
+
default: () => (core?: StageCore | undefined) => {
|
|
66
|
+
container: HTMLElement | null | undefined;
|
|
67
|
+
};
|
|
55
68
|
};
|
|
56
69
|
/** 编辑器初始化时默认选中的组件ID */
|
|
57
70
|
defaultSelected: {
|
|
@@ -59,10 +72,18 @@ declare const _default: DefineComponent<{
|
|
|
59
72
|
};
|
|
60
73
|
canSelect: {
|
|
61
74
|
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
75
|
+
default: (el: HTMLElement) => boolean;
|
|
62
76
|
};
|
|
63
77
|
stageRect: {
|
|
64
78
|
type: PropType<StageRect>;
|
|
65
79
|
};
|
|
80
|
+
codeOptions: {
|
|
81
|
+
type: ObjectConstructor;
|
|
82
|
+
default: () => {};
|
|
83
|
+
};
|
|
84
|
+
updateDragEl: {
|
|
85
|
+
type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
|
|
86
|
+
};
|
|
66
87
|
}, Services, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("props-panel-mounted" | "update:modelValue")[], "props-panel-mounted" | "update:modelValue", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
67
88
|
/** 页面初始值 */
|
|
68
89
|
modelValue: {
|
|
@@ -79,6 +100,14 @@ declare const _default: DefineComponent<{
|
|
|
79
100
|
sidebar: {
|
|
80
101
|
type: PropType<SideBarData>;
|
|
81
102
|
};
|
|
103
|
+
layerContentMenu: {
|
|
104
|
+
type: PropType<MenuItem[]>;
|
|
105
|
+
default: () => never[];
|
|
106
|
+
};
|
|
107
|
+
stageContentMenu: {
|
|
108
|
+
type: PropType<MenuItem[]>;
|
|
109
|
+
default: () => never[];
|
|
110
|
+
};
|
|
82
111
|
/** 顶部工具栏配置 */
|
|
83
112
|
menu: {
|
|
84
113
|
type: PropType<MenuBarData>;
|
|
@@ -93,6 +122,8 @@ declare const _default: DefineComponent<{
|
|
|
93
122
|
};
|
|
94
123
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
95
124
|
runtimeUrl: StringConstructor;
|
|
125
|
+
/** 选中时是否自动滚动到可视区域 */
|
|
126
|
+
autoScrollIntoView: BooleanConstructor;
|
|
96
127
|
/** 组件的属性配置表单的dsl */
|
|
97
128
|
propsConfigs: {
|
|
98
129
|
type: PropType<Record<string, FormConfig>>;
|
|
@@ -111,6 +142,9 @@ declare const _default: DefineComponent<{
|
|
|
111
142
|
/** 画布中组件选中框的移动范围 */
|
|
112
143
|
moveableOptions: {
|
|
113
144
|
type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
|
|
145
|
+
default: () => (core?: StageCore | undefined) => {
|
|
146
|
+
container: HTMLElement | null | undefined;
|
|
147
|
+
};
|
|
114
148
|
};
|
|
115
149
|
/** 编辑器初始化时默认选中的组件ID */
|
|
116
150
|
defaultSelected: {
|
|
@@ -118,19 +152,33 @@ declare const _default: DefineComponent<{
|
|
|
118
152
|
};
|
|
119
153
|
canSelect: {
|
|
120
154
|
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
155
|
+
default: (el: HTMLElement) => boolean;
|
|
121
156
|
};
|
|
122
157
|
stageRect: {
|
|
123
158
|
type: PropType<StageRect>;
|
|
124
159
|
};
|
|
160
|
+
codeOptions: {
|
|
161
|
+
type: ObjectConstructor;
|
|
162
|
+
default: () => {};
|
|
163
|
+
};
|
|
164
|
+
updateDragEl: {
|
|
165
|
+
type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
|
|
166
|
+
};
|
|
125
167
|
}>> & {
|
|
126
168
|
"onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
|
|
127
169
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
128
170
|
}, {
|
|
129
171
|
menu: MenuBarData;
|
|
172
|
+
layerContentMenu: MenuItem[];
|
|
173
|
+
stageContentMenu: MenuItem[];
|
|
174
|
+
codeOptions: Record<string, any>;
|
|
130
175
|
modelValue: MApp;
|
|
131
176
|
componentGroupList: ComponentGroup[];
|
|
177
|
+
autoScrollIntoView: boolean;
|
|
132
178
|
propsConfigs: Record<string, FormConfig>;
|
|
133
179
|
propsValues: Record<string, MNode>;
|
|
134
180
|
eventMethodList: Record<string, any>;
|
|
181
|
+
moveableOptions: MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions);
|
|
182
|
+
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
135
183
|
}>;
|
|
136
184
|
export default _default;
|
|
@@ -16,9 +16,9 @@ declare const _default: DefineComponent<Readonly<{
|
|
|
16
16
|
}>>> & {
|
|
17
17
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
18
18
|
}, {
|
|
19
|
-
name
|
|
20
|
-
config
|
|
21
|
-
model
|
|
22
|
-
prop
|
|
19
|
+
readonly name?: any;
|
|
20
|
+
readonly config?: any;
|
|
21
|
+
readonly model?: any;
|
|
22
|
+
readonly prop?: any;
|
|
23
23
|
}>;
|
|
24
24
|
export default _default;
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import type { DefineComponent, ComputedRef, ComponentOptionsMixin,
|
|
1
|
+
import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
|
|
2
2
|
import type { MApp } from '@tmagic/schema';
|
|
3
3
|
import { GetColumnWidth } from '../type';
|
|
4
|
-
declare const _default: DefineComponent<{
|
|
4
|
+
declare const _default: DefineComponent<{
|
|
5
|
+
codeOptions: {
|
|
6
|
+
type: ObjectConstructor;
|
|
7
|
+
default: () => {};
|
|
8
|
+
};
|
|
9
|
+
}, {
|
|
5
10
|
root: ComputedRef<MApp | undefined>;
|
|
6
11
|
pageLength: ComputedRef<number>;
|
|
7
12
|
showSrc: ComputedRef<boolean | undefined>;
|
|
8
13
|
columnWidth: ComputedRef<GetColumnWidth | undefined>;
|
|
9
14
|
saveCode(value: string): void;
|
|
10
|
-
},
|
|
15
|
+
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
16
|
+
codeOptions: {
|
|
17
|
+
type: ObjectConstructor;
|
|
18
|
+
default: () => {};
|
|
19
|
+
};
|
|
20
|
+
}>>, {
|
|
21
|
+
codeOptions: Record<string, any>;
|
|
22
|
+
}>;
|
|
11
23
|
export default _default;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { FormValue } from '@tmagic/form';
|
|
2
3
|
declare const _default: DefineComponent<{}, {
|
|
3
|
-
values: Ref<
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
[x: number]: any;
|
|
6
|
-
}>;
|
|
4
|
+
values: Ref<FormValue>;
|
|
7
5
|
configForm: Ref<any>;
|
|
8
6
|
curFormConfig: any;
|
|
9
7
|
propsPanelSize: ComputedRef<unknown>;
|
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes
|
|
1
|
+
import type { DefineComponent, Ref, ComputedRef, ComponentOptionsMixin, EmitsOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
|
|
2
2
|
import type { MPage } from '@tmagic/schema';
|
|
3
|
-
|
|
4
|
-
import StageCore from '@tmagic/stage';
|
|
5
|
-
declare const _default: DefineComponent<{
|
|
6
|
-
runtimeUrl: StringConstructor;
|
|
7
|
-
render: {
|
|
8
|
-
type: PropType<() => HTMLDivElement>;
|
|
9
|
-
};
|
|
10
|
-
moveableOptions: {
|
|
11
|
-
type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
|
|
12
|
-
};
|
|
13
|
-
canSelect: {
|
|
14
|
-
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
15
|
-
};
|
|
16
|
-
}, {
|
|
3
|
+
declare const _default: DefineComponent<{}, {
|
|
17
4
|
workspace: Ref<HTMLDivElement | undefined>;
|
|
18
5
|
page: ComputedRef<MPage | undefined>;
|
|
19
|
-
},
|
|
20
|
-
runtimeUrl: StringConstructor;
|
|
21
|
-
render: {
|
|
22
|
-
type: PropType<() => HTMLDivElement>;
|
|
23
|
-
};
|
|
24
|
-
moveableOptions: {
|
|
25
|
-
type: PropType<MoveableOptions | ((core?: StageCore | undefined) => MoveableOptions)>;
|
|
26
|
-
};
|
|
27
|
-
canSelect: {
|
|
28
|
-
type: PropType<(el: HTMLElement) => boolean | Promise<boolean>>;
|
|
29
|
-
};
|
|
30
|
-
}>>, {}>;
|
|
6
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{}>>, {}>;
|
|
31
7
|
export default _default;
|
|
@@ -27,7 +27,7 @@ import { EventEmitter } from 'events';
|
|
|
27
27
|
* editorService.afterAdd();
|
|
28
28
|
* }
|
|
29
29
|
*
|
|
30
|
-
* 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after
|
|
30
|
+
* 调用时的参数会透传到before方法的参数中, 然后before的return 会作为原方法的参数和after的参数,after第一个参数则是原方法的return值;
|
|
31
31
|
* 如需终止后续方法调用可以return new Error();
|
|
32
32
|
*
|
|
33
33
|
* 方法2:
|
|
@@ -15,24 +15,7 @@ export interface HistoryState {
|
|
|
15
15
|
declare class History extends BaseService {
|
|
16
16
|
state: {
|
|
17
17
|
pageId?: Id | undefined;
|
|
18
|
-
pageSteps:
|
|
19
|
-
[x: string]: {
|
|
20
|
-
pushElement: (element: StepValue) => void;
|
|
21
|
-
canUndo: () => boolean;
|
|
22
|
-
undo: () => StepValue | null;
|
|
23
|
-
canRedo: () => boolean;
|
|
24
|
-
redo: () => StepValue | null;
|
|
25
|
-
getCurrentElement: () => StepValue | null;
|
|
26
|
-
};
|
|
27
|
-
[x: number]: {
|
|
28
|
-
pushElement: (element: StepValue) => void;
|
|
29
|
-
canUndo: () => boolean;
|
|
30
|
-
undo: () => StepValue | null;
|
|
31
|
-
canRedo: () => boolean;
|
|
32
|
-
redo: () => StepValue | null;
|
|
33
|
-
getCurrentElement: () => StepValue | null;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
18
|
+
pageSteps: Record<Id, UndoRedo<StepValue>>;
|
|
36
19
|
canRedo: boolean;
|
|
37
20
|
canUndo: boolean;
|
|
38
21
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormConfig } from '@tmagic/form';
|
|
2
|
-
import type { MNode } from '@tmagic/schema';
|
|
2
|
+
import type { MNode, MPage } from '@tmagic/schema';
|
|
3
3
|
import BaseService from './BaseService';
|
|
4
4
|
declare class Props extends BaseService {
|
|
5
5
|
private state;
|
|
@@ -29,7 +29,13 @@ declare class Props extends BaseService {
|
|
|
29
29
|
* @param type 组件类型
|
|
30
30
|
* @returns 组件初始值
|
|
31
31
|
*/
|
|
32
|
-
getPropsValue(type: string, defaultValue?:
|
|
32
|
+
getPropsValue(type: string, defaultValue?: Record<string, any>): Promise<any>;
|
|
33
|
+
createId(type: string | number): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
36
|
+
* @param {Object} config 组件配置
|
|
37
|
+
*/
|
|
38
|
+
setNewItemId(config: MNode, parent?: MPage): Promise<void>;
|
|
33
39
|
}
|
|
34
40
|
export declare type PropsService = Props;
|
|
35
41
|
declare const _default: Props;
|
package/dist/types/src/type.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Component } from 'vue';
|
|
|
2
2
|
import type { FormConfig } from '@tmagic/form';
|
|
3
3
|
import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
4
4
|
import type StageCore from '@tmagic/stage';
|
|
5
|
+
import type { MoveableOptions } from '@tmagic/stage';
|
|
5
6
|
import type { ComponentListService } from './services/componentList';
|
|
6
7
|
import type { EditorService } from './services/editor';
|
|
7
8
|
import type { EventsService } from './services/events';
|
|
@@ -21,6 +22,14 @@ export interface Services {
|
|
|
21
22
|
componentListService: ComponentListService;
|
|
22
23
|
uiService: UiService;
|
|
23
24
|
}
|
|
25
|
+
export interface StageOptions {
|
|
26
|
+
runtimeUrl: string;
|
|
27
|
+
autoScrollIntoView: boolean;
|
|
28
|
+
render: () => HTMLDivElement;
|
|
29
|
+
moveableOptions: MoveableOptions | ((core?: StageCore) => MoveableOptions);
|
|
30
|
+
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
31
|
+
updateDragEl: (el: HTMLDivElement) => void;
|
|
32
|
+
}
|
|
24
33
|
export interface StoreState {
|
|
25
34
|
root: MApp | null;
|
|
26
35
|
page: MPage | null;
|
|
@@ -2,7 +2,6 @@ import type { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
|
2
2
|
import type StageCore from '@tmagic/stage';
|
|
3
3
|
import { Layout } from '../type';
|
|
4
4
|
export declare const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
5
|
-
export declare const generateId: (type: string | number) => string;
|
|
6
5
|
/**
|
|
7
6
|
* 获取所有页面配置
|
|
8
7
|
* @param app DSL跟节点
|
|
@@ -27,11 +26,6 @@ export declare const generatePageName: (pageNameList: string[]) => string;
|
|
|
27
26
|
* @returns {string}
|
|
28
27
|
*/
|
|
29
28
|
export declare const generatePageNameByApp: (app: MApp) => string;
|
|
30
|
-
/**
|
|
31
|
-
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
32
|
-
* @param {Object} config 组件配置
|
|
33
|
-
*/
|
|
34
|
-
export declare const setNewItemId: (config: MNode, parent?: MPage | undefined) => void;
|
|
35
29
|
/**
|
|
36
30
|
* @param {Object} node
|
|
37
31
|
* @returns {boolean}
|
|
@@ -41,9 +41,16 @@ export declare const DEFAULT_CONFIG: FormConfig;
|
|
|
41
41
|
* @param type 组件类型
|
|
42
42
|
* @returns Object
|
|
43
43
|
*/
|
|
44
|
-
export declare const getDefaultPropsValue: (type: string) => {
|
|
44
|
+
export declare const getDefaultPropsValue: (type: string, id: string) => {
|
|
45
45
|
type: string;
|
|
46
46
|
id: string;
|
|
47
47
|
style: {};
|
|
48
48
|
name: string;
|
|
49
|
+
items: never[];
|
|
50
|
+
} | {
|
|
51
|
+
type: string;
|
|
52
|
+
id: string;
|
|
53
|
+
style: {};
|
|
54
|
+
name: string;
|
|
55
|
+
items?: undefined;
|
|
49
56
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-rc.
|
|
2
|
+
"version": "1.0.0-rc.10",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -22,9 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "vite build"
|
|
26
|
-
"test": "jest --maxWorkers=8",
|
|
27
|
-
"test:coverage": "jest --maxWorkers=16 --coverage"
|
|
25
|
+
"build": "vite build"
|
|
28
26
|
},
|
|
29
27
|
"engines": {
|
|
30
28
|
"node": ">=14"
|
|
@@ -43,42 +41,43 @@
|
|
|
43
41
|
"typescript"
|
|
44
42
|
],
|
|
45
43
|
"dependencies": {
|
|
44
|
+
"@babel/core": "^7.18.0",
|
|
46
45
|
"@element-plus/icons": "0.0.11",
|
|
47
|
-
"@tmagic/core": "
|
|
48
|
-
"@tmagic/form": "
|
|
49
|
-
"@tmagic/schema": "
|
|
50
|
-
"@tmagic/stage": "
|
|
51
|
-
"@tmagic/utils": "
|
|
46
|
+
"@tmagic/core": "1.0.0-rc.10",
|
|
47
|
+
"@tmagic/form": "1.0.0-rc.10",
|
|
48
|
+
"@tmagic/schema": "1.0.0-rc.10",
|
|
49
|
+
"@tmagic/stage": "1.0.0-rc.10",
|
|
50
|
+
"@tmagic/utils": "1.0.0-rc.10",
|
|
52
51
|
"buffer": "^6.0.3",
|
|
53
52
|
"color": "^3.1.3",
|
|
54
53
|
"element-plus": "^2.2.0",
|
|
55
54
|
"events": "^3.3.0",
|
|
55
|
+
"gesto": "^1.7.0",
|
|
56
56
|
"keycon": "^1.1.2",
|
|
57
57
|
"lodash-es": "^4.17.21",
|
|
58
58
|
"monaco-editor": "^0.32.1",
|
|
59
59
|
"serialize-javascript": "^6.0.0",
|
|
60
60
|
"vue": "^3.2.0"
|
|
61
61
|
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@tmagic/form": "1.0.0-rc.10",
|
|
64
|
+
"element-plus": "^2.2.0",
|
|
65
|
+
"monaco-editor": "^0.32.1",
|
|
66
|
+
"vue": "^3.2.0"
|
|
67
|
+
},
|
|
62
68
|
"devDependencies": {
|
|
63
69
|
"@types/events": "^3.0.0",
|
|
64
|
-
"@types/jest": "^26.0.23",
|
|
65
70
|
"@types/lodash-es": "^4.17.4",
|
|
66
71
|
"@types/node": "^15.12.4",
|
|
67
72
|
"@types/serialize-javascript": "^5.0.1",
|
|
68
73
|
"@vitejs/plugin-vue": "^1.2.3",
|
|
69
74
|
"@vitejs/plugin-vue-jsx": "^1.1.6",
|
|
70
75
|
"@vue/compiler-sfc": "^3.2.0",
|
|
71
|
-
"@vue/test-utils": "^2.0.0
|
|
72
|
-
"@vue/vue3-jest": "^27.0.0-alpha.4",
|
|
73
|
-
"jest": "^27.5.1",
|
|
74
|
-
"jest-serializer-vue": "^2.0.2",
|
|
75
|
-
"jest-transform-stub": "^2.0.0",
|
|
76
|
+
"@vue/test-utils": "^2.0.0",
|
|
76
77
|
"sass": "^1.35.1",
|
|
77
|
-
"ts-jest": "^27.1.4",
|
|
78
78
|
"typescript": "^4.3.4",
|
|
79
79
|
"vite": "^2.3.7",
|
|
80
80
|
"vite-plugin-dts": "^0.9.6",
|
|
81
81
|
"vue-tsc": "^0.0.24"
|
|
82
|
-
}
|
|
83
|
-
"gitHead": "3b647794d087888bfec9772f54356fa48c0b6d90"
|
|
82
|
+
}
|
|
84
83
|
}
|
package/src/Editor.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<framework>
|
|
2
|
+
<framework :code-options="codeOptions">
|
|
3
3
|
<template #nav>
|
|
4
4
|
<slot name="nav" :editorService="editorService"><nav-menu :data="menu"></nav-menu></slot>
|
|
5
5
|
</template>
|
|
@@ -12,12 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
<template #workspace :editorService="editorService">
|
|
14
14
|
<slot name="workspace">
|
|
15
|
-
<workspace
|
|
16
|
-
:runtime-url="runtimeUrl"
|
|
17
|
-
:render="render"
|
|
18
|
-
:moveable-options="moveableOptions"
|
|
19
|
-
:can-select="canSelect"
|
|
20
|
-
>
|
|
15
|
+
<workspace>
|
|
21
16
|
<template #workspace-content><slot name="workspace-content" :editorService="editorService"></slot></template>
|
|
22
17
|
<template #page-bar-title="{ page }"><slot name="page-bar-title" :page="page"></slot></template>
|
|
23
18
|
<template #page-bar-popover="{ page }"><slot name="page-bar-popover" :page="page"></slot></template>
|
|
@@ -36,7 +31,7 @@
|
|
|
36
31
|
</template>
|
|
37
32
|
|
|
38
33
|
<script lang="ts">
|
|
39
|
-
import { defineComponent, onUnmounted, PropType, provide, toRaw, watch } from 'vue';
|
|
34
|
+
import { defineComponent, onUnmounted, PropType, provide, reactive, toRaw, watch } from 'vue';
|
|
40
35
|
|
|
41
36
|
import { EventOption } from '@tmagic/core';
|
|
42
37
|
import type { FormConfig } from '@tmagic/form';
|
|
@@ -55,7 +50,7 @@ import eventsService from '@editor/services/events';
|
|
|
55
50
|
import historyService from '@editor/services/history';
|
|
56
51
|
import propsService from '@editor/services/props';
|
|
57
52
|
import uiService from '@editor/services/ui';
|
|
58
|
-
import type { ComponentGroup, MenuBarData, Services, SideBarData, StageRect } from '@editor/type';
|
|
53
|
+
import type { ComponentGroup, MenuBarData, MenuItem, Services, SideBarData, StageRect } from '@editor/type';
|
|
59
54
|
|
|
60
55
|
export default defineComponent({
|
|
61
56
|
name: 'm-editor',
|
|
@@ -87,6 +82,16 @@ export default defineComponent({
|
|
|
87
82
|
type: Object as PropType<SideBarData>,
|
|
88
83
|
},
|
|
89
84
|
|
|
85
|
+
layerContentMenu: {
|
|
86
|
+
type: Array as PropType<MenuItem[]>,
|
|
87
|
+
default: () => [],
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
stageContentMenu: {
|
|
91
|
+
type: Array as PropType<MenuItem[]>,
|
|
92
|
+
default: () => [],
|
|
93
|
+
},
|
|
94
|
+
|
|
90
95
|
/** 顶部工具栏配置 */
|
|
91
96
|
menu: {
|
|
92
97
|
type: Object as PropType<MenuBarData>,
|
|
@@ -101,6 +106,9 @@ export default defineComponent({
|
|
|
101
106
|
/** 中间工作区域中画布通过iframe渲染时的页面url */
|
|
102
107
|
runtimeUrl: String,
|
|
103
108
|
|
|
109
|
+
/** 选中时是否自动滚动到可视区域 */
|
|
110
|
+
autoScrollIntoView: Boolean,
|
|
111
|
+
|
|
104
112
|
/** 组件的属性配置表单的dsl */
|
|
105
113
|
propsConfigs: {
|
|
106
114
|
type: Object as PropType<Record<string, FormConfig>>,
|
|
@@ -122,6 +130,9 @@ export default defineComponent({
|
|
|
122
130
|
/** 画布中组件选中框的移动范围 */
|
|
123
131
|
moveableOptions: {
|
|
124
132
|
type: [Object, Function] as PropType<MoveableOptions | ((core?: StageCore) => MoveableOptions)>,
|
|
133
|
+
default: () => (core?: StageCore) => ({
|
|
134
|
+
container: core?.renderer?.contentWindow?.document.getElementById('app'),
|
|
135
|
+
}),
|
|
125
136
|
},
|
|
126
137
|
|
|
127
138
|
/** 编辑器初始化时默认选中的组件ID */
|
|
@@ -131,11 +142,21 @@ export default defineComponent({
|
|
|
131
142
|
|
|
132
143
|
canSelect: {
|
|
133
144
|
type: Function as PropType<(el: HTMLElement) => boolean | Promise<boolean>>,
|
|
145
|
+
default: (el: HTMLElement) => Boolean(el.id),
|
|
134
146
|
},
|
|
135
147
|
|
|
136
148
|
stageRect: {
|
|
137
149
|
type: [String, Object] as PropType<StageRect>,
|
|
138
150
|
},
|
|
151
|
+
|
|
152
|
+
codeOptions: {
|
|
153
|
+
type: Object,
|
|
154
|
+
default: () => ({}),
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
updateDragEl: {
|
|
158
|
+
type: Function as PropType<(el: HTMLDivElement, target: HTMLElement) => void>,
|
|
159
|
+
},
|
|
139
160
|
},
|
|
140
161
|
|
|
141
162
|
emits: ['props-panel-mounted', 'update:modelValue'],
|
|
@@ -228,6 +249,20 @@ export default defineComponent({
|
|
|
228
249
|
|
|
229
250
|
provide('services', services);
|
|
230
251
|
|
|
252
|
+
provide('layerContentMenu', props.layerContentMenu);
|
|
253
|
+
provide('stageContentMenu', props.stageContentMenu);
|
|
254
|
+
provide(
|
|
255
|
+
'stageOptions',
|
|
256
|
+
reactive({
|
|
257
|
+
runtimeUrl: props.runtimeUrl,
|
|
258
|
+
autoScrollIntoView: props.autoScrollIntoView,
|
|
259
|
+
render: props.render,
|
|
260
|
+
moveableOptions: props.moveableOptions,
|
|
261
|
+
canSelect: props.canSelect,
|
|
262
|
+
updateDragEl: props.updateDragEl,
|
|
263
|
+
}),
|
|
264
|
+
);
|
|
265
|
+
|
|
231
266
|
return services;
|
|
232
267
|
},
|
|
233
268
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div v-if="menuData.length
|
|
2
|
+
<div v-if="menuData.length && visible" class="magic-editor-content-menu" ref="menu" :style="menuStyle">
|
|
3
3
|
<div>
|
|
4
4
|
<tool-button
|
|
5
5
|
v-for="(item, index) in menuData"
|
|
@@ -11,13 +11,19 @@
|
|
|
11
11
|
></tool-button>
|
|
12
12
|
</div>
|
|
13
13
|
<teleport to="body">
|
|
14
|
-
<content-menu
|
|
14
|
+
<content-menu
|
|
15
|
+
class="sub-menu"
|
|
16
|
+
ref="subMenu"
|
|
17
|
+
:menu-data="subMenuData"
|
|
18
|
+
:is-sub-menu="true"
|
|
19
|
+
@hide="hide"
|
|
20
|
+
></content-menu>
|
|
15
21
|
</teleport>
|
|
16
22
|
</div>
|
|
17
23
|
</template>
|
|
18
24
|
|
|
19
25
|
<script lang="ts">
|
|
20
|
-
import { defineComponent, nextTick, onMounted, PropType, ref } from 'vue';
|
|
26
|
+
import { defineComponent, nextTick, onMounted, onUnmounted, PropType, ref } from 'vue';
|
|
21
27
|
|
|
22
28
|
import { MenuButton, MenuItem } from '@editor/type';
|
|
23
29
|
|
|
@@ -31,9 +37,16 @@ export default defineComponent({
|
|
|
31
37
|
type: Array as PropType<MenuItem[]>,
|
|
32
38
|
default: () => [],
|
|
33
39
|
},
|
|
40
|
+
|
|
41
|
+
isSubMenu: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
34
45
|
},
|
|
35
46
|
|
|
36
|
-
|
|
47
|
+
emits: ['hide', 'show'],
|
|
48
|
+
|
|
49
|
+
setup(props, { emit }) {
|
|
37
50
|
const menu = ref<HTMLDivElement>();
|
|
38
51
|
const subMenu = ref<any>();
|
|
39
52
|
const visible = ref(false);
|
|
@@ -44,20 +57,35 @@ export default defineComponent({
|
|
|
44
57
|
});
|
|
45
58
|
|
|
46
59
|
const hide = () => {
|
|
60
|
+
if (!visible.value) return;
|
|
61
|
+
|
|
47
62
|
visible.value = false;
|
|
63
|
+
subMenu.value?.hide();
|
|
64
|
+
|
|
65
|
+
emit('hide');
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const hideHandler = (e: MouseEvent) => {
|
|
69
|
+
const target = e.target as HTMLElement | undefined;
|
|
70
|
+
if (!visible.value || !target) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (menu.value?.contains(target) || subMenu.value?.$el?.contains(target)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
hide();
|
|
48
77
|
};
|
|
49
78
|
|
|
50
79
|
onMounted(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
80
|
+
if (props.isSubMenu) return;
|
|
81
|
+
|
|
82
|
+
globalThis.addEventListener('mousedown', hideHandler, true);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
onUnmounted(() => {
|
|
86
|
+
if (props.isSubMenu) return;
|
|
87
|
+
|
|
88
|
+
globalThis.removeEventListener('mousedown', hideHandler, true);
|
|
61
89
|
});
|
|
62
90
|
|
|
63
91
|
return {
|
|
@@ -70,21 +98,26 @@ export default defineComponent({
|
|
|
70
98
|
hide,
|
|
71
99
|
|
|
72
100
|
show(e: MouseEvent) {
|
|
73
|
-
|
|
101
|
+
// 加settimeout是以为,如果菜单中的按钮监听的是mouseup,那么菜单显示出来时鼠标如果正好在菜单上就会马上触发按钮的mouseup
|
|
102
|
+
setTimeout(() => {
|
|
103
|
+
visible.value = true;
|
|
104
|
+
|
|
105
|
+
nextTick(() => {
|
|
106
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
74
107
|
|
|
75
|
-
|
|
76
|
-
|
|
108
|
+
let top = e.clientY;
|
|
109
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
110
|
+
top = document.body.clientHeight - menuHeight;
|
|
111
|
+
}
|
|
77
112
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
113
|
+
menuStyle.value = {
|
|
114
|
+
top: `${top}px`,
|
|
115
|
+
left: `${e.clientX}px`,
|
|
116
|
+
};
|
|
82
117
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
});
|
|
118
|
+
emit('show');
|
|
119
|
+
});
|
|
120
|
+
}, 300);
|
|
88
121
|
},
|
|
89
122
|
|
|
90
123
|
showSubMenu(item: MenuItem) {
|