diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts index 20919824a..878a1ccdd 100644 --- a/app/src/protyle/wysiwyg/input.ts +++ b/app/src/protyle/wysiwyg/input.ts @@ -49,10 +49,10 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: wbrElement.remove(); return; } - if (turnIntoTaskList(protyle, type, blockElement, editElement)) { + if (turnIntoTaskList(protyle, type, blockElement, editElement, range)) { return; } - if (headingTurnIntoList(protyle, type, blockElement, editElement)) { + if (headingTurnIntoList(protyle, type, blockElement, editElement, range)) { return; } // table、粗体 中也会有 br,仅用于类似#a#,删除后会产生的 br diff --git a/app/src/protyle/wysiwyg/turnIntoList.ts b/app/src/protyle/wysiwyg/turnIntoList.ts index d1d601585..a015f9309 100644 --- a/app/src/protyle/wysiwyg/turnIntoList.ts +++ b/app/src/protyle/wysiwyg/turnIntoList.ts @@ -2,7 +2,7 @@ import {transaction, updateTransaction} from "./transaction"; import {focusByWbr} from "../util/selection"; import * as dayjs from "dayjs"; -export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement: HTMLElement, editElement: HTMLElement) => { +export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement: HTMLElement, editElement: HTMLElement, range: Range) => { if (type !== "NodeCodeBlock" && blockElement.parentElement.getAttribute("data-subtype") !== "t" && ( @@ -29,6 +29,7 @@ export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement: blockElement.previousElementSibling.outerHTML = `
` editElement.innerHTML = editElement.innerHTML.substring(contextStartIndex); updateTransaction(protyle, liElement.getAttribute("data-node-id"), liElement.outerHTML, oldHTML); + focusByWbr(protyle.wysiwyg.element, range) return true; } return false; @@ -46,7 +47,7 @@ export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement: }, { action: "insert", id: newId, - data: `