Skip to content

Build your personal knowledge base with Trilium Notes

feat(tree): move the rarely created note types into a More submenu

Elian Doranb71b896a7062
diff --git a/apps/client/src/services/note_types.spec.ts b/apps/client/src/services/note_types.spec.ts
index 94c69d5407..3039a6e209 100644
--- a/apps/client/src/services/note_types.spec.ts
+++ b/apps/client/src/services/note_types.spec.ts
@@ -480,6 +480,35 @@ describe("new template badges", () => {
}
});
+ it("puts the rarely created note types in a More submenu of the menu, after the snippets and collections", async () => {
+ withTemplates();
+ const restore = withTemplatesRoot([
+ fakeTemplate("tpl-snippet", [ "template", "snippet" ], "Snippet"),
+ fakeTemplate("tpl-coll", [ "template", "collection" ], "Coll")
+ ]);
+ const rare = [ "noteMap", "render", "search", "webView" ];
+ try {
+ const data = await noteTypesService.loadNoteTypeData();
+ const menu: any[] = noteTypesService.buildNoteTypeItems(data, "insertNoteAfter" as never);
+
+ const more = menu.find((i) => i.title === "note_types.more");
+ expect(more).toBeDefined();
+ expect(more.command).toBeUndefined();
+ expect(more.items.map((i: any) => i.type)).toEqual(rare);
+ expect(more.items.every((i: any) => i.command === "insertNoteAfter")).toBe(true);
+ expect(menu.some((i) => rare.includes(i.type))).toBe(false);
+ const submenus = menu.filter((i) => i.items && i.type === undefined).map((i) => i.title);
+ expect(submenus).toEqual([ "note_types.snippet", "note_types.book", "note_types.more" ]);
+
+ // The chooser's flat list keeps them inline.
+ const list: any[] = await noteTypesService.getNoteTypeItems();
+ expect(rare.every((type) => list.some((i) => i.type === type))).toBe(true);
+ expect(list.some((i) => i.title === "note_types.more")).toBe(false);
+ } finally {
+ restore();
+ }
+ });
+
it("escapes template titles for the menu, which renders HTML, and not for the list, which renders text", async () => {
const user = buildNote({ id: "userTemplateHtml", title: "<img src=x onerror=alert(1)>", "#template": "" });
withTemplates([ user.noteId ]);
diff --git a/apps/client/src/services/note_types.ts b/apps/client/src/services/note_types.ts
index e6140ec62d..092338bee0 100644
--- a/apps/client/src/services/note_types.ts
+++ b/apps/client/src/services/note_types.ts
@@ -222,8 +222,9 @@ async function loadNoteTypeData(): Promise<NoteTypeData> {
type NoteTypeLayout = "menu" | "list";
/**
- * The note type items. In a `"menu"` the snippets and the collections each form a submenu; a
- * `"list"`, such as the note type chooser draws, cannot open one, so there they stay inline. The AI
+ * The note type items. In a `"menu"` the snippets, the collections and the rarely created note
+ * types ({@link MORE_NOTE_TYPES}) each form a submenu; a `"list"`, such as the note type chooser
+ * draws, cannot open one, so there they stay inline. The AI
* quick action template stands beside the AI chat note type, and is offered only alongside it.
*/
function buildNoteTypeItems(data: NoteTypeData, command?: TreeCommandNames, layout: NoteTypeLayout = "menu") {
@@ -234,7 +235,12 @@ function buildNoteTypeItems(data: NoteTypeData, command?: TreeCommandNames, layo
const collections = builtIn("collection");
const items: MenuItem<TreeCommandNames>[] = [];
+ const more: MenuItem<TreeCommandNames>[] = [];
for (const blankType of getBlankNoteTypes(command)) {
+ if (layout === "menu" && "type" in blankType && blankType.type && MORE_NOTE_TYPES.has(blankType.type)) {
+ more.push(blankType);
+ continue;
+ }
if (layout === "menu" && "mime" in blankType && blankType.type === "code" && blankType.mime === "text/plain") {
blankType.items = getCodeLanguageItems(command);
}
@@ -246,16 +252,19 @@ function buildNoteTypeItems(data: NoteTypeData, command?: TreeCommandNames, layo
items.push(...withLeading(SEPARATOR, [ ...snippets, ...builtIn("other") ]));
items.push(...withLeading({ title: t("note_types.collections"), kind: "header" }, collections));
} else {
- items.push(...withLeading(SEPARATOR, builtIn("other")));
- if (snippets.length > 0 || collections.length > 0) items.push(SEPARATOR);
+ items.push(...withLeading(SEPARATOR, builtIn("other")), SEPARATOR);
if (snippets.length > 0) items.push({ title: t("note_types.snippet"), uiIcon: "bx bx-align-left", items: snippets });
if (collections.length > 0) items.push({ title: t("note_types.book"), uiIcon: "bx bx-book", items: collections });
+ items.push({ title: t("note_types.more"), uiIcon: "bx bx-dots-horizontal-rounded", items: more });
}
items.push(...getUserTemplates(command, userTemplateNotes, newTemplates, layout));
return items;
}
+/** The note types created rarely enough that the menus offer them from a "More" submenu. */
+const MORE_NOTE_TYPES = new Set<string>([ "noteMap", "render", "search", "webView" ]);
+
/** Builds the note type list of the note type chooser. Use {@link loadNoteTypeData} directly to build several. */
async function getNoteTypeItems(command?: TreeCommandNames) {
return buildNoteTypeItems(await loadNoteTypeData(), command, "list");
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 6302b724aa..8a5ec2e44d 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2582,7 +2582,8 @@
"spreadsheet": "Spreadsheet",
"note-types": "Note types",
"built-in-templates": "Built-in templates",
- "snippet": "Snippet"
+ "snippet": "Snippet",
+ "more": "More"
},
"template_selection": {
"add-existing": "Add existing template",
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree/Note tree contextual menu.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree/Note tree contextual menu.html
index 74497715eb..617705857a 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree/Note tree contextual menu.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree/Note tree contextual menu.html
@@ -46,7 +46,8 @@
<li>Allows easy creation of a note with a specified <a href="#root/_help_KSZ04uQ2D1St">note type</a>.</li>
<li><a class="reference-link" href="#root/_help_B2ORr7OVEZtc">Snippets</a> and&nbsp;<a
class="reference-link" href="#root/_help_GTwFsgaA0lCt">Collections</a> are
- grouped in the <em>Snippet</em> and <em>Collection</em> submenus.</li>
+ grouped in the <em>Snippet</em> and <em>Collection</em> submenus, and the note
+ types created less often in the <em>More</em> submenu.</li>
<li><a class="reference-link" href="#root/_help_KC1HB96bqqHX">Templates</a>&nbsp;will
also be present (if any) at the end of the list.</li>
<li>The note will be added on the same level of hierarchy as the note selected.</li>
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types.html
index c4d93c2734..5e3ffffc67 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types.html
@@ -12,6 +12,11 @@
<li><em>Insert child note</em>, to insert the note as a child of the selected
note.</li>
</ul>
+<p>The note types created less often, <a class="reference-link" href="#root/_help_m523cpzocqaD">Saved Search</a>,&nbsp;<a
+ class="reference-link" href="#root/_help_HcABDtFCkbFN">Render Note</a>,&nbsp;<a
+ class="reference-link" href="#root/_help_1vHRoWCEjj0L">Web View</a> and&nbsp;<a
+ class="reference-link" href="#root/_help_bdUJEHsAPYQR">Note Map</a>, are
+ in the <em>More</em> submenu.</p>
<p>
<img src="Note Types_image.png">
</p>
diff --git a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree/Note tree contextual menu.md b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree/Note tree contextual menu.md
index f4ef0d6ea3..4545cfd978 100644
--- a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree/Note tree contextual menu.md
+++ b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree/Note tree contextual menu.md
@@ -24,7 +24,7 @@ The contextual menu can operate:
* Will focus the note tree on this note. See <a class="reference-link" href="../../Navigation/Note%20Hoisting.md">Note Hoisting</a> for more information.
* **Insert note after**
* Allows easy creation of a note with a specified [note type](../../../Note%20Types.md).
- * <a class="reference-link" href="../../../Advanced%20Usage/Snippets.md">Snippets</a> and <a class="reference-link" href="../../../Collections.md">Collections</a> are grouped in the _Snippet_ and _Collection_ submenus.
+ * <a class="reference-link" href="../../../Advanced%20Usage/Snippets.md">Snippets</a> and <a class="reference-link" href="../../../Collections.md">Collections</a> are grouped in the _Snippet_ and _Collection_ submenus, and the note types created less often in the _More_ submenu.
* <a class="reference-link" href="../../../Advanced%20Usage/Templates.md">Templates</a> will also be present (if any) at the end of the list.
* The note will be added on the same level of hierarchy as the note selected.
* **Insert child note**
diff --git a/docs/User Guide/User Guide/Note Types.md b/docs/User Guide/User Guide/Note Types.md
index fc3612024a..1a7cb892c2 100644
--- a/docs/User Guide/User Guide/Note Types.md
+++ b/docs/User Guide/User Guide/Note Types.md
@@ -10,6 +10,8 @@ To create a new note of a different type, head to the <a class="reference-link"
* _Insert note after_, to put the new note underneath the one selected.
* _Insert child note_, to insert the note as a child of the selected note.
+The note types created less often, <a class="reference-link" href="Note%20Types/Saved%20Search.md">Saved Search</a>, <a class="reference-link" href="Note%20Types/Render%20Note.md">Render Note</a>, <a class="reference-link" href="Note%20Types/Web%20View.md">Web View</a> and <a class="reference-link" href="Note%20Types/Note%20Map.md">Note Map</a>, are in the _More_ submenu.
+
![](Note%20Types_image.png)
## Creating a new note of a different type via add link or new tab