diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 8af89ded..d889a0a7 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -519,6 +519,11 @@ export default class CodeEditor extends React.Component { handleHighlight (editor, changeObject) { const lines = editor.options.linesHighlighted + + if (lines == null) { + return + } + if (!lines.includes(changeObject)) { lines.push(changeObject) editor.addLineClass(changeObject, 'text', 'CodeMirror-activeline-background') @@ -566,11 +571,6 @@ export default class CodeEditor extends React.Component { this.editor.setCursor(cursor) } - restartHighlighting () { - this.editor.options.linesHighlighted = this.props.linesHighlighted - this.initialHighlighting() - } - handleDropImage (dropEvent) { dropEvent.preventDefault() const { storageKey, noteKey } = this.props @@ -709,6 +709,10 @@ export default class CodeEditor extends React.Component { } initialHighlighting () { + if (this.editor.options.linesHighlighted == null) { + return + } + const count = this.editor.lineCount() for (let i = 0; i < count; i++) { if (this.editor.options.linesHighlighted.includes(i)) { @@ -717,6 +721,11 @@ export default class CodeEditor extends React.Component { } } + restartHighlighting () { + this.editor.options.linesHighlighted = this.props.linesHighlighted + this.initialHighlighting() + } + mapImageResponse (response, pastedTxt) { return new Promise((resolve, reject) => { try {