Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
not generating externalLink labels anymore since there can be too many and benefit is too small
zadam081693f2635f
diff --git a/src/entities/note.js b/src/entities/note.jsindex 739eec9839..5ab002880a 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -811,11 +811,9 @@ class Note extends Entity {SELECT *FROM attributesWHERE 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]);}/**diff --git a/src/public/javascripts/widgets/attributes.js b/src/public/javascripts/widgets/attributes.jsindex 80b860d860..3c4644d330 100644--- a/src/public/javascripts/widgets/attributes.js+++ b/src/public/javascripts/widgets/attributes.js@@ -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 + "=");diff --git a/src/services/import/tar.js b/src/services/import/tar.jsindex 432923ead7..f09c26d16e 100644--- a/src/services/import/tar.js+++ b/src/services/import/tar.js@@ -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);}diff --git a/src/services/import/zip.js b/src/services/import/zip.jsindex f79426d203..951ccb3063 100644--- a/src/services/import/zip.js+++ b/src/services/import/zip.js@@ -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);}diff --git a/src/services/notes.js b/src/services/notes.jsindex 59f9145039..4a46887c82 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -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();