mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	feat(import/zip): improve geomap compatibility
This commit is contained in:
		
							
								
								
									
										
											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(`<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[]) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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 || "",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user