Vanessa 2024-10-12 13:11:07 +08:00
parent 3562cc0bb1
commit 50b97c0844

View File

@ -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;