An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Unify tab block menu selection indicators https://github.com/siyuan-note/siyuan/issues/17642
Daniel32eb060183c9
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.tsindex ac0d1c4e09..437ec59113 100644--- a/app/src/config/entryVisibility/catalog.test.ts+++ b/app/src/config/entryVisibility/catalog.test.ts@@ -722,7 +722,7 @@ test("list block submenu follows the base block entries", () => {test("tabs layout and task actions have their own configurable block menu", () => {assert.deepEqual(getEntryCatalogChildren("gutter.single.tabs").map(item => item.key), [- "tabsPositionTop", "tabsPositionLeft", "tabsTask",+ "tabsPositionTop", "tabsPositionLeft", "separator_tabsTask", "tabsTask",]);const keys = getEntryCatalogChildren("gutter.single").map(item => item.key);const index = keys.indexOf("tabs");@@ -732,10 +732,13 @@ test("tabs layout and task actions have their own configurable block menu", () =assert.equal(getEntryCatalogNode("gutter.single.tabs")?.simple, true);assert.equal(getEntryCatalogNode("gutter.single.tabs.tabsTask")?.simple, true);assert.equal(getEntryCatalogNode("gutter.single.tabs.tabsTask")?.type, "entry");+ assert.equal(getEntryCatalogNode("gutter.single.tabs.separator_tabsTask")?.type, "separator");const source = readFileSync(resolve(process.cwd(), "src/protyle/gutter/index.ts"), "utf8");const submenu = source.slice(source.indexOf('id: "tabsPositionTop"'), source.indexOf('} else if (type === "NodeSuperBlock" && !protyle.disabled)'));assert.deepEqual(Array.from(submenu.matchAll(/id: "([^"]+)"/g), match => match[1]),getEntryCatalogChildren("gutter.single.tabs").map(item => item.key));+ assert.equal(Array.from(submenu.matchAll(/checked:/g)).length, 3);+ assert.doesNotMatch(submenu, /iconSelect/);assert.equal(getEntryCatalogNode("gutter.single.separator_tabs")?.type, "separator");});diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.tsindex 6be3b3cd22..e4c5f3e269 100644--- a/app/src/config/entryVisibility/catalog.ts+++ b/app/src/config/entryVisibility/catalog.ts@@ -368,6 +368,7 @@ const gutterSingle = () => [node("tabs", lang("tabs"), true, [node("tabsPositionTop", lang("tabsPositionTop")),node("tabsPositionLeft", lang("tabsPositionLeft")),+ separator("separator_tabsTask"),node("tabsTask", lang("task")),]),separator("separator_cancelSuperBlock"),diff --git a/app/src/config/entryVisibility/order.test.ts b/app/src/config/entryVisibility/order.test.tsindex 361e5d3fae..ae069abc2e 100644--- a/app/src/config/entryVisibility/order.test.ts+++ b/app/src/config/entryVisibility/order.test.ts@@ -35,9 +35,22 @@ test("entry order ignores unknown and duplicate keys", () => {test("tab task action merges into saved layout menus while preserving plugin slots", () => {const defaults = getEntryCatalogChildren("gutter.single.tabs").map(item => item.key);const saved = ["tabsPositionLeft", "plugin:example:item", "tabsPositionTop"];- const merged = mergeEntryOrderPreservingUnknown(defaults, saved);- assert.deepEqual(merged.filter(key => key !== "tabsTask"), saved);- assert.deepEqual(merged, ["tabsPositionLeft", "plugin:example:item", "tabsTask", "tabsPositionTop"]);+ const separators = new Set(["separator_tabsTask"]);+ const merged = mergeEntryOrderPreservingUnknown(defaults, saved, undefined, separators);+ assert.deepEqual(merged.filter(key => key !== "tabsTask" && key !== "separator_tabsTask"), saved);+ assert.deepEqual(merged, ["tabsPositionLeft", "plugin:example:item", "separator_tabsTask", "tabsTask", "tabsPositionTop"]);+ assert.deepEqual(resolveEntryOrder(merged, merged, separators), merged);+});++test("tab task separator merges into existing task menus with valid placement", () => {+ const defaults = getEntryCatalogChildren("gutter.single.tabs").map(item => item.key);+ const separators = new Set(["separator_tabsTask"]);+ const merged = mergeEntryOrderPreservingUnknown(defaults,+ ["tabsPositionTop", "plugin:example:item", "tabsPositionLeft", "tabsTask"], undefined, separators);+ assert.deepEqual(merged.filter(key => key !== "separator_tabsTask"),+ ["tabsPositionTop", "plugin:example:item", "tabsPositionLeft", "tabsTask"]);+ assert.notEqual(merged[0], "separator_tabsTask");+ assert.notEqual(merged[merged.length - 1], "separator_tabsTask");});test("tab conversion merges into saved block menus without moving plugin slots", () => {diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 02e1766185..4ba5d0a7fc 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -2174,13 +2174,16 @@ export class Gutter {submenu: [{id: "tabsPositionTop",label: window.siyuan.languages.tabsPositionTop,- icon: (nodeElement.getAttribute("tabs-position") || "top") === "top" ? "iconSelect" : undefined,+ checked: (nodeElement.getAttribute("tabs-position") || "top") === "top",click: () => setTabsPosition(protyle, nodeElement as HTMLElement, "top"),}, {id: "tabsPositionLeft",label: window.siyuan.languages.tabsPositionLeft,- icon: nodeElement.getAttribute("tabs-position") === "left" ? "iconSelect" : undefined,+ checked: nodeElement.getAttribute("tabs-position") === "left",click: () => setTabsPosition(protyle, nodeElement as HTMLElement, "left"),+ }, {+ id: "separator_tabsTask",+ type: "separator",}, {id: "tabsTask",label: window.siyuan.languages.task,