feat(import/zip): improve geomap compatibility

This commit is contained in:
Elian Doran 2025-07-06 23:05:15 +03:00
parent a58e5789bc
commit a563330136
No known key found for this signature in database
3 changed files with 35 additions and 0 deletions

Binary file not shown.

View File

@ -70,6 +70,19 @@ describe("processNoteContent", () => {
expect(content).toContain(`<a class="reference-link" href="#root/${shopNote.noteId}`);
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[]) {

View File

@ -502,6 +502,28 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
firstNote = firstNote || note;
}
} 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({
parentNoteId: parentNoteId,
title: noteTitle || "",