Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/12452

Vanessa5936a01df587
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 175a4b9ad4..b9341d5802 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;
+ }
}
}
}