Skip to content

feat: PDF, markdown, and text inline preview with dark mode#179

Open
zjean wants to merge 15 commits intoAtalayaLabs:mainfrom
zjean:feature/pdf-markdown-preview
Open

feat: PDF, markdown, and text inline preview with dark mode#179
zjean wants to merge 15 commits intoAtalayaLabs:mainfrom
zjean:feature/pdf-markdown-preview

Conversation

@zjean
Copy link
Copy Markdown
Contributor

@zjean zjean commented Mar 6, 2026

Summary

  • Inline file previews: Add built-in viewers for PDF (via PDF.js), Markdown (via marked + highlight.js), and plain text files — no more relying on Collabora/WOPI for simple file types
  • Dark mode support: Full dark mode styling for the inline viewer, markdown renderer, and language selector
  • WOPI intercept fixes: Prevent viewable files (images, PDFs, text, markdown) from being hijacked by the WOPI editor
  • CSP hardening: Relax Content Security Policy only where needed (blob: for media, PDF.js worker) while keeping strict defaults
  • i18n improvements: Add missing translations for upload notifications, grid view labels, and file type descriptions across all supported locales

Changes

Backend

  • file_handler.rs: Support ?download=true query param for inline vs download content disposition
  • main.rs: Serve /vendor/ static assets for PDF.js, marked, and highlight.js

Frontend

  • New inline viewer with zoom controls, fullscreen, and keyboard navigation
  • PDF.js integration with custom OxiCloud styling
  • Markdown rendering with syntax highlighting and GitHub-flavored styling
  • Text file viewer with monospace formatting
  • WOPI editor exclusion for all viewable file types (images, PDFs, text, markdown)

Vendor libraries (new)

  • PDF.js 4.x (viewer + worker + fonts + cmaps)
  • marked.js (Markdown parser)
  • highlight.js (syntax highlighting)

Test plan

  • Open a .pdf file → should render in PDF.js viewer
  • Open a .md file → should render as formatted markdown with syntax highlighting
  • Open a .txt file → should render in plain text viewer (not Collabora)
  • Open a .docx file → should still open in Collabora/WOPI editor
  • Toggle dark mode → viewer should respect theme
  • Verify CSP headers allow PDF.js and markdown viewer without console errors

🤖 Generated with Claude Code

zjean and others added 15 commits March 6, 2026 11:43
Add PDF.js v5.5.207 prebuilt viewer for enhanced PDF preview,
marked.js v15 for GitHub-flavored markdown rendering, and
highlight.js v11 for syntax highlighting in code blocks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add maximize/minimize button to toolbar. Toggle with click or F key.
Escape exits fullscreen first, then closes modal on second press.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use Mozilla PDF.js prebuilt viewer for full-featured PDF preview
with search, page navigation, thumbnails sidebar, and zoom.
Add OxiCloud theme overrides for toolbar colors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Render markdown files (.md, .markdown, .mdown, .mkd) as formatted
HTML with GitHub-flavored markdown support (tables, task lists,
strikethrough, autolinks). Code blocks get syntax highlighting
via highlight.js. Libraries are lazy-loaded on first use.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add [data-theme="dark"] styles for modal content, header, toolbar,
controls, text viewer, and audio player.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. PDFs now bypass wopiEditor.canEdit() and always open in PDF.js
   viewer, regardless of WOPI configuration.
2. Fix null reference in toggleFullscreen() — use 'button.inline-
   viewer-fullscreen i' selector to avoid matching the fullscreen
   state class on .inline-viewer-content.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Blob URLs for audio and video playback were blocked by CSP because
media-src fell back to default-src 'self'. Add explicit media-src
directive allowing blob: URLs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use i18n for "Modified" and "Folder" labels in grid card view
- Translate error fallback list headers in filesView
- Add dark mode colors for language selector .lang-code, icon and arrow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use i18n for upload notification text (uploading, complete, files label)
- Add proper nested upload.* translation keys to all 9 locales
- Fix {{double brace}} interpolation syntax for i18n params
- Add missing "markdown" file type to all locale files
- Bump service worker cache version to v16

Fixes AtalayaLabs#108

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add wasm-unsafe-eval, unsafe-inline styles, and blob: connect-src
needed by PDF.js rendering and inline markdown/code highlighting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Support ?download=true to force Content-Disposition: attachment
- Simplify viewer setup and use download param for file downloads

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change list view display from block to flex for proper column alignment
- Remove duplicate display:flex declaration in fileList.css

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Text, markdown, PDF, audio, video and image files now open in the
inline viewer instead of being intercepted by the WOPI editor.
Bump SW cache to v17.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The inlineViewer had a duplicate WOPI intercept that didn't check for
text-viewable files, causing .txt files to be sent to Collabora instead
of the built-in text viewer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zjean zjean requested a review from DioCrafts as a code owner March 6, 2026 20:41
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.

1 participant