1
0
mirror of https://github.com/BoostIo/Boostnote synced 2026-01-02 11:39:25 +00:00

Make line numbers in the editor optional

This commit is contained in:
David Pavlík
2017-09-20 22:33:51 +02:00
parent 0d34a03fe0
commit 7a4258bb20
5 changed files with 22 additions and 1 deletions

View File

@@ -50,7 +50,7 @@ export default class CodeEditor extends React.Component {
this.value = this.props.value
this.editor = CodeMirror(this.refs.root, {
value: this.props.value,
lineNumbers: true,
lineNumbers: this.props.lineNumber,
lineWrapping: true,
theme: this.props.theme,
indentUnit: this.props.indentSize,
@@ -141,6 +141,10 @@ export default class CodeEditor extends React.Component {
this.editor.setOption('indentWithTabs', this.props.indentType !== 'space')
}
if (prevProps.lineNumber !== this.props.lineNumber) {
this.editor.setOption('lineNumbers', this.props.lineNumber)
}
if (needRefresh) {
this.editor.refresh()
}

View File

@@ -213,6 +213,8 @@ class MarkdownEditor extends React.Component {
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
let editorIndentSize = parseInt(config.editor.indentSize, 10)
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
let editorLineNumber = config.editor.lineNumber
if (editorLineNumber === undefined) editorLineNumber = true
let previewStyle = {}
if (this.props.ignorePreviewPointerEvents) previewStyle.pointerEvents = 'none'
@@ -242,6 +244,7 @@ class MarkdownEditor extends React.Component {
fontSize={editorFontSize}
indentType={config.editor.indentType}
indentSize={editorIndentSize}
lineNumber={editorLineNumber}
storageKey={storageKey}
onChange={(e) => this.handleChange(e)}
onBlur={(e) => this.handleBlur(e)}