Vanessa 2022-06-16 11:40:18 +08:00
parent 4170f50dc6
commit 19068b9d76
2 changed files with 2 additions and 14 deletions

View file

@ -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;
};

View file

@ -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();