* Find the first JSXText node in an AST subtree.
(node: any)
| 1483 | * Find the first JSXText node in an AST subtree. |
| 1484 | */ |
| 1485 | function findFirstJSXText(node: any): any | null { |
| 1486 | if (!node.children) return null; |
| 1487 | for (const child of node.children) { |
| 1488 | if (child.type === "JSXText" && child.value.trim()) return child; |
| 1489 | if (child.type === "JSXElement") { |
| 1490 | const found = findFirstJSXText(child); |
| 1491 | if (found) return found; |
| 1492 | } |
| 1493 | } |
| 1494 | return null; |
| 1495 | } |
| 1496 | |
| 1497 | /** |
| 1498 | * Insert text at a character offset within the concatenated JSXText of a subtree. |