@tmagic/editor 1.1.0-beta.6 → 1.1.0-beta.9
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 +4 -0
- package/dist/tmagic-editor.mjs +322 -320
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +321 -318
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +7 -7
- package/src/Editor.vue +8 -2
- package/src/components/Icon.vue +1 -1
- package/src/fields/UISelect.vue +0 -1
- package/src/index.ts +1 -1
- package/src/layouts/workspace/PageBar.vue +43 -161
- package/src/layouts/workspace/PageBarScrollContainer.vue +111 -0
- package/src/layouts/workspace/Stage.vue +6 -2
- package/src/layouts/workspace/ViewerMenu.vue +7 -10
- package/src/layouts/workspace/Workspace.vue +1 -1
- package/src/services/editor.ts +158 -106
- package/src/theme/component-list-panel.scss +5 -0
- package/src/type.ts +2 -1
- package/src/utils/editor.ts +17 -10
- package/src/utils/operator.ts +21 -122
- package/types/Editor.vue.d.ts +10 -1
- package/types/fields/UISelect.vue.d.ts +0 -4
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +48 -0
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +3 -3
- package/types/services/editor.d.ts +9 -17
- package/types/type.d.ts +2 -1
- package/types/utils/editor.d.ts +4 -1
- package/types/utils/operator.d.ts +3 -26
|
@@ -3,7 +3,6 @@ declare const _default: {
|
|
|
3
3
|
$: import("vue").ComponentInternalInstance;
|
|
4
4
|
$data: {};
|
|
5
5
|
$props: Partial<{}> & Omit<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
6
|
-
labelWidth: string;
|
|
7
6
|
config: any;
|
|
8
7
|
model: any;
|
|
9
8
|
prop: string;
|
|
@@ -25,7 +24,6 @@ declare const _default: {
|
|
|
25
24
|
$emit: (event: "change", ...args: any[]) => void;
|
|
26
25
|
$el: any;
|
|
27
26
|
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
28
|
-
labelWidth: string;
|
|
29
27
|
config: any;
|
|
30
28
|
model: any;
|
|
31
29
|
prop: string;
|
|
@@ -53,7 +51,6 @@ declare const _default: {
|
|
|
53
51
|
$nextTick: typeof import("vue").nextTick;
|
|
54
52
|
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
55
53
|
} & Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
56
|
-
labelWidth: string;
|
|
57
54
|
config: any;
|
|
58
55
|
model: any;
|
|
59
56
|
prop: string;
|
|
@@ -65,7 +62,6 @@ declare const _default: {
|
|
|
65
62
|
__isTeleport?: undefined;
|
|
66
63
|
__isSuspense?: undefined;
|
|
67
64
|
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
68
|
-
labelWidth: string;
|
|
69
65
|
config: any;
|
|
70
66
|
model: any;
|
|
71
67
|
prop: string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
new (...args: any[]): {
|
|
3
|
+
$: import("vue").ComponentInternalInstance;
|
|
4
|
+
$data: {};
|
|
5
|
+
$props: Partial<{}> & Omit<Readonly<import("vue").ExtractPropTypes<{}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>;
|
|
6
|
+
$attrs: {
|
|
7
|
+
[x: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
$refs: {
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
$slots: Readonly<{
|
|
13
|
+
[name: string]: import("vue").Slot | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
$root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
16
|
+
$parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null;
|
|
17
|
+
$emit: ((event: string, ...args: any[]) => void) | ((event: string, ...args: any[]) => void);
|
|
18
|
+
$el: any;
|
|
19
|
+
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, {}> & {
|
|
20
|
+
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
21
|
+
created?: ((() => void) | (() => void)[]) | undefined;
|
|
22
|
+
beforeMount?: ((() => void) | (() => void)[]) | undefined;
|
|
23
|
+
mounted?: ((() => void) | (() => void)[]) | undefined;
|
|
24
|
+
beforeUpdate?: ((() => void) | (() => void)[]) | undefined;
|
|
25
|
+
updated?: ((() => void) | (() => void)[]) | undefined;
|
|
26
|
+
activated?: ((() => void) | (() => void)[]) | undefined;
|
|
27
|
+
deactivated?: ((() => void) | (() => void)[]) | undefined;
|
|
28
|
+
beforeDestroy?: ((() => void) | (() => void)[]) | undefined;
|
|
29
|
+
beforeUnmount?: ((() => void) | (() => void)[]) | undefined;
|
|
30
|
+
destroyed?: ((() => void) | (() => void)[]) | undefined;
|
|
31
|
+
unmounted?: ((() => void) | (() => void)[]) | undefined;
|
|
32
|
+
renderTracked?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
33
|
+
renderTriggered?: (((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[]) | undefined;
|
|
34
|
+
errorCaptured?: (((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}>> | null, info: string) => boolean | void)[]) | undefined;
|
|
35
|
+
};
|
|
36
|
+
$forceUpdate: () => void;
|
|
37
|
+
$nextTick: typeof import("vue").nextTick;
|
|
38
|
+
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
39
|
+
} & Readonly<import("vue").ExtractPropTypes<{}>> & import("vue").ShallowUnwrapRef<{}> & {} & import("vue").ComponentCustomProperties;
|
|
40
|
+
__isFragment?: undefined;
|
|
41
|
+
__isTeleport?: undefined;
|
|
42
|
+
__isSuspense?: undefined;
|
|
43
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
44
|
+
$slots: {
|
|
45
|
+
default: (_: {}) => any;
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
export default _default;
|
|
@@ -27,7 +27,7 @@ declare const _default: {
|
|
|
27
27
|
}>, {
|
|
28
28
|
isMultiSelect: boolean;
|
|
29
29
|
}>>>, {
|
|
30
|
-
show: (e: MouseEvent) => void
|
|
30
|
+
show: (e: MouseEvent) => Promise<void>;
|
|
31
31
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {
|
|
32
32
|
isMultiSelect: boolean;
|
|
33
33
|
}> & {
|
|
@@ -55,7 +55,7 @@ declare const _default: {
|
|
|
55
55
|
}>, {
|
|
56
56
|
isMultiSelect: boolean;
|
|
57
57
|
}>>> & import("vue").ShallowUnwrapRef<{
|
|
58
|
-
show: (e: MouseEvent) => void
|
|
58
|
+
show: (e: MouseEvent) => Promise<void>;
|
|
59
59
|
}> & {} & import("vue").ComponentCustomProperties;
|
|
60
60
|
__isFragment?: undefined;
|
|
61
61
|
__isTeleport?: undefined;
|
|
@@ -65,7 +65,7 @@ declare const _default: {
|
|
|
65
65
|
}>, {
|
|
66
66
|
isMultiSelect: boolean;
|
|
67
67
|
}>>>, {
|
|
68
|
-
show: (e: MouseEvent) => void
|
|
68
|
+
show: (e: MouseEvent) => Promise<void>;
|
|
69
69
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {
|
|
70
70
|
isMultiSelect: boolean;
|
|
71
71
|
}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
@@ -65,37 +65,28 @@ declare class Editor extends BaseService {
|
|
|
65
65
|
* @returns 加入多选的节点配置
|
|
66
66
|
*/
|
|
67
67
|
multiSelect(ids: Id[]): void;
|
|
68
|
-
|
|
69
|
-
* 批量向容器添加节点
|
|
70
|
-
* @param configs 将要添加的节点数组
|
|
71
|
-
* @returns 添加后的节点
|
|
72
|
-
*/
|
|
73
|
-
multiAdd(configs: MNode[]): Promise<MNode[]>;
|
|
68
|
+
doAdd(node: MNode, parent: MContainer): Promise<MNode>;
|
|
74
69
|
/**
|
|
75
70
|
* 向指点容器添加组件节点
|
|
76
71
|
* @param addConfig 将要添加的组件节点配置
|
|
77
72
|
* @param parent 要添加到的容器组件节点配置,如果不设置,默认为当前选中的组件的父节点
|
|
78
73
|
* @returns 添加后的节点
|
|
79
74
|
*/
|
|
80
|
-
add(addNode: AddMNode, parent?: MContainer | null): Promise<MNode>;
|
|
75
|
+
add(addNode: AddMNode | MNode[], parent?: MContainer | null): Promise<MNode | MNode[]>;
|
|
76
|
+
doRemove(node: MNode): Promise<void>;
|
|
81
77
|
/**
|
|
82
78
|
* 删除组件
|
|
83
79
|
* @param {Object} node
|
|
84
80
|
* @return {Object} 删除的组件配置
|
|
85
81
|
*/
|
|
86
|
-
remove(nodeOrNodeList: MNode | MNode[]): Promise<
|
|
87
|
-
|
|
88
|
-
* 批量删除
|
|
89
|
-
* @param nodes 批量删除的节点
|
|
90
|
-
* @returns 批量删除的节点
|
|
91
|
-
*/
|
|
92
|
-
multiRemove(nodes: MNode[]): Promise<MNode[]>;
|
|
82
|
+
remove(nodeOrNodeList: MNode | MNode[]): Promise<void>;
|
|
83
|
+
doUpdate(config: MNode): Promise<MNode>;
|
|
93
84
|
/**
|
|
94
85
|
* 更新节点
|
|
95
86
|
* @param config 新的节点配置,配置中需要有id信息
|
|
96
87
|
* @returns 更新后的节点配置
|
|
97
88
|
*/
|
|
98
|
-
update(config: MNode): Promise<MNode>;
|
|
89
|
+
update(config: MNode | MNode[]): Promise<MNode | MNode[]>;
|
|
99
90
|
/**
|
|
100
91
|
* 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
|
|
101
92
|
* @param id1 组件ID
|
|
@@ -114,13 +105,14 @@ declare class Editor extends BaseService {
|
|
|
114
105
|
* @param position 粘贴的坐标
|
|
115
106
|
* @returns 添加后的组件节点配置
|
|
116
107
|
*/
|
|
117
|
-
paste(position?: PastePosition): Promise<MNode[] | void>;
|
|
108
|
+
paste(position?: PastePosition): Promise<MNode | MNode[] | void>;
|
|
109
|
+
doAlignCenter(config: MNode): Promise<MNode>;
|
|
118
110
|
/**
|
|
119
111
|
* 将指点节点设置居中
|
|
120
112
|
* @param config 组件节点配置
|
|
121
113
|
* @returns 当前组件节点配置
|
|
122
114
|
*/
|
|
123
|
-
alignCenter(config: MNode): Promise<MNode |
|
|
115
|
+
alignCenter(config: MNode | MNode[]): Promise<MNode | MNode[]>;
|
|
124
116
|
/**
|
|
125
117
|
* 移动当前选中节点位置
|
|
126
118
|
* @param offset 偏移量
|
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>;
|
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;
|
|
@@ -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: (addNode: AddMNode | MNode[]) => MContainer | undefined;
|
|
21
|
+
export declare const getDefaultConfig: (addNode: AddMNode, parentNode: MContainer) => Promise<any>;
|