Skip to content

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

:recycle: https://github.com/siyuan-note/siyuan/issues/4541?utm_source=ld246.com

Vanessa19068b9d76e4
diff --git a/app/src/protyle/wysiwyg/getBlock.ts b/app/src/protyle/wysiwyg/getBlock.ts
index 655724cb8f..8c7ea1bdc0 100644
--- a/app/src/protyle/wysiwyg/getBlock.ts
+++ b/app/src/protyle/wysiwyg/getBlock.ts
@@ -170,15 +170,3 @@ export const hasPreviousSibling = (element: Node) => {
}
return false;
};
-
-export const hasPrevious = (element: Node) => {
- let previousSibling = element.previousSibling;
- while (previousSibling) {
- if (previousSibling.textContent === "") {
- previousSibling = previousSibling.previousSibling;
- } else {
- return previousSibling;
- }
- }
- return false;
-};
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 4144a6cb49..ce8d0b4543 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -17,7 +17,7 @@ import {
getLastBlock,
getNextBlock,
getPreviousBlock,
- getTopAloneElement, hasNextSibling, hasPrevious,
+ getTopAloneElement, hasNextSibling, hasPreviousSibling,
isNotEditBlock,
} from "./getBlock";
import {matchHotKey} from "../util/hotKey";
@@ -593,7 +593,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const currentNode = range.startContainer.childNodes[range.startOffset - 1] as HTMLElement;
if (position.start === 0 && (
range.startOffset === 0 ||
- (currentNode && currentNode.nodeType === 3 && !hasPrevious(currentNode) && currentNode.textContent === "") // https://ld246.com/article/1649251218696
+ (currentNode && currentNode.nodeType === 3 && !hasPreviousSibling(currentNode) && currentNode.textContent === "") // https://ld246.com/article/1649251218696
)) {
removeBlock(protyle, nodeElement, range);
event.stopPropagation();