mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
feat(import/single): mermaid with .mmd extension
This commit is contained in:
parent
3dae771e90
commit
858ad91708
@ -30,6 +30,10 @@ describe("#getMime", () => {
|
|||||||
"File extension ('.mermaid') that is defined in EXTENSION_TO_MIME",
|
"File extension ('.mermaid') that is defined in EXTENSION_TO_MIME",
|
||||||
["test.mermaid"], "text/vnd.mermaid"
|
["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",
|
"File extension with inconsistent capitalization that is defined in EXTENSION_TO_MIME",
|
||||||
|
@ -70,7 +70,8 @@ const EXTENSION_TO_MIME = new Map<string, string>([
|
|||||||
[".swift", "text/x-swift"],
|
[".swift", "text/x-swift"],
|
||||||
[".ts", "text/x-typescript"],
|
[".ts", "text/x-typescript"],
|
||||||
[".excalidraw", "application/json"],
|
[".excalidraw", "application/json"],
|
||||||
[".mermaid", "text/vnd.mermaid"]
|
[".mermaid", "text/vnd.mermaid"],
|
||||||
|
[".mmd", "text/vnd.mermaid"]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/** @returns false if MIME is not detected */
|
/** @returns false if MIME is not detected */
|
||||||
|
5
src/services/import/samples/New note.mmd
Normal file
5
src/services/import/samples/New note.mmd
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
graph TD;
|
||||||
|
A-->B;
|
||||||
|
A-->C;
|
||||||
|
B-->D;
|
||||||
|
C-->D;
|
@ -97,7 +97,7 @@ describe("processNoteContent", () => {
|
|||||||
expect(importedNote.title).toBe("New note");
|
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");
|
const { importedNote } = await testImport("New note.mermaid", "application/json");
|
||||||
expect(importedNote).toMatchObject({
|
expect(importedNote).toMatchObject({
|
||||||
mime: "text/vnd.mermaid",
|
mime: "text/vnd.mermaid",
|
||||||
@ -105,4 +105,13 @@ describe("processNoteContent", () => {
|
|||||||
title: "New note"
|
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"
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -182,6 +182,7 @@ export function removeTextFileExtension(filePath: string) {
|
|||||||
case ".htm":
|
case ".htm":
|
||||||
case ".excalidraw":
|
case ".excalidraw":
|
||||||
case ".mermaid":
|
case ".mermaid":
|
||||||
|
case ".mmd":
|
||||||
return filePath.substring(0, filePath.length - extension.length);
|
return filePath.substring(0, filePath.length - extension.length);
|
||||||
default:
|
default:
|
||||||
return filePath;
|
return filePath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user