Skip to content

Build your personal knowledge base with Trilium Notes

we're now saving links also for notes included in relation maps which helps with translation of noteIds during import from native tar

azivner6a36e1ca8609
diff --git a/src/public/javascripts/services/note_detail_relation_map.js b/src/public/javascripts/services/note_detail_relation_map.js
index d573376e58..868a786607 100644
--- a/src/public/javascripts/services/note_detail_relation_map.js
+++ b/src/public/javascripts/services/note_detail_relation_map.js
@@ -549,6 +549,8 @@ async function dropNoteOntoRelationMapHandler(ev) {
}
}
+ saveData();
+
await refresh();
}
diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js
index a6045ef844..6e6a913445 100644
--- a/src/services/consistency_checks.js
+++ b/src/services/consistency_checks.js
@@ -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(`
diff --git a/src/services/import/tar.js b/src/services/import/tar.js
index 9c8168d55c..26045c77b8 100644
--- a/src/services/import/tar.js
+++ b/src/services/import/tar.js
@@ -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') {
diff --git a/src/services/notes.js b/src/services/notes.js
index e74e649718..4fa7503ebd 100644
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@ -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();