diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts index c5ca10c81..75544bccc 100644 --- a/app/src/protyle/wysiwyg/enter.ts +++ b/app/src/protyle/wysiwyg/enter.ts @@ -180,7 +180,13 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle // 段首换行 if (editableElement.textContent !== "" && range.toString() === "" && position.start === 0) { - const newElement = genEmptyElement(false, true); + let newElement; + if (blockElement.previousElementSibling.getAttribute("data-type") === "NodeHeading" && + blockElement.previousElementSibling.getAttribute("fold") === "1") { + newElement = genHeadingElement(blockElement.previousElementSibling, false, true) as HTMLDivElement; + } else { + newElement = genEmptyElement(false, true); + } const newId = newElement.getAttribute("data-node-id"); transaction(protyle, [{ action: "insert",