mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 10:46:32 +00:00
improvement: refactor buildStyle to NamedParameters style, and add some jsdoc
This commit is contained in:
@@ -47,17 +47,31 @@ const CSS_FILES = [
|
|||||||
]
|
]
|
||||||
const win = global.process.platform === 'win32'
|
const win = global.process.platform === 'win32'
|
||||||
|
|
||||||
function buildStyle (
|
/**
|
||||||
fontFamily,
|
* @param {Object} opts
|
||||||
fontSize,
|
* @param {String} opts.fontFamily
|
||||||
codeBlockFontFamily,
|
* @param {Numberl} opts.fontSize
|
||||||
lineNumber,
|
* @param {String} opts.codeBlockFontFamily
|
||||||
scrollPastEnd,
|
* @param {String} opts.theme
|
||||||
optimizeOverflowScroll,
|
* @param {Boolean} [opts.lineNumber] Should show line number
|
||||||
theme,
|
* @param {Boolean} [opts.scrollPastEnd]
|
||||||
allowCustomCSS,
|
* @param {Boolean} [opts.optimizeOverflowScroll] Should tweak body style to optimize overflow scrollbar display
|
||||||
customCSS
|
* @param {Boolean} [opts.allowCustomCSS] Should add custom css
|
||||||
) {
|
* @param {String} [opts.customCSS] Will be added to bottom, only if `opts.allowCustomCSS` is truthy
|
||||||
|
* @returns {String}
|
||||||
|
*/
|
||||||
|
function buildStyle (opts) {
|
||||||
|
const {
|
||||||
|
fontFamily,
|
||||||
|
fontSize,
|
||||||
|
codeBlockFontFamily,
|
||||||
|
lineNumber,
|
||||||
|
scrollPastEnd,
|
||||||
|
optimizeOverflowScroll,
|
||||||
|
theme,
|
||||||
|
allowCustomCSS,
|
||||||
|
customCSS
|
||||||
|
} = opts
|
||||||
return `
|
return `
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Lato';
|
font-family: 'Lato';
|
||||||
@@ -338,17 +352,16 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
customCSS
|
customCSS
|
||||||
} = this.getStyleParams()
|
} = this.getStyleParams()
|
||||||
|
|
||||||
const inlineStyles = buildStyle(
|
const inlineStyles = buildStyle({
|
||||||
fontFamily,
|
fontFamily,
|
||||||
fontSize,
|
fontSize,
|
||||||
codeBlockFontFamily,
|
codeBlockFontFamily,
|
||||||
lineNumber,
|
lineNumber,
|
||||||
scrollPastEnd,
|
scrollPastEnd,
|
||||||
false,
|
|
||||||
theme,
|
theme,
|
||||||
allowCustomCSS,
|
allowCustomCSS,
|
||||||
customCSS
|
customCSS
|
||||||
)
|
})
|
||||||
let body = this.markdown.render(noteContent)
|
let body = this.markdown.render(noteContent)
|
||||||
body = attachmentManagement.fixLocalURLS(
|
body = attachmentManagement.fixLocalURLS(
|
||||||
body,
|
body,
|
||||||
@@ -668,17 +681,17 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
'codeTheme'
|
'codeTheme'
|
||||||
).href = this.GetCodeThemeLink(codeBlockTheme)
|
).href = this.GetCodeThemeLink(codeBlockTheme)
|
||||||
|
|
||||||
this.getWindow().document.getElementById('style').innerHTML = buildStyle(
|
this.getWindow().document.getElementById('style').innerHTML = buildStyle({
|
||||||
fontFamily,
|
fontFamily,
|
||||||
fontSize,
|
fontSize,
|
||||||
codeBlockFontFamily,
|
codeBlockFontFamily,
|
||||||
lineNumber,
|
lineNumber,
|
||||||
scrollPastEnd,
|
scrollPastEnd,
|
||||||
true,
|
optimizeOverflowScroll: true,
|
||||||
theme,
|
theme,
|
||||||
allowCustomCSS,
|
allowCustomCSS,
|
||||||
customCSS,
|
customCSS
|
||||||
)
|
})
|
||||||
this.getWindow().document.documentElement.style.overflowY = 'hidden'
|
this.getWindow().document.documentElement.style.overflowY = 'hidden'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user