( containerId: string, blocks: Record<string, BlockState> )
| 155 | * @returns Array of node IDs that are descendants of this container |
| 156 | */ |
| 157 | export function findAllDescendantNodes( |
| 158 | containerId: string, |
| 159 | blocks: Record<string, BlockState> |
| 160 | ): string[] { |
| 161 | const descendants: string[] = [] |
| 162 | const visited = new Set<string>() |
| 163 | const stack = [containerId] |
| 164 | while (stack.length > 0) { |
| 165 | const current = stack.pop()! |
| 166 | if (visited.has(current)) continue |
| 167 | visited.add(current) |
| 168 | for (const block of Object.values(blocks)) { |
| 169 | if (block.data?.parentId === current) { |
| 170 | descendants.push(block.id) |
| 171 | stack.push(block.id) |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | return descendants |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Checks if any ancestor container of a block is locked. |
no test coverage detected