(boxShadow)
| 363 | |
| 364 | // Parse CSS box-shadow into PptxGenJS shadow properties |
| 365 | const parseBoxShadow = (boxShadow) => { |
| 366 | if (!boxShadow || boxShadow === 'none') return null; |
| 367 | |
| 368 | // Browser computed style format: "rgba(0, 0, 0, 0.3) 2px 2px 8px 0px [inset]" |
| 369 | // CSS format: "[inset] 2px 2px 8px 0px rgba(0, 0, 0, 0.3)" |
| 370 | |
| 371 | const insetMatch = boxShadow.match(/inset/); |
| 372 | |
| 373 | // IMPORTANT: PptxGenJS/PowerPoint doesn't properly support inset shadows |
| 374 | // Only process outer shadows to avoid file corruption |
| 375 | if (insetMatch) return null; |
| 376 | |
| 377 | // Extract color first (rgba or rgb at start) |
| 378 | const colorMatch = boxShadow.match(/rgba?\([^)]+\)/); |
| 379 | |
| 380 | // Extract numeric values (handles both px and pt units) |
| 381 | const parts = boxShadow.match(/([-\d.]+)(px|pt)/g); |
| 382 | |
| 383 | if (!parts || parts.length < 2) return null; |
| 384 | |
| 385 | const offsetX = parseFloat(parts[0]); |
| 386 | const offsetY = parseFloat(parts[1]); |
| 387 | const blur = parts.length > 2 ? parseFloat(parts[2]) : 0; |
| 388 | |
| 389 | // Calculate angle from offsets (in degrees, 0 = right, 90 = down) |
| 390 | let angle = 0; |
| 391 | if (offsetX !== 0 || offsetY !== 0) { |
| 392 | angle = Math.atan2(offsetY, offsetX) * (180 / Math.PI); |
| 393 | if (angle < 0) angle += 360; |
| 394 | } |
| 395 | |
| 396 | // Calculate offset distance (hypotenuse) |
| 397 | const offset = Math.sqrt(offsetX * offsetX + offsetY * offsetY) * PT_PER_PX; |
| 398 | |
| 399 | // Extract opacity from rgba |
| 400 | let opacity = 0.5; |
| 401 | if (colorMatch) { |
| 402 | const opacityMatch = colorMatch[0].match(/[\d.]+\)$/); |
| 403 | if (opacityMatch) { |
| 404 | opacity = parseFloat(opacityMatch[0].replace(')', '')); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | return { |
| 409 | type: 'outer', |
| 410 | angle: Math.round(angle), |
| 411 | blur: blur * 0.75, // Convert to points |
| 412 | color: colorMatch ? rgbToHex(colorMatch[0]) : '000000', |
| 413 | offset: offset, |
| 414 | opacity |
| 415 | }; |
| 416 | }; |
| 417 | |
| 418 | // Parse inline formatting tags (<b>, <i>, <u>, <strong>, <em>, <span>) into text runs |
| 419 | const parseInlineFormatting = (element, baseOptions = {}, runs = [], baseTextTransform = (x) => x) => { |
no test coverage detected