diff --git a/app/src/block/util.ts b/app/src/block/util.ts index b35ee1dd1..196772f85 100644 --- a/app/src/block/util.ts +++ b/app/src/block/util.ts @@ -2,7 +2,7 @@ import {focusByWbr, getEditorRange} from "../protyle/util/selection"; import {hasClosestBlock} from "../protyle/util/hasClosest"; import {getTopAloneElement} from "../protyle/wysiwyg/getBlock"; import {genListItemElement, updateListOrder} from "../protyle/wysiwyg/list"; -import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction"; +import {transaction, turnsIntoOneTransaction, updateTransaction} from "../protyle/wysiwyg/transaction"; import {scrollCenter} from "../util/highlightById"; import {Constants} from "../constants"; import {hideElements} from "../protyle/ui/hideElements"; @@ -37,7 +37,7 @@ export const cancelSB = (protyle: IProtyle, nodeElement: Element) => { nodeElement.lastElementChild.remove(); // 超级块中的 html 块需要反转义再赋值 https://github.com/siyuan-note/siyuan/issues/13155 nodeElement.querySelectorAll("protyle-html").forEach(item => { - item.setAttribute("data-content" , item.getAttribute("data-content").replace(/</g, "<").replace(/>/g, ">")); + item.setAttribute("data-content", item.getAttribute("data-content").replace(/</g, "<").replace(/>/g, ">")); }); nodeElement.outerHTML = nodeElement.innerHTML; return; @@ -154,6 +154,15 @@ export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id id: newId, }]); } + if (blockElement.parentElement.classList.contains("sb") && + blockElement.parentElement.getAttribute("data-sb-layout") === "col") { + turnsIntoOneTransaction({ + protyle, + selectsElement: position === "afterend" ? [blockElement, blockElement.nextElementSibling] : [blockElement.previousElementSibling, blockElement], + type: "BlocksMergeSuperBlock", + level: "row" + }); + } focusByWbr(protyle.wysiwyg.element, range); scrollCenter(protyle); }; diff --git a/app/src/protyle/util/table.ts b/app/src/protyle/util/table.ts index 96f50083e..f6df3f26b 100644 --- a/app/src/protyle/util/table.ts +++ b/app/src/protyle/util/table.ts @@ -737,7 +737,7 @@ export const clearTableCell = (protyle: IProtyle, tableBlockElement: HTMLElement } }); tableSelectElement.removeAttribute("style"); - if (getSelection().rangeCount>0) { + if (getSelection().rangeCount > 0) { const range = getSelection().getRangeAt(0); if (tableBlockElement.contains(range.startContainer)) { range.insertNode(document.createElement("wbr")); diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts index 8cba280b1..84e082e1b 100644 --- a/app/src/protyle/wysiwyg/enter.ts +++ b/app/src/protyle/wysiwyg/enter.ts @@ -160,6 +160,15 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle action: "delete", id: blockId, }, undoInsert]); + if (topId === blockId && blockElement.parentElement.classList.contains("sb") && + blockElement.parentElement.getAttribute("data-sb-layout") === "col") { + turnsIntoOneTransaction({ + protyle, + selectsElement: [blockElement.previousElementSibling, blockElement], + type: "BlocksMergeSuperBlock", + level: "row" + }); + } focusByWbr(blockElement, range); return true; } diff --git a/app/src/protyle/wysiwyg/list.ts b/app/src/protyle/wysiwyg/list.ts index 1611564db..2245c7173 100644 --- a/app/src/protyle/wysiwyg/list.ts +++ b/app/src/protyle/wysiwyg/list.ts @@ -1,5 +1,5 @@ import {focusByWbr} from "../util/selection"; -import {transaction, updateTransaction} from "./transaction"; +import {transaction, turnsIntoOneTransaction, updateTransaction} from "./transaction"; import {genEmptyBlock} from "../../block/util"; import * as dayjs from "dayjs"; import {Constants} from "../../constants"; @@ -351,8 +351,8 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range: } if (parentLiItemElement.classList.contains("protyle-wysiwyg") || parentLiItemElement.classList.contains("sb") || parentLiItemElement.classList.contains("bq")) { // 顶层列表 - const doOperations: IOperation[] = []; - const undoOperations: IOperation[] = []; + const topDoOperations: IOperation[] = []; + const topUndoOperations: IOperation[] = []; range.collapse(false); moveToPrevious(deleteElement, range, isDelete); range.insertNode(document.createElement("wbr")); @@ -370,13 +370,13 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range: if (!id) { return; } - doOperations.push({ + topDoOperations.push({ action: "move", id, previousID: topPreviousID, parentID: parentLiItemElement.getAttribute("data-node-id") || protyle.block.parentID }); - undoOperations.push({ + topUndoOperations.push({ action: "move", id, previousID: index === 1 ? undefined : topPreviousID, @@ -401,7 +401,7 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range: lastBlockElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); lastBlockElement.innerHTML = `