From 643d9077fc641b4af26a4f25ad1fd45c79cb27fc Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 18 Nov 2019 23:01:31 +0100 Subject: [PATCH] configurable keyboard shortcuts WIP --- docs/backend_api/ApiToken.html | 15 +- docs/backend_api/Attribute.html | 15 +- docs/backend_api/BackendScriptApi.html | 425 +--- docs/backend_api/Branch.html | 15 +- docs/backend_api/Note.html | 229 +- docs/backend_api/NoteRevision.html | 71 +- docs/backend_api/Option.html | 15 +- docs/backend_api/RecentNote.html | 15 +- docs/backend_api/entities_api_token.js.html | 8 +- docs/backend_api/entities_attribute.js.html | 24 +- docs/backend_api/entities_branch.js.html | 18 +- docs/backend_api/entities_note.js.html | 36 + .../entities_note_revision.js.html | 36 +- docs/backend_api/entities_option.js.html | 10 +- docs/backend_api/entities_recent_note.js.html | 8 +- docs/backend_api/global.html | 2 +- .../services_backend_script_api.js.html | 28 +- docs/frontend_api/Branch.html | 2 +- docs/frontend_api/FrontendScriptApi.html | 182 +- docs/frontend_api/KeyboardAction.html | 2266 +++++++++++++++++ docs/frontend_api/KeyboardActions.html | 280 ++ docs/frontend_api/NoteFull.html | 2 +- docs/frontend_api/NoteShort.html | 360 +-- 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 | 4 +- docs/frontend_api/global.html | 4 +- docs/frontend_api/index.html | 2 +- docs/frontend_api/module.exports.html | 280 ++ .../services_frontend_script_api.js.html | 10 +- .../services_keyboard_action.js.html | 280 ++ .../services_keyboard_actions.js.html | 61 + package.json | 2 +- .../services/frontend_script_api.js | 4 + .../javascripts/services/keyboard_action.js | 261 ++ src/public/javascripts/services/keys.js | 16 + src/services/keyboard_actions.js | 157 ++ src/services/options_init.js | 15 +- 39 files changed, 4387 insertions(+), 777 deletions(-) create mode 100644 docs/frontend_api/KeyboardAction.html create mode 100644 docs/frontend_api/KeyboardActions.html create mode 100644 docs/frontend_api/module.exports.html create mode 100644 docs/frontend_api/services_keyboard_action.js.html create mode 100644 docs/frontend_api/services_keyboard_actions.js.html create mode 100644 src/public/javascripts/services/keyboard_action.js create mode 100644 src/public/javascripts/services/keys.js create mode 100644 src/services/keyboard_actions.js diff --git a/docs/backend_api/ApiToken.html b/docs/backend_api/ApiToken.html index ba16476ba..5c512b555 100644 --- a/docs/backend_api/ApiToken.html +++ b/docs/backend_api/ApiToken.html @@ -28,7 +28,7 @@
-

ApiToken(apiTokenId, token, isDeleted, utcDateCreated)

+

ApiToken()

ApiToken is an entity representing token used to authenticate against Trilium API from client applications. Currently used only by Trilium Sender.
@@ -45,7 +45,7 @@ -

new ApiToken(apiTokenId, token, isDeleted, utcDateCreated)

+

new ApiToken()

@@ -60,10 +60,15 @@ -
Parameters:
+ + + + +
Properties:
+ - +
@@ -180,8 +185,6 @@ - -
diff --git a/docs/backend_api/Attribute.html b/docs/backend_api/Attribute.html index a42ab9c37..8df31066f 100644 --- a/docs/backend_api/Attribute.html +++ b/docs/backend_api/Attribute.html @@ -28,7 +28,7 @@
-

Attribute(attributeId, noteId, type, name, value, position, isInheritable, isDeleted, utcDateCreated, utcDateModified)

+

Attribute()

Attribute is key value pair owned by a note.
@@ -45,7 +45,7 @@ -

new Attribute(attributeId, noteId, type, name, value, position, isInheritable, isDeleted, utcDateCreated, utcDateModified)

+

new Attribute()

@@ -60,10 +60,15 @@ -
Parameters:
+ + + + +
Properties:
+ -
+
@@ -318,8 +323,6 @@ - -
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html index eec8511d8..bcc2ef0fb 100644 --- a/docs/backend_api/BackendScriptApi.html +++ b/docs/backend_api/BackendScriptApi.html @@ -396,7 +396,7 @@ the backend.
Source:
@@ -534,7 +534,7 @@ the backend. -

createNote(parentNoteId, title, contentopt, extraOptionsopt) → {Promise.<{note: Note, branch: Branch}>}

+

createNote(extraOptionsopt) → {Promise.<{note: Note, branch: Branch}>}

@@ -576,115 +576,6 @@ the backend.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -693,7 +584,7 @@ the backend.
parentNoteId - - -string - - - - - - - - - - - - create new note under this parent
title - - -string - - - - - - - - - - - -
content - - -string - - - - - - <optional>
- - - - - -
- - "" - -
extraOptions -CreateNoteExtraOptions +CreateNoteParams @@ -760,295 +651,7 @@ the backend.
Source:
- - - - - - - - - - - - - - - - - - - - - - - -
Returns:
- - -
- object contains newly created entities note and branch -
- - - -
-
- Type -
-
- -Promise.<{note: Note, branch: Branch}> - - -
-
- - - - - - - - - - - - - -

createNoteAndRefresh(parentNoteId, title, contentopt, extraOptionsopt) → {Promise.<{note: Note, branch: Branch}>}

- - - - - - -
- Creates new note according to given params and force all connected clients to refresh their tree. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeAttributesDefaultDescription
parentNoteId - - -string - - - - - - - - - - - - create new note under this parent
title - - -string - - - - - - - - - - - -
content - - -string - - - - - - <optional>
- - - - - -
- - "" - -
extraOptions - - -CreateNoteExtraOptions - - - - - - <optional>
- - - - - -
- - {} - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
@@ -1533,7 +1136,7 @@ the backend.
Source:
@@ -1997,7 +1600,7 @@ the backend.
Source:
@@ -2765,7 +2368,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3418,7 +3021,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3596,7 +3199,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3751,7 +3354,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -3901,7 +3504,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -4404,7 +4007,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -4537,7 +4140,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -4912,7 +4515,7 @@ transactional by default.
Source:
diff --git a/docs/backend_api/Branch.html b/docs/backend_api/Branch.html index bad86000e..dc7fe59aa 100644 --- a/docs/backend_api/Branch.html +++ b/docs/backend_api/Branch.html @@ -28,7 +28,7 @@
-

Branch(branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, utcDateModified, utcDateCreated)

+

Branch()

Branch represents note's placement in the tree - it's essentially pair of noteId and parentNoteId. Each note can have multiple (at least one) branches, meaning it can be placed into multiple places in the tree.
@@ -46,7 +46,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in -

new Branch(branchId, noteId, parentNoteId, notePosition, prefix, isExpanded, isDeleted, utcDateModified, utcDateCreated)

+

new Branch()

@@ -61,10 +61,15 @@ Each note can have multiple (at least one) branches, meaning it can be placed in -
Parameters:
+ + + + +
Properties:
+ - +
@@ -296,8 +301,6 @@ Each note can have multiple (at least one) branches, meaning it can be placed in - -
diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html index 5f8d01cc5..e9a278742 100644 --- a/docs/backend_api/Note.html +++ b/docs/backend_api/Note.html @@ -224,6 +224,29 @@ +
+ + + + + + + + + + + + + + + @@ -419,7 +442,7 @@
Source:
@@ -486,6 +509,108 @@ +

(async) addAttribute() → {Promise.<Attribute>}

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Promise.<Attribute> + + +
+
+ + + + + + + + + + + + +

(async) getAttribute(type, name) → {Promise.<Attribute>}

@@ -606,7 +731,7 @@
Source:
@@ -773,7 +898,7 @@
Source:
@@ -951,7 +1076,7 @@
Source:
@@ -1057,7 +1182,7 @@
Source:
@@ -1159,7 +1284,7 @@
Source:
@@ -1265,7 +1390,7 @@
Source:
@@ -1371,7 +1496,7 @@
Source:
@@ -1473,7 +1598,7 @@
Source:
@@ -1706,7 +1831,7 @@
Source:
@@ -1904,7 +2029,7 @@
Source:
@@ -2102,7 +2227,7 @@
Source:
@@ -2204,7 +2329,7 @@
Source:
@@ -2355,7 +2480,7 @@
Source:
@@ -2522,7 +2647,7 @@
Source:
@@ -2689,7 +2814,7 @@
Source:
@@ -2844,7 +2969,7 @@
Source:
@@ -2956,7 +3081,7 @@
Source:
@@ -3058,7 +3183,7 @@
Source:
@@ -3166,7 +3291,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -3274,7 +3399,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -3429,7 +3554,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -3596,7 +3721,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -3763,7 +3888,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -3918,7 +4043,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -4088,7 +4213,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -4239,7 +4364,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -4349,7 +4474,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -4451,7 +4576,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -4557,7 +4682,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -4735,7 +4860,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -4841,7 +4966,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -4996,7 +5121,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -5151,7 +5276,7 @@ This method can be significantly faster than the getAttributes()
Source:
@@ -5262,7 +5387,7 @@ Cache is note instance scoped.
Source:
@@ -5346,7 +5471,7 @@ Cache is note instance scoped.
Source:
@@ -5452,7 +5577,7 @@ Cache is note instance scoped.
Source:
@@ -5558,7 +5683,7 @@ Cache is note instance scoped.
Source:
@@ -5664,7 +5789,7 @@ Cache is note instance scoped.
Source:
@@ -5770,7 +5895,7 @@ Cache is note instance scoped.
Source:
@@ -5876,7 +6001,7 @@ Cache is note instance scoped.
Source:
@@ -6105,7 +6230,7 @@ Cache is note instance scoped.
Source:
@@ -6303,7 +6428,7 @@ Cache is note instance scoped.
Source:
@@ -6501,7 +6626,7 @@ Cache is note instance scoped.
Source:
@@ -6730,7 +6855,7 @@ Cache is note instance scoped.
Source:
@@ -6832,7 +6957,7 @@ Cache is note instance scoped.
Source:
@@ -6934,7 +7059,7 @@ Cache is note instance scoped.
Source:
@@ -7132,7 +7257,7 @@ Cache is note instance scoped.
Source:
@@ -7330,7 +7455,7 @@ Cache is note instance scoped.
Source:
@@ -7590,7 +7715,7 @@ Cache is note instance scoped.
Source:
@@ -7819,7 +7944,7 @@ Cache is note instance scoped.
Source:
@@ -8048,7 +8173,7 @@ Cache is note instance scoped.
Source:
diff --git a/docs/backend_api/NoteRevision.html b/docs/backend_api/NoteRevision.html index 7143be4fb..232710773 100644 --- a/docs/backend_api/NoteRevision.html +++ b/docs/backend_api/NoteRevision.html @@ -28,7 +28,7 @@
-

NoteRevision(noteRevisionId, noteId, type, mime, title, isProtected, dateLastEdited, dateCreated, utcDateLastEdited, utcDateCreated, utcDateModified)

+

NoteRevision()

NoteRevision represents snapshot of note's title and content at some point in the past. It's used for seamless note versioning.
@@ -45,7 +45,7 @@ -

new NoteRevision(noteRevisionId, noteId, type, mime, title, isProtected, dateLastEdited, dateCreated, utcDateLastEdited, utcDateCreated, utcDateModified)

+

new NoteRevision()

@@ -60,10 +60,15 @@ -
Parameters:
+ + + + +
Properties:
+ -
contentLength + + +int + + + + length of content
isProtected
+
@@ -193,6 +198,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -206,7 +257,7 @@
contentLength + + +int + + + +
isErased + + +boolean + + + +
-string +boolean @@ -341,8 +392,6 @@ - -
@@ -372,7 +421,7 @@
Source:
@@ -487,7 +536,7 @@
Source:
@@ -589,7 +638,7 @@
Source:
@@ -695,7 +744,7 @@
Source:
diff --git a/docs/backend_api/Option.html b/docs/backend_api/Option.html index 6a5164900..8bde36791 100644 --- a/docs/backend_api/Option.html +++ b/docs/backend_api/Option.html @@ -28,7 +28,7 @@
-

Option(name, value, isSynced, utcDateModified, utcDateCreated)

+

Option()

Option represents name-value pair, either directly configurable by the user or some system property.
@@ -45,7 +45,7 @@ -

new Option(name, value, isSynced, utcDateModified, utcDateCreated)

+

new Option()

@@ -60,10 +60,15 @@ -
Parameters:
+ + + + +
Properties:
+ - +
@@ -203,8 +208,6 @@ - -
diff --git a/docs/backend_api/RecentNote.html b/docs/backend_api/RecentNote.html index 0e9b1b93c..756a21c9d 100644 --- a/docs/backend_api/RecentNote.html +++ b/docs/backend_api/RecentNote.html @@ -28,7 +28,7 @@
-

RecentNote(noteId, notePath, isDeleted, utcDateModified)

+

RecentNote()

RecentNote represents recently visited note.
@@ -45,7 +45,7 @@ -

new RecentNote(noteId, notePath, isDeleted, utcDateModified)

+

new RecentNote()

@@ -60,10 +60,15 @@ -
Parameters:
+ + + + +
Properties:
+ -
+
@@ -180,8 +185,6 @@ - -
diff --git a/docs/backend_api/entities_api_token.js.html b/docs/backend_api/entities_api_token.js.html index eda639384..5d835d2e3 100644 --- a/docs/backend_api/entities_api_token.js.html +++ b/docs/backend_api/entities_api_token.js.html @@ -34,10 +34,10 @@ const dateUtils = require('../services/date_utils'); /** * ApiToken is an entity representing token used to authenticate against Trilium API from client applications. Currently used only by Trilium Sender. * - * @param {string} apiTokenId - primary key - * @param {string} token - * @param {boolean} isDeleted - true if API token is deleted - * @param {string} utcDateCreated + * @property {string} apiTokenId - primary key + * @property {string} token + * @property {boolean} isDeleted - true if API token is deleted + * @property {string} utcDateCreated * * @extends Entity */ diff --git a/docs/backend_api/entities_attribute.js.html b/docs/backend_api/entities_attribute.js.html index db22d936e..aa9220e39 100644 --- a/docs/backend_api/entities_attribute.js.html +++ b/docs/backend_api/entities_attribute.js.html @@ -36,16 +36,16 @@ const sql = require('../services/sql'); /** * Attribute is key value pair owned by a note. * - * @param {string} attributeId - * @param {string} noteId - * @param {string} type - * @param {string} name - * @param {string} value - * @param {int} position - * @param {boolean} isInheritable - * @param {boolean} isDeleted - * @param {string} utcDateCreated - * @param {string} utcDateModified + * @property {string} attributeId + * @property {string} noteId + * @property {string} type + * @property {string} name + * @property {string} value + * @property {int} position + * @property {boolean} isInheritable + * @property {boolean} isDeleted + * @property {string} utcDateCreated + * @property {string} utcDateModified * * @extends Entity */ @@ -107,6 +107,10 @@ class Attribute extends Entity { async beforeSaving() { if (!this.value) { + if (this.type === 'relation') { + throw new Error(`Cannot save relation ${this.name} since it does not target any note.`); + } + // null value isn't allowed this.value = ""; } diff --git a/docs/backend_api/entities_branch.js.html b/docs/backend_api/entities_branch.js.html index 9ae543ca5..c8c2e4866 100644 --- a/docs/backend_api/entities_branch.js.html +++ b/docs/backend_api/entities_branch.js.html @@ -37,15 +37,15 @@ const sql = require('../services/sql'); * Branch represents note's placement in the tree - it's essentially pair of noteId and parentNoteId. * Each note can have multiple (at least one) branches, meaning it can be placed into multiple places in the tree. * - * @param {string} branchId - primary key - * @param {string} noteId - * @param {string} parentNoteId - * @param {int} notePosition - * @param {string} prefix - * @param {boolean} isExpanded - * @param {boolean} isDeleted - * @param {string} utcDateModified - * @param {string} utcDateCreated + * @property {string} branchId - primary key + * @property {string} noteId + * @property {string} parentNoteId + * @property {int} notePosition + * @property {string} prefix + * @property {boolean} isExpanded + * @property {boolean} isDeleted + * @property {string} utcDateModified + * @property {string} utcDateCreated * * @extends Entity */ diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.html index 06ba0c295..69877fcd7 100644 --- a/docs/backend_api/entities_note.js.html +++ b/docs/backend_api/entities_note.js.html @@ -49,6 +49,7 @@ const RELATION_DEFINITION = 'relation-definition'; * @property {string} type - one of "text", "code", "file" or "render" * @property {string} mime - MIME type, e.g. "text/html" * @property {string} title - note title + * @property {int} contentLength - length of content * @property {boolean} isProtected - true if note is protected * @property {boolean} isDeleted - true if note is deleted * @property {boolean} isErased - true if note's content is erased after it has been deleted @@ -141,8 +142,13 @@ class Note extends Entity { /** @returns {Promise} */ async setContent(content) { + if (content === null || content === undefined) { + throw new Error(`Cannot set null content to note ${this.noteId}`); + } + // force updating note itself so that dateModified is represented correctly even for the content this.forcedChange = true; + this.contentLength = content.length; await this.save(); this.content = content; @@ -498,6 +504,32 @@ class Note extends Entity { } } + /** + * @return {Promise<Attribute>} + */ + async addAttribute(type, name, value = "") { + const attr = new Attribute({ + noteId: this.noteId, + type: type, + name: name, + value: value + }); + + await attr.save(); + + this.invalidateAttributeCache(); + + return attr; + } + + async addLabel(name, value = "") { + return await this.addAttribute(LABEL, name, value); + } + + async addRelation(name, targetNoteId) { + return await this.addAttribute(RELATION, name, targetNoteId); + } + /** * @param {string} name - label name * @returns {Promise<boolean>} true if label exists (including inherited) @@ -767,6 +799,10 @@ class Note extends Entity { this.utcDateCreated = dateUtils.utcNowDateTime(); } + if (this.contentLength === undefined) { + this.contentLength = -1; + } + super.beforeSaving(); if (this.isChanged) { diff --git a/docs/backend_api/entities_note_revision.js.html b/docs/backend_api/entities_note_revision.js.html index 50f8befae..8557348d0 100644 --- a/docs/backend_api/entities_note_revision.js.html +++ b/docs/backend_api/entities_note_revision.js.html @@ -39,24 +39,26 @@ const syncTableService = require('../services/sync_table'); /** * NoteRevision represents snapshot of note's title and content at some point in the past. It's used for seamless note versioning. * - * @param {string} noteRevisionId - * @param {string} noteId - * @param {string} type - * @param {string} mime - * @param {string} title - * @param {string} isProtected - * @param {string} dateLastEdited - * @param {string} dateCreated - * @param {string} utcDateLastEdited - * @param {string} utcDateCreated - * @param {string} utcDateModified + * @property {string} noteRevisionId + * @property {string} noteId + * @property {string} type + * @property {string} mime + * @property {string} title + * @property {int} contentLength + * @property {boolean} isErased + * @property {boolean} isProtected + * @property {string} dateLastEdited + * @property {string} dateCreated + * @property {string} utcDateLastEdited + * @property {string} utcDateCreated + * @property {string} utcDateModified * * @extends Entity */ class NoteRevision extends Entity { static get entityName() { return "note_revisions"; } static get primaryKeyName() { return "noteRevisionId"; } - static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "contentLength", "isProtected", "dateLastEdited", "dateCreated", "utcDateLastEdited", "utcDateCreated", "utcDateModified"]; } + static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "contentLength", "isErased", "isProtected", "dateLastEdited", "dateCreated", "utcDateLastEdited", "utcDateCreated", "utcDateModified"]; } constructor(row) { super(row); @@ -130,7 +132,7 @@ class NoteRevision extends Entity { async setContent(content) { // force updating note itself so that utcDateModified is represented correctly even for the content this.forcedChange = true; - this.contentLength = content.length; + this.contentLength = content === null ? 0 : content.length; await this.save(); this.content = content; @@ -156,6 +158,14 @@ class NoteRevision extends Entity { await syncTableService.addNoteRevisionContentSync(this.noteRevisionId); } + beforeSaving() { + super.beforeSaving(); + + if (this.isChanged) { + this.utcDateModified = dateUtils.utcNowDateTime(); + } + } + // cannot be static! updatePojo(pojo) { if (pojo.isProtected) { diff --git a/docs/backend_api/entities_option.js.html b/docs/backend_api/entities_option.js.html index f9dc87bab..7b658bfdd 100644 --- a/docs/backend_api/entities_option.js.html +++ b/docs/backend_api/entities_option.js.html @@ -34,11 +34,11 @@ const dateUtils = require('../services/date_utils'); /** * Option represents name-value pair, either directly configurable by the user or some system property. * - * @param {string} name - * @param {string} value - * @param {boolean} isSynced - * @param {string} utcDateModified - * @param {string} utcDateCreated + * @property {string} name + * @property {string} value + * @property {boolean} isSynced + * @property {string} utcDateModified + * @property {string} utcDateCreated * * @extends Entity */ diff --git a/docs/backend_api/entities_recent_note.js.html b/docs/backend_api/entities_recent_note.js.html index 531d0482c..b820fdced 100644 --- a/docs/backend_api/entities_recent_note.js.html +++ b/docs/backend_api/entities_recent_note.js.html @@ -34,10 +34,10 @@ const dateUtils = require('../services/date_utils'); /** * RecentNote represents recently visited note. * - * @param {string} noteId - * @param {string} notePath - * @param {boolean} isDeleted - * @param {string} utcDateModified + * @property {string} noteId + * @property {string} notePath + * @property {boolean} isDeleted + * @property {string} utcDateModified * * @extends Entity */ diff --git a/docs/backend_api/global.html b/docs/backend_api/global.html index 0759abe47..542cf911b 100644 --- a/docs/backend_api/global.html +++ b/docs/backend_api/global.html @@ -290,7 +290,7 @@ -

CreateNoteExtraOptions

+

CreateNoteParams

diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html index eb68860b6..0fbb86466 100644 --- a/docs/backend_api/services_backend_script_api.js.html +++ b/docs/backend_api/services_backend_script_api.js.html @@ -206,7 +206,7 @@ function BackendScriptApi(currentNote, apiParams) { */ /** - * @typedef {object} CreateNoteExtraOptions + * @typedef {object} CreateNoteParams * @property {boolean} [json=false] - should the note be JSON * @property {boolean} [isProtected=false] - should the note be protected * @property {string} [type='text'] - note type @@ -217,32 +217,10 @@ function BackendScriptApi(currentNote, apiParams) { /** * @method * - * @param {string} parentNoteId - create new note under this parent - * @param {string} title - * @param {string} [content=""] - * @param {CreateNoteExtraOptions} [extraOptions={}] + * @param {CreateNoteParams} [extraOptions={}] * @returns {Promise<{note: Note, branch: Branch}>} object contains newly created entities note and branch */ - this.createNote = noteService.createNote; - - /** - * Creates new note according to given params and force all connected clients to refresh their tree. - * - * @method - * - * @param {string} parentNoteId - create new note under this parent - * @param {string} title - * @param {string} [content=""] - * @param {CreateNoteExtraOptions} [extraOptions={}] - * @returns {Promise<{note: Note, branch: Branch}>} object contains newly created entities note and branch - */ - this.createNoteAndRefresh = async function(parentNoteId, title, content, extraOptions) { - const ret = await noteService.createNote(parentNoteId, title, content, extraOptions); - - ws.refreshTree(); - - return ret; - }; + this.createNote = noteService.createNewNote; /** * Log given message to trilium logs. diff --git a/docs/frontend_api/Branch.html b/docs/frontend_api/Branch.html index cc6fc3b03..0b7013743 100644 --- a/docs/frontend_api/Branch.html +++ b/docs/frontend_api/Branch.html @@ -719,7 +719,7 @@
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html index dc8fc5a64..5ce01216e 100644 --- a/docs/frontend_api/FrontendScriptApi.html +++ b/docs/frontend_api/FrontendScriptApi.html @@ -81,7 +81,7 @@
Source:
@@ -223,7 +223,7 @@
Source:
@@ -333,7 +333,113 @@
Source:
+ + + + + + + +
+ + + + + + + + +

keys

+ + + + + + + + + + +
Properties:
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + +KeyboardAction + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -446,7 +552,7 @@
Source:
@@ -552,7 +658,7 @@
Source:
@@ -662,7 +768,7 @@
Source:
@@ -771,7 +877,7 @@
Source:
@@ -900,7 +1006,7 @@
Source:
@@ -1055,7 +1161,7 @@
Source:
@@ -1210,7 +1316,7 @@
Source:
@@ -1366,7 +1472,7 @@
Source:
@@ -1546,7 +1652,7 @@
Source:
@@ -1679,7 +1785,7 @@
Source:
@@ -1785,7 +1891,7 @@
Source:
@@ -1891,7 +1997,7 @@
Source:
@@ -2050,7 +2156,7 @@
Source:
@@ -2157,7 +2263,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2312,7 +2418,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2468,7 +2574,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2669,7 +2775,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2775,7 +2881,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2930,7 +3036,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -3039,7 +3145,7 @@ note.
Source:
@@ -3194,7 +3300,7 @@ note.
Source:
@@ -3327,7 +3433,7 @@ note.
Source:
@@ -3433,7 +3539,7 @@ note.
Source:
@@ -3521,7 +3627,7 @@ note.
Source:
@@ -3627,7 +3733,7 @@ note.
Source:
@@ -3733,7 +3839,7 @@ note.
Source:
@@ -3888,7 +3994,7 @@ note.
Source:
@@ -4049,7 +4155,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4209,7 +4315,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4365,7 +4471,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4520,7 +4626,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4671,7 +4777,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4808,7 +4914,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4945,7 +5051,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4991,7 +5097,7 @@ Internally this serializes the anonymous function into string and sends it to ba
diff --git a/docs/frontend_api/KeyboardAction.html b/docs/frontend_api/KeyboardAction.html new file mode 100644 index 000000000..1877d3729 --- /dev/null +++ b/docs/frontend_api/KeyboardAction.html @@ -0,0 +1,2266 @@ + + + + + JSDoc: Class: KeyboardAction + + + + + + + + + + +
+ +

Class: KeyboardAction

+ + + + + + +
+ +
+ +

KeyboardAction()

+ +
blaa vlaa
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new KeyboardAction()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

(static) AddLinkToText

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) BackInNoteHistory

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ClipboardCopy

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ClipboardCut

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ClipboardPaste

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) CloneNotesTo

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) CloseTab

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) CollapseTree

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) CreateNoteAfter

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) CreateNoteInto

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) FindInText

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) FocusNote

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ForwardInNoteHistory

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) InsertDateTime

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) JumpToNote

+ + + + +
+ Open "Jump to note" dialog +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) MarkdownToHTML

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) MoveNotesTo

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) NewTab

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) NextTab

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) OpenDevTools

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) OpenSQLConsole

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) PreviousTab

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) Redo

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ReloadApp

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) RunCurrentNote

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) RunSQL

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ScrollToActiveNote

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) SearchNotes

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) SelectAllNotesInParent

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ShowAttributes

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ShowHelp

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ToggleFullscreen

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ToggleZenMode

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) Undo

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ZoomIn

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

(static) ZoomOut

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/frontend_api/KeyboardActions.html b/docs/frontend_api/KeyboardActions.html new file mode 100644 index 000000000..0e5a93353 --- /dev/null +++ b/docs/frontend_api/KeyboardActions.html @@ -0,0 +1,280 @@ + + + + + JSDoc: Class: KeyboardActions + + + + + + + + + + +
+ +

Class: KeyboardActions

+ + + + + + +
+ +
+ +

KeyboardActions()

+ +
blaa vlaa
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new KeyboardActions()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

JUMP_TO

+ + + + + + + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + +string + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/frontend_api/NoteFull.html b/docs/frontend_api/NoteFull.html index 890782f59..113ac1492 100644 --- a/docs/frontend_api/NoteFull.html +++ b/docs/frontend_api/NoteFull.html @@ -449,7 +449,7 @@
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html index 1823f4bfc..110e0e051 100644 --- a/docs/frontend_api/NoteShort.html +++ b/docs/frontend_api/NoteShort.html @@ -278,7 +278,7 @@
Source:
@@ -346,7 +346,7 @@
Source:
@@ -414,7 +414,7 @@
Source:
@@ -432,123 +432,7 @@ -

cssClass

- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - -

isDeleted

- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - -

isProtected

+

contentLength

@@ -606,6 +490,180 @@ +

cssClass

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

isDeleted

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

isProtected

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + +

mime

@@ -646,7 +704,7 @@
Source:
@@ -772,7 +830,7 @@
Source:
@@ -840,7 +898,7 @@
Source:
@@ -956,7 +1014,7 @@
Source:
@@ -1104,7 +1162,7 @@
Source:
@@ -1271,7 +1329,7 @@
Source:
@@ -1445,7 +1503,7 @@
Source:
@@ -1551,7 +1609,7 @@
Source:
@@ -1653,7 +1711,7 @@
Source:
@@ -1755,7 +1813,7 @@
Source:
@@ -1857,7 +1915,7 @@
Source:
@@ -2008,7 +2066,7 @@
Source:
@@ -2175,7 +2233,7 @@
Source:
@@ -2342,7 +2400,7 @@
Source:
@@ -2497,7 +2555,7 @@
Source:
@@ -2603,7 +2661,7 @@
Source:
@@ -2705,7 +2763,7 @@
Source:
@@ -2856,7 +2914,7 @@
Source:
@@ -3023,7 +3081,7 @@
Source:
@@ -3190,7 +3248,7 @@
Source:
@@ -3345,7 +3403,7 @@
Source:
@@ -3515,7 +3573,7 @@
Source:
@@ -3666,7 +3724,7 @@
Source:
@@ -3776,7 +3834,7 @@
Source:
@@ -3950,7 +4008,7 @@
Source:
@@ -4056,7 +4114,7 @@
Source:
@@ -4207,7 +4265,7 @@
Source:
@@ -4362,7 +4420,7 @@
Source:
@@ -4473,7 +4531,7 @@ Cache is note instance scoped.
Source:
@@ -4557,7 +4615,7 @@ Cache is note instance scoped.
Source:
@@ -4621,7 +4679,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 01956a8e7..2f85b38f8 100644 --- a/docs/frontend_api/entities_attribute.js.html +++ b/docs/frontend_api/entities_attribute.js.html @@ -71,7 +71,7 @@ export default Attribute;
diff --git a/docs/frontend_api/entities_branch.js.html b/docs/frontend_api/entities_branch.js.html index bf5d06879..cc008e83d 100644 --- a/docs/frontend_api/entities_branch.js.html +++ b/docs/frontend_api/entities_branch.js.html @@ -70,7 +70,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 b66927b7b..9f141a2a7 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 dd056d723..8de758b82 100644 --- a/docs/frontend_api/entities_note_short.js.html +++ b/docs/frontend_api/entities_note_short.js.html @@ -49,6 +49,8 @@ class NoteShort { this.noteId = row.noteId; /** @param {string} */ this.title = row.title; + /** @param {int} */ + this.contentLength = row.contentLength; /** @param {boolean} */ this.isProtected = row.isProtected; /** @param {string} one of 'text', 'code', 'file' or 'render' */ @@ -361,7 +363,7 @@ export default NoteShort;
diff --git a/docs/frontend_api/global.html b/docs/frontend_api/global.html index 7f4006e31..043fc4c5f 100644 --- a/docs/frontend_api/global.html +++ b/docs/frontend_api/global.html @@ -303,7 +303,7 @@
Source:
@@ -333,7 +333,7 @@
diff --git a/docs/frontend_api/index.html b/docs/frontend_api/index.html index 310dca343..cd881639d 100644 --- a/docs/frontend_api/index.html +++ b/docs/frontend_api/index.html @@ -50,7 +50,7 @@
diff --git a/docs/frontend_api/module.exports.html b/docs/frontend_api/module.exports.html new file mode 100644 index 000000000..4050b4d16 --- /dev/null +++ b/docs/frontend_api/module.exports.html @@ -0,0 +1,280 @@ + + + + + JSDoc: Class: exports + + + + + + + + + + +
+ +

Class: exports

+ + + + + + +
+ +
+ +

exports()

+ +
blaa vlaa
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new exports()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

JUMP_TO

+ + + + + + + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeDescription
+ + +string + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html index e97f6466a..d03a54856 100644 --- a/docs/frontend_api/services_frontend_script_api.js.html +++ b/docs/frontend_api/services_frontend_script_api.js.html @@ -39,6 +39,7 @@ import dateNotesService from './date_notes.js'; import StandardWidget from '../widgets/standard_widget.js'; import ws from "./ws.js"; import hoistedNoteService from "./hoisted_note.js"; +import KeyboardAction from "./keyboard_action.js"; /** * This is the main frontend API interface for scripts. It's published in the local "api" object. @@ -68,6 +69,11 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte /** @property {StandardWidget} */ this.StandardWidget = StandardWidget; + /** @property {KeyboardAction} */ + this.keys = new KeyboardAction(); + + this.bind = keys.bind; + /** * Activates note in the tree and in the note detail. * @@ -115,7 +121,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte const button = $('<button>') .addClass("btn btn-sm") - .click(opts.action); + .on('click', opts.action); if (opts.icon) { button.append($("<span>").addClass("bx bx-" + opts.icon)) @@ -422,7 +428,7 @@ export default FrontendScriptApi;
diff --git a/docs/frontend_api/services_keyboard_action.js.html b/docs/frontend_api/services_keyboard_action.js.html new file mode 100644 index 000000000..f477850d8 --- /dev/null +++ b/docs/frontend_api/services_keyboard_action.js.html @@ -0,0 +1,280 @@ + + + + + JSDoc: Source: services/keyboard_action.js + + + + + + + + + + +
+ +

Source: services/keyboard_action.js

+ + + + + + +
+
+
/**
+ * blaa vlaa
+ */
+class KeyboardAction {
+    constructor(params) {
+        this.optionName = params.optionName;
+    }
+}
+
+/**
+ * Open "Jump to note" dialog
+ * @static
+ */
+KeyboardAction.JumpToNote = new KeyboardAction({
+	optionName: "JumpToNote",
+	defaultShortcuts: "mod+j",
+	description: 'Open "Jump to note" dialog'
+});
+
+/** @static */
+KeyboardAction.MarkdownToHTML = new KeyboardAction({
+	optionName: "MarkdownToHTML",
+	defaultShortcuts: "mod+return"
+});
+
+/** @static */
+KeyboardAction.NewTab = new KeyboardAction({
+	optionName: "NewTab",
+	defaultShortcuts: "mod+t"
+});
+
+/** @static */
+KeyboardAction.CloseTab = new KeyboardAction({
+	optionName: "CloseTab",
+	defaultShortcuts: "mod+w"
+});
+
+/** @static */
+KeyboardAction.NextTab = new KeyboardAction({
+	optionName: "NextTab",
+	defaultShortcuts: "mod+tab"
+});
+
+/** @static */
+KeyboardAction.PreviousTab = new KeyboardAction({
+	optionName: "PreviousTab",
+	defaultShortcuts: "mod+shift+tab"
+});
+
+/** @static */
+KeyboardAction.CreateNoteAfter = new KeyboardAction({
+	optionName: "CreateNoteAfter",
+	defaultShortcuts: "mod+o"
+});
+
+/** @static */
+KeyboardAction.CreateNoteInto = new KeyboardAction({
+	optionName: "CreateNoteInto",
+	defaultShortcuts: "mod+p"
+});
+
+/** @static */
+KeyboardAction.ScrollToActiveNote = new KeyboardAction({
+	optionName: "ScrollToActiveNote",
+	defaultShortcuts: "mod+."
+});
+
+/** @static */
+KeyboardAction.CollapseTree = new KeyboardAction({
+	optionName: "CollapseTree",
+	defaultShortcuts: "alt+c"
+});
+
+/** @static */
+KeyboardAction.RunSQL = new KeyboardAction({
+	optionName: "RunSQL",
+	defaultShortcuts: "mod+return"
+});
+
+/** @static */
+KeyboardAction.FocusNote = new KeyboardAction({
+	optionName: "FocusNote",
+	defaultShortcuts: "return"
+});
+
+/** @static */
+KeyboardAction.RunCurrentNote = new KeyboardAction({
+	optionName: "RunCurrentNote",
+	defaultShortcuts: "mod+return"
+});
+
+/** @static */
+KeyboardAction.ClipboardCopy = new KeyboardAction({
+	optionName: "ClipboardCopy",
+	defaultShortcuts: "mod+c"
+});
+
+/** @static */
+KeyboardAction.ClipboardPaste = new KeyboardAction({
+	optionName: "ClipboardPaste",
+	defaultShortcuts: "mod+v"
+});
+
+/** @static */
+KeyboardAction.ClipboardCut = new KeyboardAction({
+	optionName: "ClipboardCut",
+	defaultShortcuts: "mod+x"
+});
+
+/** @static */
+KeyboardAction.SelectAllNotesInParent = new KeyboardAction({
+	optionName: "SelectAllNotesInParent",
+	defaultShortcuts: "mod+a"
+});
+
+/** @static */
+KeyboardAction.Undo = new KeyboardAction({
+	optionName: "Undo",
+	defaultShortcuts: "mod+z"
+});
+
+/** @static */
+KeyboardAction.Redo = new KeyboardAction({
+	optionName: "Redo",
+	defaultShortcuts: "mod+y"
+});
+
+/** @static */
+KeyboardAction.AddLinkToText = new KeyboardAction({
+	optionName: "AddLinkToText",
+	defaultShortcuts: "mod+l"
+});
+
+/** @static */
+KeyboardAction.CloneNotesTo = new KeyboardAction({
+	optionName: "CloneNotesTo",
+	defaultShortcuts: "mod+shift+c"
+});
+
+/** @static */
+KeyboardAction.MoveNotesTo = new KeyboardAction({
+	optionName: "MoveNotesTo",
+	defaultShortcuts: "mod+shift+c"
+});
+
+/** @static */
+KeyboardAction.SearchNotes = new KeyboardAction({
+	optionName: "SearchNotes",
+	defaultShortcuts: "mod+s"
+});
+
+/** @static */
+KeyboardAction.ShowAttributes = new KeyboardAction({
+	optionName: "ShowAttributes",
+	defaultShortcuts: "alt+a"
+});
+
+/** @static */
+KeyboardAction.ShowHelp = new KeyboardAction({
+	optionName: "ShowHelp",
+	defaultShortcuts: "f1"
+});
+
+/** @static */
+KeyboardAction.OpenSQLConsole = new KeyboardAction({
+	optionName: "OpenSQLConsole",
+	defaultShortcuts: "alt+o"
+});
+
+/** @static */
+KeyboardAction.BackInNoteHistory = new KeyboardAction({
+	optionName: "BackInNoteHistory",
+	defaultShortcuts: "alt+left"
+});
+
+/** @static */
+KeyboardAction.ForwardInNoteHistory = new KeyboardAction({
+	optionName: "ForwardInNoteHistory",
+	defaultShortcuts: "alt+right"
+});
+
+/** @static */
+KeyboardAction.ToggleZenMode = new KeyboardAction({
+	optionName: "ToggleZenMode",
+	defaultShortcuts: "alt+m"
+});
+
+/** @static */
+KeyboardAction.InsertDateTime = new KeyboardAction({
+	optionName: "InsertDateTime",
+	defaultShortcuts: "alt+t"
+});
+
+/** @static */
+KeyboardAction.ReloadApp = new KeyboardAction({
+    optionName: "ReloadApp",
+    defaultShortcuts: ["f5", "mod+r"]
+});
+
+/** @static */
+KeyboardAction.OpenDevTools = new KeyboardAction({
+	optionName: "OpenDevTools",
+	defaultShortcuts: "mod+shift+i"
+});
+
+/** @static */
+KeyboardAction.FindInText = new KeyboardAction({
+	optionName: "FindInText",
+	defaultShortcuts: "mod+f"
+});
+
+/** @static */
+KeyboardAction.ToggleFullscreen = new KeyboardAction({
+	optionName: "ToggleFullscreen",
+	defaultShortcuts: "f11"
+});
+
+/** @static */
+KeyboardAction.ZoomOut = new KeyboardAction({
+	optionName: "ZoomOut",
+	defaultShortcuts: "mod+-"
+});
+
+/** @static */
+KeyboardAction.ZoomIn = new KeyboardAction({
+	optionName: "ZoomIn",
+	defaultShortcuts: "mod+="
+});
+
+export default KeyboardAction;
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/frontend_api/services_keyboard_actions.js.html b/docs/frontend_api/services_keyboard_actions.js.html new file mode 100644 index 000000000..6e24019bd --- /dev/null +++ b/docs/frontend_api/services_keyboard_actions.js.html @@ -0,0 +1,61 @@ + + + + + JSDoc: Source: services/keyboard_action.js + + + + + + + + + + +
+ +

Source: services/keyboard_action.js

+ + + + + + +
+
+
/**
+ * blaa vlaa
+ */
+class KeyboardActions {
+    constructor() {
+        /** @property {string} */
+        this.JUMP_TO = "";
+    }
+}
+
+export default KeyboardActions;
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/package.json b/package.json index e69cb2386..54fc9b368 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "start-server": "TRILIUM_ENV=dev node ./src/www", "start-electron": "TRILIUM_ENV=dev electron . --disable-gpu", "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-frontend-docs": "./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/javascripts/entities/*.js src/public/javascripts/services/keyboard_action.js src/public/javascripts/services/frontend_script_api.js", "build-docs": "npm run build-backend-docs && npm run build-frontend-docs" }, "dependencies": { diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js index ea6d2dd01..9d45a3677 100644 --- a/src/public/javascripts/services/frontend_script_api.js +++ b/src/public/javascripts/services/frontend_script_api.js @@ -11,6 +11,7 @@ import dateNotesService from './date_notes.js'; import StandardWidget from '../widgets/standard_widget.js'; import ws from "./ws.js"; import hoistedNoteService from "./hoisted_note.js"; +import KeyboardAction from "./keyboard_action.js"; /** * This is the main frontend API interface for scripts. It's published in the local "api" object. @@ -40,6 +41,9 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte /** @property {StandardWidget} */ this.StandardWidget = StandardWidget; + /** @property {KeyboardAction} */ + this.KeyboardAction = KeyboardAction; + /** * Activates note in the tree and in the note detail. * diff --git a/src/public/javascripts/services/keyboard_action.js b/src/public/javascripts/services/keyboard_action.js new file mode 100644 index 000000000..2d74036ec --- /dev/null +++ b/src/public/javascripts/services/keyboard_action.js @@ -0,0 +1,261 @@ +/** + * blaa vlaa + */ +class KeyboardAction { + constructor(params) { + /** @property {string} */ + this.optionName = params.optionName; + /** @property {string[]} */ + this.defaultShortcuts = Array.isArray(params.defaultShortcuts) ? params.defaultShortcuts : [params.defaultShortcuts]; + /** @property {string[]} */ + this.activeShortcuts = this.defaultShortcuts.slice(); + /** @property {string} */ + this.description = params.description; + } + + addShortcut(shortcut) { + this.activeShortcuts.push(shortcut); + } + + /** + * @param {string|string[]} shortcuts + */ + replaceShortcuts(shortcuts) { + this.activeShortcuts = Array.isArray(shortcuts) ? shortcuts : [shortcuts]; + } + + /** @return {KeyboardAction[]} */ + static get allActions() { + return Object.keys(KeyboardAction) + .map(key => KeyboardAction[key]) + .filter(obj => obj instanceof KeyboardAction); + } +} + +const ELECTRON = 1; + +/** + * Open "Jump to note" dialog + * @static + */ +KeyboardAction.JumpToNote = new KeyboardAction({ + optionName: "JumpToNote", + defaultShortcuts: "mod+j", + description: 'Open "Jump to note" dialog' +}); + +/** @static */ +KeyboardAction.MarkdownToHTML = new KeyboardAction({ + optionName: "MarkdownToHTML", + defaultShortcuts: "mod+return" +}); + +/** @static */ +KeyboardAction.NewTab = new KeyboardAction({ + optionName: "NewTab", + defaultShortcuts: "mod+t", + only: ELECTRON +}); + +/** @static */ +KeyboardAction.CloseTab = new KeyboardAction({ + optionName: "CloseTab", + defaultShortcuts: "mod+w", + only: ELECTRON +}); + +/** @static */ +KeyboardAction.NextTab = new KeyboardAction({ + optionName: "NextTab", + defaultShortcuts: "mod+tab", + only: ELECTRON +}); + +/** @static */ +KeyboardAction.PreviousTab = new KeyboardAction({ + optionName: "PreviousTab", + defaultShortcuts: "mod+shift+tab", + only: ELECTRON +}); + +/** @static */ +KeyboardAction.CreateNoteAfter = new KeyboardAction({ + optionName: "CreateNoteAfter", + defaultShortcuts: "mod+o" +}); + +/** @static */ +KeyboardAction.CreateNoteInto = new KeyboardAction({ + optionName: "CreateNoteInto", + defaultShortcuts: "mod+p" +}); + +/** @static */ +KeyboardAction.ScrollToActiveNote = new KeyboardAction({ + optionName: "ScrollToActiveNote", + defaultShortcuts: "mod+." +}); + +/** @static */ +KeyboardAction.CollapseTree = new KeyboardAction({ + optionName: "CollapseTree", + defaultShortcuts: "alt+c" +}); + +/** @static */ +KeyboardAction.RunSQL = new KeyboardAction({ + optionName: "RunSQL", + defaultShortcuts: "mod+return" +}); + +/** @static */ +KeyboardAction.FocusNote = new KeyboardAction({ + optionName: "FocusNote", + defaultShortcuts: "return" +}); + +/** @static */ +KeyboardAction.RunCurrentNote = new KeyboardAction({ + optionName: "RunCurrentNote", + defaultShortcuts: "mod+return" +}); + +/** @static */ +KeyboardAction.ClipboardCopy = new KeyboardAction({ + optionName: "ClipboardCopy", + defaultShortcuts: "mod+c" +}); + +/** @static */ +KeyboardAction.ClipboardPaste = new KeyboardAction({ + optionName: "ClipboardPaste", + defaultShortcuts: "mod+v" +}); + +/** @static */ +KeyboardAction.ClipboardCut = new KeyboardAction({ + optionName: "ClipboardCut", + defaultShortcuts: "mod+x" +}); + +/** @static */ +KeyboardAction.SelectAllNotesInParent = new KeyboardAction({ + optionName: "SelectAllNotesInParent", + defaultShortcuts: "mod+a" +}); + +/** @static */ +KeyboardAction.Undo = new KeyboardAction({ + optionName: "Undo", + defaultShortcuts: "mod+z" +}); + +/** @static */ +KeyboardAction.Redo = new KeyboardAction({ + optionName: "Redo", + defaultShortcuts: "mod+y" +}); + +/** @static */ +KeyboardAction.AddLinkToText = new KeyboardAction({ + optionName: "AddLinkToText", + defaultShortcuts: "mod+l" +}); + +/** @static */ +KeyboardAction.CloneNotesTo = new KeyboardAction({ + optionName: "CloneNotesTo", + defaultShortcuts: "mod+shift+c" +}); + +/** @static */ +KeyboardAction.MoveNotesTo = new KeyboardAction({ + optionName: "MoveNotesTo", + defaultShortcuts: "mod+shift+c" +}); + +/** @static */ +KeyboardAction.SearchNotes = new KeyboardAction({ + optionName: "SearchNotes", + defaultShortcuts: "mod+s" +}); + +/** @static */ +KeyboardAction.ShowAttributes = new KeyboardAction({ + optionName: "ShowAttributes", + defaultShortcuts: "alt+a" +}); + +/** @static */ +KeyboardAction.ShowHelp = new KeyboardAction({ + optionName: "ShowHelp", + defaultShortcuts: "f1" +}); + +/** @static */ +KeyboardAction.OpenSQLConsole = new KeyboardAction({ + optionName: "OpenSQLConsole", + defaultShortcuts: "alt+o" +}); + +/** @static */ +KeyboardAction.BackInNoteHistory = new KeyboardAction({ + optionName: "BackInNoteHistory", + defaultShortcuts: "alt+left" +}); + +/** @static */ +KeyboardAction.ForwardInNoteHistory = new KeyboardAction({ + optionName: "ForwardInNoteHistory", + defaultShortcuts: "alt+right" +}); + +/** @static */ +KeyboardAction.ToggleZenMode = new KeyboardAction({ + optionName: "ToggleZenMode", + defaultShortcuts: "alt+m" +}); + +/** @static */ +KeyboardAction.InsertDateTime = new KeyboardAction({ + optionName: "InsertDateTime", + defaultShortcuts: "alt+t" +}); + +/** @static */ +KeyboardAction.ReloadApp = new KeyboardAction({ + optionName: "ReloadApp", + defaultShortcuts: ["f5", "mod+r"] +}); + +/** @static */ +KeyboardAction.OpenDevTools = new KeyboardAction({ + optionName: "OpenDevTools", + defaultShortcuts: "mod+shift+i" +}); + +/** @static */ +KeyboardAction.FindInText = new KeyboardAction({ + optionName: "FindInText", + defaultShortcuts: "mod+f" +}); + +/** @static */ +KeyboardAction.ToggleFullscreen = new KeyboardAction({ + optionName: "ToggleFullscreen", + defaultShortcuts: "f11" +}); + +/** @static */ +KeyboardAction.ZoomOut = new KeyboardAction({ + optionName: "ZoomOut", + defaultShortcuts: "mod+-" +}); + +/** @static */ +KeyboardAction.ZoomIn = new KeyboardAction({ + optionName: "ZoomIn", + defaultShortcuts: "mod+=" +}); + +export default KeyboardAction; \ No newline at end of file diff --git a/src/public/javascripts/services/keys.js b/src/public/javascripts/services/keys.js new file mode 100644 index 000000000..64517f91b --- /dev/null +++ b/src/public/javascripts/services/keys.js @@ -0,0 +1,16 @@ +class Actions { + constructor() { + this.JUMP_TO = ""; + } +} + +const actions = new Actions(); + +function bind() { + +} + +export default { + actions, + bind +}; \ No newline at end of file diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.js new file mode 100644 index 000000000..6a8d345b4 --- /dev/null +++ b/src/services/keyboard_actions.js @@ -0,0 +1,157 @@ +const ELECTRON = "electron"; + +const KEYBOARD_ACTIONS = [ + { + optionName: "JumpToNote", + defaultShortcuts: ["mod+j"], + description: 'Open "Jump to note" dialog' + }, + { + optionName: "MarkdownToHTML", + defaultShortcuts: ["mod+return"] + }, + { + optionName: "NewTab", + defaultShortcuts: ["mod+t"], + only: ELECTRON + }, + { + optionName: "CloseTab", + defaultShortcuts: ["mod+w"], + only: ELECTRON + }, + { + optionName: "NextTab", + defaultShortcuts: ["mod+tab"], + only: ELECTRON + }, + { + optionName: "PreviousTab", + defaultShortcuts: ["mod+shift+tab"], + only: ELECTRON + }, + { + optionName: "CreateNoteAfter", + defaultShortcuts: ["mod+o"] + }, + { + optionName: "CreateNoteInto", + defaultShortcuts: ["mod+p"] + }, + { + optionName: "ScrollToActiveNote", + defaultShortcuts: ["mod+."] + }, + { + optionName: "CollapseTree", + defaultShortcuts: ["alt+c"] + }, + { + optionName: "RunSQL", + defaultShortcuts: ["mod+return"] + }, + { + optionName: "FocusNote", + defaultShortcuts: ["return"] + }, + { + optionName: "RunCurrentNote", + defaultShortcuts: ["mod+return"] + }, + { + optionName: "ClipboardCopy", + defaultShortcuts: ["mod+c"] + }, + { + optionName: "ClipboardPaste", + defaultShortcuts: ["mod+v"] + }, + { + optionName: "ClipboardCut", + defaultShortcuts: ["mod+x"] + }, + { + optionName: "SelectAllNotesInParent", + defaultShortcuts: ["mod+a"] + }, + { + optionName: "Undo", + defaultShortcuts: ["mod+z"] + }, + { + optionName: "Redo", + defaultShortcuts: ["mod+y"] + }, + { + optionName: "AddLinkToText", + defaultShortcuts: ["mod+l"] + }, + { + optionName: "CloneNotesTo", + defaultShortcuts: ["mod+shift+c"] + }, + { + optionName: "MoveNotesTo", + defaultShortcuts: ["mod+shift+c"] + }, + { + optionName: "SearchNotes", + defaultShortcuts: ["mod+s"] + }, + { + optionName: "ShowAttributes", + defaultShortcuts: ["alt+a"] + }, + { + optionName: "ShowHelp", + defaultShortcuts: ["f1"] + }, + { + optionName: "OpenSQLConsole", + defaultShortcuts: ["alt+o"] + }, + { + optionName: "BackInNoteHistory", + defaultShortcuts: ["alt+left"] + }, + { + optionName: "ForwardInNoteHistory", + defaultShortcuts: ["alt+right"] + }, + { + optionName: "ToggleZenMode", + defaultShortcuts: ["alt+m"] + }, + { + optionName: "InsertDateTime", + defaultShortcuts: ["alt+t"] + }, + { + optionName: "ReloadApp", + defaultShortcuts: ["f5", "mod+r"] + }, + { + optionName: "OpenDevTools", + defaultShortcuts: ["mod+shift+i"] + }, + { + optionName: "FindInText", + defaultShortcuts: ["mod+f"] + }, + { + optionName: "ToggleFullscreen", + defaultShortcuts: ["f11"] + }, + { + optionName: "ZoomOut", + defaultShortcuts: ["mod+-"] + }, + { + optionName: "ZoomIn", + defaultShortcuts: ["mod+="] + } +]; + +module.exports = { + KEYBOARD_ACTIONS +}; \ No newline at end of file diff --git a/src/services/options_init.js b/src/services/options_init.js index 2fc6472a8..12e437c3b 100644 --- a/src/services/options_init.js +++ b/src/services/options_init.js @@ -5,6 +5,7 @@ const appInfo = require('./app_info'); const utils = require('./utils'); const log = require('./log'); const dateUtils = require('./date_utils'); +const keyboardActions = require('./keyboard_actions'); async function initDocumentOptions() { await optionService.createOption('documentId', utils.randomSecureToken(16), false); @@ -85,7 +86,9 @@ const defaultOptions = [ async function initStartupOptions() { const optionsMap = await optionService.getOptionsMap(); - for (const {name, value, isSynced} of defaultOptions) { + const allDefaultOptions = defaultOptions.concat(getKeyboardDefaultOptions()); + + for (const {name, value, isSynced} of allDefaultOptions) { if (!(name in optionsMap)) { await optionService.createOption(name, value, isSynced); @@ -94,6 +97,16 @@ async function initStartupOptions() { } } +function getKeyboardDefaultOptions() { + return keyboardActions.KEYBOARD_ACTIONS.map(ka => { + return { + name: "keyboardShortcuts" + ka.optionName, + value: JSON.stringify(ka.defaultShortcuts), + isSynced: false + }; + }); +} + module.exports = { initDocumentOptions, initSyncedOptions,