(childArray: React.ReactNode[])
| 34 | * and `<br>` elements (injected by remarkBreaks between images). |
| 35 | */ |
| 36 | export function classifyChildren(childArray: React.ReactNode[]): { |
| 37 | imageChildren: React.ReactNode[]; |
| 38 | nonImageChildren: React.ReactNode[]; |
| 39 | } { |
| 40 | const imageChildren = childArray.filter(isBlockMedia); |
| 41 | const nonImageChildren = childArray.filter( |
| 42 | (child) => |
| 43 | !isBlockMedia(child) && |
| 44 | !(typeof child === "string" && child.trim() === "") && |
| 45 | !(React.isValidElement(child) && child.type === "br"), |
| 46 | ); |
| 47 | return { imageChildren, nonImageChildren }; |
| 48 | } |
| 49 | |
| 50 | /** Returns true when a paragraph contains 2+ images and no other content. */ |
| 51 | export function isImageOnlyParagraph(childArray: React.ReactNode[]): boolean { |
no test coverage detected