mirror of
https://github.com/zadam/trilium.git
synced 2024-09-21 16:16:04 +08:00
small API additions
This commit is contained in:
parent
16fef78344
commit
fb975849b9
|
@ -27,6 +27,10 @@ class Attribute {
|
||||||
return this.treeCache.notes[this.noteId];
|
return this.treeCache.notes[this.noteId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get targetNoteId() { // alias
|
||||||
|
return this.type === 'relation' ? this.value : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
get jsonValue() {
|
get jsonValue() {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(this.value);
|
return JSON.parse(this.value);
|
||||||
|
|
|
@ -484,6 +484,15 @@ class NoteShort {
|
||||||
.map(attributeId => this.treeCache.attributes[attributeId]);
|
.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() {
|
get toString() {
|
||||||
return `Note(noteId=${this.noteId}, title=${this.title})`;
|
return `Note(noteId=${this.noteId}, title=${this.title})`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import ScriptContext from "./script_context.js";
|
import ScriptContext from "./script_context.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
import treeCache from "./tree_cache.js";
|
|
||||||
|
|
||||||
async function getAndExecuteBundle(noteId, originEntity = null) {
|
async function getAndExecuteBundle(noteId, originEntity = null) {
|
||||||
const bundle = await server.get('script/bundle/' + noteId);
|
const bundle = await server.get('script/bundle/' + noteId);
|
||||||
|
@ -77,4 +76,4 @@ export default {
|
||||||
getAndExecuteBundle,
|
getAndExecuteBundle,
|
||||||
executeStartupBundles,
|
executeStartupBundles,
|
||||||
getWidgetBundlesByParent
|
getWidgetBundlesByParent
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,6 +276,9 @@ class TreeCache {
|
||||||
return child.parentToBranch[parentNoteId];
|
return child.parentToBranch[parentNoteId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Promise<NoteComplement>}
|
||||||
|
*/
|
||||||
async getNoteComplement(noteId) {
|
async getNoteComplement(noteId) {
|
||||||
if (!this.noteComplementPromises[noteId]) {
|
if (!this.noteComplementPromises[noteId]) {
|
||||||
this.noteComplementPromises[noteId] = server.get('notes/' + noteId).then(row => new NoteComplement(row));
|
this.noteComplementPromises[noteId] = server.get('notes/' + noteId).then(row => new NoteComplement(row));
|
||||||
|
|
|
@ -285,7 +285,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
|
||||||
|
|
||||||
const relation = attrs.find(attr =>
|
const relation = attrs.find(attr =>
|
||||||
attr.type === 'relation'
|
attr.type === 'relation'
|
||||||
&& ['template', 'runOnNoteView', 'renderNote'].includes(attr.name)
|
&& ['template', 'renderNote'].includes(attr.name)
|
||||||
&& attr.isAffecting(this.note));
|
&& attr.isAffecting(this.note));
|
||||||
|
|
||||||
if (label || relation) {
|
if (label || relation) {
|
||||||
|
|
|
@ -100,4 +100,4 @@ export default class NoteTitleWidget extends TabAwareWidget {
|
||||||
beforeUnloadEvent() {
|
beforeUnloadEvent() {
|
||||||
this.spacedUpdate.updateNowIfNecessary();
|
this.spacedUpdate.updateNowIfNecessary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ const BUILTIN_ATTRIBUTES = [
|
||||||
{ type: 'label', name: 'bookZoomLevel', isDangerous: false },
|
{ type: 'label', name: 'bookZoomLevel', isDangerous: false },
|
||||||
|
|
||||||
// relation names
|
// relation names
|
||||||
{ type: 'relation', name: 'runOnNoteView', isDangerous: true },
|
|
||||||
{ type: 'relation', name: 'runOnNoteCreation', isDangerous: true },
|
{ type: 'relation', name: 'runOnNoteCreation', isDangerous: true },
|
||||||
{ type: 'relation', name: 'runOnNoteTitleChange', isDangerous: true },
|
{ type: 'relation', name: 'runOnNoteTitleChange', isDangerous: true },
|
||||||
{ type: 'relation', name: 'runOnNoteChange', isDangerous: true },
|
{ type: 'relation', name: 'runOnNoteChange', isDangerous: true },
|
||||||
|
|
Loading…
Reference in a new issue