Skip to content

Add Smart File Viewer component with auto-detection and multi-format support#20

Merged
angelikretool merged 1 commit intotryretool:mainfrom
widlestudiollp:add/global-file-viewer
Apr 6, 2026
Merged

Add Smart File Viewer component with auto-detection and multi-format support#20
angelikretool merged 1 commit intotryretool:mainfrom
widlestudiollp:add/global-file-viewer

Conversation

@widlestudiollp
Copy link
Copy Markdown
Contributor

Overview

This PR adds a new Smart File Viewer custom component for Retool that automatically detects and renders multiple file types without requiring manual configuration.

It supports files from:

  • Upload (local files)
  • URLs (including Google Drive / Docs / Sheets / Slides)
  • Base64 strings

Features

  • Auto-detection of file types (PDF, Word, Excel, CSV, JSON, images, video, text)
  • Google Drive and Docs preview support via embedded URLs
  • PDF viewer with pagination and navigation controls
  • Word (.docx) rendering using mammoth (HTML conversion)
  • Excel and CSV parsing into table view
  • JSON structured preview
  • Text file viewer with formatted output
  • Image and video preview support
  • Download, print, and clear functionality
  • Responsive UI with auto height adjustment

Technical Details

  • Built using React + TypeScript
  • Integrated with Retool using @tryretool/custom-component-support
  • Uses:
    • react-pdf for PDF rendering
    • xlsx for Excel parsing
    • mammoth for Word document rendering
  • Implements Blob URL handling for consistent file rendering
  • Includes MIME detection + filename fallback for accurate file type detection
  • Handles cleanup of Blob URLs to prevent memory leaks

Fixes & Improvements

  • Fixed incorrect MIME detection for .docx files (ZIP-based format issue)
  • Prevented PDF rendering errors for non-PDF files
  • Improved file type detection using filename fallback
  • Ensured proper handling of Base64 inputs
  • Stabilized rendering for multiple file formats

Screenshots / Preview

Screen Shot 2026-04-06 at 5 24 12 PM Screen Shot 2026-04-06 at 5 23 15 PM

Notes

This component is designed to be production-ready, extensible, and reusable across Retool apps for handling various file preview use cases.

Future enhancements can include:

  • Audio file support
  • Drag-and-drop upload
  • Improved Word rendering fidelity
  • Large dataset pagination

@angelikretool angelikretool merged commit 8b04b61 into tryretool:main Apr 6, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants