mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
api docs
This commit is contained in:
@@ -39,6 +39,7 @@ const NoteRevision = require("./note_revision");
|
||||
const TaskContext = require("../../services/task_context");
|
||||
const dayjs = require("dayjs");
|
||||
const utc = require('dayjs/plugin/utc');
|
||||
const searchService = require("../../services/search/services/search.js");
|
||||
dayjs.extend(utc)
|
||||
|
||||
const LABEL = 'label';
|
||||
@@ -867,6 +868,27 @@ class Note extends AbstractEntity {
|
||||
return Array.from(set);
|
||||
}
|
||||
|
||||
/** @return {Note[]} */
|
||||
getSearchResultNotes() {
|
||||
if (this.type !== 'search') {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
const searchService = require("../../services/search/services/search");
|
||||
const {searchResultNoteIds} = searchService.searchFromNote(this);
|
||||
|
||||
const becca = this.becca;
|
||||
return searchResultNoteIds
|
||||
.map(resultNoteId => becca.notes[resultNoteId])
|
||||
.filter(note => !!note);
|
||||
}
|
||||
catch (e) {
|
||||
log.error(`Could not resolve search note ${this.noteId}: ${e.message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {{notes: Note[], relationships: Array.<{parentNoteId: string, childNoteId: string}>}}
|
||||
*/
|
||||
@@ -876,16 +898,8 @@ class Note extends AbstractEntity {
|
||||
|
||||
function resolveSearchNote(searchNote) {
|
||||
try {
|
||||
const searchService = require("../../services/search/services/search");
|
||||
const becca = searchNote.becca;
|
||||
const {searchResultNoteIds} = searchService.searchFromNote(searchNote);
|
||||
|
||||
for (const resultNoteId of searchResultNoteIds) {
|
||||
const resultNote = becca.notes[resultNoteId];
|
||||
|
||||
if (resultNote) {
|
||||
addSubtreeNotesInner(resultNote, searchNote);
|
||||
}
|
||||
for (const resultNote of searchNote.getSearchResultNotes()) {
|
||||
addSubtreeNotesInner(resultNote, searchNote);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user