feat(insert_note): add dedicated section for collections

This commit is contained in:
Elian Doran
2025-07-09 18:55:08 +03:00
parent fc4a595725
commit 035b72a08d
2 changed files with 22 additions and 2 deletions

View File

@@ -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(),

View File

@@ -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",