diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html
index edecc2636..2ed05931c 100644
--- a/docs/frontend_api/FrontendScriptApi.html
+++ b/docs/frontend_api/FrontendScriptApi.html
@@ -1057,7 +1057,7 @@
Source:
@@ -1188,7 +1188,7 @@
Source:
@@ -1292,7 +1292,7 @@
Source:
@@ -1396,7 +1396,7 @@
Source:
@@ -1500,7 +1500,7 @@
Source:
@@ -1604,7 +1604,7 @@
Source:
@@ -1761,7 +1761,7 @@
Source:
@@ -1861,7 +1861,7 @@
Source:
@@ -1970,7 +1970,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2123,7 +2123,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2277,7 +2277,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2476,7 +2476,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2580,7 +2580,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2733,7 +2733,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2840,7 +2840,7 @@ note.
Source:
@@ -2993,7 +2993,7 @@ note.
Source:
@@ -3124,7 +3124,7 @@ note.
Source:
@@ -3228,7 +3228,7 @@ note.
Source:
@@ -3314,7 +3314,7 @@ note.
Source:
@@ -3463,7 +3463,7 @@ note.
Source:
@@ -3594,7 +3594,7 @@ note.
Source:
@@ -3809,6 +3809,314 @@ Internally this serializes the anonymous function into string and sends it to ba
+ searchForNote(searchString) → {Promise.<(NoteShort|null)>}
+
+
+
+
+
+
+
+ This is a powerful search method - you can search by attributes and their values, e.g.:
+"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ searchString |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<(NoteShort|null)>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ searchForNotes(searchString) → {Promise.<Array.<NoteShort>>}
+
+
+
+
+
+
+
+ This is a powerful search method - you can search by attributes and their values, e.g.:
+"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ searchString |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<Array.<NoteShort>>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
setCodeMimeTypes(types)
@@ -3906,7 +4214,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4037,7 +4345,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4172,7 +4480,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4307,7 +4615,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html
index 39edef43a..be54b8405 100644
--- a/docs/frontend_api/services_frontend_script_api.js.html
+++ b/docs/frontend_api/services_frontend_script_api.js.html
@@ -163,6 +163,38 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
}
};
+ /**
+ * This is a powerful search method - you can search by attributes and their values, e.g.:
+ * "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
+ *
+ * @method
+ * @param {string} searchString
+ * @returns {Promise<NoteShort[]>}
+ */
+ this.searchForNotes = async searchString => {
+ const noteIds = await this.runOnServer(async searchString => {
+ const notes = await api.searchForNotes(searchString);
+
+ return notes.map(note => note.noteId);
+ }, [searchString]);
+
+ return await treeCache.getNotes(noteIds);
+ };
+
+ /**
+ * This is a powerful search method - you can search by attributes and their values, e.g.:
+ * "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
+ *
+ * @method
+ * @param {string} searchString
+ * @returns {Promise<NoteShort|null>}
+ */
+ this.searchForNote = async searchString => {
+ const notes = await this.searchForNotes(searchString);
+
+ return notes.length > 0 ? notes[0] : null;
+ };
+
/**
* Returns note by given noteId. If note is missing from cache, it's loaded.
**
diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js
index 4c1b7f061..6b5a950b7 100644
--- a/src/public/javascripts/services/frontend_script_api.js
+++ b/src/public/javascripts/services/frontend_script_api.js
@@ -135,6 +135,38 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
}
};
+ /**
+ * This is a powerful search method - you can search by attributes and their values, e.g.:
+ * "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
+ *
+ * @method
+ * @param {string} searchString
+ * @returns {Promise}
+ */
+ this.searchForNotes = async searchString => {
+ const noteIds = await this.runOnServer(async searchString => {
+ const notes = await api.searchForNotes(searchString);
+
+ return notes.map(note => note.noteId);
+ }, [searchString]);
+
+ return await treeCache.getNotes(noteIds);
+ };
+
+ /**
+ * This is a powerful search method - you can search by attributes and their values, e.g.:
+ * "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
+ *
+ * @method
+ * @param {string} searchString
+ * @returns {Promise}
+ */
+ this.searchForNote = async searchString => {
+ const notes = await this.searchForNotes(searchString);
+
+ return notes.length > 0 ? notes[0] : null;
+ };
+
/**
* Returns note by given noteId. If note is missing from cache, it's loaded.
**