mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
feat(import/zip): improve geomap compatibility
This commit is contained in:
parent
a58e5789bc
commit
a563330136
BIN
apps/server/src/services/import/samples/geomap.zip
Normal file
BIN
apps/server/src/services/import/samples/geomap.zip
Normal file
Binary file not shown.
@ -70,6 +70,19 @@ describe("processNoteContent", () => {
|
|||||||
expect(content).toContain(`<a class="reference-link" href="#root/${shopNote.noteId}`);
|
expect(content).toContain(`<a class="reference-link" href="#root/${shopNote.noteId}`);
|
||||||
expect(content).toContain(`<img src="api/images/${bananaNote!.noteId}/banana.jpeg`);
|
expect(content).toContain(`<img src="api/images/${bananaNote!.noteId}/banana.jpeg`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("can import old geomap notes", async () => {
|
||||||
|
const { importedNote } = await testImport("geomap.zip");
|
||||||
|
expect(importedNote.type).toBe("book");
|
||||||
|
expect(importedNote.mime).toBe("");
|
||||||
|
expect(importedNote.getRelationValue("template")).toBe("_template_geo_map");
|
||||||
|
|
||||||
|
const attachment = importedNote.getAttachmentsByRole("viewConfig")[0];
|
||||||
|
expect(attachment.title).toBe("geoMap.json");
|
||||||
|
expect(attachment.mime).toBe("application/json");
|
||||||
|
const content = attachment.getContent();
|
||||||
|
expect(content).toStrictEqual(`{"view":{"center":{"lat":49.19598332223546,"lng":-2.1414576506668808},"zoom":12}}`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function getNoteByTitlePath(parentNote: BNote, ...titlePath: string[]) {
|
function getNoteByTitlePath(parentNote: BNote, ...titlePath: string[]) {
|
||||||
|
@ -502,6 +502,28 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
|
|||||||
firstNote = firstNote || note;
|
firstNote = firstNote || note;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (detectedType as string === "geoMap") {
|
||||||
|
attributes.push({
|
||||||
|
noteId,
|
||||||
|
type: "relation",
|
||||||
|
name: "template",
|
||||||
|
value: "_template_geo_map"
|
||||||
|
});
|
||||||
|
|
||||||
|
const attachment = new BAttachment({
|
||||||
|
attachmentId: getNewAttachmentId(newEntityId()),
|
||||||
|
ownerId: noteId,
|
||||||
|
title: "geoMap.json",
|
||||||
|
role: "viewConfig",
|
||||||
|
mime: "application/json",
|
||||||
|
position: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
attachment.setContent(content, { forceSave: true });
|
||||||
|
content = "";
|
||||||
|
mime = "";
|
||||||
|
}
|
||||||
|
|
||||||
({ note } = noteService.createNewNote({
|
({ note } = noteService.createNewNote({
|
||||||
parentNoteId: parentNoteId,
|
parentNoteId: parentNoteId,
|
||||||
title: noteTitle || "",
|
title: noteTitle || "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user