From 7122325401a2f613e93ecc839d3235203120761a Mon Sep 17 00:00:00 2001 From: sauravniraula Date: Sat, 26 Jul 2025 00:52:18 +0545 Subject: [PATCH] feat(nextjs): elements with background image style will be extractly correctly on export --- .../api/presentation_to_pptx_model/route.ts | 34 ++++++++++++++++--- .../general/QuoteSlideLayout.tsx | 12 +++---- servers/nextjs/utils/pptx_models_utils.ts | 1 + 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/servers/nextjs/app/api/presentation_to_pptx_model/route.ts b/servers/nextjs/app/api/presentation_to_pptx_model/route.ts index 49bdc924..4dd4524a 100644 --- a/servers/nextjs/app/api/presentation_to_pptx_model/route.ts +++ b/servers/nextjs/app/api/presentation_to_pptx_model/route.ts @@ -77,6 +77,9 @@ async function getBrowserAndPage(id: string): Promise<[Browser, Page]> { waitUntil: "networkidle0", timeout: 60000, }); + page.on('console', (msg) => { + console.log('console', msg.text()); + }); return [browser, page]; } @@ -284,14 +287,14 @@ async function getAllChildElementsAttributes({ element, rootRect = null, depth = const isCanvas = attributes.tagName === 'canvas'; const isTable = attributes.tagName === 'table'; - const isRootPosition = attributes.position && + const occupiesRoot = attributes.position && attributes.position.left === 0 && attributes.position.top === 0 && attributes.position.width === rootRect!.width && attributes.position.height === rootRect!.height; const hasOtherProperties = hasBackground || hasBorder || hasShadow || hasText || hasImage || isSvg || isCanvas || isTable; - return hasOtherProperties && !isRootPosition; + return hasOtherProperties && (!occupiesRoot || hasImage); }) : allResults; if (depth === 0) { @@ -430,6 +433,23 @@ async function getElementAttributes(element: ElementHandle): Promise): Promise): Promise): Promise): Promise = ({ data: slideData }) }} > {/* Background Image */} -
= ({ data: slideData }) {/* Main Content */}
- + {/* Heading */}

@@ -80,12 +80,12 @@ const QuoteSlideLayout: React.FC = ({ data: slideData })
{/* Quote Icon */}
- - +
diff --git a/servers/nextjs/utils/pptx_models_utils.ts b/servers/nextjs/utils/pptx_models_utils.ts index a6cc720c..7ab0eb8c 100644 --- a/servers/nextjs/utils/pptx_models_utils.ts +++ b/servers/nextjs/utils/pptx_models_utils.ts @@ -78,6 +78,7 @@ export function convertElementAttributesToPptxSlides( function convertElementToPptxShape( element: ElementAttributes ): PptxTextBoxModel | PptxAutoShapeBoxModel | PptxConnectorModel | PptxPictureBoxModel | null { + if (!element.position) { return null; }