mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Add configuration to render line breaks as <br> or not
This commit is contained in:
@@ -283,6 +283,7 @@ class MarkdownEditor extends React.Component {
|
||||
indentSize={editorIndentSize}
|
||||
scrollPastEnd={config.preview.scrollPastEnd}
|
||||
smartQuotes={config.preview.smartQuotes}
|
||||
breaks={config.preview.breaks}
|
||||
sanitize={config.preview.sanitize}
|
||||
ref='preview'
|
||||
onContextMenu={(e) => this.handleContextMenu(e)}
|
||||
|
||||
@@ -145,10 +145,11 @@ export default class MarkdownPreview extends React.Component {
|
||||
}
|
||||
|
||||
initMarkdown () {
|
||||
const { smartQuotes, sanitize } = this.props
|
||||
const { smartQuotes, sanitize, breaks } = this.props
|
||||
this.markdown = new Markdown({
|
||||
typographer: smartQuotes,
|
||||
sanitize
|
||||
sanitize,
|
||||
breaks
|
||||
})
|
||||
}
|
||||
|
||||
@@ -340,7 +341,9 @@ export default class MarkdownPreview extends React.Component {
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
if (prevProps.value !== this.props.value) this.rewriteIframe()
|
||||
if (prevProps.smartQuotes !== this.props.smartQuotes || prevProps.sanitize !== this.props.sanitize) {
|
||||
if (prevProps.smartQuotes !== this.props.smartQuotes ||
|
||||
prevProps.sanitize !== this.props.sanitize ||
|
||||
prevProps.breaks !== this.props.breaks) {
|
||||
this.initMarkdown()
|
||||
this.rewriteIframe()
|
||||
}
|
||||
@@ -599,5 +602,6 @@ MarkdownPreview.propTypes = {
|
||||
value: PropTypes.string,
|
||||
showCopyNotification: PropTypes.bool,
|
||||
storagePath: PropTypes.string,
|
||||
smartQuotes: PropTypes.bool
|
||||
smartQuotes: PropTypes.bool,
|
||||
breaks: PropTypes.bool
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ class MarkdownSplitEditor extends React.Component {
|
||||
lineNumber={config.preview.lineNumber}
|
||||
scrollPastEnd={config.preview.scrollPastEnd}
|
||||
smartQuotes={config.preview.smartQuotes}
|
||||
breaks={config.preview.breaks}
|
||||
sanitize={config.preview.sanitize}
|
||||
ref='preview'
|
||||
tabInde='0'
|
||||
|
||||
@@ -25,7 +25,7 @@ class Markdown {
|
||||
linkify: true,
|
||||
html: true,
|
||||
xhtmlOut: true,
|
||||
breaks: true,
|
||||
breaks: config.preview.breaks,
|
||||
highlight: function (str, lang) {
|
||||
const delimiter = ':'
|
||||
const langInfo = lang.split(delimiter)
|
||||
|
||||
@@ -55,6 +55,7 @@ export const DEFAULT_CONFIG = {
|
||||
latexBlockClose: '$$',
|
||||
scrollPastEnd: false,
|
||||
smartQuotes: true,
|
||||
breaks: true,
|
||||
sanitize: 'STRICT' // 'STRICT', 'ALLOW_STYLES', 'NONE'
|
||||
},
|
||||
blog: {
|
||||
|
||||
@@ -96,6 +96,7 @@ class UiTab extends React.Component {
|
||||
latexBlockClose: this.refs.previewLatexBlockClose.value,
|
||||
scrollPastEnd: this.refs.previewScrollPastEnd.checked,
|
||||
smartQuotes: this.refs.previewSmartQuotes.checked,
|
||||
breaks: this.refs.previewBreaks.checked,
|
||||
sanitize: this.refs.previewSanitize.value
|
||||
}
|
||||
}
|
||||
@@ -475,6 +476,16 @@ class UiTab extends React.Component {
|
||||
Enable smart quotes
|
||||
</label>
|
||||
</div>
|
||||
<div styleName='group-checkBoxSection'>
|
||||
<label>
|
||||
<input onChange={(e) => this.handleUIChange(e)}
|
||||
checked={this.state.config.preview.breaks}
|
||||
ref='previewBreaks'
|
||||
type='checkbox'
|
||||
/>
|
||||
Render newlines in Markdown paragraphs as <br>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div styleName='group-section'>
|
||||
<div styleName='group-section-label'>
|
||||
|
||||
Reference in New Issue
Block a user