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
feat(template): duplicate content for mermaid diagrams
Elian Doranc7b99adb6a1c
diff --git a/src/public/app/services/note_create.ts b/src/public/app/services/note_create.tsindex 47cf02bb6c..14299ba4f8 100644--- a/src/public/app/services/note_create.ts+++ b/src/public/app/services/note_create.ts@@ -62,7 +62,7 @@ async function createNote(parentNotePath: string | undefined, options: CreateNotconst parentNoteId = treeService.getNoteIdFromUrl(parentNotePath);- if (options.type === "mermaid" && !options.content) {+ if (options.type === "mermaid" && !options.content && !options.templateNoteId) {options.content = `graph TD;A-->B;A-->C;diff --git a/src/services/handlers.ts b/src/services/handlers.tsindex 2630e2519e..5c65c8a498 100644--- a/src/services/handlers.ts+++ b/src/services/handlers.ts@@ -102,7 +102,7 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>const content = note.getContent();if (- ["text", "code"].includes(note.type) &&+ ["text", "code", "mermaid"].includes(note.type) &&typeof content === "string" &&// if the note has already content we're not going to overwrite it with template's one(!content || content.trim().length === 0) &&