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: Support pinning and unpinning multiple documents https://github.com/siyuan-note/siyuan/issues/19401
Daniel09276bd269bf
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.tsindex 4be66eeacd..394fe92dc2 100644--- a/app/src/config/entryVisibility/catalog.test.ts+++ b/app/src/config/entryVisibility/catalog.test.ts@@ -883,6 +883,16 @@ test("multiple document and notebook entries follow their document tree menus",assert.ok(getEntryCatalogChildren("docTree.multi").some((item) => item.key === "delete"));});+test("document multi-selection includes both pin actions before the existing separator", () => {+ const keys = getEntryCatalogChildren("docTree.multi").map(item => item.key);+ assert.deepEqual(keys.slice(keys.indexOf("delete"), keys.indexOf("separator_1") + 1),+ ["delete", "pinDoc", "unpinDoc", "separator_1"]);+ for (const key of ["pinDoc", "unpinDoc"]) {+ assert.equal(getEntryCatalogNode(`docTree.multi.${key}`)?.simple, true);+ assert.equal(getEntryCatalogDefaultVisibility(`docTree.multi.${key}`), true);+ }+});+test("pinned area has no configurable visibility switch", () => {assert.equal(getEntryCatalogNode("documentPanel.pinnedDocs"), undefined);assert.equal(getEntryCatalogNode("docTree.panel.pinnedDocs"), undefined);diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.tsindex ab93e0f9a3..c0ab73ae90 100644--- a/app/src/config/entryVisibility/catalog.ts+++ b/app/src/config/entryVisibility/catalog.ts@@ -189,7 +189,7 @@ const docTreeDocument = () => {const docTreeMultiple = () => {const [copy, move, addToDatabase, remove, riffCard, openBy, exportEntry] = docTreeCommon(true);- return [copy, move, addToDatabase, remove, separator("separator_1"), riffCard,+ return [copy, move, addToDatabase, remove, node("pinDoc", lang("pinDoc")), node("unpinDoc", lang("unpinDoc")), separator("separator_1"), riffCard,separator("separator_2"), openBy, exportEntry];};diff --git a/app/src/config/entryVisibility/order.test.ts b/app/src/config/entryVisibility/order.test.tsindex 4c32d896fc..45d6725623 100644--- a/app/src/config/entryVisibility/order.test.ts+++ b/app/src/config/entryVisibility/order.test.ts@@ -53,6 +53,20 @@ test("removed pinned area switch is not rendered while plugin slots are preserveassert.deepEqual(rendered, saved.filter(key => key !== "pinnedDocs"));});+test("multi-document pin actions merge without losing plugin slots or separators", () => {+ const entries = getEntryCatalogChildren("docTree.multi");+ const defaults = entries.map(item => item.key);+ const saved = defaults.filter(key => key !== "pinDoc" && key !== "unpinDoc");+ saved.splice(1, 0, "plugin:example:item");+ const merged = mergeEntryOrderPreservingUnknown(defaults, saved);+ const separators = new Set(entries.filter(item => item.type === "separator").map(item => item.key));+ const rendered = resolveEntryOrder([...defaults, "plugin:example:item"], merged, separators);+ assert.equal(rendered[1], "plugin:example:item");+ assert.deepEqual(rendered.slice(rendered.indexOf("delete"), rendered.indexOf("separator_1") + 1),+ ["delete", "pinDoc", "unpinDoc", "separator_1"]);+ assert.deepEqual(rendered.filter(key => key !== "pinDoc" && key !== "unpinDoc"), saved);+});+test("entry order ignores unknown and duplicate keys", () => {assert.deepEqual(mergeEntryOrder(["a", "b", "c"], ["missing", "c", "c", "a"]), ["c", "a", "b"]);});diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex aa5ed36dfb..a8540a82c2 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -298,6 +298,26 @@ const initMultiMenu = (selectItemElements: NodeListOf<HTMLElement>, app: App) =>if (blockIDs.length === 0) {return window.siyuan.menus.menu;}+ if (!window.siyuan.config.readonly) {+ const canPin = selectedItems.every(item => {+ const notebook = item.getAttribute("data-notebook") || item.closest("ul[data-url]")?.getAttribute("data-url");+ return notebook && !isEncryptedBox(notebook);+ });+ if (canPin) {+ window.siyuan.menus.menu.append(new MenuItem({+ id: "pinDoc",+ icon: "iconPin",+ label: window.siyuan.languages.pinDoc,+ click: () => { updatePinnedDocs(blockIDs, "pin"); },+ }).element);+ }+ window.siyuan.menus.menu.append(new MenuItem({+ id: "unpinDoc",+ icon: "iconUnpin",+ label: window.siyuan.languages.unpinDoc,+ click: () => { updatePinnedDocs(blockIDs, "unpin"); },+ }).element);+ }window.siyuan.menus.menu.append(new MenuItem({id: "separator_1", type: "separator"}).element);if (!window.siyuan.config.readonly && !isEncryptedBox(notebookId)) {const riffCardMenu = [{diff --git a/docs/PINNED-DOCUMENTS.md b/docs/PINNED-DOCUMENTS.mdindex a4812c33a4..1cb8e6522d 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 |+| 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 || Drop on a root insertion line | Create or reorder a pinned entry without moving the source document |diff --git a/docs/PINNED-DOCUMENTS.zh-CN.md b/docs/PINNED-DOCUMENTS.zh-CN.mdindex 406a0f6bab..2ae1a5c692 100644--- a/docs/PINNED-DOCUMENTS.zh-CN.md+++ b/docs/PINNED-DOCUMENTS.zh-CN.md@@ -15,6 +15,7 @@| 操作 | 行为 ||---|---|| 菜单置顶 | 新入口放在最顶部;已置顶时同一菜单项切换为取消置顶 |+| 多选文档 | 同时提供置顶和取消置顶,不区分是否已置顶;包含加密笔记本文档时不提供置顶 || 置顶文档右键或更多 | 打开文档菜单,支持取消置顶、重命名等操作 || 点击文档图标 | 桌面端打开图标选择器,或遵循已配置的图标展开行为;移动端展开或打开文档 || 根层插入线拖放 | 创建或调整置顶入口,源文档位置不变 |