mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
fix2618
This commit is contained in:
@@ -149,6 +149,8 @@ class MarkdownEditor extends React.Component {
|
|||||||
const idMatch = /checkbox-([0-9]+)/
|
const idMatch = /checkbox-([0-9]+)/
|
||||||
const checkedMatch = /^\s*[\+\-\*] \[x\]/i
|
const checkedMatch = /^\s*[\+\-\*] \[x\]/i
|
||||||
const uncheckedMatch = /^\s*[\+\-\*] \[ \]/
|
const uncheckedMatch = /^\s*[\+\-\*] \[ \]/
|
||||||
|
const checkReplace = /\[x\]/i
|
||||||
|
const uncheckReplace = /\[ \]/
|
||||||
if (idMatch.test(e.target.getAttribute('id'))) {
|
if (idMatch.test(e.target.getAttribute('id'))) {
|
||||||
const lineIndex = parseInt(e.target.getAttribute('id').match(idMatch)[1], 10) - 1
|
const lineIndex = parseInt(e.target.getAttribute('id').match(idMatch)[1], 10) - 1
|
||||||
const lines = this.refs.code.value
|
const lines = this.refs.code.value
|
||||||
@@ -157,10 +159,10 @@ class MarkdownEditor extends React.Component {
|
|||||||
const targetLine = lines[lineIndex]
|
const targetLine = lines[lineIndex]
|
||||||
|
|
||||||
if (targetLine.match(checkedMatch)) {
|
if (targetLine.match(checkedMatch)) {
|
||||||
lines[lineIndex] = targetLine.replace(checkedMatch, '- [ ]')
|
lines[lineIndex] = targetLine.replace(checkReplace, '[ ]')
|
||||||
}
|
}
|
||||||
if (targetLine.match(uncheckedMatch)) {
|
if (targetLine.match(uncheckedMatch)) {
|
||||||
lines[lineIndex] = targetLine.replace(uncheckedMatch, '- [x]')
|
lines[lineIndex] = targetLine.replace(uncheckReplace, '[x]')
|
||||||
}
|
}
|
||||||
this.refs.code.setValue(lines.join('\n'))
|
this.refs.code.setValue(lines.join('\n'))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
const idMatch = /checkbox-([0-9]+)/
|
const idMatch = /checkbox-([0-9]+)/
|
||||||
const checkedMatch = /^\s*[\+\-\*] \[x\]/i
|
const checkedMatch = /^\s*[\+\-\*] \[x\]/i
|
||||||
const uncheckedMatch = /^\s*[\+\-\*] \[ \]/
|
const uncheckedMatch = /^\s*[\+\-\*] \[ \]/
|
||||||
|
const checkReplace = /\[x\]/i
|
||||||
|
const uncheckReplace = /\[ \]/
|
||||||
if (idMatch.test(e.target.getAttribute('id'))) {
|
if (idMatch.test(e.target.getAttribute('id'))) {
|
||||||
const lineIndex = parseInt(e.target.getAttribute('id').match(idMatch)[1], 10) - 1
|
const lineIndex = parseInt(e.target.getAttribute('id').match(idMatch)[1], 10) - 1
|
||||||
const lines = this.refs.code.value
|
const lines = this.refs.code.value
|
||||||
@@ -88,10 +90,10 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
const targetLine = lines[lineIndex]
|
const targetLine = lines[lineIndex]
|
||||||
|
|
||||||
if (targetLine.match(checkedMatch)) {
|
if (targetLine.match(checkedMatch)) {
|
||||||
lines[lineIndex] = targetLine.replace(checkedMatch, '- [ ]')
|
lines[lineIndex] = targetLine.replace(checkReplace, '[ ]')
|
||||||
}
|
}
|
||||||
if (targetLine.match(uncheckedMatch)) {
|
if (targetLine.match(uncheckedMatch)) {
|
||||||
lines[lineIndex] = targetLine.replace(uncheckedMatch, '- [x]')
|
lines[lineIndex] = targetLine.replace(uncheckReplace, '[x]')
|
||||||
}
|
}
|
||||||
this.refs.code.setValue(lines.join('\n'))
|
this.refs.code.setValue(lines.join('\n'))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user