mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
not generating externalLink labels anymore since there can be too many and benefit is too small
This commit is contained in:
parent
8d312515dd
commit
081693f263
@ -811,11 +811,9 @@ class Note extends Entity {
|
||||
SELECT *
|
||||
FROM attributes
|
||||
WHERE noteId = ? AND
|
||||
isDeleted = 0 AND
|
||||
((type = 'relation' AND
|
||||
name IN ('internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'))
|
||||
OR
|
||||
(type = 'label' AND name = 'externalLink'))`, [this.noteId]);
|
||||
isDeleted = 0 AND
|
||||
type = 'relation' AND
|
||||
name IN ('internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink')`, [this.noteId]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,19 +69,7 @@ export default class AttributesWidget extends CollapsibleWidget {
|
||||
async renderAttributes(attributes, $container) {
|
||||
for (const attribute of attributes) {
|
||||
if (attribute.type === 'label') {
|
||||
if (attribute.name === 'externalLink') {
|
||||
$container.append('@' + attribute.name + "=");
|
||||
$container.append(
|
||||
$('<a>')
|
||||
.text(attribute.value)
|
||||
.attr('href', attribute.value)
|
||||
.addClass('external')
|
||||
);
|
||||
$container.append(" ");
|
||||
}
|
||||
else {
|
||||
$container.append(utils.formatLabel(attribute) + " ");
|
||||
}
|
||||
$container.append(utils.formatLabel(attribute) + " ");
|
||||
} else if (attribute.type === 'relation') {
|
||||
if (attribute.value) {
|
||||
$container.append('@' + attribute.name + "=");
|
||||
|
@ -152,11 +152,6 @@ async function importTar(taskContext, fileBuffer, importRootNote) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attr.type === 'label' && attr.name === 'externalLink') {
|
||||
// also created automatically
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attr.type === 'relation') {
|
||||
attr.value = getNewNoteId(attr.value);
|
||||
}
|
||||
|
@ -154,11 +154,6 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attr.type === 'label' && attr.name === 'externalLink') {
|
||||
// also created automatically
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attr.type === 'relation') {
|
||||
attr.value = getNewNoteId(attr.value);
|
||||
}
|
||||
|
@ -225,20 +225,6 @@ function findInternalLinks(content, foundLinks) {
|
||||
return content.replace(/href="[^"]*#root/g, 'href="#root');
|
||||
}
|
||||
|
||||
function findExternalLinks(content, foundLinks) {
|
||||
const re = /href="([a-zA-Z]+:\/\/[^"]*)"/g;
|
||||
let match;
|
||||
|
||||
while (match = re.exec(content)) {
|
||||
foundLinks.push({
|
||||
name: 'externalLink',
|
||||
value: match[1]
|
||||
});
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
function findIncludeNoteLinks(content, foundLinks) {
|
||||
const re = /<section class="include-note" data-note-id="([a-zA-Z0-9]+)">/g;
|
||||
let match;
|
||||
@ -392,7 +378,6 @@ async function saveLinks(note, content) {
|
||||
if (note.type === 'text') {
|
||||
content = findImageLinks(content, foundLinks);
|
||||
content = findInternalLinks(content, foundLinks);
|
||||
content = findExternalLinks(content, foundLinks);
|
||||
content = findIncludeNoteLinks(content, foundLinks);
|
||||
|
||||
content = await downloadImages(note.noteId, content);
|
||||
@ -407,11 +392,9 @@ async function saveLinks(note, content) {
|
||||
const existingLinks = await note.getLinks();
|
||||
|
||||
for (const foundLink of foundLinks) {
|
||||
if (foundLink.name !== 'externalLink') {
|
||||
const targetNote = await repository.getNote(foundLink.value);
|
||||
if (!targetNote || targetNote.isDeleted) {
|
||||
continue;
|
||||
}
|
||||
const targetNote = await repository.getNote(foundLink.value);
|
||||
if (!targetNote || targetNote.isDeleted) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const existingLink = existingLinks.find(existingLink =>
|
||||
@ -421,7 +404,7 @@ async function saveLinks(note, content) {
|
||||
if (!existingLink) {
|
||||
const newLink = await new Attribute({
|
||||
noteId: note.noteId,
|
||||
type: foundLink.name === 'externalLink' ? 'label' : 'relation',
|
||||
type: 'relation',
|
||||
name: foundLink.name,
|
||||
value: foundLink.value,
|
||||
}).save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user