Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/15989

Vanessac58299a95709
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 7d9d07ab6f..10ca256090 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 b25ad8b4fa..6a498c9d0a 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 => {