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
fix(export): export a single mind map note as .json instead of .dat
Swastik Tripathi0743ead24daf
diff --git a/packages/trilium-core/src/services/export/single.spec.ts b/packages/trilium-core/src/services/export/single.spec.tsindex b32fe8dd7b..2a52740e20 100644--- a/packages/trilium-core/src/services/export/single.spec.ts+++ b/packages/trilium-core/src/services/export/single.spec.ts@@ -82,8 +82,20 @@ describe("Note type mappings", () => {expect(result.payload).toBe(content);});+ it("exports mind map notes as their JSON content with a .json extension", () => {+ const content = JSON.stringify({ nodeData: { id: "root", topic: "Root", children: [] } });+ const note = buildNote({ type: "mindMap", mime: "application/json", title: "Mind map" });+ for (const format of [ "html", "markdown" ] as ExportFormat[]) {+ expect(mapByNoteType(note, content, format)).toMatchObject({+ payload: content,+ extension: "json",+ mime: "application/json"+ });+ }+ });+it("falls back to a raw .dat dump for note types without a dedicated mapping", () => {- // book/webView/mindMap/… aren't handled explicitly; rather than a zero-byte `.undefined`, they+ // book/webView/… aren't handled explicitly; rather than a zero-byte `.undefined`, they// export their raw content with a generic extension (mirrors the zip export's `dat` fallback).const note = buildNote({ type: "book", mime: "", title: "My book" });expect(mapByNoteType(note, "raw contents", "html")).toMatchObject({diff --git a/packages/trilium-core/src/services/export/single.ts b/packages/trilium-core/src/services/export/single.tsindex d6586738ca..5bc36f8098 100644--- a/packages/trilium-core/src/services/export/single.ts+++ b/packages/trilium-core/src/services/export/single.ts@@ -112,7 +112,7 @@ export function mapByNoteType(note: BNote, content: string | Uint8Array, format:payload = content;extension = "triliumsheet";mime = "application/json";- } else if (note.type === "relationMap" || note.type === "search") {+ } else if (note.type === "relationMap" || note.type === "search" || note.type === "mindMap") {payload = content;extension = "json";mime = "application/json";