From 19068b9d76e43986793dac89e2390f462d5ba7a9 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 16 Jun 2022 11:40:18 +0800 Subject: [PATCH] :recycle: https://github.com/siyuan-note/siyuan/issues/4541?utm_source=ld246.com --- app/src/protyle/wysiwyg/getBlock.ts | 12 ------------ app/src/protyle/wysiwyg/keydown.ts | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/app/src/protyle/wysiwyg/getBlock.ts b/app/src/protyle/wysiwyg/getBlock.ts index 655724cb8..8c7ea1bdc 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 4144a6cb4..ce8d0b454 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();