forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmaterial.ts
More file actions
160 lines (143 loc) · 4.17 KB
/
material.ts
File metadata and controls
160 lines (143 loc) · 4.17 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
import {
IPublicTypeAssetsJson,
IPublicTypeMetadataTransducer,
IPublicTypeComponentAction,
IPublicTypeNpmInfo,
IPublicTypeDisposable,
IPublicTypeContextMenuAction,
IPublicTypeContextMenuItem,
} from '../type';
import { IPublicModelComponentMeta } from '../model';
import { ComponentType } from 'react';
export interface IPublicApiMaterial {
/**
* 获取组件 map 结构
* get map of components
*/
get componentsMap(): {
[key: string]: IPublicTypeNpmInfo | ComponentType<any> | object;
};
/**
* 设置「资产包」结构
* set data for Assets
* @returns void
*/
setAssets(assets: IPublicTypeAssetsJson): Promise<void>;
/**
* 获取「资产包」结构
* get AssetsJson data
* @returns IPublicTypeAssetsJson
*/
getAssets(): IPublicTypeAssetsJson | undefined;
/**
* 加载增量的「资产包」结构,该增量包会与原有的合并
* load Assets incrementally, and will merge this with exiting assets
* @param incrementalAssets
* @returns
*/
loadIncrementalAssets(incrementalAssets: IPublicTypeAssetsJson): void;
/**
* 注册物料元数据管道函数,在物料信息初始化时执行。
* register transducer to process component meta, which will be
* excuted during component meta`s initialization
* @param transducer
* @param level
* @param id
*/
registerMetadataTransducer(
transducer: IPublicTypeMetadataTransducer,
level?: number,
id?: string | undefined,
): void;
/**
* 获取所有物料元数据管道函数
* get all registered metadata transducers
* @returns {IPublicTypeMetadataTransducer[]}
*/
getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[];
/**
* 获取指定名称的物料元数据
* get component meta by component name
* @param componentName
* @returns
*/
getComponentMeta(componentName: string): IPublicModelComponentMeta | null;
/**
* test if the given object is a ComponentMeta instance or not
* @param obj
* @experiemental unstable API, pay extra caution when trying to use it
*/
isComponentMeta(obj: any): boolean;
/**
* 获取所有已注册的物料元数据
* get map of all component metas
*/
getComponentMetasMap(): Map<string, IPublicModelComponentMeta>;
/**
* 在设计器辅助层增加一个扩展 action
*
* add an action button in canvas context menu area
* @param action
* @example
* ```ts
* import { plugins } from '@felce/lowcode-engine';
* import { IPublicModelPluginContext } from '@felce/lowcode-types';
*
* const removeCopyAction = (ctx: IPublicModelPluginContext) => {
* return {
* async init() {
* const { removeBuiltinComponentAction } = ctx.material;
* removeBuiltinComponentAction('copy');
* }
* }
* };
* removeCopyAction.pluginName = 'removeCopyAction';
* await plugins.register(removeCopyAction);
* ```
*/
addBuiltinComponentAction(action: IPublicTypeComponentAction): void;
/**
* 移除设计器辅助层的指定 action
* remove a builtin action button from canvas context menu area
* @param name
*/
removeBuiltinComponentAction(name: string): void;
/**
* 修改已有的设计器辅助层的指定 action
* modify a builtin action button in canvas context menu area
* @param actionName
* @param handle
*/
modifyBuiltinComponentAction(
actionName: string,
handle: (action: IPublicTypeComponentAction) => void,
): void;
/**
* 监听 assets 变化的事件
* add callback for assets changed event
* @param fn
*/
onChangeAssets(fn: () => void): IPublicTypeDisposable;
/**
* 刷新 componentMetasMap,可触发模拟器里的 components 重新构建
* @since v1.1.7
*/
refreshComponentMetasMap(): void;
/**
* 添加右键菜单项
* @param action
*/
addContextMenuOption(action: IPublicTypeContextMenuAction): void;
/**
* 删除特定右键菜单项
* @param name
*/
removeContextMenuOption(name: string): void;
/**
* 调整右键菜单项布局
* @param actions
*/
adjustContextMenuLayout(
fn: (actions: IPublicTypeContextMenuItem[]) => IPublicTypeContextMenuItem[],
): void;
}