Skip to content

Build your personal knowledge base with Trilium Notes

fix overwriting / deleting auto links, closes #1406

zadam99f01b9ccfd6
diff --git a/src/entities/attribute.js b/src/entities/attribute.js
index 857531ffea..b5aecf6e19 100644
--- a/src/entities/attribute.js
+++ b/src/entities/attribute.js
@@ -34,6 +34,10 @@ class Attribute extends Entity {
this.isInheritable = !!this.isInheritable;
}
+ isAutoLink() {
+ return this.type === 'relation' && ['internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'].includes(this.name);
+ }
+
/**
* @returns {Note|null}
*/
diff --git a/src/routes/api/attributes.js b/src/routes/api/attributes.js
index 345ecfae43..98360a36c7 100644
--- a/src/routes/api/attributes.js
+++ b/src/routes/api/attributes.js
@@ -147,8 +147,10 @@ function updateNoteAttributes(req) {
// all the remaining existing attributes are not defined anymore and should be deleted
for (const toDeleteAttr of existingAttrs) {
- toDeleteAttr.isDeleted = true;
- toDeleteAttr.save();
+ if (!toDeleteAttr.isAutoLink()) {
+ toDeleteAttr.isDeleted = true;
+ toDeleteAttr.save();
+ }
}
}