| 131 | |
| 132 | // Helper: Add elements to slide |
| 133 | function addElements(slideData, targetSlide, pres) { |
| 134 | for (const el of slideData.elements) { |
| 135 | if (el.type === 'image') { |
| 136 | let imagePath = el.src.startsWith('file://') ? el.src.replace('file://', '') : el.src; |
| 137 | targetSlide.addImage({ |
| 138 | path: imagePath, |
| 139 | x: el.position.x, |
| 140 | y: el.position.y, |
| 141 | w: el.position.w, |
| 142 | h: el.position.h |
| 143 | }); |
| 144 | } else if (el.type === 'line') { |
| 145 | targetSlide.addShape(pres.ShapeType.line, { |
| 146 | x: el.x1, |
| 147 | y: el.y1, |
| 148 | w: el.x2 - el.x1, |
| 149 | h: el.y2 - el.y1, |
| 150 | line: { color: el.color, width: el.width } |
| 151 | }); |
| 152 | } else if (el.type === 'shape') { |
| 153 | const shapeOptions = { |
| 154 | x: el.position.x, |
| 155 | y: el.position.y, |
| 156 | w: el.position.w, |
| 157 | h: el.position.h, |
| 158 | shape: el.shape.rectRadius > 0 ? pres.ShapeType.roundRect : pres.ShapeType.rect |
| 159 | }; |
| 160 | |
| 161 | if (el.shape.fill) { |
| 162 | shapeOptions.fill = { color: el.shape.fill }; |
| 163 | if (el.shape.transparency != null) shapeOptions.fill.transparency = el.shape.transparency; |
| 164 | } |
| 165 | if (el.shape.line) shapeOptions.line = el.shape.line; |
| 166 | if (el.shape.rectRadius > 0) shapeOptions.rectRadius = el.shape.rectRadius; |
| 167 | if (el.shape.shadow) shapeOptions.shadow = el.shape.shadow; |
| 168 | |
| 169 | targetSlide.addText(el.text || '', shapeOptions); |
| 170 | } else if (el.type === 'list') { |
| 171 | const listOptions = { |
| 172 | x: el.position.x, |
| 173 | y: el.position.y, |
| 174 | w: el.position.w, |
| 175 | h: el.position.h, |
| 176 | fontSize: el.style.fontSize, |
| 177 | fontFace: el.style.fontFace, |
| 178 | color: el.style.color, |
| 179 | align: el.style.align, |
| 180 | valign: 'top', |
| 181 | lineSpacing: el.style.lineSpacing, |
| 182 | paraSpaceBefore: el.style.paraSpaceBefore, |
| 183 | paraSpaceAfter: el.style.paraSpaceAfter, |
| 184 | margin: el.style.margin |
| 185 | }; |
| 186 | if (el.style.margin) listOptions.margin = el.style.margin; |
| 187 | targetSlide.addText(el.items, listOptions); |
| 188 | } else { |
| 189 | // Check if text is single-line (height suggests one line) |
| 190 | const lineHeight = el.style.lineSpacing || el.style.fontSize * 1.2; |