forked from imengyu/node-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.ts
97 lines (94 loc) · 1.91 KB
/
Menu.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { BlockEditor } from "./Editor/BlockEditor";
export class MenuData {
public name = '';
public enable = true;
public checked = false;
public show = true;
public shortcut = '';
public separator = false;
public callback : MenuCallback = null;
public childs : Array<MenuData> = null;
public enter = false;
public constructor(name : string, callbackOrChild : MenuCallback | Array<MenuData> , shortcut = '', checked = false, enabled = true) {
this.name = name;
if(typeof callbackOrChild == 'function')
this.callback = callbackOrChild;
else
this.childs = callbackOrChild;
this.shortcut = shortcut;
this.checked = checked;
this.enable = enabled;
}
}
export type MenuCallback = (menu : MenuData) => void;
export class MenuSeparator extends MenuData {
public constructor() {
super('Separator', null);
this.separator = true;
}
}
//Vue contextmenu js
export declare interface MenuOptions {
/**
* 菜单结构信息
*/
items : MenuItem[],
/**
* 鼠标事件信息
*/
event ?: Event,
/**
* 菜单显示X坐标, 存在event则失效
*/
x ?: number,
/**
* 菜单显示Y坐标, 存在event则失效
*/
y ?: number,
/**
* 菜单样式z-index
*/
zIndex ?: number,
/**
* 自定义菜单class
*/
customClass ?: string,
/**
* 主菜单最小宽度
*/
minWidth ?: number,
}
export declare interface MenuItem {
/**
* 菜单项名称
*/
label ?: string,
/**
* 菜单项图标, 生成<i></i>元素
*/
icon ?: string,
/**
* 是否禁用菜单项
*/
disabled ?: boolean,
/**
* 是否显示分割线
*/
divided ?: boolean,
/**
* 自定义子菜单class
*/
customClass ?: string,
/**
* 子菜单最小宽度
*/
minWidth ?: number,
/**
* 菜单项点击事件
*/
onClick ?: (this: BlockEditor) => void,
/**
* 子菜单结构信息
*/
children ?: MenuItem[],
}