diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 7d9d07ab6..10ca25609 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -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); } diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index b25ad8b4f..6a498c9d0 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -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); - protyle.contentElement.scrollTop = scrollTop; - protyle.scroll.lastScrollTop = scrollTop; + 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 => {