From 18eca7f8d37574a42218c24837e6619e87527136 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 8 Sep 2023 23:06:36 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/9141 --- app/src/protyle/wysiwyg/remove.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts index b50a531cf..72532a3d0 100644 --- a/app/src/protyle/wysiwyg/remove.ts +++ b/app/src/protyle/wysiwyg/remove.ts @@ -241,7 +241,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran if (sideElement) { if (protyle.block.showAll && sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0) { setTimeout(() => { - zoomOut({protyle, id:protyle.block.parent2ID, focusId:protyle.block.parent2ID}); + zoomOut({protyle, id: protyle.block.parent2ID, focusId: protyle.block.parent2ID}); }, Constants.TIMEOUT_INPUT * 2 + 100); } else { if ((sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0)) { @@ -385,7 +385,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran const parentElement = blockElement.parentElement; const editableElement = getContenteditableElement(blockElement); - const previousLastElement = getLastBlock(previousElement) as HTMLElement; + let previousLastElement = getLastBlock(previousElement) as HTMLElement; const isSelectNode = previousLastElement && (previousLastElement.classList.contains("table") || previousLastElement.classList.contains("render-node") || previousLastElement.classList.contains("iframe") || previousLastElement.classList.contains("hr") || previousLastElement.classList.contains("code-block")); const previousId = previousLastElement.getAttribute("data-node-id"); if (isSelectNode) { @@ -412,7 +412,8 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran transaction(protyle, doOperations, undoOperations); } // toStart 参数不能为 false, 否则 https://github.com/siyuan-note/siyuan/issues/9141 - focusBlock(protyle.wysiwyg.element.querySelector(`[data-node-id="${previousId}"]`), undefined, true); + previousLastElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${previousId}"]`) + focusBlock(previousLastElement, undefined, getContenteditableElement(previousLastElement).textContent === "\n"); } else { focusBlock(previousLastElement, undefined, false); }