Browse Source

:art: https://github.com/siyuan-note/siyuan/issues/10696

Vanessa 8 tháng trước cách đây
mục cha
commit
50b97c0844
1 tập tin đã thay đổi với 13 bổ sung1 xóa
  1. 13 1
      app/src/protyle/wysiwyg/enter.ts

+ 13 - 1
app/src/protyle/wysiwyg/enter.ts

@@ -7,7 +7,7 @@ import {
     hasPreviousSibling,
     hasPreviousSibling,
     isNotEditBlock
     isNotEditBlock
 } from "./getBlock";
 } from "./getBlock";
-import {transaction, updateTransaction} from "./transaction";
+import {transaction, turnsIntoOneTransaction, updateTransaction} from "./transaction";
 import {breakList, genListItemElement, listOutdent, updateListOrder} from "./list";
 import {breakList, genListItemElement, listOutdent, updateListOrder} from "./list";
 import {highlightRender} from "../render/highlightRender";
 import {highlightRender} from "../render/highlightRender";
 import {Constants} from "../../constants";
 import {Constants} from "../../constants";
@@ -249,6 +249,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
     const undoOperation: IOperation[] = [];
     const undoOperation: IOperation[] = [];
     let currentElement = blockElement;
     let currentElement = blockElement;
     // 回车之前的块为 1\n\n2 时会产生多个块
     // 回车之前的块为 1\n\n2 时会产生多个块
+    const selectsElement: Element[] = []
     Array.from(enterElement.children).forEach((item: HTMLElement) => {
     Array.from(enterElement.children).forEach((item: HTMLElement) => {
         if (item.dataset.nodeId === id) {
         if (item.dataset.nodeId === id) {
             blockElement.before(item);
             blockElement.before(item);
@@ -278,6 +279,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
         }
         }
         mathRender(item);
         mathRender(item);
         currentElement = item;
         currentElement = item;
+        selectsElement.push(item);
     });
     });
 
 
     Array.from(newElement.children).forEach((item: HTMLElement) => {
     Array.from(newElement.children).forEach((item: HTMLElement) => {
@@ -299,8 +301,18 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
             mathRender(currentElement.nextElementSibling);
             mathRender(currentElement.nextElementSibling);
         }
         }
         currentElement = item;
         currentElement = item;
+        selectsElement.push(item);
     });
     });
+    const parentElement = currentElement.parentElement
     transaction(protyle, doOperation, undoOperation);
     transaction(protyle, doOperation, undoOperation);
+    if (parentElement.classList.contains("sb") && parentElement.getAttribute("data-sb-layout") === "col") {
+        turnsIntoOneTransaction({
+            protyle,
+            selectsElement,
+            type: "BlocksMergeSuperBlock",
+            level: "row"
+        });
+    }
     focusBlock(currentElement);
     focusBlock(currentElement);
     scrollCenter(protyle);
     scrollCenter(protyle);
     return true;
     return true;