Skip to content

Build your personal knowledge base with Trilium Notes

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.ts
index 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: CreateNot
const 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.ts
index 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) &&