Skip to content

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

:bug: Preserve editor content while loading mobile documents https://github.com/siyuan-note/siyuan/issues/19332

Daniel646e1267b95e
diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts
index e36fff1c69..4ad7c3f30b 100644
--- a/app/src/mobile/editor.ts
+++ b/app/src/mobile/editor.ts
@@ -202,15 +202,15 @@ export const loadMobileFileById = (app: App, id: string, action: TProtyleAction[
window.siyuan.mobile.editor.protyle.notebookId = data.data.box;
window.siyuan.mobile.editor.protyle.title.element.removeAttribute("data-render");
addLoading(window.siyuan.mobile.editor.protyle);
- if (previousRootID !== data.data.rootID) {
- window.siyuan.mobile.editor.protyle.wysiwyg.element.innerHTML = "";
- }
+ // 保留正文直到新文档返回,跨文档切换时显式更新只读状态
+ const updateReadonly = previousRootID !== data.data.rootID ? true : undefined;
const targetScrollAttr = scrollAttr || window.siyuan.storage[Constants.LOCAL_FILEPOSITION][data.data.rootID];
if (actionList.includes(Constants.CB_GET_SCROLL) && targetScrollAttr) {
getDocByScroll({
protyle: window.siyuan.mobile.editor.protyle,
scrollAttr: targetScrollAttr,
mergedOptions: protyleOptions,
+ updateReadonly,
signal,
fail,
isValid,
@@ -254,6 +254,7 @@ export const loadMobileFileById = (app: App, id: string, action: TProtyleAction[
data: getResponse,
protyle: window.siyuan.mobile.editor.protyle,
action: actionList,
+ updateReadonly,
scrollPosition,
isValid,
afterCB() {