Browse Source

:bug: fix https://github.com/siyuan-note/siyuan/issues/6335

Vanessa 2 years ago
parent
commit
f4c3be9bd0
1 changed files with 4 additions and 2 deletions
  1. 4 2
      app/src/protyle/wysiwyg/getBlock.ts

+ 4 - 2
app/src/protyle/wysiwyg/getBlock.ts

@@ -96,12 +96,14 @@ export const getTopEmptyElement = (element: Element) => {
         if (!topElement.parentElement.getAttribute("data-node-id")) {
             topElement = topElement.parentElement;
         } else {
-            const hasText = Array.from(topElement.parentElement.querySelectorAll('[contenteditable="true"]')).find(item => {
+            let hasText = false
+            Array.from(topElement.parentElement.querySelectorAll('[contenteditable="true"]')).find(item => {
                 if (item.textContent.replace(Constants.ZWSP, "").replace("\n", "") !== "") {
+                    hasText = true;
                     return true;
                 }
             });
-            if (!hasText || topElement.previousElementSibling?.getAttribute("data-node-id") ||
+            if (hasText || topElement.previousElementSibling?.getAttribute("data-node-id") ||
                 topElement.nextElementSibling?.getAttribute("data-node-id")) {
                 break;
             } else {