From 5936a01df587bd2f8b30006417322aae589f3dc3 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 29 Sep 2024 10:30:24 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/12452 --- app/src/protyle/wysiwyg/keydown.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 175a4b9ad..b9341d580 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -843,10 +843,14 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { nextSibling = nextSibling.nextSibling as Element; } if (nextSibling.nodeType === 1 && nextSibling.classList.contains("img")) { - removeImage(nextSibling as Element, nodeElement, range, protyle); - event.stopPropagation(); - event.preventDefault(); - return; + // 光标需在图片前 https://github.com/siyuan-note/siyuan/issues/12452 + const textPosition = getSelectionOffset(range.startContainer, protyle.wysiwyg.element, range) + if (textPosition.start === range.startContainer.textContent.length) { + removeImage(nextSibling as Element, nodeElement, range, protyle); + event.stopPropagation(); + event.preventDefault(); + return; + } } } }