@tmagic/editor 1.1.0-beta.7 → 1.1.0
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 +50 -0
- package/dist/tmagic-editor.mjs +1198 -1027
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +1201 -1026
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +10 -10
- package/src/Editor.vue +22 -6
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/Icon.vue +7 -21
- 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 +10 -13
- package/src/layouts/workspace/Workspace.vue +133 -138
- package/src/services/componentList.ts +5 -0
- package/src/services/editor.ts +201 -112
- 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/component-list-panel.scss +5 -0
- package/src/theme/nav-menu.scss +6 -0
- package/src/type.ts +28 -11
- package/src/utils/editor.ts +17 -10
- package/src/utils/index.ts +1 -0
- package/src/utils/operator.ts +22 -123
- 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/ViewerMenu.vue.d.ts +3 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +54 -4
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +10 -17
- 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/editor.d.ts +4 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/operator.d.ts +3 -26
- 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
|
@@ -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/editor.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare const generatePageNameByApp: (app: MApp) => string;
|
|
|
33
33
|
export declare const isFixed: (node: MNode) => boolean;
|
|
34
34
|
export declare const getNodeIndex: (node: MNode, parent: MContainer | MApp) => number;
|
|
35
35
|
export declare const getRelativeStyle: (style?: Record<string, any>) => Record<string, any>;
|
|
36
|
-
export declare const getInitPositionStyle: (style: Record<string, any> | undefined, layout: Layout
|
|
36
|
+
export declare const getInitPositionStyle: (style: Record<string, any> | undefined, layout: Layout) => Record<string, any>;
|
|
37
37
|
export declare const setLayout: (node: MNode, layout: Layout) => MNode;
|
|
38
38
|
export declare const change2Fixed: (node: MNode, root: MApp) => {
|
|
39
39
|
left: number;
|
|
@@ -42,3 +42,6 @@ export declare const change2Fixed: (node: MNode, root: MApp) => {
|
|
|
42
42
|
export declare const Fixed2Other: (node: MNode, root: MApp, getLayout: (parent: MNode, node?: MNode) => Promise<Layout>) => Promise<Record<string, any>>;
|
|
43
43
|
export declare const getGuideLineFromCache: (key: string) => number[];
|
|
44
44
|
export declare const fixNodeLeft: (config: MNode, parent: MContainer, doc?: Document) => any;
|
|
45
|
+
export declare const fixNodePosition: (config: MNode, parent: MContainer, stage: StageCore | null) => {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
} | undefined;
|
package/types/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Id, MContainer, MNode } from '@tmagic/schema';
|
|
2
|
-
import { AddMNode,
|
|
2
|
+
import { AddMNode, PastePosition } from '../type';
|
|
3
3
|
/**
|
|
4
4
|
* 粘贴前置操作:返回分配了新id以及校准了坐标的配置
|
|
5
5
|
* @param position 粘贴的坐标
|
|
@@ -7,18 +7,6 @@ import { AddMNode, Layout, PastePosition } from '../type';
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
export declare const beforePaste: (position: PastePosition, config: MNode[]) => Promise<MNode[]>;
|
|
10
|
-
/**
|
|
11
|
-
* 新增元素前置操作,实现了在编辑器中新增元素节点,并返回新增元素信息以供stage更新
|
|
12
|
-
* @param addNode 待添加元素的配置
|
|
13
|
-
* @param parent 父级容器(可选)
|
|
14
|
-
* @returns 新增的元素,父级元素,布局方式,是否为根页面
|
|
15
|
-
*/
|
|
16
|
-
export declare const beforeAdd: (addNode: AddMNode, parent?: MContainer | null) => Promise<{
|
|
17
|
-
parentNode: MContainer;
|
|
18
|
-
newNode: MNode;
|
|
19
|
-
layout: Layout;
|
|
20
|
-
isPage: boolean;
|
|
21
|
-
}>;
|
|
22
10
|
/**
|
|
23
11
|
* 将元素粘贴到容器内时,将相对于画布坐标转换为相对于容器的坐标
|
|
24
12
|
* @param position PastePosition 粘贴时相对于画布的坐标
|
|
@@ -29,16 +17,5 @@ export declare const getPositionInContainer: (position: PastePosition | undefine
|
|
|
29
17
|
left: number;
|
|
30
18
|
top: number;
|
|
31
19
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* @param parentNode 父元素
|
|
35
|
-
* @param newNode 当前新增元素
|
|
36
|
-
* @param layout 布局方式
|
|
37
|
-
*/
|
|
38
|
-
export declare const notifyAddToStage: (parentNode: MContainer, newNode: MNode, layout: Layout) => Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* 删除前置操作:实现了在编辑器中删除元素节点,并返回父级元素信息以供stage更新
|
|
41
|
-
* @param node 待删除的节点
|
|
42
|
-
* @returns 父级元素,root根元素
|
|
43
|
-
*/
|
|
44
|
-
export declare const beforeRemove: (node: MNode) => Promise<MContainer | void>;
|
|
20
|
+
export declare const getAddParent: (node: MNode) => MContainer | undefined;
|
|
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 {};
|