Skip to content

Build your personal knowledge base with Trilium Notes

feat(export/single): mermaid with right extension and MIME

Elian Doran16cbd2f793d9
diff --git a/src/services/export/single.spec.ts b/src/services/export/single.spec.ts
new file mode 100644
index 0000000000..cf9d391fc0
--- /dev/null
+++ b/src/services/export/single.spec.ts
@@ -0,0 +1,17 @@
+import { describe, expect, it } from "vitest";
+import BNote from "../../becca/entities/bnote.js";
+import { mapByNoteType } from "./single.js";
+
+describe("Note type mappings", () => {
+ it("supports mermaid note", () => {
+ const note = new BNote({
+ type: "mermaid",
+ title: "New note"
+ });
+
+ expect(mapByNoteType(note, "", "html")).toMatchObject({
+ extension: "mermaid",
+ mime: "text/vnd.mermaid"
+ });
+ });
+});
diff --git a/src/services/export/single.ts b/src/services/export/single.ts
index 18ea830364..b626bf9193 100644
--- a/src/services/export/single.ts
+++ b/src/services/export/single.ts
@@ -65,6 +65,10 @@ export function mapByNoteType(note: BNote, content: string | Buffer<ArrayBufferL
payload = content;
extension = "excalidraw";
mime = "application/json";
+ } else if (note.type === "mermaid") {
+ payload = content;
+ extension = "mermaid";
+ mime = "text/vnd.mermaid";
} else if (note.type === "relationMap" || note.type === "search") {
payload = content;
extension = "json";