diff --git a/CLAUDE.md b/CLAUDE.md index 8f46325..f1d4cf2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -398,10 +398,18 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co (per-file, untouched by the batch work - the batch composable just prefixes its text with "Extracting N/M: filename —"), useRowEditing (saveEdit() now calls - `documentsService.updateDocument`, best-effort), useImageZoom, - useAutoGrow, useModalFocus (NEW 2026-10-13 — shared by every - modal component below: focuses the overlay the instant it - becomes visible, so Esc closes it immediately) + `documentsService.updateDocument`, best-effort), useImageZoom + (gained `highlight`/`highlightStyle`/`showHighlight`/ + `clearHighlight` 2026-10-13, for the review screen's + row-highlighting on an image upload — reuses its own + existing zoom math), + useAutoGrow, useModalFocus (shared by every modal + component below: focuses the overlay the instant it + becomes visible, so Esc closes it immediately), usePdfViewer + (NEW 2026-10-13 — pdf.js document loading, per-page canvas + rendering, zoom, "scroll to page N and highlight bbox"; + parallels useImageZoom's own shape — see "Review screen" + under Key decisions & lessons for the full record) /components — AppHeader (sticky top bar — brand mark, active-project breadcrumb, account menu with email + sign out; added 2026-10-13, see "Enterprise app-shell redesign" under Key @@ -427,7 +435,11 @@ security only, not the full SaaS-shaped doc — and the judgment call on what co ConfirmModal for delete), DownloadChoiceModal (NEW 2026-10-13 — "current document" vs. "all N documents", replacing a separate always-visible Download All button), - ProcessingIndicator, SourceDocumentPanel, TransactionsTable + ProcessingIndicator, SourceDocumentPanel (PDF path renders + via pdf.js/usePdfViewer as of 2026-10-13, not the browser's + native ` +
+
+

{{ pdfLoadError }}

+
+
+ +
+
+
Loading PDF…
+
Statement image preview +
diff --git a/frontend/src/composables/useImageZoom.js b/frontend/src/composables/useImageZoom.js index c2a2713..3558159 100644 --- a/frontend/src/composables/useImageZoom.js +++ b/frontend/src/composables/useImageZoom.js @@ -14,8 +14,25 @@ export function useImageZoom() { const wrapRef = ref(null) const zoom = ref(1) const fitZoom = ref(1) + // The review screen's row-highlighting for an image upload (a raw + // JPG/PNG, not a PDF) - source_bbox is already in this image's own + // natural-pixel space (see table_extract.py's _line_bbox / + // raw_ocr_extract.py), so the overlay position is just the same + // `* zoom` math applyZoom already uses for the itself, no axis + // flip or separate coordinate system needed. + const highlight = ref(null) // {bbox} | null const zoomLevelText = computed(() => Math.round(zoom.value * 100) + '%') + const highlightStyle = computed(() => { + if (!highlight.value) return null + const { x0, x1, top, bottom } = highlight.value.bbox + return { + left: x0 * zoom.value + 'px', + top: top * zoom.value + 'px', + width: (x1 - x0) * zoom.value + 'px', + height: (bottom - top) * zoom.value + 'px', + } + }) function applyZoom(z) { zoom.value = Math.max(ZOOM_MIN, Math.min(ZOOM_MAX, z)) @@ -47,5 +64,21 @@ export function useImageZoom() { applyZoom(fitZoom.value) } - return { imgRef, wrapRef, zoomLevelText, onImageLoad, zoomIn, zoomOut, resetZoom } + function showHighlight(bbox) { + if (!bbox) return + highlight.value = { bbox } + wrapRef.value?.scrollTo({ + left: Math.max(0, bbox.x0 * zoom.value - wrapRef.value.clientWidth / 2), + top: Math.max(0, bbox.top * zoom.value - wrapRef.value.clientHeight / 2), + behavior: 'smooth', + }) + } + function clearHighlight() { + highlight.value = null + } + + return { + imgRef, wrapRef, zoomLevelText, onImageLoad, zoomIn, zoomOut, resetZoom, + highlight, highlightStyle, showHighlight, clearHighlight, + } } diff --git a/frontend/src/composables/usePdfViewer.js b/frontend/src/composables/usePdfViewer.js new file mode 100644 index 0000000..bd01995 --- /dev/null +++ b/frontend/src/composables/usePdfViewer.js @@ -0,0 +1,159 @@ +/** + * pdf.js-based PDF rendering, replacing the browser's native