mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
19 lines
442 B
TypeScript
19 lines
442 B
TypeScript
import type { Node } from '@affine/component';
|
|
|
|
export function flattenIds<RenderProps>(arr: Node<RenderProps>[]): string[] {
|
|
const result: string[] = [];
|
|
|
|
function flatten(arr: Node<RenderProps>[]) {
|
|
for (let i = 0, len = arr.length; i < len; i++) {
|
|
const item = arr[i];
|
|
result.push(item.id);
|
|
if (Array.isArray(item.children)) {
|
|
flatten(item.children);
|
|
}
|
|
}
|
|
}
|
|
|
|
flatten(arr);
|
|
return result;
|
|
}
|