mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
fix: #288 Fixed Snippet tabs overwriting other tabs when closed
This commit is contained in:
@@ -201,6 +201,7 @@ export default class CodeEditor extends React.Component {
|
||||
this.editor.setValue(this.props.value)
|
||||
this.editor.clearHistory()
|
||||
this.editor.on('change', this.changeHandler)
|
||||
this.editor.refresh()
|
||||
}
|
||||
|
||||
setValue (value) {
|
||||
|
||||
@@ -250,17 +250,21 @@ class SnippetNoteDetail extends React.Component {
|
||||
}
|
||||
|
||||
deleteSnippetByIndex (index) {
|
||||
this.setState(() => {
|
||||
let snippets = this.state.note.snippets.slice()
|
||||
snippets.splice(index, 1)
|
||||
this.state.note.snippets = snippets
|
||||
let note = Object.assign({}, this.state.note, {snippets})
|
||||
let snippetIndex = this.state.snippetIndex >= snippets.length
|
||||
? snippets.length - 1
|
||||
: this.state.snippetIndex
|
||||
this.setState({
|
||||
note: this.state.note,
|
||||
|
||||
return {
|
||||
note,
|
||||
snippetIndex
|
||||
}
|
||||
}, () => {
|
||||
this.save()
|
||||
this.refs['code-' + this.state.snippetIndex].reload()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user