@tmagic/editor 1.1.0-beta.8 → 1.1.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 +46 -0
- package/dist/tmagic-editor.mjs +1052 -873
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +1054 -872
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +31 -9
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +6 -20
- package/src/components/ScrollBar.vue +147 -0
- package/src/components/ScrollViewer.vue +89 -44
- package/src/components/ToolButton.vue +40 -138
- package/src/fields/UISelect.vue +2 -2
- package/src/index.ts +2 -0
- package/src/layouts/NavMenu.vue +156 -23
- package/src/layouts/PropsPanel.vue +49 -51
- package/src/layouts/sidebar/LayerMenu.vue +3 -3
- package/src/layouts/sidebar/LayerPanel.vue +39 -8
- package/src/layouts/workspace/PageBar.vue +1 -1
- package/src/layouts/workspace/Stage.vue +8 -86
- package/src/layouts/workspace/ViewerMenu.vue +6 -6
- package/src/layouts/workspace/Workspace.vue +133 -138
- package/src/services/componentList.ts +5 -0
- package/src/services/editor.ts +148 -76
- package/src/services/events.ts +8 -2
- package/src/services/props.ts +31 -52
- package/src/services/storage.ts +4 -0
- package/src/services/ui.ts +32 -30
- package/src/theme/nav-menu.scss +6 -0
- package/src/type.ts +28 -11
- package/src/utils/index.ts +1 -0
- package/src/utils/operator.ts +6 -60
- package/src/utils/props.ts +0 -3
- package/src/utils/scroll-viewer.ts +90 -158
- package/src/utils/stage.ts +91 -0
- package/types/Editor.vue.d.ts +17 -8
- package/types/components/ContentMenu.vue.d.ts +8 -8
- package/types/components/Icon.vue.d.ts +62 -12
- package/types/components/ScrollBar.vue.d.ts +83 -0
- package/types/components/ScrollViewer.vue.d.ts +131 -19
- package/types/components/ToolButton.vue.d.ts +56 -59
- package/types/index.d.ts +2 -0
- package/types/layouts/NavMenu.vue.d.ts +92 -23
- package/types/layouts/PropsPanel.vue.d.ts +25 -208
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +7 -7
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +17 -15
- package/types/layouts/workspace/Workspace.vue.d.ts +54 -4
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +7 -9
- package/types/services/events.d.ts +1 -0
- package/types/services/props.d.ts +41 -9
- package/types/services/storage.d.ts +1 -0
- package/types/services/ui.d.ts +3 -1
- package/types/type.d.ts +25 -11
- package/types/utils/index.d.ts +1 -0
- package/types/utils/operator.d.ts +1 -7
- package/types/utils/props.d.ts +0 -1
- package/types/utils/scroll-viewer.d.ts +16 -18
- package/types/utils/stage.d.ts +3 -0
|
@@ -73,24 +73,20 @@ declare class Editor extends BaseService {
|
|
|
73
73
|
* @returns 添加后的节点
|
|
74
74
|
*/
|
|
75
75
|
add(addNode: AddMNode | MNode[], parent?: MContainer | null): Promise<MNode | MNode[]>;
|
|
76
|
+
doRemove(node: MNode): Promise<void>;
|
|
76
77
|
/**
|
|
77
78
|
* 删除组件
|
|
78
79
|
* @param {Object} node
|
|
79
80
|
* @return {Object} 删除的组件配置
|
|
80
81
|
*/
|
|
81
|
-
remove(nodeOrNodeList: MNode | MNode[]): Promise<
|
|
82
|
-
|
|
83
|
-
* 批量删除
|
|
84
|
-
* @param nodes 批量删除的节点
|
|
85
|
-
* @returns 批量删除的节点
|
|
86
|
-
*/
|
|
87
|
-
multiRemove(nodes: MNode[]): Promise<MNode[]>;
|
|
82
|
+
remove(nodeOrNodeList: MNode | MNode[]): Promise<void>;
|
|
83
|
+
doUpdate(config: MNode): Promise<MNode>;
|
|
88
84
|
/**
|
|
89
85
|
* 更新节点
|
|
90
86
|
* @param config 新的节点配置,配置中需要有id信息
|
|
91
87
|
* @returns 更新后的节点配置
|
|
92
88
|
*/
|
|
93
|
-
update(config: MNode): Promise<MNode>;
|
|
89
|
+
update(config: MNode | MNode[]): Promise<MNode | MNode[]>;
|
|
94
90
|
/**
|
|
95
91
|
* 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
|
|
96
92
|
* @param id1 组件ID
|
|
@@ -110,12 +106,14 @@ declare class Editor extends BaseService {
|
|
|
110
106
|
* @returns 添加后的组件节点配置
|
|
111
107
|
*/
|
|
112
108
|
paste(position?: PastePosition): Promise<MNode | MNode[] | void>;
|
|
109
|
+
doPaste(config: MNode[], position?: PastePosition): Promise<MNode[]>;
|
|
110
|
+
doAlignCenter(config: MNode): Promise<MNode>;
|
|
113
111
|
/**
|
|
114
112
|
* 将指点节点设置居中
|
|
115
113
|
* @param config 组件节点配置
|
|
116
114
|
* @returns 当前组件节点配置
|
|
117
115
|
*/
|
|
118
|
-
alignCenter(config: MNode): Promise<MNode |
|
|
116
|
+
alignCenter(config: MNode | MNode[]): Promise<MNode | MNode[]>;
|
|
119
117
|
/**
|
|
120
118
|
* 移动当前选中节点位置
|
|
121
119
|
* @param offset 偏移量
|
|
@@ -10,6 +10,7 @@ declare class Events extends BaseService {
|
|
|
10
10
|
setMethods(methods: Record<string, EventOption[]>): void;
|
|
11
11
|
setMethod(type: string, method: EventOption[]): void;
|
|
12
12
|
getMethod(type: string): EventOption[];
|
|
13
|
+
destroy(): void;
|
|
13
14
|
}
|
|
14
15
|
export declare type EventsService = Events;
|
|
15
16
|
declare const _default: Events;
|
|
@@ -1,16 +1,47 @@
|
|
|
1
1
|
import type { FormConfig } from '@tmagic/form';
|
|
2
|
-
import type { MNode
|
|
2
|
+
import type { MNode } from '@tmagic/schema';
|
|
3
3
|
import BaseService from './BaseService';
|
|
4
4
|
declare class Props extends BaseService {
|
|
5
5
|
private state;
|
|
6
6
|
constructor();
|
|
7
7
|
setPropsConfigs(configs: Record<string, FormConfig>): void;
|
|
8
|
+
fillConfig(config: FormConfig): Promise<{
|
|
9
|
+
type: string;
|
|
10
|
+
items: ({
|
|
11
|
+
title: string;
|
|
12
|
+
labelWidth: string;
|
|
13
|
+
items: (import("@tmagic/form").ChildConfig & {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
})[];
|
|
16
|
+
} | {
|
|
17
|
+
title: string;
|
|
18
|
+
items: {
|
|
19
|
+
type: string;
|
|
20
|
+
name: string;
|
|
21
|
+
items: ({
|
|
22
|
+
name: string;
|
|
23
|
+
label: string;
|
|
24
|
+
type: string;
|
|
25
|
+
options: (mForm: import("@tmagic/form").FormState, { formValue }: any) => {
|
|
26
|
+
text: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}[];
|
|
29
|
+
} | {
|
|
30
|
+
name: string;
|
|
31
|
+
label: string;
|
|
32
|
+
type: string;
|
|
33
|
+
options?: undefined;
|
|
34
|
+
})[];
|
|
35
|
+
}[];
|
|
36
|
+
labelWidth?: undefined;
|
|
37
|
+
})[];
|
|
38
|
+
}[]>;
|
|
8
39
|
/**
|
|
9
40
|
* 为指定类型组件设置组件属性表单配置
|
|
10
41
|
* @param type 组件类型
|
|
11
42
|
* @param config 组件属性表单配置
|
|
12
43
|
*/
|
|
13
|
-
setPropsConfig(type: string, config: FormConfig): void
|
|
44
|
+
setPropsConfig(type: string, config: FormConfig): Promise<void>;
|
|
14
45
|
/**
|
|
15
46
|
* 获取指点类型的组件属性表单配置
|
|
16
47
|
* @param type 组件类型
|
|
@@ -30,18 +61,12 @@ declare class Props extends BaseService {
|
|
|
30
61
|
* @returns 组件初始值
|
|
31
62
|
*/
|
|
32
63
|
getPropsValue(type: string, { inputEvent, ...defaultValue }?: Record<string, any>): Promise<any>;
|
|
33
|
-
/**
|
|
34
|
-
* 生成指定位数的GUID,无【-】格式
|
|
35
|
-
* @param digit 位数,默认值8
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
guid(digit?: number): string;
|
|
39
64
|
createId(type: string | number): Promise<string>;
|
|
40
65
|
/**
|
|
41
66
|
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
42
67
|
* @param {Object} config 组件配置
|
|
43
68
|
*/
|
|
44
|
-
setNewItemId(config: MNode
|
|
69
|
+
setNewItemId(config: MNode): Promise<MNode>;
|
|
45
70
|
/**
|
|
46
71
|
* 获取默认属性配置
|
|
47
72
|
* @param type 组件类型
|
|
@@ -60,6 +85,13 @@ declare class Props extends BaseService {
|
|
|
60
85
|
layout?: undefined;
|
|
61
86
|
items?: undefined;
|
|
62
87
|
}>;
|
|
88
|
+
destroy(): void;
|
|
89
|
+
/**
|
|
90
|
+
* 生成指定位数的GUID,无【-】格式
|
|
91
|
+
* @param digit 位数,默认值8
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
private guid;
|
|
63
95
|
}
|
|
64
96
|
export declare type PropsService = Props;
|
|
65
97
|
declare const _default: Props;
|
|
@@ -49,6 +49,7 @@ export declare class WebStorage extends BaseService {
|
|
|
49
49
|
* 设置存储项,支持storageService.usePlugin
|
|
50
50
|
*/
|
|
51
51
|
setItem(key: string, value: any, options?: Options): Promise<void>;
|
|
52
|
+
destroy(): void;
|
|
52
53
|
private getValueAndProtocol;
|
|
53
54
|
}
|
|
54
55
|
export declare type StorageService = WebStorage;
|
package/types/services/ui.d.ts
CHANGED
|
@@ -25,10 +25,12 @@ declare class Ui extends BaseService {
|
|
|
25
25
|
constructor();
|
|
26
26
|
set<T = any>(name: keyof UiState, value: T): void;
|
|
27
27
|
get<T>(name: keyof typeof state): T;
|
|
28
|
+
initColumnWidth(): void;
|
|
28
29
|
zoom(zoom: number): void;
|
|
30
|
+
calcZoom(): number;
|
|
31
|
+
destroy(): void;
|
|
29
32
|
private setColumnWidth;
|
|
30
33
|
private setStageRect;
|
|
31
|
-
private calcZoom;
|
|
32
34
|
}
|
|
33
35
|
export declare type UiService = Ui;
|
|
34
36
|
declare const _default: Ui;
|
package/types/type.d.ts
CHANGED
|
@@ -2,7 +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
|
+
import type { ContainerHighlightType, MoveableOptions } from '@tmagic/stage';
|
|
6
6
|
import type { ComponentListService } from './services/componentList';
|
|
7
7
|
import type { EditorService } from './services/editor';
|
|
8
8
|
import type { EventsService } from './services/events';
|
|
@@ -29,6 +29,7 @@ export interface StageOptions {
|
|
|
29
29
|
autoScrollIntoView: boolean;
|
|
30
30
|
containerHighlightClassName: string;
|
|
31
31
|
containerHighlightDuration: number;
|
|
32
|
+
containerHighlightType: ContainerHighlightType;
|
|
32
33
|
render: () => HTMLDivElement;
|
|
33
34
|
moveableOptions: MoveableOptions | ((core?: StageCore) => MoveableOptions);
|
|
34
35
|
canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
@@ -53,15 +54,20 @@ export interface PropsState {
|
|
|
53
54
|
export interface ComponentGroupState {
|
|
54
55
|
list: ComponentGroup[];
|
|
55
56
|
}
|
|
57
|
+
export declare enum ColumnLayout {
|
|
58
|
+
LEFT = "left",
|
|
59
|
+
CENTER = "center",
|
|
60
|
+
RIGHT = "right"
|
|
61
|
+
}
|
|
56
62
|
export interface SetColumnWidth {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
[ColumnLayout.LEFT]?: number;
|
|
64
|
+
[ColumnLayout.CENTER]?: number | 'auto';
|
|
65
|
+
[ColumnLayout.RIGHT]?: number;
|
|
60
66
|
}
|
|
61
67
|
export interface GetColumnWidth {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
[ColumnLayout.LEFT]: number;
|
|
69
|
+
[ColumnLayout.CENTER]: number;
|
|
70
|
+
[ColumnLayout.RIGHT]: number;
|
|
65
71
|
}
|
|
66
72
|
export interface StageRect {
|
|
67
73
|
width: number;
|
|
@@ -138,6 +144,7 @@ export interface MenuButton {
|
|
|
138
144
|
/** type为button/dropdown时点击运行的方法 */
|
|
139
145
|
handler?: (data: Services, event: MouseEvent) => Promise<any> | any;
|
|
140
146
|
/** type为dropdown时,下拉的菜单列表, 或者有子菜单时 */
|
|
147
|
+
className?: string;
|
|
141
148
|
items?: MenuButton[];
|
|
142
149
|
}
|
|
143
150
|
export interface MenuComponent {
|
|
@@ -150,6 +157,7 @@ export interface MenuComponent {
|
|
|
150
157
|
listeners?: Record<string, Function>;
|
|
151
158
|
slots?: Record<string, any>;
|
|
152
159
|
/** 是否显示,默认为true */
|
|
160
|
+
className?: string;
|
|
153
161
|
display?: boolean | ((data?: Services) => Promise<boolean> | boolean);
|
|
154
162
|
}
|
|
155
163
|
/**
|
|
@@ -160,15 +168,15 @@ export interface MenuComponent {
|
|
|
160
168
|
* 'zoom-in': 放大按钮
|
|
161
169
|
* 'zoom-out': 缩小按钮
|
|
162
170
|
*/
|
|
163
|
-
export declare type MenuItem = '/' | 'delete' | 'undo' | 'redo' | 'zoom' | 'zoom-in' | 'zoom-out' | 'guides' | 'rule' | MenuButton | MenuComponent;
|
|
171
|
+
export declare type MenuItem = '/' | 'delete' | 'undo' | 'redo' | 'zoom' | 'zoom-in' | 'zoom-out' | 'guides' | 'rule' | MenuButton | MenuComponent | string;
|
|
164
172
|
/** 工具栏 */
|
|
165
173
|
export interface MenuBarData {
|
|
166
174
|
/** 顶部工具栏左边项 */
|
|
167
|
-
|
|
175
|
+
[ColumnLayout.LEFT]?: MenuItem[];
|
|
168
176
|
/** 顶部工具栏中间项 */
|
|
169
|
-
|
|
177
|
+
[ColumnLayout.CENTER]?: MenuItem[];
|
|
170
178
|
/** 顶部工具栏右边项 */
|
|
171
|
-
|
|
179
|
+
[ColumnLayout.RIGHT]?: MenuItem[];
|
|
172
180
|
}
|
|
173
181
|
export interface SideComponent extends MenuComponent {
|
|
174
182
|
/** 显示文案 */
|
|
@@ -227,3 +235,9 @@ export declare enum Keys {
|
|
|
227
235
|
}
|
|
228
236
|
export declare const H_GUIDE_LINE_STORAGE_KEY = "$MagicStageHorizontalGuidelinesData";
|
|
229
237
|
export declare const V_GUIDE_LINE_STORAGE_KEY = "$MagicStageVerticalGuidelinesData";
|
|
238
|
+
export interface ScrollViewerEvent {
|
|
239
|
+
scrollLeft: number;
|
|
240
|
+
scrollTop: number;
|
|
241
|
+
scrollHeight: number;
|
|
242
|
+
scrollWidth: number;
|
|
243
|
+
}
|
package/types/utils/index.d.ts
CHANGED
|
@@ -17,11 +17,5 @@ export declare const getPositionInContainer: (position: PastePosition | undefine
|
|
|
17
17
|
left: number;
|
|
18
18
|
top: number;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
* 删除前置操作:实现了在编辑器中删除元素节点,并返回父级元素信息以供stage更新
|
|
22
|
-
* @param node 待删除的节点
|
|
23
|
-
* @returns 父级元素,root根元素
|
|
24
|
-
*/
|
|
25
|
-
export declare const beforeRemove: (node: MNode) => Promise<MContainer | void>;
|
|
26
|
-
export declare const getAddParent: (addNode: AddMNode | MNode[]) => MContainer | undefined;
|
|
20
|
+
export declare const getAddParent: (node: MNode) => MContainer | undefined;
|
|
27
21
|
export declare const getDefaultConfig: (addNode: AddMNode, parentNode: MContainer) => Promise<any>;
|
package/types/utils/props.d.ts
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
1
3
|
interface ScrollViewerOptions {
|
|
2
4
|
container: HTMLDivElement;
|
|
3
5
|
target: HTMLDivElement;
|
|
4
6
|
zoom: number;
|
|
5
7
|
}
|
|
6
|
-
export declare class ScrollViewer {
|
|
7
|
-
private enter;
|
|
8
|
-
private targetEnter;
|
|
9
|
-
private keydown;
|
|
8
|
+
export declare class ScrollViewer extends EventEmitter {
|
|
10
9
|
private container;
|
|
11
10
|
private target;
|
|
12
11
|
private zoom;
|
|
13
12
|
private scrollLeft;
|
|
14
13
|
private scrollTop;
|
|
15
|
-
private
|
|
16
|
-
private
|
|
14
|
+
private scrollHeight;
|
|
15
|
+
private scrollWidth;
|
|
16
|
+
private width;
|
|
17
|
+
private height;
|
|
18
|
+
private translateXCorrectionValue;
|
|
19
|
+
private translateYCorrectionValue;
|
|
17
20
|
private resizeObserver;
|
|
18
21
|
constructor(options: ScrollViewerOptions);
|
|
19
22
|
destroy(): void;
|
|
20
23
|
setZoom(zoom: number): void;
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
scrollTo({ left, top }: {
|
|
25
|
+
left?: number;
|
|
26
|
+
top?: number;
|
|
27
|
+
}): void;
|
|
23
28
|
private wheelHandler;
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
private targetMouseLeaveHandler;
|
|
28
|
-
private mousedownHandler;
|
|
29
|
-
private mouseupHandler;
|
|
30
|
-
private mousemoveHandler;
|
|
31
|
-
private keydownHandler;
|
|
32
|
-
private keyupHandler;
|
|
33
|
-
private setScrollOffset;
|
|
29
|
+
private getPos;
|
|
30
|
+
private setScrollSize;
|
|
31
|
+
private setSize;
|
|
34
32
|
}
|
|
35
33
|
export {};
|