mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Fix regular expression related checkbox logic
This commit is contained in:
committed by
Junyoung Choi
parent
052fb3df5b
commit
e402929cca
@@ -159,8 +159,8 @@ class MarkdownEditor extends React.Component {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
const idMatch = /checkbox-([0-9]+)/
|
||||
const checkedMatch = /^\s*[\+\-\*] \[x\]/i
|
||||
const uncheckedMatch = /^\s*[\+\-\*] \[ \]/
|
||||
const checkedMatch = /^\s*>?\s*[\+\-\*] \[x\]/i
|
||||
const uncheckedMatch = /^\s*>?\s*[\+\-\*] \[ \]/
|
||||
const checkReplace = /\[x\]/i
|
||||
const uncheckReplace = /\[ \]/
|
||||
if (idMatch.test(e.target.getAttribute('id'))) {
|
||||
|
||||
@@ -78,8 +78,8 @@ class MarkdownSplitEditor extends React.Component {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
const idMatch = /checkbox-([0-9]+)/
|
||||
const checkedMatch = /^\s*[\+\-\*] \[x\]/i
|
||||
const uncheckedMatch = /^\s*[\+\-\*] \[ \]/
|
||||
const checkedMatch = /^\s*>?\s*[\+\-\*] \[x\]/i
|
||||
const uncheckedMatch = /^\s*>?\s*[\+\-\*] \[ \]/
|
||||
const checkReplace = /\[x\]/i
|
||||
const uncheckReplace = /\[ \]/
|
||||
if (idMatch.test(e.target.getAttribute('id'))) {
|
||||
|
||||
@@ -4,7 +4,7 @@ export function getTodoStatus (content) {
|
||||
let numberOfCompletedTodo = 0
|
||||
|
||||
splitted.forEach((line) => {
|
||||
const trimmedLine = line.trim()
|
||||
const trimmedLine = line.trim().replace(/^>\s*/, '')
|
||||
if (trimmedLine.match(/^[\+\-\*] \[(\s|x)\] ./i)) {
|
||||
numberOfTodo++
|
||||
}
|
||||
|
||||
@@ -28,7 +28,12 @@ test('getTodoStatus should return a correct hash object', t => {
|
||||
['- [x] `- [x] a`\n', { total: 1, completed: 1 }],
|
||||
['- [X] `- [X] a`\n', { total: 1, completed: 1 }],
|
||||
[' \t - [X] `- [X] a`\n', { total: 1, completed: 1 }],
|
||||
[' \t - [X] `- [X] a`\n \t - [ ] `- [X] a`\n', { total: 2, completed: 1 }]
|
||||
[' \t - [X] `- [X] a`\n \t - [ ] `- [X] a`\n', { total: 2, completed: 1 }],
|
||||
['> - [ ] a\n', { total: 1, completed: 0 }],
|
||||
['> - [ ] a\n- [x] a\n', { total: 2, completed: 1 }],
|
||||
['> + [ ] a\n+ foo [x]bar a\n', { total: 1, completed: 0 }],
|
||||
['> - [X] `- [X] a`\n', { total: 1, completed: 1 }],
|
||||
['> \t - [X] `- [X] a`\n', { total: 1, completed: 1 }]
|
||||
]
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
|
||||
Reference in New Issue
Block a user