Skip to content

Commit d113e6f

Browse files
committed
fix: enable vertical and horizontal scrolling in template builder
Use absolute positioning with native overflow scrolling for both Edit and Preview tabs. Remove maxWidth constraint on A4 paper preview to maintain full width with horizontal scroll.
1 parent 43e6fd0 commit d113e6f

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed

src/renderer/src/components/template-builder/LivePreview.tsx

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { renderTemplate } from '../../lib/template-renderer'
55
import { useSampleData } from './SampleDataContext'
66
import { SampleDataEditor } from './SampleDataEditor'
77
import { Badge } from '../ui/badge'
8-
import { ScrollArea } from '../ui/scroll-area'
98
import { cn } from '../../lib/utils'
109

1110
interface LivePreviewProps {
@@ -25,7 +24,7 @@ export const LivePreview = ({ templateStructure }: LivePreviewProps) => {
2524
}, [templateStructure, sampleContext])
2625

2726
return (
28-
<div className="flex flex-col h-full overflow-hidden">
27+
<div className="absolute inset-0 flex flex-col overflow-hidden">
2928
{/* Preview Header */}
3029
<div className="flex-shrink-0 flex items-center justify-between px-4 py-2 border-b bg-muted/30">
3130
<span className="text-sm font-medium">Live Preview</span>
@@ -49,21 +48,19 @@ export const LivePreview = ({ templateStructure }: LivePreviewProps) => {
4948
{isEditorOpen && <SampleDataEditor />}
5049

5150
{/* Preview Content - scrollable within container */}
52-
<div className="flex-1 min-h-0 overflow-hidden">
53-
<ScrollArea className="h-full">
54-
<div className="p-6 bg-muted/30">
55-
<div className="flex justify-center">
56-
{/* A4 Paper Simulation */}
57-
<div
58-
className="bg-white rounded shadow-xl border"
59-
style={{
60-
width: '210mm',
61-
minHeight: '297mm',
62-
maxWidth: '100%',
63-
boxShadow:
64-
'0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.05)'
65-
}}
66-
>
51+
<div className="flex-1 min-h-0 overflow-auto bg-muted/30">
52+
<div className="p-6">
53+
<div className="flex justify-center">
54+
{/* A4 Paper Simulation */}
55+
<div
56+
className="bg-white rounded shadow-xl border"
57+
style={{
58+
width: '210mm',
59+
minHeight: '297mm',
60+
boxShadow:
61+
'0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.05)'
62+
}}
63+
>
6764
{/* Print styles scoped to preview */}
6865
<style>
6966
{`
@@ -192,10 +189,9 @@ export const LivePreview = ({ templateStructure }: LivePreviewProps) => {
192189
className="preview-content"
193190
dangerouslySetInnerHTML={{ __html: previewHtml }}
194191
/>
195-
</div>
196192
</div>
197193
</div>
198-
</ScrollArea>
194+
</div>
199195
</div>
200196
</div>
201197
)

src/renderer/src/components/template-builder/TemplateBuilder.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export const TemplateBuilder = ({
203203
</TabsList>
204204
</div>
205205

206-
<TabsContent value="edit" className="flex-1 m-0 overflow-hidden">
206+
<TabsContent value="edit" className="flex-1 m-0 overflow-hidden relative">
207207
<TemplateCanvas
208208
blocks={templateStructure.blocks}
209209
selectedBlockId={selectedBlockId}
@@ -212,7 +212,7 @@ export const TemplateBuilder = ({
212212
/>
213213
</TabsContent>
214214

215-
<TabsContent value="preview" className="flex-1 m-0 overflow-hidden">
215+
<TabsContent value="preview" className="flex-1 m-0 overflow-hidden relative">
216216
<LivePreview templateStructure={templateStructure} />
217217
</TabsContent>
218218
</Tabs>

src/renderer/src/components/template-builder/TemplateCanvas.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ export const TemplateCanvas = ({
116116
return (
117117
<div
118118
ref={setNodeRef}
119-
className={cn(
120-
'flex-1 p-4 overflow-y-auto bg-muted/30',
121-
'min-h-0'
122-
)}
119+
className={cn('absolute inset-0 p-4 overflow-y-auto bg-muted/30')}
123120
onClick={() => onSelectBlock(null)}
124121
>
125122
<div

src/renderer/src/components/ui/scroll-area.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const ScrollArea = React.forwardRef<
1414
className={cn("relative overflow-hidden", className)}
1515
{...props}
1616
>
17-
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
17+
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit] [&>div]:!block">
1818
{children}
1919
</ScrollAreaPrimitive.Viewport>
2020
<ScrollBar />

0 commit comments

Comments
 (0)