diff --git a/backend/workers/thumbnails.go b/backend/workers/thumbnails.go index a3dd8f6..e30d332 100644 --- a/backend/workers/thumbnails.go +++ b/backend/workers/thumbnails.go @@ -218,7 +218,8 @@ func generateOfficeThumbnail(filePath, destPath string, cfg *config.Config) erro "ignorePrintArea": true, "printGridlines": true, "printHeadings": true, - "fitToWidth": 1, + "fitToWidth": 0, + "orientation": "landscape", }, } pdfUrl, err := callConvert(pdfPayload) diff --git a/frontend/src/components/FileExplorer.tsx b/frontend/src/components/FileExplorer.tsx index 4d2e8e8..58b95cd 100644 --- a/frontend/src/components/FileExplorer.tsx +++ b/frontend/src/components/FileExplorer.tsx @@ -1222,10 +1222,10 @@ export default function FileExplorer({ onLogout }: FileExplorerProps) { })(); if (isMedia && file.checksum && viewMode === 'grid') { - const isDoc = file.name.endsWith('.docx') || file.name.endsWith('.pptx') || file.name.endsWith('.xlsx'); + const docType = file.name.endsWith('.docx') ? 'docs' : file.name.endsWith('.pptx') ? 'slides' : (file.name.endsWith('.xlsx') || file.name.endsWith('.xls')) ? 'sheets' : null; return (
- +
); } diff --git a/frontend/src/components/OfficeHome.tsx b/frontend/src/components/OfficeHome.tsx index 9106662..9569b96 100644 --- a/frontend/src/components/OfficeHome.tsx +++ b/frontend/src/components/OfficeHome.tsx @@ -244,7 +244,7 @@ export default function OfficeHome({ type, onFileSelect, onCreateBlank, onPinCha > {file.checksum ? (
- } downloadToken={downloadToken} isDocument={true} /> + } downloadToken={downloadToken} docType={type} />
) : ( diff --git a/frontend/src/components/ThumbnailImage.tsx b/frontend/src/components/ThumbnailImage.tsx index ef91d2b..c97a71a 100644 --- a/frontend/src/components/ThumbnailImage.tsx +++ b/frontend/src/components/ThumbnailImage.tsx @@ -5,38 +5,66 @@ interface ThumbnailImageProps { checksum: string; fallbackIcon: React.ReactNode; downloadToken: string; - isDocument?: boolean; + docType?: 'docs' | 'slides' | 'sheets' | null; } -export default function ThumbnailImage({ checksum, fallbackIcon, downloadToken, isDocument }: ThumbnailImageProps) { +export default function ThumbnailImage({ checksum, fallbackIcon, downloadToken, docType }: ThumbnailImageProps) { const [errorCount, setErrorCount] = useState(0); const [key, setKey] = useState(0); const [showFallback, setShowFallback] = useState(false); + const docStyle = docType === 'docs' + ? 'w-[85%] aspect-[1/1.4] bg-white border border-gray-300 dark:border-gray-600 shadow-md' + : docType === 'slides' + ? 'w-[85%] aspect-[16/9] bg-white border border-gray-300 dark:border-gray-600 shadow-md' + : docType === 'sheets' + ? 'w-[85%] aspect-[1.4/1] bg-white border border-gray-300 dark:border-gray-600 shadow-md' + : 'w-full h-full'; + + const imgElement = ( + 0 ? `&t=${key}` : ''}` : ''} + alt="" + className={`object-contain ${docType ? 'w-full h-full object-cover mix-blend-multiply' : 'w-full h-full'}`} + style={{ display: showFallback ? 'none' : 'block' }} + onError={(e) => { + if (errorCount < 20) { + e.currentTarget.style.display = 'none'; + setTimeout(() => { + setErrorCount(c => c + 1); + setKey(Date.now()); + }, 2000); + } else { + setShowFallback(true); + } + }} + onLoad={(e) => { + e.currentTarget.style.display = 'block'; + setShowFallback(false); + }} + /> + ); + + if (docType) { + return ( +
+ {imgElement} + {showFallback && fallbackIcon} +
+ ); + } + return ( <> - 0 ? `&t=${key}` : ''}` : ''} - alt="" - className={`object-contain ${isDocument ? 'max-w-[85%] max-h-[85%] bg-white border border-gray-300 dark:border-gray-600 shadow-md' : 'w-full h-full'}`} - style={{ display: showFallback ? 'none' : 'block' }} - onError={(e) => { - if (errorCount < 20) { - e.currentTarget.style.display = 'none'; - setTimeout(() => { - setErrorCount(c => c + 1); - setKey(Date.now()); - }, 2000); - } else { - setShowFallback(true); - } - }} - onLoad={(e) => { - e.currentTarget.style.display = 'block'; - setShowFallback(false); - }} - /> + {imgElement} {showFallback && fallbackIcon} );