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",
|
||||
["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",
|
||||
|
@ -70,7 +70,8 @@ const EXTENSION_TO_MIME = new Map<string, string>([
|
||||
[".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 */
|
||||
|
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");
|
||||
});
|
||||
|
||||
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"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user