* Find a placeholder node in a list by matching type and/or idx.
( placeholders: SafeXmlNode[], info: PlaceholderInfo )
| 58 | * Find a placeholder node in a list by matching type and/or idx. |
| 59 | */ |
| 60 | function findPlaceholderNode( |
| 61 | placeholders: SafeXmlNode[], |
| 62 | info: PlaceholderInfo |
| 63 | ): SafeXmlNode | undefined { |
| 64 | for (const ph of placeholders) { |
| 65 | // Navigate to the ph element to read its attributes |
| 66 | let phEl: SafeXmlNode | undefined |
| 67 | const nvSpPr = ph.child('nvSpPr') |
| 68 | if (nvSpPr.exists()) { |
| 69 | phEl = nvSpPr.child('nvPr').child('ph') |
| 70 | } |
| 71 | if (!phEl || !phEl.exists()) { |
| 72 | const nvPicPr = ph.child('nvPicPr') |
| 73 | if (nvPicPr.exists()) { |
| 74 | phEl = nvPicPr.child('nvPr').child('ph') |
| 75 | } |
| 76 | } |
| 77 | if (!phEl || !phEl.exists()) continue |
| 78 | |
| 79 | const phType = phEl.attr('type') |
| 80 | const phIdx = phEl.numAttr('idx') |
| 81 | |
| 82 | // Match by idx first (most specific), then by type |
| 83 | if (info.idx !== undefined && phIdx === info.idx) return ph |
| 84 | if (info.type && phType === info.type) return ph |
| 85 | } |
| 86 | return undefined |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Extract lstStyle from a placeholder shape node. |
no test coverage detected