From 0afc41060a935a46642a082128bea5002c2410e1 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 16 Nov 2023 00:11:14 +0100 Subject: [PATCH 1/4] template LABEL should not be inherited #4349 --- package-lock.json | 32 +++++++++---------- package.json | 4 +-- .../search/expressions/attribute_exists.js | 8 ++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index d94058c5c..1392940ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "trilium", - "version": "0.61.10-beta", + "version": "0.61.13", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "trilium", - "version": "0.61.10-beta", + "version": "0.61.13", "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { @@ -47,7 +47,7 @@ "jimp": "0.22.10", "joplin-turndown-plugin-gfm": "1.0.12", "jsdom": "22.1.0", - "marked": "9.1.2", + "marked": "9.1.6", "mime-types": "2.1.35", "multer": "1.4.5-lts.1", "node-abi": "3.50.0", @@ -79,7 +79,7 @@ }, "devDependencies": { "cross-env": "7.0.3", - "electron": "25.9.2", + "electron": "25.9.5", "electron-builder": "24.6.4", "electron-packager": "17.1.2", "electron-rebuild": "3.2.9", @@ -4276,9 +4276,9 @@ } }, "node_modules/electron": { - "version": "25.9.2", - "resolved": "https://registry.npmjs.org/electron/-/electron-25.9.2.tgz", - "integrity": "sha512-hVBN5rsrL99BKNHvzMeYy2PkAmewuIobu4U3o3EzVz4MDoLmMfW4yTH5GZ4RbJrpokoEky5IzGtRR/ggPzL6Fw==", + "version": "25.9.5", + "resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz", + "integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==", "hasInstallScript": true, "dependencies": { "@electron/get": "^2.0.0", @@ -9037,9 +9037,9 @@ } }, "node_modules/marked": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.2.tgz", - "integrity": "sha512-qoKMJqK0w6vkLk8+KnKZAH6neUZSNaQqVZ/h2yZ9S7CbLuFHyS2viB0jnqcWF9UKjwsAbMrQtnQhdmdvOVOw9w==", + "version": "9.1.6", + "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.6.tgz", + "integrity": "sha512-jcByLnIFkd5gSXZmjNvS1TlmRhCXZjIzHYlaGkPlLIekG55JDR2Z4va9tZwCiP+/RDERiNhMOFu01xd6O5ct1Q==", "bin": { "marked": "bin/marked.js" }, @@ -16633,9 +16633,9 @@ } }, "electron": { - "version": "25.9.2", - "resolved": "https://registry.npmjs.org/electron/-/electron-25.9.2.tgz", - "integrity": "sha512-hVBN5rsrL99BKNHvzMeYy2PkAmewuIobu4U3o3EzVz4MDoLmMfW4yTH5GZ4RbJrpokoEky5IzGtRR/ggPzL6Fw==", + "version": "25.9.5", + "resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz", + "integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==", "requires": { "@electron/get": "^2.0.0", "@types/node": "^18.11.18", @@ -20139,9 +20139,9 @@ "requires": {} }, "marked": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.2.tgz", - "integrity": "sha512-qoKMJqK0w6vkLk8+KnKZAH6neUZSNaQqVZ/h2yZ9S7CbLuFHyS2viB0jnqcWF9UKjwsAbMrQtnQhdmdvOVOw9w==" + "version": "9.1.6", + "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.6.tgz", + "integrity": "sha512-jcByLnIFkd5gSXZmjNvS1TlmRhCXZjIzHYlaGkPlLIekG55JDR2Z4va9tZwCiP+/RDERiNhMOFu01xd6O5ct1Q==" }, "matcher": { "version": "3.0.0", diff --git a/package.json b/package.json index 3231defaf..b3dae2e6a 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "jimp": "0.22.10", "joplin-turndown-plugin-gfm": "1.0.12", "jsdom": "22.1.0", - "marked": "9.1.2", + "marked": "9.1.6", "mime-types": "2.1.35", "multer": "1.4.5-lts.1", "node-abi": "3.50.0", @@ -101,7 +101,7 @@ }, "devDependencies": { "cross-env": "7.0.3", - "electron": "25.9.2", + "electron": "25.9.5", "electron-builder": "24.6.4", "electron-packager": "17.1.2", "electron-rebuild": "3.2.9", diff --git a/src/services/search/expressions/attribute_exists.js b/src/services/search/expressions/attribute_exists.js index df4fa938d..6d2e92d64 100644 --- a/src/services/search/expressions/attribute_exists.js +++ b/src/services/search/expressions/attribute_exists.js @@ -10,6 +10,8 @@ class AttributeExistsExp extends Expression { this.attributeType = attributeType; this.attributeName = attributeName; + // template attr is used as a marker for templates, but it's not meant to be inherited + this.isTemplateLabel = this.attributeType === 'label' && (this.attributeName === 'template' || this.attributeName === 'workspacetemplate'); this.prefixMatch = prefixMatch; } @@ -23,12 +25,10 @@ class AttributeExistsExp extends Expression { for (const attr of attrs) { const note = attr.note; - if (attr.isInheritable) { + if (attr.isInheritable && !this.isTemplateLabel) { resultNoteSet.addAll(note.getSubtreeNotesIncludingTemplated()); } - else if (note.isInherited() && - // template attr is used as a marker for templates, but it's not meant to be inherited - !(this.attributeType === 'label' && (this.attributeName === 'template' || this.attributeName === 'workspacetemplate'))) { + else if (note.isInherited() && !this.isTemplateLabel) { resultNoteSet.addAll(note.getInheritingNotes()); } else { From 999cf0d9e31bcb8c5bd3e677ae4603d63b3efcd6 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 16 Nov 2023 00:21:34 +0100 Subject: [PATCH 2/4] release 0.61.14 --- package.json | 2 +- src/services/build.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b3dae2e6a..105242666 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.61.13", + "version": "0.61.14", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/services/build.js b/src/services/build.js index bf62de945..077c0a278 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2023-11-06T00:21:41+01:00", buildRevision: "531e9d4aff47b7e8332420645546d25ab28acf85" }; +module.exports = { buildDate:"2023-11-16T00:21:34+01:00", buildRevision: "0afc41060a935a46642a082128bea5002c2410e1" }; From 426a8f75aa3df819eba947f5279a823c9c6aceef Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 16 Nov 2023 23:31:33 +0100 Subject: [PATCH 3/4] fix creating tree cycle by moving clone into another clone, closes #4442 --- src/routes/api/branches.js | 6 +++--- src/services/branches.js | 20 +++++++++++--------- src/services/tree.js | 12 ++++++++---- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/routes/api/branches.js b/src/routes/api/branches.js index 0af2ae7a0..9a560d5c0 100644 --- a/src/routes/api/branches.js +++ b/src/routes/api/branches.js @@ -19,14 +19,14 @@ const ValidationError = require("../../errors/validation_error"); function moveBranchToParent(req) { const {branchId, parentBranchId} = req.params; - const parentBranch = becca.getBranch(parentBranchId); const branchToMove = becca.getBranch(branchId); + const targetParentBranch = becca.getBranch(parentBranchId); - if (!parentBranch || !branchToMove) { + if (!branchToMove || !targetParentBranch) { throw new ValidationError(`One or both branches '${branchId}', '${parentBranchId}' have not been found`); } - return branchService.moveBranchToBranch(branchToMove, parentBranch, branchId); + return branchService.moveBranchToBranch(branchToMove, targetParentBranch, branchId); } function moveBranchBeforeNote(req) { diff --git a/src/services/branches.js b/src/services/branches.js index f35db98df..681676ab1 100644 --- a/src/services/branches.js +++ b/src/services/branches.js @@ -1,12 +1,12 @@ const treeService = require("./tree"); const sql = require("./sql"); -function moveBranchToNote(sourceBranch, targetParentNoteId) { - if (sourceBranch.parentNoteId === targetParentNoteId) { +function moveBranchToNote(branchToMove, targetParentNoteId) { + if (branchToMove.parentNoteId === targetParentNoteId) { return {success: true}; // no-op } - const validationResult = treeService.validateParentChild(targetParentNoteId, sourceBranch.noteId, sourceBranch.branchId); + const validationResult = treeService.validateParentChild(targetParentNoteId, branchToMove.noteId, branchToMove.branchId); if (!validationResult.success) { return [200, validationResult]; @@ -15,10 +15,10 @@ function moveBranchToNote(sourceBranch, targetParentNoteId) { const maxNotePos = sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [targetParentNoteId]); const newNotePos = maxNotePos === null ? 0 : maxNotePos + 10; - const newBranch = sourceBranch.createClone(targetParentNoteId, newNotePos); + const newBranch = branchToMove.createClone(targetParentNoteId, newNotePos); newBranch.save(); - sourceBranch.markAsDeleted(); + branchToMove.markAsDeleted(); return { success: true, @@ -26,16 +26,18 @@ function moveBranchToNote(sourceBranch, targetParentNoteId) { }; } -function moveBranchToBranch(sourceBranch, targetParentBranch) { - const res = moveBranchToNote(sourceBranch, targetParentBranch.noteId); +function moveBranchToBranch(branchToMove, targetParentBranch) { + const res = moveBranchToNote(branchToMove, targetParentBranch.noteId); if (!res.success) { return res; } // expanding so that the new placement of the branch is immediately visible - targetParentBranch.isExpanded = true; - targetParentBranch.save(); + if (!targetParentBranch.isExpanded) { + targetParentBranch.isExpanded = true; + targetParentBranch.save(); + } return res; } diff --git a/src/services/tree.js b/src/services/tree.js index adc075f28..87a99d379 100644 --- a/src/services/tree.js +++ b/src/services/tree.js @@ -8,7 +8,7 @@ const becca = require('../becca/becca'); function validateParentChild(parentNoteId, childNoteId, branchId = null) { if (['root', '_hidden', '_share', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(childNoteId)) { - return { branch: null, success: false, message: `Cannot change this note's location.`}; + return { branch: null, success: false, message: `Cannot change this note's location.` }; } if (parentNoteId === 'none') { @@ -16,14 +16,14 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) { return { branch: null, success: false, message: `Cannot move anything into 'none' parent.` }; } - const existing = becca.getBranchFromChildAndParent(childNoteId, parentNoteId); + const existingBranch = becca.getBranchFromChildAndParent(childNoteId, parentNoteId); - if (existing && (branchId === null || existing.branchId !== branchId)) { + if (existingBranch && existingBranch.branchId !== branchId) { const parentNote = becca.getNote(parentNoteId); const childNote = becca.getNote(childNoteId); return { - branch: existing, + branch: existingBranch, success: false, message: `Note "${childNote.title}" note already exists in the "${parentNote.title}".` }; @@ -52,6 +52,10 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) { * Tree cycle can be created when cloning or when moving existing clone. This method should detect both cases. */ function wouldAddingBranchCreateCycle(parentNoteId, childNoteId) { + if (parentNoteId === childNoteId) { + return true; + } + const childNote = becca.getNote(childNoteId); const parentNote = becca.getNote(parentNoteId); From 23351298c8c6857227d8636a3b479ef8705789f2 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 16 Nov 2023 23:35:50 +0100 Subject: [PATCH 4/4] fix incorrect syntax/typo, closes #4443 --- src/public/app/services/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index e42207839..73ad58704 100644 --- a/src/public/app/services/link.js +++ b/src/public/app/services/link.js @@ -288,7 +288,7 @@ async function loadReferenceLinkTitle($el, href = null) { if (note) { const icon = await getLinkIcon(noteId, viewScope.viewMode); -k + $el.prepend($("").addClass(icon)); } }