mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-17 03:31:52 +00:00
Fixed legacy default Markdown/Snippet notes bug
Fixed a bug where a note or snippet is created before the pull request and you ran Boostnote for the first time after the pr and you firstly created a note or markdown and only then returned to the old default notes and you couldn't highlight
This commit is contained in:
@@ -520,10 +520,6 @@ export default class CodeEditor extends React.Component {
|
|||||||
handleHighlight (editor, changeObject) {
|
handleHighlight (editor, changeObject) {
|
||||||
const lines = editor.options.linesHighlighted
|
const lines = editor.options.linesHighlighted
|
||||||
|
|
||||||
if (lines == null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lines.includes(changeObject)) {
|
if (!lines.includes(changeObject)) {
|
||||||
lines.push(changeObject)
|
lines.push(changeObject)
|
||||||
editor.addLineClass(changeObject, 'text', 'CodeMirror-activeline-background')
|
editor.addLineClass(changeObject, 'text', 'CodeMirror-activeline-background')
|
||||||
|
|||||||
@@ -47,11 +47,6 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
editorType: props.config.editor.type
|
editorType: props.config.editor.type
|
||||||
}
|
}
|
||||||
|
|
||||||
let lines = this.state.note.linesHighlighted
|
|
||||||
if (lines === undefined) {
|
|
||||||
lines = []
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dispatchTimer = null
|
this.dispatchTimer = null
|
||||||
|
|
||||||
this.toggleLockButton = this.handleToggleLockButton.bind(this)
|
this.toggleLockButton = this.handleToggleLockButton.bind(this)
|
||||||
@@ -78,7 +73,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
if (!this.state.isMovingNote && (isNewNote || hasDeletedTags)) {
|
if (!this.state.isMovingNote && (isNewNote || hasDeletedTags)) {
|
||||||
if (this.saveQueue != null) this.saveNow()
|
if (this.saveQueue != null) this.saveNow()
|
||||||
this.setState({
|
this.setState({
|
||||||
note: Object.assign({}, nextProps.note)
|
note: Object.assign({linesHighlighted: []}, nextProps.note)
|
||||||
}, () => {
|
}, () => {
|
||||||
this.refs.content.reload()
|
this.refs.content.reload()
|
||||||
if (this.refs.tags) this.refs.tags.reset()
|
if (this.refs.tags) this.refs.tags.reset()
|
||||||
|
|||||||
@@ -48,16 +48,10 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
note: Object.assign({
|
note: Object.assign({
|
||||||
description: ''
|
description: ''
|
||||||
}, props.note, {
|
}, props.note, {
|
||||||
snippets: props.note.snippets.map((snippet) => Object.assign({}, snippet))
|
snippets: props.note.snippets.map((snippet) => Object.assign({linesHighlighted: []}, snippet))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state.note.snippets.forEach(function (s) {
|
|
||||||
if (s.linesHighlighted === undefined) {
|
|
||||||
s.linesHighlighted = []
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
this.scrollToNextTabThreshold = 0.7
|
this.scrollToNextTabThreshold = 0.7
|
||||||
this.generateToc = () => this.handleGenerateToc()
|
this.generateToc = () => this.handleGenerateToc()
|
||||||
}
|
}
|
||||||
@@ -82,8 +76,9 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
const nextNote = Object.assign({
|
const nextNote = Object.assign({
|
||||||
description: ''
|
description: ''
|
||||||
}, nextProps.note, {
|
}, nextProps.note, {
|
||||||
snippets: nextProps.note.snippets.map((snippet) => Object.assign({}, snippet))
|
snippets: nextProps.note.snippets.map((snippet) => Object.assign({linesHighlighted: []}, snippet))
|
||||||
})
|
})
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
snippetIndex: 0,
|
snippetIndex: 0,
|
||||||
note: nextNote
|
note: nextNote
|
||||||
@@ -694,10 +689,8 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
|
|
||||||
const viewList = note.snippets.map((snippet, index) => {
|
const viewList = note.snippets.map((snippet, index) => {
|
||||||
const isActive = this.state.snippetIndex === index
|
const isActive = this.state.snippetIndex === index
|
||||||
|
|
||||||
let syntax = CodeMirror.findModeByName(convertModeName(snippet.mode))
|
let syntax = CodeMirror.findModeByName(convertModeName(snippet.mode))
|
||||||
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
|
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
|
||||||
|
|
||||||
return <div styleName='tabView'
|
return <div styleName='tabView'
|
||||||
key={index}
|
key={index}
|
||||||
style={{zIndex: isActive ? 5 : 4}}
|
style={{zIndex: isActive ? 5 : 4}}
|
||||||
|
|||||||
Reference in New Issue
Block a user