Skip to content

feat: support MD/TXT file upload alongside PDF#41

Open
YizukiAme wants to merge 4 commits intoTHU-MAIC:mainfrom
YizukiAme:feat/md-txt-upload
Open

feat: support MD/TXT file upload alongside PDF#41
YizukiAme wants to merge 4 commits intoTHU-MAIC:mainfrom
YizukiAme:feat/md-txt-upload

Conversation

@YizukiAme
Copy link

What

Enable uploading Markdown (.md, .markdown) and plain text (.txt) files as course material, alongside existing PDF support. Text files bypass the OCR pipeline entirely — their content is read client-side and passed directly to the generation pipeline.

Why

Many users have learning materials in Markdown or plain text format. Previously, the upload UI only accepted .pdf files, requiring users to convert their notes before uploading.

Changes

File Change
components/generation/generation-toolbar.tsx Widen accept filter to .pdf,.md,.txt,.markdown; add isSupportedFile() helper; update UI label
app/page.tsx Branch on file extension — text files use FileReader.readAsText() to populate pdfText directly, skipping storePdfBlob() and OCR
lib/i18n/common.ts Add docUpload i18n key
lib/i18n/generation.ts Update file limit strings from "PDF" to "PDF / Markdown / TXT"

How it works

Text file (.md/.txt)  →  FileReader.readAsText()  →  pdfText = content  →  generation-preview skips PDF parsing
PDF file (.pdf)       →  storePdfBlob()           →  pdfStorageKey       →  generation-preview runs OCR as before

The generation-preview page already checks hasPdfToAnalyze = !!pdfStorageKey && !pdfText — when pdfText is already populated (text files), it skips directly to outline generation. Zero changes needed in generation-preview.

Extensibility

The isSupportedFile() helper and extension-based branching make it easy to add more formats (.docx, .csv, etc.) in the future.

Testing

  • ✅ TypeScript compiles cleanly (npx tsc --noEmit)
  • Manual: upload .md file → content passes to generation
  • Manual: upload .txt file → content passes to generation
  • Manual: upload .pdf file → existing OCR flow works (no regression)

YizukiAme and others added 4 commits March 17, 2026 00:33
When AI generates whiteboard elements that exceed the fixed 1000x562.5
canvas, content was clipped by overflow-hidden with no way to view it.

This commit adds interactive navigation to the whiteboard:

- Auto-fit: when elements overflow, content is scaled and centered to
  ensure nothing is clipped (with 24px padding)
- Drag-to-pan: hold and drag to pan around the whiteboard
- Scroll-to-zoom: mouse wheel zooms in/out (0.2x to 5x range)
- Double-click or Reset View button to return to default view
- View auto-resets when new whiteboard content loads

When content fits within the canvas, behavior is unchanged - no extra
cursor, no transforms, no visual regression.

Fixes THU-MAIC#19
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