Skip to content

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

:art: Focus document title after creation on mobile https://github.com/siyuan-note/siyuan/issues/19359

Daniel079d46d69978
diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts
index 4ad7c3f30b..bc9091f306 100644
--- a/app/src/mobile/editor.ts
+++ b/app/src/mobile/editor.ts
@@ -22,6 +22,7 @@ import {stickyRow} from "../protyle/render/av/row";
import {invalidateTrackedRanges} from "../protyle/util/trackedRange";
import {getActiveMobileSecondaryEditor} from "./util/secondaryEditors";
import {closeMobileBacklinkSheets} from "./util/backlinkPanels";
+import {focusByRange} from "../protyle/util/selection";
export const getCurrentEditor = () => {
return getActiveMobileSecondaryEditor() || window.siyuan.mobile.popEditor || window.siyuan.mobile.editor;
@@ -84,6 +85,17 @@ export const loadMobileFileById = (app: App, id: string, action: TProtyleAction[
void window.siyuan.mobile.docks.file?.selectOpenedFile(protyle.notebookId, protyle.path);
}
afterOpen?.(protyle);
+ if (isValid() && action.includes(Constants.CB_GET_OPENNEW) && !protyle.disabled &&
+ protyle.title?.editElement.isContentEditable) {
+ // 新建文档加载完成后聚焦标题,通过移动端焦点桥接唤起键盘。
+ const titleElement = protyle.title.editElement;
+ protyle.contentElement.scrollTop = 0;
+ titleElement.focus({preventScroll: true});
+ const range = document.createRange();
+ range.selectNodeContents(titleElement);
+ range.collapse(false);
+ focusByRange(range);
+ }
};
const fail = (invalid = false) => {
if (completed) {