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/6126

Vanessa7df95e03b2fd
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 33d82c4837..948f52ed6c 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -680,6 +680,12 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const selectText = range.toString();
// 删除,不可使用 !isCtrl(event),否则软删除回导致 https://github.com/siyuan-note/siyuan/issues/5607
if (!event.altKey && !event.shiftKey && (event.key === "Backspace" || event.key === "Delete")) {
+ if (protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {
+ removeBlock(protyle, nodeElement, range);
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
// https://github.com/siyuan-note/siyuan/issues/5547
const previousSibling = hasPreviousSibling(range.startContainer) as HTMLElement;
if (range.startOffset === 1 && range.startContainer.textContent === Constants.ZWSP &&
@@ -712,7 +718,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
// 光标位于转义符前 F5 后,rang 和点击后的不同,也需进行判断
if (range.startOffset === 1 && range.startContainer.nodeType !== 3 &&
- range.startContainer.parentElement.getAttribute("data-type").indexOf("backslash") > -1 &&
+ range.startContainer.parentElement.getAttribute("data-type")?.indexOf("backslash") > -1 &&
!hasPreviousSibling(range.startContainer.parentElement)) {
range.setStartBefore(range.startContainer.parentElement);
removeBlock(protyle, nodeElement, range);
@@ -721,12 +727,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
const imgSelectElement = protyle.wysiwyg.element.querySelector(".img--select");
- if (protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {
- removeBlock(protyle, nodeElement, range);
- event.stopPropagation();
- event.preventDefault();
- return;
- } else if (imgSelectElement) {
+ if (imgSelectElement) {
imgSelectElement.insertAdjacentHTML("afterend", "<wbr>");
imgSelectElement.classList.remove("img--select");
const oldHTML = nodeElement.outerHTML;