diff --git a/CHANGELOG.md b/CHANGELOG.md index cbd6d3b..b36f9ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html) ## [Unreleased] +### Changed + +- **Formatted view default** — markdown, RTF, and HTML files now open in formatted/rendered view by default when navigated to directly (from the tree, command palette, or a direct link with no line selection). The three separate per-format profile flags (`markdownFormat`, `rtfFormat`, `htmlFormat`) have been consolidated into a single `showFormatted` preference. + --- ## [0.7.5] - 2026-04-24 diff --git a/Cargo.lock b/Cargo.lock index b235b3c..68bb283 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "find-client" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "axum", @@ -1473,7 +1473,7 @@ dependencies = [ [[package]] name = "find-common" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "find-extract-types", @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "find-content-store" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "find-common", @@ -1503,7 +1503,7 @@ dependencies = [ [[package]] name = "find-extract-archive" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "bzip2", @@ -1527,7 +1527,7 @@ dependencies = [ [[package]] name = "find-extract-dicom" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "dicom-dictionary-std", @@ -1538,7 +1538,7 @@ dependencies = [ [[package]] name = "find-extract-dispatch" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "find-extract-dicom", @@ -1558,7 +1558,7 @@ dependencies = [ [[package]] name = "find-extract-epub" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "find-extract-types", @@ -1570,7 +1570,7 @@ dependencies = [ [[package]] name = "find-extract-html" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "find-extract-types", @@ -1580,7 +1580,7 @@ dependencies = [ [[package]] name = "find-extract-media" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "find-extract-types", @@ -1595,7 +1595,7 @@ dependencies = [ [[package]] name = "find-extract-office" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "calamine", @@ -1608,7 +1608,7 @@ dependencies = [ [[package]] name = "find-extract-pdf" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "find-extract-types", @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "find-extract-pe" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "find-extract-types", @@ -1632,7 +1632,7 @@ dependencies = [ [[package]] name = "find-extract-text" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "content_inspector", @@ -1656,7 +1656,7 @@ dependencies = [ [[package]] name = "find-handler" -version = "0.7.4" +version = "0.7.5" dependencies = [ "url", ] @@ -1669,7 +1669,7 @@ checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "find-preview-dicom" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "dicom-object", @@ -1679,7 +1679,7 @@ dependencies = [ [[package]] name = "find-server" -version = "0.7.4" +version = "0.7.5" dependencies = [ "anyhow", "axum", diff --git a/web/src/lib/FileViewer.svelte b/web/src/lib/FileViewer.svelte index 01587d1..426caef 100644 --- a/web/src/lib/FileViewer.svelte +++ b/web/src/lib/FileViewer.svelte @@ -199,17 +199,11 @@ // Tab width: user profile overrides server default. $: tabWidth = $profile.tabWidth ?? $serverTabWidth; - // Markdown format preference - $: markdownFormat = $profile.markdownFormat ?? false; + // Show formatted/rendered view — default to formatted when opening without a line selection. + $: showFormatted = $profile.showFormatted ?? preferOriginal; - // RTF format preference - $: rtfFormat = $profile.rtfFormat ?? false; - - // HTML format preference - $: htmlFormat = $profile.htmlFormat ?? false; - - function toggleHtmlFormat() { - $profile.htmlFormat = !htmlFormat; + function toggleShowFormatted() { + $profile.showFormatted = !showFormatted; } // RTF rendered HTML — rendered client-side via rtf.js (dynamically imported). @@ -217,7 +211,7 @@ let rtfFetchedForPath = ''; let rtfError = false; - $: if (rtfFormat && isRtf && rtfFetchedForPath !== rawInlinePath) { + $: if (showFormatted && isRtf && rtfFetchedForPath !== rawInlinePath) { fetchRtfHtml(rawInlinePath); } @@ -247,10 +241,6 @@ } } - function toggleRtfFormat() { - $profile.rtfFormat = !rtfFormat; - } - // "Open in Explorer" — visible when a source root is configured for this source. // For archive members we use the outer file path (Explorer can select the archive // but cannot navigate into a virtual member path). @@ -339,7 +329,7 @@ $: markdownTooLarge = isMarkdown && rawContent.length > $maxMarkdownRenderKb * 1024; // Render markdown to HTML (skipped when file exceeds size cap). - $: renderedMarkdown = markdownFormat && isMarkdown && !markdownTooLarge + $: renderedMarkdown = showFormatted && isMarkdown && !markdownTooLarge ? marked.parse(rawContent, { gfm: true, breaks: true }) : ''; @@ -347,10 +337,6 @@ $profile.wordWrap = !wordWrap; } - function toggleMarkdownFormat() { - $profile.markdownFormat = !markdownFormat; - } - function formatSize(bytes: number | null): string { if (bytes === null) return ''; if (bytes < 1024) return `${bytes} B`; @@ -696,19 +682,9 @@ {/if} {/if} - {#if isMarkdown && !markdownTooLarge} - - {/if} - {#if isRtf} - - {/if} - {#if isHtml} - {/if} {#if canOpenInExplorer} @@ -860,12 +836,12 @@ {/each} {/if} - {#if markdownTooLarge && markdownFormat} + {#if markdownTooLarge && showFormatted}
File too large to render as markdown ({Math.round(rawContent.length / 1024)} KB > {$maxMarkdownRenderKb} KB limit). Showing plain text.
{/if} - {#if htmlFormat && isHtml} + {#if showFormatted && isHtml} - {:else if rtfFormat && isRtf} + {:else if showFormatted && isRtf} {#if renderedRtf} {:else if rtfError} @@ -873,7 +849,7 @@ {:else}
Converting…
{/if} - {:else if markdownFormat && isMarkdown && !markdownTooLarge} + {:else if showFormatted && isMarkdown && !markdownTooLarge} {:else if codeLines.length === 0 && metaLines.length === 0 && archivePrefix} diff --git a/web/src/lib/profile.ts b/web/src/lib/profile.ts index de7dd80..5e19dc4 100644 --- a/web/src/lib/profile.ts +++ b/web/src/lib/profile.ts @@ -3,9 +3,7 @@ import { writable } from 'svelte/store'; export interface UserProfile { sidebarWidth?: number; wordWrap?: boolean; - markdownFormat?: boolean; - rtfFormat?: boolean; - htmlFormat?: boolean; + showFormatted?: boolean; sourceRoots?: Record; handlerInstalled?: boolean; contextWindow?: number; diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index bf114fc..892b88c 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -536,19 +536,23 @@ // ── Sidebar resize ─────────────────────────────────────────────────────────── - function onResizeStart(e: MouseEvent) { + function onResizeStart(e: PointerEvent) { + const handle = e.currentTarget as HTMLElement; + handle.setPointerCapture(e.pointerId); const startX = e.clientX; const startWidth = sidebarWidth; - function onMove(ev: MouseEvent) { + function onMove(ev: PointerEvent) { sidebarWidth = Math.min(600, Math.max(120, startWidth + ev.clientX - startX)); } function onUp() { - document.removeEventListener('mousemove', onMove); - document.removeEventListener('mouseup', onUp); + handle.removeEventListener('pointermove', onMove); + handle.removeEventListener('pointerup', onUp); + handle.removeEventListener('pointercancel', onUp); profile.update((p) => ({ ...p, sidebarWidth })); } - document.addEventListener('mousemove', onMove); - document.addEventListener('mouseup', onUp); + handle.addEventListener('pointermove', onMove); + handle.addEventListener('pointerup', onUp); + handle.addEventListener('pointercancel', onUp); } function onResizeKeydown(e: KeyboardEvent) { @@ -584,7 +588,7 @@ class="resize-handle" type="button" aria-label="Resize sidebar" - on:mousedown={onResizeStart} + on:pointerdown={onResizeStart} on:keydown={onResizeKeydown} /> {/if}