This commit is contained in:
Vanessa 2025-10-22 19:46:45 +08:00
parent 788a8d9a39
commit 426be24f54

View file

@ -180,7 +180,13 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
// 段首换行 // 段首换行
if (editableElement.textContent !== "" && range.toString() === "" && position.start === 0) { 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"); const newId = newElement.getAttribute("data-node-id");
transaction(protyle, [{ transaction(protyle, [{
action: "insert", action: "insert",