From ca856a8770efabd67277f89a78401b77e12e56cc Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 1 May 2024 16:25:40 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/11209 --- app/src/protyle/wysiwyg/keydown.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 181cc6b74..9fe59d58a 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -24,7 +24,7 @@ import { getLastBlock, getNextBlock, getPreviousBlock, - getTopAloneElement, + getTopAloneElement, hasNextSibling, hasPreviousSibling, isNotEditBlock, } from "./getBlock"; @@ -806,6 +806,20 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { event.stopPropagation(); event.preventDefault(); return; + } else + // 图片前 Delete 无效 https://github.com/siyuan-note/siyuan/issues/11209 + let nextSibling = hasNextSibling(range.startContainer) as Element; + if (nextSibling) { + if (nextSibling.nodeType === 3 && nextSibling.textContent === Constants.ZWSP) { + 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; + } + } } } else { const currentNode = range.startContainer.childNodes[range.startOffset - 1] as HTMLElement;