[PR #20035] [MERGED] feat: Enhanced File Viewer Modal (Excel, CSV, Markdown & Code) #25437

Closed
opened 2026-04-20 05:56:16 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20035
Author: @silentoplayz
Created: 12/18/2025
Status: Merged
Merged: 12/20/2025
Merged by: @tjbck

Base: devHead: feat/revamp-FileItemModel


📝 Commits (6)

  • 0326184 feat: Add Excel file viewer to FileItemModal
  • a3267a4 feat: Add CSV file viewer to FileItemModal
  • 432fe35 feat: Add Markdown and Code syntax highlighting to file viewer
  • 73ca287 chore: add dependency
  • d953640 fix: default to raw text view for Excel/Code/MD files
  • 5d3cdbb fix: only show rows count in preview tab for excel files

📊 Changes

2 files changed (+326 additions, -13 deletions)

View changed files

📝 package.json (+1 -0)
📝 src/lib/components/common/FileItemModal.svelte (+325 -13)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.

This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.
Before submitting, make sure you've checked the following:

  • Target branch: Verify that the pull request targets the dev branch. Not targeting the dev branch will lead to immediate closure of the PR.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: If necessary, update relevant documentation Open WebUI Docs like environment variables, the tutorials, or other documentation sources.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description.
  • Agentic AI Code: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • feat: Introduces a new feature or enhancement to the codebase

Changelog Entry

Description

This PR significantly enhances the FileItemModal component to provide a rich viewing experience for various file types that were previously displayed as plain text. It introduces native-like viewers for Excel/CSV spreadsheets, Markdown documents, and Source Code files.
Key Improvements:

  • Excel (.xls, .xlsx) & CSV: Now rendered as interactive, scrollable HTML tables with multi-sheet support.
  • Markdown (.md): Now rendered with full typography (headers, lists, links, tables) using the existing Markdown component.
  • Source Code: Now rendered with syntax highlighting using the CodeBlock component.
  • Improved Metadata: Displays accurate row counts for spreadsheet files instead of generic "extracted lines".

Added

  • Excel & CSV Viewer: Integrated xlsx library to parse and display spreadsheet data in formatted tables.
  • Markdown Rendering: Logic to detect .md files and render them using the Markdown component with prose styling.
  • Code Syntax Highlighting: Logic to detect source code files and render them using the CodeBlock component.
  • Multi-sheet Navigation: Tabbed interface for switching between sheets in Excel workbooks.
  • File Type Detection: Robust detection logic for isExcel, isMarkdown, and isCode based on MIME types and extensions.

Changed

  • Refactored src/lib/components/common/FileItemModal.svelte to support conditional rendering of different content types.
  • Updated file metadata display to show accurate "X Rows" for Excel/CSV files.
  • Improved error handling for file loading failures.

Dependencies

  • Added xlsx (^0.18.5) dependency to package.json for client-side Excel parsing.

Additional Information

This feature revamp addresses the need for better in-app file previews (Issue #2867). It leverages existing components (Markdown, CodeBlock) to keep the codebase consistent and implementation lightweight ("Quick Wins"), while adding xlsx for robust spreadsheet handling.

Note

For PDF and other text files, users may notice a lower "extracted line" count compared to previous versions. This is due to optimized whitespace handling during content rendering/extraction. It's the same content, just less white space noise.

Screenshots or Videos

Before (test-multiple-sheets.xlsx)

image

After (test-multiple-sheets.xlsx)

image image

Before (test.xlsx)

image

After (test.xlsx)

image

Before (test.xls)

image

After (test.xls)

image

Before (file_example_XLSX_5000.xlsx)

image

After (file_example_XLSX_5000.xlsx)

image

Before (file_example_XLSX_5000.xls)

image

After (file_example_XLSX_5000.xls)

image

Before (user-import.csv)

image

After (user-import.csv)

image

Before (improved-migration-guide.md)

image

After (improved-migration-guide.md)

image

Before (MemTest86_User_Guide_UEFI.pdf)

image

After (MemTest86_User_Guide_UEFI.pdf)

image

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/20035 **Author:** [@silentoplayz](https://github.com/silentoplayz) **Created:** 12/18/2025 **Status:** ✅ Merged **Merged:** 12/20/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `feat/revamp-FileItemModel` --- ### 📝 Commits (6) - [`0326184`](https://github.com/open-webui/open-webui/commit/0326184da21ec80fc020db6e7ad735a89581e495) feat: Add Excel file viewer to FileItemModal - [`a3267a4`](https://github.com/open-webui/open-webui/commit/a3267a4718f4ce261e24705412a58725f7eeedab) feat: Add CSV file viewer to FileItemModal - [`432fe35`](https://github.com/open-webui/open-webui/commit/432fe35708cf9ee09964cb9cb289f39fc3b5bcfa) feat: Add Markdown and Code syntax highlighting to file viewer - [`73ca287`](https://github.com/open-webui/open-webui/commit/73ca287032119353cc72b82dc70351537328b426) chore: add dependency - [`d953640`](https://github.com/open-webui/open-webui/commit/d953640bba94be820b5e961c69a079bb8ee34491) fix: default to raw text view for Excel/Code/MD files - [`5d3cdbb`](https://github.com/open-webui/open-webui/commit/5d3cdbb18b4a13fb79b1e06164c129520a3c5760) fix: only show rows count in preview tab for excel files ### 📊 Changes **2 files changed** (+326 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+1 -0) 📝 `src/lib/components/common/FileItemModal.svelte` (+325 -13) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request. This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Verify that the pull request targets the `dev` branch. **Not targeting the `dev` branch will lead to immediate closure of the PR.** - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** If necessary, update relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs) like environment variables, the tutorials, or other documentation sources. - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Perform manual tests to **verify the implemented fix/feature works as intended AND does not break any other functionality**. Take this as an opportunity to **make screenshots of the feature/fix and include it in the PR description**. - [x] **Agentic AI Code:** Confirm this Pull Request is **not written by any AI Agent** or has at least **gone through additional human review AND manual testing**. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR. - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **feat**: Introduces a new feature or enhancement to the codebase # Changelog Entry ### Description This PR significantly enhances the `FileItemModal` component to provide a rich viewing experience for various file types that were previously displayed as plain text. It introduces native-like viewers for **Excel/CSV spreadsheets**, **Markdown documents**, and **Source Code files**. **Key Improvements:** - **Excel (.xls, .xlsx) & CSV**: Now rendered as interactive, scrollable HTML tables with multi-sheet support. - **Markdown (.md)**: Now rendered with full typography (headers, lists, links, tables) using the existing `Markdown` component. - **Source Code**: Now rendered with syntax highlighting using the `CodeBlock` component. - **Improved Metadata**: Displays accurate row counts for spreadsheet files instead of generic "extracted lines". ### Added - **Excel & CSV Viewer**: Integrated `xlsx` library to parse and display spreadsheet data in formatted tables. - **Markdown Rendering**: Logic to detect `.md` files and render them using the `Markdown` component with `prose` styling. - **Code Syntax Highlighting**: Logic to detect source code files and render them using the `CodeBlock` component. - **Multi-sheet Navigation**: Tabbed interface for switching between sheets in Excel workbooks. - **File Type Detection**: Robust detection logic for `isExcel`, `isMarkdown`, and `isCode` based on MIME types and extensions. ### Changed - Refactored `src/lib/components/common/FileItemModal.svelte` to support conditional rendering of different content types. - Updated file metadata display to show accurate "X Rows" for Excel/CSV files. - Improved error handling for file loading failures. ### Dependencies - Added `xlsx` (^0.18.5) dependency to `package.json` for client-side Excel parsing. --- ### Additional Information This feature revamp addresses the need for better in-app file previews (Issue #2867). It leverages existing components (`Markdown`, `CodeBlock`) to keep the codebase consistent and implementation lightweight ("Quick Wins"), while adding `xlsx` for robust spreadsheet handling. > [!NOTE] > For PDF and other text files, users may notice a lower "extracted line" count compared to previous versions. This is due to optimized whitespace handling during content rendering/extraction. It's the same content, just less white space noise. ### Screenshots or Videos ### Before (test-multiple-sheets.xlsx) <img width="927" height="271" alt="image" src="https://github.com/user-attachments/assets/55ea97ba-25da-47fd-ae23-1603cd3b506d" /> ### After (test-multiple-sheets.xlsx) <img width="927" height="271" alt="image" src="https://github.com/user-attachments/assets/29dd86d3-1f8a-4df5-8012-ef462a24870f" /> <img width="927" height="271" alt="image" src="https://github.com/user-attachments/assets/ccae180c-c1a2-4b84-be6a-6fb34f17b4a2" /> ### Before (test.xlsx) <img width="927" height="271" alt="image" src="https://github.com/user-attachments/assets/70c753fd-37e6-4d1f-a6b0-3a11565c0c59" /> ### After (test.xlsx) <img width="927" height="271" alt="image" src="https://github.com/user-attachments/assets/320635db-2f69-4d47-969c-f78e826f5742" /> ### Before (test.xls) <img width="927" height="271" alt="image" src="https://github.com/user-attachments/assets/120e7b0a-0080-422f-b8d4-b0defba76e40" /> ### After (test.xls) <img width="927" height="271" alt="image" src="https://github.com/user-attachments/assets/55d1bc83-b062-4546-9c33-9b0fb66026c4" /> ### Before (file_example_XLSX_5000.xlsx) <img width="928" height="496" alt="image" src="https://github.com/user-attachments/assets/f95a797a-186a-4d06-b012-37ff6ad32413" /> ### After (file_example_XLSX_5000.xlsx) <img width="947" height="879" alt="image" src="https://github.com/user-attachments/assets/b312e376-123c-4933-8f4d-fa8ff8a336bf" /> ### Before (file_example_XLSX_5000.xls) <img width="927" height="503" alt="image" src="https://github.com/user-attachments/assets/ff531adb-7289-4eed-b162-51395546a0b9" /> ### After (file_example_XLSX_5000.xls) <img width="926" height="881" alt="image" src="https://github.com/user-attachments/assets/13defddc-8eff-44f1-aa22-6a7c3b0ec44d" /> ### Before (user-import.csv) <img width="915" height="494" alt="image" src="https://github.com/user-attachments/assets/ba31719a-d054-43d2-a75e-f3cb6dce5090" /> ### After (user-import.csv) <img width="921" height="873" alt="image" src="https://github.com/user-attachments/assets/560f3793-38ed-4b8d-a2b3-f5afab44bf7f" /> ### Before (improved-migration-guide.md) <img width="914" height="500" alt="image" src="https://github.com/user-attachments/assets/bb59ae5c-cc9c-42c5-a6b2-3080afe6c185" /> ### After (improved-migration-guide.md) <img width="913" height="880" alt="image" src="https://github.com/user-attachments/assets/ea63c51e-f0a4-4ea5-a94b-a38e345c3d44" /> ### Before (MemTest86_User_Guide_UEFI.pdf) <img width="944" height="577" alt="image" src="https://github.com/user-attachments/assets/c73efee7-a03a-4806-9d85-71280f436b22" /> ### After (MemTest86_User_Guide_UEFI.pdf) <img width="944" height="577" alt="image" src="https://github.com/user-attachments/assets/37124925-9e35-4c9a-8a41-4952832875c5" /> ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 05:56:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#25437