(node: ReactNode)
| 17 | } |
| 18 | |
| 19 | function extractText(node: ReactNode): string { |
| 20 | if (typeof node === "string") return node; |
| 21 | if (typeof node === "number") return String(node); |
| 22 | if (Array.isArray(node)) return node.map(extractText).join(""); |
| 23 | if (isValidElement(node) && node.props) { |
| 24 | return extractText((node.props as { children?: ReactNode }).children); |
| 25 | } |
| 26 | return ""; |
| 27 | } |
| 28 | |
| 29 | function PreBlock( |
| 30 | props: ComponentPropsWithoutRef<"pre"> & { children?: ReactNode; node?: unknown }, |