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: Align configurable menu catalog with menu declarations https://github.com/siyuan-note/siyuan/issues/19441
Daniel05aba591dddc
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.tsindex fd402dccb9..c9d1bb834d 100644--- a/app/src/config/entryVisibility/catalog.test.ts+++ b/app/src/config/entryVisibility/catalog.test.ts@@ -798,13 +798,55 @@ test("super block column insertion actions follow block insertion actions", () =});test("table block width actions keep current-column and whole-table scopes together", () => {- assert.deepEqual(getEntryCatalogChildren("gutter.single.table").slice(0, 3).map((item) => item.key), [+ assert.deepEqual(getEntryCatalogChildren("gutter.single.table").slice(1, 4).map((item) => item.key), ["useDefaultWidth","distributeAllColWidths","useDefaultWidthForAllColumns",]);});+test("table catalog follows the menu arrays and conditional declarations", () => {+ const source = readFileSync(resolve(process.cwd(), "src/menus/protyle.ts"), "utf8");+ const table = source.slice(source.indexOf("export const tableMenu ="));+ const pushedIDs = (array: string) => Array.from(table.matchAll(+ new RegExp(`${array}\\.push\\(\\{\\s*id: ("[^" ]+"|isPinHead \\? "unpinTableHead" : "pinTableHead")`, "g"),+ )).flatMap(match => match[1].startsWith("isPinHead")+ ? ["pinTableHead", "unpinTableHead"] : [JSON.parse(match[1])]);+ const other = pushedIDs("otherMenus");+ const moves = pushedIDs("other2Menus");+ const inserts = pushedIDs("insertMenus");+ const removes = pushedIDs("removeMenus");+ assert.deepEqual(getEntryCatalogChildren("gutter.single.table").map(item => item.key), [+ ...other, "separator_insert", ...inserts, ...moves, "separator_delete", ...removes,+ ]);+ const alignment = table.slice(table.indexOf("const alignmentMenus"), table.indexOf("if (alignWholeTable)", table.indexOf("const alignmentMenus")));+ const alignmentIDs = Array.from(alignment.matchAll(/id: "([^"]+)"/g), match => match[1]);+ assert.deepEqual(getEntryCatalogChildren("inline.text.more").map(item => item.key), [+ ...other.filter(id => !["distributeAllColWidths", "useDefaultWidthForAllColumns", "transposeTable", "alignment"].includes(id)),+ ...alignmentIDs, ...moves,+ ]);+ [...inserts, ...removes].forEach(id => assert.ok(getEntryCatalogNode(`inline.text.${id}`)));+ assert.match(source, /submenu: tableMenus\.otherMenus\.concat\(tableMenus\.other2Menus\)/);+});++test("conditional copy and image actions have configuration entries in menu order", () => {+ const common = ["copyBlockRef", "copyBlockEmbed", "copyProtocol", "copyProtocolInMd", "copyWebURL", "copyHPath"];+ assert.deepEqual(getEntryCatalogChildren("gutter.multi.copy").map(item => item.key), [+ ...common, "copyID", "copyText", "copyRichText", "copyPlainText", "copy", "duplicate",+ ]);+ assert.deepEqual(getEntryCatalogChildren("gutter.single.copy").map(item => item.key), [+ ...common, "copyAVID", "copyID", "copyText", "copyRichText", "copyPlainText", "copyAsPNG",+ "copyMirror", "copy", "duplicate", "duplicateMirror", "duplicateCompletely",+ ]);+ const image = getEntryCatalogChildren("inline.image").map(item => item.key);+ assert.deepEqual(image.slice(image.indexOf("separator_3")), ["separator_3", "openBy", "export", "copyFile", "copyAsPNG"]);+ ["gutter.single.table.cancelMerged", "gutter.single.table.transposeTable", "inline.text.more.cancelMerged",+ "gutter.single.copy.copyMirror", "inline.image.openBy"].forEach(path => {+ assert.equal(getEntryCatalogNode(path).type, "entry");+ assert.equal(getEntryCatalogNode(path).simple, true);+ });+});+test("code block actions follow the code block menu order", () => {assert.deepEqual(getEntryCatalogChildren("gutter.single.code").map((item) => item.key), ["md29",diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.tsindex 3928ae107d..c9f9fda91d 100644--- a/app/src/config/entryVisibility/catalog.ts+++ b/app/src/config/entryVisibility/catalog.ts@@ -193,17 +193,21 @@ const docTreeMultiple = () => {separator("separator_2"), openBy, exportEntry];};-const gutterCopyChildren = (includeCopyAsPNG = false) => [- ...copyChildren(),+const gutterCopyChildren = (single = false) => [+ ...copyChildren().slice(0, 6),+ ...(single ? [node("copyAVID", lang("copyAVID"))] : []),+ ...copyChildren().slice(6),+ node("copyText", lang("copyText")),node("copyRichText", lang("copyRichText")),node("copyPlainText", lang("copyPlainText")),- ...(includeCopyAsPNG ? [node("copyAsPNG", lang("copyAsPNG"))] : []),- node("copyText", lang("copyText")),+ ...(single ? [node("copyAsPNG", lang("copyAsPNG"))] : []),+ ...(single ? [node("copyMirror", lang("copyMirror"))] : []),node("copy", lang("copy")),- node("copyAVID", lang("copyAVID")),node("duplicate", lang("duplicateCopy")),- node("duplicateMirror", lang("duplicateMirror")),- node("duplicateCompletely", lang("duplicateCompletely")),+ ...(single ? [+ node("duplicateMirror", lang("duplicateMirror")),+ node("duplicateCompletely", lang("duplicateCompletely")),+ ] : []),];const gutterTurnInto = (multi: boolean) => node("turnInto", lang("turnInto"), true, [@@ -296,6 +300,7 @@ const gutterHeight = () => node("height", lang("height"), true, []);const gutterTable = () => node("table", lang("tableBlock"), true, [+ node("cancelMerged", lang("cancelMerged")),node("useDefaultWidth", lang("useDefaultWidth")),node("distributeAllColWidths", lang("distributeAllColWidths")),node("useDefaultWidthForAllColumns", lang("useDefaultWidthForAllColumns")),@@ -304,6 +309,7 @@ const gutterTable = () => node("table", lang("tableBlock"), true, [node("tableHeaderRow", lang("tableHeaderRow")),node("tableHeaderColumn", lang("tableHeaderColumn")),node("title", lang("title")),+ node("transposeTable", lang("transposeTable")),separator("separator_1"),node("alignment", lang("alignment"), true, [node("alignLeft", lang("alignLeft")),@@ -872,6 +878,7 @@ export const entryCatalog: IEntryCatalogSection[] = [node("deleteColumn", lang("delete-column")),separator("separator_3"),node("more", lang("more"), true, [+ node("cancelMerged", lang("cancelMerged")),node("useDefaultWidth", lang("useDefaultWidth")),node("pinTableHead", lang("pinTableHead")),node("unpinTableHead", lang("unpinTableHead")),@@ -883,19 +890,11 @@ export const entryCatalog: IEntryCatalogSection[] = [node("alignCenter", lang("alignCenter")),node("alignRight", lang("alignRight")),node("useDefaultAlign", lang("useDefaultAlign")),- separator("separator_insert"),- node("insertRowAbove", lang("insertRowAbove")),- node("insertRowBelow", lang("insertRowBelow")),- node("insertColumnLeft", lang("insertColumnLeft")),- node("insertColumnRight", lang("insertColumnRight")),separator("separator_2"),node("moveToUp", lang("moveToUp")),node("moveToDown", lang("moveToDown")),node("moveToLeft", lang("moveToLeft")),node("moveToRight", lang("moveToRight")),- separator("separator_delete"),- node("deleteRow", lang("delete-row")),- node("deleteColumn", lang("delete-column")),]),],},@@ -945,6 +944,7 @@ export const entryCatalog: IEntryCatalogSection[] = [node("default", lang("default")),]),separator("separator_3"),+ node("openBy", lang("openBy")),node("export", lang("export")),node("copyFile", lang("copyFile"), false),node("copyAsPNG", lang("copyAsPNG"), false),diff --git a/app/src/config/entryVisibility/order.test.ts b/app/src/config/entryVisibility/order.test.tsindex cbebfeeb77..690799cdeb 100644--- a/app/src/config/entryVisibility/order.test.ts+++ b/app/src/config/entryVisibility/order.test.ts@@ -14,6 +14,27 @@ test("entry order keeps custom order and inserts new entries by their default neassert.deepEqual(mergeEntryOrder(["a", "new", "b", "c"], ["c", "a", "b"]), ["c", "a", "new", "b"]);});+test("missing table and image actions merge into saved orders while preserving plugin slots", () => {+ [+ {path: "gutter.single.table", added: ["cancelMerged", "transposeTable"]},+ {path: "inline.text.more", added: ["cancelMerged"]},+ {path: "inline.image", added: ["openBy"]},+ {path: "gutter.single.copy", added: ["copyMirror"]},+ ].forEach(({path, added}) => {+ const entries = getEntryCatalogChildren(path);+ const defaults = entries.map(item => item.key);+ const saved = defaults.filter(key => !added.includes(key));+ saved.splice(2, 0, "plugin:example:item");+ const merged = mergeEntryOrderPreservingUnknown(defaults, saved);+ assert.equal(merged.indexOf("plugin:example:item"), saved.indexOf("plugin:example:item"));+ assert.deepEqual(merged.filter(key => !added.includes(key) && key !== "plugin:example:item"),+ saved.filter(key => key !== "plugin:example:item"));+ added.forEach(key => assert.ok(merged.includes(key)));+ 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("entry order inserts the code block Tab setting before the existing code options", () => {assert.deepEqual(mergeEntryOrder(["md29", "md31", "md2", "md27", "saveCodeBlockAsFile"],