1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Add CodeEditor::setLineContent method to manipulate line contents, related #3163

Avoid changing all CodeMirror instance's contents
This commit is contained in:
hikerpig
2019-08-02 10:41:12 +08:00
committed by Junyoung Choi
parent 6ef9c3865f
commit 2352c78cb6
3 changed files with 19 additions and 6 deletions

View File

@@ -169,14 +169,15 @@ class MarkdownEditor extends React.Component {
.split('\n')
const targetLine = lines[lineIndex]
let newLine = targetLine
if (targetLine.match(checkedMatch)) {
lines[lineIndex] = targetLine.replace(checkReplace, '[ ]')
newLine = targetLine.replace(checkReplace, '[ ]')
}
if (targetLine.match(uncheckedMatch)) {
lines[lineIndex] = targetLine.replace(uncheckReplace, '[x]')
newLine = targetLine.replace(uncheckReplace, '[x]')
}
this.refs.code.setValue(lines.join('\n'))
this.refs.code.setLineContent(lineIndex, newLine)
}
}