Appearance
useTxtViewer Composable ​
File Information ​
- Path:
app/composables/core/miscellaneous/useTxtViewer.ts - Purpose: Plain-text viewer logic for the TxtViewer component: load content via fetch (or /api/txt/proxy for cross-origin), zoom, fit mode, and in-document search
- Type: Core Composable (Miscellaneous)
Overview ​
Accepts props.src and provides loading state, text content, zoom, fit mode, and find-in-page (highlight matches, next/prev). Resolves cross-origin URLs to the server proxy (/api/txt/proxy?url=...). Uses fetch with credentials when same-origin or proxied. Emits loaded and error.
Parameters ​
- props:
{ src: string } - emit:
(event: 'loaded' | 'error', payload) => void
Return Type ​
- loading, txtReady, content, txtContainer, txtSearchInput, contentRef
- contentFontSizePx, highlightedHtml (for search highlights)
- txtZoom, txtZoomLabel, txtFitMode
- txtSearchOpen, txtSearchQuery, txtSearchMatchIndex, txtSearchMatchCount
- fitToPage, fitToWidth, zoomIn, zoomOut, resetZoom
- toggleTxtSearch, findPrev, findNext, closeTxtSearch
Usage ​
Used by the TxtViewer component. The component passes src (asset URL); the composable fetches (or proxies) and exposes content and controls.