Skip to content

Build your personal knowledge base with Trilium Notes

feat(insert_note): add dedicated section for collections

Elian Doran035b72a08d41
diff --git a/apps/client/src/services/note_types.ts b/apps/client/src/services/note_types.ts
index 9f566f4879..b2da7f76af 100644
--- a/apps/client/src/services/note_types.ts
+++ b/apps/client/src/services/note_types.ts
@@ -81,7 +81,8 @@ let rootCreationDate: Date | undefined;
async function getNoteTypeItems(command?: TreeCommandNames) {
const items: MenuItem<TreeCommandNames>[] = [
...getBlankNoteTypes(command),
- ...await getBuiltInTemplates(command),
+ ...await getBuiltInTemplates("Collections", command, true),
+ ...await getBuiltInTemplates(null, command, false),
...await getUserTemplates(command)
];
@@ -139,7 +140,7 @@ async function getUserTemplates(command?: TreeCommandNames) {
return items;
}
-async function getBuiltInTemplates(command?: TreeCommandNames) {
+async function getBuiltInTemplates(title: string | null, command: TreeCommandNames | undefined, filterCollections: boolean) {
const templatesRoot = await froca.getNote("_templates");
if (!templatesRoot) {
console.warn("Unable to find template root.");
@@ -155,7 +156,18 @@ async function getBuiltInTemplates(command?: TreeCommandNames) {
SEPARATOR
];
+ if (title) {
+ items.push({
+ title: title,
+ enabled: false
+ });
+ }
+
for (const templateNote of childNotes) {
+ if (templateNote.hasLabel("collection") !== filterCollections) {
+ continue;
+ }
+
const item: MenuItem<TreeCommandNames> = {
title: templateNote.title,
uiIcon: templateNote.getIcon(),
diff --git a/apps/server/src/services/hidden_subtree_templates.ts b/apps/server/src/services/hidden_subtree_templates.ts
index cfe61922ce..fa8d146e2c 100644
--- a/apps/server/src/services/hidden_subtree_templates.ts
+++ b/apps/server/src/services/hidden_subtree_templates.ts
@@ -37,6 +37,10 @@ export default function buildHiddenSubtreeTemplates() {
name: "template",
type: "label"
},
+ {
+ name: "collection",
+ type: "label"
+ },
{
name: "viewType",
type: "label",
@@ -54,6 +58,10 @@ export default function buildHiddenSubtreeTemplates() {
name: "template",
type: "label"
},
+ {
+ name: "collection",
+ type: "label"
+ },
{
name: "viewType",
type: "label",