diff --git a/package-lock.json b/package-lock.json index 06d8e634f..bd02e3e31 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/package.json b/package.json index 332b4d3f9..975f4a263 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/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 */ 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 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}`); } } 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/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 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" }; 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/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; 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); } 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;