mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 09:16:45 +01:00
using included note should create a relation, closes #820
This commit is contained in:
@@ -242,6 +242,20 @@ function findInternalLinks(content, foundLinks) {
|
||||
return content.replace(/href="[^"]*#root/g, 'href="#root');
|
||||
}
|
||||
|
||||
function findIncludeNoteLinks(content, foundLinks) {
|
||||
const re = /<section class="include-note" data-note-id="([a-zA-Z0-9]+)">/g;
|
||||
let match;
|
||||
|
||||
while (match = re.exec(content)) {
|
||||
foundLinks.push({
|
||||
name: 'includeNoteLink',
|
||||
value: match[1]
|
||||
});
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
function findRelationMapLinks(content, foundLinks) {
|
||||
const obj = JSON.parse(content);
|
||||
|
||||
@@ -263,10 +277,11 @@ async function saveLinks(note, content) {
|
||||
}
|
||||
|
||||
const foundLinks = [];
|
||||
|
||||
console.log("Scanning", content);
|
||||
if (note.type === 'text') {
|
||||
content = findImageLinks(content, foundLinks);
|
||||
content = findInternalLinks(content, foundLinks);
|
||||
content = findIncludeNoteLinks(content, foundLinks);
|
||||
}
|
||||
else if (note.type === 'relation-map') {
|
||||
findRelationMapLinks(content, foundLinks);
|
||||
|
||||
Reference in New Issue
Block a user