forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.ts
More file actions
63 lines (52 loc) · 1.36 KB
/
index.ts
File metadata and controls
63 lines (52 loc) · 1.36 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
import { IPublicTypeNodeSchema } from '@felce/lowcode-types';
/**
* 返回给定 schema 结构中所有的 nodeId
* @param schema
* @param ids
*/
export function getIdsFromSchema(schema: IPublicTypeNodeSchema, ids: any) {
if (ids === void 0) {
ids = [];
}
if (!schema) return ids;
var componentName = schema.componentName,
id = schema.id,
children = schema.children;
if (componentName) {
ids.push(id);
}
if (Array.isArray(children) && children.length > 0) {
children.forEach(function (node: any) {
return getIdsFromSchema(node, ids);
});
}
return ids;
}
/**
* 根据给定的 nodeId 返回 node json 结构
* @param schema
* @param _id
*/
export function getNodeFromSchemaById(schema: IPublicTypeNodeSchema, _id: string) {
if (!schema) return null;
var id = schema.id,
children = schema.children;
var retNode = null;
if (_id === id) return schema;
if (Array.isArray(children) && children.length > 0) {
children.some(function (node: any) {
retNode = getNodeFromSchemaById(node, _id);
if (retNode) {
return true;
}
return false;
});
}
return retNode;
}
export {
}
export * from './bom';
export * from './event';
export * from './renderer';
export * from './misc';