An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Add pin action to the notebook menu https://github.com/siyuan-note/siyuan/issues/19401
Daniel109752323a00
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.tsindex 394fe92dc2..fd402dccb9 100644--- a/app/src/config/entryVisibility/catalog.test.ts+++ b/app/src/config/entryVisibility/catalog.test.ts@@ -1004,6 +1004,16 @@ test("configuration labels distinguish block scopes and size controls", () => {}});+test("notebook pin entries follow settings and precede sorting", () => {+ const keys = getEntryCatalogChildren("docTree.notebook").map(item => item.key);+ assert.deepEqual(keys.slice(keys.indexOf("config"), keys.indexOf("sort") + 1),+ ["config", "pinDoc", "unpinDoc", "sort"]);+ for (const key of ["pinDoc", "unpinDoc"]) {+ assert.equal(getEntryCatalogNode(`docTree.notebook.${key}`)?.simple, true);+ assert.equal(getEntryCatalogNode(`docTree.notebook.${key}`)?.type, "entry");+ }+});+test("document tree pin entries follow attributes and precede sorting", () => {const keys = getEntryCatalogChildren("docTree.document").map(item => item.key);assert.deepEqual(keys.slice(keys.indexOf("attr"), keys.indexOf("sort") + 1), ["attr", "pinDoc", "unpinDoc", "sort"]);diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.tsindex c0ab73ae90..3928ae107d 100644--- a/app/src/config/entryVisibility/catalog.ts+++ b/app/src/config/entryVisibility/catalog.ts@@ -687,6 +687,8 @@ export const entryCatalog: IEntryCatalogSection[] = [node("openDocument", lang("openDocument")),node("rename", lang("rename")),node("config", lang("config")),+ node("pinDoc", lang("pinDoc")),+ node("unpinDoc", lang("unpinDoc")),node("sort", lang("sort"), true, sortChildren("sortByFiletree")),node("riffCard", lang("riffCard"), false),node("search", lang("search")),diff --git a/app/src/config/entryVisibility/order.test.ts b/app/src/config/entryVisibility/order.test.tsindex 45d6725623..cbebfeeb77 100644--- a/app/src/config/entryVisibility/order.test.ts+++ b/app/src/config/entryVisibility/order.test.ts@@ -40,6 +40,19 @@ test("pin entries merge into document menus without moving existing plugin slotsassert.deepEqual(resolveEntryOrder([...defaults, "plugin:example:item"], merged, separators), merged);});+test("notebook pin actions merge into saved menus and preserve plugin slots", () => {+ const entries = getEntryCatalogChildren("docTree.notebook");+ const defaults = entries.map(item => item.key);+ const saved = defaults.filter(key => !["pinDoc", "unpinDoc"].includes(key));+ saved.splice(1, 0, "plugin:example:item");+ const merged = mergeEntryOrderPreservingUnknown(defaults, saved);+ assert.deepEqual(merged.filter(key => !["pinDoc", "unpinDoc"].includes(key)), saved);+ assert.deepEqual(merged.slice(merged.indexOf("config"), merged.indexOf("sort") + 1),+ ["config", "pinDoc", "unpinDoc", "sort"]);+ const separators = new Set(entries.filter(item => item.type === "separator").map(item => item.key));+ assert.deepEqual(resolveEntryOrder([...defaults, "plugin:example:item"], merged, separators), merged);+});+test("removed pinned area switch is not rendered while plugin slots are preserved", () => {const entries = getEntryCatalogChildren("docTree.panel");const defaults = entries.map(item => item.key);diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex 76987f8eff..908f3e8891 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -487,6 +487,16 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {});}}).element);+ if (window.siyuan.config.fileTree.boxDocEnabled && liElement.getAttribute("data-node-id") &&+ !isEncryptedBox(notebookId)) {+ const pinned = pinnedDocIDs.has(notebookId);+ window.siyuan.menus.menu.append(new MenuItem({+ id: pinned ? "unpinDoc" : "pinDoc",+ icon: pinned ? "iconUnpin" : "iconPin",+ label: pinned ? window.siyuan.languages.unpinDoc : window.siyuan.languages.pinDoc,+ click: () => { updatePinnedDocs([notebookId], pinned ? "unpin" : "pin"); },+ }).element);+ }const subMenu = sortMenu("notebook", parseInt(liElement.parentElement.getAttribute("data-sortmode")), (sort) => {if (sort === null) {return;diff --git a/docs/PINNED-DOCUMENTS.md b/docs/PINNED-DOCUMENTS.mdindex a3e1e6f318..214c213bff 100644--- a/docs/PINNED-DOCUMENTS.md+++ b/docs/PINNED-DOCUMENTS.md@@ -15,6 +15,7 @@ The section appears when it contains pinned documents and hides automatically wh| Operation | Behavior ||---|---|| Pin from a menu | Insert the entry at the top; the same menu item becomes Unpin for an already pinned document |+| Notebook More menu | When notebook root documents are enabled, offer Pin or Unpin for an ordinary notebook's root document; expand the pinned entry to browse its visible top-level documents || Multiple selected documents | Offer both Pin and Unpin regardless of existing pin status; hide Pin if any selected document belongs to an encrypted notebook || Context menu or More on a pinned document | Open the document menu, including Unpin and Rename || Click a document icon | On desktop, open the icon picker or follow the configured icon expansion behavior; mobile expands or opens the document |diff --git a/docs/PINNED-DOCUMENTS.zh-CN.md b/docs/PINNED-DOCUMENTS.zh-CN.mdindex e218d357be..6f29e088aa 100644--- a/docs/PINNED-DOCUMENTS.zh-CN.md+++ b/docs/PINNED-DOCUMENTS.zh-CN.md@@ -16,6 +16,7 @@|---|---|| 菜单置顶 | 新入口放在最顶部;已置顶时同一菜单项切换为取消置顶 || 多选文档 | 同时提供置顶和取消置顶,不区分是否已置顶;包含加密笔记本文档时不提供置顶 |+| 笔记本更多菜单 | 启用笔记本顶级文档后,普通笔记本提供置顶或取消置顶;置顶入口展开后显示该笔记本的可见顶层文档 || 置顶文档右键或更多 | 打开文档菜单,支持取消置顶、重命名等操作 || 点击文档图标 | 桌面端打开图标选择器,或遵循已配置的图标展开行为;移动端展开或打开文档 || 根层插入线拖放 | 创建或调整置顶入口,源文档位置不变 |