Skip to content

Build your personal knowledge base with Trilium Notes

added date note APIs to frontend script API

zadam253a6ef0816e
diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html
index ceaa2bbd13..1cf2ff4337 100644
--- a/docs/backend_api/Note.html
+++ b/docs/backend_api/Note.html
@@ -581,7 +581,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line326">line 326</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line347">line 347</a>
</li></ul></dd>
@@ -746,7 +746,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line195">line 195</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line216">line 216</a>
</li></ul></dd>
@@ -922,7 +922,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line337">line 337</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line358">line 358</a>
</li></ul></dd>
@@ -1026,7 +1026,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line624">line 624</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line645">line 645</a>
</li></ul></dd>
@@ -1126,7 +1126,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line652">line 652</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line673">line 673</a>
</li></ul></dd>
@@ -1230,7 +1230,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line638">line 638</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line659">line 659</a>
</li></ul></dd>
@@ -1334,7 +1334,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line66">line 66</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line75">line 75</a>
</li></ul></dd>
@@ -1434,7 +1434,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line513">line 513</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line534">line 534</a>
</li></ul></dd>
@@ -1665,7 +1665,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line536">line 536</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line557">line 557</a>
</li></ul></dd>
@@ -1861,7 +1861,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line574">line 574</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line595">line 595</a>
</li></ul></dd>
@@ -2057,7 +2057,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line583">line 583</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line604">line 604</a>
</li></ul></dd>
@@ -2157,7 +2157,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line90">line 90</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line111">line 111</a>
</li></ul></dd>
@@ -2306,7 +2306,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line424">line 424</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line445">line 445</a>
</li></ul></dd>
@@ -2471,7 +2471,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line220">line 220</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line241">line 241</a>
</li></ul></dd>
@@ -2636,7 +2636,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line212">line 212</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line233">line 233</a>
</li></ul></dd>
@@ -2789,7 +2789,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line436">line 436</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line457">line 457</a>
</li></ul></dd>
@@ -2897,7 +2897,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line599">line 599</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line620">line 620</a>
</li></ul></dd>
@@ -3001,7 +3001,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line617">line 617</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line638">line 638</a>
</li></ul></dd>
@@ -3101,7 +3101,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line180">line 180</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line201">line 201</a>
</li></ul></dd>
@@ -3205,7 +3205,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line664">line 664</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line685">line 685</a>
</li></ul></dd>
@@ -3358,7 +3358,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line430">line 430</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line451">line 451</a>
</li></ul></dd>
@@ -3523,7 +3523,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line236">line 236</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line257">line 257</a>
</li></ul></dd>
@@ -3688,7 +3688,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line228">line 228</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line249">line 249</a>
</li></ul></dd>
@@ -3841,7 +3841,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line448">line 448</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line469">line 469</a>
</li></ul></dd>
@@ -3997,7 +3997,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line442">line 442</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line463">line 463</a>
</li></ul></dd>
@@ -4105,7 +4105,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line590">line 590</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line611">line 611</a>
</li></ul></dd>
@@ -4205,7 +4205,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line161">line 161</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line182">line 182</a>
</li></ul></dd>
@@ -4313,7 +4313,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line608">line 608</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line629">line 629</a>
</li></ul></dd>
@@ -4413,7 +4413,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line187">line 187</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line208">line 208</a>
</li></ul></dd>
@@ -4589,7 +4589,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line317">line 317</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line338">line 338</a>
</li></ul></dd>
@@ -4693,7 +4693,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line631">line 631</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line652">line 652</a>
</li></ul></dd>
@@ -4846,7 +4846,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line412">line 412</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line433">line 433</a>
</li></ul></dd>
@@ -4999,7 +4999,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line418">line 418</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line439">line 439</a>
</li></ul></dd>
@@ -5108,7 +5108,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line244">line 244</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line265">line 265</a>
</li></ul></dd>
@@ -5190,7 +5190,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line149">line 149</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line170">line 170</a>
</li></ul></dd>
@@ -5294,7 +5294,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line141">line 141</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line162">line 162</a>
</li></ul></dd>
@@ -5398,7 +5398,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line136">line 136</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line157">line 157</a>
</li></ul></dd>
@@ -5502,7 +5502,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line131">line 131</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line152">line 152</a>
</li></ul></dd>
@@ -5606,7 +5606,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line154">line 154</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line175">line 175</a>
</li></ul></dd>
@@ -5710,7 +5710,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line249">line 249</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line270">line 270</a>
</li></ul></dd>
@@ -5937,7 +5937,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line395">line 395</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line416">line 416</a>
</li></ul></dd>
@@ -6133,7 +6133,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line499">line 499</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line520">line 520</a>
</li></ul></dd>
@@ -6329,7 +6329,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line508">line 508</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line529">line 529</a>
</li></ul></dd>
@@ -6556,7 +6556,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line369">line 369</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line390">line 390</a>
</li></ul></dd>
@@ -6656,7 +6656,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line97">line 97</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line118">line 118</a>
</li></ul></dd>
@@ -6756,7 +6756,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line126">line 126</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line147">line 147</a>
</li></ul></dd>
@@ -6952,7 +6952,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line481">line 481</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line502">line 502</a>
</li></ul></dd>
@@ -7148,7 +7148,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line490">line 490</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line511">line 511</a>
</li></ul></dd>
@@ -7406,7 +7406,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line352">line 352</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line373">line 373</a>
</li></ul></dd>
@@ -7633,7 +7633,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line462">line 462</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line483">line 483</a>
</li></ul></dd>
@@ -7860,7 +7860,7 @@ Cache is note instance scoped.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line472">line 472</a>
+ <a href="entities_note.js.html">entities/note.js</a>, <a href="entities_note.js.html#line493">line 493</a>
</li></ul></dd>
diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.html
index 62eaad682a..f1acd74b0e 100644
--- a/docs/backend_api/entities_note.js.html
+++ b/docs/backend_api/entities_note.js.html
@@ -90,10 +90,31 @@ class Note extends Entity {
}
}
+ /*
+ * Note content has quite special handling - it's not a separate entity, but a lazily loaded
+ * part of Note entity with it's own sync. Reasons behind this hybrid design has been:
+ *
+ * - content can be quite large and it's not necessary to load it / fill memory for any note access even if we don't need a content, especially for bulk operations like search
+ * - changes in the note metadata or title should not trigger note content sync (so we keep separate utcDateModified and sync rows)
+ * - but to the user note content and title changes are one and the same - single dateModified (so all changes must go through Note and content is not a separate entity)
+ */
+
/** @returns {Promise&lt;*>} */
- async getContent() {
+ async getContent(silentNotFoundError = false) {
if (this.content === undefined) {
- this.content = await sql.getValue(`SELECT content FROM note_contents WHERE noteId = ?`, [this.noteId]);
+ const res = await sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
+
+ if (!res) {
+ if (silentNotFoundError) {
+ return undefined;
+ }
+ else {
+ throw new Error("Cannot find note content for noteId=" + this.noteId);
+ }
+ }
+
+ this.content = res.content;
+ this.contentHash = res.contentHash; // used only for note_fulltext consistency check
if (this.isProtected) {
if (this.isContentAvailable) {
@@ -123,6 +144,10 @@ class Note extends Entity {
/** @returns {Promise} */
async setContent(content) {
+ // force updating note itself so that dateChanged is represented correctly even for the content
+ this.forcedChange = true;
+ await this.save();
+
this.content = content;
const pojo = {
@@ -144,10 +169,6 @@ class Note extends Entity {
await sql.upsert("note_contents", "noteId", pojo);
await syncTableService.addNoteContentSync(this.noteId);
-
- this.forcedChange = true;
-
- await this.save();
}
/** @returns {Promise} */
@@ -736,6 +757,7 @@ class Note extends Entity {
delete pojo.isContentAvailable;
delete pojo.__attributeCache;
delete pojo.content;
+ delete pojo.contentHash;
}
async afterSaving() {
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html
index 73e9bb535a..c2704ceacd 100644
--- a/docs/frontend_api/FrontendScriptApi.html
+++ b/docs/frontend_api/FrontendScriptApi.html
@@ -81,7 +81,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line18">line 18</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line19">line 19</a>
</li></ul></dd>
@@ -221,7 +221,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line24">line 24</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line25">line 25</a>
</li></ul></dd>
@@ -334,7 +334,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line26">line 26</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line27">line 27</a>
</li></ul></dd>
@@ -444,7 +444,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line22">line 22</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line23">line 23</a>
</li></ul></dd>
@@ -573,7 +573,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line43">line 43</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line47">line 47</a>
</li></ul></dd>
@@ -726,7 +726,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line35">line 35</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line39">line 39</a>
</li></ul></dd>
@@ -879,7 +879,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line62">line 62</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line66">line 66</a>
</li></ul></dd>
@@ -1057,7 +1057,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line199">line 199</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line223">line 223</a>
</li></ul></dd>
@@ -1188,7 +1188,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line159">line 159</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line183">line 183</a>
</li></ul></dd>
@@ -1292,7 +1292,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line211">line 211</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line235">line 235</a>
</li></ul></dd>
@@ -1396,7 +1396,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line205">line 205</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line229">line 229</a>
</li></ul></dd>
@@ -1452,7 +1452,7 @@
- <h4 class="name" id="getCodeMimeTypes"><span class="type-signature"></span>getCodeMimeTypes<span class="signature">()</span><span class="type-signature"> &rarr; {array}</span></h4>
+ <h4 class="name" id="getActiveNotePath"><span class="type-signature"></span>getActiveNotePath<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
@@ -1500,7 +1500,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line242">line 242</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line241">line 241</a>
</li></ul></dd>
@@ -1527,7 +1527,7 @@
<div class="param-desc">
- list of currently used code mime types
+ returns note path of active note
</div>
@@ -1538,7 +1538,7 @@
</dt>
<dd>
-<span class="param-type">array</span>
+<span class="param-type">string</span>
</dd>
@@ -1556,7 +1556,7 @@
- <h4 class="name" id="getDefaultCodeMimeTypes"><span class="type-signature"></span>getDefaultCodeMimeTypes<span class="signature">()</span><span class="type-signature"> &rarr; {array}</span></h4>
+ <h4 class="name" id="getCodeMimeTypes"><span class="type-signature"></span>getCodeMimeTypes<span class="signature">()</span><span class="type-signature"> &rarr; {array}</span></h4>
@@ -1604,7 +1604,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line236">line 236</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line272">line 272</a>
</li></ul></dd>
@@ -1631,7 +1631,7 @@
<div class="param-desc">
- list of default code mime types
+ list of currently used code mime types
</div>
@@ -1660,7 +1660,7 @@
- <h4 class="name" id="getInstanceName"><span class="type-signature"></span>getInstanceName<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
+ <h4 class="name" id="getDateNote"><span class="type-signature"></span>getDateNote<span class="signature">(date)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="NoteShort.html">NoteShort</a>>}</span></h4>
@@ -1668,8 +1668,7 @@
<div class="description">
- Instance name identifies particular Trilium instance. It can be useful for scripts
-if some action needs to happen on only one specific instance.
+ Returns date-note. If it doesn't exist, it is automatically created.
</div>
@@ -1680,6 +1679,55 @@ if some action needs to happen on only one specific instance.
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>date</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">e.g. "2019-04-29"</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
@@ -1713,7 +1761,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line152">line 152</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line306">line 306</a>
</li></ul></dd>
@@ -1747,7 +1795,7 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
-<span class="param-type">string</span>
+<span class="param-type">Promise.&lt;<a href="NoteShort.html">NoteShort</a>></span>
</dd>
@@ -1765,118 +1813,19 @@ if some action needs to happen on only one specific instance.
- <h4 class="name" id="getNotes"><span class="type-signature"></span>getNotes<span class="signature">(noteIds, silentNotFoundError<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="NoteShort.html">NoteShort</a>>>}</span></h4>
-
-
-
-
-
-
-<div class="description">
- Returns list of notes. If note is missing from cache, it's loaded.
-
-This is often used to bulk-fill the cache with notes which would have to be picked one by one
-otherwise (by e.g. createNoteLink())
-</div>
-
-
-
-
-
-
-
-
-
- <h5>Parameters:</h5>
-
-
-<table class="params">
- <thead>
- <tr>
-
- <th>Name</th>
-
-
- <th>Type</th>
-
-
- <th>Attributes</th>
-
-
-
-
- <th class="last">Description</th>
- </tr>
- </thead>
-
- <tbody>
+ <h4 class="name" id="getDefaultCodeMimeTypes"><span class="type-signature"></span>getDefaultCodeMimeTypes<span class="signature">()</span><span class="type-signature"> &rarr; {array}</span></h4>
- <tr>
-
- <td class="name"><code>noteIds</code></td>
-
-
- <td class="type">
-
-
-<span class="param-type">Array.&lt;string></span>
-
-
-
- </td>
-
-
- <td class="attributes">
-
-
-
-
-
- </td>
-
-
-
-
- <td class="description last"></td>
- </tr>
-
- <tr>
-
- <td class="name"><code>silentNotFoundError</code></td>
-
-
- <td class="type">
-
-
-<span class="param-type">boolean</span>
-
- </td>
-
- <td class="attributes">
-
- &lt;optional><br>
-
-
-
- </td>
-
-
- <td class="description last">don't report error if the note is not found</td>
- </tr>
-
- </tbody>
-</table>
@@ -1912,7 +1861,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line144">line 144</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line266">line 266</a>
</li></ul></dd>
@@ -1938,6 +1887,10 @@ otherwise (by e.g. createNoteLink())
<h5>Returns:</h5>
+<div class="param-desc">
+ list of default code mime types
+</div>
+
<dl>
@@ -1946,7 +1899,7 @@ otherwise (by e.g. createNoteLink())
</dt>
<dd>
-<span class="param-type">Promise.&lt;Array.&lt;<a href="NoteShort.html">NoteShort</a>>></span>
+<span class="param-type">array</span>
</dd>
@@ -1964,7 +1917,7 @@ otherwise (by e.g. createNoteLink())
- <h4 class="name" id="isNoteStillActive"><span class="type-signature"></span>isNoteStillActive<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
+ <h4 class="name" id="getInstanceName"><span class="type-signature"></span>getInstanceName<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
@@ -1972,10 +1925,8 @@ otherwise (by e.g. createNoteLink())
<div class="description">
- This method checks whether user navigated away from the note from which the scripts has been started.
-This is necessary because script execution is async and by the time it is finished, the user might have
-already navigated away from this page - the end result would be that script might return data for the wrong
-note.
+ Instance name identifies particular Trilium instance. It can be useful for scripts
+if some action needs to happen on only one specific instance.
</div>
@@ -2019,7 +1970,7 @@ note.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line222">line 222</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line176">line 176</a>
</li></ul></dd>
@@ -2045,10 +1996,6 @@ note.
<h5>Returns:</h5>
-<div class="param-desc">
- returns true if the original note is still loaded, false if user switched to another
-</div>
-
<dl>
@@ -2057,7 +2004,7 @@ note.
</dt>
<dd>
-<span class="param-type">boolean</span>
+<span class="param-type">string</span>
</dd>
@@ -2075,13 +2022,17 @@ note.
- <h4 class="name" id="onNoteChange"><span class="type-signature"></span>onNoteChange<span class="signature">(func)</span><span class="type-signature"></span></h4>
+ <h4 class="name" id="getMonthNote"><span class="type-signature"></span>getMonthNote<span class="signature">(month)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="NoteShort.html">NoteShort</a>>}</span></h4>
+<div class="description">
+ Returns month-note. If it doesn't exist, it is automatically created.
+</div>
+
@@ -2115,13 +2066,13 @@ note.
<tr>
- <td class="name"><code>func</code></td>
+ <td class="name"><code>month</code></td>
<td class="type">
-<span class="param-type">function</span>
+<span class="param-type">string</span>
@@ -2131,7 +2082,7 @@ note.
- <td class="description last">callback called on note change as user is typing (not necessarily tied to save event)</td>
+ <td class="description last">e.g. "2019-04"</td>
</tr>
@@ -2172,7 +2123,7 @@ note.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line230">line 230</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line315">line 315</a>
</li></ul></dd>
@@ -2195,6 +2146,24 @@ note.
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise.&lt;<a href="NoteShort.html">NoteShort</a>></span>
+
+
+ </dd>
+</dl>
+
+
@@ -2206,13 +2175,18 @@ note.
- <h4 class="name" id="parseDate"><span class="type-signature"></span>parseDate<span class="signature">(str)</span><span class="type-signature"> &rarr; {Date}</span></h4>
+ <h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">(noteId)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="NoteShort.html">NoteShort</a>>}</span></h4>
+<div class="description">
+ Returns note by given noteId. If note is missing from cache, it's loaded.
+*
+</div>
+
@@ -2246,7 +2220,7 @@ note.
<tr>
- <td class="name"><code>str</code></td>
+ <td class="name"><code>noteId</code></td>
<td class="type">
@@ -2303,7 +2277,7 @@ note.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line166">line 166</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line144">line 144</a>
</li></ul></dd>
@@ -2329,10 +2303,6 @@ note.
<h5>Returns:</h5>
-<div class="param-desc">
- parsed object
-</div>
-
<dl>
@@ -2341,7 +2311,7 @@ note.
</dt>
<dd>
-<span class="param-type">Date</span>
+<span class="param-type">Promise.&lt;<a href="NoteShort.html">NoteShort</a>></span>
</dd>
@@ -2359,14 +2329,19 @@ note.
- <h4 class="name" id="protectActiveNote"><span class="type-signature"></span>protectActiveNote<span class="signature">()</span><span class="type-signature"></span></h4>
+ <h4 class="name" id="getNotes"><span class="type-signature"></span>getNotes<span class="signature">(noteIds, silentNotFoundError<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="NoteShort.html">NoteShort</a>>>}</span></h4>
+<div class="description">
+ Returns list of notes. If note is missing from cache, it's loaded.
+This is often used to bulk-fill the cache with notes which would have to be picked one by one
+otherwise (by e.g. createNoteLink())
+</div>
@@ -2376,27 +2351,121 @@ note.
-
-
-<dl class="details">
-
+ <h5>Parameters:</h5>
-
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
-
+ <th>Type</th>
-
+
+ <th>Attributes</th>
+
-
+
-
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+ <tbody>
-
+ <tr>
+
+ <td class="name"><code>noteIds</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">Array.&lt;string></span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+
+
+
+
+ </td>
+
+
+
+
+ <td class="description last"></td>
+ </tr>
+
+
+
+ <tr>
+
+ <td class="name"><code>silentNotFoundError</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">boolean</span>
+
+
+
+ </td>
+
+
+ <td class="attributes">
+
+ &lt;optional><br>
+
+
+
+
+
+ </td>
+
+
+
+
+ <td class="description last">don't report error if the note is not found</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
-
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2407,7 +2476,7 @@ note.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line259">line 259</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line156">line 156</a>
</li></ul></dd>
@@ -2430,6 +2499,24 @@ note.
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise.&lt;Array.&lt;<a href="NoteShort.html">NoteShort</a>>></span>
+
+
+ </dd>
+</dl>
+
+
@@ -2441,7 +2528,7 @@ note.
- <h4 class="name" id="refreshTree"><span class="type-signature"></span>refreshTree<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;void>}</span></h4>
+ <h4 class="name" id="getTodayNote"><span class="type-signature"></span>getTodayNote<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="NoteShort.html">NoteShort</a>>}</span></h4>
@@ -2449,7 +2536,7 @@ note.
<div class="description">
- Refresh tree
+ Returns date-note for today. If it doesn't exist, it is automatically created.
</div>
@@ -2493,7 +2580,7 @@ note.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line190">line 190</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line297">line 297</a>
</li></ul></dd>
@@ -2527,7 +2614,160 @@ note.
</dt>
<dd>
-<span class="param-type">Promise.&lt;void></span>
+<span class="param-type">Promise.&lt;<a href="NoteShort.html">NoteShort</a>></span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="getYearNote"><span class="type-signature"></span>getYearNote<span class="signature">(year)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="NoteShort.html">NoteShort</a>>}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ Returns year-note. If it doesn't exist, it is automatically created.
+</div>
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>year</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">e.g. "2019"</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line324">line 324</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise.&lt;<a href="NoteShort.html">NoteShort</a>></span>
</dd>
@@ -2541,6 +2781,849 @@ note.
+
+
+
+
+ <h4 class="name" id="isNoteStillActive"><span class="type-signature"></span>isNoteStillActive<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ This method checks whether user navigated away from the note from which the scripts has been started.
+This is necessary because script execution is async and by the time it is finished, the user might have
+already navigated away from this page - the end result would be that script might return data for the wrong
+note.
+</div>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line252">line 252</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+<div class="param-desc">
+ returns true if the original note is still loaded, false if user switched to another
+</div>
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">boolean</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="onNoteChange"><span class="type-signature"></span>onNoteChange<span class="signature">(func)</span><span class="type-signature"></span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>func</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">function</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last">callback called on note change as user is typing (not necessarily tied to save event)</td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line260">line 260</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="parseDate"><span class="type-signature"></span>parseDate<span class="signature">(str)</span><span class="type-signature"> &rarr; {Date}</span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>str</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last"></td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line190">line 190</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+<div class="param-desc">
+ parsed object
+</div>
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Date</span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="protectActiveNote"><span class="type-signature"></span>protectActiveNote<span class="signature">()</span><span class="type-signature"></span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line289">line 289</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="refreshTree"><span class="type-signature"></span>refreshTree<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;void>}</span></h4>
+
+
+
+
+
+
+<div class="description">
+ Refresh tree
+</div>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line214">line 214</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h5>Returns:</h5>
+
+
+
+
+<dl>
+ <dt>
+ Type
+ </dt>
+ <dd>
+
+<span class="param-type">Promise.&lt;void></span>
+
+
+ </dd>
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="reloadChildren"><span class="type-signature"></span>reloadChildren<span class="signature">(noteId)</span><span class="type-signature"></span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>noteId</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last"></td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line162">line 162</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h4 class="name" id="reloadParents"><span class="type-signature"></span>reloadParents<span class="signature">(noteId)</span><span class="type-signature"></span></h4>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h5>Parameters:</h5>
+
+
+<table class="params">
+ <thead>
+ <tr>
+
+ <th>Name</th>
+
+
+ <th>Type</th>
+
+
+
+
+
+ <th class="last">Description</th>
+ </tr>
+ </thead>
+
+ <tbody>
+
+
+ <tr>
+
+ <td class="name"><code>noteId</code></td>
+
+
+ <td class="type">
+
+
+<span class="param-type">string</span>
+
+
+
+ </td>
+
+
+
+
+
+ <td class="description last"></td>
+ </tr>
+
+
+ </tbody>
+</table>
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line168">line 168</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2670,7 +3753,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line112">line 112</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line116">line 116</a>
</li></ul></dd>
@@ -2823,7 +3906,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line248">line 248</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line278">line 278</a>
</li></ul></dd>
@@ -2954,7 +4037,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line254">line 254</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line284">line 284</a>
</li></ul></dd>
@@ -3089,7 +4172,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line182">line 182</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line206">line 206</a>
</li></ul></dd>
@@ -3224,7 +4307,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line174">line 174</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line198">line 198</a>
</li></ul></dd>
diff --git a/docs/frontend_api/NoteFull.html b/docs/frontend_api/NoteFull.html
index 655bc3f932..50bedd7921 100644
--- a/docs/frontend_api/NoteFull.html
+++ b/docs/frontend_api/NoteFull.html
@@ -199,7 +199,7 @@
-<h4 class="name" id="utcDateCreated"><span class="type-signature"></span>utcDateCreated<span class="type-signature"></span></h4>
+<h4 class="name" id="dateCreated"><span class="type-signature"></span>dateCreated<span class="type-signature"></span></h4>
@@ -257,7 +257,7 @@
-<h4 class="name" id="utcDateModified"><span class="type-signature"></span>utcDateModified<span class="type-signature"></span></h4>
+<h4 class="name" id="dateModified"><span class="type-signature"></span>dateModified<span class="type-signature"></span></h4>
@@ -314,6 +314,122 @@
+
+<h4 class="name" id="utcDateCreated"><span class="type-signature"></span>utcDateCreated<span class="type-signature"></span></h4>
+
+
+
+
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="entities_note_full.js.html">entities/note_full.js</a>, <a href="entities_note_full.js.html#line20">line 20</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
+
+<h4 class="name" id="utcDateModified"><span class="type-signature"></span>utcDateModified<span class="type-signature"></span></h4>
+
+
+
+
+
+
+
+
+
+
+<dl class="details">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <dt class="tag-source">Source:</dt>
+ <dd class="tag-source"><ul class="dummy"><li>
+ <a href="entities_note_full.js.html">entities/note_full.js</a>, <a href="entities_note_full.js.html#line23">line 23</a>
+ </li></ul></dd>
+
+
+
+
+
+
+
+</dl>
+
+
+
+
+
+
+
diff --git a/docs/frontend_api/entities_note_full.js.html b/docs/frontend_api/entities_note_full.js.html
index d052c4b01f..535bbb7c4f 100644
--- a/docs/frontend_api/entities_note_full.js.html
+++ b/docs/frontend_api/entities_note_full.js.html
@@ -38,6 +38,12 @@ class NoteFull extends NoteShort {
/** @param {string} */
this.content = row.content;
+ /** @param {string} */
+ this.dateCreated = row.dateCreated;
+
+ /** @param {string} */
+ this.dateModified = row.dateModified;
+
/** @param {string} */
this.utcDateCreated = row.utcDateCreated;
diff --git a/docs/frontend_api/global.html b/docs/frontend_api/global.html
index 643d96edff..104db4601a 100644
--- a/docs/frontend_api/global.html
+++ b/docs/frontend_api/global.html
@@ -303,7 +303,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
- <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line49">line 49</a>
+ <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line53">line 53</a>
</li></ul></dd>
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html
index 860717d74e..eac242c9ff 100644
--- a/docs/frontend_api/services_frontend_script_api.js.html
+++ b/docs/frontend_api/services_frontend_script_api.js.html
@@ -36,6 +36,7 @@ import noteDetailService from './note_detail.js';
import noteTypeService from './note_type.js';
import noteTooltipService from './note_tooltip.js';
import protectedSessionService from'./protected_session.js';
+import dateNotesService from'./date_notes.js';
/**
* This is the main frontend API interface for scripts. It's published in the local "api" object.
@@ -53,6 +54,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
/** @property {object|null} entity whose event triggered this execution */
this.originEntity = originEntity;
+ // to keep consistency with backend API
+ this.dayjs = dayjs;
+
/**
* Activates note in the tree and in the note detail.
*
@@ -159,6 +163,14 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
}
};
+ /**
+ * Returns note by given noteId. If note is missing from cache, it's loaded.
+ **
+ * @param {string} noteId
+ * @return {Promise&lt;NoteShort>}
+ */
+ this.getNote = async noteId => await treeCache.getNote(noteId);
+
/**
* Returns list of notes. If note is missing from cache, it's loaded.
*
@@ -171,6 +183,18 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
*/
this.getNotes = async (noteIds, silentNotFoundError = false) => await treeCache.getNotes(noteIds, silentNotFoundError);
+ /**
+ * @param {string} noteId
+ * @method
+ */
+ this.reloadChildren = async noteId => await treeCache.reloadChildren(noteId);
+
+ /**
+ * @param {string} noteId
+ * @method
+ */
+ this.reloadParents = async noteId => await treeCache.reloadParents(noteId);
+
/**
* Instance name identifies particular Trilium instance. It can be useful for scripts
* if some action needs to happen on only one specific instance.
@@ -238,6 +262,12 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
*/
this.getActiveNote = noteDetailService.getActiveNote;
+ /**
+ * @method
+ * @returns {string} returns note path of active note
+ */
+ this.getActiveNotePath = treeService.getActiveNotePath;
+
/**
* This method checks whether user navigated away from the note from which the scripts has been started.
* This is necessary because script execution is async and by the time it is finished, the user might have
@@ -285,6 +315,41 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
* @method
*/
this.protectActiveNote = protectedSessionService.protectNoteAndSendToServer;
+
+ /**
+ * Returns date-note for today. If it doesn't exist, it is automatically created.
+ *
+ * @method
+ * @return {Promise&lt;NoteShort>}
+ */
+ this.getTodayNote = dateNotesService.getTodayNote;
+
+ /**
+ * Returns date-note. If it doesn't exist, it is automatically created.
+ *
+ * @method
+ * @param {string} date - e.g. "2019-04-29"
+ * @return {Promise&lt;NoteShort>}
+ */
+ this.getDateNote = dateNotesService.getDateNote;
+
+ /**
+ * Returns month-note. If it doesn't exist, it is automatically created.
+ *
+ * @method
+ * @param {string} month - e.g. "2019-04"
+ * @return {Promise&lt;NoteShort>}
+ */
+ this.getMonthNote = dateNotesService.getMonthNote;
+
+ /**
+ * Returns year-note. If it doesn't exist, it is automatically created.
+ *
+ * @method
+ * @param {string} year - e.g. "2019"
+ * @return {Promise&lt;NoteShort>}
+ */
+ this.getYearNote = dateNotesService.getYearNote;
}
export default FrontendScriptApi;</code></pre>
diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js
index a55e39649d..7f63ddca3c 100644
--- a/src/public/javascripts/services/frontend_script_api.js
+++ b/src/public/javascripts/services/frontend_script_api.js
@@ -8,6 +8,7 @@ import noteDetailService from './note_detail.js';
import noteTypeService from './note_type.js';
import noteTooltipService from './note_tooltip.js';
import protectedSessionService from'./protected_session.js';
+import dateNotesService from'./date_notes.js';
/**
* This is the main frontend API interface for scripts. It's published in the local "api" object.
@@ -286,6 +287,41 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
* @method
*/
this.protectActiveNote = protectedSessionService.protectNoteAndSendToServer;
+
+ /**
+ * Returns date-note for today. If it doesn't exist, it is automatically created.
+ *
+ * @method
+ * @return {Promise<NoteShort>}
+ */
+ this.getTodayNote = dateNotesService.getTodayNote;
+
+ /**
+ * Returns date-note. If it doesn't exist, it is automatically created.
+ *
+ * @method
+ * @param {string} date - e.g. "2019-04-29"
+ * @return {Promise<NoteShort>}
+ */
+ this.getDateNote = dateNotesService.getDateNote;
+
+ /**
+ * Returns month-note. If it doesn't exist, it is automatically created.
+ *
+ * @method
+ * @param {string} month - e.g. "2019-04"
+ * @return {Promise<NoteShort>}
+ */
+ this.getMonthNote = dateNotesService.getMonthNote;
+
+ /**
+ * Returns year-note. If it doesn't exist, it is automatically created.
+ *
+ * @method
+ * @param {string} year - e.g. "2019"
+ * @return {Promise<NoteShort>}
+ */
+ this.getYearNote = dateNotesService.getYearNote;
}
export default FrontendScriptApi;
\ No newline at end of file