From 70758429546b819b894feebb51648540bf62414f Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 5 Nov 2019 21:26:54 +0100 Subject: [PATCH] expose bindGlobalShortcut to frontend script API --- docs/backend_api/entities_branch.js.html | 4 + docs/frontend_api/FrontendScriptApi.html | 198 ++++++++++++++++-- docs/frontend_api/NoteShort.html | 122 ++++++++--- docs/frontend_api/entities_note_short.js.html | 7 +- .../services_frontend_script_api.js.html | 9 + .../services/frontend_script_api.js | 7 + 6 files changed, 294 insertions(+), 53 deletions(-) diff --git a/docs/backend_api/entities_branch.js.html b/docs/backend_api/entities_branch.js.html index 7a4d69a8f..9ae543ca5 100644 --- a/docs/backend_api/entities_branch.js.html +++ b/docs/backend_api/entities_branch.js.html @@ -73,6 +73,10 @@ class Branch extends Entity { this.notePosition = maxNotePos === null ? 0 : maxNotePos + 10; } + if (!this.isExpanded) { + this.isExpanded = false; + } + if (!this.isDeleted) { this.isDeleted = false; } diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html index d4415c6ca..3fd3adc2b 100644 --- a/docs/frontend_api/FrontendScriptApi.html +++ b/docs/frontend_api/FrontendScriptApi.html @@ -1240,6 +1240,162 @@ + + + + + + +

bindGlobalShortcut(keyboardShortcut, handler)

+ + + + + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
keyboardShortcut + + +string + + + + e.g. "ctrl+shift+a"
handler + + +function + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -1390,7 +1546,7 @@
Source:
@@ -1523,7 +1679,7 @@
Source:
@@ -1629,7 +1785,7 @@
Source:
@@ -1735,7 +1891,7 @@
Source:
@@ -1894,7 +2050,7 @@
Source:
@@ -2001,7 +2157,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2156,7 +2312,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2619,7 +2775,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2774,7 +2930,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2883,7 +3039,7 @@ note.
Source:
@@ -3038,7 +3194,7 @@ note.
Source:
@@ -3171,7 +3327,7 @@ note.
Source:
@@ -3277,7 +3433,7 @@ note.
Source:
@@ -3365,7 +3521,7 @@ note.
Source:
@@ -3426,6 +3582,10 @@ note. +
+ Update frontend tree (note) cache from the backend. +
+ @@ -3516,7 +3676,7 @@ note.
Source:
@@ -4148,7 +4308,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4299,7 +4459,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4436,7 +4596,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4573,7 +4733,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html index 1192154d2..d120e54a5 100644 --- a/docs/frontend_api/NoteShort.html +++ b/docs/frontend_api/NoteShort.html @@ -281,7 +281,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -349,7 +349,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -417,7 +417,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -475,7 +475,65 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
+ + + + + + + + + + + + + + + + +

isDeleted

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -717,7 +775,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -785,7 +843,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -1049,7 +1107,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -1216,7 +1274,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -1390,7 +1448,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -1496,7 +1554,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -1598,7 +1656,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -1700,7 +1758,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -1802,7 +1860,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -1953,7 +2011,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -2120,7 +2178,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -2287,7 +2345,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -2442,7 +2500,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -2548,7 +2606,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -2650,7 +2708,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -2801,7 +2859,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -2968,7 +3026,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -3135,7 +3193,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -3290,7 +3348,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -3460,7 +3518,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -3611,7 +3669,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -3721,7 +3779,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -3895,7 +3953,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -4001,7 +4059,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -4152,7 +4210,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -4307,7 +4365,7 @@ This note's representation is used in note tree and is kept in TreeCache.
Source:
@@ -4418,7 +4476,7 @@ Cache is note instance scoped.
Source:
@@ -4502,7 +4560,7 @@ Cache is note instance scoped.
Source:
diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.html index debf67855..feac110e3 100644 --- a/docs/frontend_api/entities_note_short.js.html +++ b/docs/frontend_api/entities_note_short.js.html @@ -60,6 +60,8 @@ class NoteShort { /** @param {string} content-type, e.g. "application/json" */ this.mime = row.mime; /** @param {boolean} */ + this.isDeleted = row.isDeleted; + /** @param {boolean} */ this.archived = row.archived; /** @param {string} */ this.cssClass = row.cssClass; @@ -108,7 +110,7 @@ class NoteShort { const branchIdPos = {}; for (const branchId of Object.values(this.childToBranch)) { - branchIdPos[branchId] = this.treeCache.branches[branchId].notePosition; + branchIdPos[branchId] = this.treeCache.getBranch(branchId).notePosition; } this.children.sort((a, b) => branchIdPos[this.childToBranch[a]] < branchIdPos[this.childToBranch[b]] ? -1 : 1); @@ -153,7 +155,8 @@ class NoteShort { /** @returns {Promise<Branch[]>} */ async getChildBranches() { - const branchIds = Object.values(this.childToBranch); + // don't use Object.values() to guarantee order + const branchIds = this.children.map(childNoteId => this.childToBranch[childNoteId]); return this.treeCache.getBranches(branchIds); } diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html index 8f42be765..60cc942ba 100644 --- a/docs/frontend_api/services_frontend_script_api.js.html +++ b/docs/frontend_api/services_frontend_script_api.js.html @@ -240,6 +240,8 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte this.getNotes = async (noteIds, silentNotFoundError = false) => await treeCache.getNotes(noteIds, silentNotFoundError); /** + * Update frontend tree (note) cache from the backend. + * * @param {string[]} noteIds * @method */ @@ -385,6 +387,13 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte * @return {Promise} */ this.setHoistedNoteId = hoistedNoteService.setHoistedNoteId; + + /** + * @method + * @param {string} keyboardShortcut - e.g. "ctrl+shift+a" + * @param {function} handler + */ + this.bindGlobalShortcut = utils.bindGlobalShortcut; } export default FrontendScriptApi; diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js index a71955c24..e90921677 100644 --- a/src/public/javascripts/services/frontend_script_api.js +++ b/src/public/javascripts/services/frontend_script_api.js @@ -359,6 +359,13 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte * @return {Promise} */ this.setHoistedNoteId = hoistedNoteService.setHoistedNoteId; + + /** + * @method + * @param {string} keyboardShortcut - e.g. "ctrl+shift+a" + * @param {function} handler + */ + this.bindGlobalShortcut = utils.bindGlobalShortcut; } export default FrontendScriptApi; \ No newline at end of file