From 9d740f26c1a1a547acebedc49234f04bfbf019c3 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 22 Mar 2024 08:59:42 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/10686 --- app/src/protyle/wysiwyg/enter.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts index 274493374..c64d5d169 100644 --- a/app/src/protyle/wysiwyg/enter.ts +++ b/app/src/protyle/wysiwyg/enter.ts @@ -219,9 +219,10 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle // 回车之前的块为 1\n\n2 时会产生多个块 Array.from(enterElement.children).forEach((item: HTMLElement) => { if (item.dataset.nodeId === id) { - const previousElement = blockElement.previousElementSibling; + const blockPreviousElement = blockElement.previousElementSibling; + const blockParentElement = blockElement.parentElement; blockElement.outerHTML = item.outerHTML; - blockElement = (previousElement?.nextElementSibling || protyle.wysiwyg.element.firstElementChild) as HTMLElement; + blockElement = (blockPreviousElement ? blockPreviousElement.nextElementSibling : blockParentElement.firstElementChild) as HTMLElement; doOperation.push({ action: "update", data: blockElement.outerHTML,