File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,8 @@ class MarkdownEditor extends React.Component {
149
149
const idMatch = / c h e c k b o x - ( [ 0 - 9 ] + ) /
150
150
const checkedMatch = / ^ \s * [ \+ \- \* ] \[ x \] / i
151
151
const uncheckedMatch = / ^ \s * [ \+ \- \* ] \[ \] /
152
+ const checkReplace = / \[ x \] / i
153
+ const uncheckReplace = / \[ \] /
152
154
if ( idMatch . test ( e . target . getAttribute ( 'id' ) ) ) {
153
155
const lineIndex = parseInt ( e . target . getAttribute ( 'id' ) . match ( idMatch ) [ 1 ] , 10 ) - 1
154
156
const lines = this . refs . code . value
@@ -157,10 +159,10 @@ class MarkdownEditor extends React.Component {
157
159
const targetLine = lines [ lineIndex ]
158
160
159
161
if ( targetLine . match ( checkedMatch ) ) {
160
- lines [ lineIndex ] = targetLine . replace ( checkedMatch , '- [ ]' )
162
+ lines [ lineIndex ] = targetLine . replace ( checkReplace , '[ ]' )
161
163
}
162
164
if ( targetLine . match ( uncheckedMatch ) ) {
163
- lines [ lineIndex ] = targetLine . replace ( uncheckedMatch , '- [x]' )
165
+ lines [ lineIndex ] = targetLine . replace ( uncheckReplace , '[x]' )
164
166
}
165
167
this . refs . code . setValue ( lines . join ( '\n' ) )
166
168
}
Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ class MarkdownSplitEditor extends React.Component {
80
80
const idMatch = / c h e c k b o x - ( [ 0 - 9 ] + ) /
81
81
const checkedMatch = / ^ \s * [ \+ \- \* ] \[ x \] / i
82
82
const uncheckedMatch = / ^ \s * [ \+ \- \* ] \[ \] /
83
+ const checkReplace = / \[ x \] / i
84
+ const uncheckReplace = / \[ \] /
83
85
if ( idMatch . test ( e . target . getAttribute ( 'id' ) ) ) {
84
86
const lineIndex = parseInt ( e . target . getAttribute ( 'id' ) . match ( idMatch ) [ 1 ] , 10 ) - 1
85
87
const lines = this . refs . code . value
@@ -88,10 +90,10 @@ class MarkdownSplitEditor extends React.Component {
88
90
const targetLine = lines [ lineIndex ]
89
91
90
92
if ( targetLine . match ( checkedMatch ) ) {
91
- lines [ lineIndex ] = targetLine . replace ( checkedMatch , '- [ ]' )
93
+ lines [ lineIndex ] = targetLine . replace ( checkReplace , '[ ]' )
92
94
}
93
95
if ( targetLine . match ( uncheckedMatch ) ) {
94
- lines [ lineIndex ] = targetLine . replace ( uncheckedMatch , '- [x]' )
96
+ lines [ lineIndex ] = targetLine . replace ( uncheckReplace , '[x]' )
95
97
}
96
98
this . refs . code . setValue ( lines . join ( '\n' ) )
97
99
}
You can’t perform that action at this time.
0 commit comments