mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	we're now saving links also for notes included in relation maps which helps with translation of noteIds during import from native tar
This commit is contained in:
		| @@ -549,6 +549,8 @@ async function dropNoteOntoRelationMapHandler(ev) { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     saveData(); | ||||
|  | ||||
|     await refresh(); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -263,7 +263,8 @@ async function runAllChecks() { | ||||
|             links | ||||
|           WHERE  | ||||
|             type != 'image' | ||||
|             AND type != 'hyper'`, | ||||
|             AND type != 'hyper' | ||||
|             AND type != 'relation-map'`, | ||||
|         "Link type is invalid", errorList); | ||||
|  | ||||
|     await runCheck(` | ||||
|   | ||||
| @@ -202,7 +202,7 @@ async function importNotes(ctx, files, parentNoteId) { | ||||
|                     isExpanded: !!file.meta.isExpanded | ||||
|                 }).save(); | ||||
|  | ||||
|                 return; | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             if (file.meta.type !== 'file' && file.meta.type !== 'image') { | ||||
|   | ||||
| @@ -199,15 +199,34 @@ function findHyperLinks(content, foundLinks) { | ||||
|     return match; | ||||
| } | ||||
|  | ||||
| function findRelationMapLinks(content, foundLinks) { | ||||
|     const obj = JSON.parse(content); | ||||
|  | ||||
|     for (const note of obj.notes) { | ||||
|         foundLinks.push({ | ||||
|             type: 'relation-map', | ||||
|             targetNoteId: note.noteId | ||||
|         }) | ||||
|     } | ||||
| } | ||||
|  | ||||
| async function saveLinks(note) { | ||||
|     if (note.type !== 'text') { | ||||
|     if (note.type !== 'text' && note.type !== 'relation-map') { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     const foundLinks = []; | ||||
|  | ||||
|     findImageLinks(note.content, foundLinks); | ||||
|     findHyperLinks(note.content, foundLinks); | ||||
|     if (note.type === 'text') { | ||||
|         findImageLinks(note.content, foundLinks); | ||||
|         findHyperLinks(note.content, foundLinks); | ||||
|     } | ||||
|     else if (note.type === 'relation-map') { | ||||
|         findRelationMapLinks(note.content, foundLinks); | ||||
|     } | ||||
|     else { | ||||
|         throw new Error("Unrecognized type " + note.type); | ||||
|     } | ||||
|  | ||||
|     const existingLinks = await note.getLinks(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user