Skip to content

Commit 0dd7442

Browse files
committed
support maxWidth for pdf viewer
1 parent a36758e commit 0dd7442

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

docs/tdev/gallery/markdown/remark-pdf/index.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import BrowserWindow from '@tdev-components/BrowserWindow';
77
# PDF Viewer
88

99
```md
10-
::pdf[./assets/lehrplan-ofi.pdf]
10+
::pdf[./assets/lehrplan-ofi.pdf]{maxHeight=450px}
1111
```
1212

13-
<BrowserWindow maxHeight={'450px'}>
14-
::pdf[./assets/lehrplan-ofi.pdf]
13+
<BrowserWindow>
14+
::pdf[./assets/lehrplan-ofi.pdf]{maxHeight=450px}
1515
</BrowserWindow>
1616

1717
## Optionen
@@ -30,10 +30,10 @@ import BrowserWindow from '@tdev-components/BrowserWindow';
3030
: Breite des PDF Viewers.
3131
: Standardmässig auf __100%__ gesetzt.
3232
: z.B. `width=200px`
33-
`height`
34-
: Höhe des PDF Viewers.
33+
`maxHeight`
34+
: Höhe des PDF Viewers, nicht aber des PDF Dokuments.
3535
: Standardmässig wird eine ganze Seite angezeigt.
36-
: z.B. `height=200px`
36+
: z.B. `maxHeight=200px`
3737

3838

3939
### Einzelne Seite anzeigen (`page`)

packages/tdev/remark-pdf/PdfViewer/PdfViewer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface Props {
1717
page?: number;
1818
scroll?: boolean;
1919
width?: number;
20+
maxHeight?: number | string;
2021
minWidth?: number;
2122
scale?: number;
2223
noDownload?: boolean;
@@ -128,6 +129,7 @@ const PdfViewer = (props: Props) => {
128129
props.scroll && styles.scroll,
129130
(numPages <= 1 || props.page !== undefined) && styles.singlepage
130131
)}
132+
style={{ maxHeight: props.maxHeight, overflowY: props.maxHeight ? 'auto' : undefined }}
131133
ref={ref}
132134
>
133135
<div style={{ height: `${height + 8}px` }}>

packages/tdev/remark-pdf/remark-plugin/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const PdfViewerNode = (
4949
attr.scroll !== undefined && toJsxAttribute('scroll', attr.scroll),
5050
attr.page !== undefined && toJsxAttribute('page', attr.page),
5151
attr.width !== undefined && toJsxAttribute('width', attr.width),
52+
attr.maxHeight !== undefined && toJsxAttribute('maxHeight', attr.maxHeight),
5253
attr.minWidth !== undefined && toJsxAttribute('minWidth', attr.minWidth),
5354
attr.noDownload !== undefined && toJsxAttribute('noDownload', attr.noDownload),
5455
attr.scale !== undefined && toJsxAttribute('scale', attr.scale),

0 commit comments

Comments
 (0)