Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Merge branch 'master' into next60
zadamb84670d503fd
diff --cc src/becca/entities/bnote.jsindex 8c87dc09e2,b8e58c740f..6139f7fa77--- a/src/becca/entities/bnote.js+++ b/src/becca/entities/bnote.js@@@ -1096,28 -1164,9 +1111,30 @@@ class BNote extends AbstractBeccaEntit.map(row => new BNoteRevision(row));}+ /** @returns {BAttachment[]} */+ getAttachments() {+ return sql.getRows(`+ SELECT attachments.*+ FROM attachments+ WHERE parentId = ?+ AND isDeleted = 0`, [this.noteId])+ .map(row => new BAttachment(row));+ }++ /** @returns {BAttachment|null} */+ getAttachmentById(attachmentId) {+ return sql.getRows(`+ SELECT attachments.*+ FROM attachments+ WHERE parentId = ?+ AND attachmentId = ?+ AND isDeleted = 0`, [this.noteId, attachmentId])+ .map(row => new BAttachment(row))[0];+ }+/**+ * Gives all possible note paths leading to this note. Paths containing search note are ignored (could form cycles)+ ** @returns {string[][]} - array of notePaths (each represented by array of noteIds constituting the particular note path)*/getAllNotePaths() {diff --cc src/public/app/services/tree.jsindex 2cc5803d98,88f13cdded..60e862f972--- a/src/public/app/services/tree.js+++ b/src/public/app/services/tree.js@@@ -368,8 -308,7 +338,7 @@@ export defaultgetNoteTitle,getNotePathTitle,getNoteTitleWithPathAsSuffix,- getHashValueFromAddress,+ parseNavigationStateFromAddress,isNotePathInAddress,- parseNotePath,isNotePathInHiddenSubtree};diff --cc src/routes/routes.jsindex 5338de0297,a52a067f5e..8bb865abbe--- a/src/routes/routes.js+++ b/src/routes/routes.js@@@ -120,15 -127,31 +120,15 @@@ function register(app)apiRoute(PUT, '/api/notes/:noteId/sort-children', notesApiRoute.sortChildNotes);apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectNote);apiRoute(PUT, '/api/notes/:noteId/type', notesApiRoute.setNoteTypeMime);- apiRoute(GET, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.getNoteRevisions);- apiRoute(DELETE, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.eraseAllNoteRevisions);- apiRoute(GET, '/api/notes/:noteId/revisions/:noteRevisionId', noteRevisionsApiRoute.getNoteRevision);- apiRoute(DELETE, '/api/notes/:noteId/revisions/:noteRevisionId', noteRevisionsApiRoute.eraseNoteRevision);- route(GET, '/api/notes/:noteId/revisions/:noteRevisionId/download', [auth.checkApiAuthOrElectron], noteRevisionsApiRoute.downloadNoteRevision);- apiRoute(PUT, '/api/notes/:noteId/restore-revision/:noteRevisionId', noteRevisionsApiRoute.restoreNoteRevision);- apiRoute(POST, '/api/notes/relation-map', notesApiRoute.getRelationMap);- apiRoute(POST, '/api/notes/erase-deleted-notes-now', notesApiRoute.eraseDeletedNotesNow);apiRoute(PUT, '/api/notes/:noteId/title', notesApiRoute.changeTitle);- apiRoute(POST, '/api/notes/:noteId/duplicate/:parentNoteId', notesApiRoute.duplicateSubtree);- apiRoute(POST, '/api/notes/:noteId/upload-modified-file', notesApiRoute.uploadModifiedFile);-- apiRoute(GET, '/api/edited-notes/:date', noteRevisionsApiRoute.getEditedNotesOnDate);-+ apiRoute(PST, '/api/notes/:noteId/duplicate/:parentNoteId', notesApiRoute.duplicateSubtree);+ apiRoute(PST, '/api/notes/:noteId/upload-modified-file', notesApiRoute.uploadModifiedFile);apiRoute(PUT, '/api/notes/:noteId/clone-to-branch/:parentBranchId', cloningApiRoute.cloneNoteToBranch);apiRoute(PUT, '/api/notes/:noteId/toggle-in-parent/:parentNoteId/:present', cloningApiRoute.toggleNoteInParent);- apiRoute(PUT, '/api/notes/:noteId/clone-to-note/:parentNoteId', cloningApiRoute.cloneNoteToNote);+ apiRoute(PUT, '/api/notes/:noteId/clone-to-note/:parentNoteId', cloningApiRoute.cloneNoteToParentNote);apiRoute(PUT, '/api/notes/:noteId/clone-after/:afterBranchId', cloningApiRoute.cloneNoteAfter);-- route(GET, '/api/notes/:branchId/export/:type/:format/:version/:taskId', [auth.checkApiAuthOrElectron], exportRoute.exportBranch);- route(POST, '/api/notes/:parentNoteId/import', [auth.checkApiAuthOrElectron, uploadMiddlewareWithErrorHandling, csrfMiddleware], importRoute.importToBranch, apiResultHandler);-route(PUT, '/api/notes/:noteId/file', [auth.checkApiAuthOrElectron, uploadMiddlewareWithErrorHandling, csrfMiddleware],filesRoute.updateFile, apiResultHandler);-route(GET, '/api/notes/:noteId/open', [auth.checkApiAuthOrElectron], filesRoute.openFile);route(GET, '/api/notes/:noteId/open-partial', [auth.checkApiAuthOrElectron],createPartialContentHandler(filesRoute.fileContentProvider, {diff --cc src/services/notes.jsindex 5b92ee6d04,f3d2191458..89551433c4--- a/src/services/notes.js+++ b/src/services/notes.js@@@ -20,8 -21,8 +20,9 @@@ const dayjs = require("dayjs")const htmlSanitizer = require("./html_sanitizer");const ValidationError = require("../errors/validation_error");const noteTypesService = require("./note_types");+ const fs = require("fs");+/** @param {BNote} parentNote */function getNewNotePosition(parentNote) {if (parentNote.isLabelTruthy('newNotesOnTop')) {const minNotePos = parentNote.getChildBranches()