Skip to content

Commit 3695751

Browse files
Fix print mode not showing content in Markdown slides and Animated slides (#1299)
1 parent a9b73ac commit 3695751

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

.changeset/dull-books-provide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'spectacle': patch
3+
---
4+
5+
Fix print mode not showing content for Markdown and Animated item slides.

packages/spectacle/src/components/appear.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ReactNode, useContext } from 'react';
22
import { animated, useSpring } from 'react-spring';
33
import { useSteps } from '../hooks/use-steps';
44
import { SlideContext } from './slide/slide';
5+
import { DeckContext } from './deck/deck';
56

67
const SteppedComponent = (props: SteppedComponentProps): JSX.Element => {
78
const {
@@ -17,6 +18,8 @@ const SteppedComponent = (props: SteppedComponentProps): JSX.Element => {
1718
inactiveStyle = { opacity: '0' }
1819
} = props;
1920
const slideContext = useContext(SlideContext);
21+
const { inPrintMode, inOverviewMode } = useContext(DeckContext);
22+
2023
if (slideContext === null) {
2124
throw new Error(
2225
'This component must be used within a SlideContext.Provider. Did you' +
@@ -51,7 +54,7 @@ const SteppedComponent = (props: SteppedComponentProps): JSX.Element => {
5154
{placeholder}
5255
<AnimatedEl
5356
style={
54-
alwaysAppearActive
57+
alwaysAppearActive || inPrintMode || inOverviewMode
5558
? (activeStyle as React.CSSProperties)
5659
: springStyle
5760
}

packages/spectacle/src/components/deck/deck.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ DeckContext.displayName = 'DeckContext';
8686
const noop = () => {};
8787

8888
/**
89-
* The PDF DPI is 96. We want to scale the slide down because it's a 1:1 px to 1/100th of an inch.
90-
* However there are some unchangeable margins that make 0.96 too big, so we use 0.959 to prevent overflow.
89+
* By default, Spectacle will maintain a 100% zoom on print/export mode. This can be customized if the
90+
* user wants to select a different paper size.
9191
*/
92-
const DEFAULT_PRINT_SCALE = 0.959;
92+
const DEFAULT_PRINT_SCALE = 1.0;
9393
const DEFAULT_OVERVIEW_SCALE = 0.25;
9494

9595
type PortalProps = {

packages/spectacle/src/components/print-mode/index.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ const Backdrop = styled.div`
1010
background-color: white;
1111
`;
1212

13-
type PrintStyleProps = { pageSize: string; pageOrientation: string };
13+
type PrintStyleProps = { pageSize: string };
1414
const PrintStyle = createGlobalStyle<PrintStyleProps>`
1515
@media print {
1616
body, html {
1717
margin: 0;
1818
}
1919
@page {
20-
size: ${({ pageSize, pageOrientation }) =>
21-
`${pageSize} ${pageOrientation}`.trim()};
20+
size: ${({ pageSize }) => pageSize};
2221
}
2322
${AnimatedDiv} {
2423
@page {
@@ -33,19 +32,15 @@ export default function PrintMode({
3332
theme,
3433
exportMode,
3534
pageSize,
36-
pageOrientation = '',
3735
backgroundImage,
3836
template
3937
}: PrintModeProps) {
4038
const width = theme?.size?.width || defaultTheme.size.width;
4139
const height = theme?.size?.height || defaultTheme.size.height;
42-
const computedPageSize = pageSize || `${width / 100}in ${height / 100}in`;
40+
const computedPageSize = pageSize || `${width}px ${height}px`;
4341
return (
4442
<>
45-
<PrintStyle
46-
pageSize={computedPageSize}
47-
pageOrientation={pageOrientation}
48-
/>
43+
<PrintStyle pageSize={computedPageSize} />
4944
<DeckInternal
5045
printMode
5146
exportMode={exportMode}

0 commit comments

Comments
 (0)