diff --git a/docs/backend_api/ApiToken.html b/docs/backend_api/ApiToken.html
index 3ac23346c..513461163 100644
--- a/docs/backend_api/ApiToken.html
+++ b/docs/backend_api/ApiToken.html
@@ -288,7 +288,7 @@
diff --git a/docs/backend_api/Attribute.html b/docs/backend_api/Attribute.html
index f8d9c6409..8cba42261 100644
--- a/docs/backend_api/Attribute.html
+++ b/docs/backend_api/Attribute.html
@@ -426,7 +426,7 @@
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html
index 7ebaed12a..4235dde33 100644
--- a/docs/backend_api/BackendScriptApi.html
+++ b/docs/backend_api/BackendScriptApi.html
@@ -3814,7 +3814,7 @@ transactional by default.
diff --git a/docs/backend_api/Branch.html b/docs/backend_api/Branch.html
index da46e696b..90244543e 100644
--- a/docs/backend_api/Branch.html
+++ b/docs/backend_api/Branch.html
@@ -384,6 +384,113 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
+
Methods
+
+
+
+
+
+
+
+ (async) getNote() → {Note|null}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Note
+|
+
+null
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -404,7 +511,7 @@ 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 528be57b8..06d760b44 100644
--- a/docs/backend_api/Entity.html
+++ b/docs/backend_api/Entity.html
@@ -216,7 +216,7 @@
diff --git a/docs/backend_api/Image.html b/docs/backend_api/Image.html
index f16a7edae..3af2be45b 100644
--- a/docs/backend_api/Image.html
+++ b/docs/backend_api/Image.html
@@ -380,7 +380,7 @@
diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html
index 5c3b6aee2..5b9409129 100644
--- a/docs/backend_api/Note.html
+++ b/docs/backend_api/Note.html
@@ -613,7 +613,7 @@
Source:
@@ -809,7 +809,7 @@
Source:
@@ -1005,7 +1005,7 @@
Source:
@@ -1177,7 +1177,7 @@
Source:
@@ -1233,7 +1233,7 @@
- (async) getAttributes() → {Promise.<Array.<Attribute>>}
+ (async) getAttributes(nameopt) → {Promise.<Array.<Attribute>>}
@@ -1248,6 +1248,67 @@
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+ Attributes |
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ name |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+ <optional>
+
+
+
+
+
+ |
+
+
+
+
+ attribute name to filter |
+
+
+
+
+
+
+
@@ -1281,7 +1342,7 @@
Source:
@@ -1457,7 +1518,7 @@
Source:
@@ -1561,7 +1622,7 @@
Source:
@@ -1661,7 +1722,7 @@
Source:
@@ -1765,7 +1826,7 @@
Source:
@@ -1918,7 +1979,7 @@
Source:
@@ -1974,7 +2035,7 @@
- (async) getLabels() → {Promise.<Array.<Attribute>>}
+ (async) getLabels(nameopt) → {Promise.<Array.<Attribute>>}
@@ -1989,6 +2050,67 @@
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+ Attributes |
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ name |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+ <optional>
+
+
+
+
+
+ |
+
+
+
+
+ label name to filter |
+
+
+
+
+
+
+
@@ -2022,7 +2144,7 @@
Source:
@@ -2175,7 +2297,7 @@
Source:
@@ -2279,7 +2401,7 @@
Source:
@@ -2483,7 +2605,7 @@
Source:
@@ -2636,7 +2758,7 @@
Source:
@@ -2692,7 +2814,7 @@
- (async) getRelations() → {Promise.<Array.<Attribute>>}
+ (async) getRelations(nameopt) → {Promise.<Array.<Attribute>>}
@@ -2707,6 +2829,67 @@
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+ Attributes |
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ name |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+ <optional>
+
+
+
+
+
+ |
+
+
+
+
+ relation name to filter |
+
+
+
+
+
+
+
@@ -2740,7 +2923,7 @@
Source:
@@ -2893,7 +3076,7 @@
Source:
@@ -3049,7 +3232,7 @@
Source:
@@ -3157,7 +3340,7 @@
Source:
@@ -3433,7 +3616,7 @@
Source:
@@ -3489,6 +3672,110 @@
+ (async) hasChildren() → {boolean}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ - true if note has children
+
+
+
+
+
+ -
+ Type
+
+ -
+
+boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
(async) hasLabel(name) → {Promise.<boolean>}
@@ -3586,7 +3873,7 @@
Source:
@@ -3739,7 +4026,7 @@
Source:
@@ -3848,7 +4135,7 @@ Cache is note instance scoped.
Source:
@@ -4346,7 +4633,7 @@ Cache is note instance scoped.
Source:
@@ -4573,7 +4860,7 @@ Cache is note instance scoped.
Source:
@@ -4769,7 +5056,7 @@ Cache is note instance scoped.
Source:
@@ -4965,7 +5252,7 @@ Cache is note instance scoped.
Source:
@@ -5192,7 +5479,7 @@ Cache is note instance scoped.
Source:
@@ -5388,7 +5675,7 @@ Cache is note instance scoped.
Source:
@@ -5584,7 +5871,7 @@ Cache is note instance scoped.
Source:
@@ -5842,7 +6129,7 @@ Cache is note instance scoped.
Source:
@@ -6069,7 +6356,7 @@ Cache is note instance scoped.
Source:
@@ -6296,7 +6583,7 @@ Cache is note instance scoped.
Source:
@@ -6364,7 +6651,7 @@ Cache is note instance scoped.
diff --git a/docs/backend_api/NoteImage.html b/docs/backend_api/NoteImage.html
index becb73367..690c9baf5 100644
--- a/docs/backend_api/NoteImage.html
+++ b/docs/backend_api/NoteImage.html
@@ -334,7 +334,7 @@
diff --git a/docs/backend_api/NoteRevision.html b/docs/backend_api/NoteRevision.html
index 328f39192..fbd8d171e 100644
--- a/docs/backend_api/NoteRevision.html
+++ b/docs/backend_api/NoteRevision.html
@@ -403,7 +403,7 @@
diff --git a/docs/backend_api/Option.html b/docs/backend_api/Option.html
index 858bccd6f..4a8482ce2 100644
--- a/docs/backend_api/Option.html
+++ b/docs/backend_api/Option.html
@@ -311,7 +311,7 @@
diff --git a/docs/backend_api/RecentNote.html b/docs/backend_api/RecentNote.html
index c37cd8909..07116489a 100644
--- a/docs/backend_api/RecentNote.html
+++ b/docs/backend_api/RecentNote.html
@@ -288,7 +288,7 @@
diff --git a/docs/backend_api/entities_api_token.js.html b/docs/backend_api/entities_api_token.js.html
index db27a39dd..0fc30fe88 100644
--- a/docs/backend_api/entities_api_token.js.html
+++ b/docs/backend_api/entities_api_token.js.html
@@ -75,7 +75,7 @@ module.exports = ApiToken;
diff --git a/docs/backend_api/entities_attribute.js.html b/docs/backend_api/entities_attribute.js.html
index 8a97a2a1f..a51aebe98 100644
--- a/docs/backend_api/entities_attribute.js.html
+++ b/docs/backend_api/entities_attribute.js.html
@@ -134,7 +134,7 @@ module.exports = Attribute;
diff --git a/docs/backend_api/entities_branch.js.html b/docs/backend_api/entities_branch.js.html
index d6656f24d..1de70e8a8 100644
--- a/docs/backend_api/entities_branch.js.html
+++ b/docs/backend_api/entities_branch.js.html
@@ -55,6 +55,14 @@ class Branch extends Entity {
// notePosition is not part of hash because it would produce a lot of updates in case of reordering
static get hashedProperties() { return ["branchId", "noteId", "parentNoteId", "isDeleted", "prefix"]; }
+ constructor(row = {}) {
+ super(row);
+
+ // used to detect move in note tree
+ this.origParentNoteId = this.parentNoteId;
+ }
+
+ /** @returns {Note|null} */
async getNote() {
return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
}
@@ -97,7 +105,7 @@ module.exports = Branch;
diff --git a/docs/backend_api/entities_entity.js.html b/docs/backend_api/entities_entity.js.html
index 22950d4ac..5e3b0d17f 100644
--- a/docs/backend_api/entities_entity.js.html
+++ b/docs/backend_api/entities_entity.js.html
@@ -93,7 +93,7 @@ module.exports = Entity;
diff --git a/docs/backend_api/entities_image.js.html b/docs/backend_api/entities_image.js.html
index 162876e6c..3f31bfbd2 100644
--- a/docs/backend_api/entities_image.js.html
+++ b/docs/backend_api/entities_image.js.html
@@ -83,7 +83,7 @@ module.exports = Image;
diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.html
index 0acc86d57..feafba136 100644
--- a/docs/backend_api/entities_note.js.html
+++ b/docs/backend_api/entities_note.js.html
@@ -127,23 +127,37 @@ class Note extends Entity {
return await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);
}
- /** @returns {Promise<Attribute[]>} all note's attributes, including inherited ones */
- async getAttributes() {
+ /**
+ * @param {string} [name] - attribute name to filter
+ * @returns {Promise<Attribute[]>} all note's attributes, including inherited ones
+ */
+ async getAttributes(name) {
if (!this.__attributeCache) {
await this.loadAttributesToCache();
}
- return this.__attributeCache;
+ if (name) {
+ return this.__attributeCache.filter(attr => attr.name === name);
+ }
+ else {
+ return this.__attributeCache;
+ }
}
- /** @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones */
- async getLabels() {
- return (await this.getAttributes()).filter(attr => attr.type === LABEL);
+ /**
+ * @param {string} [name] - label name to filter
+ * @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones
+ */
+ async getLabels(name) {
+ return (await this.getAttributes(name)).filter(attr => attr.type === LABEL);
}
- /** @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones */
- async getRelations() {
- return (await this.getAttributes()).filter(attr => attr.type === RELATION);
+ /**
+ * @param {string} [name] - relation name to filter
+ * @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones
+ */
+ async getRelations(name) {
+ return (await this.getAttributes(name)).filter(attr => attr.type === RELATION);
}
/**
@@ -496,6 +510,13 @@ class Note extends Entity {
return await repository.getEntities("SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);
}
+ /**
+ * @returns {boolean} - true if note has children
+ */
+ async hasChildren() {
+ return (await this.getChildNotes()).length > 0;
+ }
+
/**
* @returns {Promise<Note[]>} child notes of this note
*/
@@ -580,7 +601,7 @@ module.exports = Note;
diff --git a/docs/backend_api/entities_note_image.js.html b/docs/backend_api/entities_note_image.js.html
index 837bd72d2..e60507b35 100644
--- a/docs/backend_api/entities_note_image.js.html
+++ b/docs/backend_api/entities_note_image.js.html
@@ -90,7 +90,7 @@ module.exports = NoteImage;
diff --git a/docs/backend_api/entities_note_revision.js.html b/docs/backend_api/entities_note_revision.js.html
index cf2e8a7c2..129d75cca 100644
--- a/docs/backend_api/entities_note_revision.js.html
+++ b/docs/backend_api/entities_note_revision.js.html
@@ -91,7 +91,7 @@ module.exports = NoteRevision;
diff --git a/docs/backend_api/entities_option.js.html b/docs/backend_api/entities_option.js.html
index b875e8335..8acb062d1 100644
--- a/docs/backend_api/entities_option.js.html
+++ b/docs/backend_api/entities_option.js.html
@@ -78,7 +78,7 @@ module.exports = Option;
diff --git a/docs/backend_api/entities_recent_note.js.html b/docs/backend_api/entities_recent_note.js.html
index 8353b2ca5..108bf9ba2 100644
--- a/docs/backend_api/entities_recent_note.js.html
+++ b/docs/backend_api/entities_recent_note.js.html
@@ -75,7 +75,7 @@ module.exports = RecentNote;
diff --git a/docs/backend_api/global.html b/docs/backend_api/global.html
index 103072b40..2e3b50f0f 100644
--- a/docs/backend_api/global.html
+++ b/docs/backend_api/global.html
@@ -594,7 +594,7 @@
diff --git a/docs/backend_api/index.html b/docs/backend_api/index.html
index 5c4e117d4..6c0ee3c57 100644
--- a/docs/backend_api/index.html
+++ b/docs/backend_api/index.html
@@ -56,7 +56,7 @@
diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html
index 339efbffd..9e790304e 100644
--- a/docs/backend_api/services_backend_script_api.js.html
+++ b/docs/backend_api/services_backend_script_api.js.html
@@ -278,7 +278,7 @@ module.exports = BackendScriptApi;
diff --git a/docs/frontend_api/Branch.html b/docs/frontend_api/Branch.html
index 30a2c8bda..d0a24eb02 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 5f5601c95..9cbffba06 100644
--- a/docs/frontend_api/FrontendScriptApi.html
+++ b/docs/frontend_api/FrontendScriptApi.html
@@ -81,7 +81,7 @@
Source:
@@ -221,7 +221,7 @@
Source:
@@ -334,7 +334,7 @@
Source:
@@ -444,7 +444,7 @@
Source:
@@ -573,7 +573,7 @@
Source:
@@ -726,7 +726,7 @@
Source:
@@ -879,7 +879,7 @@
Source:
@@ -1057,7 +1057,7 @@
Source:
@@ -1188,7 +1188,7 @@
Source:
@@ -1244,6 +1244,110 @@
+ getCurrentNoteContent() → {string}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ content of currently loaded note in the editor (HTML, code etc.)
+
+
+
+
+
+ -
+ Type
+
+ -
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
getInstanceName() → {string}
@@ -1297,7 +1401,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -1496,7 +1600,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -1544,6 +1648,137 @@ otherwise (by e.g. createNoteLink())
+
+
+
+
+ onNoteChange(func)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ func |
+
+
+
+
+
+function
+
+
+
+ |
+
+
+
+
+
+ callback called on note change |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1645,7 +1880,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -1753,7 +1988,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -1930,7 +2165,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -2087,7 +2322,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -2222,7 +2457,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -2272,7 +2507,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 bf24211a9..1c335ca92 100644
--- a/docs/frontend_api/NoteFull.html
+++ b/docs/frontend_api/NoteFull.html
@@ -279,7 +279,7 @@
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html
index 97005cd98..b01b6ee04 100644
--- a/docs/frontend_api/NoteShort.html
+++ b/docs/frontend_api/NoteShort.html
@@ -1316,7 +1316,7 @@ Its notable omission is the note content.
diff --git a/docs/frontend_api/entities_branch.js.html b/docs/frontend_api/entities_branch.js.html
index d4b1b9b86..0742712ea 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 5e7ba1951..742f8552d 100644
--- a/docs/frontend_api/entities_note_full.js.html
+++ b/docs/frontend_api/entities_note_full.js.html
@@ -64,7 +64,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 09df0f057..c369da114 100644
--- a/docs/frontend_api/entities_note_short.js.html
+++ b/docs/frontend_api/entities_note_short.js.html
@@ -128,7 +128,7 @@ export default NoteShort;
diff --git a/docs/frontend_api/global.html b/docs/frontend_api/global.html
index 63e4813bf..2e5c12b06 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 7546ae660..dfc80b998 100644
--- a/docs/frontend_api/index.html
+++ b/docs/frontend_api/index.html
@@ -56,7 +56,7 @@
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html
index fb86853c0..8b26e8a38 100644
--- a/docs/frontend_api/services_frontend_script_api.js.html
+++ b/docs/frontend_api/services_frontend_script_api.js.html
@@ -32,6 +32,7 @@ import utils from './utils.js';
import infoService from './info.js';
import linkService from './link.js';
import treeCache from './tree_cache.js';
+import noteDetailService from './note_detail.js';
/**
* This is the main frontend API interface for scripts. It's published in the local "api" object.
@@ -219,6 +220,18 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
* @param {string} [noteTitle] - if not present we'll use note title
*/
this.createNoteLink = linkService.createNoteLink;
+
+ /**
+ * @method
+ * @returns {string} content of currently loaded note in the editor (HTML, code etc.)
+ */
+ this.getCurrentNoteContent = noteDetailService.getCurrentNoteContent;
+
+ /**
+ * @method
+ * @param {function} func - callback called on note change
+ */
+ this.onNoteChange = noteDetailService.onNoteChange;
}
export default FrontendScriptApi;
@@ -237,7 +250,7 @@ export default FrontendScriptApi;
diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js
index cfe9dc2e3..57590dfed 100644
--- a/src/public/javascripts/services/frontend_script_api.js
+++ b/src/public/javascripts/services/frontend_script_api.js
@@ -4,6 +4,7 @@ import utils from './utils.js';
import infoService from './info.js';
import linkService from './link.js';
import treeCache from './tree_cache.js';
+import noteDetailService from './note_detail.js';
/**
* This is the main frontend API interface for scripts. It's published in the local "api" object.
@@ -191,6 +192,18 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) {
* @param {string} [noteTitle] - if not present we'll use note title
*/
this.createNoteLink = linkService.createNoteLink;
+
+ /**
+ * @method
+ * @returns {string} content of currently loaded note in the editor (HTML, code etc.)
+ */
+ this.getCurrentNoteContent = noteDetailService.getCurrentNoteContent;
+
+ /**
+ * @method
+ * @param {function} func - callback called on note change
+ */
+ this.onNoteChange = noteDetailService.onNoteChange;
}
export default FrontendScriptApi;
\ No newline at end of file
diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js
index 7a9a6e0bc..ad6a11a5e 100644
--- a/src/public/javascripts/services/note_detail.js
+++ b/src/public/javascripts/services/note_detail.js
@@ -49,6 +49,10 @@ const components = {
};
function getComponent(type) {
+ if (!type) {
+ type = getCurrentNote().type;
+ }
+
if (components[type]) {
return components[type];
}
@@ -93,11 +97,19 @@ async function switchToNote(noteId) {
}
}
+function getCurrentNoteContent() {
+ return getComponent().getContent();
+}
+
+function onNoteChange(func) {
+ return getComponent().onNoteChange(func);
+}
+
async function saveNote() {
const note = getCurrentNote();
note.title = $noteTitle.val();
- note.content = getComponent(note.type).getContent();
+ note.content = getCurrentNoteContent(note);
// it's important to set the flag back to false immediatelly after retrieving title and content
// otherwise we might overwrite another change (especially async code)
@@ -107,7 +119,6 @@ async function saveNote() {
await server.put('notes/' + note.noteId, note.dto);
-
if (note.isProtected) {
protectedSessionHolder.touchProtectedSession();
}
@@ -549,5 +560,7 @@ export default {
refreshAttributes,
saveNote,
saveNoteIfChanged,
- noteChanged
+ noteChanged,
+ getCurrentNoteContent,
+ onNoteChange
};
\ No newline at end of file
diff --git a/src/public/javascripts/services/note_detail_code.js b/src/public/javascripts/services/note_detail_code.js
index 3cd9fc099..4ed8452f3 100644
--- a/src/public/javascripts/services/note_detail_code.js
+++ b/src/public/javascripts/services/note_detail_code.js
@@ -35,7 +35,7 @@ async function show() {
tabindex: 100
});
- codeEditor.on('change', noteDetailService.noteChanged);
+ onNoteChange(noteDetailService.noteChanged);
}
$noteDetailCode.show();
@@ -85,6 +85,10 @@ async function executeCurrentNote() {
infoService.showMessage("Note executed");
}
+function onNoteChange(func) {
+ codeEditor.on('change', func);
+}
+
$(document).bind('keydown', "ctrl+return", executeCurrentNote);
$executeScriptButton.click(executeCurrentNote);
@@ -92,5 +96,6 @@ $executeScriptButton.click(executeCurrentNote);
export default {
show,
getContent,
- focus
+ focus,
+ onNoteChange
}
\ No newline at end of file
diff --git a/src/public/javascripts/services/note_detail_file.js b/src/public/javascripts/services/note_detail_file.js
index 724f0f50b..d90ce502b 100644
--- a/src/public/javascripts/services/note_detail_file.js
+++ b/src/public/javascripts/services/note_detail_file.js
@@ -46,5 +46,6 @@ function getFileUrl() {
export default {
show,
getContent: () => null,
- focus: () => null
+ focus: () => null,
+ onNoteChange: () => null
}
\ No newline at end of file
diff --git a/src/public/javascripts/services/note_detail_render.js b/src/public/javascripts/services/note_detail_render.js
index bf5c94c49..281e2ff56 100644
--- a/src/public/javascripts/services/note_detail_render.js
+++ b/src/public/javascripts/services/note_detail_render.js
@@ -34,5 +34,6 @@ $renderButton.click(render);
export default {
show: render,
getContent: () => "",
- focus: () => null
+ focus: () => null,
+ onNoteChange: () => null
}
\ No newline at end of file
diff --git a/src/public/javascripts/services/note_detail_search.js b/src/public/javascripts/services/note_detail_search.js
index 0b1b8306d..05b63e524 100644
--- a/src/public/javascripts/services/note_detail_search.js
+++ b/src/public/javascripts/services/note_detail_search.js
@@ -28,5 +28,6 @@ function show() {
export default {
getContent,
show,
- focus: () => null
+ focus: () => null,
+ onNoteChange: () => null
}
\ No newline at end of file
diff --git a/src/public/javascripts/services/note_detail_text.js b/src/public/javascripts/services/note_detail_text.js
index 39af122be..9088a8c58 100644
--- a/src/public/javascripts/services/note_detail_text.js
+++ b/src/public/javascripts/services/note_detail_text.js
@@ -29,7 +29,7 @@ async function show() {
}
});
- textEditor.model.document.on('change:data', noteDetailService.noteChanged);
+ onNoteChange(noteDetailService.noteChanged);
}
}
@@ -105,6 +105,10 @@ async function sendMarkdownDialog() {
$markdownImportTextarea.val('');
}
+function onNoteChange(func) {
+ textEditor.model.document.on('change:data', func);
+}
+
$markdownImportButton.click(sendMarkdownDialog);
$markdownImportDialog.bind('keydown', 'ctrl+return', sendMarkdownDialog);
@@ -115,5 +119,6 @@ export default {
show,
getEditor,
getContent,
- focus
+ focus,
+ onNoteChange
}
\ No newline at end of file
diff --git a/src/public/javascripts/services/note_type.js b/src/public/javascripts/services/note_type.js
index d5de6b31d..f5f3a9679 100644
--- a/src/public/javascripts/services/note_type.js
+++ b/src/public/javascripts/services/note_type.js
@@ -34,6 +34,7 @@ function NoteTypeModel() {
{ mime: 'application/javascript;env=backend', title: 'JavaScript backend' },
{ mime: 'application/json', title: 'JSON' },
{ mime: 'text/x-kotlin', title: 'Kotlin' },
+ { mime: 'text/x-stex', title: 'LaTex' },
{ mime: 'text/x-lua', title: 'Lua' },
{ mime: 'text/x-markdown', title: 'Markdown' },
{ mime: 'text/x-objectivec', title: 'Objective C' },