From fab4c59f9bb2c2785bf8a2bd5ad173753fb36839 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 20 Aug 2019 21:40:47 +0200 Subject: [PATCH] using dynamic import for dialogs and widgets to speed up initial load --- docs/backend_api/ApiToken.html | 6 +- docs/backend_api/Attribute.html | 14 +- docs/backend_api/BackendScriptApi.html | 58 ++- docs/backend_api/Branch.html | 10 +- docs/backend_api/Entity.html | 6 +- docs/backend_api/Note.html | 357 ++++++++++++++-- docs/backend_api/NoteRevision.html | 8 +- docs/backend_api/Option.html | 8 +- docs/backend_api/RecentNote.html | 6 +- docs/backend_api/entities_api_token.js.html | 4 +- docs/backend_api/entities_attribute.js.html | 4 +- docs/backend_api/entities_branch.js.html | 4 +- docs/backend_api/entities_entity.js.html | 4 +- docs/backend_api/entities_note.js.html | 30 +- .../entities_note_revision.js.html | 4 +- docs/backend_api/entities_option.js.html | 4 +- docs/backend_api/entities_recent_note.js.html | 4 +- docs/backend_api/global.html | 4 +- docs/backend_api/index.html | 4 +- docs/backend_api/scripts/linenumber.js | 18 +- .../services_backend_script_api.js.html | 4 +- docs/backend_api/styles/jsdoc-default.css | 4 +- docs/frontend_api/Branch.html | 10 +- docs/frontend_api/FrontendScriptApi.html | 240 +++++++++-- docs/frontend_api/NoteFull.html | 6 +- docs/frontend_api/NoteShort.html | 387 ++++++++++++++++-- docs/frontend_api/entities_attribute.js.html | 2 +- docs/frontend_api/entities_branch.js.html | 2 +- docs/frontend_api/entities_note_full.js.html | 2 +- docs/frontend_api/entities_note_short.js.html | 37 +- docs/frontend_api/global.html | 4 +- docs/frontend_api/index.html | 2 +- docs/frontend_api/scripts/linenumber.js | 18 +- .../services_frontend_script_api.js.html | 22 +- docs/frontend_api/styles/jsdoc-default.css | 4 +- package-lock.json | 219 ++++++++-- package.json | 11 +- src/public/javascripts/desktop.js | 16 +- src/public/javascripts/dialogs/about.js | 6 +- src/public/javascripts/dialogs/add_link.js | 9 +- src/public/javascripts/dialogs/attributes.js | 8 +- .../javascripts/dialogs/branch_prefix.js | 8 +- src/public/javascripts/dialogs/confirm.js | 14 +- src/public/javascripts/dialogs/event_log.js | 8 +- src/public/javascripts/dialogs/export.js | 8 +- src/public/javascripts/dialogs/help.js | 6 +- src/public/javascripts/dialogs/import.js | 9 +- src/public/javascripts/dialogs/info.js | 8 +- .../javascripts/dialogs/jump_to_note.js | 6 +- src/public/javascripts/dialogs/link_map.js | 6 +- .../javascripts/dialogs/markdown_import.js | 8 +- src/public/javascripts/dialogs/note_info.js | 6 +- .../javascripts/dialogs/note_revisions.js | 6 +- src/public/javascripts/dialogs/note_source.js | 8 +- src/public/javascripts/dialogs/options.js | 7 +- src/public/javascripts/dialogs/prompt.js | 6 +- .../javascripts/dialogs/protected_session.js | 9 +- .../javascripts/dialogs/recent_changes.js | 6 +- src/public/javascripts/dialogs/sql_console.js | 6 +- src/public/javascripts/services/branches.js | 3 +- .../javascripts/services/drag_and_drop.js | 5 +- .../javascripts/services/entrypoints.js | 66 +-- .../javascripts/services/note_detail.js | 5 +- .../services/note_detail_relation_map.js | 11 +- src/public/javascripts/services/note_type.js | 6 +- .../javascripts/services/protected_session.js | 3 +- src/public/javascripts/services/sidebar.js | 18 +- src/public/javascripts/services/tree.js | 3 +- .../javascripts/services/tree_context_menu.js | 6 +- .../javascripts/services/tree_keybindings.js | 4 +- src/public/javascripts/widgets/attributes.js | 4 +- src/public/javascripts/widgets/link_map.js | 4 +- 72 files changed, 1393 insertions(+), 450 deletions(-) diff --git a/docs/backend_api/ApiToken.html b/docs/backend_api/ApiToken.html index 1458d93ee..ba16476ba 100644 --- a/docs/backend_api/ApiToken.html +++ b/docs/backend_api/ApiToken.html @@ -239,6 +239,8 @@ + + @@ -282,13 +284,13 @@
diff --git a/docs/backend_api/Attribute.html b/docs/backend_api/Attribute.html index dc991dd30..a42ab9c37 100644 --- a/docs/backend_api/Attribute.html +++ b/docs/backend_api/Attribute.html @@ -349,7 +349,7 @@
Source:
@@ -377,6 +377,8 @@ + + @@ -485,6 +487,8 @@ + +
Returns:
@@ -585,6 +589,8 @@ + +
Returns:
@@ -685,6 +691,8 @@ + +
Returns:
@@ -724,13 +732,13 @@
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html index f970bf8b3..803a7e61d 100644 --- a/docs/backend_api/BackendScriptApi.html +++ b/docs/backend_api/BackendScriptApi.html @@ -109,6 +109,8 @@ + + @@ -781,6 +783,8 @@ the backend. + +
Returns:
@@ -1067,6 +1071,8 @@ the backend. + +
Returns:
@@ -1247,6 +1253,8 @@ the backend. + +
Returns:
@@ -1446,6 +1454,8 @@ the backend. + +
Returns:
@@ -1546,6 +1556,8 @@ the backend. + +
Returns:
@@ -1702,6 +1714,8 @@ the backend. + +
Returns:
@@ -1851,6 +1865,8 @@ the backend. + +
Returns:
@@ -2004,6 +2020,8 @@ the backend. + +
Returns:
@@ -2176,6 +2194,8 @@ the backend. + +
Returns:
@@ -2352,6 +2372,8 @@ the backend. + +
Returns:
@@ -2501,6 +2523,8 @@ the backend. + +
Returns:
@@ -2606,6 +2630,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -2762,6 +2788,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -2911,6 +2939,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -3107,6 +3137,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -3303,6 +3335,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -3407,6 +3441,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -3583,6 +3619,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -3736,6 +3774,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -3889,6 +3929,8 @@ if some action needs to happen on only one specific instance. + + @@ -4020,6 +4062,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -4174,6 +4218,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -4409,6 +4455,8 @@ This method looks similar to toggleNoteInParent() but differs because we're look + + @@ -4535,6 +4583,8 @@ This method looks similar to toggleNoteInParent() but differs because we're look + +
Returns:
@@ -4749,6 +4799,8 @@ This method looks similar to toggleNoteInParent() but differs because we're look + +
Returns:
@@ -4906,6 +4958,8 @@ transactional by default. + +
Returns:
@@ -4949,13 +5003,13 @@ transactional by default.
diff --git a/docs/backend_api/Branch.html b/docs/backend_api/Branch.html index b53324408..bad86000e 100644 --- a/docs/backend_api/Branch.html +++ b/docs/backend_api/Branch.html @@ -327,7 +327,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
Source:
@@ -355,6 +355,8 @@ Each note can have multiple (at least one) branches, meaning it can be placed in + + @@ -463,6 +465,8 @@ Each note can have multiple (at least one) branches, meaning it can be placed in + +
Returns:
@@ -505,13 +509,13 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
diff --git a/docs/backend_api/Entity.html b/docs/backend_api/Entity.html index 4259b6dfd..6e3118974 100644 --- a/docs/backend_api/Entity.html +++ b/docs/backend_api/Entity.html @@ -178,6 +178,8 @@ + + @@ -210,13 +212,13 @@
diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html index d0efab35d..4ffc94575 100644 --- a/docs/backend_api/Note.html +++ b/docs/backend_api/Note.html @@ -396,7 +396,7 @@
Source:
@@ -424,6 +424,8 @@ + + @@ -581,7 +583,7 @@
Source:
@@ -604,6 +606,8 @@ + +
Returns:
@@ -769,6 +773,8 @@ + +
Returns:
@@ -922,7 +928,7 @@
Source:
@@ -945,6 +951,8 @@ + +
Returns:
@@ -1026,7 +1034,7 @@
Source:
@@ -1049,6 +1057,8 @@ + +
Returns:
@@ -1126,7 +1136,7 @@
Source:
@@ -1149,6 +1159,8 @@ + +
Returns:
@@ -1230,7 +1242,7 @@
Source:
@@ -1253,6 +1265,8 @@ + +
Returns:
@@ -1357,6 +1371,8 @@ + +
Returns:
@@ -1434,7 +1450,7 @@
Source:
@@ -1457,6 +1473,8 @@ + +
Returns:
@@ -1665,7 +1683,7 @@
Source:
@@ -1688,6 +1706,8 @@ + +
Returns:
@@ -1861,7 +1881,7 @@
Source:
@@ -1884,6 +1904,8 @@ + +
Returns:
@@ -2057,7 +2079,7 @@
Source:
@@ -2080,6 +2102,8 @@ + +
Returns:
@@ -2180,6 +2204,8 @@ + +
Returns:
@@ -2306,7 +2332,7 @@
Source:
@@ -2329,6 +2355,8 @@ + +
Returns:
@@ -2494,6 +2522,8 @@ + +
Returns:
@@ -2659,6 +2689,8 @@ + +
Returns:
@@ -2789,7 +2821,7 @@
Source:
@@ -2812,6 +2844,8 @@ + +
Returns:
@@ -2845,7 +2879,7 @@ - + @@ -2885,6 +2919,8 @@ +
Deprecated:
+ @@ -2897,7 +2933,7 @@
Source:
@@ -2920,6 +2956,8 @@ + +
Returns:
@@ -2931,7 +2969,7 @@
-Promise.<Array.<Link>> +Promise.<Array.<Attribute>>
@@ -2949,7 +2987,7 @@ -

(async) getLinksWithDeleted() → {Promise.<Array.<Link>>}

+

(async) getLinksWithDeleted() → {Promise.<Array.<Link>>}

@@ -3001,7 +3039,7 @@
Source:
@@ -3024,6 +3062,8 @@ + +
Returns:
@@ -3035,7 +3075,7 @@
-Promise.<Array.<Link>> +Promise.<Array.<Link>>
@@ -3124,6 +3164,8 @@ + +
Returns:
@@ -3205,7 +3247,7 @@
Source:
@@ -3228,6 +3270,8 @@ + +
Returns:
@@ -3358,7 +3402,7 @@
Source:
@@ -3381,6 +3425,8 @@ + +
Returns:
@@ -3523,7 +3569,7 @@
Source:
@@ -3546,6 +3592,8 @@ + +
Returns:
@@ -3711,6 +3759,8 @@ + +
Returns:
@@ -3841,7 +3891,7 @@
Source:
@@ -3864,6 +3914,8 @@ + +
Returns:
@@ -3900,6 +3952,169 @@ +

(async) getRelationTargets(nameopt) → {Promise.<Array.<Note>>}

+ + + + + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
name + + +string + + + + + + <optional>
+ + + + + +
relation name to filter
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Promise.<Array.<Note>> + + +
+
+ + + + + + + + + + + + +

(async) getRelationValue(name) → {Promise.<string>}

@@ -3997,7 +4212,7 @@
Source:
@@ -4020,6 +4235,8 @@ + +
Returns:
@@ -4105,7 +4322,7 @@
Source:
@@ -4128,6 +4345,8 @@ + +
Returns:
@@ -4228,6 +4447,8 @@ + +
Returns:
@@ -4261,7 +4482,7 @@ - + @@ -4313,7 +4534,7 @@
Source:
@@ -4336,6 +4557,8 @@ + +
Returns:
@@ -4347,7 +4570,7 @@
-Promise.<Array.<Link>> +Promise.<Array.<Link>>
@@ -4436,6 +4659,8 @@ + +
Returns:
@@ -4589,7 +4814,7 @@
Source:
@@ -4612,6 +4837,8 @@ + +
Returns:
@@ -4693,7 +4920,7 @@
Source:
@@ -4716,6 +4943,8 @@ + +
Returns:
@@ -4846,7 +5075,7 @@
Source:
@@ -4869,6 +5098,8 @@ + +
Returns:
@@ -4999,7 +5230,7 @@
Source:
@@ -5022,6 +5253,8 @@ + +
Returns:
@@ -5108,7 +5341,7 @@ Cache is note instance scoped.
Source:
@@ -5136,6 +5369,8 @@ Cache is note instance scoped. + + @@ -5213,6 +5448,8 @@ Cache is note instance scoped. + +
Returns:
@@ -5317,6 +5554,8 @@ Cache is note instance scoped. + +
Returns:
@@ -5421,6 +5660,8 @@ Cache is note instance scoped. + +
Returns:
@@ -5525,6 +5766,8 @@ Cache is note instance scoped. + +
Returns:
@@ -5629,6 +5872,8 @@ Cache is note instance scoped. + +
Returns:
@@ -5710,7 +5955,7 @@ Cache is note instance scoped.
Source:
@@ -5733,6 +5978,8 @@ Cache is note instance scoped. + +
Returns:
@@ -5937,7 +6184,7 @@ Cache is note instance scoped.
Source:
@@ -5960,6 +6207,8 @@ Cache is note instance scoped. + +
Returns:
@@ -6133,7 +6382,7 @@ Cache is note instance scoped.
Source:
@@ -6156,6 +6405,8 @@ Cache is note instance scoped. + +
Returns:
@@ -6329,7 +6580,7 @@ Cache is note instance scoped.
Source:
@@ -6352,6 +6603,8 @@ Cache is note instance scoped. + +
Returns:
@@ -6556,7 +6809,7 @@ Cache is note instance scoped.
Source:
@@ -6579,6 +6832,8 @@ Cache is note instance scoped. + +
Returns:
@@ -6679,6 +6934,8 @@ Cache is note instance scoped. + +
Returns:
@@ -6779,6 +7036,8 @@ Cache is note instance scoped. + +
Returns:
@@ -6952,7 +7211,7 @@ Cache is note instance scoped.
Source:
@@ -6975,6 +7234,8 @@ Cache is note instance scoped. + +
Returns:
@@ -7148,7 +7409,7 @@ Cache is note instance scoped.
Source:
@@ -7171,6 +7432,8 @@ Cache is note instance scoped. + +
Returns:
@@ -7406,7 +7669,7 @@ Cache is note instance scoped.
Source:
@@ -7429,6 +7692,8 @@ Cache is note instance scoped. + +
Returns:
@@ -7633,7 +7898,7 @@ Cache is note instance scoped.
Source:
@@ -7656,6 +7921,8 @@ Cache is note instance scoped. + +
Returns:
@@ -7860,7 +8127,7 @@ Cache is note instance scoped.
Source:
@@ -7883,6 +8150,8 @@ Cache is note instance scoped. + +
Returns:
@@ -7922,13 +8191,13 @@ Cache is note instance scoped.
diff --git a/docs/backend_api/NoteRevision.html b/docs/backend_api/NoteRevision.html index e42a6ad16..8a6568176 100644 --- a/docs/backend_api/NoteRevision.html +++ b/docs/backend_api/NoteRevision.html @@ -372,7 +372,7 @@
Source:
@@ -400,6 +400,8 @@ + + @@ -443,13 +445,13 @@
diff --git a/docs/backend_api/Option.html b/docs/backend_api/Option.html index fae9bbe8c..6a5164900 100644 --- a/docs/backend_api/Option.html +++ b/docs/backend_api/Option.html @@ -234,7 +234,7 @@
Source:
@@ -262,6 +262,8 @@ + + @@ -305,13 +307,13 @@
diff --git a/docs/backend_api/RecentNote.html b/docs/backend_api/RecentNote.html index 0e310241b..0e9b1b93c 100644 --- a/docs/backend_api/RecentNote.html +++ b/docs/backend_api/RecentNote.html @@ -239,6 +239,8 @@ + + @@ -282,13 +284,13 @@
diff --git a/docs/backend_api/entities_api_token.js.html b/docs/backend_api/entities_api_token.js.html index a47c05e77..eda639384 100644 --- a/docs/backend_api/entities_api_token.js.html +++ b/docs/backend_api/entities_api_token.js.html @@ -69,13 +69,13 @@ module.exports = ApiToken;
diff --git a/docs/backend_api/entities_attribute.js.html b/docs/backend_api/entities_attribute.js.html index 07dbf4e5d..db22d936e 100644 --- a/docs/backend_api/entities_attribute.js.html +++ b/docs/backend_api/entities_attribute.js.html @@ -150,13 +150,13 @@ module.exports = Attribute;
diff --git a/docs/backend_api/entities_branch.js.html b/docs/backend_api/entities_branch.js.html index dedd0198f..e76ded267 100644 --- a/docs/backend_api/entities_branch.js.html +++ b/docs/backend_api/entities_branch.js.html @@ -104,13 +104,13 @@ module.exports = Branch;
diff --git a/docs/backend_api/entities_entity.js.html b/docs/backend_api/entities_entity.js.html index a680f2931..53740aec6 100644 --- a/docs/backend_api/entities_entity.js.html +++ b/docs/backend_api/entities_entity.js.html @@ -96,13 +96,13 @@ module.exports = Entity;
diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.html index 5411ae861..1b350728b 100644 --- a/docs/backend_api/entities_note.js.html +++ b/docs/backend_api/entities_note.js.html @@ -276,6 +276,21 @@ class Note extends Entity { return (await this.getAttributes(name)).filter(attr => attr.type === RELATION); } + /** + * @param {string} [name] - relation name to filter + * @returns {Promise<Note[]>} + */ + async getRelationTargets(name) { + const relations = await this.getRelations(name); + const targets = []; + + for (const relation of relations) { + targets.push(await relation.getTargetNote()); + } + + return targets; + } + /** * @param {string} [name] - relation name to filter * @returns {Promise<Attribute[]>} all note's relation definitions including inherited ones @@ -641,10 +656,17 @@ class Note extends Entity { /** * Get list of links coming out of this note. * - * @returns {Promise<Link[]>} + * @deprecated - not intended for general use + * @returns {Promise<Attribute[]>} */ async getLinks() { - return await repository.getEntities("SELECT * FROM links WHERE noteId = ? AND isDeleted = 0", [this.noteId]); + return await repository.getEntities(` + SELECT * + FROM attributes + WHERE noteId = ? AND + isDeleted = 0 AND + type = 'relation' AND + name IN ('internal-link', 'image-link', 'relation-map-link')`, [this.noteId]); } /** @@ -769,13 +791,13 @@ module.exports = Note;
diff --git a/docs/backend_api/entities_note_revision.js.html b/docs/backend_api/entities_note_revision.js.html index a8f1993fe..112e22a8d 100644 --- a/docs/backend_api/entities_note_revision.js.html +++ b/docs/backend_api/entities_note_revision.js.html @@ -87,13 +87,13 @@ module.exports = NoteRevision;
diff --git a/docs/backend_api/entities_option.js.html b/docs/backend_api/entities_option.js.html index bbc0fb54a..f9dc87bab 100644 --- a/docs/backend_api/entities_option.js.html +++ b/docs/backend_api/entities_option.js.html @@ -76,13 +76,13 @@ module.exports = Option;
diff --git a/docs/backend_api/entities_recent_note.js.html b/docs/backend_api/entities_recent_note.js.html index 79e160eb9..531d0482c 100644 --- a/docs/backend_api/entities_recent_note.js.html +++ b/docs/backend_api/entities_recent_note.js.html @@ -69,13 +69,13 @@ module.exports = RecentNote;
diff --git a/docs/backend_api/global.html b/docs/backend_api/global.html index 193c5d8ab..0759abe47 100644 --- a/docs/backend_api/global.html +++ b/docs/backend_api/global.html @@ -588,13 +588,13 @@
diff --git a/docs/backend_api/index.html b/docs/backend_api/index.html index 263759f06..62ed0511a 100644 --- a/docs/backend_api/index.html +++ b/docs/backend_api/index.html @@ -50,13 +50,13 @@
diff --git a/docs/backend_api/scripts/linenumber.js b/docs/backend_api/scripts/linenumber.js index 8d52f7eaf..4354785ce 100644 --- a/docs/backend_api/scripts/linenumber.js +++ b/docs/backend_api/scripts/linenumber.js @@ -1,12 +1,12 @@ /*global document */ -(function() { - var source = document.getElementsByClassName('prettyprint source linenums'); - var i = 0; - var lineNumber = 0; - var lineId; - var lines; - var totalLines; - var anchorHash; +(() => { + const source = document.getElementsByClassName('prettyprint source linenums'); + let i = 0; + let lineNumber = 0; + let lineId; + let lines; + let totalLines; + let anchorHash; if (source && source[0]) { anchorHash = document.location.hash.substring(1); @@ -15,7 +15,7 @@ for (; i < totalLines; i++) { lineNumber++; - lineId = 'line' + lineNumber; + lineId = `line${lineNumber}`; lines[i].id = lineId; if (lineId === anchorHash) { lines[i].className += ' selected'; diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html index f44d49001..8e5438ee3 100644 --- a/docs/backend_api/services_backend_script_api.js.html +++ b/docs/backend_api/services_backend_script_api.js.html @@ -353,13 +353,13 @@ module.exports = BackendScriptApi;
diff --git a/docs/backend_api/styles/jsdoc-default.css b/docs/backend_api/styles/jsdoc-default.css index 9207bc824..7d1729dc9 100644 --- a/docs/backend_api/styles/jsdoc-default.css +++ b/docs/backend_api/styles/jsdoc-default.css @@ -273,7 +273,7 @@ tr > th:last-child { border-right: 1px solid #ddd; } margin: 0; } -.prettyprint +.source { border: 1px solid #ddd; width: 80%; @@ -284,7 +284,7 @@ tr > th:last-child { border-right: 1px solid #ddd; } width: inherit; } -.prettyprint code +.source code { font-size: 100%; line-height: 18px; diff --git a/docs/frontend_api/Branch.html b/docs/frontend_api/Branch.html index d109bab86..cc6fc3b03 100644 --- a/docs/frontend_api/Branch.html +++ b/docs/frontend_api/Branch.html @@ -93,7 +93,7 @@
Source:
@@ -121,6 +121,8 @@ + + @@ -570,6 +572,8 @@ + +
Returns:
@@ -670,6 +674,8 @@ + +
Returns:
@@ -719,7 +725,7 @@
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html index a7a0842e8..9168cc1a5 100644 --- a/docs/frontend_api/FrontendScriptApi.html +++ b/docs/frontend_api/FrontendScriptApi.html @@ -81,7 +81,7 @@
Source:
@@ -109,6 +109,8 @@ + + @@ -221,7 +223,7 @@
Source:
@@ -334,7 +336,113 @@
Source:
+ + + + + + + + + + + + + + + + +

StandardWidget

+ + + + + + + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + +StandardWidget + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -444,7 +552,7 @@
Source:
@@ -553,7 +661,7 @@
Source:
@@ -682,7 +790,7 @@
Source:
@@ -705,6 +813,8 @@ + +
Returns:
@@ -835,7 +945,7 @@
Source:
@@ -858,6 +968,8 @@ + +
Returns:
@@ -988,7 +1100,7 @@
Source:
@@ -1016,6 +1128,8 @@ + + @@ -1166,7 +1280,7 @@
Source:
@@ -1194,6 +1308,8 @@ + + @@ -1297,7 +1413,7 @@
Source:
@@ -1320,6 +1436,8 @@ + +
Returns:
@@ -1401,7 +1519,7 @@
Source:
@@ -1424,6 +1542,8 @@ + +
Returns:
@@ -1505,7 +1625,7 @@
Source:
@@ -1528,6 +1648,8 @@ + +
Returns:
@@ -1609,7 +1731,7 @@
Source:
@@ -1632,6 +1754,8 @@ + +
Returns:
@@ -1766,7 +1890,7 @@
Source:
@@ -1789,6 +1913,8 @@ + +
Returns:
@@ -1866,7 +1992,7 @@
Source:
@@ -1889,6 +2015,8 @@ + +
Returns:
@@ -1975,7 +2103,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -1998,6 +2126,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -2128,7 +2258,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2151,6 +2281,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -2282,7 +2414,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2305,6 +2437,8 @@ if some action needs to happen on only one specific instance. + +
Returns:
@@ -2481,7 +2615,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2504,6 +2638,8 @@ otherwise (by e.g. createNoteLink()) + +
Returns:
@@ -2585,7 +2721,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2608,6 +2744,8 @@ otherwise (by e.g. createNoteLink()) + +
Returns:
@@ -2738,7 +2876,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2761,6 +2899,8 @@ otherwise (by e.g. createNoteLink()) + +
Returns:
@@ -2845,7 +2985,7 @@ note.
Source:
@@ -2868,6 +3008,8 @@ note. + +
Returns:
@@ -2998,7 +3140,7 @@ note.
Source:
@@ -3026,6 +3168,8 @@ note. + + @@ -3129,7 +3273,7 @@ note.
Source:
@@ -3152,6 +3296,8 @@ note. + +
Returns:
@@ -3233,7 +3379,7 @@ note.
Source:
@@ -3261,6 +3407,8 @@ note. + + @@ -3319,7 +3467,7 @@ note.
Source:
@@ -3342,6 +3490,8 @@ note. + +
Returns:
@@ -3468,7 +3618,7 @@ note.
Source:
@@ -3496,6 +3646,8 @@ note. + + @@ -3599,7 +3751,7 @@ note.
Source:
@@ -3627,6 +3779,8 @@ note. + + @@ -3758,7 +3912,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -3781,6 +3935,8 @@ Internally this serializes the anonymous function into string and sends it to ba + +
Returns:
@@ -3916,7 +4072,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -3939,6 +4095,8 @@ Internally this serializes the anonymous function into string and sends it to ba + +
Returns:
@@ -4070,7 +4228,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4093,6 +4251,8 @@ Internally this serializes the anonymous function into string and sends it to ba + +
Returns:
@@ -4219,7 +4379,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4247,6 +4407,8 @@ Internally this serializes the anonymous function into string and sends it to ba + + @@ -4350,7 +4512,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4378,6 +4540,8 @@ Internally this serializes the anonymous function into string and sends it to ba + + @@ -4485,7 +4649,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4513,6 +4677,8 @@ Internally this serializes the anonymous function into string and sends it to ba + + @@ -4620,7 +4786,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4648,6 +4814,8 @@ Internally this serializes the anonymous function into string and sends it to ba + + @@ -4670,7 +4838,7 @@ Internally this serializes the anonymous function into string and sends it to ba
diff --git a/docs/frontend_api/NoteFull.html b/docs/frontend_api/NoteFull.html index 50bedd792..890782f59 100644 --- a/docs/frontend_api/NoteFull.html +++ b/docs/frontend_api/NoteFull.html @@ -93,7 +93,7 @@
Source:
@@ -121,6 +121,8 @@ + + @@ -453,7 +455,7 @@
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html index a637cb8ba..ded275cfc 100644 --- a/docs/frontend_api/NoteShort.html +++ b/docs/frontend_api/NoteShort.html @@ -94,7 +94,7 @@ Its notable omission is the note content.
Source:
@@ -122,6 +122,8 @@ Its notable omission is the note content. + + @@ -182,7 +184,7 @@ Its notable omission is the note content.
Source:
@@ -240,7 +242,7 @@ Its notable omission is the note content.
Source:
@@ -298,7 +300,7 @@ Its notable omission is the note content.
Source:
@@ -356,7 +358,7 @@ Its notable omission is the note content.
Source:
@@ -414,7 +416,7 @@ Its notable omission is the note content.
Source:
@@ -472,7 +474,7 @@ Its notable omission is the note content.
Source:
@@ -620,7 +622,7 @@ Its notable omission is the note content.
Source:
@@ -643,6 +645,8 @@ Its notable omission is the note content. + +
Returns:
@@ -785,7 +789,7 @@ Its notable omission is the note content.
Source:
@@ -808,6 +812,8 @@ Its notable omission is the note content. + +
Returns:
@@ -957,7 +963,7 @@ Its notable omission is the note content.
Source:
@@ -980,6 +986,8 @@ Its notable omission is the note content. + +
Returns:
@@ -1061,7 +1069,7 @@ Its notable omission is the note content.
Source:
@@ -1084,6 +1092,8 @@ Its notable omission is the note content. + +
Returns:
@@ -1161,7 +1171,7 @@ Its notable omission is the note content.
Source:
@@ -1184,6 +1194,8 @@ Its notable omission is the note content. + +
Returns:
@@ -1261,7 +1273,7 @@ Its notable omission is the note content.
Source:
@@ -1284,6 +1296,8 @@ Its notable omission is the note content. + +
Returns:
@@ -1361,7 +1375,7 @@ Its notable omission is the note content.
Source:
@@ -1384,6 +1398,8 @@ Its notable omission is the note content. + +
Returns:
@@ -1510,7 +1526,7 @@ Its notable omission is the note content.
Source:
@@ -1533,6 +1549,8 @@ Its notable omission is the note content. + +
Returns:
@@ -1675,7 +1693,7 @@ Its notable omission is the note content.
Source:
@@ -1698,6 +1716,8 @@ Its notable omission is the note content. + +
Returns:
@@ -1840,7 +1860,7 @@ Its notable omission is the note content.
Source:
@@ -1863,6 +1883,8 @@ Its notable omission is the note content. + +
Returns:
@@ -1993,7 +2015,7 @@ Its notable omission is the note content.
Source:
@@ -2016,6 +2038,8 @@ Its notable omission is the note content. + +
Returns:
@@ -2097,7 +2121,7 @@ Its notable omission is the note content.
Source:
@@ -2120,6 +2144,8 @@ Its notable omission is the note content. + +
Returns:
@@ -2197,7 +2223,7 @@ Its notable omission is the note content.
Source:
@@ -2220,6 +2246,8 @@ Its notable omission is the note content. + +
Returns:
@@ -2346,7 +2374,7 @@ Its notable omission is the note content.
Source:
@@ -2369,6 +2397,8 @@ Its notable omission is the note content. + +
Returns:
@@ -2511,7 +2541,7 @@ Its notable omission is the note content.
Source:
@@ -2534,6 +2564,8 @@ Its notable omission is the note content. + +
Returns:
@@ -2676,7 +2708,7 @@ Its notable omission is the note content.
Source:
@@ -2699,6 +2731,8 @@ Its notable omission is the note content. + +
Returns:
@@ -2732,7 +2766,7 @@ Its notable omission is the note content. -

(async) getRelationTarget(name) → {Promise.<Note>|null}

+

(async) getRelationTarget(name) → {Promise.<NoteShort>|null}

@@ -2829,7 +2863,7 @@ Its notable omission is the note content.
Source:
@@ -2852,6 +2886,8 @@ Its notable omission is the note content. + +
Returns:
@@ -2867,7 +2903,7 @@ Its notable omission is the note content.
-Promise.<Note> +Promise.<NoteShort> | null @@ -2888,6 +2924,169 @@ Its notable omission is the note content. +

(async) getRelationTargets(nameopt) → {Promise.<Array.<NoteShort>>}

+ + + + + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
name + + +string + + + + + + <optional>
+ + + + + +
relation name to filter
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Promise.<Array.<NoteShort>> + + +
+
+ + + + + + + + + + + + +

(async) getRelationValue(name) → {Promise.<string>}

@@ -2985,7 +3184,7 @@ Its notable omission is the note content.
Source:
@@ -3008,6 +3207,8 @@ Its notable omission is the note content. + +
Returns:
@@ -3041,6 +3242,112 @@ Its notable omission is the note content. +

(async) getTargetRelations() → {Promise.<Array.<Attribute>>}

+ + + + + + +
+ Get relations which target this note +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Promise.<Array.<Attribute>> + + +
+
+ + + + + + + + + + + + +

(async) hasAttribute(type, name) → {Promise.<boolean>}

@@ -3161,7 +3468,7 @@ Its notable omission is the note content.
Source:
@@ -3184,6 +3491,8 @@ Its notable omission is the note content. + +
Returns:
@@ -3265,7 +3574,7 @@ Its notable omission is the note content.
Source:
@@ -3288,6 +3597,8 @@ Its notable omission is the note content. + +
Returns:
@@ -3414,7 +3725,7 @@ Its notable omission is the note content.
Source:
@@ -3437,6 +3748,8 @@ Its notable omission is the note content. + +
Returns:
@@ -3567,7 +3880,7 @@ Its notable omission is the note content.
Source:
@@ -3590,6 +3903,8 @@ Its notable omission is the note content. + +
Returns:
@@ -3676,7 +3991,7 @@ Cache is note instance scoped.
Source:
@@ -3704,6 +4019,8 @@ Cache is note instance scoped. + + @@ -3758,7 +4075,7 @@ Cache is note instance scoped.
Source:
@@ -3781,6 +4098,8 @@ Cache is note instance scoped. + +
Returns:
@@ -3826,7 +4145,7 @@ Cache is note instance scoped.
diff --git a/docs/frontend_api/entities_attribute.js.html b/docs/frontend_api/entities_attribute.js.html index 6dfec708d..01956a8e7 100644 --- a/docs/frontend_api/entities_attribute.js.html +++ b/docs/frontend_api/entities_attribute.js.html @@ -77,7 +77,7 @@ export default Attribute;
diff --git a/docs/frontend_api/entities_branch.js.html b/docs/frontend_api/entities_branch.js.html index 3062203ad..bf5d06879 100644 --- a/docs/frontend_api/entities_branch.js.html +++ b/docs/frontend_api/entities_branch.js.html @@ -76,7 +76,7 @@ export default Branch;
diff --git a/docs/frontend_api/entities_note_full.js.html b/docs/frontend_api/entities_note_full.js.html index 535bbb7c4..ceca67bc9 100644 --- a/docs/frontend_api/entities_note_full.js.html +++ b/docs/frontend_api/entities_note_full.js.html @@ -68,7 +68,7 @@ export default NoteFull;
diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.html index 1ade082db..7dd2448df 100644 --- a/docs/frontend_api/entities_note_short.js.html +++ b/docs/frontend_api/entities_note_short.js.html @@ -27,6 +27,7 @@
import server from '../services/server.js';
+import Attribute from './attribute.js';
 
 const LABEL = 'label';
 const LABEL_DEFINITION = 'label-definition';
@@ -112,7 +113,8 @@ class NoteShort {
      */
     async getAttributes(name) {
         if (!this.attributeCache) {
-            this.attributeCache = await server.get('notes/' + this.noteId + '/attributes');
+            this.attributeCache = (await server.get('notes/' + this.noteId + '/attributes'))
+                .map(attrRow => new Attribute(this.treeCache, attrRow));
         }
 
         if (name) {
@@ -224,12 +226,27 @@ class NoteShort {
 
     /**
      * @param {string} name
-     * @returns {Promise<Note>|null} target note of the relation or null (if target is empty or note was not found)
+     * @returns {Promise<NoteShort>|null} target note of the relation or null (if target is empty or note was not found)
      */
     async getRelationTarget(name) {
-        const relation = await this.getRelation(name);
+        const targets = await this.getRelationTargets(name);
 
-        return relation ? await repository.getNote(relation.value) : null;
+        return targets.length > 0 ? targets[0] : null;
+    }
+
+    /**
+     * @param {string} [name] - relation name to filter
+     * @returns {Promise<NoteShort[]>}
+     */
+    async getRelationTargets(name) {
+        const relations = await this.getRelations(name);
+        const targets = [];
+
+        for (const relation of relations) {
+            targets.push(await this.treeCache.getNote(relation.value));
+        }
+
+        return targets;
     }
 
     /**
@@ -240,6 +257,16 @@ class NoteShort {
         this.attributeCache = null;
     }
 
+    /**
+     * Get relations which target this note
+     *
+     * @returns {Promise<Attribute[]>}
+     */
+    async getTargetRelations() {
+        return (await server.get('notes/' + this.noteId + '/target-relations'))
+            .map(attrRow => new Attribute(this.treeCache, attrRow));
+    }
+
     get toString() {
         return `Note(noteId=${this.noteId}, title=${this.title})`;
     }
@@ -270,7 +297,7 @@ export default NoteShort;

diff --git a/docs/frontend_api/global.html b/docs/frontend_api/global.html index 636c6101d..cb036d1f8 100644 --- a/docs/frontend_api/global.html +++ b/docs/frontend_api/global.html @@ -303,7 +303,7 @@
Source:
@@ -339,7 +339,7 @@
diff --git a/docs/frontend_api/index.html b/docs/frontend_api/index.html index 683315ec3..310dca343 100644 --- a/docs/frontend_api/index.html +++ b/docs/frontend_api/index.html @@ -56,7 +56,7 @@
diff --git a/docs/frontend_api/scripts/linenumber.js b/docs/frontend_api/scripts/linenumber.js index 8d52f7eaf..4354785ce 100644 --- a/docs/frontend_api/scripts/linenumber.js +++ b/docs/frontend_api/scripts/linenumber.js @@ -1,12 +1,12 @@ /*global document */ -(function() { - var source = document.getElementsByClassName('prettyprint source linenums'); - var i = 0; - var lineNumber = 0; - var lineId; - var lines; - var totalLines; - var anchorHash; +(() => { + const source = document.getElementsByClassName('prettyprint source linenums'); + let i = 0; + let lineNumber = 0; + let lineId; + let lines; + let totalLines; + let anchorHash; if (source && source[0]) { anchorHash = document.location.hash.substring(1); @@ -15,7 +15,7 @@ for (; i < totalLines; i++) { lineNumber++; - lineId = 'line' + lineNumber; + lineId = `line${lineNumber}`; lines[i].id = lineId; if (lineId === anchorHash) { lines[i].className += ' selected'; diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html index d04bc8332..203536ab3 100644 --- a/docs/frontend_api/services_frontend_script_api.js.html +++ b/docs/frontend_api/services_frontend_script_api.js.html @@ -35,8 +35,9 @@ import treeCache from './tree_cache.js'; import noteDetailService from './note_detail.js'; import noteTypeService from './note_type.js'; import noteTooltipService from './note_tooltip.js'; -import protectedSessionService from'./protected_session.js'; -import dateNotesService from'./date_notes.js'; +import protectedSessionService from './protected_session.js'; +import dateNotesService from './date_notes.js'; +import StandardWidget from '../widgets/standard_widget.js'; /** * This is the main frontend API interface for scripts. It's published in the local "api" object. @@ -60,6 +61,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte /** @property {TabContext|null} - experimental! */ this.tabContext = tabContext; + /** @property {StandardWidget} */ + this.StandardWidget = StandardWidget; + /** * Activates note in the tree and in the note detail. * @@ -67,7 +71,15 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte * @param {string} notePath (or noteId) * @returns {Promise<void>} */ - this.activateNote = treeService.activateNote; + this.activateNote = async (notePath, noteLoadedListener) => { + await treeService.activateNote(notePath, async () => { + await treeService.scrollToActiveNote(); + + if (noteLoadedListener) { + noteLoadedListener(); + } + }); + }; /** * Activates newly created note. Compared to this.activateNote() also refreshes tree. @@ -115,7 +127,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte } if (opts.shortcut) { - $(document).bind('keydown', opts.shortcut, opts.action); + utils.bindGlobalShortcut(opts.shortcut, opts.action); button.attr("title", "Shortcut " + opts.shortcut); } @@ -401,7 +413,7 @@ export default FrontendScriptApi;
diff --git a/docs/frontend_api/styles/jsdoc-default.css b/docs/frontend_api/styles/jsdoc-default.css index 9207bc824..7d1729dc9 100644 --- a/docs/frontend_api/styles/jsdoc-default.css +++ b/docs/frontend_api/styles/jsdoc-default.css @@ -273,7 +273,7 @@ tr > th:last-child { border-right: 1px solid #ddd; } margin: 0; } -.prettyprint +.source { border: 1px solid #ddd; width: 80%; @@ -284,7 +284,7 @@ tr > th:last-child { border-right: 1px solid #ddd; } width: inherit; } -.prettyprint code +.source code { font-size: 100%; line-height: 18px; diff --git a/package-lock.json b/package-lock.json index 2c4e964ae..e94c930d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -61,6 +61,12 @@ } } }, + "@babel/parser": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz", + "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==", + "dev": true + }, "@babel/polyfill": { "version": "7.4.4", "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.4.4.tgz", @@ -648,12 +654,6 @@ "negotiator": "0.6.2" } }, - "accessibility-developer-tools": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/accessibility-developer-tools/-/accessibility-developer-tools-2.12.0.tgz", - "integrity": "sha1-PaDM6dbsY3OWS4TzXbfPw996tRQ=", - "dev": true - }, "acorn": { "version": "5.7.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", @@ -1830,6 +1830,23 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "catharsis": { + "version": "0.8.11", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.11.tgz", + "integrity": "sha512-a+xUyMV7hD1BrDQA/3iPV7oc+6W26BgVJO05PGEoatMyIuPScQKsde6i3YorWX1qs+AZjnJ18NqdKoCtKiNh1g==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + }, + "dependencies": { + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + } + } + }, "caw": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/caw/-/caw-1.2.0.tgz", @@ -2855,17 +2872,6 @@ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" }, - "devtron": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/devtron/-/devtron-1.4.0.tgz", - "integrity": "sha1-tedIvW6Vu+cL/MaKrm/mlhGUQeE=", - "dev": true, - "requires": { - "accessibility-developer-tools": "^2.11.0", - "highlight.js": "^9.3.0", - "humanize-plus": "^1.8.1" - } - }, "dicer": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", @@ -3121,9 +3127,9 @@ "integrity": "sha512-PcW2a0tyTuPHz3tWyYqtK6r1fZ3gp+3Sop8Ph+ZYN81Ob5rwmbHEzaqs10N3BEsaGTkh/ooniXK+WwszGlc2+Q==" }, "electron": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/electron/-/electron-6.0.2.tgz", - "integrity": "sha512-2SV10JlUsEGZ8CePeQIllFBwrOmm1EONne3Ev7Ro1F4tuS9sF184d3/3wZjEtwOs7hsM6elceYnNuZfx93++YA==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/electron/-/electron-6.0.3.tgz", + "integrity": "sha512-+AFB075WVf4LBR4bdPlkGn/jYQOZ7kC4GpZBeZ3/Fj5SCoFP51TAA5HuPWdMF2KQWjpxx/18jDGqMTYWhIRsEw==", "dev": true, "requires": { "@types/node": "^10.12.18", @@ -5500,9 +5506,9 @@ } }, "file-type": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-12.1.0.tgz", - "integrity": "sha512-aZkf42yWGiH+vSOpbVgvbnoRuX4JiitMX9pHYqTHemNQ3lrx64iHi33YGAP7TSJSno56kxQY1lHmw8S6ujlFUg==" + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-12.2.0.tgz", + "integrity": "sha512-bkDBeH5doAqP69axEO69OviLlWbrZ10Ne2OPHaxBgG+fyT0w/2zfMzJz21SPwq5Iq0aN70q7RN3KRcdUY427Mg==" }, "filename-regex": { "version": "2.0.1", @@ -6622,12 +6628,6 @@ "resolved": "https://registry.npmjs.org/hide-powered-by/-/hide-powered-by-1.1.0.tgz", "integrity": "sha512-Io1zA2yOA1YJslkr+AJlWSf2yWFkKjvkcL9Ni1XSUqnGLr/qRQe2UI3Cn/J9MsJht7yEVCe0SscY1HgVMujbgg==" }, - "highlight.js": { - "version": "9.12.0", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz", - "integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=", - "dev": true - }, "hosted-git-info": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", @@ -6774,12 +6774,6 @@ } } }, - "humanize-plus": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/humanize-plus/-/humanize-plus-1.8.2.tgz", - "integrity": "sha1-pls0RZrWNnrbs3B6gqPJ+RYWcDA=", - "dev": true - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -7672,11 +7666,62 @@ } } }, + "js2xmlparser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.0.tgz", + "integrity": "sha512-WuNgdZOXVmBk5kUPMcTcVUpbGRzLfNkv7+7APq7WiDihpXVKrgxo6wwRpRl9OQeEBgKCVk9mR7RbzrnNWC8oBw==", + "dev": true, + "requires": { + "xmlcreate": "^2.0.0" + } + }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, + "jsdoc": { + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.3.tgz", + "integrity": "sha512-Yf1ZKA3r9nvtMWHO1kEuMZTlHOF8uoQ0vyo5eH7SQy5YeIiHM+B0DgKnn+X6y6KDYZcF7G2SPkKF+JORCXWE/A==", + "dev": true, + "requires": { + "@babel/parser": "^7.4.4", + "bluebird": "^3.5.4", + "catharsis": "^0.8.11", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.0", + "klaw": "^3.0.0", + "markdown-it": "^8.4.2", + "markdown-it-anchor": "^5.0.2", + "marked": "^0.7.0", + "mkdirp": "^0.5.1", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.0.1", + "taffydb": "2.6.2", + "underscore": "~1.9.1" + }, + "dependencies": { + "bluebird": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", + "dev": true + }, + "escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true + }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + } + } + }, "jsdom": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-11.12.0.tgz", @@ -7807,6 +7852,15 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" }, + "klaw": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", + "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.9" + } + }, "latest-version": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", @@ -7864,6 +7918,15 @@ "integrity": "sha1-ODuD/KhIj6p6WZQOvyi4IFjBbFU=", "dev": true }, + "linkify-it": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", + "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", + "dev": true, + "requires": { + "uc.micro": "^1.0.1" + } + }, "load-bmfont": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.0.tgz", @@ -8221,6 +8284,31 @@ "object-visit": "^1.0.0" } }, + "markdown-it": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz", + "integrity": "sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "entities": "~1.1.1", + "linkify-it": "^2.0.0", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + } + }, + "markdown-it-anchor": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.2.4.tgz", + "integrity": "sha512-n8zCGjxA3T+Mx1pG8HEgbJbkB8JFUuRkeTZQuIM8iPY6oQ8sWOPRZJDFC9a/pNg2QkHEjjGkhBEl/RSyzaDZ3A==", + "dev": true + }, + "marked": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz", + "integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==", + "dev": true + }, "math-random": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz", @@ -9173,7 +9261,7 @@ }, "semver": { "version": "5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "resolved": "http://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true } @@ -9205,9 +9293,9 @@ } }, "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" } } }, @@ -9291,9 +9379,9 @@ } }, "npm-packlist": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", - "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.4.tgz", + "integrity": "sha512-zTLo8UcVYtDU3gdeaFu2Xu0n0EvelfHDGuqtNIn5RO7yQj4H1TqNdBc/yZjxnWA0PVB8D3Woyp0i5B43JwQ6Vw==", "requires": { "ignore-walk": "^3.0.1", "npm-bundled": "^1.0.1" @@ -11323,6 +11411,23 @@ "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", "dev": true }, + "requizzle": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", + "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + }, + "dependencies": { + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + } + } + }, "resolve": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", @@ -12020,9 +12125,9 @@ } }, "sqlite3": { - "version": "4.0.9", - "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-4.0.9.tgz", - "integrity": "sha512-IkvzjmsWQl9BuBiM4xKpl5X8WCR4w0AeJHRdobCdXZ8dT/lNc1XS6WqvY35N6+YzIIgzSBeY5prdFObID9F9tA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-4.1.0.tgz", + "integrity": "sha512-RvqoKxq+8pDHsJo7aXxsFR18i+dU2Wp5o12qAJOV5LNcDt+fgJsc2QKKg3sIRfXrN9ZjzY1T7SNe/DFVqAXjaw==", "requires": { "nan": "^2.12.1", "node-pre-gyp": "^0.11.0", @@ -12365,6 +12470,12 @@ } } }, + "taffydb": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", + "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", + "dev": true + }, "tar": { "version": "4.4.8", "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", @@ -12760,6 +12871,12 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, + "uc.micro": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", + "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", + "dev": true + }, "uid-safe": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", @@ -12777,6 +12894,12 @@ "through": "^2.3.8" } }, + "underscore": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==", + "dev": true + }, "unescape": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unescape/-/unescape-1.0.1.tgz", @@ -13458,6 +13581,12 @@ "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" }, + "xmlcreate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.1.tgz", + "integrity": "sha512-MjGsXhKG8YjTKrDCXseFo3ClbMGvUD4en29H2Cev1dv4P/chlpw6KdYmlCWDkhosBVKRDjM836+3e3pm1cBNJA==", + "dev": true + }, "xmldom": { "version": "0.1.27", "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz", diff --git a/package.json b/package.json index 5bb2513da..775b52936 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "scripts": { "start-server": "TRILIUM_ENV=dev node ./src/www", "start-electron": "TRILIUM_ENV=dev electron . --disable-gpu", - "build-backend-docs": "jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/entities/*.js src/services/backend_script_api.js", - "build-frontend-docs": "jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/javascripts/entities/*.js src/public/javascripts/services/frontend_script_api.js", + "build-backend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/entities/*.js src/services/backend_script_api.js", + "build-frontend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/javascripts/entities/*.js src/public/javascripts/services/frontend_script_api.js", "build-docs": "npm run build-backend-docs && npm run build-frontend-docs", "postinstall": "electron-builder install-app-deps" }, @@ -38,7 +38,7 @@ "electron-window-state": "5.0.3", "express": "4.17.1", "express-session": "1.16.2", - "file-type": "12.1.0", + "file-type": "12.2.0", "fs-extra": "8.1.0", "helmet": "3.20.0", "html": "1.0.0", @@ -69,7 +69,7 @@ "session-file-store": "1.3.1", "simple-node-logger": "18.12.23", "sqlite": "3.0.3", - "sqlite3": "4.0.9", + "sqlite3": "4.1.0", "tar-stream": "2.1.0", "turndown": "5.0.3", "unescape": "1.0.1", @@ -77,12 +77,13 @@ "xml2js": "0.4.19" }, "devDependencies": { - "electron": "6.0.2", + "electron": "6.0.3", "electron-builder": "21.2.0", "electron-compile": "6.4.4", "electron-installer-debian": "2.0.0", "electron-packager": "14.0.4", "electron-rebuild": "1.8.6", + "jsdoc": "^3.6.3", "lorem-ipsum": "2.0.3", "xo": "0.24.0" }, diff --git a/src/public/javascripts/desktop.js b/src/public/javascripts/desktop.js index 831079666..0748bf2c0 100644 --- a/src/public/javascripts/desktop.js +++ b/src/public/javascripts/desktop.js @@ -1,17 +1,3 @@ -import addLinkDialog from './dialogs/add_link.js'; -import jumpToNoteDialog from './dialogs/jump_to_note.js'; -import attributesDialog from './dialogs/attributes.js'; -import noteRevisionsDialog from './dialogs/note_revisions.js'; -import noteSourceDialog from './dialogs/note_source.js'; -import recentChangesDialog from './dialogs/recent_changes.js'; -import optionsDialog from './dialogs/options.js'; -import sqlConsoleDialog from './dialogs/sql_console.js'; -import markdownImportDialog from './dialogs/markdown_import.js'; -import exportDialog from './dialogs/export.js'; -import importDialog from './dialogs/import.js'; -import protectedSessionDialog from './dialogs/protected_session.js'; -import linkMapDialog from './dialogs/link_map.js'; - import cloning from './services/cloning.js'; import contextMenu from './services/tree_context_menu.js'; import dragAndDropSetup from './services/drag_and_drop.js'; @@ -50,7 +36,7 @@ window.glob.isMobile = utils.isMobile; // required for CKEditor image upload plugin window.glob.getActiveNode = treeService.getActiveNode; window.glob.getHeaders = server.getHeaders; -window.glob.showAddLinkDialog = addLinkDialog.showDialog; +window.glob.showAddLinkDialog = () => import('./dialogs/add_link.js').then(d => d.showDialog()); // this is required by CKEditor when uploading images window.glob.noteChanged = noteDetailService.noteChanged; window.glob.refreshTree = treeService.reload; diff --git a/src/public/javascripts/dialogs/about.js b/src/public/javascripts/dialogs/about.js index e96d591f1..3a07d95c6 100644 --- a/src/public/javascripts/dialogs/about.js +++ b/src/public/javascripts/dialogs/about.js @@ -9,7 +9,7 @@ const $buildDate = $("#build-date"); const $buildRevision = $("#build-revision"); const $dataDirectory = $("#data-directory"); -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); const appInfo = await server.get('app-info'); @@ -25,8 +25,4 @@ async function showDialog() { glob.activeDialog = $dialog; $dialog.modal(); -} - -export default { - showDialog } \ No newline at end of file diff --git a/src/public/javascripts/dialogs/add_link.js b/src/public/javascripts/dialogs/add_link.js index f94516846..c55a4794c 100644 --- a/src/public/javascripts/dialogs/add_link.js +++ b/src/public/javascripts/dialogs/add_link.js @@ -24,11 +24,11 @@ function setLinkType(linkType) { linkTypeChanged(); } -async function showDialogForClone() { +export async function showDialogForClone() { showDialog('selected-to-active'); } -async function showDialog(linkType) { +export async function showDialog(linkType) { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -147,8 +147,3 @@ function linkTypeChanged() { } $linkTypes.change(linkTypeChanged); - -export default { - showDialog, - showDialogForClone -}; \ No newline at end of file diff --git a/src/public/javascripts/dialogs/attributes.js b/src/public/javascripts/dialogs/attributes.js index ed3cdecc8..7e5659f76 100644 --- a/src/public/javascripts/dialogs/attributes.js +++ b/src/public/javascripts/dialogs/attributes.js @@ -254,7 +254,7 @@ function AttributesModel() { } } -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); // lazily apply bindings on first use @@ -285,8 +285,4 @@ $dialog.on('focus', '.label-value', function (e) { $el: $(this), open: true }) -}); - -export default { - showDialog -}; \ No newline at end of file +}); \ No newline at end of file diff --git a/src/public/javascripts/dialogs/branch_prefix.js b/src/public/javascripts/dialogs/branch_prefix.js index ffa4246e6..a8762ec9f 100644 --- a/src/public/javascripts/dialogs/branch_prefix.js +++ b/src/public/javascripts/dialogs/branch_prefix.js @@ -12,7 +12,7 @@ const $noteTitle = $('#branch-prefix-note-title'); let branchId; -async function showDialog(node) { +export async function showDialog(node) { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -47,8 +47,4 @@ $form.submit(() => { return false; }); -$dialog.on('shown.bs.modal', () => $treePrefixInput.focus()); - -export default { - showDialog -}; \ No newline at end of file +$dialog.on('shown.bs.modal', () => $treePrefixInput.focus()); \ No newline at end of file diff --git a/src/public/javascripts/dialogs/confirm.js b/src/public/javascripts/dialogs/confirm.js index 006c9bdc8..6cbac83aa 100644 --- a/src/public/javascripts/dialogs/confirm.js +++ b/src/public/javascripts/dialogs/confirm.js @@ -9,7 +9,7 @@ const DELETE_NOTE_BUTTON_ID = "confirm-dialog-delete-note"; let resolve; let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards -function confirm(message) { +export function confirm(message) { $originallyFocused = $(':focus'); $custom.hide(); @@ -27,7 +27,7 @@ function confirm(message) { return new Promise((res, rej) => { resolve = res; }); } -function confirmDeleteNoteBoxWithNote(title) { +export function confirmDeleteNoteBoxWithNote(title) { glob.activeDialog = $dialog; $confirmContent.text(`Are you sure you want to remove the note "${title}" from relation map?`); @@ -52,7 +52,7 @@ function confirmDeleteNoteBoxWithNote(title) { return new Promise((res, rej) => { resolve = res; }); } -function isDeleteNoteChecked() { +export function isDeleteNoteChecked() { return $("#" + DELETE_NOTE_BUTTON_ID + ":checked").length > 0; } @@ -77,10 +77,4 @@ function doResolve(ret) { } $cancelButton.click(() => doResolve(false)); -$okButton.click(() => doResolve(true)); - -export default { - confirm, - confirmDeleteNoteBoxWithNote, - isDeleteNoteChecked -} \ No newline at end of file +$okButton.click(() => doResolve(true)); \ No newline at end of file diff --git a/src/public/javascripts/dialogs/event_log.js b/src/public/javascripts/dialogs/event_log.js index 66731096f..89ae2ede1 100644 --- a/src/public/javascripts/dialogs/event_log.js +++ b/src/public/javascripts/dialogs/event_log.js @@ -5,7 +5,7 @@ import server from '../services/server.js'; const $dialog = $("#event-log-dialog"); const $list = $("#event-log-list"); -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -29,8 +29,4 @@ async function showDialog() { $list.append(eventEl); } -} - -export default { - showDialog -}; +} \ No newline at end of file diff --git a/src/public/javascripts/dialogs/export.js b/src/public/javascripts/dialogs/export.js index 3d93e9100..749614dfd 100644 --- a/src/public/javascripts/dialogs/export.js +++ b/src/public/javascripts/dialogs/export.js @@ -18,7 +18,7 @@ const $opmlVersions = $("#opml-versions"); let exportId = ''; let branchId = null; -async function showDialog(node, defaultType) { +export async function showDialog(node, defaultType) { utils.closeActiveDialog(); // each opening of the dialog resets the exportId so we don't associate it with previous exports anymore @@ -134,8 +134,4 @@ messagingService.subscribeToMessages(async message => { infoService.showMessage("Export finished successfully."); } -}); - -export default { - showDialog -}; \ No newline at end of file +}); \ No newline at end of file diff --git a/src/public/javascripts/dialogs/help.js b/src/public/javascripts/dialogs/help.js index 85ddf61fe..ccf73dfbc 100644 --- a/src/public/javascripts/dialogs/help.js +++ b/src/public/javascripts/dialogs/help.js @@ -2,14 +2,10 @@ import utils from "../services/utils.js"; const $dialog = $("#help-dialog"); -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; $dialog.modal(); -} - -export default { - showDialog } \ No newline at end of file diff --git a/src/public/javascripts/dialogs/import.js b/src/public/javascripts/dialogs/import.js index c4d8b2ea3..47e39821a 100644 --- a/src/public/javascripts/dialogs/import.js +++ b/src/public/javascripts/dialogs/import.js @@ -21,7 +21,7 @@ const $explodeArchivesCheckbox = $("#explode-archives-checkbox"); let importId; let importIntoNoteId = null; -async function showDialog(node) { +export async function showDialog(node) { utils.closeActiveDialog(); // each opening of the dialog resets the importId so we don't associate it with previous imports anymore @@ -74,7 +74,7 @@ async function importIntoNote(importNoteId) { $dialog.modal('hide'); } -async function uploadFiles(importNoteId, files, options) { +export async function uploadFiles(importNoteId, files, options) { if (files.length === 0) { return; } @@ -144,8 +144,3 @@ $fileUploadInput.change(() => { $importButton.attr("disabled", "disabled"); } }); - -export default { - showDialog, - uploadFiles -} \ No newline at end of file diff --git a/src/public/javascripts/dialogs/info.js b/src/public/javascripts/dialogs/info.js index 5a1eb3193..0a42a851e 100644 --- a/src/public/javascripts/dialogs/info.js +++ b/src/public/javascripts/dialogs/info.js @@ -7,7 +7,7 @@ const $okButton = $("#info-dialog-ok-button"); let resolve; let $originallyFocused; // element focused before the dialog was opened so we can return to it afterwards -function info(message) { +export function info(message) { $originallyFocused = $(':focus'); utils.closeActiveDialog(); @@ -34,8 +34,4 @@ $dialog.on("hidden.bs.modal", () => { } }); -$okButton.click(() => $dialog.modal("hide")); - -export default { - info -} \ No newline at end of file +$okButton.click(() => $dialog.modal("hide")); \ No newline at end of file diff --git a/src/public/javascripts/dialogs/jump_to_note.js b/src/public/javascripts/dialogs/jump_to_note.js index 46533ff31..e6539d18e 100644 --- a/src/public/javascripts/dialogs/jump_to_note.js +++ b/src/public/javascripts/dialogs/jump_to_note.js @@ -7,7 +7,7 @@ const $dialog = $("#jump-to-note-dialog"); const $autoComplete = $("#jump-to-note-autocomplete"); const $showInFullTextButton = $("#show-in-full-text-button"); -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -46,7 +46,3 @@ function showInFullText(e) { $showInFullTextButton.click(showInFullText); utils.bindElShortcut($dialog, 'ctrl+return', showInFullText); - -export default { - showDialog -}; \ No newline at end of file diff --git a/src/public/javascripts/dialogs/link_map.js b/src/public/javascripts/dialogs/link_map.js index 873865d9f..6f0ca6ba4 100644 --- a/src/public/javascripts/dialogs/link_map.js +++ b/src/public/javascripts/dialogs/link_map.js @@ -26,7 +26,7 @@ let jsPlumbInstance = null; let pzInstance = null; let renderer = null; -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -216,7 +216,3 @@ function noteIdToId(noteId) { $(".link-map-settings").change(loadNotesAndRelations); $maxNotesInput.on("input", loadNotesAndRelations); - -export default { - showDialog -}; \ No newline at end of file diff --git a/src/public/javascripts/dialogs/markdown_import.js b/src/public/javascripts/dialogs/markdown_import.js index eab3843e1..1a1e2e36a 100644 --- a/src/public/javascripts/dialogs/markdown_import.js +++ b/src/public/javascripts/dialogs/markdown_import.js @@ -25,7 +25,7 @@ async function convertMarkdownToHtml(text) { infoService.showMessage("Markdown content has been imported into the document."); } -async function importMarkdownInline() { +export async function importMarkdownInline() { if (utils.isElectron()) { const {clipboard} = require('electron'); const text = clipboard.readText(); @@ -56,8 +56,4 @@ $importButton.click(sendForm); utils.bindElShortcut($dialog, 'ctrl+return', sendForm); // for CKEditor integration (button on block toolbar) -window.glob.importMarkdownInline = importMarkdownInline; - -export default { - importMarkdownInline -}; \ No newline at end of file +window.glob.importMarkdownInline = importMarkdownInline; \ No newline at end of file diff --git a/src/public/javascripts/dialogs/note_info.js b/src/public/javascripts/dialogs/note_info.js index 15e976c0c..9da0d2ca3 100644 --- a/src/public/javascripts/dialogs/note_info.js +++ b/src/public/javascripts/dialogs/note_info.js @@ -9,7 +9,7 @@ const $type = $("#note-info-type"); const $mime = $("#note-info-mime"); const $okButton = $("#note-info-ok-button"); -function showDialog() { +export function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -26,7 +26,3 @@ function showDialog() { } $okButton.click(() => $dialog.modal('hide')); - -export default { - showDialog -}; \ No newline at end of file diff --git a/src/public/javascripts/dialogs/note_revisions.js b/src/public/javascripts/dialogs/note_revisions.js index 8ac7531a6..ed559135e 100644 --- a/src/public/javascripts/dialogs/note_revisions.js +++ b/src/public/javascripts/dialogs/note_revisions.js @@ -14,7 +14,7 @@ async function showCurrentNoteRevisions() { await showNoteRevisionsDialog(noteDetailService.getActiveNoteId()); } -async function showNoteRevisionsDialog(noteId, noteRevisionId) { +export async function showNoteRevisionsDialog(noteId, noteRevisionId) { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -73,7 +73,3 @@ $(document).on('click', "a[data-action='note-revision']", event => { return false; }); - -export default { - showCurrentNoteRevisions -}; \ No newline at end of file diff --git a/src/public/javascripts/dialogs/note_source.js b/src/public/javascripts/dialogs/note_source.js index e913cd3d4..22d48fd39 100644 --- a/src/public/javascripts/dialogs/note_source.js +++ b/src/public/javascripts/dialogs/note_source.js @@ -4,7 +4,7 @@ import utils from "../services/utils.js"; const $dialog = $("#note-source-dialog"); const $noteSource = $("#note-source"); -function showDialog() { +export function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -41,8 +41,4 @@ function formatNode(node, level) { } return node; -} - -export default { - showDialog -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/public/javascripts/dialogs/options.js b/src/public/javascripts/dialogs/options.js index 323ebfb0f..fc68a0cbf 100644 --- a/src/public/javascripts/dialogs/options.js +++ b/src/public/javascripts/dialogs/options.js @@ -16,7 +16,7 @@ function addTabHandler(handler) { tabHandlers.push(handler); } -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -38,11 +38,6 @@ async function saveOptions(options) { infoService.showMessage("Options change have been saved."); } -export default { - showDialog, - saveOptions -}; - addTabHandler((function() { const $themeSelect = $("#theme-select"); const $zoomFactorSelect = $("#zoom-factor-select"); diff --git a/src/public/javascripts/dialogs/prompt.js b/src/public/javascripts/dialogs/prompt.js index 5c5004c97..085948302 100644 --- a/src/public/javascripts/dialogs/prompt.js +++ b/src/public/javascripts/dialogs/prompt.js @@ -11,7 +11,7 @@ const $form = $("#prompt-dialog-form"); let resolve; let shownCb; -function ask({ message, defaultValue, shown }) { +export function ask({ message, defaultValue, shown }) { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -58,7 +58,3 @@ $form.submit(() => { $dialog.modal('hide'); }); - -export default { - ask -} \ No newline at end of file diff --git a/src/public/javascripts/dialogs/protected_session.js b/src/public/javascripts/dialogs/protected_session.js index 46cfa66a7..dd2debb54 100644 --- a/src/public/javascripts/dialogs/protected_session.js +++ b/src/public/javascripts/dialogs/protected_session.js @@ -4,13 +4,13 @@ const $dialog = $("#protected-session-password-dialog"); const $passwordForm = $dialog.find(".protected-session-password-form"); const $passwordInput = $dialog.find(".protected-session-password"); -function show() { +export function show() { $dialog.modal(); $passwordInput.focus(); } -function close() { +export function close() { // this may fal if the dialog has not been previously opened (not sure if still true with Bootstrap modal) try { $dialog.modal('hide'); @@ -26,8 +26,3 @@ $passwordForm.submit(() => { return false; }); - -export default { - show, - close -} \ No newline at end of file diff --git a/src/public/javascripts/dialogs/recent_changes.js b/src/public/javascripts/dialogs/recent_changes.js index 00ebbbfac..b92e812a6 100644 --- a/src/public/javascripts/dialogs/recent_changes.js +++ b/src/public/javascripts/dialogs/recent_changes.js @@ -5,7 +5,7 @@ import server from '../services/server.js'; const $dialog = $("#recent-changes-dialog"); const $content = $("#recent-changes-content"); -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -76,7 +76,3 @@ function groupByDate(result) { } return groupedByDate; } - -export default { - showDialog -}; \ No newline at end of file diff --git a/src/public/javascripts/dialogs/sql_console.js b/src/public/javascripts/dialogs/sql_console.js index 92a87b243..83c706124 100644 --- a/src/public/javascripts/dialogs/sql_console.js +++ b/src/public/javascripts/dialogs/sql_console.js @@ -14,7 +14,7 @@ let codeEditor; $dialog.on("shown.bs.modal", e => initEditor()); -async function showDialog() { +export async function showDialog() { utils.closeActiveDialog(); glob.activeDialog = $dialog; @@ -130,7 +130,3 @@ async function showTables() { utils.bindElShortcut($query, 'ctrl+return', execute); $executeButton.click(execute); - -export default { - showDialog -}; \ No newline at end of file diff --git a/src/public/javascripts/services/branches.js b/src/public/javascripts/services/branches.js index 22aca4618..d69dd6692 100644 --- a/src/public/javascripts/services/branches.js +++ b/src/public/javascripts/services/branches.js @@ -6,7 +6,6 @@ import treeCache from "./tree_cache.js"; import treeUtils from "./tree_utils.js"; import hoistedNoteService from "./hoisted_note.js"; import noteDetailService from "./note_detail.js"; -import confirmDialog from "../dialogs/confirm.js"; async function moveBeforeNode(nodesToMove, beforeNode) { nodesToMove = await filterRootNote(nodesToMove); @@ -90,6 +89,8 @@ async function deleteNodes(nodes) { const nodeTitles = $("
    ").append(...nodes.map(node => $("
  • ").text(node.title))); const confirmText = $("
    ").text('This will delete the following notes and their sub-notes: ').append(nodeTitles); + const confirmDialog = await import('../dialogs/confirm.js'); + if (!await confirmDialog.confirm(confirmText)) { return false; } diff --git a/src/public/javascripts/services/drag_and_drop.js b/src/public/javascripts/services/drag_and_drop.js index 520f60d88..19c354c55 100644 --- a/src/public/javascripts/services/drag_and_drop.js +++ b/src/public/javascripts/services/drag_and_drop.js @@ -1,6 +1,5 @@ import treeService from './tree.js'; import treeChangesService from './branches.js'; -import importDialog from '../dialogs/import.js'; const dragAndDropSetup = { autoExpandMS: 600, @@ -25,10 +24,12 @@ const dragAndDropSetup = { }, dragEnter: (node, data) => true, // allow drop on any node dragOver: (node, data) => true, - dragDrop: (node, data) => { + dragDrop: async (node, data) => { const dataTransfer = data.dataTransfer; if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) { + const importDialog = await import('../dialogs/import.js'); + importDialog.uploadFiles(node.data.noteId, dataTransfer.files, { safeImport: true, shrinkImages: true, diff --git a/src/public/javascripts/services/entrypoints.js b/src/public/javascripts/services/entrypoints.js index 7e6d73c06..3cf60bd59 100644 --- a/src/public/javascripts/services/entrypoints.js +++ b/src/public/javascripts/services/entrypoints.js @@ -1,21 +1,21 @@ import utils from "./utils.js"; -import treeService from "./tree.js"; import linkService from "./link.js"; import zoomService from "./zoom.js"; -import noteRevisionsDialog from "../dialogs/note_revisions.js"; -import optionsDialog from "../dialogs/options.js"; -import addLinkDialog from "../dialogs/add_link.js"; -import jumpToNoteDialog from "../dialogs/jump_to_note.js"; -import noteSourceDialog from "../dialogs/note_source.js"; -import recentChangesDialog from "../dialogs/recent_changes.js"; -import sqlConsoleDialog from "../dialogs/sql_console.js"; -import searchNotesService from "./search_notes.js"; -import attributesDialog from "../dialogs/attributes.js"; -import helpDialog from "../dialogs/help.js"; -import noteInfoDialog from "../dialogs/note_info.js"; -import aboutDialog from "../dialogs/about.js"; -import linkMapDialog from "../dialogs/link_map.js"; import protectedSessionService from "./protected_session.js"; +import searchNotesService from "./search_notes.js"; + +const NOTE_REVISIONS = "../dialogs/note_revisions.js"; +const OPTIONS = "../dialogs/options.js"; +const ADD_LINK = "../dialogs/add_link.js"; +const JUMP_TO_NOTE = "../dialogs/jump_to_note.js"; +const NOTE_SOURCE = "../dialogs/note_source.js"; +const RECENT_CHANGES = "../dialogs/recent_changes.js"; +const SQL_CONSOLE = "../dialogs/sql_console.js"; +const ATTRIBUTES = "../dialogs/attributes.js"; +const HELP = "../dialogs/help.js"; +const NOTE_INFO = "../dialogs/note_info.js"; +const ABOUT = "../dialogs/about.js"; +const LINK_MAP = "../dialogs/link_map.js"; function registerEntrypoints() { // hot keys are active also inside inputs and content editables @@ -23,13 +23,13 @@ function registerEntrypoints() { jQuery.hotkeys.options.filterContentEditable = false; jQuery.hotkeys.options.filterTextInputs = false; - utils.bindGlobalShortcut('ctrl+l', addLinkDialog.showDialog); - utils.bindGlobalShortcut('ctrl+shift+l', addLinkDialog.showDialogForClone); + utils.bindGlobalShortcut('ctrl+l', () => import(ADD_LINK).then(d => d.showDialog())); + utils.bindGlobalShortcut('ctrl+shift+l', () => import(ADD_LINK).then(d => d.showDialogForClone())); - $("#jump-to-note-dialog-button").click(jumpToNoteDialog.showDialog); - utils.bindGlobalShortcut('ctrl+j', jumpToNoteDialog.showDialog); + $("#jump-to-note-dialog-button").click(() => import(JUMP_TO_NOTE).then(d => d.showDialog())); + utils.bindGlobalShortcut('ctrl+j', () => import(JUMP_TO_NOTE).then(d => d.showDialog())); - $("#recent-changes-button").click(recentChangesDialog.showDialog); + $("#recent-changes-button").click(() => import(RECENT_CHANGES).then(d => d.showDialog())); $("#enter-protected-session-button").click(protectedSessionService.enterProtectedSession); $("#leave-protected-session-button").click(protectedSessionService.leaveProtectedSession); @@ -38,17 +38,17 @@ function registerEntrypoints() { utils.bindGlobalShortcut('ctrl+s', searchNotesService.toggleSearch); const $noteTabContainer = $("#note-tab-container"); - $noteTabContainer.on("click", ".show-attributes-button", attributesDialog.showDialog); - utils.bindGlobalShortcut('alt+a', attributesDialog.showDialog); + $noteTabContainer.on("click", ".show-attributes-button", () => import(ATTRIBUTES).then(d => d.showDialog())); + utils.bindGlobalShortcut('alt+a', () => import(ATTRIBUTES).then(d => d.showDialog())); - $noteTabContainer.on("click", ".show-note-info-button", noteInfoDialog.showDialog); + $noteTabContainer.on("click", ".show-note-info-button", () => import(NOTE_INFO).then(d => d.showDialog())); $noteTabContainer.on("click", ".show-note-revisions-button", function() { if ($(this).hasClass("disabled")) { return; } - noteRevisionsDialog.showCurrentNoteRevisions(); + import(NOTE_REVISIONS).then(d => d.showDialog()); }); $noteTabContainer.on("click", ".show-source-button", function() { @@ -56,22 +56,26 @@ function registerEntrypoints() { return; } - noteSourceDialog.showDialog(); + import(NOTE_SOURCE).then(d => { + console.log(d); + + d.showDialog() + }); }); $noteTabContainer.on("click", ".show-link-map-button", function() { - linkMapDialog.showDialog(); + import(LINK_MAP).then(d => d.showDialog()); }); - $("#options-button").click(optionsDialog.showDialog); + $("#options-button").click(() => import(OPTIONS).then(d => d.showDialog())); - $("#show-help-button").click(helpDialog.showDialog); - utils.bindGlobalShortcut('f1', helpDialog.showDialog); + $("#show-help-button").click(() => import(HELP).then(d => d.showDialog())); + utils.bindGlobalShortcut('f1', () => import(HELP).then(d => d.showDialog())); - $("#open-sql-console-button").click(sqlConsoleDialog.showDialog); - utils.bindGlobalShortcut('alt+o', sqlConsoleDialog.showDialog); + $("#open-sql-console-button").click(() => import(SQL_CONSOLE).then(d => d.showDialog())); + utils.bindGlobalShortcut('alt+o', () => import(SQL_CONSOLE).then(d => d.showDialog())); - $("#show-about-dialog-button").click(aboutDialog.showDialog); + $("#show-about-dialog-button").click(() => import(ABOUT).then(d => d.showDialog())); if (utils.isElectron()) { $("#history-navigation").show(); diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js index e35f68be7..476780694 100644 --- a/src/public/javascripts/services/note_detail.js +++ b/src/public/javascripts/services/note_detail.js @@ -2,12 +2,10 @@ import treeService from './tree.js'; import TabContext from './tab_context.js'; import server from './server.js'; import messagingService from "./messaging.js"; -import infoService from "./info.js"; import treeCache from "./tree_cache.js"; import NoteFull from "../entities/note_full.js"; import bundleService from "./bundle.js"; import utils from "./utils.js"; -import importDialog from "../dialogs/import.js"; import contextMenuService from "./context_menu.js"; import treeUtils from "./tree_utils.js"; import tabRow from "./tab_row.js"; @@ -383,13 +381,14 @@ $tabContentsContainer.on("dragover", e => e.preventDefault()); $tabContentsContainer.on("dragleave", e => e.preventDefault()); -$tabContentsContainer.on("drop", e => { +$tabContentsContainer.on("drop", async e => { const activeNote = getActiveNote(); if (!activeNote) { return; } + const importDialog = await import("../dialogs/import.js"); importDialog.uploadFiles(activeNote.noteId, e.originalEvent.dataTransfer.files, { safeImport: true, shrinkImages: true, diff --git a/src/public/javascripts/services/note_detail_relation_map.js b/src/public/javascripts/services/note_detail_relation_map.js index bd69a6d6c..9652d6df2 100644 --- a/src/public/javascripts/services/note_detail_relation_map.js +++ b/src/public/javascripts/services/note_detail_relation_map.js @@ -6,9 +6,6 @@ import treeService from "./tree.js"; import contextMenuWidget from "./context_menu.js"; import infoService from "./info.js"; import attributeAutocompleteService from "./attribute_autocomplete.js"; -import promptDialog from "../dialogs/prompt.js"; -import infoDialog from "../dialogs/info.js"; -import confirmDialog from "../dialogs/confirm.js"; const uniDirectionalOverlays = [ [ "Arrow", { @@ -125,6 +122,7 @@ class NoteDetailRelationMap { this.clipboard = null; this.$createChildNote.click(async () => { + const promptDialog = await import('"../dialogs/prompt.js"'); const title = await promptDialog.ask({ message: "Enter title of new note", defaultValue: "new note" }); if (!title.trim()) { @@ -164,6 +162,8 @@ class NoteDetailRelationMap { noteDetailService.openInTab(noteId); } else if (cmd === "remove") { + const confirmDialog = await import('../dialogs/confirm.js'); + if (!await confirmDialog.confirmDeleteNoteBoxWithNote($title.text())) { return; } @@ -184,6 +184,7 @@ class NoteDetailRelationMap { this.saveData(); } else if (cmd === "edit-title") { + const promptDialog = await import('"../dialogs/prompt.js"'); const title = await promptDialog.ask({ message: "Enter new note title:", defaultValue: $title.text() @@ -429,6 +430,8 @@ class NoteDetailRelationMap { }, selectContextMenuItem: async (event, cmd) => { if (cmd === 'remove') { + const confirmDialog = await import('../dialogs/confirm.js'); + if (!await confirmDialog.confirm("Are you sure you want to remove the relation?")) { return; } @@ -451,6 +454,7 @@ class NoteDetailRelationMap { return; } + const promptDialog = await import('"../dialogs/prompt.js"'); const name = await promptDialog.ask({ message: "Specify new relation name:", shown: ({ $answer }) => @@ -476,6 +480,7 @@ class NoteDetailRelationMap { && rel.name === name); if (relationExists) { + const infoDialog = await import('../dialogs/info.js'); await infoDialog.info("Connection '" + name + "' between these notes already exists."); this.jsPlumbInstance.deleteConnection(connection); diff --git a/src/public/javascripts/services/note_type.js b/src/public/javascripts/services/note_type.js index a39d7b505..dd00ab672 100644 --- a/src/public/javascripts/services/note_type.js +++ b/src/public/javascripts/services/note_type.js @@ -2,7 +2,6 @@ import treeService from './tree.js'; import noteDetailService from './note_detail.js'; import server from './server.js'; import infoService from "./info.js"; -import confirmDialog from "../dialogs/confirm.js"; const DEFAULT_MIME_TYPES = [ { mime: 'text/x-csrc', title: 'C' }, @@ -113,12 +112,13 @@ function NoteTypeContext(ctx) { self.updateExecuteScriptButtonVisibility(); } - function confirmChangeIfContent() { + async function confirmChangeIfContent() { if (!self.ctx.getComponent().getContent()) { return true; } - return confirmDialog.confirm("It is not recommended to change note type when note content is not empty. Do you want to continue anyway?"); + const confirmDialog = await import("../dialogs/confirm.js"); + return await confirmDialog.confirm("It is not recommended to change note type when note content is not empty. Do you want to continue anyway?"); } this.selectText = async function() { diff --git a/src/public/javascripts/services/protected_session.js b/src/public/javascripts/services/protected_session.js index b18c740f6..c24adbbaa 100644 --- a/src/public/javascripts/services/protected_session.js +++ b/src/public/javascripts/services/protected_session.js @@ -4,7 +4,6 @@ import utils from './utils.js'; import server from './server.js'; import protectedSessionHolder from './protected_session_holder.js'; import infoService from "./info.js"; -import protectedSessionDialog from "../dialogs/protected_session.js"; const $enterProtectedSessionButton = $("#enter-protected-session-button"); const $leaveProtectedSessionButton = $("#leave-protected-session-button"); @@ -28,7 +27,7 @@ function enterProtectedSession() { // using deferred instead of promise because it allows resolving from outside protectedSessionDeferred = dfd; - protectedSessionDialog.show(); + import("../dialogs/protected_session.js").then(protectedSessionDialog => protectedSessionDialog.show()) } return dfd.promise(); diff --git a/src/public/javascripts/services/sidebar.js b/src/public/javascripts/services/sidebar.js index 15270c9d9..585cb1958 100644 --- a/src/public/javascripts/services/sidebar.js +++ b/src/public/javascripts/services/sidebar.js @@ -1,8 +1,3 @@ -import NoteInfoWidget from "../widgets/note_info.js"; -import LinkMapWidget from "../widgets/link_map.js"; -import NoteRevisionsWidget from "../widgets/note_revisions.js"; -import AttributesWidget from "../widgets/attributes.js"; -import WhatLinksHereWidget from "../widgets/what_links_here.js"; import bundleService from "./bundle.js"; import messagingService from "./messaging.js"; @@ -32,6 +27,7 @@ class Sidebar { this.$sidebar.show(); this.$showSideBarButton.hide(); this.ctx.stateChanged(); + this.noteLoaded(); }); this.$showSideBarButton.toggle(!state.visible); @@ -50,10 +46,20 @@ class Sidebar { } async noteLoaded() { + if (!this.isVisible() || !this.ctx.note) { + return; + } + this.widgets = []; this.$widgetContainer.empty(); - const widgetClasses = [AttributesWidget, LinkMapWidget, WhatLinksHereWidget, NoteRevisionsWidget, NoteInfoWidget]; + const widgetClasses = [ + await import("../widgets/note_info.js"), + await import("../widgets/link_map.js"), + await import("../widgets/note_revisions.js"), + await import("../widgets/attributes.js"), + await import("../widgets/what_links_here.js") + ].map(m => m.default); const widgetRelations = await this.ctx.note.getRelations('widget'); diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 1dfa7428e..b720652b4 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -13,7 +13,6 @@ import treeKeyBindings from "./tree_keybindings.js"; import Branch from '../entities/branch.js'; import NoteShort from '../entities/note_short.js'; import hoistedNoteService from '../services/hoisted_note.js'; -import confirmDialog from "../dialogs/confirm.js"; import optionsInit from "../services/options_init.js"; import TreeContextMenu from "./tree_context_menu.js"; import bundle from "./bundle.js"; @@ -154,6 +153,8 @@ async function activateNote(notePath, noteLoadedListener) { const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); if (hoistedNoteId !== 'root' && !runNotePath.includes(hoistedNoteId)) { + const confirmDialog = await import('../dialogs/confirm.js'); + if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree. Do you want to unhoist?")) { return; } diff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.js index 8e073aed5..b407f476a 100644 --- a/src/public/javascripts/services/tree_context_menu.js +++ b/src/public/javascripts/services/tree_context_menu.js @@ -3,9 +3,6 @@ import messagingService from './messaging.js'; import protectedSessionService from './protected_session.js'; import treeChangesService from './branches.js'; import treeUtils from './tree_utils.js'; -import branchPrefixDialog from '../dialogs/branch_prefix.js'; -import exportDialog from '../dialogs/export.js'; -import importDialog from '../dialogs/import.js'; import treeCache from "./tree_cache.js"; import syncService from "./sync.js"; import hoistedNoteService from './hoisted_note.js'; @@ -108,6 +105,7 @@ class TreeContextMenu { }); } else if (cmd === "editBranchPrefix") { + const branchPrefixDialog = await import('../dialogs/branch_prefix.js'); branchPrefixDialog.showDialog(this.node); } else if (cmd === "protectSubtree") { @@ -132,9 +130,11 @@ class TreeContextMenu { treeChangesService.deleteNodes(treeService.getSelectedOrActiveNodes(this.node)); } else if (cmd === "export") { + const exportDialog = await import('../dialogs/export.js'); exportDialog.showDialog(this.node,"subtree"); } else if (cmd === "importIntoNote") { + const importDialog = await import('../dialogs/import.js'); importDialog.showDialog(this.node); } else if (cmd === "collapseSubtree") { diff --git a/src/public/javascripts/services/tree_keybindings.js b/src/public/javascripts/services/tree_keybindings.js index ab42274e4..1ad6af2e2 100644 --- a/src/public/javascripts/services/tree_keybindings.js +++ b/src/public/javascripts/services/tree_keybindings.js @@ -1,7 +1,6 @@ import noteDetailService from "./note_detail.js"; import treeChangesService from "./branches.js"; import treeService from "./tree.js"; -import editBranchPrefixDialog from "../dialogs/branch_prefix.js"; import hoistedNoteService from "./hoisted_note.js"; import clipboard from "./clipboard.js"; @@ -86,7 +85,8 @@ const keyBindings = { return false; }, - "f2": node => { + "f2": async node => { + const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js"); editBranchPrefixDialog.showDialog(node); }, "alt+-": node => { diff --git a/src/public/javascripts/widgets/attributes.js b/src/public/javascripts/widgets/attributes.js index de069f948..eda7c1db3 100644 --- a/src/public/javascripts/widgets/attributes.js +++ b/src/public/javascripts/widgets/attributes.js @@ -1,4 +1,3 @@ -import attributesDialog from "../dialogs/attributes.js"; import utils from "../services/utils.js"; import linkService from "../services/link.js"; import messagingService from "../services/messaging.js"; @@ -9,7 +8,8 @@ class AttributesWidget extends StandardWidget { getHeaderActions() { const $showFullButton = $("").append("show dialog").addClass('widget-header-action'); - $showFullButton.click(() => { + $showFullButton.click(async () => { + const attributesDialog = await import("../dialogs/attributes.js"); attributesDialog.showDialog(); }); diff --git a/src/public/javascripts/widgets/link_map.js b/src/public/javascripts/widgets/link_map.js index a5f78107d..3bed76fe3 100644 --- a/src/public/javascripts/widgets/link_map.js +++ b/src/public/javascripts/widgets/link_map.js @@ -1,5 +1,4 @@ import libraryLoader from "../services/library_loader.js"; -import linkMapDialog from "../dialogs/link_map.js"; import server from "../services/server.js"; import treeCache from "../services/tree_cache.js"; import linkService from "../services/link.js"; @@ -28,7 +27,8 @@ class LinkMapWidget extends StandardWidget { getHeaderActions() { const $showFullButton = $("").append("show full").addClass('widget-header-action'); - $showFullButton.click(() => { + $showFullButton.click(async () => { + const linkMapDialog = await import("../dialogs/link_map.js"); linkMapDialog.showDialog(); });