diff --git a/src/services/import/mime.spec.ts b/src/services/import/mime.spec.ts index 7281d31c2..5b04d0f2a 100644 --- a/src/services/import/mime.spec.ts +++ b/src/services/import/mime.spec.ts @@ -30,6 +30,10 @@ describe("#getMime", () => { "File extension ('.mermaid') that is defined in EXTENSION_TO_MIME", ["test.mermaid"], "text/vnd.mermaid" ], + [ + "File extension ('.mermaid') that is defined in EXTENSION_TO_MIME", + ["test.mmd"], "text/vnd.mermaid" + ], [ "File extension with inconsistent capitalization that is defined in EXTENSION_TO_MIME", diff --git a/src/services/import/mime.ts b/src/services/import/mime.ts index cb400b8d8..5f050184f 100644 --- a/src/services/import/mime.ts +++ b/src/services/import/mime.ts @@ -70,7 +70,8 @@ const EXTENSION_TO_MIME = new Map([ [".swift", "text/x-swift"], [".ts", "text/x-typescript"], [".excalidraw", "application/json"], - [".mermaid", "text/vnd.mermaid"] + [".mermaid", "text/vnd.mermaid"], + [".mmd", "text/vnd.mermaid"] ]); /** @returns false if MIME is not detected */ diff --git a/src/services/import/samples/New note.mmd b/src/services/import/samples/New note.mmd new file mode 100644 index 000000000..577e63359 --- /dev/null +++ b/src/services/import/samples/New note.mmd @@ -0,0 +1,5 @@ +graph TD; + A-->B; + A-->C; + B-->D; + C-->D; \ No newline at end of file diff --git a/src/services/import/single.spec.ts b/src/services/import/single.spec.ts index 060801eb9..e26934b08 100644 --- a/src/services/import/single.spec.ts +++ b/src/services/import/single.spec.ts @@ -97,7 +97,7 @@ describe("processNoteContent", () => { expect(importedNote.title).toBe("New note"); }); - it("supports mermaid note", async () => { + it("imports .mermaid as mermaid note", async () => { const { importedNote } = await testImport("New note.mermaid", "application/json"); expect(importedNote).toMatchObject({ mime: "text/vnd.mermaid", @@ -105,4 +105,13 @@ describe("processNoteContent", () => { title: "New note" }); }); + + it("imports .mmd as mermaid note", async () => { + const { importedNote } = await testImport("New note.mmd", "application/json"); + expect(importedNote).toMatchObject({ + mime: "text/vnd.mermaid", + type: "mermaid", + title: "New note" + }); + }); }); diff --git a/src/services/utils.ts b/src/services/utils.ts index 87dcf2d67..926e24fb4 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -182,6 +182,7 @@ export function removeTextFileExtension(filePath: string) { case ".htm": case ".excalidraw": case ".mermaid": + case ".mmd": return filePath.substring(0, filePath.length - extension.length); default: return filePath;