An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Keep mobile keyboard open when entering document content https://github.com/siyuan-note/siyuan/issues/19803
Daniel03615eca0e7a
diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.tsindex ceb775fb0a..b49f90a0b5 100644--- a/app/src/mobile/util/initFramework.ts+++ b/app/src/mobile/util/initFramework.ts@@ -432,6 +432,8 @@ export const initFramework = async (app: App, isStart: boolean) => {const initEditorName = () => {const inputElement = document.getElementById("toolbarName") as HTMLInputElement;let titleSavePromise: Promise<unknown> = Promise.resolve();+ let titleSavedOnEnter: {rootID: string, value: string} | undefined;+ let enteringDocument = false;const saveTitle = () => {if (inputElement.getAttribute("readonly") === "readonly") {return titleSavePromise;@@ -451,6 +453,12 @@ const initEditorName = () => {};inputElement.setAttribute("placeholder", window.siyuan.languages._kernel[16]);inputElement.addEventListener("blur", () => {+ const skipSave = titleSavedOnEnter?.rootID === window.siyuan.mobile.editor?.protyle.block.rootID &&+ titleSavedOnEnter.value === inputElement.value;+ titleSavedOnEnter = undefined;+ if (skipSave) {+ return;+ }void saveTitle();});inputElement.addEventListener("keydown", (event: KeyboardEvent) => {@@ -464,10 +472,17 @@ const initEditorName = () => {const rootID = protyle.block.rootID;event.preventDefault();event.stopPropagation();- inputElement.blur();- enterDocumentFromTitle(protyle, {- beforeLoad: titleSavePromise,+ if (enteringDocument) {+ return;+ }+ enteringDocument = true;+ const beforeLoad = saveTitle();+ titleSavedOnEnter = {rootID, value: inputElement.value};+ void enterDocumentFromTitle(protyle, {+ beforeLoad,isValid: () => window.siyuan.mobile.editor?.protyle === protyle && protyle.block.rootID === rootID,+ }).finally(() => {+ enteringDocument = false;});});};diff --git a/app/src/protyle/header/titleEnter.ts b/app/src/protyle/header/titleEnter.tsindex 6c89db5e90..7eae3d47c4 100644--- a/app/src/protyle/header/titleEnter.ts+++ b/app/src/protyle/header/titleEnter.ts@@ -31,6 +31,9 @@ const enterLoadedDocumentStart = (protyle: IProtyle) => {protyle.contentElement.scrollTop = 0;protyle.scroll.lastScrollTop = 1;if (action === "focus") {+ /// #if MOBILE+ (editElement as HTMLElement)?.focus({preventScroll: true});+ /// #endif// 配合提示文本使用,避免提示文本挤压到第二个块中focusBlock(firstElement, protyle.wysiwyg.element);return;@@ -39,6 +42,9 @@ const enterLoadedDocumentStart = (protyle: IProtyle) => {const newId = Lute.NewNodeID();const newElement = genEmptyElement(false, true, newId);protyle.wysiwyg.element.insertAdjacentElement("afterbegin", newElement);+ /// #if MOBILE+ (getContenteditableElement(newElement) as HTMLElement).focus({preventScroll: true});+ /// #endiffocusByWbr(newElement, protyle.toolbar.range || getEditorRange(newElement));transaction(protyle, [{action: "insert",@@ -54,10 +60,10 @@ const enterLoadedDocumentStart = (protyle: IProtyle) => {export const enterDocumentFromTitle = (protyle: IProtyle, options?: {beforeLoad?: Promise<unknown>,isValid?: () => boolean,-}) => {+}): Promise<void> => {const isValid = options?.isValid || (() => true);if (!isValid()) {- return;+ return Promise.resolve();}const firstElement = protyle.wysiwyg.element.firstElementChild;const editElement = firstElement ? getContenteditableElement(firstElement) : undefined;@@ -70,13 +76,13 @@ export const enterDocumentFromTitle = (protyle: IProtyle, options?: {});if (action !== "load") {enterLoadedDocumentStart(protyle);- return;+ return Promise.resolve();}const rootID = protyle.block.rootID;- const loadDocumentStart = () => {+ const loadDocumentStart = (): Promise<void> => {if (!isValid() || protyle.block.rootID !== rootID) {- return;+ return Promise.resolve();}const getDocParam: FileTreeGetDocRequestInput = {id: rootID,@@ -86,7 +92,7 @@ export const enterDocumentFromTitle = (protyle: IProtyle, options?: {if (isEncryptedBox(protyle.notebookId)) {getDocParam.notebook = protyle.notebookId;}- fetchPost("/api/filetree/getDoc", getDocParam, (response) => {+ return fetchPost("/api/filetree/getDoc", getDocParam, (response) => {if (!isValid() || protyle.block.rootID !== rootID) {return;}@@ -104,8 +110,7 @@ export const enterDocumentFromTitle = (protyle: IProtyle, options?: {});};if (options?.beforeLoad) {- void options.beforeLoad.then(loadDocumentStart, loadDocumentStart);- } else {- loadDocumentStart();+ return options.beforeLoad.then(loadDocumentStart, loadDocumentStart);}+ return loadDocumentStart();};