Skip to content

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

:sparkles: Support parent document title expansion on mobile https://github.com/siyuan-note/siyuan/issues/19752

Danielb17bdcca188a
diff --git a/app/src/config/tabs/fileTab.ts b/app/src/config/tabs/fileTab.ts
index ae8599d235..910ed152ac 100644
--- a/app/src/config/tabs/fileTab.ts
+++ b/app/src/config/tabs/fileTab.ts
@@ -51,14 +51,16 @@ const registerFileTreeBehaviorGroup = (tab: SettingTabBuilder) => {
getAllModels().files.forEach((files) => files.updateDocActions());
}),
});
+ /// #endif
group.switch("fileTree.parentDocClickExpand", {
title: window.siyuan.languages.parentDocClickExpand,
- desc: window.siyuan.languages.parentDocClickExpandTip,
+ desc: window.siyuan.mobile ? "" : window.siyuan.languages.parentDocClickExpandTip,
save: (value) => fileConfigApi.patch("parentDocClickExpand", value, () => {
+ /// #if !MOBILE
getAllModels().files.forEach((files) => files.updateDocActions());
+ /// #endif
}),
});
- /// #endif
group.switch("fileTree.alwaysSelectOpenedFile", {
title: window.siyuan.languages.selectOpen,
desc: window.siyuan.languages.fileTree2,
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index fc4e97bbf0..2547ce0046 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -48,7 +48,7 @@ import {syncFileTreeItemDefaultIcon} from "../emoji/fileTreeIcon";
import {getHostCapabilities} from "../util/hostCapabilities";
/// #if MOBILE
import {openEmojiPanel} from "../emoji";
-import {openMobileFileByIdInNewTab} from "../mobile/editor";
+import {openMobileFileById, openMobileFileByIdInNewTab} from "../mobile/editor";
/// #endif
const confirmEncryptedExport = (notebookId: string, callback: () => void) => {
@@ -432,7 +432,6 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
window.siyuan.menus.menu.element.setAttribute("data-from", Constants.MENU_FROM_DOC_TREE_MORE_NOTEBOOK);
const notebookId = liElement.parentElement.getAttribute("data-url");
const name = getNotebookName(notebookId);
- /// #if !MOBILE
const boxDocID = liElement.getAttribute("data-node-id");
if (boxDocID && window.siyuan.config.fileTree.parentDocClickExpand &&
Number(liElement.getAttribute("data-count")) > 0) {
@@ -441,15 +440,18 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
label: window.siyuan.languages.openDocument,
icon: "iconOpen",
click: () => {
+ /// #if MOBILE
+ openMobileFileById(app, boxDocID, [Constants.CB_GET_SCROLL], undefined, notebookId);
+ /// #else
openFileById({
app,
id: boxDocID,
action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],
});
+ /// #endif
}
}).element);
}
- /// #endif
if (!window.siyuan.config.readonly) {
/// #if MOBILE
window.siyuan.menus.menu.append(new MenuItem({
@@ -735,22 +737,24 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
}).element);
window.siyuan.menus.menu.append(new MenuItem({id: "separator_open", type: "separator"}).element);
/// #endif
- /// #if !MOBILE
if (window.siyuan.config.fileTree.parentDocClickExpand && Number(liElement.getAttribute("data-count")) > 0) {
window.siyuan.menus.menu.append(new MenuItem({
id: "openDocument",
label: window.siyuan.languages.openDocument,
icon: "iconOpen",
click: () => {
+ /// #if MOBILE
+ openMobileFileById(app, id, [Constants.CB_GET_SCROLL], undefined, notebookId);
+ /// #else
openFileById({
app,
id,
action: isPhablet() ? [Constants.CB_GET_SCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],
});
+ /// #endif
}
}).element);
}
- /// #endif
if (!window.siyuan.config.readonly) {
if (isCustomFileTreeList(liElement.getAttribute("data-pin-root") === "true" ? liElement : liElement.parentElement)) {
window.siyuan.menus.menu.append(new MenuItem({
diff --git a/app/src/mobile/dock/MobileFiles.ts b/app/src/mobile/dock/MobileFiles.ts
index 92ebfa70dc..d15ab9ff88 100644
--- a/app/src/mobile/dock/MobileFiles.ts
+++ b/app/src/mobile/dock/MobileFiles.ts
@@ -306,11 +306,19 @@ export class MobileFiles extends Model {
const ulElement = hasTopClosestByTag(target, "UL");
const notebookId = ulElement ? ulElement.getAttribute("data-url") : "";
if (target.getAttribute("data-type") === "navigation-file") {
- openMobileFileById(app, target.getAttribute("data-node-id"), [Constants.CB_GET_SCROLL], undefined, notebookId);
+ if (window.siyuan.config.fileTree.parentDocClickExpand && Number(target.getAttribute("data-count")) > 0) {
+ this.toggleTreeItem(target);
+ } else {
+ openMobileFileById(app, target.getAttribute("data-node-id"), [Constants.CB_GET_SCROLL], undefined, notebookId);
+ }
} else if (target.getAttribute("data-type") === "navigation-root") {
const boxDocID = target.getAttribute("data-node-id");
if (boxDocID) {
- openMobileFileById(app, boxDocID, [Constants.CB_GET_SCROLL], undefined, notebookId);
+ if (window.siyuan.config.fileTree.parentDocClickExpand && Number(target.getAttribute("data-count")) > 0) {
+ this.toggleTreeItem(target);
+ } else {
+ openMobileFileById(app, boxDocID, [Constants.CB_GET_SCROLL], undefined, notebookId);
+ }
} else if (ulElement) {
this.getLeaf(target, notebookId);
}