mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02: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:
parent
3fee263355
commit
6a36e1ca86
@ -549,6 +549,8 @@ async function dropNoteOntoRelationMapHandler(ev) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveData();
|
||||||
|
|
||||||
await refresh();
|
await refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,8 @@ async function runAllChecks() {
|
|||||||
links
|
links
|
||||||
WHERE
|
WHERE
|
||||||
type != 'image'
|
type != 'image'
|
||||||
AND type != 'hyper'`,
|
AND type != 'hyper'
|
||||||
|
AND type != 'relation-map'`,
|
||||||
"Link type is invalid", errorList);
|
"Link type is invalid", errorList);
|
||||||
|
|
||||||
await runCheck(`
|
await runCheck(`
|
||||||
|
@ -202,7 +202,7 @@ async function importNotes(ctx, files, parentNoteId) {
|
|||||||
isExpanded: !!file.meta.isExpanded
|
isExpanded: !!file.meta.isExpanded
|
||||||
}).save();
|
}).save();
|
||||||
|
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.meta.type !== 'file' && file.meta.type !== 'image') {
|
if (file.meta.type !== 'file' && file.meta.type !== 'image') {
|
||||||
|
@ -199,15 +199,34 @@ function findHyperLinks(content, foundLinks) {
|
|||||||
return match;
|
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) {
|
async function saveLinks(note) {
|
||||||
if (note.type !== 'text') {
|
if (note.type !== 'text' && note.type !== 'relation-map') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const foundLinks = [];
|
const foundLinks = [];
|
||||||
|
|
||||||
findImageLinks(note.content, foundLinks);
|
if (note.type === 'text') {
|
||||||
findHyperLinks(note.content, foundLinks);
|
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();
|
const existingLinks = await note.getLinks();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user