diff --git a/app/src/protyle/wysiwyg/turnIntoList.ts b/app/src/protyle/wysiwyg/turnIntoList.ts index f0b30af2d..4bf58e6d6 100644 --- a/app/src/protyle/wysiwyg/turnIntoList.ts +++ b/app/src/protyle/wysiwyg/turnIntoList.ts @@ -11,10 +11,12 @@ export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement: ["[]", "【】"].includes(editElement.innerHTML.substring(0, 2)) ) ) { - const contextStar2tIndex = (editElement.innerHTML.indexOf("】") + 1); - let contextStartIndex = (editElement.innerHTML.indexOf("]") + 1) || contextStar2tIndex; - if (contextStartIndex !== -1 && contextStar2tIndex < contextStartIndex) { + const contextStar2tIndex = editElement.innerHTML.indexOf("】") + 1; + let contextStartIndex = editElement.innerHTML.indexOf("]") + 1; + if (contextStartIndex === 0) { contextStartIndex = contextStar2tIndex; + } else if (contextStartIndex > 0 && contextStar2tIndex > 0) { + contextStartIndex = Math.min(contextStartIndex, contextStar2tIndex); } const isDone = editElement.innerHTML.substring(1, 2).toLowerCase() === "x"; if (blockElement.parentElement.classList.contains("li") &&