forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetadata.ts
More file actions
232 lines (196 loc) · 5.57 KB
/
metadata.ts
File metadata and controls
232 lines (196 loc) · 5.57 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import { MouseEvent } from 'react';
import { IPublicTypePropType, IPublicTypeComponentAction } from './';
import { IPublicModelNode, IPublicModelSettingField } from '../model';
/**
* 嵌套控制函数
*/
export type IPublicTypeNestingFilter = (testNode: any, currentNode: any) => boolean;
/**
* 嵌套控制
* 防止错误的节点嵌套,比如 a 嵌套 a, FormField 只能在 Form 容器下,Column 只能在 Table 下等
*/
export interface IPublicTypeNestingRule {
/**
* 子级白名单
*/
childWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/**
* 父级白名单
*/
parentWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/**
* 后裔白名单
*/
descendantWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/**
* 后裔黑名单
*/
descendantBlacklist?: string[] | string | RegExp | IPublicTypeNestingFilter;
/**
* 祖先白名单 可用来做区域高亮
*/
ancestorWhitelist?: string[] | string | RegExp | IPublicTypeNestingFilter;
}
/**
* 组件能力配置
*/
export interface IPublicTypeComponentConfigure {
/**
* 是否容器组件
*/
isContainer?: boolean;
/**
* 组件是否带浮层,浮层组件拖入设计器时会遮挡画布区域,此时应当辅助一些交互以防止阻挡
*/
isModal?: boolean;
/**
* 是否存在渲染的根节点
*/
isNullNode?: boolean;
/**
* 组件树描述信息
*/
descriptor?: string;
/**
* 嵌套控制:防止错误的节点嵌套
* 比如 a 嵌套 a, FormField 只能在 Form 容器下,Column 只能在 Table 下等
*/
nestingRule?: IPublicTypeNestingRule;
/**
* 是否是最小渲染单元
* 最小渲染单元下的组件渲染和更新都从单元的根节点开始渲染和更新。如果嵌套了多层最小渲染单元,渲染会从最外层的最小渲染单元开始渲染。
*/
isMinimalRenderUnit?: boolean;
/**
* 组件选中框的 cssSelector
*/
rootSelector?: string;
/**
* 禁用的行为,可以为 `'copy'`, `'move'`, `'remove'` 或它们组成的数组
*/
disableBehaviors?: string[] | string;
/**
* 用于详细配置上述操作项的内容
*/
actions?: IPublicTypeComponentAction[];
}
export interface IPublicTypeInitialItem {
name: string;
initial: (target: IPublicModelSettingField, currentValue: any) => any;
}
export interface IPublicTypeFilterItem {
name: string;
filter: (target: IPublicModelSettingField | null, currentValue: any) => any;
}
export interface IPublicTypeAutorunItem {
name: string;
autorun: (target: IPublicModelSettingField | null) => any;
}
// thinkof Array
/**
* Live Text Editing(如果 children 内容是纯文本,支持双击直接编辑)的可配置项目
*/
export interface IPublicTypeLiveTextEditingConfig {
/**
* @todo 待补充文档
*/
propTarget: string;
/**
* @todo 待补充文档
*/
selector?: string;
/**
* 编辑模式 纯文本 | 段落编辑 | 文章编辑(默认纯文本,无跟随工具条)
* @default 'plaintext'
*/
mode?: 'plaintext' | 'paragraph' | 'article';
/**
* 从 contentEditable 获取内容并设置到属性
*/
onSaveContent?: (content: string, prop: any) => any;
}
export type ConfigureSupportEvent = string | ConfigureSupportEventConfig;
export interface ConfigureSupportEventConfig {
name: string;
propType?: IPublicTypePropType;
description?: string;
template?: string;
}
/**
* 通用扩展面板支持性配置
*/
export interface ConfigureSupport {
/**
* 支持事件列表
*/
events?: ConfigureSupportEvent[];
/**
* 支持 className 设置
*/
className?: boolean;
/**
* 支持样式设置
*/
style?: boolean;
/**
* 支持生命周期设置
*/
lifecycles?: any[];
// general?: boolean;
/**
* 支持循环设置
*/
loop?: boolean;
/**
* 支持条件式渲染设置
*/
condition?: boolean;
}
/**
* handleResizing
*/
/**
* 配置 callbacks 可捕获引擎抛出的一些事件,例如 onNodeAdd、onResize 等
*/
export interface IPublicTypeCallbacks {
// hooks
onMouseDownHook?: (e: MouseEvent, currentNode: IPublicModelNode | null) => any;
onDblClickHook?: (e: MouseEvent, currentNode: IPublicModelNode | null) => any;
onClickHook?: (e: MouseEvent, currentNode: IPublicModelNode | null) => any;
// onLocateHook?: (e: any, currentNode: any) => any;
// onAcceptHook?: (currentNode: any, locationData: any) => any;
onMoveHook?: (currentNode: IPublicModelNode) => boolean;
// thinkof 限制性拖拽
onHoverHook?: (currentNode: IPublicModelNode) => boolean;
/** 选中 hook,如果返回值是 false,可以控制组件不可被选中 */
onSelectHook?: (currentNode: IPublicModelNode) => boolean;
onChildMoveHook?: (childNode: IPublicModelNode, currentNode: IPublicModelNode) => boolean;
// events
onNodeRemove?: (removedNode: IPublicModelNode | null, currentNode: IPublicModelNode | null) => void;
onNodeAdd?: (addedNode: IPublicModelNode | null, currentNode: IPublicModelNode | null) => void;
onSubtreeModified?: (currentNode: IPublicModelNode, options: any) => void;
onResize?: (
e: MouseEvent & {
trigger: string;
deltaX?: number;
deltaY?: number;
},
currentNode: any,
) => void;
onResizeStart?: (
e: MouseEvent & {
trigger: string;
deltaX?: number;
deltaY?: number;
},
currentNode: any,
) => void;
onResizeEnd?: (
e: MouseEvent & {
trigger: string;
deltaX?: number;
deltaY?: number;
},
currentNode: IPublicModelNode,
) => void;
}