@tmagic/editor 1.0.0-beta.13 → 1.0.0-beta.16
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/coverage/clover.xml +703 -601
- package/coverage/coverage-final.json +35 -33
- package/coverage/lcov-report/index.html +56 -56
- package/coverage/lcov-report/src/Editor.vue.html +1 -1
- package/coverage/lcov-report/{layouts/sidebar/LayerMenu.vue.html → src/components/ContentMenu.vue.html} +137 -95
- package/coverage/lcov-report/src/components/Icon.vue.html +5 -5
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
- package/coverage/lcov-report/src/components/ToolButton.vue.html +180 -63
- package/coverage/lcov-report/src/components/index.html +34 -19
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Framework.vue.html +13 -13
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/index.html +15 -15
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +78 -12
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +149 -92
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +43 -121
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +23 -140
- package/coverage/lcov-report/{utils/undo-redo.ts.html → src/layouts/sidebar/TabPane.vue.html} +94 -118
- package/coverage/lcov-report/src/layouts/sidebar/index.html +64 -49
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +99 -12
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +86 -95
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +208 -97
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +3 -3
- package/coverage/lcov-report/src/layouts/workspace/index.html +35 -35
- package/coverage/lcov-report/src/services/BaseService.ts.html +11 -11
- package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
- package/coverage/lcov-report/src/services/editor.ts.html +103 -10
- package/coverage/lcov-report/src/services/events.ts.html +1 -1
- package/coverage/lcov-report/src/services/history.ts.html +29 -8
- package/coverage/lcov-report/src/services/index.html +25 -25
- package/coverage/lcov-report/src/services/props.ts.html +4 -7
- package/coverage/lcov-report/src/services/ui.ts.html +1 -1
- package/coverage/lcov-report/src/type.ts.html +8 -14
- package/coverage/lcov-report/src/utils/compose.ts.html +4 -4
- package/coverage/lcov-report/src/utils/config.ts.html +1 -1
- package/coverage/lcov-report/src/utils/editor.ts.html +2 -2
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
- package/coverage/lcov-report/src/utils/props.ts.html +59 -2
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
- package/coverage/lcov.info +1679 -1402
- package/dist/style.css +47 -20
- package/dist/tmagic-editor.es.js +732 -485
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +733 -485
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +1 -1
- package/dist/types/src/components/ToolButton.vue.d.ts +12 -1
- package/dist/types/src/fields/UISelect.vue.d.ts +4 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/layouts/CodeEditor.vue.d.ts +13 -4
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -0
- package/dist/types/src/layouts/sidebar/Sidebar.vue.d.ts +2 -3
- package/dist/types/src/layouts/sidebar/TabPane.vue.d.ts +14 -0
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +2 -0
- package/dist/types/src/services/history.d.ts +1 -0
- package/dist/types/src/services/props.d.ts +2 -2
- package/dist/types/src/type.d.ts +6 -8
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +15 -10
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ToolButton.vue +66 -27
- package/src/fields/UISelect.vue +14 -6
- package/src/index.ts +2 -0
- package/src/layouts/CodeEditor.vue +20 -10
- package/src/layouts/Framework.vue +6 -6
- package/src/layouts/sidebar/ComponentListPanel.vue +23 -1
- package/src/layouts/sidebar/LayerMenu.vue +91 -72
- package/src/layouts/sidebar/LayerPanel.vue +23 -49
- package/src/layouts/sidebar/Sidebar.vue +13 -52
- package/src/layouts/sidebar/TabPane.vue +68 -0
- package/src/layouts/workspace/PageBar.vue +35 -6
- package/src/layouts/workspace/Stage.vue +41 -44
- package/src/layouts/workspace/ViewerMenu.vue +104 -67
- package/src/layouts/workspace/Workspace.vue +2 -2
- package/src/services/editor.ts +33 -2
- package/src/services/history.ts +7 -0
- package/src/services/props.ts +2 -3
- package/src/theme/common/var.scss +1 -0
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +1 -1
- package/src/theme/nav-menu.scss +6 -2
- package/src/theme/page-bar.scss +22 -1
- package/src/theme/props-panel.scss +4 -0
- package/src/type.ts +6 -8
- package/src/utils/editor.ts +1 -1
- package/src/utils/polyfills.ts +22 -0
- package/src/utils/props.ts +19 -0
- package/coverage/lcov-report/Icon.vue.html +0 -172
- package/coverage/lcov-report/ToolButton.vue.html +0 -655
- package/coverage/lcov-report/layouts/sidebar/index.html +0 -116
- package/coverage/lcov-report/utils/index.html +0 -116
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -980
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -188
- package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
|
@@ -126,9 +126,9 @@ declare const _default: DefineComponent<{
|
|
|
126
126
|
"onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
|
|
127
127
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
128
128
|
}, {
|
|
129
|
-
componentGroupList: ComponentGroup[];
|
|
130
129
|
menu: MenuBarData;
|
|
131
130
|
modelValue: MApp;
|
|
131
|
+
componentGroupList: ComponentGroup[];
|
|
132
132
|
propsConfigs: Record<string, FormConfig>;
|
|
133
133
|
propsValues: Record<string, MNode>;
|
|
134
134
|
eventMethodList: Record<string, any>;
|
|
@@ -9,6 +9,10 @@ declare const _default: DefineComponent<{
|
|
|
9
9
|
display: boolean;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
eventType: {
|
|
13
|
+
type: PropType<"mousedown" | "mouseup" | "click">;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
12
16
|
}, {
|
|
13
17
|
ZoomIn: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{}>, {}>;
|
|
14
18
|
ZoomOut: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{}>, {}>;
|
|
@@ -19,7 +23,9 @@ declare const _default: DefineComponent<{
|
|
|
19
23
|
zoomInHandler: () => void | undefined;
|
|
20
24
|
zoomOutHandler: () => void | undefined;
|
|
21
25
|
dropdownHandler(command: any): void;
|
|
22
|
-
|
|
26
|
+
clickHandler(item: MenuButton | MenuComponent, event: MouseEvent): void;
|
|
27
|
+
mousedownHandler(item: MenuButton | MenuComponent, event: MouseEvent): void;
|
|
28
|
+
mouseupHandler(item: MenuButton | MenuComponent, event: MouseEvent): void;
|
|
23
29
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
24
30
|
data: {
|
|
25
31
|
type: PropType<string | MenuButton | MenuComponent>;
|
|
@@ -29,7 +35,12 @@ declare const _default: DefineComponent<{
|
|
|
29
35
|
display: boolean;
|
|
30
36
|
};
|
|
31
37
|
};
|
|
38
|
+
eventType: {
|
|
39
|
+
type: PropType<"mousedown" | "mouseup" | "click">;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
32
42
|
}>>, {
|
|
33
43
|
data: string | MenuButton | MenuComponent;
|
|
44
|
+
eventType: "mousedown" | "mouseup" | "click";
|
|
34
45
|
}>;
|
|
35
46
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DefineComponent,
|
|
1
|
+
import type { DefineComponent, ComponentOptionsMixin, EmitsOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps, ComputedRef, Ref, ExtractPropTypes } from 'vue';
|
|
2
2
|
declare const _default: DefineComponent<{
|
|
3
3
|
labelWidth: StringConstructor;
|
|
4
4
|
config: ObjectConstructor;
|
|
@@ -9,6 +9,9 @@ declare const _default: DefineComponent<{
|
|
|
9
9
|
};
|
|
10
10
|
name: StringConstructor;
|
|
11
11
|
}, {
|
|
12
|
+
Delete: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{}>, {}>;
|
|
13
|
+
Pointer: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{}>, {}>;
|
|
14
|
+
Close: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{}>, {}>;
|
|
12
15
|
val: ComputedRef<any>;
|
|
13
16
|
uiSelectMode: Ref<boolean>;
|
|
14
17
|
toName: ComputedRef<string>;
|
|
@@ -13,6 +13,7 @@ export { default as uiService } from './services/ui';
|
|
|
13
13
|
export { default as ComponentListPanel } from './layouts/sidebar/ComponentListPanel.vue';
|
|
14
14
|
export { default as LayerPanel } from './layouts/sidebar/LayerPanel.vue';
|
|
15
15
|
export { default as PropsPanel } from './layouts/PropsPanel.vue';
|
|
16
|
+
export { default as ToolButton } from './components/ToolButton.vue';
|
|
16
17
|
declare const _default: {
|
|
17
18
|
install: (app: App, opt?: InstallOptions | undefined) => void;
|
|
18
19
|
};
|
|
@@ -8,13 +8,17 @@ declare const _default: DefineComponent<{
|
|
|
8
8
|
type: (StringConstructor | ObjectConstructor)[];
|
|
9
9
|
};
|
|
10
10
|
type: {
|
|
11
|
-
type: StringConstructor
|
|
11
|
+
type: StringConstructor;
|
|
12
12
|
default: () => string;
|
|
13
13
|
};
|
|
14
14
|
language: {
|
|
15
|
-
type: StringConstructor
|
|
15
|
+
type: StringConstructor;
|
|
16
16
|
default: () => string;
|
|
17
17
|
};
|
|
18
|
+
options: {
|
|
19
|
+
type: ObjectConstructor;
|
|
20
|
+
default: () => {};
|
|
21
|
+
};
|
|
18
22
|
}, {
|
|
19
23
|
values: Ref<string>;
|
|
20
24
|
loading: Ref<boolean>;
|
|
@@ -30,18 +34,23 @@ declare const _default: DefineComponent<{
|
|
|
30
34
|
type: (StringConstructor | ObjectConstructor)[];
|
|
31
35
|
};
|
|
32
36
|
type: {
|
|
33
|
-
type: StringConstructor
|
|
37
|
+
type: StringConstructor;
|
|
34
38
|
default: () => string;
|
|
35
39
|
};
|
|
36
40
|
language: {
|
|
37
|
-
type: StringConstructor
|
|
41
|
+
type: StringConstructor;
|
|
38
42
|
default: () => string;
|
|
39
43
|
};
|
|
44
|
+
options: {
|
|
45
|
+
type: ObjectConstructor;
|
|
46
|
+
default: () => {};
|
|
47
|
+
};
|
|
40
48
|
}>> & {
|
|
41
49
|
onInitd?: ((...args: any[]) => any) | undefined;
|
|
42
50
|
onSave?: ((...args: any[]) => any) | undefined;
|
|
43
51
|
}, {
|
|
44
52
|
type: string;
|
|
45
53
|
language: string;
|
|
54
|
+
options: Record<string, any>;
|
|
46
55
|
}>;
|
|
47
56
|
export default _default;
|
|
@@ -8,5 +8,6 @@ declare const _default: DefineComponent<{}, {
|
|
|
8
8
|
title: string;
|
|
9
9
|
}[] | undefined>;
|
|
10
10
|
appendComponent({ text, type, data }: ComponentItem): void;
|
|
11
|
+
dragstartHandler({ text, type, data }: ComponentItem, e: DragEvent): void;
|
|
11
12
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{}>>, {}>;
|
|
12
13
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DefineComponent, Ref,
|
|
2
|
-
import { SideBarData
|
|
1
|
+
import type { DefineComponent, Ref, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import { SideBarData } from '../../type';
|
|
3
3
|
declare const _default: DefineComponent<{
|
|
4
4
|
data: {
|
|
5
5
|
type: PropType<SideBarData>;
|
|
@@ -11,7 +11,6 @@ declare const _default: DefineComponent<{
|
|
|
11
11
|
};
|
|
12
12
|
}, {
|
|
13
13
|
activeTabName: Ref<string>;
|
|
14
|
-
items: ComputedRef<SideComponent[] | Record<string, any>[]>;
|
|
15
14
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
16
15
|
data: {
|
|
17
16
|
type: PropType<SideBarData>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import { SideComponent, SideItem } from '../../type';
|
|
3
|
+
declare const _default: DefineComponent<{
|
|
4
|
+
data: {
|
|
5
|
+
type: PropType<SideItem>;
|
|
6
|
+
};
|
|
7
|
+
}, {
|
|
8
|
+
config: ComputedRef<SideComponent | undefined>;
|
|
9
|
+
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
10
|
+
data: {
|
|
11
|
+
type: PropType<SideItem>;
|
|
12
|
+
};
|
|
13
|
+
}>>, {}>;
|
|
14
|
+
export default _default;
|
|
@@ -12,5 +12,7 @@ declare const _default: DefineComponent<{}, {
|
|
|
12
12
|
canScroll: Ref<boolean>;
|
|
13
13
|
itemsContainerWidth: ComputedRef<number>;
|
|
14
14
|
scroll: (type: "left" | "right" | "start" | "end") => void;
|
|
15
|
+
Delete: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{}>, {}>;
|
|
16
|
+
DocumentCopy: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{}>, {}>;
|
|
15
17
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{}>>, {}>;
|
|
16
18
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormConfig } from '@tmagic/form';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MNode } from '@tmagic/schema';
|
|
3
3
|
import BaseService from './BaseService';
|
|
4
4
|
declare class Props extends BaseService {
|
|
5
5
|
private state;
|
|
@@ -29,7 +29,7 @@ declare class Props extends BaseService {
|
|
|
29
29
|
* @param type 组件类型
|
|
30
30
|
* @returns 组件初始值
|
|
31
31
|
*/
|
|
32
|
-
getPropsValue(type: string, defaultValue?: {}): Promise<
|
|
32
|
+
getPropsValue(type: string, defaultValue?: {}): Promise<any>;
|
|
33
33
|
}
|
|
34
34
|
export declare type PropsService = Props;
|
|
35
35
|
declare const _default: Props;
|
package/dist/types/src/type.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface StoreState {
|
|
|
29
29
|
highlightNode: MNode | null;
|
|
30
30
|
stage: StageCore | null;
|
|
31
31
|
modifiedNodeIds: Map<Id, Id>;
|
|
32
|
+
pageLength: number;
|
|
32
33
|
}
|
|
33
34
|
export interface PropsState {
|
|
34
35
|
propsConfigMap: Record<string, FormConfig>;
|
|
@@ -92,6 +93,8 @@ export interface MenuButton {
|
|
|
92
93
|
* zoom: 放大缩小
|
|
93
94
|
*/
|
|
94
95
|
type: 'button' | 'dropdown' | 'text' | 'divider' | 'zoom';
|
|
96
|
+
/** 当type为divider时有效,分割线方向, 默认vertical */
|
|
97
|
+
direction?: 'horizontal' | 'vertical';
|
|
95
98
|
/** 展示的文案 */
|
|
96
99
|
text?: string;
|
|
97
100
|
/** 鼠标悬浮是显示的气泡中的文案 */
|
|
@@ -103,14 +106,9 @@ export interface MenuButton {
|
|
|
103
106
|
/** 是否显示,默认为true */
|
|
104
107
|
display?: boolean | ((data?: Services) => boolean);
|
|
105
108
|
/** type为button/dropdown时点击运行的方法 */
|
|
106
|
-
handler?: (data
|
|
107
|
-
/** type为dropdown
|
|
108
|
-
items?:
|
|
109
|
-
/** 展示的文案 */
|
|
110
|
-
text: string;
|
|
111
|
-
/** 点击运行的方法 */
|
|
112
|
-
handler(data: Services): any;
|
|
113
|
-
}[];
|
|
109
|
+
handler?: (data: Services, event: MouseEvent) => Promise<any> | any;
|
|
110
|
+
/** type为dropdown时,下拉的菜单列表, 或者有子菜单时 */
|
|
111
|
+
items?: MenuButton[];
|
|
114
112
|
}
|
|
115
113
|
export interface MenuComponent {
|
|
116
114
|
type: 'component';
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-beta.
|
|
2
|
+
"version": "1.0.0-beta.16",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
|
-
"sideEffects":
|
|
4
|
+
"sideEffects": [
|
|
5
|
+
"dist/*",
|
|
6
|
+
"src/theme/*"
|
|
7
|
+
],
|
|
5
8
|
"main": "dist/tmagic-editor.umd.js",
|
|
6
9
|
"module": "dist/tmagic-editor.es.js",
|
|
7
10
|
"style": "dist/style.css",
|
|
@@ -14,7 +17,8 @@
|
|
|
14
17
|
"./dist/style.css": {
|
|
15
18
|
"import": "./dist/style.css",
|
|
16
19
|
"require": "./dist/style.css"
|
|
17
|
-
}
|
|
20
|
+
},
|
|
21
|
+
"./*": "./*"
|
|
18
22
|
},
|
|
19
23
|
"license": "Apache-2.0",
|
|
20
24
|
"scripts": {
|
|
@@ -40,13 +44,14 @@
|
|
|
40
44
|
],
|
|
41
45
|
"dependencies": {
|
|
42
46
|
"@element-plus/icons": "0.0.11",
|
|
43
|
-
"@tmagic/core": "^1.0.0-beta.
|
|
44
|
-
"@tmagic/form": "^1.0.0-beta.
|
|
45
|
-
"@tmagic/schema": "^1.0.0-beta.
|
|
46
|
-
"@tmagic/stage": "^1.0.0-beta.
|
|
47
|
-
"@tmagic/utils": "^1.0.0-beta.
|
|
47
|
+
"@tmagic/core": "^1.0.0-beta.16",
|
|
48
|
+
"@tmagic/form": "^1.0.0-beta.16",
|
|
49
|
+
"@tmagic/schema": "^1.0.0-beta.16",
|
|
50
|
+
"@tmagic/stage": "^1.0.0-beta.16",
|
|
51
|
+
"@tmagic/utils": "^1.0.0-beta.16",
|
|
52
|
+
"buffer": "^6.0.3",
|
|
48
53
|
"color": "^3.1.3",
|
|
49
|
-
"element-plus": "^2.
|
|
54
|
+
"element-plus": "^2.2.0",
|
|
50
55
|
"events": "^3.3.0",
|
|
51
56
|
"keycon": "^1.1.2",
|
|
52
57
|
"lodash-es": "^4.17.21",
|
|
@@ -75,5 +80,5 @@
|
|
|
75
80
|
"vite-plugin-dts": "^0.9.6",
|
|
76
81
|
"vue-tsc": "^0.0.24"
|
|
77
82
|
},
|
|
78
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "2aebfb1b8ceb5c8e26dfb59b643ed9f4f4b7bd15"
|
|
79
84
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="menuData.length" v-show="visible" class="magic-editor-content-menu" ref="menu" :style="menuStyle">
|
|
3
|
+
<div>
|
|
4
|
+
<tool-button
|
|
5
|
+
v-for="(item, index) in menuData"
|
|
6
|
+
event-type="mouseup"
|
|
7
|
+
:data="item"
|
|
8
|
+
:key="index"
|
|
9
|
+
@mouseup="hide"
|
|
10
|
+
@mouseenter="showSubMenu(item)"
|
|
11
|
+
></tool-button>
|
|
12
|
+
</div>
|
|
13
|
+
<teleport to="body">
|
|
14
|
+
<content-menu class="sub-menu" ref="subMenu" :menu-data="subMenuData"></content-menu>
|
|
15
|
+
</teleport>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
import { defineComponent, nextTick, onMounted, PropType, ref } from 'vue';
|
|
21
|
+
|
|
22
|
+
import { MenuButton, MenuItem } from '@editor/type';
|
|
23
|
+
|
|
24
|
+
import ToolButton from './ToolButton.vue';
|
|
25
|
+
|
|
26
|
+
export default defineComponent({
|
|
27
|
+
components: { ToolButton },
|
|
28
|
+
|
|
29
|
+
props: {
|
|
30
|
+
menuData: {
|
|
31
|
+
type: Array as PropType<MenuItem[]>,
|
|
32
|
+
default: () => [],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
setup() {
|
|
37
|
+
const menu = ref<HTMLDivElement>();
|
|
38
|
+
const subMenu = ref<any>();
|
|
39
|
+
const visible = ref(false);
|
|
40
|
+
const subMenuData = ref<MenuItem[]>([]);
|
|
41
|
+
const menuStyle = ref({
|
|
42
|
+
left: '0',
|
|
43
|
+
top: '0',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const hide = () => {
|
|
47
|
+
visible.value = false;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
onMounted(() => {
|
|
51
|
+
globalThis.addEventListener(
|
|
52
|
+
'mousedown',
|
|
53
|
+
(e: MouseEvent) => {
|
|
54
|
+
if (!visible.value || (e.target && menu.value?.contains(e.target as HTMLElement))) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
hide();
|
|
58
|
+
},
|
|
59
|
+
true,
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
menu,
|
|
65
|
+
subMenu,
|
|
66
|
+
visible,
|
|
67
|
+
menuStyle,
|
|
68
|
+
subMenuData,
|
|
69
|
+
|
|
70
|
+
hide,
|
|
71
|
+
|
|
72
|
+
show(e: MouseEvent) {
|
|
73
|
+
visible.value = true;
|
|
74
|
+
|
|
75
|
+
nextTick(() => {
|
|
76
|
+
const menuHeight = menu.value?.clientHeight || 0;
|
|
77
|
+
|
|
78
|
+
let top = e.clientY;
|
|
79
|
+
if (menuHeight + e.clientY > document.body.clientHeight) {
|
|
80
|
+
top = document.body.clientHeight - menuHeight;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
menuStyle.value = {
|
|
84
|
+
top: `${top}px`,
|
|
85
|
+
left: `${e.clientX}px`,
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
showSubMenu(item: MenuItem) {
|
|
91
|
+
const menuItem = item as MenuButton;
|
|
92
|
+
if (typeof item !== 'object' || !menuItem.items?.length) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
subMenuData.value = menuItem.items;
|
|
97
|
+
if (menu.value) {
|
|
98
|
+
subMenu.value.show({
|
|
99
|
+
clientX: menu.value.offsetLeft + menu.value.clientWidth,
|
|
100
|
+
clientY: menu.value.offsetTop,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
</script>
|
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
2
|
+
<div
|
|
3
|
+
v-if="display"
|
|
4
|
+
class="menu-item"
|
|
5
|
+
:class="item.type"
|
|
6
|
+
@click="clickHandler(item, $event)"
|
|
7
|
+
@mousedown="mousedownHandler(item, $event)"
|
|
8
|
+
@mouseup="mouseupHandler(item, $event)"
|
|
9
|
+
>
|
|
10
|
+
<el-divider v-if="item.type === 'divider'" :direction="item.direction || 'vertical'"></el-divider>
|
|
4
11
|
<div v-else-if="item.type === 'text'" class="menu-item-text">{{ item.text }}</div>
|
|
5
12
|
|
|
6
13
|
<template v-else-if="item.type === 'zoom'">
|
|
7
|
-
<
|
|
14
|
+
<tool-button
|
|
15
|
+
:data="{ type: 'button', icon: ZoomOut, handler: zoomOutHandler, tooltip: '缩小' }"
|
|
16
|
+
:event-type="eventType"
|
|
17
|
+
></tool-button>
|
|
8
18
|
<span class="menu-item-text" style="margin: 0 5px">{{ parseInt(`${zoom * 100}`, 10) }}%</span>
|
|
9
|
-
<
|
|
19
|
+
<tool-button
|
|
20
|
+
:data="{ type: 'button', icon: ZoomIn, handler: zoomInHandler, tooltip: '放大' }"
|
|
21
|
+
:event-type="eventType"
|
|
22
|
+
></tool-button>
|
|
10
23
|
</template>
|
|
11
24
|
|
|
12
|
-
<
|
|
13
|
-
v-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<el-button size="small"
|
|
19
|
-
><m-icon :icon="item.icon"></m-icon><span>{{ item.text }}</span></el-button
|
|
25
|
+
<template v-else-if="item.type === 'button'">
|
|
26
|
+
<el-tooltip v-if="item.tooltip" effect="dark" placement="bottom-start" :content="item.tooltip">
|
|
27
|
+
<el-button size="small" text :disabled="disabled"
|
|
28
|
+
><m-icon v-if="item.icon" :icon="item.icon"></m-icon><span>{{ item.text }}</span></el-button
|
|
29
|
+
>
|
|
30
|
+
</el-tooltip>
|
|
31
|
+
<el-button v-else size="small" text :disabled="disabled"
|
|
32
|
+
><m-icon v-if="item.icon" :icon="item.icon"></m-icon><span>{{ item.text }}</span></el-button
|
|
20
33
|
>
|
|
21
|
-
</
|
|
34
|
+
</template>
|
|
22
35
|
|
|
23
36
|
<el-dropdown v-else-if="item.type === 'dropdown'" trigger="click" :disabled="disabled" @command="dropdownHandler">
|
|
24
37
|
<span class="el-dropdown-link menubar-menu-button">
|
|
@@ -38,7 +51,7 @@
|
|
|
38
51
|
</template>
|
|
39
52
|
|
|
40
53
|
<script lang="ts">
|
|
41
|
-
import { computed, defineComponent, inject, PropType } from 'vue';
|
|
54
|
+
import { computed, defineComponent, inject, markRaw, PropType } from 'vue';
|
|
42
55
|
import { ArrowDown, Back, Delete, Grid, Right, ScaleToOriginal, ZoomIn, ZoomOut } from '@element-plus/icons';
|
|
43
56
|
|
|
44
57
|
import { NodeType } from '@tmagic/schema';
|
|
@@ -58,6 +71,11 @@ export default defineComponent({
|
|
|
58
71
|
display: false,
|
|
59
72
|
}),
|
|
60
73
|
},
|
|
74
|
+
|
|
75
|
+
eventType: {
|
|
76
|
+
type: String as PropType<'mousedown' | 'mouseup' | 'click'>,
|
|
77
|
+
default: 'click',
|
|
78
|
+
},
|
|
61
79
|
},
|
|
62
80
|
|
|
63
81
|
setup(props) {
|
|
@@ -87,7 +105,7 @@ export default defineComponent({
|
|
|
87
105
|
case 'delete':
|
|
88
106
|
return {
|
|
89
107
|
type: 'button',
|
|
90
|
-
icon: Delete,
|
|
108
|
+
icon: markRaw(Delete),
|
|
91
109
|
tooltip: '刪除',
|
|
92
110
|
disabled: () => services?.editorService.get('node')?.type === NodeType.PAGE,
|
|
93
111
|
handler: () => services?.editorService.remove(services?.editorService.get('node')),
|
|
@@ -95,7 +113,7 @@ export default defineComponent({
|
|
|
95
113
|
case 'undo':
|
|
96
114
|
return {
|
|
97
115
|
type: 'button',
|
|
98
|
-
icon: Back,
|
|
116
|
+
icon: markRaw(Back),
|
|
99
117
|
tooltip: '后退',
|
|
100
118
|
disabled: () => !services?.historyService.state.canUndo,
|
|
101
119
|
handler: () => services?.editorService.undo(),
|
|
@@ -103,7 +121,7 @@ export default defineComponent({
|
|
|
103
121
|
case 'redo':
|
|
104
122
|
return {
|
|
105
123
|
type: 'button',
|
|
106
|
-
icon: Right,
|
|
124
|
+
icon: markRaw(Right),
|
|
107
125
|
tooltip: '前进',
|
|
108
126
|
disabled: () => !services?.historyService.state.canRedo,
|
|
109
127
|
handler: () => services?.editorService.redo(),
|
|
@@ -111,28 +129,28 @@ export default defineComponent({
|
|
|
111
129
|
case 'zoom-in':
|
|
112
130
|
return {
|
|
113
131
|
type: 'button',
|
|
114
|
-
icon: ZoomIn,
|
|
132
|
+
icon: markRaw(ZoomIn),
|
|
115
133
|
tooltip: '放大',
|
|
116
134
|
handler: zoomInHandler,
|
|
117
135
|
};
|
|
118
136
|
case 'zoom-out':
|
|
119
137
|
return {
|
|
120
138
|
type: 'button',
|
|
121
|
-
icon: ZoomOut,
|
|
139
|
+
icon: markRaw(ZoomOut),
|
|
122
140
|
tooltip: '縮小',
|
|
123
141
|
handler: zoomOutHandler,
|
|
124
142
|
};
|
|
125
143
|
case 'rule':
|
|
126
144
|
return {
|
|
127
145
|
type: 'button',
|
|
128
|
-
icon: ScaleToOriginal,
|
|
146
|
+
icon: markRaw(ScaleToOriginal),
|
|
129
147
|
tooltip: showRule.value ? '隐藏标尺' : '显示标尺',
|
|
130
148
|
handler: () => uiService?.set('showRule', !showRule.value),
|
|
131
149
|
};
|
|
132
150
|
case 'guides':
|
|
133
151
|
return {
|
|
134
152
|
type: 'button',
|
|
135
|
-
icon: Grid,
|
|
153
|
+
icon: markRaw(Grid),
|
|
136
154
|
tooltip: showGuides.value ? '隐藏参考线' : '显示参考线',
|
|
137
155
|
handler: () => uiService?.set('showGuides', !showGuides.value),
|
|
138
156
|
};
|
|
@@ -153,9 +171,16 @@ export default defineComponent({
|
|
|
153
171
|
return item.value.disabled;
|
|
154
172
|
});
|
|
155
173
|
|
|
174
|
+
const buttonHandler = (item: MenuButton | MenuComponent, event: MouseEvent) => {
|
|
175
|
+
if (disabled.value) return;
|
|
176
|
+
if (typeof (item as MenuButton).handler === 'function' && services) {
|
|
177
|
+
(item as MenuButton).handler?.(services, event);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
156
181
|
return {
|
|
157
|
-
ZoomIn,
|
|
158
|
-
ZoomOut,
|
|
182
|
+
ZoomIn: markRaw(ZoomIn),
|
|
183
|
+
ZoomOut: markRaw(ZoomOut),
|
|
159
184
|
|
|
160
185
|
item,
|
|
161
186
|
zoom,
|
|
@@ -178,10 +203,24 @@ export default defineComponent({
|
|
|
178
203
|
}
|
|
179
204
|
},
|
|
180
205
|
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
if (
|
|
184
|
-
(item
|
|
206
|
+
clickHandler(item: MenuButton | MenuComponent, event: MouseEvent) {
|
|
207
|
+
if (props.eventType !== 'click') return;
|
|
208
|
+
if (item.type === 'button') {
|
|
209
|
+
buttonHandler(item, event);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
mousedownHandler(item: MenuButton | MenuComponent, event: MouseEvent) {
|
|
214
|
+
if (props.eventType !== 'mousedown') return;
|
|
215
|
+
if (item.type === 'button') {
|
|
216
|
+
buttonHandler(item, event);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
mouseupHandler(item: MenuButton | MenuComponent, event: MouseEvent) {
|
|
221
|
+
if (props.eventType !== 'mouseup') return;
|
|
222
|
+
if (item.type === 'button') {
|
|
223
|
+
buttonHandler(item, event);
|
|
185
224
|
}
|
|
186
225
|
},
|
|
187
226
|
};
|
package/src/fields/UISelect.vue
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-ui-select" v-if="uiSelectMode" @click="cancelHandler">
|
|
3
|
-
<
|
|
3
|
+
<el-button type="danger" :icon="Delete" text style="padding: 0">取消</el-button>
|
|
4
4
|
</div>
|
|
5
|
-
<div class="m-fields-ui-select" v-else @click="startSelect">
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
<div class="m-fields-ui-select" v-else @click="startSelect" style="display: flex">
|
|
6
|
+
<el-tooltip content="清除">
|
|
7
|
+
<el-button v-if="val" style="padding: 0" type="danger" :icon="Close" text @click.stop="deleteHandler"></el-button>
|
|
8
|
+
</el-tooltip>
|
|
9
|
+
<el-tooltip :content="val ? toName + '_' + val : '点击此处选择'">
|
|
10
|
+
<el-button text style="padding: 0; margin: 0">{{ val ? toName + '_' + val : '点击此处选择' }}</el-button>
|
|
11
|
+
</el-tooltip>
|
|
9
12
|
</div>
|
|
10
13
|
</template>
|
|
11
14
|
|
|
12
15
|
<script lang="ts">
|
|
13
|
-
import { computed, defineComponent, inject, ref } from 'vue';
|
|
16
|
+
import { computed, defineComponent, inject, markRaw, ref } from 'vue';
|
|
17
|
+
import { Close, Delete, Pointer } from '@element-plus/icons';
|
|
14
18
|
|
|
15
19
|
import { FormState } from '@tmagic/form';
|
|
16
20
|
|
|
@@ -60,6 +64,10 @@ export default defineComponent({
|
|
|
60
64
|
};
|
|
61
65
|
|
|
62
66
|
return {
|
|
67
|
+
Delete: markRaw(Delete),
|
|
68
|
+
Pointer: markRaw(Pointer),
|
|
69
|
+
Close: markRaw(Close),
|
|
70
|
+
|
|
63
71
|
val,
|
|
64
72
|
uiSelectMode,
|
|
65
73
|
toName: computed(() => {
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
+
import './utils/polyfills';
|
|
18
19
|
|
|
19
20
|
import { App } from 'vue';
|
|
20
21
|
|
|
@@ -41,6 +42,7 @@ export { default as uiService } from './services/ui';
|
|
|
41
42
|
export { default as ComponentListPanel } from './layouts/sidebar/ComponentListPanel.vue';
|
|
42
43
|
export { default as LayerPanel } from './layouts/sidebar/LayerPanel.vue';
|
|
43
44
|
export { default as PropsPanel } from './layouts/PropsPanel.vue';
|
|
45
|
+
export { default as ToolButton } from './components/ToolButton.vue';
|
|
44
46
|
|
|
45
47
|
const defaultInstallOpt: InstallOptions = {
|
|
46
48
|
// @todo, 自定义图片上传方法等编辑器依赖的外部选项
|