Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/collections/board/card templates: show the note type switcher in popup editor for blank templates
Adorian Doran73ad429b62df
diff --git a/apps/client/src/services/note_create.spec.ts b/apps/client/src/services/note_create.spec.tsindex 7d1b2a0cd1..91d2f6f897 100644--- a/apps/client/src/services/note_create.spec.ts+++ b/apps/client/src/services/note_create.spec.ts@@ -294,7 +294,10 @@ describe("createTemplateNote", () => {}),undefined);- expect(triggerCommand).toHaveBeenCalledWith("openInPopup", { noteIdOrPath: NOTE_ID });+ expect(triggerCommand).toHaveBeenCalledWith("openInPopup", {+ noteIdOrPath: NOTE_ID,+ showNoteTypeSwitcher: true+ });expect(result).toBe(childNote);});});diff --git a/apps/client/src/services/note_create.ts b/apps/client/src/services/note_create.tsindex 599c3f2255..702817cefd 100644--- a/apps/client/src/services/note_create.ts+++ b/apps/client/src/services/note_create.ts@@ -258,7 +258,11 @@ async function createTemplateNote(parentNoteId: string, title: string) {return undefined;}- appContext.triggerCommand("openInPopup", { noteIdOrPath: note.noteId });+ // Blank when it opens, so the editor offers the note types to make it one of instead.+ appContext.triggerCommand("openInPopup", {+ noteIdOrPath: note.noteId,+ showNoteTypeSwitcher: true+ });return note;}diff --git a/apps/client/src/widgets/react/TemplateSelectionCard.spec.tsx b/apps/client/src/widgets/react/TemplateSelectionCard.spec.tsxindex afed120a8d..492f92b9f6 100644--- a/apps/client/src/widgets/react/TemplateSelectionCard.spec.tsx+++ b/apps/client/src/widgets/react/TemplateSelectionCard.spec.tsx@@ -148,7 +148,8 @@ describe("TemplateSelectionCard", () => {const quick = items[0];if (!quick || !("handler" in quick)) throw new Error("expected a quick edit entry");quick.handler?.(quick, {} as never);- expect(command).toHaveBeenCalledWith("openInPopup", { noteIdOrPath: "mine" });+ expect(command)+ .toHaveBeenCalledWith("openInPopup", { noteIdOrPath: "mine", showNoteTypeSwitcher: true });});it("quick-edits and deletes from the keyboard", async () => {@@ -157,7 +158,8 @@ describe("TemplateSelectionCard", () => {await draw();press(segments()[1], " ");- expect(command).toHaveBeenCalledWith("openInPopup", { noteIdOrPath: "mine" });+ expect(command)+ .toHaveBeenCalledWith("openInPopup", { noteIdOrPath: "mine", showNoteTypeSwitcher: true });press(segments()[1], "Delete");await act(async () => { await Promise.resolve(); await Promise.resolve(); });diff --git a/apps/client/src/widgets/react/template_commands.ts b/apps/client/src/widgets/react/template_commands.tsindex ddaf12e647..cf7668c43c 100644--- a/apps/client/src/widgets/react/template_commands.ts+++ b/apps/client/src/widgets/react/template_commands.ts@@ -68,7 +68,8 @@ export function openTemplateMenu(/** Opens a template in the popup editor, which leaves whatever asked for it standing. */export function quickEdit(noteId: string) {- appContext.triggerCommand("openInPopup", { noteIdOrPath: noteId });+ // A template that has yet to be written can still become a note of another type.+ appContext.triggerCommand("openInPopup", { noteIdOrPath: noteId, showNoteTypeSwitcher: true });}/**