Skip to content

Commit

Permalink
fix issues with overflowing fit-text when exporting to pdf hakimel#3191
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed May 31, 2022
1 parent a3f4caf commit 5a031c0
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
4 changes: 0 additions & 4 deletions css/print/pdf.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ html.print-pdf {
min-height: auto !important;
}

.reveal .r-fit-text {
white-space: normal !important;
}

.reveal img {
box-shadow: none;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/reveal.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions js/controllers/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ export default class Print {
slide.style.top = top + 'px';
slide.style.width = slideWidth + 'px';

// Re-run the slide layout so that r-fit-text is applied based on
// the printed slide size
this.Reveal.slideContent.layout( slide )
this.Reveal.slideContent.layout( slide );

if( slide.slideBackgroundElement ) {
page.insertBefore( slide.slideBackgroundElement, slide );
Expand Down Expand Up @@ -219,6 +217,9 @@ export default class Print {

pages.forEach( page => pageContainer.appendChild( page ) );

// Re-run JS-based content layout after the slide is added to page DOM
this.Reveal.slideContent.layout( this.Reveal.getSlidesElement() );

// Notify subscribers that the PDF layout is good to go
this.Reveal.dispatchEvent({ type: 'pdf-ready' });

Expand Down
7 changes: 3 additions & 4 deletions js/controllers/slidecontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,14 @@ export default class SlideContent {
}

/**
* Applies JS-dependent layout helpers for the given slide,
* if there are any.
* Applies JS-dependent layout helpers for the scope.
*/
layout( slide ) {
layout( scopeElement ) {

// Autosize text with the r-fit-text class based on the
// size of its container. This needs to happen after the
// slide is visible in order to measure the text.
Array.from( slide.querySelectorAll( '.r-fit-text' ) ).forEach( element => {
Array.from( scopeElement.querySelectorAll( '.r-fit-text' ) ).forEach( element => {
fitty( element, {
minSize: 24,
maxSize: this.Reveal.getConfig().height * 0.8,
Expand Down

0 comments on commit 5a031c0

Please sign in to comment.