mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 11:56:01 +01:00 
			
		
		
		
	feat(export/single): mermaid with right extension and MIME
This commit is contained in:
		
							
								
								
									
										17
									
								
								src/services/export/single.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/services/export/single.spec.ts
									
									
									
									
									
										Normal file
									
								
							@@ -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"
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
@@ -65,6 +65,10 @@ export function mapByNoteType(note: BNote, content: string | Buffer<ArrayBufferL
 | 
				
			|||||||
        payload = content;
 | 
					        payload = content;
 | 
				
			||||||
        extension = "excalidraw";
 | 
					        extension = "excalidraw";
 | 
				
			||||||
        mime = "application/json";
 | 
					        mime = "application/json";
 | 
				
			||||||
 | 
					    } else if (note.type === "mermaid") {
 | 
				
			||||||
 | 
					        payload = content;
 | 
				
			||||||
 | 
					        extension = "mermaid";
 | 
				
			||||||
 | 
					        mime = "text/vnd.mermaid";
 | 
				
			||||||
    } else if (note.type === "relationMap" || note.type === "search") {
 | 
					    } else if (note.type === "relationMap" || note.type === "search") {
 | 
				
			||||||
        payload = content;
 | 
					        payload = content;
 | 
				
			||||||
        extension = "json";
 | 
					        extension = "json";
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user