Skip to content

Build your personal knowledge base with Trilium Notes

small API additions

zadamfb975849b974
diff --git a/src/public/app/entities/attribute.js b/src/public/app/entities/attribute.js
index 3d5a636166..91b8044da1 100644
--- a/src/public/app/entities/attribute.js
+++ b/src/public/app/entities/attribute.js
@@ -27,6 +27,10 @@ class Attribute {
return this.treeCache.notes[this.noteId];
}
+ get targetNoteId() { // alias
+ return this.type === 'relation' ? this.value : undefined;
+ }
+
get jsonValue() {
try {
return JSON.parse(this.value);
diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js
index a553acd989..6bbb54bc30 100644
--- a/src/public/app/entities/note_short.js
+++ b/src/public/app/entities/note_short.js
@@ -484,6 +484,15 @@ class NoteShort {
.map(attributeId => this.treeCache.attributes[attributeId]);
}
+ /**
+ * Return note complement which is most importantly note's content
+ *
+ * @return {Promise<NoteComplement>}
+ */
+ async getNoteComplement() {
+ return await this.treeCache.getNoteComplement(this.noteId);
+ }
+
get toString() {
return `Note(noteId=${this.noteId}, title=${this.title})`;
}
diff --git a/src/public/app/services/bundle.js b/src/public/app/services/bundle.js
index 8ee8246296..2935b91026 100644
--- a/src/public/app/services/bundle.js
+++ b/src/public/app/services/bundle.js
@@ -1,7 +1,6 @@
import ScriptContext from "./script_context.js";
import server from "./server.js";
import toastService from "./toast.js";
-import treeCache from "./tree_cache.js";
async function getAndExecuteBundle(noteId, originEntity = null) {
const bundle = await server.get('script/bundle/' + noteId);
@@ -77,4 +76,4 @@ export default {
getAndExecuteBundle,
executeStartupBundles,
getWidgetBundlesByParent
-}
\ No newline at end of file
+}
diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js
index 0aaebac3e7..8461a1f580 100644
--- a/src/public/app/services/tree_cache.js
+++ b/src/public/app/services/tree_cache.js
@@ -276,6 +276,9 @@ class TreeCache {
return child.parentToBranch[parentNoteId];
}
+ /**
+ * @return {Promise<NoteComplement>}
+ */
async getNoteComplement(noteId) {
if (!this.noteComplementPromises[noteId]) {
this.noteComplementPromises[noteId] = server.get('notes/' + noteId).then(row => new NoteComplement(row));
diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js
index d979368fd7..225294991b 100644
--- a/src/public/app/widgets/note_detail.js
+++ b/src/public/app/widgets/note_detail.js
@@ -285,7 +285,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
const relation = attrs.find(attr =>
attr.type === 'relation'
- && ['template', 'runOnNoteView', 'renderNote'].includes(attr.name)
+ && ['template', 'renderNote'].includes(attr.name)
&& attr.isAffecting(this.note));
if (label || relation) {
diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js
index 576dd5b810..edcf8874d2 100644
--- a/src/public/app/widgets/note_title.js
+++ b/src/public/app/widgets/note_title.js
@@ -100,4 +100,4 @@ export default class NoteTitleWidget extends TabAwareWidget {
beforeUnloadEvent() {
this.spacedUpdate.updateNowIfNecessary();
}
-}
\ No newline at end of file
+}
diff --git a/src/services/attributes.js b/src/services/attributes.js
index 975d800841..13db04fbc3 100644
--- a/src/services/attributes.js
+++ b/src/services/attributes.js
@@ -29,7 +29,6 @@ const BUILTIN_ATTRIBUTES = [
{ type: 'label', name: 'bookZoomLevel', isDangerous: false },
// relation names
- { type: 'relation', name: 'runOnNoteView', isDangerous: true },
{ type: 'relation', name: 'runOnNoteCreation', isDangerous: true },
{ type: 'relation', name: 'runOnNoteTitleChange', isDangerous: true },
{ type: 'relation', name: 'runOnNoteChange', isDangerous: true },