(schema: IPublicTypeNodeSchema, nodeId: string)
| 79 | } |
| 80 | |
| 81 | export function getNodeSchemaById(schema: IPublicTypeNodeSchema, nodeId: string): IPublicTypeNodeSchema | undefined { |
| 82 | let found: IPublicTypeNodeSchema | undefined; |
| 83 | if (schema.id === nodeId) { |
| 84 | return schema; |
| 85 | } |
| 86 | const { children, props } = schema; |
| 87 | // 查找 children |
| 88 | if (Array.isArray(children)) { |
| 89 | for (const child of children) { |
| 90 | found = getNodeSchemaById(child as IPublicTypeNodeSchema, nodeId); |
| 91 | if (found) return found; |
| 92 | } |
| 93 | } |
| 94 | if (isPlainObject(props)) { |
| 95 | // 查找 props,主要是 slot 类型 |
| 96 | found = getNodeSchemaFromPropsById(props, nodeId); |
| 97 | if (found) return found; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNodeSchema | undefined { |
| 102 | let found: IPublicTypeNodeSchema | undefined; |
no test coverage detected
searching dependent graphs…