Compare commits

...

19 Commits

Author SHA1 Message Date
zadam
ef2ade849b release 0.61.15 2023-11-20 23:23:12 +01:00
zadam
88067c071c add api.backupNow() to backend API, closes #4455 2023-11-20 23:14:53 +01:00
zadam
f5018e9820 fix buggy http proxy initialization, closes #4453 2023-11-20 23:03:19 +01:00
zadam
19a10e59e9 fix edit history crossing note activation in canvas, #4437 2023-11-20 22:13:52 +01:00
zadam
23351298c8 fix incorrect syntax/typo, closes #4443 2023-11-16 23:35:50 +01:00
zadam
426a8f75aa fix creating tree cycle by moving clone into another clone, closes #4442 2023-11-16 23:31:33 +01:00
zadam
999cf0d9e3 release 0.61.14 2023-11-16 00:21:34 +01:00
zadam
0afc41060a template LABEL should not be inherited #4349 2023-11-16 00:11:14 +01:00
zadam
0507c46ae9 revert general HTML support 2023-11-13 00:58:55 +01:00
zadam
6515dd7b23 fix assigning extension to attachment export filenames, closes #4415 2023-11-12 23:57:21 +01:00
zadam
5a38bf78e1 fix content renderer of protected canvas/mermaid notes, closes #4414 2023-11-12 23:43:04 +01:00
zadam
4bdb40904f fix loading reference link titles in read-only text notes, closes #4404 2023-11-12 22:57:04 +01:00
zadam
7fc1eb5262 release 0.61.13 2023-11-06 00:21:41 +01:00
zadam
531e9d4aff graceful handling of sync error 2023-11-06 00:15:35 +01:00
zadam
e0d4766c2d fix recursion in the inline image processing 2023-11-05 21:50:08 +01:00
zadam
ab4e83771c fix throwing empty error 2023-11-04 22:53:09 +01:00
zadam
803b6df40c release 0.61.12 2023-11-04 00:16:19 +01:00
zadam
1ebdb0f5e1 emergency disabling of image compression since it appears to make problems in migration to 0.61 2023-11-04 00:10:54 +01:00
zadam
df5951ce46 improve sync debug info 2023-11-04 00:02:31 +01:00
39 changed files with 821 additions and 191 deletions

View File

@@ -3,8 +3,12 @@ module.exports = () => {
const becca = require("../../src/becca/becca");
const cls = require("../../src/services/cls");
const log = require("../../src/services/log");
const sql = require("../../src/services/sql");
cls.init(() => {
// emergency disabling of image compression since it appears to make problems in migration to 0.61
sql.execute(`UPDATE options SET value = 'false' WHERE name = 'compressImages'`);
beccaLoader.load();
for (const note of Object.values(becca.notes)) {

View File

@@ -0,0 +1,2 @@
-- emergency disabling of image compression since it appears to make problems in migration to 0.61
UPDATE options SET value = 'false' WHERE name = 'compressImages';

View File

@@ -1588,7 +1588,7 @@ See addLabel, addRelation for more specific methods.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1333">line 1333</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1327">line 1327</a>
</li></ul></dd>
@@ -1835,7 +1835,7 @@ See addLabel, addRelation for more specific methods.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1354">line 1354</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1348">line 1348</a>
</li></ul></dd>
@@ -2081,7 +2081,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1367">line 1367</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1361">line 1361</a>
</li></ul></dd>
@@ -2316,7 +2316,7 @@ returned.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1452">line 1452</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1446">line 1446</a>
</li></ul></dd>
@@ -2432,7 +2432,7 @@ In the future, this functionality might get more generic and some of the require
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1504">line 1504</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1498">line 1498</a>
</li></ul></dd>
@@ -2653,7 +2653,7 @@ In the future, this functionality might get more generic and some of the require
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1542">line 1542</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1536">line 1536</a>
</li></ul></dd>
@@ -2848,7 +2848,7 @@ In the future, this functionality might get more generic and some of the require
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1174">line 1174</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1168">line 1168</a>
</li></ul></dd>
@@ -4207,7 +4207,7 @@ In the future, this functionality might get more generic and some of the require
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1227">line 1227</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1221">line 1221</a>
</li></ul></dd>
@@ -4386,7 +4386,7 @@ In the future, this functionality might get more generic and some of the require
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1237">line 1237</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1231">line 1231</a>
</li></ul></dd>
@@ -9019,7 +9019,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1196">line 1196</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1190">line 1190</a>
</li></ul></dd>
@@ -11329,7 +11329,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1268">line 1268</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1262">line 1262</a>
</li></ul></dd>
@@ -11435,7 +11435,7 @@ This method can be significantly faster than the getAttribute()
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1246">line 1246</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1240">line 1240</a>
</li></ul></dd>
@@ -12675,7 +12675,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1312">line 1312</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1306">line 1306</a>
</li></ul></dd>
@@ -12855,7 +12855,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1428">line 1428</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1422">line 1422</a>
</li></ul></dd>
@@ -13035,7 +13035,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1436">line 1436</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1430">line 1430</a>
</li></ul></dd>
@@ -13182,7 +13182,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<h4 class="name" id="saveAttachment"><span class="type-signature"></span>saveAttachment<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="BAttachment.html">BAttachment</a>}</span></h4>
<h4 class="name" id="saveAttachment"><span class="type-signature"></span>saveAttachment<span class="signature">(matchBy)</span><span class="type-signature"> &rarr; {<a href="BAttachment.html">BAttachment</a>}</span></h4>
@@ -13197,6 +13197,64 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>matchBy</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="default">
attachmentId
</td>
<td class="description last">choose by which property we detect if to update an existing attachment.
Supported values are either 'attachmentId' (default) or 'title'</td>
</tr>
</tbody>
</table>
@@ -13230,7 +13288,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1640">line 1640</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1636">line 1636</a>
</li></ul></dd>
@@ -13332,7 +13390,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1596">line 1596</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1590">line 1590</a>
</li></ul></dd>
@@ -13564,7 +13622,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1281">line 1281</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1275">line 1275</a>
</li></ul></dd>
@@ -14023,7 +14081,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1412">line 1412</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1406">line 1406</a>
</li></ul></dd>
@@ -14183,7 +14241,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1420">line 1420</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1414">line 1414</a>
</li></ul></dd>
@@ -14425,7 +14483,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1379">line 1379</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1373">line 1373</a>
</li></ul></dd>
@@ -14636,7 +14694,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1395">line 1395</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1389">line 1389</a>
</li></ul></dd>
@@ -14847,7 +14905,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1404">line 1404</a>
<a href="becca_entities_bnote.js.html">becca/entities/bnote.js</a>, <a href="becca_entities_bnote.js.html#line1398">line 1398</a>
</li></ul></dd>

View File

@@ -94,7 +94,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line30">line 30</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line31">line 31</a>
</li></ul></dd>
@@ -240,7 +240,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line594">line 594</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line602">line 602</a>
</li></ul></dd>
@@ -352,7 +352,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line46">line 46</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line47">line 47</a>
</li></ul></dd>
@@ -462,7 +462,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line34">line 34</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line35">line 35</a>
</li></ul></dd>
@@ -572,7 +572,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line48">line 48</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line49">line 49</a>
</li></ul></dd>
@@ -682,7 +682,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line36">line 36</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line37">line 37</a>
</li></ul></dd>
@@ -792,7 +792,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line438">line 438</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line439">line 439</a>
</li></ul></dd>
@@ -902,7 +902,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line32">line 32</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line33">line 33</a>
</li></ul></dd>
@@ -1012,7 +1012,7 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line50">line 50</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line51">line 51</a>
</li></ul></dd>
@@ -1040,6 +1040,161 @@ available in the JS backend notes. You can use e.g. <code>api.log(api.startNote.
<h4 class="name" id="backupNow"><span class="type-signature"></span>backupNow<span class="signature">(backupName)</span><span class="type-signature"> &rarr; {Promise}</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>backupName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">If the backupName is e.g. "now", then the backup will be written to "backup-now.db" file</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line595">line 595</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
- resolves once the backup is finished
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="createDataNote"><span class="type-signature"></span>createDataNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> &rarr; {Object}</span></h4>
@@ -1188,7 +1343,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line199">line 199</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line200">line 200</a>
</li></ul></dd>
@@ -1691,7 +1846,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line222">line 222</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line223">line 223</a>
</li></ul></dd>
@@ -2311,7 +2466,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line242">line 242</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line243">line 243</a>
</li></ul></dd>
@@ -2817,7 +2972,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line465">line 465</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line466">line 466</a>
</li></ul></dd>
@@ -3018,7 +3173,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line182">line 182</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line183">line 183</a>
</li></ul></dd>
@@ -3200,7 +3355,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line159">line 159</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line160">line 160</a>
</li></ul></dd>
@@ -3401,7 +3556,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line149">line 149</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line150">line 150</a>
</li></ul></dd>
@@ -3552,7 +3707,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line426">line 426</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line427">line 427</a>
</li></ul></dd>
@@ -3753,7 +3908,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line531">line 531</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line532">line 532</a>
</li></ul></dd>
@@ -3855,7 +4010,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line444">line 444</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line445">line 445</a>
</li></ul></dd>
@@ -4013,7 +4168,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line79">line 79</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line80">line 80</a>
</li></ul></dd>
@@ -4167,7 +4322,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line72">line 72</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line73">line 73</a>
</li></ul></dd>
@@ -4368,7 +4523,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line325">line 325</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line326">line 326</a>
</li></ul></dd>
@@ -4478,7 +4633,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line58">line 58</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line59">line 59</a>
</li></ul></dd>
@@ -4679,7 +4834,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line356">line 356</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line357">line 357</a>
</li></ul></dd>
@@ -4833,7 +4988,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line65">line 65</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line66">line 66</a>
</li></ul></dd>
@@ -5034,7 +5189,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line138">line 138</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line139">line 139</a>
</li></ul></dd>
@@ -5235,7 +5390,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line128">line 128</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line129">line 129</a>
</li></ul></dd>
@@ -5341,7 +5496,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line315">line 315</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line316">line 316</a>
</li></ul></dd>
@@ -5511,7 +5666,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line334">line 334</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line335">line 335</a>
</li></ul></dd>
@@ -5814,7 +5969,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line346">line 346</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line347">line 347</a>
</li></ul></dd>
@@ -6015,7 +6170,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line366">line 366</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line367">line 367</a>
</li></ul></dd>
@@ -6168,7 +6323,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line288">line 288</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line289">line 289</a>
</li></ul></dd>
@@ -6323,7 +6478,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_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line419">line 419</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line420">line 420</a>
</li></ul></dd>
@@ -6508,7 +6663,7 @@ instances execute the given function.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line544">line 544</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line545">line 545</a>
</li></ul></dd>
@@ -6672,7 +6827,7 @@ you need to make some DB changes, you need to surround your call with api.transa
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line587">line 587</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line588">line 588</a>
</li></ul></dd>
@@ -6875,7 +7030,7 @@ you need to make some DB changes, you need to surround your call with api.transa
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line114">line 114</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line115">line 115</a>
</li></ul></dd>
@@ -7077,7 +7232,7 @@ you need to make some DB changes, you need to surround your call with api.transa
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line90">line 90</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line91">line 91</a>
</li></ul></dd>
@@ -7286,7 +7441,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line400">line 400</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line401">line 401</a>
</li></ul></dd>
@@ -7629,7 +7784,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line380">line 380</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line381">line 381</a>
</li></ul></dd>
@@ -7853,7 +8008,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line171">line 171</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line172">line 172</a>
</li></ul></dd>
@@ -8009,7 +8164,7 @@ exists, then we'll use that transaction.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line410">line 410</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line411">line 411</a>
</li></ul></dd>
@@ -8164,7 +8319,7 @@ exists, then we'll use that transaction.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line433">line 433</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line434">line 434</a>
</li></ul></dd>

View File

@@ -1184,14 +1184,8 @@ class BNote extends AbstractBeccaEntity {
/** @returns {BAttachment} */
getAttachmentByTitle(title) {
return sql.getRows(`
SELECT attachments.*
FROM attachments
WHERE ownerId = ?
AND title = ?
AND isDeleted = 0
ORDER BY position`, [this.noteId, title])
.map(row => new BAttachment(row))[0];
// cannot use SQL to filter by title since it can be encrypted
return this.getAttachments().filter(attachment => attachment.title === title)[0];
}
/**
@@ -1663,24 +1657,32 @@ class BNote extends AbstractBeccaEntity {
}
/**
* @param {string} matchBy - choose by which property we detect if to update an existing attachment.
* Supported values are either 'attachmentId' (default) or 'title'
* @returns {BAttachment}
*/
saveAttachment({attachmentId, role, mime, title, content, position}) {
saveAttachment({attachmentId, role, mime, title, content, position}, matchBy = 'attachmentId') {
if (!['attachmentId', 'title'].includes(matchBy)) {
throw new Error(`Unsupported value '${matchBy}' for matchBy param, has to be either 'attachmentId' or 'title'.`);
}
let attachment;
if (attachmentId) {
if (matchBy === 'title') {
attachment = this.getAttachmentByTitle(title);
} else if (matchBy === 'attachmentId' &amp;&amp; attachmentId) {
attachment = this.becca.getAttachmentOrThrow(attachmentId);
} else {
attachment = new BAttachment({
ownerId: this.noteId,
title,
role,
mime,
isProtected: this.isProtected,
position
});
}
attachment = attachment || new BAttachment({
ownerId: this.noteId,
title,
role,
mime,
isProtected: this.isProtected,
position
});
content = content || "";
attachment.setContent(content, {forceSave: true});

View File

@@ -185,14 +185,8 @@ class BRevision extends AbstractBeccaEntity {
/** @returns {BAttachment} */
getAttachmentByTitle(title) {
return sql.getRows(`
SELECT attachments.*
FROM attachments
WHERE ownerId = ?
AND title = ?
AND isDeleted = 0
ORDER BY position`, [this.revisionId, title])
.map(row => new BAttachment(row))[0];
// cannot use SQL to filter by title since it can be encrypted
return this.getAttachments().filter(attachment => attachment.title === title)[0];
}
beforeSaving() {

View File

@@ -47,7 +47,8 @@ const SpacedUpdate = require("./spaced_update");
const specialNotesService = require("./special_notes");
const branchService = require("./branches");
const exportService = require("./export/zip");
const syncMutex = require("./sync_mutex.js");
const syncMutex = require("./sync_mutex");
const backupService = require("./backup");
/**
* &lt;p>This is the main backend API interface for scripts. All the properties and methods are published in the "api" object
@@ -614,6 +615,13 @@ function BackendScriptApi(currentNote, apiParams) {
*/
this.runOutsideOfSync = syncMutex.doExclusively;
/**
* @method
* @param {string} backupName - If the backupName is e.g. "now", then the backup will be written to "backup-now.db" file
* @returns {Promise} - resolves once the backup is finished
*/
this.backupNow = backupService.backupNow;
/**
* This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.
*

View File

@@ -912,7 +912,7 @@ and relation (representing named relationship between source and target note)</d
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -1124,7 +1124,7 @@ parents.</div>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -6570,7 +6570,7 @@
<h4 class="name" id="getSortedNotePathRecords"><span class="type-signature"></span>getSortedNotePathRecords<span class="signature">(hoistedNoteId<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;{isArchived: boolean, isInHoistedSubTree: boolean, isSearch: boolean, notePath: Array.&lt;string>, isHidden: boolean}>}</span></h4>
<h4 class="name" id="getSortedNotePathRecords"><span class="type-signature"></span>getSortedNotePathRecords<span class="signature">(hoistedNoteId<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;{isArchived: boolean, isInHoistedSubTree: boolean, isSearch: boolean, <a href="global.html#notePath">notePath</a>: Array.&lt;string>, isHidden: boolean}>}</span></h4>
@@ -6723,7 +6723,7 @@
</dt>
<dd>
<span class="param-type">Array.&lt;{isArchived: boolean, isInHoistedSubTree: boolean, isSearch: boolean, notePath: Array.&lt;string>, isHidden: boolean}></span>
<span class="param-type">Array.&lt;{isArchived: boolean, isInHoistedSubTree: boolean, isSearch: boolean, <a href="global.html#notePath">notePath</a>: Array.&lt;string>, isHidden: boolean}></span>
</dd>
@@ -8690,7 +8690,7 @@
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -293,7 +293,7 @@ available in the JS frontend notes. You can use e.g. <code>api.showMessage(api.s
<td class="type">
<span class="param-type">BasicWidget</span>
<span class="param-type"><a href="BasicWidget.html">BasicWidget</a></span>
@@ -8356,7 +8356,7 @@ Typical use case is when a new note has been created, we should wait until it is
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -80,7 +80,7 @@ export default FAttachment;
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -116,7 +116,7 @@ export default FAttribute;
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -75,7 +75,7 @@
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -100,7 +100,7 @@ export default FBranch;
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -1021,7 +1021,7 @@ export default FNote;
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -94,6 +94,242 @@
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="hoistedNoteId"><span class="type-signature"></span>hoistedNoteId<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="widgets_note_context_aware_widget.js.html">widgets/note_context_aware_widget.js</a>, <a href="widgets_note_context_aware_widget.js.html#line38">line 38</a>
</li></ul></dd>
</dl>
<h4 class="name" id="note"><span class="type-signature"></span>note<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="widgets_note_context_aware_widget.js.html">widgets/note_context_aware_widget.js</a>, <a href="widgets_note_context_aware_widget.js.html#line23">line 23</a>
</li></ul></dd>
</dl>
<h4 class="name" id="noteId"><span class="type-signature"></span>noteId<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="widgets_note_context_aware_widget.js.html">widgets/note_context_aware_widget.js</a>, <a href="widgets_note_context_aware_widget.js.html#line28">line 28</a>
</li></ul></dd>
</dl>
<h4 class="name" id="notePath"><span class="type-signature"></span>notePath<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="widgets_note_context_aware_widget.js.html">widgets/note_context_aware_widget.js</a>, <a href="widgets_note_context_aware_widget.js.html#line33">line 33</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
@@ -322,6 +558,157 @@
<h4 class="name" id="refreshWithNote"><span class="type-signature">(async) </span>refreshWithNote<span class="signature">(note)</span><span class="type-signature"> &rarr; {Promise.&lt;void>}</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>note</code></td>
<td class="type">
<span class="param-type"><a href="FNote.html">FNote</a></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="widgets_note_context_aware_widget.js.html">widgets/note_context_aware_widget.js</a>, <a href="widgets_note_context_aware_widget.js.html#line64">line 64</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;void></span>
</dd>
</dl>
@@ -337,7 +724,7 @@
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -50,7 +50,7 @@
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

View File

@@ -601,7 +601,7 @@ export default FrontendScriptApi;
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li></ul>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FAttribute.html">FAttribute</a></li><li><a href="FBranch.html">FBranch</a></li><li><a href="FNote.html">FNote</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getJsonContent">getJsonContent</a></li><li><a href="global.html#getJsonContentSafely">getJsonContentSafely</a></li><li><a href="global.html#hoistedNoteId">hoistedNoteId</a></li><li><a href="global.html#note">note</a></li><li><a href="global.html#noteId">noteId</a></li><li><a href="global.html#notePath">notePath</a></li><li><a href="global.html#refreshWithNote">refreshWithNote</a></li></ul>
</nav>
<br class="clear">

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

32
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "trilium",
"version": "0.61.10-beta",
"version": "0.61.14",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "trilium",
"version": "0.61.10-beta",
"version": "0.61.14",
"hasInstallScript": true,
"license": "AGPL-3.0-only",
"dependencies": {
@@ -47,7 +47,7 @@
"jimp": "0.22.10",
"joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "22.1.0",
"marked": "9.1.2",
"marked": "9.1.6",
"mime-types": "2.1.35",
"multer": "1.4.5-lts.1",
"node-abi": "3.50.0",
@@ -79,7 +79,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "25.9.2",
"electron": "25.9.5",
"electron-builder": "24.6.4",
"electron-packager": "17.1.2",
"electron-rebuild": "3.2.9",
@@ -4276,9 +4276,9 @@
}
},
"node_modules/electron": {
"version": "25.9.2",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.2.tgz",
"integrity": "sha512-hVBN5rsrL99BKNHvzMeYy2PkAmewuIobu4U3o3EzVz4MDoLmMfW4yTH5GZ4RbJrpokoEky5IzGtRR/ggPzL6Fw==",
"version": "25.9.5",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz",
"integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==",
"hasInstallScript": true,
"dependencies": {
"@electron/get": "^2.0.0",
@@ -9037,9 +9037,9 @@
}
},
"node_modules/marked": {
"version": "9.1.2",
"resolved": "https://registry.npmjs.org/marked/-/marked-9.1.2.tgz",
"integrity": "sha512-qoKMJqK0w6vkLk8+KnKZAH6neUZSNaQqVZ/h2yZ9S7CbLuFHyS2viB0jnqcWF9UKjwsAbMrQtnQhdmdvOVOw9w==",
"version": "9.1.6",
"resolved": "https://registry.npmjs.org/marked/-/marked-9.1.6.tgz",
"integrity": "sha512-jcByLnIFkd5gSXZmjNvS1TlmRhCXZjIzHYlaGkPlLIekG55JDR2Z4va9tZwCiP+/RDERiNhMOFu01xd6O5ct1Q==",
"bin": {
"marked": "bin/marked.js"
},
@@ -16633,9 +16633,9 @@
}
},
"electron": {
"version": "25.9.2",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.2.tgz",
"integrity": "sha512-hVBN5rsrL99BKNHvzMeYy2PkAmewuIobu4U3o3EzVz4MDoLmMfW4yTH5GZ4RbJrpokoEky5IzGtRR/ggPzL6Fw==",
"version": "25.9.5",
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz",
"integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==",
"requires": {
"@electron/get": "^2.0.0",
"@types/node": "^18.11.18",
@@ -20139,9 +20139,9 @@
"requires": {}
},
"marked": {
"version": "9.1.2",
"resolved": "https://registry.npmjs.org/marked/-/marked-9.1.2.tgz",
"integrity": "sha512-qoKMJqK0w6vkLk8+KnKZAH6neUZSNaQqVZ/h2yZ9S7CbLuFHyS2viB0jnqcWF9UKjwsAbMrQtnQhdmdvOVOw9w=="
"version": "9.1.6",
"resolved": "https://registry.npmjs.org/marked/-/marked-9.1.6.tgz",
"integrity": "sha512-jcByLnIFkd5gSXZmjNvS1TlmRhCXZjIzHYlaGkPlLIekG55JDR2Z4va9tZwCiP+/RDERiNhMOFu01xd6O5ct1Q=="
},
"matcher": {
"version": "3.0.0",

View File

@@ -2,7 +2,7 @@
"name": "trilium",
"productName": "Trilium Notes",
"description": "Trilium Notes",
"version": "0.61.11",
"version": "0.61.15",
"license": "AGPL-3.0-only",
"main": "electron.js",
"bin": {
@@ -72,7 +72,7 @@
"jimp": "0.22.10",
"joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "22.1.0",
"marked": "9.1.2",
"marked": "9.1.6",
"mime-types": "2.1.35",
"multer": "1.4.5-lts.1",
"node-abi": "3.50.0",
@@ -101,7 +101,7 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "25.9.2",
"electron": "25.9.5",
"electron-builder": "24.6.4",
"electron-packager": "17.1.2",
"electron-rebuild": "3.2.9",

View File

@@ -1156,14 +1156,8 @@ class BNote extends AbstractBeccaEntity {
/** @returns {BAttachment} */
getAttachmentByTitle(title) {
return sql.getRows(`
SELECT attachments.*
FROM attachments
WHERE ownerId = ?
AND title = ?
AND isDeleted = 0
ORDER BY position`, [this.noteId, title])
.map(row => new BAttachment(row))[0];
// cannot use SQL to filter by title since it can be encrypted
return this.getAttachments().filter(attachment => attachment.title === title)[0];
}
/**

View File

@@ -157,14 +157,8 @@ class BRevision extends AbstractBeccaEntity {
/** @returns {BAttachment} */
getAttachmentByTitle(title) {
return sql.getRows(`
SELECT attachments.*
FROM attachments
WHERE ownerId = ?
AND title = ?
AND isDeleted = 0
ORDER BY position`, [this.revisionId, title])
.map(row => new BAttachment(row))[0];
// cannot use SQL to filter by title since it can be encrypted
return this.getAttachments().filter(attachment => attachment.title === title)[0];
}
beforeSaving() {

View File

@@ -268,7 +268,9 @@ function linkContextMenu(e) {
}
async function loadReferenceLinkTitle($el, href = null) {
href = href || $el.find("a").attr("href");
const $link = $el[0].tagName === 'A' ? $el : $el.find("a");
href = href || $link.attr("href");
if (!href) {
console.warn("Empty URL for parsing: " + $el[0].outerHTML);
return;

View File

@@ -172,7 +172,7 @@ if (utils.isElectron()) {
await reportError(arg.method, arg.url, arg.statusCode, arg.body);
}
idToRequestMap[arg.requestId].reject();
idToRequestMap[arg.requestId].reject(new Error(`Server responded with ${arg.statusCode}`));
}
delete idToRequestMap[arg.requestId];

View File

@@ -240,6 +240,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
this.excalidrawRef.current.updateScene(sceneData);
this.excalidrawRef.current.addFiles(fileArray);
this.excalidrawRef.current.history.clear();
}
Promise.all(

View File

@@ -19,14 +19,14 @@ const ValidationError = require("../../errors/validation_error");
function moveBranchToParent(req) {
const {branchId, parentBranchId} = req.params;
const parentBranch = becca.getBranch(parentBranchId);
const branchToMove = becca.getBranch(branchId);
const targetParentBranch = becca.getBranch(parentBranchId);
if (!parentBranch || !branchToMove) {
if (!branchToMove || !targetParentBranch) {
throw new ValidationError(`One or both branches '${branchId}', '${parentBranchId}' have not been found`);
}
return branchService.moveBranchToBranch(branchToMove, parentBranch, branchId);
return branchService.moveBranchToBranch(branchToMove, targetParentBranch, branchId);
}
function moveBranchBeforeNote(req) {

View File

@@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 226;
const APP_DB_VERSION = 227;
const SYNC_VERSION = 31;
const CLIPPER_PROTOCOL_VERSION = "1.0";

View File

@@ -19,7 +19,8 @@ const SpacedUpdate = require("./spaced_update");
const specialNotesService = require("./special_notes");
const branchService = require("./branches");
const exportService = require("./export/zip");
const syncMutex = require("./sync_mutex.js");
const syncMutex = require("./sync_mutex");
const backupService = require("./backup");
/**
* <p>This is the main backend API interface for scripts. All the properties and methods are published in the "api" object
@@ -586,6 +587,13 @@ function BackendScriptApi(currentNote, apiParams) {
*/
this.runOutsideOfSync = syncMutex.doExclusively;
/**
* @method
* @param {string} backupName - If the backupName is e.g. "now", then the backup will be written to "backup-now.db" file
* @returns {Promise} - resolves once the backup is finished
*/
this.backupNow = backupService.backupNow;
/**
* This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.
*

View File

@@ -1,12 +1,12 @@
const treeService = require("./tree");
const sql = require("./sql");
function moveBranchToNote(sourceBranch, targetParentNoteId) {
if (sourceBranch.parentNoteId === targetParentNoteId) {
function moveBranchToNote(branchToMove, targetParentNoteId) {
if (branchToMove.parentNoteId === targetParentNoteId) {
return {success: true}; // no-op
}
const validationResult = treeService.validateParentChild(targetParentNoteId, sourceBranch.noteId, sourceBranch.branchId);
const validationResult = treeService.validateParentChild(targetParentNoteId, branchToMove.noteId, branchToMove.branchId);
if (!validationResult.success) {
return [200, validationResult];
@@ -15,10 +15,10 @@ function moveBranchToNote(sourceBranch, targetParentNoteId) {
const maxNotePos = sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [targetParentNoteId]);
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 10;
const newBranch = sourceBranch.createClone(targetParentNoteId, newNotePos);
const newBranch = branchToMove.createClone(targetParentNoteId, newNotePos);
newBranch.save();
sourceBranch.markAsDeleted();
branchToMove.markAsDeleted();
return {
success: true,
@@ -26,16 +26,18 @@ function moveBranchToNote(sourceBranch, targetParentNoteId) {
};
}
function moveBranchToBranch(sourceBranch, targetParentBranch) {
const res = moveBranchToNote(sourceBranch, targetParentBranch.noteId);
function moveBranchToBranch(branchToMove, targetParentBranch) {
const res = moveBranchToNote(branchToMove, targetParentBranch.noteId);
if (!res.success) {
return res;
}
// expanding so that the new placement of the branch is immediately visible
targetParentBranch.isExpanded = true;
targetParentBranch.save();
if (!targetParentBranch.isExpanded) {
targetParentBranch.isExpanded = true;
targetParentBranch.save();
}
return res;
}

View File

@@ -1 +1 @@
module.exports = { buildDate:"2023-11-03T11:46:53+01:00", buildRevision: "01093d05d7ca1ede0c9af3fe2f5b04969ade816d" };
module.exports = { buildDate:"2023-11-20T23:23:12+01:00", buildRevision: "88067c071c37354df23487a3e2a38d8ee20a7d1b" };

View File

@@ -75,15 +75,14 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true)
* @return {string}
*/
function getDataFileName(type, mime, baseFileName, existingFileNames) {
let fileName = baseFileName;
let fileName = baseFileName.trim();
if (fileName.length > 30) {
fileName = fileName.substr(0, 30).trim();
}
let existingExtension = path.extname(fileName).toLowerCase();
let newExtension;
if (fileName.length > 30) {
fileName = fileName.substr(0, 30);
}
// the following two are handled specifically since we always want to have these extensions no matter the automatic detection
// and/or existing detected extensions in the note name
if (type === 'text' && format === 'markdown') {
@@ -108,7 +107,7 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true)
}
}
// if the note is already named with extension (e.g. "jquery"), then it's silly to append the exact same extension again
// if the note is already named with the extension (e.g. "image.jpg"), then it's silly to append the exact same extension again
if (newExtension && existingExtension !== `.${newExtension.toLowerCase()}`) {
fileName += `.${newExtension}`;
}

View File

@@ -148,8 +148,16 @@ function saveImageToAttachment(noteId, uploadBuffer, originalName, shrinkImageSw
title: fileName
});
const noteService = require("../services/notes");
noteService.asyncPostProcessContent(note, note.getContent()); // to mark an unused attachment for deletion
// TODO: this is a quick-fix solution of a recursive bug - this is called from asyncPostProcessContent()
// find some async way to do this - perhaps some global timeout with a Set of noteIds needing one more
// run of asyncPostProcessContent
setTimeout(() => {
sql.transactional(() => {
const note = becca.getNoteOrThrow(noteId);
const noteService = require("../services/notes");
noteService.asyncPostProcessContent(note, note.getContent()); // to mark an unused attachment for deletion
});
}, 5000);
// resizing images asynchronously since JIMP does not support sync operation
processImage(uploadBuffer, originalName, shrinkImageSwitch).then(({buffer, imageFormat}) => {

View File

@@ -160,6 +160,8 @@ function getImage(imageUrl) {
});
}
const HTTP = 'http:', HTTPS = 'https:';
function getProxyAgent(opts) {
if (!opts.proxy) {
return null;
@@ -167,15 +169,15 @@ function getProxyAgent(opts) {
const {protocol} = url.parse(opts.url);
if (protocol === 'http:' || protocol === 'https:') {
const protoNoColon = protocol.substr(0, protocol.length - 1);
const AgentClass = require(`${protoNoColon}-proxy-agent`);
return new AgentClass(opts.proxy);
}
else {
if (![HTTP, HTTPS].includes(protocol)) {
return null;
}
const AgentClass = HTTP === protocol
? require("http-proxy-agent").HttpProxyAgent
: require("https-proxy-agent").HttpsProxyAgent;
return new AgentClass(opts.proxy);
}
function getClient(opts) {

View File

@@ -10,6 +10,8 @@ class AttributeExistsExp extends Expression {
this.attributeType = attributeType;
this.attributeName = attributeName;
// template attr is used as a marker for templates, but it's not meant to be inherited
this.isTemplateLabel = this.attributeType === 'label' && (this.attributeName === 'template' || this.attributeName === 'workspacetemplate');
this.prefixMatch = prefixMatch;
}
@@ -23,12 +25,10 @@ class AttributeExistsExp extends Expression {
for (const attr of attrs) {
const note = attr.note;
if (attr.isInheritable) {
if (attr.isInheritable && !this.isTemplateLabel) {
resultNoteSet.addAll(note.getSubtreeNotesIncludingTemplated());
}
else if (note.isInherited() &&
// template attr is used as a marker for templates, but it's not meant to be inherited
!(this.attributeType === 'label' && (this.attributeName === 'template' || this.attributeName === 'workspacetemplate'))) {
else if (note.isInherited() && !this.isTemplateLabel) {
resultNoteSet.addAll(note.getInheritingNotes());
}
else {

View File

@@ -292,7 +292,9 @@ async function syncRequest(syncContext, method, requestPath, body) {
return response;
}
function getEntityChangeRow(entityName, entityId) {
function getEntityChangeRow(entityChange) {
const {entityName, entityId} = entityChange;
if (entityName === 'note_reordering') {
return sql.getMap("SELECT branchId, notePosition FROM branches WHERE parentNoteId = ? AND isDeleted = 0", [entityId]);
}
@@ -300,13 +302,14 @@ function getEntityChangeRow(entityName, entityId) {
const primaryKey = entityConstructor.getEntityFromEntityName(entityName).primaryKeyName;
if (!primaryKey) {
throw new Error(`Unknown entity '${entityName}'`);
throw new Error(`Unknown entity for entity change ${JSON.stringify(entityChange)}`);
}
const entityRow = sql.getRow(`SELECT * FROM ${entityName} WHERE ${primaryKey} = ?`, [entityId]);
if (!entityRow) {
throw new Error(`Entity ${entityName} '${entityId}' not found.`);
log.error(`Cannot find entity for entity change ${JSON.stringify(entityChange)}`);
return null;
}
if (entityName === 'blobs' && entityRow.content !== null) {
@@ -332,7 +335,10 @@ function getEntityChangeRecords(entityChanges) {
continue;
}
const entity = getEntityChangeRow(entityChange.entityName, entityChange.entityId);
const entity = getEntityChangeRow(entityChange);
if (!entity) {
continue;
}
const record = { entityChange, entity };

View File

@@ -8,7 +8,7 @@ const becca = require('../becca/becca');
function validateParentChild(parentNoteId, childNoteId, branchId = null) {
if (['root', '_hidden', '_share', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(childNoteId)) {
return { branch: null, success: false, message: `Cannot change this note's location.`};
return { branch: null, success: false, message: `Cannot change this note's location.` };
}
if (parentNoteId === 'none') {
@@ -16,14 +16,14 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
return { branch: null, success: false, message: `Cannot move anything into 'none' parent.` };
}
const existing = becca.getBranchFromChildAndParent(childNoteId, parentNoteId);
const existingBranch = becca.getBranchFromChildAndParent(childNoteId, parentNoteId);
if (existing && (branchId === null || existing.branchId !== branchId)) {
if (existingBranch && existingBranch.branchId !== branchId) {
const parentNote = becca.getNote(parentNoteId);
const childNote = becca.getNote(childNoteId);
return {
branch: existing,
branch: existingBranch,
success: false,
message: `Note "${childNote.title}" note already exists in the "${parentNote.title}".`
};
@@ -52,6 +52,10 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
* Tree cycle can be created when cloning or when moving existing clone. This method should detect both cases.
*/
function wouldAddingBranchCreateCycle(parentNoteId, childNoteId) {
if (parentNoteId === childNoteId) {
return true;
}
const childNote = becca.getNote(childNoteId);
const parentNote = becca.getNote(parentNoteId);