Vanessa 2025-10-09 20:02:53 +08:00
parent a82fa8be36
commit c58299a957
2 changed files with 15 additions and 2 deletions

View file

@ -149,6 +149,9 @@ const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement:
id: newSourceId,
});
if (foldData) {
foldData.doOperations[0].context = {
focusId: sourceElements[0].getAttribute("data-node-id"),
};
doOperations.push(...foldData.doOperations);
undoOperations.push(...foldData.undoOperations);
}
@ -258,6 +261,9 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
undoOperations.push(...responseTransaction.data.undoOperations);
}
if (foldData) {
foldData.doOperations[0].context = {
focusId: sourceElements[0].getAttribute("data-node-id"),
};
doOperations.push(...foldData.doOperations);
undoOperations.push(...foldData.undoOperations);
}

View file

@ -20,6 +20,7 @@ import {countBlockWord} from "../../layout/status";
import {isPaidUser, needSubscribe} from "../../util/needSubscribe";
import {resize} from "../util/resize";
import {processClonePHElement} from "../render/util";
import {scrollCenter} from "../../util/highlightById";
const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
// 移动到其他文档中,该块需移除
@ -1395,8 +1396,14 @@ const processFold = (operation: IOperation, protyle: IProtyle) => {
highlightRender(protyle.wysiwyg.element);
avRender(protyle.wysiwyg.element, protyle);
blockRender(protyle, protyle.wysiwyg.element);
if (operation.context.focusId) {
const focusElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${operation.context.focusId}"]`);
focusBlock(focusElement);
scrollCenter(protyle, focusElement, false);
} else {
protyle.contentElement.scrollTop = scrollTop;
protyle.scroll.lastScrollTop = scrollTop;
}
return;
}
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {