From c8e01d6ccedd75835bdf63272f01fecd42989a2c Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 5 Mar 2019 20:44:50 +0100 Subject: [PATCH 1/8] pretty print JSON into note content --- src/entities/note.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entities/note.js b/src/entities/note.js index 05ee5a0a5..a206b5caa 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -106,7 +106,7 @@ class Note extends Entity { /** @returns {Promise} */ async setJsonContent(content) { - await this.setContent(JSON.stringify(content)); + await this.setContent(JSON.stringify(content, null, '\t')); } /** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */ From fe86c09f22dfa9d9c9aa50ba83e686e96d6e8a1a Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 5 Mar 2019 20:49:39 +0100 Subject: [PATCH 2/8] make sure date label is always created with YYYY-MM-DD and not the rest of date time --- src/services/date_notes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/date_notes.js b/src/services/date_notes.js index bcb3d601f..ee45c7ca1 100644 --- a/src/services/date_notes.js +++ b/src/services/date_notes.js @@ -116,7 +116,7 @@ async function getDateNote(dateStr) { dateNote = await createNote(monthNote.noteId, noteTitle); } - await attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr); + await attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr.substr(0, 10)); } return dateNote; From ecbaffa5f3ef9335521992d156a2b48b814ecbe8 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 7 Mar 2019 20:45:32 +0100 Subject: [PATCH 3/8] return focus back to note detail after quitting add link dialog --- src/public/javascripts/dialogs/add_link.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/public/javascripts/dialogs/add_link.js b/src/public/javascripts/dialogs/add_link.js index d4fd54ada..87819bc6b 100644 --- a/src/public/javascripts/dialogs/add_link.js +++ b/src/public/javascripts/dialogs/add_link.js @@ -137,6 +137,10 @@ function linkTypeChanged() { $linkTypes.change(linkTypeChanged); +// return back focus to note text detail after quitting add link +// the problem is that cursor position is reset +$dialog.on("hidden.bs.modal", () => noteDetailText.focus()); + export default { showDialog }; \ No newline at end of file From ee58bf3d5c4c40ec9dee1df0b353fc3ec9195dae Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 7 Mar 2019 20:51:55 +0100 Subject: [PATCH 4/8] fix bundle execution error handling --- src/public/javascripts/services/bundle.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/public/javascripts/services/bundle.js b/src/public/javascripts/services/bundle.js index 4d67496ba..1548a1e0f 100644 --- a/src/public/javascripts/services/bundle.js +++ b/src/public/javascripts/services/bundle.js @@ -9,6 +9,8 @@ async function getAndExecuteBundle(noteId, originEntity = null) { } async function executeBundle(bundle, originEntity) { + console.log(bundle); + const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity); try { @@ -17,7 +19,7 @@ async function executeBundle(bundle, originEntity) { }.call(apiContext)); } catch (e) { - infoService.showAndLogError(`Execution of script "${bundle.note.title}" (${bundle.note.noteId}) failed with error: ${e.message}`); + infoService.showAndLogError(`Execution of ${bundle.noteId} failed with error: ${e.message}`); } } From 02eddc347abebce63a8882f6f83ac73655005849 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 7 Mar 2019 22:00:23 +0100 Subject: [PATCH 5/8] fix export of protected notes to tar archive, fixes #432 --- src/services/protected_session.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/protected_session.js b/src/services/protected_session.js index 83b877aff..283e04279 100644 --- a/src/services/protected_session.js +++ b/src/services/protected_session.js @@ -15,7 +15,7 @@ function setDataKey(decryptedDataKey) { } function setProtectedSessionId(req) { - cls.namespace.set('protectedSessionId', req.headers['trilium-protected-session-id']); + cls.namespace.set('protectedSessionId', req.headers['trilium-protected-session-id'] || req.query.protectedSessionId); } function getProtectedSessionId() { @@ -62,7 +62,9 @@ function decryptNoteContent(noteContent) { } try { - noteContent.content = dataEncryptionService.decrypt(getDataKey(), noteContent.content); + if (noteContent.content != null) { + noteContent.content = dataEncryptionService.decrypt(getDataKey(), noteContent.content.toString()); + } } catch (e) { e.message = `Cannot decrypt note content for noteContentId=${noteContent.noteContentId}: ` + e.message; From ae17e4dc601ef98974827d8910112d53460165a0 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 7 Mar 2019 22:40:05 +0100 Subject: [PATCH 6/8] release 0.30.4 --- package.json | 2 +- src/services/build.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 47feec441..82fadc52a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.30.3-beta", + "version": "0.30.4", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/services/build.js b/src/services/build.js index 7369f9166..4675c7bb5 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2019-03-03T20:47:50+01:00", buildRevision: "95d8f07458853dbad08964e7ec1af1d50792b0a2" }; +module.exports = { buildDate:"2019-03-07T22:40:05+01:00", buildRevision: "02eddc347abebce63a8882f6f83ac73655005849" }; From a432ad74834f3ee614c9c4f29822280f84a7e7b7 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 8 Mar 2019 22:25:12 +0100 Subject: [PATCH 7/8] fix isProtected consistency for images and files + related consistency check --- package-lock.json | 2 +- src/public/javascripts/services/note_detail.js | 5 ++++- src/services/consistency_checks.js | 7 +++++++ src/services/notes.js | 14 ++++++++------ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index ed2f68159..2c7112a53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "trilium", - "version": "0.30.3-beta", + "version": "0.30.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js index c2f7c3393..1cd8b55ba 100644 --- a/src/public/javascripts/services/note_detail.js +++ b/src/public/javascripts/services/note_detail.js @@ -117,7 +117,10 @@ async function saveNote() { } note.title = $noteTitle.val(); - note.noteContent.content = getCurrentNoteContent(note); + + if (note.noteContent != null) { // might be null for file/image + note.noteContent.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) diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 208fbc8a5..8a351873d 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -357,6 +357,13 @@ async function findLogicIssues() { logFix(`Removed link ${linkId} because target note ${targetNoteId} is also deleted.`); }); + + await findIssues(` + SELECT noteId + FROM notes + JOIN note_contents USING(noteId) + WHERE notes.isDeleted = 0 AND notes.isProtected != note_contents.isProtected`, + ({noteId}) => `Note ${noteId} has inconsistent isProtected in notes and note_contents tables`); } async function runSyncRowChecks(entityName, key) { diff --git a/src/services/notes.js b/src/services/notes.js index 623fbc1c5..7509956bf 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -332,19 +332,21 @@ async function updateNote(noteId, noteUpdates) { const noteTitleChanged = note.title !== noteUpdates.title; - noteUpdates.noteContent.content = await saveLinks(note, noteUpdates.noteContent.content); - note.title = noteUpdates.title; note.isProtected = noteUpdates.isProtected; await note.save(); - if (note.type !== 'file' && note.type !== 'image') { - const noteContent = await note.getNoteContent(); + const noteContent = await note.getNoteContent(); + + if (!['file', 'image'].includes(note.type)) { + noteUpdates.noteContent.content = await saveLinks(note, noteUpdates.noteContent.content); + noteContent.content = noteUpdates.noteContent.content; - noteContent.isProtected = noteUpdates.isProtected; - await noteContent.save(); } + noteContent.isProtected = noteUpdates.isProtected; + await noteContent.save(); + if (noteTitleChanged) { await triggerNoteTitleChanged(note); } From 37d2a7939ceff95e0c66755a7fb0ad13083d0f38 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 9 Mar 2019 18:57:21 +0100 Subject: [PATCH 8/8] fix background/border on quick help dialog, closes #440 --- src/public/stylesheets/style.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index a0d0dca5f..a47284ea6 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -910,4 +910,9 @@ a.external:after, a[href^="http://"]:after, a[href^="https://"]:after { font-size: smaller; content: "\2197"; vertical-align: top; +} + +.card { + background-color: inherit !important; + border-color: var(--main-border-color) !important; } \ No newline at end of file