Skip to content

Web Documents: inline text/code viewer (xml, ts, js, html, …) like mobile, not download-only #19

Description

@ehsan6sha

Summary

Open text/document files inline in the web app (files.fx.land/app/) like the mobile app, instead of only downloading. Today the web bucket screen only treats .txt/.md/.json/.csv/.log (+ text/*, application/json MIME) as inline-viewable and renders them as a bare SelectableText in a small dialog; everything else — including .xml, .ts, .js, .html, .yaml, .py, etc. — falls through to download. So the document types users care about feel download-only.

Native reference

lib/features/viewer/screens/text_viewer_screen.dart + lib/core/models/local_file.dart (isTextViewable):

  • Inline-viewable extensions (40+): txt, md, rtf, csv, log, ini, conf, cfg, json, xml, yaml, yml, sql, dart, js, ts, jsx, tsx, vue, py, java, kt, swift, c, cpp, h, cs, go, rs, rb, php, html, css, sh, gradle, properties, env, gitignore, dockerignore, makefile, cmake.
  • Code extensions get a dark editor theme (#1E1E1E bg, white text, monospace): dart, js, ts, py, java, kt, swift, go, rs, c, cpp, h, css, html, xml, json, yaml, yml, sh, bash.
  • Full-screen viewer: AppBar with filename + "N lines • size"; actions = search toggle, go-to-line (disabled when wrap on), copy-all, settings menu (larger/smaller text 10-24pt, wrap toggle, line-numbers toggle).
  • Line-number gutter (toggle); wrap mode = variable-height ListView with soft-wrap; no-wrap mode = horizontal scroll with fixed item height.
  • Search: case-insensitive, highlights matched substrings (yellow), match counter i/N, prev/next, scroll-to-match.
  • JSON pretty-printed (indent 2) when < 5 MB.

Web plan

  • New pure, VM-testable logic file (no package:web/dart:ui): extension parsing (mirrors native incl. dotfiles/Makefile), isTextViewable, isCode, JSON pretty-print, line-match search — so the classification + helpers are unit-tested.
  • New full-screen web text viewer widget mirroring the native UX (line numbers, code dark theme, font sizing, wrap toggle, search w/ highlight + next/prev, go-to-line, copy-all, download, JSON pretty-print). Rendered as a full-screen dialog (consistent with the app's existing dialog-based previews; keeps download + Recent recording in the bucket screen so Web Home: add Recent section (recently-opened cloud files) like the mobile app #17 keeps working).
  • Bucket screen: expand the inline-text classification to the native list (+ text/*, application/json, application/xml MIME) so xml/ts/js/html/etc. open inline; route text to the new viewer; binary/over-cap → download fallback.
  • Decode bytes as UTF-8 lenient (malformed → replacement char). Generous size cap for inline rendering; above it, download instead.

Acceptance

  • Opening a .xml/.ts/.js/.html/.yaml/.py/.md/.csv/... document in the web app shows it inline in a mobile-style viewer (not a download).
  • Code files render in the dark editor theme; line numbers, font sizing, wrap, search (with highlight + nav), copy-all, download all work; JSON pretty-printed.
  • No regression to image/media preview, download, or the Recent strip (Web Home: add Recent section (recently-opened cloud files) like the mobile app #17). analyze + unit tests + web build green; live.

Part of the mobile->web parity work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions