Skip to content

feat(ui): open non-md files as plain text in editor#2

Open
hoiyada7-maker wants to merge 15 commits into
mainfrom
feat/plain-text-viewer
Open

feat(ui): open non-md files as plain text in editor#2
hoiyada7-maker wants to merge 15 commits into
mainfrom
feat/plain-text-viewer

Conversation

@hoiyada7-maker
Copy link
Copy Markdown
Owner

Summary

When a user clicks a non-.md file in the sidebar (e.g. .txt, .js, .py), instead of showing only "open in default app", the error toast now offers two choices:

  • Open in Default App — existing behavior
  • Open as Text — loads the file into the editor, hides preview (editor-only mode), treating it like Notepad

Binary files (PDF, images, executables) still show only "open in default app" with no second option.

How it works

  1. validatePlainTextFile — new helper that checks binary signatures + file size but ignores extension
  2. LoadError.canOpenAsText — flag set when a refused file passes the plain-text check
  3. loadPlainTextFile — new hook function that loads any text file bypassing extension validation
  4. Toast.secondAction — new prop for a second action button
  5. On "Open as Text": loads file → activates editor-only mode (no preview)

Test plan

  • Click a .txt file → toast shows both "open in default app" and "open as text"
  • "Open as text" → file content appears in editor, preview panel hidden
  • Click a .png / .pdf → toast shows only "open in default app" (no second option)
  • tsc clean ✓

🤖 Generated with Claude Code

hoiyada7-maker and others added 9 commits May 30, 2026 20:46
- Right-click on sidebar items now shows Copy Path and Copy Relative Path
- Added hide/show titlebar toggle button in breadcrumb bar
- Moved reading mode and theme buttons from titlebar to breadcrumb
- Extracted ThemeButton as a standalone reusable component
- Added visual separator (border-left) between view controls and file actions
- Fixed MSVC build environment via .cargo/config.toml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove TAURI_SIGNING_PRIVATE_KEY requirement
- Disable createUpdaterArtifacts at build time via node one-liner
- Add workflow_dispatch input so release can be triggered manually
- Bump actions/checkout and actions/cache to v4

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The file had hardcoded Windows CC/CXX/AR/LIB paths that broke Linux and
macOS CI builds. Added to .gitignore so it stays locally for dev but
never reaches CI runners (which auto-detect MSVC or use system toolchain).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- New Tauri command `reveal_in_file_manager`:
  Windows: opens parent folder for files, folder itself for dirs
  macOS: `open -R` to reveal in Finder
  Linux: xdg-open on parent dir
- Context menu shows Reveal in Explorer for both files and folders

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1. Explorer panel — sidebar header renamed to EXPLORER, single
   rootPath replaced with a persisted multi-folder list. Existing
   single-folder session is auto-migrated on first load.

2. Add/close folders — FolderPlus button in header opens a folder
   picker and appends to the list. Each root-folder section has an X
   button (hover-revealed) that removes it from the panel.

3. Star icon on files — each .md file row gets a star button to the
   right of the stage button. Click toggles favorites, filled star
   when active. State persisted to localStorage.

4. Favorites section — starred files appear at the top of the panel
   in a collapsible Favorites section with drag-to-reorder support.

New files: root-folder.tsx, favorites.tsx
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a sidebar file fails extension validation but is plain text
(not binary, not oversized), the error toast now shows two actions:
- "open in default app" — existing behaviour
- "open as text" — loads content into editor, activates editor-only
  mode (preview hidden) so the file is shown like Notepad

Implementation:
- files.ts: extract checkBinaryAndSize helper, add validatePlainTextFile
  that skips extension check
- LoadError: add canOpenAsText? flag set when plain-text fallback is safe
- use-file-session: add loadPlainTextFile that bypasses extension guard
- toast.tsx: add secondAction? prop for a second action button
- app.tsx: wire "open as text" → loadPlainTextFile + setEditorOnly(true)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hoiyada7-maker hoiyada7-maker force-pushed the feat/plain-text-viewer branch from e1d6250 to ad63cd3 Compare May 31, 2026 13:54
hoiyada7-maker and others added 6 commits May 31, 2026 23:17
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… mode

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Read relative img src paths via tauri-plugin-fs and convert to base64
data URIs so images stored alongside the markdown file are visible in
the preview pane.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <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.

1 participant