Skip to content

Commit ab78af0

Browse files
committed
fix2618
1 parent ae840ea commit ab78af0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

browser/components/MarkdownEditor.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class MarkdownEditor extends React.Component {
149149
const idMatch = /checkbox-([0-9]+)/
150150
const checkedMatch = /^\s*[\+\-\*] \[x\]/i
151151
const uncheckedMatch = /^\s*[\+\-\*] \[ \]/
152+
const checkReplace = /\[x\]/i
153+
const uncheckReplace = /\[ \]/
152154
if (idMatch.test(e.target.getAttribute('id'))) {
153155
const lineIndex = parseInt(e.target.getAttribute('id').match(idMatch)[1], 10) - 1
154156
const lines = this.refs.code.value
@@ -157,10 +159,10 @@ class MarkdownEditor extends React.Component {
157159
const targetLine = lines[lineIndex]
158160

159161
if (targetLine.match(checkedMatch)) {
160-
lines[lineIndex] = targetLine.replace(checkedMatch, '- [ ]')
162+
lines[lineIndex] = targetLine.replace(checkReplace, '[ ]')
161163
}
162164
if (targetLine.match(uncheckedMatch)) {
163-
lines[lineIndex] = targetLine.replace(uncheckedMatch, '- [x]')
165+
lines[lineIndex] = targetLine.replace(uncheckReplace, '[x]')
164166
}
165167
this.refs.code.setValue(lines.join('\n'))
166168
}

browser/components/MarkdownSplitEditor.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class MarkdownSplitEditor extends React.Component {
8080
const idMatch = /checkbox-([0-9]+)/
8181
const checkedMatch = /^\s*[\+\-\*] \[x\]/i
8282
const uncheckedMatch = /^\s*[\+\-\*] \[ \]/
83+
const checkReplace = /\[x\]/i
84+
const uncheckReplace = /\[ \]/
8385
if (idMatch.test(e.target.getAttribute('id'))) {
8486
const lineIndex = parseInt(e.target.getAttribute('id').match(idMatch)[1], 10) - 1
8587
const lines = this.refs.code.value
@@ -88,10 +90,10 @@ class MarkdownSplitEditor extends React.Component {
8890
const targetLine = lines[lineIndex]
8991

9092
if (targetLine.match(checkedMatch)) {
91-
lines[lineIndex] = targetLine.replace(checkedMatch, '- [ ]')
93+
lines[lineIndex] = targetLine.replace(checkReplace, '[ ]')
9294
}
9395
if (targetLine.match(uncheckedMatch)) {
94-
lines[lineIndex] = targetLine.replace(uncheckedMatch, '- [x]')
96+
lines[lineIndex] = targetLine.replace(uncheckReplace, '[x]')
9597
}
9698
this.refs.code.setValue(lines.join('\n'))
9799
}

0 commit comments

Comments
 (0)