From d5732d77310700a9fb31549bc474ca951d24c472 Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 26 Oct 2022 16:52:00 +0200 Subject: [PATCH] api docs --- docs/backend_api/AbstractEntity.html | 2 +- docs/backend_api/Attribute.html | 2 +- docs/backend_api/BackendScriptApi.html | 382 +++++++++++++++--- docs/backend_api/EtapiToken.html | 2 +- docs/backend_api/NoteRevision.html | 2 +- docs/backend_api/Option.html | 2 +- docs/backend_api/RecentNote.html | 2 +- .../becca_entities_abstract_entity.js.html | 2 +- .../becca_entities_attribute.js.html | 2 +- .../becca_entities_etapi_token.js.html | 2 +- .../becca_entities_note_revision.js.html | 2 +- .../backend_api/becca_entities_option.js.html | 2 +- .../becca_entities_recent_note.js.html | 2 +- docs/backend_api/global.html | 10 +- docs/backend_api/index.html | 2 +- docs/backend_api/module-sql.html | 2 +- .../services_backend_script_api.js.html | 38 +- docs/backend_api/services_sql.js.html | 2 +- docs/frontend_api/Attribute.html | 2 +- docs/frontend_api/Branch.html | 2 +- docs/frontend_api/FrontendScriptApi.html | 250 +++++++++--- docs/frontend_api/NoteComplement.html | 2 +- docs/frontend_api/entities_attribute.js.html | 2 +- docs/frontend_api/entities_branch.js.html | 8 +- .../entities_note_complement.js.html | 2 +- docs/frontend_api/global.html | 4 +- docs/frontend_api/index.html | 2 +- docs/frontend_api/module.exports.html | 2 +- .../services_frontend_script_api.js.html | 30 +- .../widgets_collapsible_widget.js.html | 2 +- 30 files changed, 625 insertions(+), 143 deletions(-) diff --git a/docs/backend_api/AbstractEntity.html b/docs/backend_api/AbstractEntity.html index b39f717a3..83ea380cb 100644 --- a/docs/backend_api/AbstractEntity.html +++ b/docs/backend_api/AbstractEntity.html @@ -991,7 +991,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
diff --git a/docs/backend_api/Attribute.html b/docs/backend_api/Attribute.html index 3b7696898..fb0796b3b 100644 --- a/docs/backend_api/Attribute.html +++ b/docs/backend_api/Attribute.html @@ -1904,7 +1904,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html index 8e1204851..8d0cc9b6b 100644 --- a/docs/backend_api/BackendScriptApi.html +++ b/docs/backend_api/BackendScriptApi.html @@ -81,7 +81,7 @@
Source:
@@ -185,7 +185,7 @@
Source:
@@ -295,7 +295,7 @@
Source:
@@ -405,7 +405,7 @@
Source:
@@ -515,7 +515,7 @@
Source:
@@ -625,7 +625,7 @@
Source:
@@ -735,7 +735,7 @@
Source:
@@ -845,7 +845,7 @@
Source:
@@ -955,7 +955,7 @@
Source:
@@ -1131,7 +1131,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -1298,7 +1298,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -1584,7 +1584,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -1789,7 +1789,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -1971,7 +1971,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2172,7 +2172,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2323,7 +2323,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2429,7 +2429,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2587,7 +2587,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2741,7 +2741,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2798,7 +2798,7 @@ JSON MIME type. See also createNewNote() for more options. -

getDateNote(date) → {Note|null}

+

getDateNote(date, rootNoteopt) → {Note|null}

@@ -2830,6 +2830,8 @@ JSON MIME type. See also createNewNote() for more options. Type + Attributes + @@ -2855,6 +2857,14 @@ JSON MIME type. See also createNewNote() for more options. + + + + + + + + @@ -2862,6 +2872,39 @@ JSON MIME type. See also createNewNote() for more options. + + + + rootNote + + + + + +Note + + + + + + + + + <optional>
+ + + + + + + + + + + specify calendar root note, normally leave empty to use default calendar + + + @@ -2901,7 +2944,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2958,7 +3001,7 @@ JSON MIME type. See also createNewNote() for more options. -

getDayNote(date) → {Note|null}

+

getDayNote(date, rootNoteopt) → {Note|null}

@@ -2990,6 +3033,8 @@ JSON MIME type. See also createNewNote() for more options. Type + Attributes + @@ -3015,6 +3060,14 @@ JSON MIME type. See also createNewNote() for more options. + + + + + + + + @@ -3022,6 +3075,39 @@ JSON MIME type. See also createNewNote() for more options. + + + + rootNote + + + + + +Note + + + + + + + + + <optional>
+ + + + + + + + + + + specify calendar root note, normally leave empty to use default calendar + + + @@ -3059,7 +3145,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -3169,7 +3255,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3226,7 +3312,7 @@ if some action needs to happen on only one specific instance. -

getMonthNote(date) → {Note|null}

+

getMonthNote(date, rootNoteopt) → {Note|null}

@@ -3258,6 +3344,8 @@ if some action needs to happen on only one specific instance. Type + Attributes + @@ -3283,6 +3371,14 @@ if some action needs to happen on only one specific instance. + + + + + + + + @@ -3290,6 +3386,39 @@ if some action needs to happen on only one specific instance. + + + + rootNote + + + + + +Note + + + + + + + + + <optional>
+ + + + + + + + + + + specify calendar root note, normally leave empty to use default calendar + + + @@ -3327,7 +3456,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3481,7 +3610,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3682,7 +3811,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3880,7 +4009,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3989,7 +4118,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4046,7 +4175,7 @@ if some action needs to happen on only one specific instance. -

getTodayNote() → {Note|null}

+

getTodayNote(rootNoteopt) → {Note|null}

@@ -4065,6 +4194,67 @@ if some action needs to happen on only one specific instance. +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
rootNote + + +Note + + + + + + <optional>
+ + + + + +
specify calendar root note, normally leave empty to use default calendar
+ + @@ -4098,7 +4288,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4155,7 +4345,7 @@ if some action needs to happen on only one specific instance. -

getWeekNote(date, options) → {Note|null}

+

getWeekNote(date, optionsopt, rootNoteopt) → {Note|null}

@@ -4187,6 +4377,8 @@ if some action needs to happen on only one specific instance. Type + Attributes + @@ -4212,6 +4404,14 @@ if some action needs to happen on only one specific instance. + + + + + + + + @@ -4235,6 +4435,16 @@ if some action needs to happen on only one specific instance. + + + <optional>
+ + + + + + + @@ -4242,6 +4452,39 @@ if some action needs to happen on only one specific instance. + + + + rootNote + + + + + +Note + + + + + + + + + <optional>
+ + + + + + + + + + + specify calendar root note, normally leave empty to use default calendar + + + @@ -4279,7 +4522,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4336,7 +4579,7 @@ if some action needs to happen on only one specific instance. -

getYearNote(year) → {Note|null}

+

getYearNote(year, rootNoteopt) → {Note|null}

@@ -4368,6 +4611,8 @@ if some action needs to happen on only one specific instance. Type + Attributes + @@ -4393,6 +4638,14 @@ if some action needs to happen on only one specific instance. + + + + + + + + @@ -4400,6 +4653,39 @@ if some action needs to happen on only one specific instance. + + + + rootNote + + + + + +Note + + + + + + + + + <optional>
+ + + + + + + + + + + specify calendar root note, normally leave empty to use default calendar + + + @@ -4437,7 +4723,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4502,7 +4788,7 @@ if some action needs to happen on only one specific instance.
- Log given message to trilium logs. + Log given message to trilium logs and log pane in UI
@@ -4590,7 +4876,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4727,7 +5013,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4835,7 +5121,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5016,7 +5302,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5218,7 +5504,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5427,7 +5713,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -5560,7 +5846,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -5766,7 +6052,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -5922,7 +6208,7 @@ exists, then we'll use that transaction.
Source:
@@ -6077,7 +6363,7 @@ exists, then we'll use that transaction.
Source:
@@ -6151,7 +6437,7 @@ exists, then we'll use that transaction.
diff --git a/docs/backend_api/EtapiToken.html b/docs/backend_api/EtapiToken.html index da6e56f2f..fd90ac06e 100644 --- a/docs/backend_api/EtapiToken.html +++ b/docs/backend_api/EtapiToken.html @@ -1461,7 +1461,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
diff --git a/docs/backend_api/NoteRevision.html b/docs/backend_api/NoteRevision.html index c8c829447..f2443f927 100644 --- a/docs/backend_api/NoteRevision.html +++ b/docs/backend_api/NoteRevision.html @@ -2174,7 +2174,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
diff --git a/docs/backend_api/Option.html b/docs/backend_api/Option.html index bd356c359..e4764f7db 100644 --- a/docs/backend_api/Option.html +++ b/docs/backend_api/Option.html @@ -1319,7 +1319,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
diff --git a/docs/backend_api/RecentNote.html b/docs/backend_api/RecentNote.html index 39babc507..0b293ddae 100644 --- a/docs/backend_api/RecentNote.html +++ b/docs/backend_api/RecentNote.html @@ -1251,7 +1251,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
diff --git a/docs/backend_api/becca_entities_abstract_entity.js.html b/docs/backend_api/becca_entities_abstract_entity.js.html index 5b8a48e51..58361497f 100644 --- a/docs/backend_api/becca_entities_abstract_entity.js.html +++ b/docs/backend_api/becca_entities_abstract_entity.js.html @@ -209,7 +209,7 @@ module.exports = AbstractEntity;
diff --git a/docs/backend_api/becca_entities_attribute.js.html b/docs/backend_api/becca_entities_attribute.js.html index ac020be8e..7c88c09f3 100644 --- a/docs/backend_api/becca_entities_attribute.js.html +++ b/docs/backend_api/becca_entities_attribute.js.html @@ -254,7 +254,7 @@ module.exports = Attribute;
diff --git a/docs/backend_api/becca_entities_etapi_token.js.html b/docs/backend_api/becca_entities_etapi_token.js.html index da33cc50d..72b9adef4 100644 --- a/docs/backend_api/becca_entities_etapi_token.js.html +++ b/docs/backend_api/becca_entities_etapi_token.js.html @@ -120,7 +120,7 @@ module.exports = EtapiToken;
diff --git a/docs/backend_api/becca_entities_note_revision.js.html b/docs/backend_api/becca_entities_note_revision.js.html index f4062ef6c..f22ca3048 100644 --- a/docs/backend_api/becca_entities_note_revision.js.html +++ b/docs/backend_api/becca_entities_note_revision.js.html @@ -235,7 +235,7 @@ module.exports = NoteRevision;
diff --git a/docs/backend_api/becca_entities_option.js.html b/docs/backend_api/becca_entities_option.js.html index 15d02ab4d..a6ab8a5e3 100644 --- a/docs/backend_api/becca_entities_option.js.html +++ b/docs/backend_api/becca_entities_option.js.html @@ -89,7 +89,7 @@ module.exports = Option;
diff --git a/docs/backend_api/becca_entities_recent_note.js.html b/docs/backend_api/becca_entities_recent_note.js.html index 3c7e3b40b..6b3f05d15 100644 --- a/docs/backend_api/becca_entities_recent_note.js.html +++ b/docs/backend_api/becca_entities_recent_note.js.html @@ -77,7 +77,7 @@ module.exports = RecentNote;
diff --git a/docs/backend_api/global.html b/docs/backend_api/global.html index 43d1da8e1..43ea3274e 100644 --- a/docs/backend_api/global.html +++ b/docs/backend_api/global.html @@ -391,7 +391,7 @@
Source:
@@ -579,7 +579,7 @@
Source:
@@ -767,7 +767,7 @@
Source:
@@ -1053,7 +1053,7 @@
Source:
@@ -1089,7 +1089,7 @@
diff --git a/docs/backend_api/index.html b/docs/backend_api/index.html index 0799c2465..3a8828939 100644 --- a/docs/backend_api/index.html +++ b/docs/backend_api/index.html @@ -56,7 +56,7 @@
diff --git a/docs/backend_api/module-sql.html b/docs/backend_api/module-sql.html index a129e51d9..f006a89d7 100644 --- a/docs/backend_api/module-sql.html +++ b/docs/backend_api/module-sql.html @@ -1258,7 +1258,7 @@
diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html index 23c98b39e..f6de2455f 100644 --- a/docs/backend_api/services_backend_script_api.js.html +++ b/docs/backend_api/services_backend_script_api.js.html @@ -42,6 +42,8 @@ const appInfo = require('./app_info'); const searchService = require('./search/services/search'); const SearchContext = require("./search/search_context"); const becca = require("../becca/becca"); +const ws = require("./ws"); +const SpacedUpdate = require("./spaced_update"); /** * This is the main backend API interface for scripts. It's published in the local "api" object. @@ -316,12 +318,34 @@ function BackendScriptApi(currentNote, apiParams) { }); }; + this.logMessages = {}; + this.logSpacedUpdates = {}; + /** - * Log given message to trilium logs. + * Log given message to trilium logs and log pane in UI * * @param message */ - this.log = message => log.info(message); + this.log = message => { + log.info(message); + + const {noteId} = this.startNote; + + this.logMessages[noteId] = this.logMessages[noteId] || []; + this.logSpacedUpdates[noteId] = this.logSpacedUpdates[noteId] || new SpacedUpdate(() => { + const messages = this.logMessages[noteId]; + this.logMessages[noteId] = []; + + ws.sendMessageToAllClients({ + type: 'api-log-messages', + noteId, + messages + }); + }, 100); + + this.logMessages[noteId].push(message); + this.logSpacedUpdates[noteId].scheduleUpdate(); + }; /** * Returns root note of the calendar. @@ -336,6 +360,7 @@ function BackendScriptApi(currentNote, apiParams) { * * @method * @param {string} date in YYYY-MM-DD format + * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar * @returns {Note|null} * @deprecated use getDayNote instead */ @@ -346,6 +371,7 @@ function BackendScriptApi(currentNote, apiParams) { * * @method * @param {string} date in YYYY-MM-DD format + * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar * @returns {Note|null} */ this.getDayNote = dateNoteService.getDayNote; @@ -354,6 +380,7 @@ function BackendScriptApi(currentNote, apiParams) { * Returns today's day note. If such note doesn't exist, it is created. * * @method + * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar * @returns {Note|null} */ this.getTodayNote = dateNoteService.getTodayNote; @@ -363,7 +390,8 @@ function BackendScriptApi(currentNote, apiParams) { * * @method * @param {string} date in YYYY-MM-DD format - * @param {object} options - "startOfTheWeek" - either "monday" (default) or "sunday" + * @param {object} [options] - "startOfTheWeek" - either "monday" (default) or "sunday" + * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar * @returns {Note|null} */ this.getWeekNote = dateNoteService.getWeekNote; @@ -373,6 +401,7 @@ function BackendScriptApi(currentNote, apiParams) { * * @method * @param {string} date in YYYY-MM format + * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar * @returns {Note|null} */ this.getMonthNote = dateNoteService.getMonthNote; @@ -382,6 +411,7 @@ function BackendScriptApi(currentNote, apiParams) { * * @method * @param {string} year in YYYY format + * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar * @returns {Note|null} */ this.getYearNote = dateNoteService.getYearNote; @@ -482,7 +512,7 @@ module.exports = BackendScriptApi;
diff --git a/docs/backend_api/services_sql.js.html b/docs/backend_api/services_sql.js.html index 7af2575ee..87a04b733 100644 --- a/docs/backend_api/services_sql.js.html +++ b/docs/backend_api/services_sql.js.html @@ -404,7 +404,7 @@ module.exports = {
diff --git a/docs/frontend_api/Attribute.html b/docs/frontend_api/Attribute.html index 34387fd67..f37b6de37 100644 --- a/docs/frontend_api/Attribute.html +++ b/docs/frontend_api/Attribute.html @@ -850,7 +850,7 @@ and relation (representing named relationship between source and target note) diff --git a/docs/frontend_api/Branch.html b/docs/frontend_api/Branch.html index 00f7dbb78..d5b3f7327 100644 --- a/docs/frontend_api/Branch.html +++ b/docs/frontend_api/Branch.html @@ -1062,7 +1062,7 @@ parents.
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html index becbb6eae..793e73149 100644 --- a/docs/frontend_api/FrontendScriptApi.html +++ b/docs/frontend_api/FrontendScriptApi.html @@ -81,7 +81,7 @@
Source:
@@ -223,7 +223,7 @@
Source:
@@ -329,7 +329,7 @@
Source:
@@ -435,7 +435,7 @@
Source:
@@ -545,7 +545,7 @@
Source:
@@ -651,7 +651,7 @@
Source:
@@ -757,7 +757,7 @@
Source:
@@ -870,7 +870,7 @@
Source:
@@ -980,7 +980,7 @@
Source:
@@ -1088,7 +1088,7 @@
Source:
@@ -1196,7 +1196,7 @@
Source:
@@ -1325,7 +1325,7 @@
Source:
@@ -1480,7 +1480,7 @@
Source:
@@ -1635,7 +1635,7 @@
Source:
@@ -1772,7 +1772,7 @@
Source:
@@ -1911,7 +1911,7 @@
Source:
@@ -2067,7 +2067,7 @@
Source:
@@ -2427,7 +2427,7 @@
Source:
@@ -2560,7 +2560,7 @@
Source:
@@ -2670,7 +2670,7 @@
Source:
@@ -2776,7 +2776,7 @@
Source:
@@ -2882,7 +2882,7 @@
Source:
@@ -2992,7 +2992,7 @@
Source:
@@ -3103,7 +3103,7 @@ implementation of actual widget type.
Source:
@@ -3207,7 +3207,7 @@ implementation of actual widget type.
Source:
@@ -3315,7 +3315,7 @@ implementation of actual widget type.
Source:
@@ -3483,7 +3483,7 @@ implementation of actual widget type.
Source:
@@ -3620,7 +3620,7 @@ implementation of actual widget type.
Source:
@@ -3777,7 +3777,7 @@ implementation of actual widget type.
Source:
@@ -3932,7 +3932,7 @@ implementation of actual widget type.
Source:
@@ -4039,7 +4039,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4194,7 +4194,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4350,7 +4350,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4551,7 +4551,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4657,7 +4657,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4812,7 +4812,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -4967,7 +4967,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5015,6 +5015,138 @@ otherwise (by e.g. createNoteLink()) + + + + + + +

log(message)

+ + + + + + +
+ Log given message to the log pane in UI +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
message + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -5145,7 +5277,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5323,7 +5455,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5474,7 +5606,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5582,7 +5714,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5738,7 +5870,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -5894,7 +6026,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6031,7 +6163,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6185,7 +6317,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6271,7 +6403,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6408,7 +6540,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -6569,7 +6701,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6677,7 +6809,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6815,7 +6947,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -6971,7 +7103,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7126,7 +7258,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7277,7 +7409,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7414,7 +7546,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7551,7 +7683,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7711,7 +7843,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7871,7 +8003,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -7963,7 +8095,7 @@ Typical use case is when new note has been created, we should wait until it is s
Source:
@@ -8015,7 +8147,7 @@ Typical use case is when new note has been created, we should wait until it is s
diff --git a/docs/frontend_api/NoteComplement.html b/docs/frontend_api/NoteComplement.html index d922a07ae..cb2d6501b 100644 --- a/docs/frontend_api/NoteComplement.html +++ b/docs/frontend_api/NoteComplement.html @@ -781,7 +781,7 @@
diff --git a/docs/frontend_api/entities_attribute.js.html b/docs/frontend_api/entities_attribute.js.html index 72e9731b3..d44f46ece 100644 --- a/docs/frontend_api/entities_attribute.js.html +++ b/docs/frontend_api/entities_attribute.js.html @@ -121,7 +121,7 @@ export default Attribute;
diff --git a/docs/frontend_api/entities_branch.js.html b/docs/frontend_api/entities_branch.js.html index abf328ead..e96a6a59b 100644 --- a/docs/frontend_api/entities_branch.js.html +++ b/docs/frontend_api/entities_branch.js.html @@ -80,6 +80,12 @@ class Branch { get toString() { return `Branch(branchId=${this.branchId})`; } + + get pojo() { + const pojo = {...this}; + delete pojo.froca; + return pojo; + } } export default Branch; @@ -99,7 +105,7 @@ export default Branch;
diff --git a/docs/frontend_api/entities_note_complement.js.html b/docs/frontend_api/entities_note_complement.js.html index 93cd2ef27..360dce760 100644 --- a/docs/frontend_api/entities_note_complement.js.html +++ b/docs/frontend_api/entities_note_complement.js.html @@ -82,7 +82,7 @@ export default NoteComplement;
diff --git a/docs/frontend_api/global.html b/docs/frontend_api/global.html index 30e91a656..48b1f623a 100644 --- a/docs/frontend_api/global.html +++ b/docs/frontend_api/global.html @@ -395,7 +395,7 @@
Source:
@@ -431,7 +431,7 @@
diff --git a/docs/frontend_api/index.html b/docs/frontend_api/index.html index 0eb4b2332..8dc8b7de8 100644 --- a/docs/frontend_api/index.html +++ b/docs/frontend_api/index.html @@ -56,7 +56,7 @@
diff --git a/docs/frontend_api/module.exports.html b/docs/frontend_api/module.exports.html index 1f1bd8852..a20ad67f4 100644 --- a/docs/frontend_api/module.exports.html +++ b/docs/frontend_api/module.exports.html @@ -161,7 +161,7 @@
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html index e27c5db16..a39196f1c 100644 --- a/docs/frontend_api/services_frontend_script_api.js.html +++ b/docs/frontend_api/services_frontend_script_api.js.html @@ -41,6 +41,7 @@ import appContext from "./app_context.js"; import NoteContextAwareWidget from "../widgets/note_context_aware_widget.js"; import NoteContextCachingWidget from "../widgets/note_context_caching_widget.js"; import BasicWidget from "../widgets/basic_widget.js"; +import SpacedUpdate from "./spaced_update.js"; /** * This is the main frontend API interface for scripts. It's published in the local "api" object. @@ -622,6 +623,33 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain * @returns {string} random string */ this.randomString = utils.randomString; + + this.logMessages = {}; + this.logSpacedUpdates = {}; + + /** + * Log given message to the log pane in UI + * + * @param message + */ + this.log = message => { + const {noteId} = this.startNote; + + message = utils.now() + ": " + message; + + console.log(`Script ${noteId}: ${message}`); + + this.logMessages[noteId] = this.logMessages[noteId] || []; + this.logSpacedUpdates[noteId] = this.logSpacedUpdates[noteId] || new SpacedUpdate(() => { + const messages = this.logMessages[noteId]; + this.logMessages[noteId] = []; + + appContext.triggerEvent("apiLogMessages", {noteId, messages}); + }, 100); + + this.logMessages[noteId].push(message); + this.logSpacedUpdates[noteId].scheduleUpdate(); + }; } export default FrontendScriptApi; @@ -641,7 +669,7 @@ export default FrontendScriptApi;
diff --git a/docs/frontend_api/widgets_collapsible_widget.js.html b/docs/frontend_api/widgets_collapsible_widget.js.html index 0411406f7..4a731fa1a 100644 --- a/docs/frontend_api/widgets_collapsible_widget.js.html +++ b/docs/frontend_api/widgets_collapsible_widget.js.html @@ -80,7 +80,7 @@ export default class CollapsibleWidget extends NoteContextAwareWidget {