Skip to content

feat: quick file preview for images, PDF, docx, and more - #120

Merged
mattenarle10 merged 1 commit into
mattenarle10:mainfrom
amazing-project:worktree-feature-file-preview
Jul 27, 2026
Merged

feat: quick file preview for images, PDF, docx, and more#120
mattenarle10 merged 1 commit into
mattenarle10:mainfrom
amazing-project:worktree-feature-file-preview

Conversation

@beihai23

Copy link
Copy Markdown
Contributor

Summary

marka.md only opens .md/.markdown/.mdx/.csv. Clicking any other file (image, PDF, docx, video, config.json, …) hits the binary-signature guard and shows a bare "open in default app" toast — there's no way to glance at a file inside the app. This adds an in-app quick preview overlay, with zero new dependencies.

What it does

A new fullscreen overlay (FilePreviewOverlay) mirrors the existing DiagramViewerOverlay chrome and renders each file type natively:

Type Rendering
Images (png/jpg/gif/webp/svg/bmp/avif/…) <img> with zoom / fit / drag-pan / ctrl-wheel
Video (mp4/mov/webm/…) <video controls>
Audio (mp3/wav/flac/…) <audio controls>
PDF <iframe> via webview-native rendering
Text / code (json/yaml/sh/…) read-only <pre> + "open as text" to edit
Office / unknown (docx/xlsx/pptx/zip/…) info card + "open in default app"

Binary files are read once via @tauri-apps/plugin-fs readFile → blob/data URL (PDF uses a data URL for webview-iframe compatibility; blob URLs are revoked on close). No new Tauri permissions are required — fs:allow-read-file and opener:allow-open-path are already granted.

Triggers

  • Click a previewable file → preview (replaces the old toast)
  • Context menu → "quick preview"
  • Space on a focused sidebar row (Finder Quick Look style)

.md/.csv keep opening in the editor as before. The toolbar shows a quick preview badge + esc to close hint so it's clearly read-only; on macOS the toolbar left-padding clears the native traffic-light buttons.

Behavior change

Clicking a non-markdown file now opens the preview overlay instead of the load-error toast. Text/code files preview read-only with an "open as text" button, so editability is preserved (one click into the editor).

Key files

  • src/lib/preview.ts — extension → kind/mime classification (pure, tested)
  • src/components/overlays/file-preview-overlay.tsx — the overlay + per-kind renderers
  • src/styles/overlays/file-preview.css — overlay styles
  • src/app.tsx — routing (handleSelectFile), context-menu item, Space shortcut, overlay wiring
  • src/components/files/folder-node.tsxdata-mdv-tree-path on file rows (Space target)
  • 9 locales — new menu.quickPreview + preview.* keys

Verification

Rebased onto main; on the new base (TypeScript 7, v1.6.2):

  • bun test — 54 pass (includes new tests/preview.test.ts for kind/mime classification)
  • bunx tsc --noEmit
  • bun run build (tsc + vite) ✅
  • cargo check --release ✅ (no Rust changes)
  • 9 locales all carry the new keys (no bare keys)

Manual QA still recommended across formats.

Out of scope / future

  • True docx/xlsx/pptx rendering (would need mammoth/pdf.js — intentionally zero-dep for now; info card + "open in default" covers it)
  • Tauri asset protocol (convertFileSrc) for streaming large media — current path reads the whole file, fine for typical preview sizes
  • Drag-drop into the window still routes only markdown

🤖 Generated with Claude Code

Clicking a non-markdown file in the sidebar now opens an in-app preview
instead of the "open in default app" toast. Zero new dependencies.

- images/video/audio: native renderers via blob url
- pdf: webview-native iframe via data url
- text/code: read-only <pre> with "open as text" to edit
- office/unknown formats: info card + "open in default app"

Triggers: click, context menu "quick preview", and Space (Finder Quick
Look) on a focused sidebar row. .md/.csv keep opening in the editor.
macOS toolbar left-padding clears the native traffic-light buttons.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mattenarle10

Copy link
Copy Markdown
Owner

hey sorry just got back on the repo, will review and merge in a bit!

@mattenarle10
mattenarle10 merged commit 7e9b843 into mattenarle10:main Jul 27, 2026
2 checks passed
sashamerzliakov added a commit to sashamerzliakov/markamd that referenced this pull request Jul 29, 2026
The install section, the release badge and the homebrew line were all
inherited from upstream, so a visitor read the fork's feature list and then
downloaded Matt's app without any of it. The updater badge claimed
"notarized — Apple Developer", which is not true of this build.

- install now points at this repo's releases, states plainly that the fork
  ships macOS/apple-silicon only, and sends anyone wanting Windows, Linux or
  intel mac to upstream with a note about what they'll be getting
- documents the unsigned first-launch step, since this build has no Developer
  ID and macOS will block it
- says the in-app updater is disabled and why: it needs upstream's signing key,
  and pointing it at upstream's manifest would replace the fork with the
  original app
- says homebrew installs upstream, not this
- release badge reads from this repo; upstream's kept alongside it for context
- "notarized" badge replaced with "fork build: unsigned"

Version becomes 1.6.2-fork.1: upstream 1.6.2 as the base, fork revision 1.
Not 1.7.x — upstream's quick-preview overlay (mattenarle10#120) is deliberately not in
this fork, so claiming that lineage would be wrong.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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