diff --git a/apps/server/src/services/import/samples/geomap.zip b/apps/server/src/services/import/samples/geomap.zip new file mode 100644 index 000000000..6443c1997 Binary files /dev/null and b/apps/server/src/services/import/samples/geomap.zip differ diff --git a/apps/server/src/services/import/zip.spec.ts b/apps/server/src/services/import/zip.spec.ts index 4860f7b94..db2c7ba76 100644 --- a/apps/server/src/services/import/zip.spec.ts +++ b/apps/server/src/services/import/zip.spec.ts @@ -70,6 +70,19 @@ describe("processNoteContent", () => { expect(content).toContain(` { + 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[]) { diff --git a/apps/server/src/services/import/zip.ts b/apps/server/src/services/import/zip.ts index 67deb1056..b2d83bdc6 100644 --- a/apps/server/src/services/import/zip.ts +++ b/apps/server/src/services/import/zip.ts @@ -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 || "",