fix: make PDF preview fill available vertical space (#600)
This commit is contained in:
@@ -48,8 +48,22 @@ export default function ImageDiffViewer({
|
||||
mimeType,
|
||||
sideBySide
|
||||
}: ImageDiffViewerProps): JSX.Element {
|
||||
// Why: in inline (single-column) mode the grid defaults to equal row
|
||||
// heights, which squishes each preview into half the panel. Using
|
||||
// minmax(32rem, 1fr) ensures content panes are tall enough to show a
|
||||
// full page, and overflow-y-auto lets the user scroll between them.
|
||||
// Empty "No preview" panes collapse to auto height.
|
||||
const gridRowStyle = !sideBySide
|
||||
? {
|
||||
gridTemplateRows: `${originalContent ? 'minmax(32rem, 1fr)' : 'auto'} ${modifiedContent ? 'minmax(32rem, 1fr)' : 'auto'}`
|
||||
}
|
||||
: undefined
|
||||
|
||||
return (
|
||||
<div className={`grid h-full min-h-0 gap-3 p-3 ${sideBySide ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
<div
|
||||
className={`grid h-full min-h-0 gap-3 p-3 ${sideBySide ? 'grid-cols-2' : 'grid-cols-1 overflow-y-auto'}`}
|
||||
style={gridRowStyle}
|
||||
>
|
||||
<ImageDiffPane
|
||||
label="Original"
|
||||
content={originalContent}
|
||||
|
||||
@@ -96,7 +96,7 @@ export default function ImageViewer({
|
||||
}
|
||||
|
||||
const previewPane = isPdf ? (
|
||||
<div className="relative flex flex-1 items-center justify-center overflow-auto bg-muted/20 p-4">
|
||||
<div className="relative flex flex-1 flex-col overflow-auto bg-muted/20 p-4">
|
||||
{/* Why: Electron's Chromium PDF viewer can fail to initialize inside a
|
||||
sandboxed iframe even when the Blob URL is valid. Using <embed> keeps
|
||||
the preview isolated to the browser's native PDF surface without
|
||||
@@ -104,7 +104,7 @@ export default function ImageViewer({
|
||||
<embed
|
||||
src={previewUrl}
|
||||
type={mimeType}
|
||||
className="h-full min-h-[24rem] w-full rounded-md border border-border/60 bg-background"
|
||||
className="flex-1 min-h-[24rem] w-full rounded-md border border-border/60 bg-background"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user