From 63a70f2ffa9f162ad28c016defee3b27b84a5f1a Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 14 Mar 2023 21:15:08 +0100 Subject: [PATCH 01/10] release 0.59.2 --- package.json | 2 +- src/services/build.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 05baeaf2f..5d7c9d49b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.59.1", + "version": "0.59.2", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/services/build.js b/src/services/build.js index cd5327164..8b4a403e6 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2023-02-28T23:39:34+01:00", buildRevision: "9eb3075f65af98bd8c4a8ca8cc241ae2ae05bfa9" }; +module.exports = { buildDate:"2023-03-14T21:15:08+01:00", buildRevision: "d8e9086bdeb721db795783b5d92395a9bd6882c9" }; From 147160ed450813320cef1a717273a4ac6b062de7 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 16 Mar 2023 13:30:33 +0100 Subject: [PATCH 02/10] fix dead references in consistency_checks.js --- src/services/consistency_checks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 3fecf607c..dc2e6072c 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -156,7 +156,7 @@ class ConsistencyChecks { let message = `Branch '${branchId}' was was missing parent note '${parentNoteId}', so it was deleted. `; if (becca.getNote(noteId).getParentBranches().length === 0) { - const newBranch = new Branch({ + const newBranch = new BBranch({ parentNoteId: 'root', noteId: noteId, prefix: 'recovered' @@ -447,7 +447,7 @@ class ConsistencyChecks { branch.markAsDeleted("parent-is-search"); // create a replacement branch in root parent - new Branch({ + new BBranch({ parentNoteId: 'root', noteId: branch.noteId, prefix: 'recovered' From 5ad47d38665fbb78847cc01514607047dd3fa341 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 17 Mar 2023 20:44:26 +0100 Subject: [PATCH 03/10] fix cache invalidation upon note title change --- src/becca/becca_loader.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/becca/becca_loader.js b/src/becca/becca_loader.js index ad4c90a10..f7659e964 100644 --- a/src/becca/becca_loader.js +++ b/src/becca/becca_loader.js @@ -70,7 +70,9 @@ function reload() { } function postProcessEntityUpdate(entityName, entity) { - if (entityName === 'branches') { + if (entityName === 'notes') { + noteUpdated(entity); + } else if (entityName === 'branches') { branchUpdated(entity); } else if (entityName === 'attributes') { attributeUpdated(entity); @@ -161,6 +163,15 @@ function branchDeleted(branchId) { delete becca.branches[branch.branchId]; } +function noteUpdated(entity) { + const note = becca.notes[entity.noteId]; + + if (note) { + // type / mime could have been changed, and they are present in flatTextCache + note.flatTextCache = null; + } +} + function branchUpdated(branch) { const childNote = becca.notes[branch.noteId]; From 4c3fcc3ea6f37debcb87ac1a7f5698c27be0e67b Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 17 Mar 2023 22:04:49 +0100 Subject: [PATCH 04/10] fix sanitization of autocomplete against XSS --- src/services/search/services/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index 06362b28c..beb0555d1 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -307,7 +307,7 @@ function highlightSearchResults(searchResults, highlightedTokens) { for (const result of searchResults) { const note = becca.notes[result.noteId]; - result.highlightedNotePathTitle = result.notePathTitle.replace('/[<\{\}]/g', ''); + result.highlightedNotePathTitle = result.notePathTitle.replace(/[<{}]/g, ''); if (highlightedTokens.find(token => note.type.includes(token))) { result.highlightedNotePathTitle += ` "type: ${note.type}'`; From 64d8c7a657b84a77c19663bf30a663f2e342960b Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 17 Mar 2023 22:14:50 +0100 Subject: [PATCH 05/10] add a check for the hidden note existence, #3728 --- db/migrations/0212__delete_all_attributes_of_named_notes.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/db/migrations/0212__delete_all_attributes_of_named_notes.js b/db/migrations/0212__delete_all_attributes_of_named_notes.js index 47ddb9114..d90f25e44 100644 --- a/db/migrations/0212__delete_all_attributes_of_named_notes.js +++ b/db/migrations/0212__delete_all_attributes_of_named_notes.js @@ -2,12 +2,18 @@ module.exports = () => { const cls = require("../../src/services/cls"); const beccaLoader = require("../../src/becca/becca_loader"); const becca = require("../../src/becca/becca"); + const log = require("../../src/services/log"); cls.init(() => { beccaLoader.load(); const hidden = becca.getNote("_hidden"); + if (!hidden) { + log.info("MIGRATION 212: no _hidden note, skipping."); + return; + } + for (const noteId of hidden.getSubtreeNoteIds({includeHidden: true})) { if (noteId.startsWith("_")) { // is "named" note const note = becca.getNote(noteId); From 117f1101e48d820adec6565f510221703fa5a653 Mon Sep 17 00:00:00 2001 From: dymani Date: Sat, 18 Mar 2023 10:18:34 +0800 Subject: [PATCH 06/10] Fix typo in backend API createOrUpdateLauncher() (cherry picked from commit b3f47bb2b6617ed8a43c6235b7a9d153dc58eb95) --- src/services/backend_script_api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js index 50bab0c0d..bab0702f5 100644 --- a/src/services/backend_script_api.js +++ b/src/services/backend_script_api.js @@ -475,7 +475,7 @@ function BackendScriptApi(currentNote, apiParams) { const noteId = 'al_' + opts.id; const launcherNote = - becca.getNote(opts.id) || + becca.getNote(noteId) || specialNotesService.createLauncher({ noteId: noteId, parentNoteId: parentNoteId, @@ -514,7 +514,7 @@ function BackendScriptApi(currentNote, apiParams) { if (opts.icon) { launcherNote.setLabel('iconClass', `bx ${opts.icon}`); } else { - launcherNote.removeLabel('keyboardShortcut'); + launcherNote.removeLabel('iconClass'); } return {note: launcherNote}; From 6b1f9d3243a4bc4aa41796d9dc1fce15830c1e3a Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 19 Mar 2023 22:23:58 +0100 Subject: [PATCH 07/10] add #newNotesOnTop, closes #3734 (cherry picked from commit d31b5ac99fadfaeaf23fd809598fd0f816b629e2) --- .../attribute_widgets/attribute_detail.js | 3 ++- src/services/builtin_attributes.js | 1 + src/services/notes.js | 21 ++++++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/public/app/widgets/attribute_widgets/attribute_detail.js b/src/public/app/widgets/attribute_widgets/attribute_detail.js index dc018836a..488f3709b 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_widgets/attribute_detail.js @@ -242,7 +242,8 @@ const ATTR_HELP = { "keepCurrentHoisting": "Opening this link won't change hoisting even if the note is not displayable in the current hoisted subtree.", "executeButton": "Title of the button which will execute the current code note", "executeDescription": "Longer description of the current code note displayed together with the execute button", - "excludeFromNoteMap": "Notes with this label will be hidden from the Note Map" + "excludeFromNoteMap": "Notes with this label will be hidden from the Note Map", + "newNotesOnTop": "New notes will be created at the top of the parent note, not on the bottom." }, "relation": { "runOnNoteCreation": "executes when note is created on backend. Use this relation if you want to run the script for all notes created under a specific subtree. In that case, create it on the subtree root note and make it inheritable. A new note created within the subtree (any depth) will trigger the script.", diff --git a/src/services/builtin_attributes.js b/src/services/builtin_attributes.js index 1597c6599..abb569656 100644 --- a/src/services/builtin_attributes.js +++ b/src/services/builtin_attributes.js @@ -62,6 +62,7 @@ module.exports = [ { type: 'label', name: 'keepCurrentHoisting'}, { type: 'label', name: 'executeButton'}, { type: 'label', name: 'executeDescription'}, + { type: 'label', name: 'newNotesOnTop'}, // relation names { type: 'relation', name: 'internalLink' }, diff --git a/src/services/notes.js b/src/services/notes.js index 2c71a9a08..6dfa34cb0 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -22,17 +22,18 @@ const htmlSanitizer = require("./html_sanitizer"); const ValidationError = require("../errors/validation_error"); const noteTypesService = require("./note_types"); -function getNewNotePosition(parentNoteId) { - const note = becca.notes[parentNoteId]; +function getNewNotePosition(parentNote) { + if (parentNote.hasLabel('newNotesOnTop')) { + const minNotePos = parentNote.getChildBranches() + .reduce((min, note) => Math.min(min, note.notePosition), 0); - if (!note) { - throw new Error(`Can't find note ${parentNoteId}`); + return minNotePos - 10; + } else { + const maxNotePos = parentNote.getChildBranches() + .reduce((max, note) => Math.max(max, note.notePosition), 0); + + return maxNotePos + 10; } - - const maxNotePos = note.getChildBranches() - .reduce((max, note) => Math.max(max, note.notePosition), 0); - - return maxNotePos + 10; } function triggerNoteTitleChanged(note) { @@ -186,7 +187,7 @@ function createNewNote(params) { branch = new BBranch({ noteId: note.noteId, parentNoteId: params.parentNoteId, - notePosition: params.notePosition !== undefined ? params.notePosition : getNewNotePosition(params.parentNoteId), + notePosition: params.notePosition !== undefined ? params.notePosition : getNewNotePosition(parentNote), prefix: params.prefix, isExpanded: !!params.isExpanded }).save(); From cd72ea524e52290181195ceb01c20bb57da29b6d Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 23 Mar 2023 23:47:28 +0100 Subject: [PATCH 08/10] promoted and inherited attributes should be shown grouped based on the owning note, #3761 --- src/public/app/entities/fnote.js | 9 ++++++++- .../ribbon_widgets/inherited_attribute_list.js | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/public/app/entities/fnote.js b/src/public/app/entities/fnote.js index 1f44a97bf..70594d647 100644 --- a/src/public/app/entities/fnote.js +++ b/src/public/app/entities/fnote.js @@ -706,7 +706,14 @@ class FNote { }); // attrs are not resorted if position changes after initial load - promotedAttrs.sort((a, b) => a.position < b.position ? -1 : 1); + promotedAttrs.sort((a, b) => { + if (a.noteId === b.noteId) { + return a.position < b.position ? -1 : 1; + } else { + // inherited promoted attributes should stay grouped: https://github.com/zadam/trilium/issues/3761 + return a.noteId < b.noteId ? -1 : 1; + } + }); return promotedAttrs; } diff --git a/src/public/app/widgets/ribbon_widgets/inherited_attribute_list.js b/src/public/app/widgets/ribbon_widgets/inherited_attribute_list.js index e434c20a6..01031686e 100644 --- a/src/public/app/widgets/ribbon_widgets/inherited_attribute_list.js +++ b/src/public/app/widgets/ribbon_widgets/inherited_attribute_list.js @@ -92,7 +92,18 @@ export default class InheritedAttributesWidget extends NoteContextAwareWidget { } getInheritedAttributes(note) { - return note.getAttributes().filter(attr => attr.noteId !== this.noteId); + const attrs = note.getAttributes().filter(attr => attr.noteId !== this.noteId); + + attrs.sort((a, b) => { + if (a.noteId === b.noteId) { + return a.position < b.position ? -1 : 1; + } else { + // inherited attributes should stay grouped: https://github.com/zadam/trilium/issues/3761 + return a.noteId < b.noteId ? -1 : 1; + } + }); + + return attrs; } entitiesReloadedEvent({loadResults}) { From a099876088ca923b12571749c6118bb8ffd764ea Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 26 Mar 2023 20:50:37 +0200 Subject: [PATCH 09/10] fix escaping in sql console results --- package-lock.json | 5 ++--- src/public/app/widgets/sql_result.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index dbd019d3b..8117a4a56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,11 @@ { "name": "trilium", - "version": "0.59.1", + "version": "0.59.2", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "trilium", - "version": "0.59.1", + "version": "0.59.2", "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { diff --git a/src/public/app/widgets/sql_result.js b/src/public/app/widgets/sql_result.js index 142dc79e3..4224e714b 100644 --- a/src/public/app/widgets/sql_result.js +++ b/src/public/app/widgets/sql_result.js @@ -60,7 +60,7 @@ export default class SqlResultWidget extends NoteContextAwareWidget { const $row = $(""); for (const key in result) { - $row.append($("").html(key)); + $row.append($("").text(key)); } $table.append($row); @@ -69,7 +69,7 @@ export default class SqlResultWidget extends NoteContextAwareWidget { const $row = $(""); for (const key in result) { - $row.append($("").html(result[key])); + $row.append($("").text(result[key])); } $table.append($row); From 9881e6de3e4966af39ec6245562dca6ac7b25eaa Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 26 Mar 2023 23:09:15 +0200 Subject: [PATCH 10/10] fix hangup on highlighting empty tokens, closes #3772 --- src/services/search/services/search.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index beb0555d1..d682af090 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -299,7 +299,9 @@ function highlightSearchResults(searchResults, highlightedTokens) { // which would make the resulting HTML string invalid. // { and } are used for marking and tag (to avoid matches on single 'b' character) // < and > are used for marking and - highlightedTokens = highlightedTokens.map(token => token.replace('/[<\{\}]/g', '')); + highlightedTokens = highlightedTokens + .map(token => token.replace('/[<\{\}]/g', '')) + .filter(token => !!token?.trim()); // sort by the longest, so we first highlight the longest matches highlightedTokens.sort((a, b) => a.length > b.length ? -1 : 1);