@@ -42,16 +42,31 @@ const CSS_FILES = [
42
42
`${ appPath } /node_modules/react-image-carousel/lib/css/main.min.css`
43
43
]
44
44
45
- function buildStyle (
46
- fontFamily ,
47
- fontSize ,
48
- codeBlockFontFamily ,
49
- lineNumber ,
50
- scrollPastEnd ,
51
- theme ,
52
- allowCustomCSS ,
53
- customCSS
54
- ) {
45
+ /**
46
+ * @param {Object } opts
47
+ * @param {String } opts.fontFamily
48
+ * @param {Numberl } opts.fontSize
49
+ * @param {String } opts.codeBlockFontFamily
50
+ * @param {String } opts.theme
51
+ * @param {Boolean } [opts.lineNumber] Should show line number
52
+ * @param {Boolean } [opts.scrollPastEnd]
53
+ * @param {Boolean } [opts.optimizeOverflowScroll] Should tweak body style to optimize overflow scrollbar display
54
+ * @param {Boolean } [opts.allowCustomCSS] Should add custom css
55
+ * @param {String } [opts.customCSS] Will be added to bottom, only if `opts.allowCustomCSS` is truthy
56
+ * @returns {String }
57
+ */
58
+ function buildStyle ( opts ) {
59
+ const {
60
+ fontFamily,
61
+ fontSize,
62
+ codeBlockFontFamily,
63
+ lineNumber,
64
+ scrollPastEnd,
65
+ optimizeOverflowScroll,
66
+ theme,
67
+ allowCustomCSS,
68
+ customCSS
69
+ } = opts
55
70
return `
56
71
@font-face {
57
72
font-family: 'Lato';
@@ -81,12 +96,14 @@ function buildStyle (
81
96
url('${ appPath } /resources/fonts/MaterialIcons-Regular.woff') format('woff'),
82
97
url('${ appPath } /resources/fonts/MaterialIcons-Regular.ttf') format('truetype');
83
98
}
99
+
84
100
${ markdownStyle }
85
101
86
102
body {
87
103
font-family: '${ fontFamily . join ( "','" ) } ';
88
104
font-size: ${ fontSize } px;
89
- ${ scrollPastEnd && 'padding-bottom: 90vh;' }
105
+ ${ scrollPastEnd ? 'padding-bottom: 90vh;' : '' }
106
+ ${ optimizeOverflowScroll ? 'height: 100%;' : '' }
90
107
}
91
108
@media print {
92
109
body {
@@ -312,7 +329,7 @@ export default class MarkdownPreview extends React.Component {
312
329
customCSS
313
330
} = this . getStyleParams ( )
314
331
315
- const inlineStyles = buildStyle (
332
+ const inlineStyles = buildStyle ( {
316
333
fontFamily,
317
334
fontSize,
318
335
codeBlockFontFamily,
@@ -321,7 +338,7 @@ export default class MarkdownPreview extends React.Component {
321
338
theme,
322
339
allowCustomCSS,
323
340
customCSS
324
- )
341
+ } )
325
342
let body = this . markdown . render ( noteContent )
326
343
body = attachmentManagement . fixLocalURLS (
327
344
body ,
@@ -652,16 +669,18 @@ export default class MarkdownPreview extends React.Component {
652
669
this . getWindow ( ) . document . getElementById (
653
670
'codeTheme'
654
671
) . href = this . getCodeThemeLink ( codeBlockTheme )
655
- this . getWindow ( ) . document . getElementById ( 'style' ) . innerHTML = buildStyle (
672
+ this . getWindow ( ) . document . getElementById ( 'style' ) . innerHTML = buildStyle ( {
656
673
fontFamily,
657
674
fontSize,
658
675
codeBlockFontFamily,
659
676
lineNumber,
660
677
scrollPastEnd,
678
+ optimizeOverflowScroll : true ,
661
679
theme,
662
680
allowCustomCSS,
663
681
customCSS
664
- )
682
+ } )
683
+ this . getWindow ( ) . document . documentElement . style . overflowY = 'hidden'
665
684
}
666
685
667
686
getCodeThemeLink ( name ) {
0 commit comments