Skip to content

Commit addf9b9

Browse files
committed
tweak MarkdownPreview style to optimize overflow scrollbar display, fix #2902
1 parent 4e30d4b commit addf9b9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

browser/components/MarkdownPreview.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function buildStyle (
5353
codeBlockFontFamily,
5454
lineNumber,
5555
scrollPastEnd,
56+
optimizeOverflowScroll,
5657
theme,
5758
allowCustomCSS,
5859
customCSS
@@ -86,12 +87,14 @@ function buildStyle (
8687
url('${appPath}/resources/fonts/MaterialIcons-Regular.woff') format('woff'),
8788
url('${appPath}/resources/fonts/MaterialIcons-Regular.ttf') format('truetype');
8889
}
90+
8991
${markdownStyle}
9092
9193
body {
9294
font-family: '${fontFamily.join("','")}';
9395
font-size: ${fontSize}px;
94-
${scrollPastEnd && 'padding-bottom: 90vh;'}
96+
${scrollPastEnd ? 'padding-bottom: 90vh;' : ''}
97+
${optimizeOverflowScroll ? 'height: 100%;' : ''}
9598
}
9699
@media print {
97100
body {
@@ -341,6 +344,7 @@ export default class MarkdownPreview extends React.Component {
341344
codeBlockFontFamily,
342345
lineNumber,
343346
scrollPastEnd,
347+
false,
344348
theme,
345349
allowCustomCSS,
346350
customCSS
@@ -663,16 +667,19 @@ export default class MarkdownPreview extends React.Component {
663667
this.getWindow().document.getElementById(
664668
'codeTheme'
665669
).href = this.GetCodeThemeLink(codeBlockTheme)
670+
666671
this.getWindow().document.getElementById('style').innerHTML = buildStyle(
667672
fontFamily,
668673
fontSize,
669674
codeBlockFontFamily,
670675
lineNumber,
671676
scrollPastEnd,
677+
true,
672678
theme,
673679
allowCustomCSS,
674-
customCSS
680+
customCSS,
675681
)
682+
this.getWindow().document.documentElement.style.overflowY = 'hidden'
676683
}
677684

678685
GetCodeThemeLink (name) {

0 commit comments

Comments
 (0)