From 602b9ae64a8f0f99eea993ef9d7813b6a8084845 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 23 Sep 2023 00:04:32 +0200 Subject: [PATCH] API docs --- docs/backend_api/BAttachment.html | 6 +- docs/backend_api/BNote.html | 479 +++++++----- .../becca_entities_battachment.js.html | 7 +- docs/backend_api/becca_entities_bnote.js.html | 46 +- docs/backend_api/services_sql.js.html | 4 +- docs/frontend_api/FAttribute.html | 2 +- docs/frontend_api/FBranch.html | 2 +- docs/frontend_api/FNote.html | 188 +++-- docs/frontend_api/FrontendScriptApi.html | 680 ++++++++++++++++-- .../frontend_api/entities_fattachment.js.html | 2 +- docs/frontend_api/entities_fattribute.js.html | 2 +- docs/frontend_api/entities_fblob.js.html | 23 +- docs/frontend_api/entities_fbranch.js.html | 2 +- docs/frontend_api/entities_fnote.js.html | 12 +- docs/frontend_api/index.html | 2 +- .../services_frontend_script_api.js.html | 37 +- 16 files changed, 1183 insertions(+), 311 deletions(-) diff --git a/docs/backend_api/BAttachment.html b/docs/backend_api/BAttachment.html index 985ee21e9..50e40c1e3 100644 --- a/docs/backend_api/BAttachment.html +++ b/docs/backend_api/BAttachment.html @@ -1388,7 +1388,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -1770,7 +1770,7 @@ larger amounts of data and generally not accessible to the user.
Source:
@@ -2815,7 +2815,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/BNote.html b/docs/backend_api/BNote.html index 6c07103c9..f77a085e5 100644 --- a/docs/backend_api/BNote.html +++ b/docs/backend_api/BNote.html @@ -1588,7 +1588,7 @@ See addLabel, addRelation for more specific methods.
Source:
@@ -1835,7 +1835,7 @@ See addLabel, addRelation for more specific methods.
Source:
@@ -2081,7 +2081,7 @@ returned.
Source:
@@ -2316,7 +2316,7 @@ returned.
Source:
@@ -2432,7 +2432,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -2653,7 +2653,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -2919,7 +2919,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3025,7 +3025,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3127,7 +3127,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3229,7 +3229,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3286,7 +3286,7 @@ In the future, this functionality might get more generic and some of the require -

getAttachmentByRole() → {Array.<BAttachment>}

+

getAttachmentByTitle() → {BAttachment}

@@ -3334,7 +3334,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3370,7 +3370,7 @@ In the future, this functionality might get more generic and some of the require
-Array.<BAttachment> +BAttachment
@@ -3436,7 +3436,109 @@ In the future, this functionality might get more generic and some of the require
Source:
+ + + + + + + + + + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Array.<BAttachment> + + +
+
+ + + + + + + + + + + + + +

getAttachmentsByRole() → {Array.<BAttachment>}

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -3610,7 +3712,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3789,7 +3891,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -3997,7 +4099,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4176,7 +4278,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4355,7 +4457,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -4826,108 +4928,6 @@ In the future, this functionality might get more generic and some of the require -

getContentMetadata() → {Object}

- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -Object - - -
-
- - - - - - - - - - - - -

getDescendantNoteIds()

@@ -4978,7 +4978,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5068,7 +5068,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5174,7 +5174,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5281,7 +5281,121 @@ In the future, this functionality might get more generic and some of the require
Source:
+ + + + + + + +
+ + + + + + + + + + + + + +
Throws:
+ + + +
+ + Error in case of invalid JSON + +
+ + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +* + + +
+
+ + + + + + + + + + + + + +

getJsonContentSafely() → {*|null}

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -5309,6 +5423,10 @@ In the future, this functionality might get more generic and some of the require
Returns:
+
+ valid object or null if the content cannot be parsed as JSON +
+
@@ -5318,6 +5436,9 @@ In the future, this functionality might get more generic and some of the require
* +| + +null
@@ -5432,7 +5553,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5590,7 +5711,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5760,7 +5881,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -5927,7 +6048,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -6033,7 +6154,7 @@ In the future, this functionality might get more generic and some of the require
Source:
@@ -6213,7 +6334,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6483,7 +6604,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6638,7 +6759,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6796,7 +6917,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6966,7 +7087,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7133,7 +7254,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7288,7 +7409,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7446,7 +7567,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7616,7 +7737,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8064,7 +8185,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8222,7 +8343,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8392,7 +8513,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8498,7 +8619,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8600,7 +8721,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8709,7 +8830,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8880,7 +9001,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9088,7 +9209,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9190,7 +9311,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9296,7 +9417,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9398,7 +9519,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9589,7 +9710,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9815,7 +9936,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10111,7 +10232,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10340,7 +10461,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10538,7 +10659,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10736,7 +10857,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10934,7 +11055,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11040,7 +11161,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11190,7 +11311,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11296,7 +11417,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11390,7 +11511,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11496,7 +11617,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11602,7 +11723,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11708,7 +11829,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11863,7 +11984,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -11969,7 +12090,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -12077,7 +12198,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -12536,7 +12657,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -12716,7 +12837,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -12896,7 +13017,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13091,7 +13212,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13193,7 +13314,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13425,7 +13546,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13704,7 +13825,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -13884,7 +14005,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14044,7 +14165,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14286,7 +14407,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14497,7 +14618,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -14708,7 +14829,7 @@ This is a low-level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/becca_entities_battachment.js.html b/docs/backend_api/becca_entities_battachment.js.html index 6b55ef905..f76056dfb 100644 --- a/docs/backend_api/becca_entities_battachment.js.html +++ b/docs/backend_api/becca_entities_battachment.js.html @@ -126,7 +126,12 @@ class BAttachment extends AbstractBeccaEntity { } decrypt() { - if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) { + if (!this.isProtected || !this.attachmentId) { + this.isDecrypted = true; + return; + } + + if (!this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) { try { this.title = protectedSessionService.decryptString(this.title); this.isDecrypted = true; diff --git a/docs/backend_api/becca_entities_bnote.js.html b/docs/backend_api/becca_entities_bnote.js.html index 132484866..6ef8952f1 100644 --- a/docs/backend_api/becca_entities_bnote.js.html +++ b/docs/backend_api/becca_entities_bnote.js.html @@ -239,12 +239,9 @@ class BNote extends AbstractBeccaEntity { return this._getContent(); } - /** @returns {{dateModified, utcDateModified}} */ - getContentMetadata() { - return sql.getRow(`SELECT dateModified, utcDateModified FROM blobs WHERE blobId = ?`, [this.blobId]); - } - - /** @returns {*} */ + /** + * @returns {*} + * @throws Error in case of invalid JSON */ getJsonContent() { const content = this.getContent(); @@ -255,6 +252,16 @@ class BNote extends AbstractBeccaEntity { return JSON.parse(content); } + /** @returns {*|null} valid object or null if the content cannot be parsed as JSON */ + getJsonContentSafely() { + try { + return this.getJsonContent(); + } + catch (e) { + return null; + } + } + /** * @param content * @param {object} [opts] @@ -1158,7 +1165,7 @@ class BNote extends AbstractBeccaEntity { } /** @returns {BAttachment[]} */ - getAttachmentByRole(role) { + getAttachmentsByRole(role) { return sql.getRows(` SELECT attachments.* FROM attachments @@ -1169,6 +1176,18 @@ class BNote extends AbstractBeccaEntity { .map(row => new BAttachment(row)); } + /** @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]; + } + /** * Gives all possible note paths leading to this note. Paths containing search note are ignored (could form cycles) * @@ -1599,7 +1618,6 @@ class BNote extends AbstractBeccaEntity { saveRevision() { return sql.transactional(() => { let noteContent = this.getContent(); - const contentMetadata = this.getContentMetadata(); const revision = new BRevision({ noteId: this.noteId, @@ -1608,14 +1626,10 @@ class BNote extends AbstractBeccaEntity { type: this.type, mime: this.mime, isProtected: this.isProtected, - utcDateLastEdited: this.utcDateModified > contentMetadata.utcDateModified - ? this.utcDateModified - : contentMetadata.utcDateModified, + utcDateLastEdited: this.utcDateModified, utcDateCreated: dateUtils.utcNowDateTime(), utcDateModified: dateUtils.utcNowDateTime(), - dateLastEdited: this.dateModified > contentMetadata.dateModified - ? this.dateModified - : contentMetadata.dateModified, + dateLastEdited: this.dateModified, dateCreated: dateUtils.localNowDateTime() }, true); @@ -1638,10 +1652,10 @@ class BNote extends AbstractBeccaEntity { noteContent = noteContent.replaceAll(new RegExp(`href="[^"]*attachmentId=${noteAttachment.attachmentId}[^"]*"`, 'gi'), `href="api/attachments/${revisionAttachment.attachmentId}/download"`); } - - revision.setContent(noteContent, {forceSave: true}); } + revision.setContent(noteContent); + return revision; }); } diff --git a/docs/backend_api/services_sql.js.html b/docs/backend_api/services_sql.js.html index 29891f533..828fcd8f3 100644 --- a/docs/backend_api/services_sql.js.html +++ b/docs/backend_api/services_sql.js.html @@ -54,7 +54,7 @@ const LOG_ALL_QUERIES = false; }); function insert(tableName, rec, replace = false) { - const keys = Object.keys(rec); + const keys = Object.keys(rec || {}); if (keys.length === 0) { log.error(`Can't insert empty object into table ${tableName}`); return; @@ -81,7 +81,7 @@ function replace(tableName, rec) { } function upsert(tableName, primaryKey, rec) { - const keys = Object.keys(rec); + const keys = Object.keys(rec || {}); if (keys.length === 0) { log.error(`Can't upsert empty object into table ${tableName}`); return; diff --git a/docs/frontend_api/FAttribute.html b/docs/frontend_api/FAttribute.html index 7d05e5b0a..895648571 100644 --- a/docs/frontend_api/FAttribute.html +++ b/docs/frontend_api/FAttribute.html @@ -912,7 +912,7 @@ and relation (representing named relationship between source and target note)
diff --git a/docs/frontend_api/FBranch.html b/docs/frontend_api/FBranch.html index 6bb8f4f3c..3220829d1 100644 --- a/docs/frontend_api/FBranch.html +++ b/docs/frontend_api/FBranch.html @@ -1124,7 +1124,7 @@ parents.
diff --git a/docs/frontend_api/FNote.html b/docs/frontend_api/FNote.html index 770a94b16..3e2ffb611 100644 --- a/docs/frontend_api/FNote.html +++ b/docs/frontend_api/FNote.html @@ -1168,7 +1168,7 @@
Source:
@@ -1274,7 +1274,7 @@
Source:
@@ -1401,6 +1401,108 @@ +
Returns:
+ + + + +
+
+ Type +
+
+ +Promise.<Array.<FAttachment>> + + +
+
+ + + + + + + + + + + + + +

(async) getAttachmentsByRole() → {Promise.<Array.<FAttachment>>}

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
Returns:
@@ -1550,7 +1652,7 @@
Source:
@@ -1728,7 +1830,7 @@
Source:
@@ -1928,7 +2030,7 @@
Source:
@@ -2107,7 +2209,7 @@
Source:
@@ -2286,7 +2388,7 @@
Source:
@@ -2392,7 +2494,7 @@
Source:
@@ -3057,7 +3159,7 @@
Source:
@@ -3212,7 +3314,7 @@
Source:
@@ -3379,7 +3481,7 @@
Source:
@@ -3487,7 +3589,7 @@
Source:
@@ -3589,7 +3691,7 @@
Source:
@@ -3763,7 +3865,7 @@
Source:
@@ -3941,7 +4043,7 @@
Source:
@@ -4141,7 +4243,7 @@
Source:
@@ -4296,7 +4398,7 @@
Source:
@@ -4451,7 +4553,7 @@
Source:
@@ -4618,7 +4720,7 @@
Source:
@@ -4773,7 +4875,7 @@
Source:
@@ -4928,7 +5030,7 @@
Source:
@@ -5095,7 +5197,7 @@
Source:
@@ -5658,7 +5760,7 @@
Source:
@@ -5813,7 +5915,7 @@
Source:
@@ -5983,7 +6085,7 @@
Source:
@@ -6134,7 +6236,7 @@
Source:
@@ -6301,7 +6403,7 @@
Source:
@@ -6407,7 +6509,7 @@
Source:
@@ -6585,7 +6687,7 @@
Source:
@@ -6691,7 +6793,7 @@
Source:
@@ -6797,7 +6899,7 @@
Source:
@@ -6971,7 +7073,7 @@
Source:
@@ -7228,7 +7330,7 @@
Source:
@@ -7406,7 +7508,7 @@
Source:
@@ -7561,7 +7663,7 @@
Source:
@@ -7716,7 +7818,7 @@
Source:
@@ -7871,7 +7973,7 @@
Source:
@@ -7979,7 +8081,7 @@
Source:
@@ -8063,7 +8165,7 @@
Source:
@@ -8157,7 +8259,7 @@
Source:
@@ -8263,7 +8365,7 @@
Source:
@@ -8520,7 +8622,7 @@
Source:
@@ -8588,7 +8690,7 @@
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html index 788b895a3..3b340b60a 100644 --- a/docs/frontend_api/FrontendScriptApi.html +++ b/docs/frontend_api/FrontendScriptApi.html @@ -94,7 +94,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -236,7 +236,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -342,7 +342,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -448,7 +448,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -554,7 +554,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -614,7 +614,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -724,7 +724,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -834,7 +834,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -947,7 +947,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -1057,7 +1057,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -1186,7 +1186,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -1341,7 +1341,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -1682,7 +1682,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -1819,7 +1819,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -2027,7 +2027,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -2409,7 +2409,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -2564,7 +2564,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -2721,7 +2721,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -2876,7 +2876,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -2986,7 +2986,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -3092,7 +3092,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -3198,7 +3198,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -3308,7 +3308,7 @@ available in the JS frontend notes. You can use e.g. api.showMessage(api.s
Source:
@@ -3419,7 +3419,7 @@ implementation of actual widget type.
Source:
@@ -3574,7 +3574,7 @@ implementation of actual widget type.
Source:
@@ -3729,7 +3729,7 @@ implementation of actual widget type.
Source:
@@ -3836,7 +3836,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3991,7 +3991,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4147,7 +4147,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4348,7 +4348,7 @@ otherwise (by e.g. createLink())
Source:
@@ -4454,7 +4454,7 @@ otherwise (by e.g. createLink())
Source:
@@ -4609,7 +4609,7 @@ otherwise (by e.g. createLink())
Source:
@@ -4764,7 +4764,7 @@ otherwise (by e.g. createLink())
Source:
@@ -4914,7 +4914,7 @@ otherwise (by e.g. createLink())
Source:
@@ -5092,7 +5092,7 @@ otherwise (by e.g. createLink())
Source:
@@ -5270,7 +5270,7 @@ otherwise (by e.g. createLink())
Source:
@@ -5421,7 +5421,7 @@ otherwise (by e.g. createLink())
Source:
@@ -5599,7 +5599,7 @@ otherwise (by e.g. createLink())
Source:
@@ -5773,7 +5773,7 @@ otherwise (by e.g. createLink())
Source:
@@ -5928,7 +5928,7 @@ otherwise (by e.g. createLink())
Source:
@@ -6082,7 +6082,7 @@ otherwise (by e.g. createLink())
Source:
@@ -6237,7 +6237,7 @@ otherwise (by e.g. createLink())
Source:
@@ -6398,7 +6398,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6558,7 +6558,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6714,7 +6714,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6869,7 +6869,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7020,7 +7020,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7074,7 +7074,7 @@ Internally this serializes the anonymous function into string and sends it to ba -

showError(message)

+

showConfirmDialog(message) → {Promise.<boolean>}

@@ -7082,7 +7082,7 @@ Internally this serializes the anonymous function into string and sends it to ba
- Show an error message to the user. + Show confirm dialog to the user.
@@ -7175,7 +7175,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7200,6 +7200,320 @@ Internally this serializes the anonymous function into string and sends it to ba +
Returns:
+ + +
+ promise resolving to true if the user confirmed +
+ + + +
+
+ Type +
+
+ +Promise.<boolean> + + +
+
+ + + + + + + + + + + + + +

showError(message)

+ + + + + + +
+ Show an error toast message to the user. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
message + + +string + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

showInfoDialog(message) → {Promise}

+ + + + + + +
+ Show an info dialog to the user. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
message + + +string + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Promise + + +
+
+ + @@ -7219,7 +7533,7 @@ Internally this serializes the anonymous function into string and sends it to ba
- Show an info message to the user. + Show an info toast message to the user.
@@ -7312,7 +7626,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7342,6 +7656,260 @@ Internally this serializes the anonymous function into string and sends it to ba + + + + + + +

showPromptDialog(props) → {Promise.<string>}

+ + + + + + +
+ Show prompt dialog to the user. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
props + + +object + + + + +
Properties
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
title + + +string + + + +
message + + +string + + + +
defaultValue + + +string + + + +
+ +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ promise resolving to the answer provided by the user +
+ + + +
+
+ Type +
+
+ +Promise.<string> + + +
+
+ + + + + + + @@ -7472,7 +8040,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7632,7 +8200,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7724,7 +8292,7 @@ Typical use case is when a new note has been created, we should wait until it is
Source:
@@ -7788,7 +8356,7 @@ Typical use case is when a new note has been created, we should wait until it is
diff --git a/docs/frontend_api/entities_fattachment.js.html b/docs/frontend_api/entities_fattachment.js.html index b2137c353..c49ab8dd2 100644 --- a/docs/frontend_api/entities_fattachment.js.html +++ b/docs/frontend_api/entities_fattachment.js.html @@ -80,7 +80,7 @@ export default FAttachment;
diff --git a/docs/frontend_api/entities_fattribute.js.html b/docs/frontend_api/entities_fattribute.js.html index abbb8b686..7daa67ff2 100644 --- a/docs/frontend_api/entities_fattribute.js.html +++ b/docs/frontend_api/entities_fattribute.js.html @@ -116,7 +116,7 @@ export default FAttribute;
diff --git a/docs/frontend_api/entities_fblob.js.html b/docs/frontend_api/entities_fblob.js.html index 311c1fe77..e98ee01c6 100644 --- a/docs/frontend_api/entities_fblob.js.html +++ b/docs/frontend_api/entities_fblob.js.html @@ -43,6 +43,27 @@ /** @type {string} */ this.utcDateModified = row.utcDateModified; } + + /** + * @returns {*} + * @throws Error in case of invalid JSON */ + getJsonContent() { + if (!this.content || !this.content.trim()) { + return null; + } + + return JSON.parse(this.content); + } + + /** @returns {*|null} valid object or null if the content cannot be parsed as JSON */ + getJsonContentSafely() { + try { + return this.getJsonContent(); + } + catch (e) { + return null; + } + } }
@@ -54,7 +75,7 @@
diff --git a/docs/frontend_api/entities_fbranch.js.html b/docs/frontend_api/entities_fbranch.js.html index 1d663d7de..f2049871d 100644 --- a/docs/frontend_api/entities_fbranch.js.html +++ b/docs/frontend_api/entities_fbranch.js.html @@ -100,7 +100,7 @@ export default FBranch;
diff --git a/docs/frontend_api/entities_fnote.js.html b/docs/frontend_api/entities_fnote.js.html index 2893ad25b..d6f68bcca 100644 --- a/docs/frontend_api/entities_fnote.js.html +++ b/docs/frontend_api/entities_fnote.js.html @@ -264,6 +264,12 @@ class FNote { return this.attachments; } + /** @returns {Promise<FAttachment[]>} */ + async getAttachmentsByRole(role) { + return (await this.getAttachments()) + .filter(attachment => attachment.role === role); + } + /** @returns {Promise<FAttachment>} */ async getAttachmentById(attachmentId) { const attachments = await this.getAttachments(); @@ -998,6 +1004,10 @@ class FNote { isOptions() { return this.noteId.startsWith("_options"); } + + async getMetadata() { + return await server.get(`notes/${this.noteId}/metadata`); + } } export default FNote; @@ -1011,7 +1021,7 @@ export default FNote;
diff --git a/docs/frontend_api/index.html b/docs/frontend_api/index.html index 46ccdc9a8..1fc84f364 100644 --- a/docs/frontend_api/index.html +++ b/docs/frontend_api/index.html @@ -50,7 +50,7 @@
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html index 96cc31057..3c978b25c 100644 --- a/docs/frontend_api/services_frontend_script_api.js.html +++ b/docs/frontend_api/services_frontend_script_api.js.html @@ -42,6 +42,7 @@ import NoteContextAwareWidget from "../widgets/note_context_aware_widget.js"; import BasicWidget from "../widgets/basic_widget.js"; import SpacedUpdate from "./spaced_update.js"; import shortcutService from "./shortcuts.js"; +import dialogService from "./dialog.js"; /** * <p>This is the main frontend API interface for scripts. All the properties and methods are published in the "api" object @@ -286,7 +287,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain this.parseDate = utils.parseDate; /** - * Show an info message to the user. + * Show an info toast message to the user. * * @method * @param {string} message @@ -294,13 +295,43 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain this.showMessage = toastService.showMessage; /** - * Show an error message to the user. + * Show an error toast message to the user. * * @method * @param {string} message */ this.showError = toastService.showError; + /** + * Show an info dialog to the user. + * + * @method + * @param {string} message + * @returns {Promise} + */ + this.showInfoDialog = dialogService.info; + + /** + * Show confirm dialog to the user. + * + * @method + * @param {string} message + * @returns {Promise<boolean>} promise resolving to true if the user confirmed + */ + this.showConfirmDialog = dialogService.confirm; + + /** + * Show prompt dialog to the user. + * + * @method + * @param {object} props + * @param {string} props.title + * @param {string} props.message + * @param {string} props.defaultValue + * @returns {Promise<string>} promise resolving to the answer provided by the user + */ + this.showPromptDialog = dialogService.prompt; + /** * Trigger command. This is a very low-level API which should be avoided if possible. * @@ -570,7 +601,7 @@ export default FrontendScriptApi;