From 50b97c08440265d4e228c75e134614c5e76eacf0 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 12 Oct 2024 13:11:07 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/10696 --- app/src/protyle/wysiwyg/enter.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts index 3ad5c8bb4..bd960a513 100644 --- a/app/src/protyle/wysiwyg/enter.ts +++ b/app/src/protyle/wysiwyg/enter.ts @@ -7,7 +7,7 @@ import { hasPreviousSibling, isNotEditBlock } from "./getBlock"; -import {transaction, updateTransaction} from "./transaction"; +import {transaction, turnsIntoOneTransaction, updateTransaction} from "./transaction"; import {breakList, genListItemElement, listOutdent, updateListOrder} from "./list"; import {highlightRender} from "../render/highlightRender"; import {Constants} from "../../constants"; @@ -249,6 +249,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle const undoOperation: IOperation[] = []; let currentElement = blockElement; // 回车之前的块为 1\n\n2 时会产生多个块 + const selectsElement: Element[] = [] Array.from(enterElement.children).forEach((item: HTMLElement) => { if (item.dataset.nodeId === id) { blockElement.before(item); @@ -278,6 +279,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle } mathRender(item); currentElement = item; + selectsElement.push(item); }); Array.from(newElement.children).forEach((item: HTMLElement) => { @@ -299,8 +301,18 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle mathRender(currentElement.nextElementSibling); } currentElement = item; + selectsElement.push(item); }); + const parentElement = currentElement.parentElement transaction(protyle, doOperation, undoOperation); + if (parentElement.classList.contains("sb") && parentElement.getAttribute("data-sb-layout") === "col") { + turnsIntoOneTransaction({ + protyle, + selectsElement, + type: "BlocksMergeSuperBlock", + level: "row" + }); + } focusBlock(currentElement); scrollCenter(protyle); return true;