Skip to content

Commit 48d7848

Browse files
committed
fix(checkbox): fix incorrect checkbox replacement from click
1 parent 59e8ea9 commit 48d7848

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/cherry-markdown/src/toolbars/PreviewerBubble.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ export default class PreviewerBubble {
246246
let targetCh = -1;
247247
contents.forEach((lineContent, lineIdx) => {
248248
const tmp = lineContent.trim(); // 去掉句首的空格和制表符
249-
if (tmp.startsWith('- [ ]') || tmp.startsWith('- [x]')) {
249+
if (/^-\s+\[[ x]\]/i.test(tmp)) {
250250
// 如果是个checkbox
251251
if (editorCheckboxCount === this.checkboxIdx) {
252252
targetLine = lineIdx;
253-
targetCh = lineContent.indexOf('- [') + 3;
253+
targetCh = lineContent.indexOf('[') + 1;
254254
}
255255
editorCheckboxCount += 1;
256256
}

0 commit comments

Comments
 (0)