Skip to content

Build your personal knowledge base with Trilium Notes

feat(notes): move the snippets into the insert menu's More submenu

Elian Doran9f9abec08ac2
diff --git a/apps/client/src/services/note_types.spec.ts b/apps/client/src/services/note_types.spec.ts
index f2d5c429a6..d1e92342c2 100644
--- a/apps/client/src/services/note_types.spec.ts
+++ b/apps/client/src/services/note_types.spec.ts
@@ -238,7 +238,7 @@ describe("getBuiltInTemplates", () => {
/** Every item, those in submenus included. */
const allItems = (items: any[]): any[] => items.flatMap((i) => [ i, ...allItems(i.items ?? []) ]);
const builtInSubmenus = (items: any[]) => items
- .filter((i) => i.title === "note_types.snippet" || i.title === "note_types.book")
+ .filter((i) => i.title === "note_types.book")
.map((i) => i.title);
it("warns and offers no built-in templates when the templates root is missing", async () => {
@@ -422,7 +422,7 @@ describe("new template badges", () => {
}
});
- it("puts the snippets in a submenu of the menu, and the AI quick action under More", async () => {
+ it("puts the snippets and the AI quick action under More, after its note types", async () => {
withTemplates();
const restore = withTemplatesRoot([
fakeTemplate("tpl-text-snippet", [ "template", "textSnippet" ], "Text snippet"),
@@ -435,18 +435,12 @@ describe("new template badges", () => {
const data = await noteTypesService.loadNoteTypeData();
const menu: any[] = noteTypesService.buildNoteTypeItems(data, "insertChildNote" as never);
- const submenu = menu.find((i) => i.title === "note_types.snippet");
- expect(submenu).toBeDefined();
- expect(submenu.command).toBeUndefined();
- expect(titles(submenu.items)).toEqual([ "tpl-text-snippet", "tpl-code-snippet" ]);
- expect(submenu.items.every((i: any) => i.command === "insertChildNote")).toBe(true);
- // Only in the submenu, and followed by no other group of built-in templates.
- expect(menu.some((i) => i.templateNoteId === "tpl-code-snippet")).toBe(false);
- // The AI quick action is configuration, created as rarely as the other entries of More.
- expect(titles(menu)).not.toContain("tpl-ai");
+ // Notes the text editor reads, created as rarely as the other entries of More.
+ expect(titles(menu).filter((title) => String(title).startsWith("tpl-"))).toEqual([]);
const more = menu.find((i) => i.title === "note_types.more");
// After the note types it holds, as the templates follow the note types everywhere in the menu.
- expect(titles(more.items).slice(-2)).toEqual([ "separator", "tpl-ai" ]);
+ expect(titles(more.items).slice(-4)).toEqual([ "separator", "tpl-text-snippet", "tpl-code-snippet", "tpl-ai" ]);
+ expect(more.items.slice(-3).every((i: any) => i.command === "insertChildNote")).toBe(true);
// Without the AI features, neither the chat nor the quick action is offered.
@@ -456,6 +450,7 @@ describe("new template badges", () => {
expect(withoutAiMenu.at(-1).title).toBe("note_types.more");
expect(withoutAi).not.toContain("llmChat");
expect(withoutAi).not.toContain("tpl-ai");
+ expect(withoutAi.slice(-3)).toEqual([ "separator", "tpl-text-snippet", "tpl-code-snippet" ]);
} finally {
restore();
}
@@ -493,7 +488,7 @@ describe("new template badges", () => {
}
});
- it("puts the rarely created note types in a More submenu of the menu, after the snippets and collections", async () => {
+ it("puts the rarely created note types in a More submenu of the menu, after the collections", async () => {
withTemplates();
const restore = withTemplatesRoot([
fakeTemplate("tpl-snippet", [ "template", "snippet" ], "Snippet"),
@@ -507,11 +502,11 @@ describe("new template badges", () => {
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(more.items.slice(0, rare.length).map((i: any) => i.type)).toEqual(rare);
+ expect(more.items.every((i: any) => i.kind === "separator" || 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" ]);
+ expect(submenus).toEqual([ "note_types.book", "note_types.more" ]);
} finally {
restore();
diff --git a/apps/client/src/services/note_types.ts b/apps/client/src/services/note_types.ts
index a3dc31da93..34dcdcd04b 100644
--- a/apps/client/src/services/note_types.ts
+++ b/apps/client/src/services/note_types.ts
@@ -221,9 +221,10 @@ async function loadNoteTypeData(): Promise<NoteTypeData> {
/**
* The menu of what a new note can be made from, as the note tree's insert menus and the note type
- * chooser offer it: the note types grouped by kind ({@link MENU_GROUPS}), the snippets, the
- * collections and the rarely created note types in submenus, then the user's templates. The AI
- * quick action template, offered only where AI is enabled, closes the "More" submenu.
+ * chooser offer it: the note types grouped by kind ({@link MENU_GROUPS}), the collections in a
+ * submenu, then the user's templates. The "More" submenu holds the rarely created note types, then
+ * the templates whose notes the text editor reads: the snippets and, where AI is enabled, the AI
+ * quick action.
*/
function buildNoteTypeItems(data: NoteTypeData, command?: TreeCommandNames) {
const { builtInTemplateNotes, userTemplateNotes, newTemplates } = data;
@@ -245,13 +246,14 @@ function buildNoteTypeItems(data: NoteTypeData, command?: TreeCommandNames) {
items.push(...groupItems);
}
- const snippets = builtIn("snippet");
const collections = builtIn("collection");
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 });
- const aiQuickActions = isExperimentalFeatureEnabled("llm") ? builtIn("aiQuickAction") : [];
- items.push({ title: t("note_types.more"), uiIcon: "bx bx-dots-horizontal-rounded", items: [ ...inGroup(MORE_GROUP), ...withLeading(SEPARATOR, aiQuickActions) ] });
+ const editorTemplates = [
+ ...builtIn("snippet"),
+ ...(isExperimentalFeatureEnabled("llm") ? builtIn("aiQuickAction") : [])
+ ];
+ items.push({ title: t("note_types.more"), uiIcon: "bx bx-dots-horizontal-rounded", items: [ ...inGroup(MORE_GROUP), ...withLeading(SEPARATOR, editorTemplates) ] });
items.push(...getUserTemplates(command, userTemplateNotes, newTemplates));
return items;
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 4d69174b47..ac6729160e 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2580,7 +2580,6 @@
"spreadsheet": "Spreadsheet",
"note-types": "Note types",
"built-in-templates": "Built-in templates",
- "snippet": "Snippet",
"more": "More"
},
"template_selection": {
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Snippets/Code Snippets.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Snippets/Code Snippets.html
index 742db0c7ac..acd582f10b 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Snippets/Code Snippets.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Snippets/Code Snippets.html
@@ -7,7 +7,7 @@
<ol>
<li>Right-click the note where you want to place the snippet.</li>
<li>Select <em>Insert child note</em>.</li>
- <li>Select <em>Snippet</em> → <em>Code snippet</em>.</li>
+ <li>Select <em>More</em> → <em>Code snippet</em>.</li>
</ol>
<p>Then simply type the desired code into the note and set the correct language
mode.</p>
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Snippets/Markdown Snippets.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Snippets/Markdown Snippets.html
index 85f47f152c..5ad0c35a53 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Snippets/Markdown Snippets.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Snippets/Markdown Snippets.html
@@ -8,7 +8,7 @@
<ol>
<li>Right-click the note where you want to place the snippet.</li>
<li>Select <em>Insert child note</em>.</li>
- <li>Select <em>Snippet</em> → <em>Markdown snippet</em>.</li>
+ <li>Select <em>More</em> → <em>Markdown snippet</em>.</li>
</ol>
<p>Then simply type the desired content into the note.</p>
<p>The note's title becomes the title of the snippet. Optionally, you can
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 9e21042527..e43c2d30ec 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
@@ -44,10 +44,10 @@
<li><strong>Insert note after</strong>
<ul>
<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, and the note
- types created less often in the <em>More</em> submenu.</li>
+ <li><a class="reference-link" href="#root/_help_GTwFsgaA0lCt">Collections</a> are
+ grouped in the <em>Collection</em> submenu. The note types created less often,
+ the&nbsp;<a class="reference-link" href="#root/_help_B2ORr7OVEZtc">Snippets</a> and
+ the AI quick action are 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>To find an entry quickly, type into the search box at the top of the submenu,
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Text Snippets.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Text Snippets.html
index 0ff26a4855..310cc3ca7e 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Text Snippets.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/Text Snippets.html
@@ -10,7 +10,7 @@
<ol>
<li>Right click a note where to place the text snippet.</li>
<li>Select <em>Insert child note</em>.</li>
- <li>Select <em>Snippet</em> → <em>Text snippet</em>.</li>
+ <li>Select <em>More</em> → <em>Text snippet</em>.</li>
</ol>
<p>Afterwards, simply type in the content of the note the desired text. The
text can be formatted in the same manner as a normal text note.</p>
diff --git a/docs/User Guide/User Guide/Advanced Usage/Snippets/Code Snippets.md b/docs/User Guide/User Guide/Advanced Usage/Snippets/Code Snippets.md
index 67b18173b8..f546c3fd98 100644
--- a/docs/User Guide/User Guide/Advanced Usage/Snippets/Code Snippets.md
+++ b/docs/User Guide/User Guide/Advanced Usage/Snippets/Code Snippets.md
@@ -7,7 +7,7 @@ In the <a class="reference-link" href="../../Basic%20Concepts%20and%20Features/
1. Right-click the note where you want to place the snippet.
2. Select _Insert child note_.
-3. Select _Snippet_ → _Code snippet_.
+3. Select _More_ → _Code snippet_.
Then simply type the desired code into the note and set the correct language mode.
diff --git a/docs/User Guide/User Guide/Advanced Usage/Snippets/Markdown Snippets.md b/docs/User Guide/User Guide/Advanced Usage/Snippets/Markdown Snippets.md
index 391ea4b076..53a7d0b16a 100644
--- a/docs/User Guide/User Guide/Advanced Usage/Snippets/Markdown Snippets.md
+++ b/docs/User Guide/User Guide/Advanced Usage/Snippets/Markdown Snippets.md
@@ -7,7 +7,7 @@ In the <a class="reference-link" href="../../Basic%20Concepts%20and%20Features/
1. Right-click the note where you want to place the snippet.
2. Select _Insert child note_.
-3. Select _Snippet_ → _Markdown snippet_.
+3. Select _More_ → _Markdown snippet_.
Then simply type the desired content into the note.
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 e4d4841e0c..9ad38bb96a 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, and the note types created less often in the _More_ submenu.
+ * <a class="reference-link" href="../../../Collections.md">Collections</a> are grouped in the _Collection_ submenu. The note types created less often, the <a class="reference-link" href="../../../Advanced%20Usage/Snippets.md">Snippets</a> and the AI quick action are 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.
* To find an entry quickly, type into the search box at the top of the submenu, or just start typing while the submenu is open. The submenu then lists every matching entry, including those inside its own submenus (such as a code language or a collection), each with the submenu it comes from. Use <kbd>↑</kbd> and <kbd>↓</kbd> to pick a match, <kbd>Enter</kbd> to create it, and <kbd>Esc</kbd> to clear the search.
* The note will be added on the same level of hierarchy as the note selected.
diff --git a/docs/User Guide/User Guide/Note Types/Text/Text Snippets.md b/docs/User Guide/User Guide/Note Types/Text/Text Snippets.md
index 4fbe31bd3c..c3fbdb6564 100644
--- a/docs/User Guide/User Guide/Note Types/Text/Text Snippets.md
+++ b/docs/User Guide/User Guide/Note Types/Text/Text Snippets.md
@@ -9,7 +9,7 @@ In the <a class="reference-link" href="../../Basic%20Concepts%20and%20Features/
1. Right click a note where to place the text snippet.
2. Select _Insert child note_.
-3. Select _Snippet_ → _Text snippet_.
+3. Select _More_ → _Text snippet_.
Afterwards, simply type in the content of the note the desired text. The text can be formatted in the same manner as a normal text note.