mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 38723e0189 | ||
|  | 8c88ce6f65 | 
| @@ -2,7 +2,7 @@ | ||||
|   "name": "trilium", | ||||
|   "productName": "Trilium Notes", | ||||
|   "description": "Trilium Notes", | ||||
|   "version": "0.42.4", | ||||
|   "version": "0.42.5", | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "main": "electron.js", | ||||
|   "bin": { | ||||
|   | ||||
| @@ -39,13 +39,14 @@ export async function showDialog(noteIds) { | ||||
| } | ||||
|  | ||||
| async function cloneNotesTo(notePath) { | ||||
|     const targetNoteId = treeService.getNoteIdFromNotePath(notePath); | ||||
|     const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath); | ||||
|     const targetBranchId = await treeCache.getBranchId(parentNoteId, noteId); | ||||
|  | ||||
|     for (const cloneNoteId of clonedNoteIds) { | ||||
|         await branchService.cloneNoteTo(cloneNoteId, targetNoteId, $clonePrefix.val()); | ||||
|         await branchService.cloneNoteTo(cloneNoteId, targetBranchId, $clonePrefix.val()); | ||||
|  | ||||
|         const clonedNote = await treeCache.getNote(cloneNoteId); | ||||
|         const targetNote = await treeCache.getNote(targetNoteId); | ||||
|         const targetNote = await treeCache.getBranch(targetBranchId).getNote(); | ||||
|  | ||||
|         toastService.showMessage(`Note "${clonedNote.title}" has been cloned into ${targetNote.title}`); | ||||
|     } | ||||
| @@ -64,4 +65,4 @@ $form.on('submit', () => { | ||||
|     } | ||||
|  | ||||
|     return false; | ||||
| }); | ||||
| }); | ||||
|   | ||||
| @@ -32,10 +32,11 @@ export async function showDialog(branchIds) { | ||||
|     noteAutocompleteService.showRecentNotes($noteAutoComplete); | ||||
| } | ||||
|  | ||||
| async function moveNotesTo(parentNoteId) { | ||||
|     await branchService.moveToParentNote(movedBranchIds, parentNoteId); | ||||
| async function moveNotesTo(parentBranchId) { | ||||
|     await branchService.moveToParentNote(movedBranchIds, parentBranchId); | ||||
|  | ||||
|     const parentNote = await treeCache.getNote(parentNoteId); | ||||
|     const parentBranch = treeCache.getBranch(parentBranchId); | ||||
|     const parentNote = await parentBranch.getNote(); | ||||
|  | ||||
|     toastService.showMessage(`Selected notes have been moved into ${parentNote.title}`); | ||||
| } | ||||
| @@ -46,13 +47,12 @@ $form.on('submit', () => { | ||||
|     if (notePath) { | ||||
|         $dialog.modal('hide'); | ||||
|  | ||||
|         const noteId = treeService.getNoteIdFromNotePath(notePath); | ||||
|  | ||||
|         moveNotesTo(noteId); | ||||
|         const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath); | ||||
|         treeCache.getBranchId(parentNoteId, noteId).then(branchId => moveNotesTo(branchId)); | ||||
|     } | ||||
|     else { | ||||
|         console.error("No path to move to."); | ||||
|     } | ||||
|  | ||||
|     return false; | ||||
| }); | ||||
| }); | ||||
|   | ||||
| @@ -198,8 +198,8 @@ ws.subscribeToMessages(async message => { | ||||
|     } | ||||
| }); | ||||
|  | ||||
| async function cloneNoteTo(childNoteId, parentNoteId, prefix) { | ||||
|     const resp = await server.put('notes/' + childNoteId + '/clone-to/' + parentNoteId, { | ||||
| async function cloneNoteTo(childNoteId, parentBranchId, prefix) { | ||||
|     const resp = await server.put(`notes/${childNoteId}/clone-to/${parentBranchId}`, { | ||||
|         prefix: prefix | ||||
|     }); | ||||
|  | ||||
|   | ||||
| @@ -33,13 +33,13 @@ async function pasteAfter(afterBranchId) { | ||||
|     } | ||||
| } | ||||
|  | ||||
| async function pasteInto(parentNoteId) { | ||||
| async function pasteInto(parentBranchId) { | ||||
|     if (isClipboardEmpty()) { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     if (clipboardMode === 'cut') { | ||||
|         await branchService.moveToParentNote(clipboardBranchIds, parentNoteId); | ||||
|         await branchService.moveToParentNote(clipboardBranchIds, parentBranchId); | ||||
|  | ||||
|         clipboardBranchIds = []; | ||||
|         clipboardMode = null; | ||||
| @@ -50,7 +50,7 @@ async function pasteInto(parentNoteId) { | ||||
|         for (const clipboardBranch of clipboardBranches) { | ||||
|             const clipboardNote = await clipboardBranch.getNote(); | ||||
|  | ||||
|             await branchService.cloneNoteTo(clipboardNote.noteId, parentNoteId); | ||||
|             await branchService.cloneNoteTo(clipboardNote.noteId, parentBranchId); | ||||
|         } | ||||
|  | ||||
|         // copy will keep clipboardBranchIds and clipboardMode so it's possible to paste into multiple places | ||||
| @@ -89,4 +89,4 @@ export default { | ||||
|     cut, | ||||
|     copy, | ||||
|     isClipboardEmpty | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -746,6 +746,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | ||||
|         node.icon = this.getIcon(note, isFolder); | ||||
|         node.extraClasses = this.getExtraClasses(note); | ||||
|         node.title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title; | ||||
|         node.setExpanded(branch.isExpanded, {noEvents:true}); | ||||
|         node.renderTitle(); | ||||
|     } | ||||
|  | ||||
| @@ -1079,7 +1080,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | ||||
|         const toNode = node.getPrevSibling(); | ||||
|  | ||||
|         if (toNode !== null) { | ||||
|             branchService.moveToParentNote([node.data.branchId], toNode.data.noteId); | ||||
|             branchService.moveToParentNote([node.data.branchId], toNode.data.branchId); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -1164,7 +1165,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | ||||
|     } | ||||
|  | ||||
|     pasteNotesFromClipboardCommand({node}) { | ||||
|         clipboard.pasteInto(node.data.noteId); | ||||
|         clipboard.pasteInto(node.data.branchId); | ||||
|     } | ||||
|  | ||||
|     pasteNotesAfterFromClipboard({node}) { | ||||
|   | ||||
| @@ -3,10 +3,10 @@ | ||||
| const cloningService = require('../../services/cloning'); | ||||
|  | ||||
| async function cloneNoteToParent(req) { | ||||
|     const {noteId, parentNoteId} = req.params; | ||||
|     const {noteId, parentBranchId} = req.params; | ||||
|     const {prefix} = req.body; | ||||
|  | ||||
|     return await cloningService.cloneNoteToParent(noteId, parentNoteId, prefix); | ||||
|     return await cloningService.cloneNoteToParent(noteId, parentBranchId, prefix); | ||||
| } | ||||
|  | ||||
| async function cloneNoteAfter(req) { | ||||
| @@ -18,4 +18,4 @@ async function cloneNoteAfter(req) { | ||||
| module.exports = { | ||||
|     cloneNoteToParent, | ||||
|     cloneNoteAfter | ||||
| }; | ||||
| }; | ||||
|   | ||||
| @@ -152,7 +152,7 @@ function register(app) { | ||||
|  | ||||
|     apiRoute(GET, '/api/edited-notes/:date', noteRevisionsApiRoute.getEditedNotesOnDate); | ||||
|  | ||||
|     apiRoute(PUT, '/api/notes/:noteId/clone-to/:parentNoteId', cloningApiRoute.cloneNoteToParent); | ||||
|     apiRoute(PUT, '/api/notes/:noteId/clone-to/:parentBranchId', cloningApiRoute.cloneNoteToParent); | ||||
|     apiRoute(PUT, '/api/notes/:noteId/clone-after/:afterBranchId', cloningApiRoute.cloneNoteAfter); | ||||
|  | ||||
|     route(GET, '/api/notes/:branchId/export/:type/:format/:version/:taskId', [auth.checkApiAuthOrElectron], exportRoute.exportBranch); | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| module.exports = { buildDate:"2020-05-31T10:33:12+02:00", buildRevision: "50a28d8c5198606ee5d92696095c1c97397592e8" }; | ||||
| module.exports = { buildDate:"2020-05-31T23:33:30+02:00", buildRevision: "8c88ce6f651c3df1cd97925e5b8e3281ca4b1665" }; | ||||
|   | ||||
| @@ -9,12 +9,14 @@ const Branch = require('../entities/branch'); | ||||
| const TaskContext = require("./task_context.js"); | ||||
| const utils = require('./utils'); | ||||
|  | ||||
| async function cloneNoteToParent(noteId, parentNoteId, prefix) { | ||||
|     if (await isNoteDeleted(noteId) || await isNoteDeleted(parentNoteId)) { | ||||
| async function cloneNoteToParent(noteId, parentBranchId, prefix) { | ||||
|     const parentBranch = await repository.getBranch(parentBranchId); | ||||
|  | ||||
|     if (await isNoteDeleted(noteId) || await isNoteDeleted(parentBranch.noteId)) { | ||||
|         return { success: false, message: 'Note is deleted.' }; | ||||
|     } | ||||
|  | ||||
|     const validationResult = await treeService.validateParentChild(parentNoteId, noteId); | ||||
|     const validationResult = await treeService.validateParentChild(parentBranch.noteId, noteId); | ||||
|  | ||||
|     if (!validationResult.success) { | ||||
|         return validationResult; | ||||
| @@ -22,12 +24,13 @@ async function cloneNoteToParent(noteId, parentNoteId, prefix) { | ||||
|  | ||||
|     const branch = await new Branch({ | ||||
|         noteId: noteId, | ||||
|         parentNoteId: parentNoteId, | ||||
|         parentNoteId: parentBranch.noteId, | ||||
|         prefix: prefix, | ||||
|         isExpanded: 0 | ||||
|     }).save(); | ||||
|  | ||||
|     await sql.execute("UPDATE branches SET isExpanded = 1 WHERE noteId = ?", [parentNoteId]); | ||||
|     parentBranch.isExpanded = true; // the new target should be expanded so it immediately shows up to the user | ||||
|     await parentBranch.save(); | ||||
|  | ||||
|     return { success: true, branchId: branch.branchId }; | ||||
| } | ||||
| @@ -111,4 +114,4 @@ module.exports = { | ||||
|     ensureNoteIsAbsentFromParent, | ||||
|     toggleNoteInParent, | ||||
|     cloneNoteAfter | ||||
| }; | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user